Beispiel #1
0
     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"]);
     }
 }
 if (strlen($_POST["BACK_URL"]) > 0) {
     $arResult["BACK_URL"] = htmlspecialcharsbx($_POST["BACK_URL"]);
 } else {
     $arResult["BACK_URL"] = htmlspecialcharsbx($APPLICATION->GetCurPageParam());
 }
 $res = CBlogUserGroup::GetList(array("NAME" => "ASC"), array("BLOG_ID" => $arBlog["ID"]), array("ID", "NAME", "BLOG_ID", "COUNT" => "USER2GROUP_ID"));
 while ($arGroup = $res->Fetch()) {
Beispiel #2
0
                 $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;
                 }
             } else {
                 $arResult["ERROR_MESSAGE"][] = GetMessage("BLOG_GROUP_EXIST", array("#GROUP_NAME#" => htmlspecialcharsbx($v)));
             }
         }
     }
 }
 if (!empty($autoGroup)) {
     $arFields = array("AUTO_GROUPS" => serialize($autoGroup));
 } else {
     $arFields = array("AUTO_GROUPS" => "");
 }
 $arFields["PERMS_POST"] = $_POST['perms_p'];
Beispiel #3
0
     if (is_array($_POST['group'])) {
         $arFields["AUTO_GROUPS"] = serialize(array_keys($_POST['group']));
     } else {
         $arFields["AUTO_GROUPS"] = "";
     }
     $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 ($newID) {
         BXClearCache(True, "/" . SITE_ID . "/blog/new_blogs/");
         BXClearCache(True, "/" . SITE_ID . "/blog/groups/" . $arBlog['GROUP_ID'] . "/");
         BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog['URL']);
         CBlogUserGroup::Add(array("BLOG_ID" => $newID, "NAME" => GetMessage('BLOG_FRIENDS')));
     }
 }
 if ($newID && !$errorMessage) {
     $arBlog = CBlog::GetByID($newID);
     if ($_POST['apply']) {
         if ($is404) {
             LocalRedirect(CBlog::PreparePath($arBlog['URL'], false, $is404) . "blog_edit.php");
         } else {
             $page = $arSitePath["PATH"] . "/blog_edit.php?blog=" . htmlspecialchars($arBlog['URL']);
         }
     } else {
         LocalRedirect(CBlog::PreparePath($arBlog['URL'], false, $is404));
     }
 } else {
     $bVarsFromForm = true;
Beispiel #4
0
 }
 $groups = $groupID = CBlogGroup::Add(array("SITE_ID" => $siteID, "NAME" => GetMessage("BLOG_DEMO_GROUP_1")));
 $groups .= ",";
 $groups .= CBlogGroup::Add(array("SITE_ID" => $siteID, "NAME" => GetMessage("BLOG_DEMO_GROUP_2")));
 $groups .= ",";
 $groups .= CBlogGroup::Add(array("SITE_ID" => $siteID, "NAME" => GetMessage("BLOG_DEMO_GROUP_3")));
 $groups .= ",";
 $groups .= CBlogGroup::Add(array("SITE_ID" => $siteID, "NAME" => GetMessage("BLOG_DEMO_GROUP_4")));
 $groups .= ",";
 $groups .= CBlogGroup::Add(array("SITE_ID" => $siteID, "NAME" => GetMessage("BLOG_DEMO_GROUP_5")));
 $groups .= ",";
 $groups .= CBlogGroup::Add(array("SITE_ID" => $siteID, "NAME" => GetMessage("BLOG_DEMO_GROUP_6")));
 $groups .= ",";
 $groups .= CBlogGroup::Add(array("SITE_ID" => $siteID, "NAME" => GetMessage("BLOG_DEMO_GROUP_7")));
 $blogID = CBlog::Add(array("NAME" => GetMessage("BLOG_DEMO_BLOG_NAME"), "DESCRIPTION" => GetMessage("BLOG_DEMO_BLOG_NAME"), "GROUP_ID" => $groupID, "ENABLE_IMG_VERIF" => 'Y', "EMAIL_NOTIFY" => 'Y', "ENABLE_RSS" => "Y", "ALLOW_HTML" => "Y", "URL" => "admin-blg", "ACTIVE" => "Y", "=DATE_CREATE" => $DB->GetNowFunction(), "=DATE_UPDATE" => $DB->GetNowFunction(), "OWNER_ID" => 1, "PERMS_POST" => array("1" => BLOG_PERMS_READ, "2" => BLOG_PERMS_READ), "PERMS_COMMENT" => array("1" => BLOG_PERMS_WRITE, "2" => BLOG_PERMS_WRITE)));
 $friends = CBlogUserGroup::Add(array("NAME" => GetMessage("BLOG_DEMO_FRIENDS"), "BLOG_ID" => $blogID));
 CBlogUserGroupPerms::Add(array("BLOG_ID" => $blogID, "USER_GROUP_ID" => $friends, "PERMS_TYPE" => "P", "PERMS" => "I", "AUTOSET" => "N"));
 CBlogUserGroupPerms::Add(array("BLOG_ID" => $blogID, "USER_GROUP_ID" => $friends, "PERMS_TYPE" => "C", "PERMS" => "P", "AUTOSET" => "N"));
 $categoryID[] = CBlogCategory::Add(array("BLOG_ID" => $blogID, "NAME" => GetMessage("BLOG_DEMO_CATEGORY_1")));
 $categoryID[] = CBlogCategory::Add(array("BLOG_ID" => $blogID, "NAME" => GetMessage("BLOG_DEMO_CATEGORY_2")));
 $postID = CBlogPost::Add(array("TITLE" => GetMessage("BLOG_DEMO_MESSAGE_TITLE_1"), "DETAIL_TEXT" => GetMessage("BLOG_DEMO_MESSAGE_BODY_1"), "DETAIL_TEXT_TYPE" => "text", "BLOG_ID" => $blogID, "AUTHOR_ID" => 1, "=DATE_CREATE" => $DB->GetNowFunction(), "=DATE_PUBLISH" => $DB->GetNowFunction(), "PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH, "ENABLE_TRACKBACK" => 'N', "ENABLE_COMMENTS" => 'Y', "CATEGORY_ID" => implode(",", $categoryID), "PERMS_P" => array(1 => BLOG_PERMS_READ, 2 => BLOG_PERMS_READ), "PERMS_C" => array(1 => BLOG_PERMS_WRITE, 2 => BLOG_PERMS_WRITE)));
 foreach ($categoryID as $v) {
     CBlogPostCategory::Add(array("BLOG_ID" => $blogID, "POST_ID" => $postID, "CATEGORY_ID" => $v));
 }
 $arImage = CFile::MakeFileArray(dirname(__FILE__) . '/images/' . GetMessage("BLOG_DEMO_IMG"));
 $arImage["MODULE_ID"] = "blog";
 $arFields = array("BLOG_ID" => $blogID, "POST_ID" => $postID, "USER_ID" => 1, "=TIMESTAMP_X" => $DB->GetNowFunction(), "TITLE" => GetMessage("BLOG_DEMO_IMG_TITLE"), "IMAGE_SIZE" => $arImage["size"], "FILE_ID" => $arImage);
 CBlogImage::Add($arFields);
 CBlogComment::Add(array("TITLE" => GetMessage("BLOG_DEMO_COMMENT_TITLE"), "POST_TEXT" => GetMessage("BLOG_DEMO_COMMENT_BODY"), "BLOG_ID" => $blogID, "POST_ID" => $postID, "PARENT_ID" => 0, "AUTHOR_ID" => 1, "DATE_CREATE" => ConvertTimeStamp(false, "FULL"), "AUTHOR_IP" => "192.168.0.108"));
 CBlogSitePath::Add(array("SITE_ID" => $siteID, "PATH" => "/communication/blog/#blog#/", "TYPE" => "B"));
 CBlogSitePath::Add(array("SITE_ID" => $siteID, "PATH" => "/communication/blog/#blog#/#post_id#.php", "TYPE" => "P"));