本文整理汇总了PHP中CIBlockRights::SetRights方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlockRights::SetRights方法的具体用法?PHP CIBlockRights::SetRights怎么用?PHP CIBlockRights::SetRights使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlockRights
的用法示例。
在下文中一共展示了CIBlockRights::SetRights方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GroupERights
static function GroupERights($iblockID)
{
if (CIBlock::GetArrayByID($iblockID, "RIGHTS_MODE") === "E") {
return;
}
$arGroups = self::GetGroups($iblockID);
foreach ($arGroups as $groupID => $group) {
foreach (self::$ops as $op => $opTrans) {
$arGroups[$groupID]["Operations"][$op] = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_GROUP, $groupID, 'files', $op);
}
}
$arTasks = CWebDavIblock::GetTasks();
// set e rights
$arFields = array('RIGHTS_MODE' => 'E', 'GROUP_ID' => array());
$ib = new CIBlock();
$res = $ib->Update($iblockID, $arFields);
$ibr = new CIBlockRights($iblockID);
$rights = array();
$rights['n0'] = array('GROUP_CODE' => 'G1', 'DO_CLEAN' => 'Y', 'TASK_ID' => $arTasks['X']);
// admins
$rights['n1'] = array('GROUP_CODE' => 'G2', 'DO_CLEAN' => 'Y', 'TASK_ID' => $arTasks['D']);
// nobody
$ibr->SetRights($rights);
foreach ($arGroups as $groupID => $group) {
$sectionID = $group['SECTION'];
$ibrs = new CIBlockSectionRights($iblockID, $sectionID);
$rights = array();
$i = 0;
foreach ($group["Operations"] as $op => $subj) {
// 'Operations' =>
// array
// 'view' => string 'A' (length=1)
// 'write_limited' => string 'Z' (length=1)
// 'bizproc' => null
// 'write' => string 'Z' (length=1)
//
// A>Только владелец группы
// E>Владелец группы и модераторы группы
// K>Все члены группы
// L>Авторизованные пользователи
// N>Все посетители
if ($subj) {
if ($subj == "N") {
$sSubj = "G2";
} elseif ($subj == "L") {
$sSubj = "AU";
} else {
$sSubj = "SG{$groupID}_{$subj}";
}
$rights[$sSubj] = $arTasks[self::$ops[$op]];
if (self::$ops[$op] == 'E') {
$rights["CR"] = $arTasks['W'];
}
}
}
$rights["SG{$groupID}_A"] = $arTasks["X"];
// admin of group
$arRights = array();
$i = 0;
foreach ($rights as $subj => $task) {
$arRights['n' . $i++] = array('GROUP_CODE' => $subj, 'TASK_ID' => $task, 'DO_CLEAN' => 'NOT');
}
$ibrs->SetRights($arRights);
}
}
示例2: Update
//.........这里部分代码省略.........
}
if (is_set($arFields, "SITE_ID")) {
$arFields["LID"] = $arFields["SITE_ID"];
}
if (is_set($arFields, "SECTION_PROPERTY")) {
$arFields["SECTION_PROPERTY"] = "Y";
}
$RIGHTS_MODE = CIBlock::GetArrayByID($ID, "RIGHTS_MODE");
if (!$this->CheckFields($arFields, $ID)) {
$Result = false;
$arFields["RESULT_MESSAGE"] =& $this->LAST_ERROR;
} else {
$arLID = array();
$str_LID = "";
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"]);
if (array_key_exists("PICTURE", $arFields)) {
$SAVED_PICTURE = $arFields["PICTURE"];
CFile::SaveForDB($arFields, "PICTURE", "iblock");
}
$strUpdate = $DB->PrepareUpdate("b_iblock", $arFields, "iblock");
if (array_key_exists("PICTURE", $arFields)) {
$arFields["PICTURE"] = $SAVED_PICTURE;
}
$arBinds = array();
if (is_set($arFields, "DESCRIPTION")) {
$arBinds["DESCRIPTION"] = $arFields["DESCRIPTION"];
}
if (strlen($strUpdate) > 0) {
$strSql = "UPDATE b_iblock SET " . $strUpdate . " WHERE ID=" . $ID;
$DB->QueryBind($strSql, $arBinds);
}
$this->SetMessages($ID, $arFields);
if (isset($arFields["FIELDS"]) && is_array($arFields["FIELDS"])) {
$this->SetFields($ID, $arFields["FIELDS"]);
}
if (array_key_exists("RIGHTS_MODE", $arFields)) {
if ($arFields["RIGHTS_MODE"] === "E" && $RIGHTS_MODE !== "E") {
CIBlock::SetPermission($ID, array());
} elseif ($arFields["RIGHTS_MODE"] !== "E" && $RIGHTS_MODE === "E") {
$obIBlockRights = new CIBlockRights($ID);
$obIBlockRights->DeleteAllRights();
}
if ($arFields["RIGHTS_MODE"] === "E") {
$RIGHTS_MODE = "E";
}
}
if ($RIGHTS_MODE === "E") {
if (!array_key_exists("RIGHTS", $arFields) && array_key_exists("GROUP_ID", $arFields) && is_array($arFields["GROUP_ID"])) {
$obIBlockRights = new CIBlockRights($ID);
$obIBlockRights->SetRights($obIBlockRights->ConvertGroups($arFields["GROUP_ID"]));
} elseif (array_key_exists("RIGHTS", $arFields) && is_array($arFields["RIGHTS"])) {
$obIBlockRights = new CIBlockRights($ID);
$obIBlockRights->SetRights($arFields["RIGHTS"]);
}
} else {
if (array_key_exists("GROUP_ID", $arFields) && is_array($arFields["GROUP_ID"])) {
CIBlock::SetPermission($ID, $arFields["GROUP_ID"]);
}
}
if (!empty($arLID)) {
$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 FROM b_iblock WHERE ID=" . $ID);
$arAfter = $dbAfter->Fetch();
if ($arAfter["ACTIVE"] != "Y") {
CSearch::DeleteIndex("iblock", false, false, $ID);
}
}
$_SESSION["SESS_RECOUNT_DB"] = "Y";
$Result = true;
}
$this->CleanCache($ID);
$arFields["ID"] = $ID;
$arFields["RESULT"] =& $Result;
foreach (GetModuleEvents("iblock", "OnAfterIBlockUpdate", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array(&$arFields));
}
if (defined("BX_COMP_MANAGED_CACHE")) {
$CACHE_MANAGER->ClearByTag("iblock_id_" . $ID);
}
return $Result;
}