本文整理汇总了PHP中CIBlock::SetPermission方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlock::SetPermission方法的具体用法?PHP CIBlock::SetPermission怎么用?PHP CIBlock::SetPermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlock
的用法示例。
在下文中一共展示了CIBlock::SetPermission方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: ImportIBlockFromXML
function ImportIBlockFromXML($xmlFile, $iblockCode, $iblockType, $siteID, $permissions = array())
{
if (!CModule::IncludeModule("iblock")) {
return false;
}
$rsIBlock = CIBlock::GetList(array(), array("CODE" => $iblockCode, "TYPE" => $iblockType, "SITE_ID" => $siteID));
if ($arIBlock = $rsIBlock->Fetch()) {
return false;
}
if (!is_array($siteID)) {
$siteID = array($siteID);
}
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/iblock/classes/" . strtolower($GLOBALS["DB"]->type) . "/cml2.php";
$iblockID = ImportXMLFile($xmlFile, $iblockType, $siteID, $section_action = "N", $element_action = "N", $use_crc = false, $preview = false, $sync = false, $return_last_error = false, $return_iblock_id = true);
//Import was not able to return iblock_id by error
if (!is_integer($iblockID) || $iblockID <= 0) {
//try to find iblock
$rsIBlock = CIBlock::GetList(array(), array("CODE" => $iblockCode, "TYPE" => $iblockType, "SITE_ID" => $siteID));
if ($arIBlock = $rsIBlock->Fetch()) {
$iblockID = $arIBlock["ID"];
} else {
$iblockID = false;
}
}
//Set iblock permissions
if ($iblockID > 0) {
if (empty($permissions)) {
$permissions = array(1 => "X", 2 => "R");
}
CIBlock::SetPermission($iblockID, $permissions);
}
return $iblockID;
}
示例3: createSampleIblock
function createSampleIblock($sSiteId)
{
include $this->sModuleInstallFullPath . "bitrixmigration.php";
$arResult = (include $this->sModuleInstallFullPath . "import.php");
//$sSiteId добавляется в массив в этом файле
$bm = new Bit\Includer\BitrixMigration($this->sModuleInstallFullPath, 'bm_files/');
$bm->uploadArray($arResult);
COption::SetOptionString("bit.includer", "iblock_type", "bit_includer");
COption::SetOptionString("bit.includer", "iblock_id", $iIblockId = $this->getIBlockIdByCode("bit_includer_content"));
COption::SetOptionString("bit.includer", "demo_iblock_id", $iIblockId);
define("FOR_ALL_USERS_GROUP_ID", 2);
//Id групп для всех пользователей по-умолчанию
CIBlock::SetPermission($iIblockId, array(FOR_ALL_USERS_GROUP_ID => "R"));
}
示例4: ImportIBlockFromXML
function ImportIBlockFromXML($xmlFile, $iblockCode, $iblockType, $siteID, $permissions = Array(), $checkExists = true)
{
if (!CModule::IncludeModule("iblock"))
return false;
if($checkExists)
{
$rsIBlock = CIBlock::GetList(array(), array("CODE" => $iblockCode, "TYPE" => $iblockType));
if ($arIBlock = $rsIBlock->Fetch())
return false;
}
if (!is_array($siteID))
$siteID = Array($siteID);
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/iblock/classes/".strtolower($GLOBALS["DB"]->type)."/cml2.php");
ImportXMLFile($xmlFile, $iblockType, $siteID, $section_action = "N", $element_action = "N");
$iblockID = false;
$rsIBlock = CIBlock::GetList(array(), array("CODE" => $iblockCode, "TYPE" => $iblockType));
if ($arIBlock = $rsIBlock->Fetch())
{
$iblockID = $arIBlock["ID"];
if (empty($permissions))
$permissions = Array(1 => "X", 2 => "R");
CIBlock::SetPermission($iblockID, $permissions);
}
return $iblockID;
}
示例5: DEMO_IBlock_ImportXML
function DEMO_IBlock_ImportXML($file, $site_id, $xml_force = false, $workflow = false)
{
if (strlen($file) <= 0) {
return false;
}
$xml_dir = $_SERVER['DOCUMENT_ROOT'] . "/bitrix/wizards/bitrix/demo/modules/iblock/xml/" . LANGUAGE_ID;
if (file_exists($xml_dir) && is_dir($xml_dir)) {
if (is_file($xml_dir . "/" . $file)) {
if (preg_match("/^(\\d\\d\\d)_([a-z]+)_(.+)_([a-z]{2})\\.xml\$/", $file, $match)) {
$documentRoot = rtrim(str_replace(array("\\\\", "//"), array("\\", "/"), $_SERVER["DOCUMENT_ROOT"]), "\\/");
$arFile = array("DIR" => substr($xml_dir, strlen($documentRoot)), "NAME" => $file, "TYPE" => $match[2], "XML_ID" => $match[3], "LANG" => $match[4]);
if ($arFile["TYPE"] == "FUTURE") {
$arFile["TYPE"] = "xmlcatalog";
}
//Check if iblock exists
$obIBlock = new CIBlock();
$rsIBlock = $obIBlock->GetList(array(), array("XML_ID" => $arFile["XML_ID"]));
$arIBlock = $rsIBlock->Fetch();
if (!$arIBlock || $xml_force === true) {
//Create iblock type
DEMO_IBlock_CreateType(array($arFile["TYPE"]));
ImportXMLFile($arFile["DIR"] . "/" . $arFile["NAME"], $arFile["TYPE"], array($site_id), "N", "N");
$rsIBlock = $obIBlock->GetList(array(), array("XML_ID" => $arFile["XML_ID"]));
$arIBlock = $rsIBlock->Fetch();
if (is_array($arIBlock)) {
$obIBlock = new CIBlock();
if ($workflow === "bizproc") {
if (IsModuleInstalled('bizproc')) {
$obIBlock->Update($arIBlock["ID"], array("WORKFLOW" => "N", "BIZPROC" => "Y"));
} else {
$obIBlock->Update($arIBlock["ID"], array("WORKFLOW" => "Y", "BIZPROC" => "N"));
}
} elseif ($workflow) {
$obIBlock->Update($arIBlock["ID"], array("WORKFLOW" => "Y"));
}
}
}
if ($arIBlock["ID"]) {
$obIBlock = new CIBlock();
$obIBlock->SetPermission($arIBlock["ID"], array(1 => "X", 2 => "R"));
}
return $arIBlock["ID"];
}
}
}
return false;
}
示例6: dirname
} else {
$source_base = dirname(__FILE__);
$documentRoot = rtrim(str_replace(array("\\\\", "//", "\\"), array("\\", "/", "/"), $_SERVER["DOCUMENT_ROOT"]), "\\/");
$source_base = substr($source_base, strLen($documentRoot));
$source_base = str_replace(array("\\", "//"), "/", "/" . $source_base . "/");
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/iblock/classes/" . $DBType . "/cml2.php";
$res = ImportXMLFile($source_base . "xml/" . LANGUAGE_ID . "/photogallery.xml", "gallery", $SITE_ID);
$db_res = CIBlock::GetList(array(), array("CODE" => "photo", "XML_ID" => "photo-gallery"));
if ($db_res && ($res = $db_res->Fetch())) {
$iBlockId = intVal($res["ID"]);
}
}
if ($iBlockId <= 0) {
return false;
}
CIBlock::SetPermission($iBlockId, array("1" => "W", "2" => "R"));
// 3. Add Forum
$arParams = array("USE_COMMENTS" => "N", "COMMENTS_TYPE" => "none", "FORUM_ID" => "", "BLOG_URL" => "", "PATH_TO_SMILE" => "");
if (CModule::IncludeModule("forum")) {
// 3.1 Add group
$iGroupId = 0;
$db_res = CForumGroup::GetListEx(array(), array("LID" => LANGUAGE_ID));
if ($db_res && ($res = $db_res->Fetch())) {
do {
if (GetMessage("P_FORUM_GROUP_COMMENTS") == $res["NAME"]) {
$iGroupId = intVal($res["ID"]);
break;
}
} while ($res = $db_res->Fetch());
}
if ($iGroupId <= 0) {
示例7: foreach
}
}
$res = $ib->Update($iblock_id, $arFields);
if ($ob->e_rights) {
$arParams['ENTITY_TYPE'] = 'IBLOCK';
$arParams['ENTITY_ID'] = $arParams['IBLOCK_ID'] = $iblock_id;
$arParams['ACTION'] = 'set_rights';
$arParams['DO_NOT_REDIRECT'] = true;
include $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/components/bitrix/webdav.iblock.rights/action.php";
} else {
if (is_array($_REQUEST["GROUP_ADD"]) && !empty($_REQUEST["GROUP_ADD"])) {
foreach ($_REQUEST["GROUP_ADD"] as $key => $group_id) {
$_REQUEST["GROUP"][$group_id] = $_REQUEST["GROUP_ADD_PERMISSION"][$key];
}
}
CIBlock::SetPermission($iblock_id, $_REQUEST["GROUP"]);
WDClearComponentCache(array("webdav.element.edit", "webdav.element.hist", "webdav.element.upload", "webdav.element.view", "webdav.menu", "webdav.section.edit", "webdav.section.list"));
}
$popupWindow->Close($bReload = true, $_REQUEST["back_url"]);
die;
}
}
}
/********************************************************************
/Actions
********************************************************************/
//HTML output
$popupWindow->ShowTitlebar($arIBlock["NAME"]);
if (isset($strWarning) && $strWarning != "") {
$popupWindow->ShowValidationError($strWarning);
}