本文整理汇总了PHP中CSearch::ChangePermission方法的典型用法代码示例。如果您正苦于以下问题:PHP CSearch::ChangePermission方法的具体用法?PHP CSearch::ChangePermission怎么用?PHP CSearch::ChangePermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSearch
的用法示例。
在下文中一共展示了CSearch::ChangePermission方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SetFeaturePermissions
function SetFeaturePermissions($entity_type, $entity_id, $feature, $operation, $new_perm)
{
if (substr($operation, 0, 4) == "view") {
if (CModule::IncludeModule('search')) {
global $arSonetFeaturesPermsCache;
unset($arSonetFeaturesPermsCache[$entity_type . "_" . $entity_id]);
$arGroups = CSocNetSearch::GetSearchGroups($entity_type, $entity_id, $feature, $operation);
$arParams = CSocNetSearch::GetSearchParams($entity_type, $entity_id, $feature, $operation);
CSearch::ChangePermission(false, $arGroups, false, false, false, false, $arParams);
}
}
if ($feature == "blog" && in_array($operation, array("view_post", "view_comment")) && CModule::IncludeModule('blog')) {
if ($operation == "view_post") {
CBlogPost::ChangeSocNetPermission($entity_type, $entity_id, $operation);
}
if ($operation == "view_post") {
$arPost = CBlogPost::GetSocNetPostsPerms($entity_type, $entity_id);
foreach ($arPost as $id => $perms) {
CSearch::ChangePermission("blog", $perms["PERMS"], "P" . $id);
}
} else {
$arTmpCache = array();
$arPost = CBlogPost::GetSocNetPostsPerms($entity_type, $entity_id);
$dbComment = CBlogComment::GetSocNetPostsPerms($entity_type, $entity_id);
while ($arComment = $dbComment->Fetch()) {
if (!empty($arPost[$arComment["POST_ID"]])) {
if (empty($arPost[$arComment["POST_ID"]]["PERMS_CALC"])) {
$arPost[$arComment["POST_ID"]]["PERMS_CALC"] = array();
if (is_array($arPost[$arComment["POST_ID"]]["PERMS_FULL"]) && !empty($arPost[$arComment["POST_ID"]]["PERMS_FULL"])) {
foreach ($arPost[$arComment["POST_ID"]]["PERMS_FULL"] as $e => $v) {
if (in_array($v["TYPE"], array("SG", "U"))) {
$type = $v["TYPE"] == "SG" ? "G" : "U";
if (array_key_exists($type . $v["ID"], $arTmpCache)) {
$spt = $arTmpCache[$type . $v["ID"]];
} else {
$spt = CBlogPost::GetSocnetGroups($type, $v["ID"], "view_comment");
$arTmpCache[$type . $v["ID"]] = $spt;
}
foreach ($spt as $vv) {
if (!in_array($vv, $arPost[$arComment["POST_ID"]]["PERMS_CALC"])) {
$arPost[$arComment["POST_ID"]]["PERMS_CALC"][] = $vv;
}
}
} else {
$arPost[$arComment["POST_ID"]]["PERMS_CALC"][] = $e;
}
}
}
}
CSearch::ChangePermission("blog", $arPost[$arComment["POST_ID"]]["PERMS_CALC"], "C" . $arComment["ID"]);
}
}
}
}
}
示例2: ChangeIndex
function ChangeIndex($MODULE_ID, $arFields, $ITEM_ID=false, $PARAM1=false, $PARAM2=false, $SITE_ID=false)
{
$DB = CDatabase::GetModuleConnection('search');
if(array_key_exists("TITLE", $arFields))
$arFields["TITLE"] = Trim($arFields["TITLE"]);
if(array_key_exists("BODY", $arFields))
$arFields["BODY"] = Trim($arFields["BODY"]);
if(array_key_exists("PERMISSIONS", $arFields) && is_array($arFields["PERMISSIONS"]))
CSearch::ChangePermission($MODULE_ID, $arFields["PERMISSIONS"], $ITEM_ID, $PARAM1, $PARAM2, $SITE_ID);
if(array_key_exists("SITE_ID", $arFields) && is_array($arFields["SITE_ID"]))
CSearch::ChangeSite($MODULE_ID, $arFields["SITE_ID"], $ITEM_ID, $PARAM1, $PARAM2, $SITE_ID);
$strUpdate = $DB->PrepareUpdate("b_search_content", $arFields);
if(strlen($strUpdate) > 0)
{
$strSqlWhere = CSearch::__PrepareFilter(Array("MODULE_ID"=>$MODULE_ID, "ITEM_ID"=>$ITEM_ID, "PARAM1"=>$PARAM1, "PARAM2"=>$PARAM2, "SITE_ID"=>$SITE_ID), $bIncSites);
$strSql = "
SELECT sc.ID
FROM b_search_content sc
".($bIncSites? "INNER JOIN b_search_content_site scsite ON sc.ID=scsite.SEARCH_CONTENT_ID": "")."
".(strlen($strSqlWhere)>0? "WHERE ".$strSqlWhere: "")."
";
$rs = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
while($ar = $rs->Fetch())
{
$strSql = "UPDATE b_search_content SET ".$strUpdate." WHERE ID=".$ar["ID"];
$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
if(array_key_exists("PARAMS", $arFields))
CSearch::SetContentItemParams($ar["ID"], $arFields["PARAMS"]);
}
}
}
示例3: ChangeIndex
function ChangeIndex($MODULE_ID, $arFields, $ITEM_ID = false, $PARAM1 = false, $PARAM2 = false, $SITE_ID = false)
{
global $DB;
if (is_set($arFields, "TITLE")) {
$arFields["TITLE"] = Trim($arFields["TITLE"]);
}
if (is_set($arFields, "BODY")) {
$arFields["BODY"] = Trim($arFields["BODY"]);
}
if (is_set($arFields) && is_array($arFields["PERMISSIONS"])) {
CSearch::ChangePermission($MODULE_ID, $arFields["PERMISSIONS"], $ITEM_ID, $PARAM1, $PARAM2, $SITE_ID);
}
$strUpdate = $DB->PrepareUpdate("b_search_content", $arFields);
if (strlen($strUpdate) > 0) {
$strSqlWhere = CSearch::__PrepareFilter(array("MODULE_ID" => $MODULE_ID, "ITEM_ID" => $ITEM_ID, "PARAM1" => $PARAM1, "PARAM2" => $PARAM2, "SITE_ID" => $SITE_ID), $bIncSites);
$strSql = "\n\t\t\t\tUPDATE b_search_content SET\n\t\t\t\t" . $strUpdate . "\n\t\t\t\tWHERE ID IN (\n\t\t\t\t\tSELECT sc.ID\n\t\t\t\t\tFROM b_search_content sc\n\t\t\t\t\t" . ($bIncSites ? "INNER JOIN b_search_content_site scsite ON sc.ID=scsite.SEARCH_CONTENT_ID" : "") . "\n\t\t\t\t\t" . (strlen($strSqlWhere) > 0 ? "WHERE " . $strSqlWhere : "") . "\n\t\t\t\t)\n\t\t\t";
$arBinds = array();
if (is_set($arFields, "BODY")) {
$arBinds["BODY"] = $arFields["BODY"];
}
if (is_set($arFields, "SEARCHABLE_CONTENT")) {
$arBinds["SEARCHABLE_CONTENT"] = $arFields["SEARCHABLE_CONTENT"];
}
$DB->QueryBind($strSql, $arBinds);
}
}
示例4: 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;
}
示例5: SetPermission
/**
* <p>Функция устанавливает права доступа <span class="syntax"><i>arPERMISSIONS</i> для информационного блока <i>IBLOCK_ID</i></span>. Перед этим все права установленные ранее снимаются. <br></p>
*
*
*
*
* @param int $IBLOCK_ID Код информационного блока.
*
*
*
* @param array $arPERMISSIONS Массив вида Array("код группы"=>"право доступа", ....), где <i>право
* доступа</i>: <br> D - доступ запрещён, <br> R - чтение, <br> U - редактирование
* через документооборот, <br> W - запись, <br> X - полный доступ (запись +
* назначение прав доступа на данный инфоблок).
*
*
*
* @return mixed
*
*
* <h4>Example</h4>
* <pre>
* <?<br>CIBlock::SetPermission($IBLOCK_ID, Array("1"=>"X", "2"=>"R", "3"=>"W"));<br>?>
* </pre>
*
*
*
* <h4>See Also</h4>
* <ul> <li> <a href="http://dev.1c-bitrix.ru/api_help/iblock/classes/ciblock/index.php">CIBlock</a>::<a
* href="http://dev.1c-bitrix.ru/api_help/iblock/classes/ciblock/getpermission.php">GetPermission()</a> </li> <li> <a
* href="http://dev.1c-bitrix.ru/api_help/iblock/classes/ciblock/index.php">CIBlock</a>::<a
* href="http://dev.1c-bitrix.ru/api_help/iblock/classes/ciblock/update.php">Update()</a> </li> </ul><a
* name="examples"></a>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/iblock/classes/ciblock/setpermission.php
* @author Bitrix
*/
public static function SetPermission($IBLOCK_ID, $arGROUP_ID)
{
/** @global CDatabase $DB */
global $DB;
$IBLOCK_ID = intval($IBLOCK_ID);
static $letters = "RUWX";
$arToDelete = array();
$arToInsert = array();
if (is_array($arGROUP_ID)) {
foreach ($arGROUP_ID as $group_id => $perm) {
$group_id = intval($group_id);
if ($group_id > 0 && strlen($perm) == 1 && strpos($letters, $perm) !== false) {
$arToInsert[$group_id] = $perm;
}
}
}
$rs = $DB->Query("\n\t\t\tSELECT GROUP_ID, PERMISSION\n\t\t\tFROM b_iblock_group\n\t\t\tWHERE IBLOCK_ID = " . $IBLOCK_ID . "\n\t\t", false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
while ($ar = $rs->Fetch()) {
$group_id = intval($ar["GROUP_ID"]);
if (isset($arToInsert[$group_id]) && $arToInsert[$group_id] === $ar["PERMISSION"]) {
unset($arToInsert[$group_id]);
//This already in DB
} else {
$arToDelete[] = $group_id;
}
}
if (!empty($arToDelete)) {
$DB->Query("\n\t\t\t\tDELETE FROM b_iblock_group\n\t\t\t\tWHERE IBLOCK_ID = " . $IBLOCK_ID . "\n\t\t\t\tAND GROUP_ID in (" . implode(", ", $arToDelete) . ")\n\t\t\t", false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
//And this should be deleted
}
if (!empty($arToInsert)) {
foreach ($arToInsert as $group_id => $perm) {
$DB->Query("\n\t\t\t\t\tINSERT INTO b_iblock_group(IBLOCK_ID, GROUP_ID, PERMISSION)\n\t\t\t\t\tSELECT " . $IBLOCK_ID . ", ID, '" . $perm . "'\n\t\t\t\t\tFROM b_group\n\t\t\t\t\tWHERE ID = " . $group_id . "\n\t\t\t\t");
}
}
if (!empty($arToDelete) || !empty($arToInsert)) {
if (CModule::IncludeModule("search")) {
$arGroups = CIBlock::GetGroupPermissions($IBLOCK_ID);
if (array_key_exists(2, $arGroups)) {
CSearch::ChangePermission("iblock", array(2), false, false, $IBLOCK_ID);
} else {
CSearch::ChangePermission("iblock", $arGroups, false, false, $IBLOCK_ID);
}
}
}
}
示例6: Update
//.........这里部分代码省略.........
* <h4>See Also</h4>
* <ul> <li> <a href="http://dev.1c-bitrix.ru/api_help/learning/fields.php#course">Поля курса</a> </li> <li> <a
* href="http://dev.1c-bitrix.ru/api_help/learning/classes/ccourse/index.php">CCourse</a>::<a
* href="http://dev.1c-bitrix.ru/api_help/learning/classes/ccourse/add.php">Add</a> </li> </ul> <a name="examples"></a>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/learning/classes/ccourse/update.php
* @author Bitrix
*/
public function Update($ID, $arFields)
{
global $DB;
$ID = intval($ID);
if ($ID < 1) {
return false;
}
if (is_set($arFields, "ACTIVE") && $arFields["ACTIVE"] != "Y") {
$arFields["ACTIVE"] = "N";
}
if (is_set($arFields, "DESCRIPTION_TYPE") && $arFields["DESCRIPTION_TYPE"] != "html") {
$arFields["DESCRIPTION_TYPE"] = "text";
}
if (is_set($arFields, "DETAIL_TEXT_TYPE") && $arFields["DETAIL_TEXT_TYPE"] != "html") {
$arFields["DETAIL_TEXT_TYPE"] = "text";
}
if (is_set($arFields, "PREVIEW_TEXT_TYPE") && $arFields["PREVIEW_TEXT_TYPE"] != "html") {
$arFields["PREVIEW_TEXT_TYPE"] = "text";
}
if (is_set($arFields, "RATING") && !in_array($arFields["RATING"], array("Y", "N"))) {
$arFields["RATING"] = NULL;
}
if (is_set($arFields, "RATING_TYPE") && !in_array($arFields["RATING_TYPE"], array("like", "standart_text", "like_graphic", "standart"))) {
$arFields["RATING_TYPE"] = NULL;
}
$lessonId = self::CourseGetLinkedLesson($ID);
if ($this->CheckFields($arFields, $ID) && $lessonId !== false) {
if (array_key_exists('ID', $arFields)) {
unset($arFields["ID"]);
}
$arFieldsLesson = $arFields;
$arFieldsToUnset = array('GROUP_ID', 'SITE_ID');
foreach ($arFieldsToUnset as $key => $value) {
if (array_key_exists($value, $arFieldsLesson)) {
unset($arFieldsLesson[$value]);
}
}
//Sites
if (is_set($arFields, "SITE_ID")) {
$str_LID = "''";
foreach ($arFields["SITE_ID"] as $lang) {
$str_LID .= ", '" . $DB->ForSql($lang) . "'";
}
$strSql = "DELETE FROM b_learn_course_site WHERE COURSE_ID=" . $ID;
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$strSql = "INSERT INTO b_learn_course_site(COURSE_ID, SITE_ID) " . "SELECT " . $ID . ", LID " . "FROM b_lang " . "WHERE LID IN (" . $str_LID . ") ";
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
CLearnLesson::Update($lessonId, $arFieldsLesson);
if ($ID && (is_set($arFields, "NAME") || is_set($arFields, "DESCRIPTION") || is_set($arFields, 'DETAIL_TEXT'))) {
if (CModule::IncludeModule("search")) {
$rsCourse = CCourse::GetByID($ID);
if ($arCourse = $rsCourse->Fetch()) {
$arGroupPermissions = CCourse::GetGroupPermissions($arCourse["ID"]);
if (is_set($arFields, "SITE_ID")) {
$arSiteIds = array();
foreach ($arFields["SITE_ID"] as $lang) {
$rsSitePaths = CSitePath::GetList(array(), array("SITE_ID" => $lang, "TYPE" => "C"));
if ($arSitePaths = $rsSitePaths->Fetch()) {
$strPath = $arSitePaths["PATH"];
} else {
$strPath = "";
}
$arSiteIds[$lang] = str_replace("#COURSE_ID#", $ID, $strPath);
}
$detailText = '';
if ($arCourse["DETAIL_TEXT_TYPE"] !== 'text') {
$detailText = CSearch::KillTags($arCourse['DETAIL_TEXT']);
} else {
$detailText = strip_tags($arCourse['DETAIL_TEXT']);
}
$dataBody = '';
if (strlen($detailText) > 0) {
$dataBody = $detailText;
} else {
$dataBody = $arCourse['NAME'];
}
$arSearchIndex = array("LAST_MODIFIED" => $arCourse["TIMESTAMP_X"], "TITLE" => $arCourse["NAME"], "BODY" => $dataBody, "SITE_ID" => $arSiteIds, "PERMISSIONS" => $arGroupPermissions);
CSearch::Index("learning", "C" . $ID, $arSearchIndex);
}
CSearch::ChangePermission("learning", $arGroupPermissions, false, "C" . $arCourse["ID"]);
}
}
}
global $CACHE_MANAGER;
$CACHE_MANAGER->ClearByTag('LEARN_COURSE_' . $ID);
return true;
}
return false;
}
示例7: UpdateForumTopicIndex
function UpdateForumTopicIndex($topic_id, $entity_type, $entity_id, $feature, $operation, $path_template)
{
global $DB;
if (!CModule::IncludeModule("forum")) {
return;
}
$topic_id = intval($topic_id);
$rsForumTopic = $DB->Query("SELECT FORUM_ID FROM b_forum_topic WHERE ID = " . $topic_id);
$arForumTopic = $rsForumTopic->Fetch();
if (!$arForumTopic) {
return;
}
$arGroups = $this->GetSearchGroups($entity_type, $entity_id, $feature, $operation);
CSearch::ChangePermission("forum", $arGroups, false, $arForumTopic["FORUM_ID"], $topic_id);
$rsForumMessages = $DB->Query("\n\t\t\tSELECT ID\n\t\t\tFROM b_forum_message\n\t\t\tWHERE TOPIC_ID = " . intval($topic_id) . "\n\t\t");
while ($arMessage = $rsForumMessages->Fetch()) {
$url = str_replace(array("#topic_id#", "#message_id#", "#action#"), array($arTopic["ID"], $arMessage["ID"], ""), $path_template);
CSearch::ChangeSite("forum", array(SITE_ID => $url), $arMessage["ID"]);
$this->_counter++;
}
$arParams = $this->GetSearchParams($entity_type, $entity_id, $feature, $operation);
CSearch::ChangeIndex("forum", array("UPD" => $this->_sess_id, "PARAMS" => $arParams), false, $arForumTopic["FORUM_ID"], $topic_id);
}
示例8: Update
function Update($ID, $arFields)
{
global $DB;
if (is_set($arFields, "EXTERNAL_ID")) {
$arFields["XML_ID"] = $arFields["EXTERNAL_ID"];
}
if (is_set($arFields, "PICTURE")) {
if (strlen($arFields["PICTURE"]["name"]) <= 0 && strlen($arFields["PICTURE"]["del"]) <= 0) {
unset($arFields["PICTURE"]);
} else {
$pic_res = $DB->Query("SELECT PICTURE FROM b_iblock WHERE ID=" . $ID);
if ($pic_res = $pic_res->Fetch()) {
$arFields["PICTURE"]["old_file"] = $pic_res["PICTURE"];
}
}
}
if (is_set($arFields, "ACTIVE") && $arFields["ACTIVE"] != "Y") {
$arFields["ACTIVE"] = "N";
}
if (is_set($arFields, "INDEX_SECTION") && $arFields["INDEX_SECTION"] != "Y") {
$arFields["INDEX_SECTION"] = "N";
}
if (is_set($arFields, "INDEX_ELEMENT") && $arFields["INDEX_ELEMENT"] != "Y") {
$arFields["INDEX_ELEMENT"] = "N";
}
if (is_set($arFields, "DESCRIPTION_TYPE") && $arFields["DESCRIPTION_TYPE"] != "html") {
$arFields["DESCRIPTION_TYPE"] = "text";
}
if (!$this->CheckFields(&$arFields, $ID)) {
$Result = false;
$arFields["RESULT_MESSAGE"] =& $this->LAST_ERROR;
} else {
$arLID = array();
if (is_set($arFields, "LID")) {
if (is_array($arFields["LID"])) {
$arLID = $arFields["LID"];
} else {
$arLID[] = $arFields["LID"];
}
$arFields["LID"] = false;
$str_LID = "''";
foreach ($arLID as $v) {
$arFields["LID"] = $v;
$str_LID .= ", '" . $DB->ForSql($v) . "'";
}
}
unset($arFields["ID"]);
unset($arFields["VERSION"]);
$strUpdate = $DB->PrepareUpdate("b_iblock", $arFields, "iblock");
$arBinds = array();
if (is_set($arFields, "DESCRIPTION")) {
$arBinds["DESCRIPTION"] = $arFields["DESCRIPTION"];
}
$strSql = "UPDATE b_iblock SET " . $strUpdate . " WHERE ID=" . $ID;
$DB->QueryBind($strSql, $arBinds);
if (is_set($arFields, "GROUP_ID") && is_array($arFields["GROUP_ID"])) {
CIBlock::SetPermission($ID, $arFields["GROUP_ID"]);
}
if (count($arLID) > 0) {
$strSql = "DELETE FROM b_iblock_site WHERE IBLOCK_ID=" . $ID;
$DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
$strSql = "INSERT INTO b_iblock_site(IBLOCK_ID, SITE_ID) " . "SELECT " . $ID . ", LID " . "FROM b_lang " . "WHERE LID IN (" . $str_LID . ") ";
$DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
}
if (CModule::IncludeModule("search")) {
$dbafter = $DB->Query("SELECT ACTIVE, DETAIL_PAGE_URL, LID FROM b_iblock WHERE ID=" . $ID);
$arAfter = $dbafter->Fetch();
if ($arAfter["ACTIVE"] != "Y") {
CSearch::DeleteIndex("iblock", false, false, $ID);
} else {
if (is_set($arFields, "GROUP_ID")) {
$arPerms = array();
$arGroupsPerm = $arFields["GROUP_ID"];
$arGroups = array_keys($arGroupsPerm);
for ($i = 0; $i < count($arGroups); $i++) {
if ($arGroupsPerm[$arGroups[$i]] >= "R") {
if ($arGroups[$i] == 2) {
$arPerms = array(2);
break;
}
$arPerms[] = $arGroups[$i];
}
}
CSearch::ChangePermission("iblock", $arPerms, false, false, $ID);
}
}
}
$Result = true;
}
$arFields["ID"] = $ID;
$arFields["RESULT"] =& $Result;
$events = GetModuleEvents("iblock", "OnAfterIBlockUpdate");
while ($arEvent = $events->Fetch()) {
ExecuteModuleEvent($arEvent, &$arFields);
}
return $Result;
}
示例9: UpdateSearchRights
static function UpdateSearchRights($ID, $iblockID = null)
{
if (!CModule::IncludeModule('search')) {
return true;
}
$ID = (int) $ID;
if ($ID <= 0) {
return false;
}
if ($iblockID === null) {
$rElement = CIBlockElement::GetList(array(), array('ID' => $ID, 'SHOW_NEW' => 'Y'), false, false, array('ID', 'IBLOCK_ID'));
if ($rElement && ($arElement = $rElement->Fetch())) {
$iblockID = $arElement['IBLOCK_ID'];
}
}
$iblockID = (int) $iblockID;
if ($iblockID <= 0) {
return false;
}
$code = CIBlock::GetArrayByID($iblockID, "CODE");
$bSocNet = strpos($code, "user_files") === 0 || strpos($code, "group_files") === 0;
if (!$bSocNet && CIBlock::GetArrayByID($iblockID, "INDEX_ELEMENT") === "N") {
return false;
}
$arReaders = self::GetReaders($ID, $iblockID);
CSearch::ChangePermission($bSocNet ? 'socialnetwork' : 'iblock', $arReaders, $ID);
return true;
}
示例10: UpdateForumTopicIndex
function UpdateForumTopicIndex($topic_id, $entity_type, $entity_id, $feature, $operation, $path, $arPermissions, $siteID)
{
global $DB;
if (!CModule::IncludeModule("forum")) {
return;
}
$topic_id = intval($topic_id);
$rsForumTopic = $DB->Query("SELECT FORUM_ID FROM b_forum_topic WHERE ID = " . $topic_id);
$arForumTopic = $rsForumTopic->Fetch();
if (!$arForumTopic) {
return;
}
CSearch::ChangePermission("forum", $arPermissions, false, $arForumTopic["FORUM_ID"], $topic_id);
$rsForumMessages = $DB->Query("\n\t\t\tSELECT ID\n\t\t\tFROM b_forum_message\n\t\t\tWHERE TOPIC_ID = " . $topic_id . "\n\t\t");
while ($arMessage = $rsForumMessages->Fetch()) {
CSearch::ChangeSite("forum", array($siteID => $path), $arMessage["ID"]);
}
$arParams = array("feature_id" => "S" . $entity_type . "_" . $entity_id . "_" . $feature . "_" . $operation, "socnet_user" => $entity_id);
CSearch::ChangeIndex("forum", array("PARAMS" => $arParams), false, $arForumTopic["FORUM_ID"], $topic_id);
}