当前位置: 首页>>代码示例>>PHP>>正文


PHP CBlog::SetBlogPerms方法代码示例

本文整理汇总了PHP中CBlog::SetBlogPerms方法的典型用法代码示例。如果您正苦于以下问题:PHP CBlog::SetBlogPerms方法的具体用法?PHP CBlog::SetBlogPerms怎么用?PHP CBlog::SetBlogPerms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CBlog的用法示例。


在下文中一共展示了CBlog::SetBlogPerms方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

$dbBlogGroup = CBlogGroup::GetList(array(), $arFields, false, false, array("ID"));
if ($arBlogGroup = $dbBlogGroup->Fetch()) {
    $blogGroupID = $arBlogGroup["ID"];
} else {
    $blogGroupID = CBlogGroup::Add($arFields);
}
$blogGroupID = intval($blogGroupID);
if ($blogGroupID > 0) {
    $dbBlog = CBlog::GetList(array(), array("URL" => $arResult["BLOG_URL"]), false, false, array("ID"));
    if ($arBlog = $dbBlog->Fetch()) {
        $blogId = $arBlog["ID"];
    } else {
        $arFields = array("NAME" => GetMessage("IBLOCK_CSC_BLOG_NAME"), "DESCRIPTION" => GetMessage("IBLOCK_CSC_BLOG_DESCRIPTION"), "GROUP_ID" => $blogGroupID, "ENABLE_COMMENTS" => 'Y', "ENABLE_IMG_VERIF" => 'Y', "EMAIL_NOTIFY" => isset($arParams["EMAIL_NOTIFY"]) && $arParams["EMAIL_NOTIFY"] == 'Y' ? 'Y' : 'N', "URL" => $arResult["BLOG_URL"], "ACTIVE" => "Y", "OWNER_ID" => 1, "AUTO_GROUPS" => "N");
        $blogId = CBlog::Add($arFields);
        if (IntVal($blogId) > 0) {
            CBlog::SetBlogPerms($blogId, array("1" => BLOG_PERMS_WRITE, "2" => BLOG_PERMS_WRITE), BLOG_PERMS_COMMENT);
        } else {
            if ($ex = $APPLICATION->GetException()) {
                $arResult["ERRORS"][] = $ex->GetString();
            } else {
                $arResult["ERRORS"][] = GetMessage("IBLOCK_CSC_BLOG_CREATE_ERROR");
            }
        }
    }
} else {
    if ($ex = $APPLICATION->GetException()) {
        $arResult["ERRORS"][] = $ex->GetString();
    } else {
        $arResult["ERRORS"][] = GetMessage("IBLOCK_CSC_BLOG_GROUP_CREATE_ERROR");
    }
}
开发者ID:spas-viktor,项目名称:books,代码行数:31,代码来源:component.php

