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


PHP CForumNew::SetAccessPermissions方法代码示例

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


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

示例1: Add

 function Add($arFields)
 {
     global $DB;
     if (!CForumNew::CheckFields("ADD", $arFields)) {
         return false;
     }
     /***************** Event onBeforeForumAdd **************************/
     foreach (GetModuleEvents("forum", "onBeforeForumAdd", true) as $arEvent) {
         if (ExecuteModuleEventEx($arEvent, array(&$arFields)) === false) {
             return false;
         }
     }
     /***************** /Event ******************************************/
     if (empty($arFields)) {
         return false;
     }
     $arInsert = $DB->PrepareInsert("b_forum", $arFields);
     $strSql = "INSERT INTO b_forum(" . $arInsert[0] . ") VALUES(" . $arInsert[1] . ")";
     $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     $ID = intVal($DB->LastID());
     if ($ID > 0) {
         foreach ($arFields["SITES"] as $key => $value) {
             $DB->Query("INSERT INTO b_forum2site (FORUM_ID, SITE_ID, PATH2FORUM_MESSAGE) VALUES(" . $ID . ", '" . $DB->ForSql($key, 2) . "', '" . $DB->ForSql($value, 250) . "')", false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         }
         if (is_set($arFields, "GROUP_ID") && is_array($arFields["GROUP_ID"])) {
             CForumNew::SetAccessPermissions($ID, $arFields["GROUP_ID"]);
         }
     }
     /***************** Event onAfterForumAdd ***************************/
     foreach (GetModuleEvents("forum", "onAfterForumAdd", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array(&$ID, &$arFields));
     }
     /***************** /Event ******************************************/
     return $ID;
 }
开发者ID:spas-viktor,项目名称:books,代码行数:35,代码来源:forum_new.php

示例2: Update

 function Update($ID, $arFields, $bReindex = true)
 {
     global $DB;
     $ID = intVal($ID);
     $arForum_prev = array();
     $arProcAuth = array();
     if ($ID <= 0 || !CForumNew::CheckFields("UPDATE", $arFields)) {
         return false;
     }
     if ($arFields["ACTIVE"] == "N") {
         $arForum_prev = CForumNew::GetByID($ID);
     }
     /***************** Event onBeforeForumUpdate ***********************/
     foreach (GetModuleEvents("forum", "onBeforeForumUpdate", true) as $arEvent) {
         if (ExecuteModuleEventEx($arEvent, array(&$ID, &$arFields)) === false) {
             return false;
         }
     }
     /***************** /Event ******************************************/
     if (empty($arFields)) {
         return false;
     }
     /***************** Cleaning cache **********************************/
     unset($GLOBALS["FORUM_CACHE"]["FORUM"][$ID]);
     if (CACHED_b_forum !== false) {
         $GLOBALS["CACHE_MANAGER"]->CleanDir("b_forum");
     }
     if (CACHED_b_forum2site !== false && is_array($arFields["SITES"]) && count($arFields["SITES"]) > 0) {
         $GLOBALS["CACHE_MANAGER"]->CleanDir("b_forum2site");
     }
     /***************** Cleaning cache/**********************************/
     $strUpdate = $DB->PrepareUpdate("b_forum", $arFields);
     if (!empty($strUpdate)) {
         $strSql = "UPDATE b_forum SET " . $strUpdate . " WHERE ID=" . $ID;
         $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     if (is_array($arFields["SITES"]) && count($arFields["SITES"]) > 0) {
         $DB->Query("DELETE FROM b_forum2site WHERE FORUM_ID = " . $ID);
         foreach ($arFields["SITES"] as $key => $value) {
             $value = $DB->ForSql($value, 250);
             $strSql = "INSERT INTO b_forum2site (FORUM_ID, SITE_ID, PATH2FORUM_MESSAGE) VALUES(" . $ID . ", '" . $DB->ForSql($key, 2) . "', '" . $value . "') ";
             if ($DB->type == "MYSQL") {
                 $strSql .= "ON DUPLICATE KEY UPDATE PATH2FORUM_MESSAGE='" . $value . "'";
             }
             $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         }
     }
     if (is_set($arFields, "GROUP_ID") && is_array($arFields["GROUP_ID"])) {
         CForumNew::SetAccessPermissions($ID, $arFields["GROUP_ID"]);
     }
     /***************** Event onAfterForumUpdate ************************/
     foreach (GetModuleEvents("forum", "onAfterForumUpdate", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($ID, $arFields));
     }
     /***************** /Event ******************************************/
     /***************** Update statistic ********************************/
     /* If forum became inactive than all statistics for users of this forum will be recalculated.*/
     if ($arFields["ACTIVE"] == "N" && $arForum_prev["ACTIVE"] == "Y") {
         $db_res = CForumMessage::GetList(array(), array("FORUM_ID" => $ID, "!AUTHOR_ID" => 0));
         while ($res = $db_res->Fetch()) {
             $res["AUTHOR_ID"] = intVal($res["AUTHOR_ID"]);
             if (!in_array($res["AUTHOR_ID"], $arProcAuth)) {
                 CForumUser::SetStat($res["AUTHOR_ID"]);
                 $arProcAuth[] = $res["AUTHOR_ID"];
             }
         }
         unset($arProcAuth);
     }
     /***************** Update search module ****************************/
     if (CModule::IncludeModule("search") && $bReindex == true) {
         if ($arFields["ACTIVE"] == "N" && $arForum_prev["ACTIVE"] == "Y" || $arFields["INDEXATION"] == "N" && $arForum_prev["INDEXATION"] == "Y") {
             CSearch::DeleteIndex("forum", false, $ID);
         } elseif (is_set($arFields, "GROUP_ID") && is_array($arFields["GROUP_ID"])) {
             $arGroups = CForumNew::GetAccessPermissions($ID);
             $arGPerm = array();
             foreach ($arGroups as $i => $group) {
                 if ($group[1] >= "E") {
                     $arGPerm[] = $group[0];
                     if ($group[0] == 2) {
                         break;
                     }
                 }
             }
             CSearch::ChangePermission("forum", $arGPerm, false, $ID);
         }
     }
     return $ID;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:88,代码来源:forum_new.php


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