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 '
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 '
to be replaced string '.$replaceToString; $stdDepth=$fromRoleInfo['2']; //echo '
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; $adb->pquery($query, array($mvParString, $mvDepth, $mvRoleId)); // Invalidate any cached information VTCacheUtils::clearRoleSubordinates($roleId); } header("Location: index.php?action=SettingsAjax&module=Settings&file=listroles&ajax=true"); ?>