本文整理汇总了PHP中CIBlockElementRights::SetRights方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlockElementRights::SetRights方法的具体用法?PHP CIBlockElementRights::SetRights怎么用?PHP CIBlockElementRights::SetRights使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlockElementRights
的用法示例。
在下文中一共展示了CIBlockElementRights::SetRights方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Update
//.........这里部分代码省略.........
while ($arProp = $props->Fetch()) {
if (!array_key_exists($arProp["VALUE"], $arDup)) {
$arFields["PROPERTY_VALUES"][$arProp["ID"]][$arProp['PROPERTY_VALUE_ID']] = array("VALUE" => $arProp["VALUE"], "DESCRIPTION" => $arProp["DESCRIPTION"]);
$arDup[$arProp["VALUE"]] = true;
//This is cure for files duplication bug
}
}
}
}
} else {
if (array_key_exists("PREVIEW_PICTURE", $arFields)) {
CFile::SaveForDB($arFields, "PREVIEW_PICTURE", "iblock");
}
if (array_key_exists("DETAIL_PICTURE", $arFields)) {
CFile::SaveForDB($arFields, "DETAIL_PICTURE", "iblock");
}
}
unset($arFields["IBLOCK_ID"]);
unset($arFields["WF_NEW"]);
unset($arFields["IBLOCK_SECTION_ID"]);
$bTimeStampNA = false;
if (is_set($arFields, "TIMESTAMP_X") && ($arFields["TIMESTAMP_X"] === NULL || $arFields["TIMESTAMP_X"] === false)) {
$bTimeStampNA = true;
unset($arFields["TIMESTAMP_X"]);
}
$strUpdate = $DB->PrepareUpdate("b_iblock_element", $arFields, "iblock");
if (strlen($strUpdate) > 0) {
$strUpdate .= ", ";
}
$strSql = "UPDATE b_iblock_element SET " . $strUpdate . ($bTimeStampNA ? "TIMESTAMP_X=TIMESTAMP_X" : "TIMESTAMP_X=now()") . " WHERE ID=" . $ID;
$DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
if (array_key_exists("PROPERTY_VALUES", $arFields) && is_array($arFields["PROPERTY_VALUES"]) && count($arFields["PROPERTY_VALUES"]) > 0) {
CIBlockElement::SetPropertyValues($ID, $ar_element["IBLOCK_ID"], $arFields["PROPERTY_VALUES"]);
}
if (is_set($arFields, "IBLOCK_SECTION")) {
CIBlockElement::SetElementSection($ID, $arFields["IBLOCK_SECTION"], false, $arIBlock["RIGHTS_MODE"] === "E" ? $arIBlock["ID"] : 0);
}
if ($arIBlock["RIGHTS_MODE"] === "E") {
$obElementRights = new CIBlockElementRights($arIBlock["ID"], $ID);
if (array_key_exists("RIGHTS", $arFields) && is_array($arFields["RIGHTS"])) {
$obElementRights->SetRights($arFields["RIGHTS"]);
}
}
if (array_key_exists("IPROPERTY_TEMPLATES", $arFields)) {
$ipropTemplates = new \Bitrix\Iblock\InheritedProperty\ElementTemplates($arIBlock["ID"], $ID);
$ipropTemplates->set($arFields["IPROPERTY_TEMPLATES"]);
}
if ($bUpdateSearch) {
CIBlockElement::UpdateSearch($ID, true);
}
if ($bWorkFlow) {
CIBlockElement::WF_CleanUpHistoryCopies($ID);
}
//Restore saved values
if ($SAVED_PREVIEW_PICTURE !== false) {
$arFields["PREVIEW_PICTURE_ID"] = $arFields["PREVIEW_PICTURE"];
$arFields["PREVIEW_PICTURE"] = $SAVED_PREVIEW_PICTURE;
} else {
unset($arFields["PREVIEW_PICTURE"]);
}
if ($SAVED_DETAIL_PICTURE !== false) {
$arFields["DETAIL_PICTURE_ID"] = $arFields["DETAIL_PICTURE"];
$arFields["DETAIL_PICTURE"] = $SAVED_DETAIL_PICTURE;
} else {
unset($arFields["DETAIL_PICTURE"]);
}
if ($arIBlock["FIELDS"]["LOG_ELEMENT_EDIT"]["IS_REQUIRED"] == "Y") {
$USER_ID = is_object($USER) ? intval($USER->GetID()) : 0;
$arEvents = GetModuleEvents("main", "OnBeforeEventLog", true);
if (empty($arEvents) || ExecuteModuleEventEx($arEvents[0], array($USER_ID)) === false) {
$rsElement = CIBlockElement::GetList(array(), array("=ID" => $ID, "CHECK_PERMISSIONS" => "N", "SHOW_NEW" => "Y"), false, false, array("ID", "NAME", "LIST_PAGE_URL", "CODE"));
$arElement = $rsElement->GetNext();
$res = array("ID" => $ID, "CODE" => $arElement["CODE"], "NAME" => $arElement["NAME"], "ELEMENT_NAME" => $arIBlock["ELEMENT_NAME"], "USER_ID" => $USER_ID, "IBLOCK_PAGE_URL" => $arElement["LIST_PAGE_URL"]);
CEventLog::Log("IBLOCK", "IBLOCK_ELEMENT_EDIT", "iblock", $arIBlock["ID"], serialize($res));
}
}
$Result = true;
/************* QUOTA *************/
$_SESSION["SESS_RECOUNT_DB"] = "Y";
/************* QUOTA *************/
}
$arFields["ID"] = $ID;
$arFields["IBLOCK_ID"] = $ar_element["IBLOCK_ID"];
$arFields["RESULT"] =& $Result;
if (isset($arFields["PREVIEW_PICTURE"]) && $arFields["PREVIEW_PICTURE"]["COPY_FILE"] == "Y" && $arFields["PREVIEW_PICTURE"]["copy"]) {
@unlink($arFields["PREVIEW_PICTURE"]["tmp_name"]);
@rmdir(dirname($arFields["PREVIEW_PICTURE"]["tmp_name"]));
}
if (isset($arFields["DETAIL_PICTURE"]) && $arFields["DETAIL_PICTURE"]["COPY_FILE"] == "Y" && $arFields["DETAIL_PICTURE"]["copy"]) {
@unlink($arFields["DETAIL_PICTURE"]["tmp_name"]);
@rmdir(dirname($arFields["DETAIL_PICTURE"]["tmp_name"]));
}
foreach (GetModuleEvents("iblock", "OnAfterIBlockElementUpdate", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array(&$arFields));
}
if (defined("BX_COMP_MANAGED_CACHE")) {
$GLOBALS["CACHE_MANAGER"]->ClearByTag("iblock_id_" . $arIBlock["ID"]);
}
return $Result;
}
示例2: SetPermissions
public function SetPermissions($documentId, $workflowId, $arPermissions, $bRewrite = true)
{
$documentId = intval($documentId);
if ($documentId <= 0) {
throw new CBPArgumentNullException("documentId");
}
$documentType = self::GetDocumentType($documentId);
$iblockId = intval(substr($documentType, strlen("iblock_")));
if ($iblockId <= 0) {
throw new CBPArgumentOutOfRangeException("documentType", $documentType);
}
if (CIBlock::GetArrayByID($iblockId, "RIGHTS_MODE") !== "E") {
return;
}
$ob = new CIBlockElementRights($iblockId, $documentId);
$ar = $ob->GetRights();
if ($bRewrite) {
foreach ($ar as $i => $arRight) {
if ($arRight["XML_ID"] == $workflowId) {
unset($ar[$i]);
}
}
}
$i = 0;
$l = strlen("user_");
foreach ($arPermissions as $taskId => $arUsers) {
foreach ($arUsers as $user) {
$gc = null;
if ($user == 'author') {
$u = self::GetUsersFromUserGroup('author', $documentId);
foreach ($u as $u1) {
$gc = "U" . $u1;
}
} else {
$gc = substr($user, 0, $l) == "user_" ? "U" . substr($user, $l) : "G" . $user;
}
if ($gc != null) {
$ar["n" . $i] = array("GROUP_CODE" => $gc, "TASK_ID" => $taskId, "XML_ID" => $workflowId);
$i++;
}
}
}
$ob->SetRights($ar);
}
示例3: Add
//.........这里部分代码省略.........
foreach (GetModuleEvents("iblock", "OnIBlockElementAdd", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($arFields));
}
$IBLOCK_SECTION_ID = $arFields["IBLOCK_SECTION_ID"];
unset($arFields["IBLOCK_SECTION_ID"]);
$ID = $DB->Add("b_iblock_element", $arFields, array("DETAIL_TEXT", "SEARCHABLE_CONTENT"), "iblock");
if (array_key_exists("PREVIEW_PICTURE", $arFields)) {
$arFields["PREVIEW_PICTURE_ID"] = $arFields["PREVIEW_PICTURE"];
$arFields["PREVIEW_PICTURE"] = $SAVED_PREVIEW_PICTURE;
}
if (array_key_exists("DETAIL_PICTURE", $arFields)) {
$arFields["DETAIL_PICTURE_ID"] = $arFields["DETAIL_PICTURE"];
$arFields["DETAIL_PICTURE"] = $SAVED_DETAIL_PICTURE;
}
if (CIBlockElement::GetIBVersion($arFields["IBLOCK_ID"]) == 2) {
$DB->Query("INSERT INTO b_iblock_element_prop_s" . $arFields["IBLOCK_ID"] . "(IBLOCK_ELEMENT_ID)VALUES(" . $ID . ")");
}
if (!isset($arFields["XML_ID"]) || strlen($arFields["XML_ID"]) <= 0) {
$arFields["XML_ID"] = $ID;
$DB->Query("UPDATE b_iblock_element SET XML_ID = " . $ID . " WHERE ID = " . $ID);
}
if (is_set($arFields, "PROPERTY_VALUES")) {
CIBlockElement::SetPropertyValues($ID, $arFields["IBLOCK_ID"], $arFields["PROPERTY_VALUES"]);
}
if (is_set($arFields, "IBLOCK_SECTION")) {
CIBlockElement::SetElementSection($ID, $arFields["IBLOCK_SECTION"], true, $arIBlock["RIGHTS_MODE"] === "E" ? $arIBlock["ID"] : 0, $IBLOCK_SECTION_ID);
}
if ($arIBlock["RIGHTS_MODE"] === "E") {
$obElementRights = new CIBlockElementRights($arIBlock["ID"], $ID);
if (!is_set($arFields, "IBLOCK_SECTION") || empty($arFields["IBLOCK_SECTION"])) {
$obElementRights->ChangeParents(array(), array(0));
}
if (array_key_exists("RIGHTS", $arFields) && is_array($arFields["RIGHTS"])) {
$obElementRights->SetRights($arFields["RIGHTS"]);
}
}
if (array_key_exists("IPROPERTY_TEMPLATES", $arFields)) {
$ipropTemplates = new \Bitrix\Iblock\InheritedProperty\ElementTemplates($arIBlock["ID"], $ID);
$ipropTemplates->set($arFields["IPROPERTY_TEMPLATES"]);
}
if ($bUpdateSearch) {
CIBlockElement::UpdateSearch($ID);
}
\Bitrix\Iblock\PropertyIndex\Manager::updateElementIndex($arIBlock["ID"], $ID);
if (!isset($arFields["WF_PARENT_ELEMENT_ID"]) && $arIBlock["FIELDS"]["LOG_ELEMENT_ADD"]["IS_REQUIRED"] == "Y") {
$USER_ID = is_object($USER) ? intval($USER->GetID()) : 0;
$arEvents = GetModuleEvents("main", "OnBeforeEventLog", true);
if (empty($arEvents) || ExecuteModuleEventEx($arEvents[0], array($USER_ID)) === false) {
$rsElement = CIBlockElement::GetList(array(), array("=ID" => $ID), false, false, array("LIST_PAGE_URL", "NAME", "CODE"));
$arElement = $rsElement->GetNext();
$res = array("ID" => $ID, "CODE" => $arElement["CODE"], "NAME" => $arElement["NAME"], "ELEMENT_NAME" => $arIBlock["ELEMENT_NAME"], "USER_ID" => $USER_ID, "IBLOCK_PAGE_URL" => $arElement["LIST_PAGE_URL"]);
CEventLog::Log("IBLOCK", "IBLOCK_ELEMENT_ADD", "iblock", $arIBlock["ID"], serialize($res));
}
}
if ($bWorkFlow && intval($arFields["WF_PARENT_ELEMENT_ID"]) <= 0) {
// It is completly new element - so make it copy
unset($arFields["WF_NEW"]);
$arFields["WF_PARENT_ELEMENT_ID"] = $ID;
$arNewFields = $arFields;
$arNewFields["PREVIEW_PICTURE"] = $COPY_PREVIEW_PICTURE;
$arNewFields["DETAIL_PICTURE"] = $COPY_DETAIL_PICTURE;
if (is_array($arNewFields["PROPERTY_VALUES"])) {
$i = 0;
$db_prop = CIBlockProperty::GetList(array(), array("IBLOCK_ID" => $arFields["IBLOCK_ID"], "CHECK_PERMISSIONS" => "N", "PROPERTY_TYPE" => "F"));
while ($arProp = $db_prop->Fetch()) {
$i++;
示例4: CopyCommentRights
function CopyCommentRights($ID, $arFields)
{
if (empty($arFields['LOG_ID'])) {
return false;
}
if (empty(self::$storedFileIdsByComment[$arFields['SOURCE_ID']])) {
return false;
}
$arRights0 = array();
$rConst = 0;
$rs = CTask::GetList(array("LETTER" => "asc"), array("MODULE_ID" => "iblock", "LETTER" => "R"));
if ($ar = $rs->Fetch()) {
$rConst = $ar["ID"];
} else {
return false;
}
$dbRight = CSocNetLogRights::GetList(array(), array("LOG_ID" => $arFields["LOG_ID"]));
$i = 1;
while ($arRight = $dbRight->Fetch()) {
/*$arRights0["n" .$i] = Array(
"GROUP_CODE" => $arRight["GROUP_CODE"],
"TASK_ID" => $rConst,
);*/
$gc = $arRight["GROUP_CODE"];
if (array_key_exists($gc, $arRights0) && $arRights0[$gc]["TASK_ID"] >= $rConst) {
continue;
}
$arRights0[$gc] = array("KEY" => "n" . $i, "GROUP_CODE" => $gc, "TASK_ID" => $rConst);
$i++;
}
$arFilesID = self::$storedFileIdsByComment[$arFields['SOURCE_ID']];
$arFiles = array();
foreach ($arFilesID as $id) {
$id = intval($id);
if (intval($id) > 0) {
$arFiles[] = $id;
}
}
if (!$arFiles) {
return;
}
$ibe = new CIBlockElement();
$dbWDFile = $ibe->GetList(array(), array('ID' => $arFiles, 'SHOW_NEW' => 'Y'), false, false, array('ID', 'NAME', 'SECTION_ID', 'IBLOCK_ID', 'WF_NEW'));
while ($dbWDFile && ($arWDFile = $dbWDFile->Fetch())) {
$arRights1 = $arRights0;
$ob = new CIBlockElementRights($arWDFile['IBLOCK_ID'], $arWDFile['ID']);
$ar = $ob->GetRights();
foreach ($ar as $k => $v) {
$gc = $v["GROUP_CODE"];
if (array_key_exists($gc, $arRights1) && $arRights1[$gc]["TASK_ID"] >= $v["TASK_ID"]) {
continue;
}
$arRights1[$gc] = array("KEY" => $k, "GROUP_CODE" => $gc, "TASK_ID" => $v["TASK_ID"]);
}
$arRights2 = array();
foreach ($arRights1 as $v) {
$arRights2[$v["KEY"]] = array("GROUP_CODE" => $v["GROUP_CODE"], "TASK_ID" => $v["TASK_ID"]);
}
$ob->SetRights($arRights2);
}
}
示例5: SetPermissions
public function SetPermissions($documentId, $workflowId, $arPermissions, $bRewrite = true)
{
$documentId = intval($documentId);
if ($documentId <= 0)
throw new CBPArgumentNullException("documentId");
$documentType = self::GetDocumentType($documentId);
$iblockId = intval(substr($documentType, strlen("iblock_")));
if ($iblockId <= 0)
throw new CBPArgumentOutOfRangeException("documentType", $documentType);
if (CIBlock::GetArrayByID($iblockId, "RIGHTS_MODE") !== "E")
return;
$ob = new CIBlockElementRights($iblockId, $documentId);
$documentRights = $ob->GetRights();
$mode = 'Hold';
$scope = 'ScopeWorkflow';
if (is_array($bRewrite) && class_exists('CBPSetPermissionsMode'))
{
if (isset($bRewrite['setMode']))
$mode = CBPSetPermissionsMode::outMode($bRewrite['setMode']);
if (isset($bRewrite['setScope']))
$scope = CBPSetPermissionsMode::outScope($bRewrite['setScope']);
}
elseif ($bRewrite == true)
{
$mode = 'Clear';
}
$overrideCodes = array();
if ($mode == 'Clear' || $mode == 'Rewrite')
{
foreach ($documentRights as $i => $arRight)
{
if ($scope == 'ScopeDocument' || $scope == 'ScopeWorkflow' && $arRight["XML_ID"] == $workflowId)
{
if ($mode == 'Clear')
unset($documentRights[$i]);
if ($mode == 'Rewrite')
$overrideCodes[$arRight["GROUP_CODE"]] = $i;
}
}
}
$i = 0;
$l = strlen("user_");
foreach ($arPermissions as $taskId => $arUsers)
{
foreach ($arUsers as $user)
{
if (!$user)
continue;
$gc = null;
if ($user == 'author')
{
$u = self::GetUsersFromUserGroup('author', $documentId);
foreach ($u as $u1)
$gc = "U".$u1;
}
elseif (strpos($user, 'group_') === 0)
{
$gc = strtoupper(substr($user, strlen('group_')));
}
else
{
$gc = ((substr($user, 0, $l) == "user_") ? "U".substr($user, $l) : "G".$user);
}
if ($gc != null)
{
$documentRights["n".$i] = array("GROUP_CODE" => $gc, "TASK_ID" => $taskId, "XML_ID" => $workflowId);
$i++;
if (isset($overrideCodes[$gc]))
unset($documentRights[$overrideCodes[$gc]]);
}
}
}
$ob->SetRights($documentRights);
}