本文整理汇总了PHP中CUser::clearUserGroupCache方法的典型用法代码示例。如果您正苦于以下问题:PHP CUser::clearUserGroupCache方法的具体用法?PHP CUser::clearUserGroupCache怎么用?PHP CUser::clearUserGroupCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUser
的用法示例。
在下文中一共展示了CUser::clearUserGroupCache方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Add
public function Add($arFields)
{
/** @global CMain $APPLICATION */
global $DB, $APPLICATION;
if (!$this->CheckFields($arFields)) {
return false;
}
foreach (GetModuleEvents("main", "OnBeforeGroupAdd", true) as $arEvent) {
$bEventRes = ExecuteModuleEventEx($arEvent, array(&$arFields));
if ($bEventRes === false) {
if ($err = $APPLICATION->GetException()) {
$this->LAST_ERROR .= $err->GetString() . "<br>";
} else {
$this->LAST_ERROR .= "Unknown error in OnBeforeGroupAdd handler." . "<br>";
}
return false;
}
}
if (is_set($arFields, "ACTIVE") && $arFields["ACTIVE"] != "Y") {
$arFields["ACTIVE"] = "N";
}
$arInsert = $DB->PrepareInsert("b_group", $arFields);
$strSql = "\n\t\t\tINSERT INTO b_group (\n\t\t\t\t" . $arInsert[0] . "\n\t\t\t) VALUES(\n\t\t\t\t" . $arInsert[1] . "\n\t\t\t)\n\t\t";
$DB->Query($strSql);
$ID = $DB->LastID();
if (count($arFields["USER_ID"]) > 0) {
if (is_array($arFields["USER_ID"][0]) && count($arFields["USER_ID"][0]) > 0) {
$arTmp = array();
foreach ($arFields["USER_ID"] as $userId) {
if (intval($userId["USER_ID"]) > 0 && !in_array(intval($userId["USER_ID"]), $arTmp)) {
$arInsert = $DB->PrepareInsert("b_user_group", $userId);
$strSql = "INSERT INTO b_user_group(GROUP_ID, " . $arInsert[0] . ") " . "VALUES(" . $ID . ", " . $arInsert[1] . ")";
$DB->Query($strSql);
$arTmp[] = intval($userId["USER_ID"]);
}
}
} else {
$strUsers = "0";
foreach ($arFields["USER_ID"] as $userId) {
$strUsers .= "," . intval($userId);
}
$strSql = "INSERT INTO b_user_group(GROUP_ID, USER_ID) " . "SELECT " . $ID . ", ID " . "FROM b_user " . "WHERE ID in (" . $strUsers . ")";
$DB->Query($strSql);
}
CUser::clearUserGroupCache();
}
$arFields["ID"] = $ID;
foreach (GetModuleEvents("main", "OnAfterGroupAdd", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array(&$arFields));
}
return $ID;
}
示例2: Delete
function Delete($ID)
{
/** @global CMain $APPLICATION */
global $APPLICATION, $DB;
$ID = intval($ID);
if ($ID <= 2) {
return false;
}
@set_time_limit(600);
foreach (GetModuleEvents("main", "OnBeforeGroupDelete", true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array($ID)) === false) {
$err = GetMessage("MAIN_BEFORE_DEL_ERR") . ' ' . $arEvent['TO_NAME'];
if ($ex = $APPLICATION->GetException()) {
$err .= ': ' . $ex->GetString();
}
$APPLICATION->throwException($err);
return false;
}
}
foreach (GetModuleEvents("main", "OnGroupDelete", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($ID));
}
CMain::DelGroupRight("", array($ID));
if (!$DB->Query("DELETE FROM b_user_group WHERE GROUP_ID=" . $ID . " AND GROUP_ID>2", true)) {
return false;
}
CUser::clearUserGroupCache();
return $DB->Query("DELETE FROM b_group WHERE ID=" . $ID . " AND ID>2", true);
}