[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/modules/Settings/SharingAccess/actions/ -> IndexAjax.php (source)

   1  <?php
   2  /*+***********************************************************************************
   3   * The contents of this file are subject to the vtiger CRM Public License Version 1.0
   4   * ("License"); You may not use this file except in compliance with the License
   5   * The Original Code is:  vtiger CRM Open Source
   6   * The Initial Developer of the Original Code is vtiger.
   7   * Portions created by vtiger are Copyright (C) vtiger.
   8   * All Rights Reserved.
   9   *************************************************************************************/
  10  
  11  Class Settings_SharingAccess_IndexAjax_Action extends Settings_Vtiger_IndexAjax_View {
  12  
  13  	function __construct() {
  14          parent::__construct();
  15          $this->exposeMethod('saveRule');
  16          $this->exposeMethod('deleteRule');
  17      }
  18  
  19  	public function process(Vtiger_Request $request) {
  20          $mode = $request->get('mode');
  21          if(!empty($mode)) {
  22              $this->invokeExposedMethod($mode, $request);
  23              return;
  24          }
  25      }
  26  
  27  	public function saveRule(Vtiger_Request $request) {
  28          $forModule = $request->get('for_module');
  29          $ruleId = $request->get('record');
  30  
  31          $moduleModel = Settings_SharingAccess_Module_Model::getInstance($forModule);
  32          if(empty($ruleId)) {
  33              $ruleModel = new Settings_SharingAccess_Rule_Model();
  34              $ruleModel->setModuleFromInstance($moduleModel);
  35          }else {
  36              $ruleModel = Settings_SharingAccess_Rule_Model::getInstance($moduleModel, $ruleId);
  37          }
  38  
  39          $ruleModel->set('source_id', $request->get('source_id'));
  40          $ruleModel->set('target_id', $request->get('target_id'));
  41          $ruleModel->set('permission', $request->get('permission'));
  42  
  43          $response = new Vtiger_Response();
  44          $response->setEmitType(Vtiger_Response::$EMIT_JSON);
  45          try {
  46              $ruleModel->save();
  47          } catch (AppException $e) {
  48              $response->setError('Saving Sharing Access Rule failed');
  49          }
  50          $response->emit();
  51      }
  52  
  53  	public function deleteRule(Vtiger_Request $request) {
  54          $forModule = $request->get('for_module');
  55          $ruleId = $request->get('record');
  56  
  57          $moduleModel = Settings_SharingAccess_Module_Model::getInstance($forModule);
  58          $ruleModel = Settings_SharingAccess_Rule_Model::getInstance($moduleModel, $ruleId);
  59  
  60          $response = new Vtiger_Response();
  61          $response->setEmitType(Vtiger_Response::$EMIT_JSON);
  62          try {
  63              $ruleModel->delete();
  64          } catch (AppException $e) {
  65              $response->setError('Deleting Sharing Access Rule failed');
  66          }
  67          $response->emit();
  68      }
  69          
  70          public function validateRequest(Vtiger_Request $request) { 
  71              $request->validateWriteAccess(); 
  72          } 
  73  }


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1