public function deleteRule(Vtiger_Request $request)
 {
     $forModule = $request->get('for_module');
     $ruleId = $request->get('record');
     $moduleModel = Settings_SharingAccess_Module_Model::getInstance($forModule);
     $ruleModel = Settings_SharingAccess_Rule_Model::getInstance($moduleModel, $ruleId);
     $response = new Vtiger_Response();
     $response->setEmitType(Vtiger_Response::$EMIT_JSON);
     try {
         $ruleModel->delete();
     } catch (AppException $e) {
         $response->setError('Deleting Sharing Access Rule failed');
     }
     $response->emit();
 }
Exemple #2
0
 public function process(Vtiger_Request $request)
 {
     $modulePermissions = $request->get('permissions');
     $modulePermissions[4] = $modulePermissions[6];
     foreach ($modulePermissions as $tabId => $permission) {
         $moduleModel = Settings_SharingAccess_Module_Model::getInstance($tabId);
         $moduleModel->set('permission', $permission);
         try {
             $moduleModel->save();
         } catch (AppException $e) {
         }
     }
     Settings_SharingAccess_Module_Model::recalculateSharingRules();
     $response = new Vtiger_Response();
     $response->setEmitType(Vtiger_Response::$EMIT_JSON);
     $response->emit();
 }
Exemple #3
0
 public function editRule(Vtiger_Request $request)
 {
     $viewer = $this->getViewer($request);
     $moduleName = $request->getModule();
     $qualifiedModuleName = $request->getModule(false);
     $forModule = $request->get('for_module');
     $ruleId = $request->get('record');
     $moduleModel = Settings_SharingAccess_Module_Model::getInstance($forModule);
     if ($ruleId) {
         $ruleModel = Settings_SharingAccess_Rule_Model::getInstance($moduleModel, $ruleId);
     } else {
         $ruleModel = new Settings_SharingAccess_Rule_Model();
         $ruleModel->setModuleFromInstance($moduleModel);
     }
     $viewer->assign('ALL_RULE_MEMBERS', Settings_SharingAccess_RuleMember_Model::getAll());
     $viewer->assign('ALL_PERMISSIONS', Settings_SharingAccess_Rule_Model::$allPermissions);
     $viewer->assign('MODULE_MODEL', $moduleModel);
     $viewer->assign('RULE_MODEL', $ruleModel);
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName);
     $viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel());
     echo $viewer->view('EditRule.tpl', $qualifiedModuleName, true);
 }
Exemple #4
0
 /**
  * Function returns List of Accessible Users for a Module
  * @param <String> $module
  * @return <Array of Users_Record_Model>
  */
 public function getAccessibleGroupForModule($module)
 {
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $curentUserPrivileges = Users_Privileges_Model::getCurrentUserPrivilegesModel();
     if ($currentUser->isAdminUser() || $curentUserPrivileges->hasGlobalWritePermission()) {
         $groups = $this->getAccessibleGroups("", $module);
     } else {
         $sharingAccessModel = Settings_SharingAccess_Module_Model::getInstance($module);
         if ($sharingAccessModel && $sharingAccessModel->isPrivate()) {
             $groups = $this->getAccessibleGroups('private', $module);
         } else {
             $groups = $this->getAccessibleGroups("", $module);
         }
     }
     return $groups;
 }
Exemple #5
0
 /**
  * Function to get where condition query for dashboards
  * @param <Integer> $owner
  * @return <String> query
  */
 public function getOwnerWhereConditionForDashBoards($owner)
 {
     $currentUserModel = Users_Record_Model::getCurrentUserModel();
     $sharingAccessModel = Settings_SharingAccess_Module_Model::getInstance($this->getName());
     $params = array();
     if (!empty($owner) && $currentUserModel->isAdminUser()) {
         //If admin user, then allow users data
         $ownerSql = ' smownerid = ' . $owner;
         $params[] = $owner;
     } else {
         if (!empty($owner)) {
             //If not admin user, then check sharing access for that module
             if ($sharingAccessModel->isPrivate()) {
                 $subordinateUserModels = $currentUserModel->getSubordinateUsers();
                 $subordinateUsers = array();
                 foreach ($subordinateUserModels as $id => $name) {
                     $subordinateUsers[] = $id;
                 }
                 if (in_array($owner, $subordinateUsers)) {
                     $ownerSql = ' smownerid = ' . $owner;
                 } else {
                     $ownerSql = ' smownerid = ' . $currentUserModel->getId();
                 }
             } else {
                 $ownerSql = ' smownerid = ' . $owner;
             }
         } else {
             //If no owner filter, then check if the module access is Private
             if ($sharingAccessModel->isPrivate() && !$currentUserModel->isAdminUser()) {
                 $subordinateUserModels = $currentUserModel->getSubordinateUsers();
                 foreach ($subordinateUserModels as $id => $name) {
                     $subordinateUsers[] = $id;
                     $params[] = $id;
                 }
                 if ($subordinateUsers) {
                     $ownerSql = ' smownerid IN (' . implode(',', $subordinateUsers) . ')';
                 } else {
                     $ownerSql = ' smownerid = ' . $currentUserModel->getId();
                 }
             }
         }
     }
     return $ownerSql;
 }
Exemple #6
0
 public function setModule($moduleName)
 {
     $module = Settings_SharingAccess_Module_Model::getInstance($moduleName);
     $this->module = $module;
     return $this;
 }