예제 #1
0
 $arGroup = CBlogGroup::GetByID($arBlog["GROUP_ID"]);
 if ($arGroup["SITE_ID"] == SITE_ID) {
     $arResult["BLOG"] = $arBlog;
     if (CBlog::CanUserManageBlog($arBlog["ID"], $USER_ID)) {
         if ($arParams["SET_TITLE"] == "Y") {
             $APPLICATION->SetTitle(GetMessage("BLOG_USER_GROUP_TITLE") . "\"" . $arBlog["NAME"] . "\"");
         }
         if ($_POST["save"] && check_bitrix_sessid()) {
             $arFields = array('NAME' => $_POST["NAME"]);
             if (IntVal($_POST['ID']) > 0) {
                 $res = CBlogUserGroup::GetList(array("NAME" => "ASC"), array("BLOG_ID" => $arBlog["ID"], "ID" => IntVal($_POST["ID"])));
                 if ($res->Fetch()) {
                     if ($_POST["group_del"] == "Y") {
                         CBlogUserGroup::Delete(IntVal($_POST['ID']));
                     } else {
                         $newID = CBlogUserGroup::Update(IntVal($_POST["ID"]), $arFields);
                     }
                 } else {
                     $arResult["ERROR_MESSAGE"] = GetMessage("BLOG_ERR_NO_RIGHTS");
                 }
             } else {
                 $arFields["BLOG_ID"] = $arBlog["ID"];
                 $res = CBlogUserGroup::GetList(array("NAME" => "ASC"), array("BLOG_ID" => $arFields["BLOG_ID"], "NAME" => $arFields["NAME"]));
                 if (!$res->Fetch()) {
                     $newID = CBlogUserGroup::Add($arFields);
                 } else {
                     $arResult["ERROR_MESSAGE"] = GetMessage("BLOG_GROUP_EXIST_1") . " \"" . htmlspecialcharsEx($arFields["NAME"]) . "\" " . GetMessage("BLOG_GROUP_EXIST_2");
                 }
             }
             if (strlen($arResult["ERROR_MESSAGE"]) <= 0) {
                 LocalRedirect($_POST["BACK_URL"]);
예제 #2
0
     $newID = CBlog::Update($arBlog["ID"], $arFields);
 } else {
     $arFields["=DATE_CREATE"] = $DB->CurrentTimeFunction();
     $arFields["ACTIVE"] = "Y";
     $arFields["OWNER_ID"] = $USER->GetID();
     $newID = CBlog::Add($arFields);
 }
 if (IntVal($newID) > 0) {
     $autoGroup = array();
     if (!empty($_POST["grp_name"])) {
         foreach ($_POST["grp_name"] as $k => $v) {
             if (IntVal($k) > 0) {
                 if ($_POST["grp_delete"][$k] != "Y") {
                     $res = CBlogUserGroup::GetList(array("NAME" => "ASC"), array("BLOG_ID" => $newID, "NAME" => $v, "!ID" => $k));
                     if (!$res->Fetch()) {
                         CBlogUserGroup::Update($k, array("NAME" => $v));
                         if ($_POST["group"][$k] == "Y") {
                             $autoGroup[] = $k;
                         }
                     } else {
                         $arResult["ERROR_MESSAGE"][] = GetMessage("BLOG_GROUP_EXIST", array("#GROUP_NAME#" => htmlspecialcharsbx($v)));
                     }
                 } else {
                     CBlogUserGroup::Delete($k);
                 }
             } else {
                 $res = CBlogUserGroup::GetList(array("NAME" => "ASC"), array("BLOG_ID" => $newID, "NAME" => $v));
                 if (!$res->Fetch()) {
                     $uGrID = CBlogUserGroup::Add(array("NAME" => $v, "BLOG_ID" => $newID));
                     if (IntVal($uGrID) > 0 && $_POST["group"][$k] == "Y") {
                         $autoGroup[] = $uGrID;