示例#1
0
 /**
  * Function to delete the role
  * @param <Settings_Roles_Record_Model> $transferToRole
  */
 public function delete($transferToRole)
 {
     $db = PearDatabase::getInstance();
     $roleId = $this->getId();
     $transferRoleId = $transferToRole->getId();
     $db->pquery('UPDATE vtiger_user2role SET roleid=? WHERE roleid=?', array($transferRoleId, $roleId));
     $db->pquery('DELETE FROM vtiger_role2profile WHERE roleid=?', array($roleId));
     $db->pquery('DELETE FROM vtiger_group2role WHERE roleid=?', array($roleId));
     $db->pquery('DELETE FROM vtiger_group2rs WHERE roleandsubid=?', array($roleId));
     //delete handling for sharing rules
     deleteRoleRelatedSharingRules($roleId);
     $db->pquery('DELETE FROM vtiger_role WHERE roleid=?', array($roleId));
     $allChildren = $this->getAllChildren();
     $transferParentRoleSequence = $transferToRole->getParentRoleString();
     $currentParentRoleSequence = $this->getParentRoleString();
     foreach ($allChildren as $roleId => $roleModel) {
         $oldChildParentRoleString = $roleModel->getParentRoleString();
         $newChildParentRoleString = str_replace($currentParentRoleSequence, $transferParentRoleSequence, $oldChildParentRoleString);
         $newChildDepth = count(explode('::', $newChildParentRoleString)) - 1;
         $roleModel->set('depth', $newChildDepth);
         $roleModel->set('parentrole', $newChildParentRoleString);
         $roleModel->save();
     }
 }
示例#2
0
 /**
  * Function to delete the role
  * @param <Settings_Roles_Record_Model> $transferToRole
  */
 public function delete($transferToRole)
 {
     $db = PearDatabase::getInstance();
     $roleId = $this->getId();
     $transferRoleId = $transferToRole->getId();
     $db->pquery('UPDATE vtiger_user2role SET roleid=? WHERE roleid=?', array($transferRoleId, $roleId));
     $db->pquery('DELETE FROM vtiger_role2profile WHERE roleid=?', array($roleId));
     $db->pquery('DELETE FROM vtiger_group2role WHERE roleid=?', array($roleId));
     $db->pquery('DELETE FROM vtiger_group2rs WHERE roleandsubid=?', array($roleId));
     /*
      $noOfUsers = $db->num_rows($user_result);
      $array_users = array();
      if($noOfUsers > 0) {
      for($i=0; $i<$noOfUsers; ++$i) {
      $array_users[] = $db->query_result($user_result, $i, 'userid');
      }
      }
     */
     //delete handling for sharing rules
     deleteRoleRelatedSharingRules($roleId);
     $db->pquery('DELETE FROM vtiger_role WHERE roleid=?', array($roleId));
     $allChildren = $this->getAllChildren();
     $transferParentRoleSequence = $transferToRole->getParentRoleString();
     $currentParentRoleSequence = $this->getParentRoleString();
     foreach ($allChildren as $roleId => $roleModel) {
         $oldChildParentRoleString = $roleModel->getParentRoleString();
         $newChildParentRoleString = str_replace($currentParentRoleSequence, $transferParentRoleSequence, $oldChildParentRoleString);
         $newChildDepth = count(explode('::', $newChildParentRoleString)) - 1;
         $roleModel->set('depth', $newChildDepth);
         $roleModel->set('parentrole', $newChildParentRoleString);
         $roleModel->save();
     }
     if (is_array($array_users)) {
         require_once 'modules/Users/CreateUserPrivilegeFile.php';
         foreach ($array_users as $userid) {
             createUserPrivilegesfile($userid);
             createUserSharingPrivilegesfile($userid);
         }
     }
 }
示例#3
0
/** Function to get delete the spcified vtiger_role
 * @param $roleid -- RoleId :: Type varchar
 * @param $transferRoleId -- RoleId to which vtiger_users of the vtiger_role that is being deleted are transferred:: Type varchar
 */
function deleteRole($roleId, $transferRoleId)
{
    global $log;
    $log->debug("Entering deleteRole(" . $roleId . "," . $transferRoleId . ") method ...");
    global $adb;
    $roleInfo = getRoleAndSubordinatesInformation($roleId);
    foreach ($roleInfo as $roleid => $roleDetArr) {
        $sql1 = "update vtiger_user2role set roleid=? where roleid=?";
        $adb->pquery($sql1, array($transferRoleId, $roleid));
        //Deleteing from vtiger_role2profile vtiger_table
        $sql2 = "delete from vtiger_role2profile where roleid=?";
        $adb->pquery($sql2, array($roleid));
        //delete handling for vtiger_groups
        $sql10 = "delete from vtiger_group2role where roleid=?";
        $adb->pquery($sql10, array($roleid));
        $sql11 = "delete from vtiger_group2rs where roleandsubid=?";
        $adb->pquery($sql11, array($roleid));
        //delete handling for sharing rules
        deleteRoleRelatedSharingRules($roleid);
        //delete from vtiger_role vtiger_table;
        $sql9 = "delete from vtiger_role where roleid=?";
        $adb->pquery($sql9, array($roleid));
    }
    $log->debug("Exiting deleteRole method ...");
}
示例#4
0
 public function delete($role)
 {
     $db = PearDatabase::getInstance();
     $db->dieOnError = true;
     $sql = "update vtiger_user2role set roleid=? where roleid=?";
     $db->pquery($sql, array($role->getId(), $this->getId()));
     //Deleteing from vtiger_role2profile vtiger_table
     $sql = "delete from vtiger_role2profile where roleid=?";
     $db->pquery($sql, array($this->getId()));
     //delete handling for vtiger_groups
     $sql = "delete from vtiger_group2role where roleid=?";
     $db->pquery($sql, array($this->getId()));
     $sql = "delete from vtiger_group2rs where roleandsubid=?";
     $db->pquery($sql, array($this->getId()));
     //delete handling for sharing rules
     deleteRoleRelatedSharingRules($this->getId());
     //delete from vtiger_role vtiger_table;
     $sql = "delete from vtiger_role where roleid=?";
     $db->pquery($sql, array($this->getId()));
     $targetParentRoleSequence = $role->getParentRole();
     $parentRoleSequence = $this->getParentRole();
     $roleInfoList = getRoleAndSubordinatesInformation($roleId);
     foreach ($roleInfoList as $roleId => $roleInfo) {
         // Invalidate any cached information
         VTCacheUtils::clearRoleSubordinates($roleId);
         if ($roleId == $this->getId()) {
             continue;
         }
         $currentParentRoleSequence = $roleInfo[1];
         $currentParentRoleSequence = str_replace($parentRoleSequence, $targetParentRoleSequence, $currentParentRoleSequence);
         $subDepth = count(explode('::', $currentParentRoleSequence)) - 1;
         $query = "update vtiger_role set parentrole=?,depth=? where roleid=?";
         $db->pquery($query, array($currentParentRoleSequence, $subDepth, $roleId));
     }
 }