function deleteUserRelatedSharingRules($usId) { $log = vglobal('log'); $log->debug("Entering deleteGroupRelatedSharingRules(" . $usId . ") method ..."); $adb = PearDatabase::getInstance(); $dataShareTableColArr = ['vtiger_datashare_us2us' => 'share_userid::to_userid', 'vtiger_datashare_us2grp' => 'share_userid', 'vtiger_datashare_us2role' => 'share_userid', 'vtiger_datashare_us2rs' => 'share_userid', 'vtiger_datashare_grp2us' => 'to_userid', 'vtiger_datashare_rs2us' => 'to_userid', 'vtiger_datashare_role2us' => 'to_userid']; foreach ($dataShareTableColArr as $tablename => $colname) { $colNameArr = explode('::', $colname); $query = "select shareid from " . $tablename . " where " . $colNameArr[0] . "=?"; $params = array($grpId); if (sizeof($colNameArr) > 1) { $query .= " or " . $colNameArr[1] . "=?"; array_push($params, $grpId); } $result = $adb->pquery($query, $params); $num_rows = $adb->num_rows($result); for ($i = 0; $i < $num_rows; $i++) { $shareid = $adb->query_result($result, $i, 'shareid'); deleteSharingRule($shareid); } } $log->debug('Exiting deleteGroupRelatedSharingRules method ...'); }
<?php /*+******************************************************************************** * The contents of this file are subject to the vtiger CRM Public License Version 1.0 * ("License"); You may not use this file except in compliance with the License * The Original Code is: vtiger CRM Open Source * The Initial Developer of the Original Code is vtiger. * Portions created by vtiger are Copyright (C) vtiger. * All Rights Reserved. ********************************************************************************/ require_once 'include/utils/UserInfoUtil.php'; global $adb; $shareid = $_REQUEST['shareid']; deleteSharingRule($shareid); header("Location: index.php?module=Settings&action=OrgSharingDetailView&parenttab=Settings");