<commit_before><?php
/*=========================================================================
 MIDAS Server
 Copyright (c) Kitware SAS. 26 rue <NAME>. 69100 Villeurbanne, FRANCE
 All rights reserved.
 More information http://www.kitware.com

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0.txt

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
=========================================================================*/

/** Share Controller */
class ShareController extends AppController
  {
  public $_models = array('Item', 'Folder', 'Group', 'Folderpolicygroup', 'Folderpolicyuser', 'Itempolicygroup', 'Itempolicyuser', 'User', 'Community');
  public $_daos = array();
  public $_components = array('Policy');
  public $_forms = array();

  /** Init Controller */
  function init()
    {

    } // end init()


  /** ajax dialog for managing permissions */
  function dialogAction()
    {
    $this->disableLayout();
    $type = $this->_getParam('type');
    $element = $this->_getParam('element');
    if(!isset($type) || !isset($element))
      {
      throw new Zend_Exception("Parameters problem.");
      }

    switch($type)
      {
      case 'folder':
        $element = $this->Folder->load($element);
        break;
      case 'item':
        $element = $this->Item->load($element);
        break;
      default:
        throw new Zend_Exception("Unknown type.");
        break;
      }

    if($element == false)
      {
      throw new Zend_Exception("Unable to load element.");
      }

    if($type == 'folder')
      {
      $isAdmin = $this->Folder->policyCheck($element, $this->userSession->Dao, MIDAS_POLICY_ADMIN);
      }
    else
      {
      $isAdmin = $this->Item->policyCheck($element, $this->userSession->Dao, MIDAS_POLICY_ADMIN);
      }
    if(!$isAdmin)
      {
      throw new Zend_Exception('Admin privileges required to change permissions');
      }
    

    if($this->_request->isPost())
      {
      $this->_helper->viewRenderer->setNoRender();<commit_msg>STYLE: refs #0407. Fix trailing whitespace<commit_after><?php
/*=========================================================================
 MIDAS Server
 Copyright (c) Kitware SAS. 26 rue <NAME>. 69100 Villeurbanne, FRANCE
 All rights reserved.
 More information http://www.kitware.com

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0.txt

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
=========================================================================*/

/** Share Controller */
class ShareController extends AppController
  {
  public $_models = array('Item', 'Folder', 'Group', 'Folderpolicygroup', 'Folderpolicyuser', 'Itempolicygroup', 'Itempolicyuser', 'User', 'Community');
  public $_daos = array();
  public $_components = array('Policy');
  public $_forms = array();

  /** Init Controller */
  function init()
    {

    } // end init()


  /** ajax dialog for managing permissions */
  function dialogAction()
    {
    $this->disableLayout();
    $type = $this->_getParam('type');
    $element = $this->_getParam('element');
    if(!isset($type) || !isset($element))
      {
      throw new Zend_Exception("Parameters problem.");
      }

    switch($type)
      {
      case 'folder':
        $element = $this->Folder->load($element);
        break;
      case 'item':
        $element = $this->Item->load($element);
        break;
      default:
        throw new Zend_Exception("Unknown type.");
        break;
      }

    if($element == false)
      {
      throw new Zend_Exception("Unable to load element.");
      }

    if($type == 'folder')
      {
      $isAdmin = $this->Folder->policyCheck($element, $this->userSession->Dao, MIDAS_POLICY_ADMIN);
      }
    else
      {
      $isAdmin = $this->Item->policyCheck($element, $this->userSession->Dao, MIDAS_POLICY_ADMIN);
      }
    if(!$isAdmin)
      {
      throw new Zend_Exception('Admin privileges required to change permissions');
      }

    if($this->_request->isPost())
      {
      $this->_helper->viewRenderer->setNoRender();
{'fraction_non_alphanumeric': 0.18354430379746836, 'fraction_numerical': 0.005308289097590854, 'mean_word_length': 3.2674216027874565, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4806176', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1264, 'n_words': 392}