/** This function is to delete the organisation level sharing rule * It takes the following input parameters: * $shareid -- Id of the Sharing Rule to be updated */ function deleteSharingRule($shareid) { $log = vglobal('log'); $log->debug("Entering deleteSharingRule(" . $shareid . ") method ..."); $adb = PearDatabase::getInstance(); $query2 = "select * from vtiger_datashare_module_rel where shareid=?"; $res = $adb->pquery($query2, array($shareid)); $typestr = $adb->query_result($res, 0, 'relationtype'); $tabname = getDSTableNameForType($typestr); $query3 = "delete from {$tabname} where shareid=?"; $adb->pquery($query3, array($shareid)); $query4 = "delete from vtiger_datashare_module_rel where shareid=?"; $adb->pquery($query4, array($shareid)); //deleting the releated module sharing permission $query5 = "delete from vtiger_datashare_relatedmodule_permission where shareid=?"; $adb->pquery($query5, array($shareid)); $log->debug("Exiting deleteSharingRule method ..."); }
/** Function to get the Sharing rule Info * @param $shareId -- Sharing Rule Id * @returns Sharing Rule Information Array in the following format: * $shareRuleInfoArr=Array($shareId, $tabid, $type, $share_ent_type, $to_ent_type, $share_entity_id, $to_entity_id,$permission); */ function getSharingRuleInfo($shareId) { global $log; $log->debug("Entering getSharingRuleInfo(" . $shareId . ") method ..."); global $adb; $shareRuleInfoArr = array(); $query = "select * from vtiger_datashare_module_rel where shareid=?"; $result = $adb->pquery($query, array($shareId)); //Retreving the Sharing Tabid $tabid = $adb->query_result($result, 0, 'tabid'); $type = $adb->query_result($result, 0, 'relationtype'); //Retreiving the Sharing Table Name $tableName = getDSTableNameForType($type); //Retreiving the Sharing Col Names $dsTableColArr = getDSTableColumns($tableName); $share_ent_col = $dsTableColArr[0]; $to_ent_col = $dsTableColArr[1]; //Retreiving the Sharing Entity Col Types $share_ent_type = getEntityTypeFromCol($share_ent_col); $to_ent_type = getEntityTypeFromCol($to_ent_col); //Retreiving the Value from Table $query1 = "select * from {$tableName} where shareid=?"; $result1 = $adb->pquery($query1, array($shareId)); $share_id = $adb->query_result($result1, 0, $share_ent_col); $to_id = $adb->query_result($result1, 0, $to_ent_col); $permission = $adb->query_result($result1, 0, 'permission'); //Constructing the Array $shareRuleInfoArr[] = $shareId; $shareRuleInfoArr[] = $tabid; $shareRuleInfoArr[] = $type; $shareRuleInfoArr[] = $share_ent_type; $shareRuleInfoArr[] = $to_ent_type; $shareRuleInfoArr[] = $share_id; $shareRuleInfoArr[] = $to_id; $shareRuleInfoArr[] = $permission; $log->debug("Exiting getSharingRuleInfo method ..."); return $shareRuleInfoArr; }