Exemplo n.º 1
0
$toid = $_REQUEST['parentId'];
$fromid = $_REQUEST['childId'];
global $adb, $mod_strings;
$query = "select * from vtiger_role where roleid=?";
$result = $adb->pquery($query, array($toid));
$parentRoleList = $adb->query_result($result, 0, 'parentrole');
$replace_with = $parentRoleList;
$orgDepth = $adb->query_result($result, 0, 'depth');
//echo 'replace with is '.$replace_with;
//echo '<BR>org depth '.$orgDepth;
$parentRoles = explode('::', $parentRoleList);
if (in_array($fromid, $parentRoles)) {
    echo $mod_strings['ROLE_DRAG_ERR_MSG'];
    die;
}
$roleInfo = getRoleAndSubordinatesInformation($fromid);
$fromRoleInfo = $roleInfo[$fromid];
$replaceToStringArr = explode('::' . $fromid, $fromRoleInfo[1]);
$replaceToString = $replaceToStringArr[0];
//echo '<BR>to be replaced string '.$replaceToString;
$stdDepth = $fromRoleInfo['2'];
//echo '<BR> std depth '.$stdDepth;
//Constructing the query
foreach ($roleInfo as $mvRoleId => $mvRoleInfo) {
    $subPar = explode($replaceToString, $mvRoleInfo[1], 2);
    //we have to spilit as two elements only
    $mvParString = $replace_with . $subPar[1];
    $subDepth = $mvRoleInfo[2];
    $mvDepth = $orgDepth + ($subDepth - $stdDepth + 1);
    $query = "update vtiger_role set parentrole=?,depth=? where roleid=?";
    //echo $query;
Exemplo n.º 2
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 ...");
}
Exemplo n.º 3
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));
     }
 }