示例2: Update

 function Update($ID, $arFields)
 {
     global $DB;
     $ID = IntVal($ID);
     if ($ID <= 0) {
         return false;
     }
     if (strlen($arFields["PATH"]) > 0) {
         $path = $arFields["PATH"];
         unset($arFields["PATH"]);
     }
     $arFields1 = array();
     foreach ($arFields as $key => $value) {
         if (substr($key, 0, 1) == "=") {
             $arFields1[substr($key, 1)] = $value;
             unset($arFields[$key]);
         }
     }
     if (!CBlog::CheckFields("UPDATE", $arFields, $ID)) {
         return false;
     } elseif (!$GLOBALS["USER_FIELD_MANAGER"]->CheckFields("BLOG_BLOG", $ID, $arFields)) {
         return false;
     }
     $db_events = GetModuleEvents("blog", "OnBeforeBlogUpdate");
     while ($arEvent = $db_events->Fetch()) {
         if (ExecuteModuleEventEx($arEvent, array($ID, &$arFields)) === false) {
             return false;
         }
     }
     $arBlogOld = CBlog::GetByID($ID);
     $strUpdate = $DB->PrepareUpdate("b_blog", $arFields);
     foreach ($arFields1 as $key => $value) {
         if (strlen($strUpdate) > 0) {
             $strUpdate .= ", ";
         }
         $strUpdate .= $key . "=" . $value . " ";
     }
     if (strlen($strUpdate) > 0) {
         $strSql = "UPDATE b_blog SET " . "\t" . $strUpdate . " " . "WHERE ID = " . $ID . " ";
         $DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         unset($GLOBALS["BLOG"]["BLOG_CACHE_" . $ID]);
         unset($GLOBALS["BLOG"]["BLOG4OWNER_CACHE_" . $arBlogOld["OWNER_ID"]]);
         unset($GLOBALS["BLOG"]["BLOG4OWNERGROUP_CACHE_" . $arBlogOld["SOCNET_GROUP_ID"]]);
         $events = GetModuleEvents("blog", "OnBlogUpdate");
         while ($arEvent = $events->Fetch()) {
             ExecuteModuleEventEx($arEvent, array($ID, &$arFields));
         }
         if (is_set($arFields, "PERMS_POST")) {
             CBlog::SetBlogPerms($ID, $arFields["PERMS_POST"], BLOG_PERMS_POST);
         }
         if (is_set($arFields, "PERMS_COMMENT")) {
             CBlog::SetBlogPerms($ID, $arFields["PERMS_COMMENT"], BLOG_PERMS_COMMENT);
         }
         $GLOBALS["USER_FIELD_MANAGER"]->Update("BLOG_BLOG", $ID, $arFields);
     } else {
         $ID = False;
     }
     if ($ID && (is_set($arFields, "NAME") || is_set($arFields, "DESCRIPTION"))) {
         if (CModule::IncludeModule("search")) {
             $arBlog = CBlog::GetByID($ID);
             if ($arBlogOld["ACTIVE"] == "Y" && $arBlog["ACTIVE"] != "Y" || $arBlogOld["SEARCH_INDEX"] == "Y" && $arBlog["SEARCH_INDEX"] != "Y") {
                 CSearch::DeleteIndex("blog", false, "COMMENT", $ID . "|%");
                 CSearch::DeleteIndex("blog", false, "POST", $ID);
                 CSearch::DeleteIndex("blog", "B" . $ID);
             } elseif ($arBlog["ACTIVE"] == "Y" && $arBlog["SEARCH_INDEX"] == "Y") {
                 if ($arBlog["USE_SOCNET"] == "Y") {
                     CSearch::DeleteIndex("blog", "B" . $ID);
                 } else {
                     $arGroup = CBlogGroup::GetByID($arBlog["GROUP_ID"]);
                     if (strlen($path) > 0) {
                         $path = str_replace("#blog_url#", $arBlog["URL"], $path);
                         $arPostSite = array($arGroup["SITE_ID"] => $path);
                     } else {
                         $arPostSite = array($arGroup["SITE_ID"] => CBlog::PreparePath($arBlog["URL"], $arGroup["SITE_ID"], false, $arBlog["OWNER_ID"], $arBlog["SOCNET_GROUP_ID"]));
                     }
                     $arSearchIndex = array("SITE_ID" => $arPostSite, "LAST_MODIFIED" => $arBlog["DATE_UPDATE"], "PARAM1" => "BLOG", "PARAM2" => $arBlog["OWNER_ID"], "PERMISSIONS" => array(2), "TITLE" => $arBlog["NAME"], "BODY" => strlen($arBlog["DESCRIPTION"]) > 0 ? $arBlog["DESCRIPTION"] : $arBlog["NAME"]);
                     CSearch::Index("blog", "B" . $ID, $arSearchIndex);
                 }
             }
         }
     }
     return $ID;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:83,代码来源:blog.php


注:本文中的CBlog::SetBlogPerms方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。