• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/main.php
  • Класс: CAllMain
  • Вызов: CAllMain::DelGroupRight
static function DelGroupRight($module_id='', $arGroups=array(), $site_id=false)
{
	global $DB;

	$strSql = '';

	$sGroups = '';
	if(is_array($arGroups) && !empty($arGroups))
		foreach($arGroups as $grp)
			$sGroups .= ($sGroups <> ''? ',':'').intval($grp);

	if($module_id <> '')
	{
		if($sGroups <> '')
		{
			if(COption::GetOptionString("main", "event_log_module_access", "N") === "Y")
			{
				//get old value
				$rsRight = $DB->Query("SELECT GROUP_ID, G_ACCESS FROM b_module_group WHERE MODULE_ID='".$DB->ForSql($module_id,50)."' AND GROUP_ID IN (".$sGroups.") AND SITE_ID ".($site_id ? "= '".$DB->ForSql($site_id)."'" : "IS NULL"));
				while($arRight = $rsRight->Fetch())
					CEventLog::Log("SECURITY", "MODULE_RIGHTS_CHANGED", "main", $arRight["GROUP_ID"], $module_id.($site_id ? "/".$site_id : "").": (".$arRight["G_ACCESS"].") => ()");
			}
			$strSql = "DELETE FROM b_module_group WHERE MODULE_ID='".$DB->ForSql($module_id,50)."' and GROUP_ID in (".$sGroups.") AND SITE_ID ".($site_id ? "= '".$DB->ForSql($site_id)."'" : "IS NULL");
		}
		else
		{
			//on delete module
			$strSql = "DELETE FROM b_module_group WHERE MODULE_ID='".$DB->ForSql($module_id,50)."' AND SITE_ID ".($site_id ? "= '".$DB->ForSql($site_id)."'" : "IS NULL");
		}
	}
	elseif($sGroups <> '')
	{
		//on delete user group
		$strSql = "DELETE FROM b_module_group WHERE GROUP_ID in (".$sGroups.") AND SITE_ID ".($site_id ? "= '".$DB->ForSql($site_id)."'" : "IS NULL");
	}

	if($strSql <> '')
	{
		$DB->Query($strSql);

		ModuleGroupTable::cleanCache();

		foreach (GetModuleEvents("main", "OnAfterDelGroupRight", true) as $arEvent)
		{
			ExecuteModuleEventEx($arEvent, array($module_id, $arGroups));
		}
	}
}