コード例 #1
0
ファイル: forum_new.php プロジェクト: spas-viktor/books
 function Update($ID, $arFields)
 {
     global $DB;
     $ID = intVal($ID);
     if ($ID <= 0) {
         return false;
     }
     if (!CForumGroup::CheckFields("UPDATE", $arFields, $ID)) {
         return false;
     }
     if (CACHED_b_forum_group !== false) {
         $GLOBALS["CACHE_MANAGER"]->CleanDir("b_forum_group");
     }
     /***************** Event onBeforeGroupForumsUpdate *****************/
     foreach (GetModuleEvents("forum", "onBeforeGroupForumsUpdate", true) as $arEvent) {
         if (ExecuteModuleEventEx($arEvent, array(&$ID, &$arFields)) === false) {
             return false;
         }
     }
     /***************** /Event ******************************************/
     if (empty($arFields)) {
         return false;
     }
     $strUpdate = $DB->PrepareUpdate("b_forum_group", $arFields);
     if (!empty($strUpdate)) {
         $strSql = "UPDATE b_forum_group SET " . $strUpdate . " WHERE ID = " . $ID;
         $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     if (is_set($arFields, "LANG")) {
         $DB->Query("DELETE FROM b_forum_group_lang WHERE FORUM_GROUP_ID = " . $ID, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         for ($i = 0; $i < count($arFields["LANG"]); $i++) {
             $arInsert = $DB->PrepareInsert("b_forum_group_lang", $arFields["LANG"][$i]);
             $strSql = "INSERT INTO b_forum_group_lang(FORUM_GROUP_ID, " . $arInsert[0] . ") VALUES(" . $ID . ", " . $arInsert[1] . ")";
             $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         }
     }
     CForumGroup::Resort();
     /***************** Event onAfterGroupForumsUpdate *****************/
     foreach (GetModuleEvents("forum", "onAfterGroupForumsUpdate", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($ID, $arFields));
     }
     /***************** /Event ******************************************/
     return $ID;
 }
コード例 #2
0
ファイル: group_edit.php プロジェクト: mrdeadmouse/u136006
$arError = array();
$message = false;
$bInitVars = false;
while ($arLang = $db_lang->Fetch()) {
    $arSysLangs[$langCount] = $arLang["LID"];
    $arSysLangNames[$langCount] = htmlspecialcharsbx($arLang["NAME"]);
    $langCount++;
}
$arGroups = CForumGroup::GetByLang(LANGUAGE_ID);
array_unshift($arGroups, array("ID" => 0, "NAME" => "..."));
if ((strlen($save) > 0 || strlen($apply) > 0) && $REQUEST_METHOD == "POST" && $forumPermissions == "W" && check_bitrix_sessid()) {
    $arFields = array("SORT" => intVal(intVal($SORT) <= 0 ? 150 : $SORT), "PARENT_ID" => $_REQUEST["FORUM_GROUP"]["PARENT_ID"]);
    for ($i = 0; $i < count($arSysLangs); $i++) {
        $arFields["LANG"][] = array("LID" => $arSysLangs[$i], "NAME" => $_REQUEST["FORUM_GROUP"]["LANG"][$arSysLangs[$i]]["NAME"], "DESCRIPTION" => $_REQUEST["FORUM_GROUP"]["LANG"][$arSysLangs[$i]]["DESCRIPTION"]);
    }
    if (!CForumGroup::CheckFields($ID > 0 ? "UPDATE" : "ADD", $arFields, $ID > 0 ? $ID : false)) {
        $arError[] = array("code" => "error_checkfields", "title" => GetMessage("ERROR_ADD_GROUP_BAD_FIELDS"));
    } else {
        if ($ID > 0) {
            if (!CForumGroup::CanUserUpdateGroup($ID, $USER->GetUserGroupArray())) {
                $arError[] = array("code" => "not_right_for_edit", "title" => GetMessage("ERROR_EDIT_GROUP_NOT_RIGHT"));
            } else {
                $ID1 = CForumGroup::Update($ID, $arFields);
                if (IntVal($ID1) <= 0) {
                    $arError[] = array("code" => "not_edit", "title" => GetMessage("ERROR_EDIT_GROUP"));
                }
            }
        } else {
            if (!CForumGroup::CanUserAddGroup($USER->GetUserGroupArray())) {
                $arError[] = array("code" => "not_right_for_add", "title" => GetMessage("ERROR_ADD_GROUP_NOT_RIGHT"));
            } else {