本文整理汇总了PHP中CIBlockElementRights::GetRights方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlockElementRights::GetRights方法的具体用法?PHP CIBlockElementRights::GetRights怎么用?PHP CIBlockElementRights::GetRights使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlockElementRights
的用法示例。
在下文中一共展示了CIBlockElementRights::GetRights方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
示例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: CIBlockElementRights
</td>
</tr>
<?
endif;
endif;
$tabControl->EndCustomField("BIZPROC", "");
endif;
if($arShowTabs['edit_rights']):
$tabControl->BeginNextFormTab();
if($ID > 0)
{
$obRights = new CIBlockElementRights($IBLOCK_ID, $ID);
$htmlHidden = '';
foreach($obRights->GetRights() as $RIGHT_ID => $arRight)
$htmlHidden .= '
<input type="hidden" name="RIGHTS[][RIGHT_ID]" value="'.htmlspecialcharsbx($RIGHT_ID).'">
<input type="hidden" name="RIGHTS[][GROUP_CODE]" value="'.htmlspecialcharsbx($arRight["GROUP_CODE"]).'">
<input type="hidden" name="RIGHTS[][TASK_ID]" value="'.htmlspecialcharsbx($arRight["TASK_ID"]).'">
';
}
else
{
$obRights = new CIBlockSectionRights($IBLOCK_ID, $MENU_SECTION_ID);
$htmlHidden = '';
}
$tabControl->BeginCustomField("RIGHTS", GetMessage("IBEL_E_RIGHTS_FIELD"));
IBlockShowRights(
'element',
示例4: GetProductData
/**
* @param array $arParams
* @return array|false
*/
public static function GetProductData($arParams)
{
$adminSection = defined('ADMIN_SECTION') && ADMIN_SECTION === true;
if (!isset($arParams['QUANTITY']) || (double) $arParams['QUANTITY'] <= 0) {
$arParams['QUANTITY'] = 0;
}
$arParams['RENEWAL'] = isset($arParams['RENEWAL']) && $arParams['RENEWAL'] == 'Y' ? 'Y' : 'N';
$arParams['CHECK_QUANTITY'] = isset($arParams['CHECK_QUANTITY']) && $arParams["CHECK_QUANTITY"] == 'N' ? 'N' : 'Y';
$arParams['CHECK_PRICE'] = isset($arParams['CHECK_PRICE']) && $arParams['CHECK_PRICE'] == 'N' ? 'N' : 'Y';
$arParams['CHECK_COUPONS'] = isset($arParams['CHECK_COUPONS']) && $arParams['CHECK_COUPONS'] == 'N' ? 'N' : 'Y';
$arParams['CHECK_DISCOUNT'] = isset($arParams['CHECK_DISCOUNT']) && $arParams['CHECK_DISCOUNT'] == 'N' ? 'N' : 'Y';
$arParams['SELECT_QUANTITY_TRACE'] = isset($arParams['SELECT_QUANTITY_TRACE']) && $arParams['SELECT_QUANTITY_TRACE'] == 'Y' ? 'Y' : 'N';
$arParams['BASKET_ID'] = (string) (isset($arParams['BASKET_ID']) ? $arParams['BASKET_ID'] : '0');
$arParams['USER_ID'] = isset($arParams['USER_ID']) ? (int) $arParams['USER_ID'] : 0;
if ($arParams['USER_ID'] < 0) {
$arParams['USER_ID'] = 0;
}
$arParams['SITE_ID'] = isset($arParams['SITE_ID']) ? $arParams['SITE_ID'] : false;
$strSiteID = $arParams['SITE_ID'];
$arParams['CURRENCY'] = isset($arParams['CURRENCY']) ? Currency\CurrencyManager::checkCurrencyID($arParams['CURRENCY']) : false;
if ($arParams['CURRENCY'] === false) {
$arParams['CURRENCY'] = CSaleLang::GetLangCurrency($strSiteID ? $strSiteID : SITE_ID);
}
$productID = (int) $arParams['PRODUCT_ID'];
$quantity = (double) $arParams['QUANTITY'];
$intUserID = (int) $arParams['USER_ID'];
global $USER, $APPLICATION;
$arResult = array();
if ($adminSection) {
if (!($userGroups = static::getHitCache('USER_GROUPS', $intUserID))) {
$userGroups = self::getUserGroups($intUserID);
static::setHitCache('USER_GROUPS', $intUserID, $userGroups);
}
if (empty($userGroups)) {
return $arResult;
}
if (!($arProduct = static::getHitCache('IBLOCK_ELEMENT_PERM_N', $productID))) {
$dbIBlockElement = CIBlockElement::GetList(array(), array('ID' => $productID, 'ACTIVE' => 'Y', 'ACTIVE_DATE' => 'Y', 'CHECK_PERMISSIONS' => 'N'), false, false, array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL'));
if ($arProduct = $dbIBlockElement->GetNext()) {
static::setHitCache('IBLOCK_ELEMENT_PERM_N', $productID, $arProduct);
}
unset($dbIBlockElement);
}
if (empty($arProduct) || !is_array($arProduct)) {
return $arResult;
}
if (!($iblockRights = static::getHitCache('IBLOCK_RIGHT', $arProduct['IBLOCK_ID']))) {
if ($iblockRights = CIBlock::GetArrayByID($arProduct['IBLOCK_ID'], 'RIGHTS_MODE')) {
static::setHitCache('IBLOCK_RIGHT', $arProduct['IBLOCK_ID'], $iblockRights);
}
}
$extRights = $iblockRights == 'E';
if ($intUserID == 0) {
if ($extRights) {
$elementRights = new CIBlockElementRights($arProduct['IBLOCK_ID'], $arProduct['ID']);
$readList = $elementRights->GetRights(array('operations' => array('element_read')));
$disable = true;
if (!empty($readList) && is_array($readList)) {
foreach ($readList as &$row) {
if ($row['GROUP_CODE'] == 'G2') {
$disable = false;
break;
}
}
unset($row);
}
unset($readList, $elementRights);
if ($disable) {
return $arResult;
}
unset($disable);
} else {
$groupRights = CIBlock::GetGroupPermissions($arProduct['IBLOCK_ID']);
if (empty($groupRights) || !isset($groupRights[2]) || $groupRights[2] < 'R') {
return $arResult;
}
unset($groupRights);
}
} else {
if ($extRights) {
$proxyUserPermissionKey = $productID . "|" . $intUserID;
if (!($arUserRights = static::getHitCache('USER_RIGHT', $proxyUserPermissionKey))) {
if ($arUserRights = CIBlockElementRights::GetUserOperations($productID, $intUserID)) {
static::setHitCache('USER_RIGHT', $proxyUserPermissionKey, $arUserRights);
}
}
if (empty($arUserRights) || !isset($arUserRights['element_read'])) {
return $arResult;
}
unset($arUserRights);
} else {
static $permissions = array();
if (empty($permissions[$arProduct['IBLOCK_ID'] . "_" . $intUserID])) {
$permissions[$arProduct['IBLOCK_ID'] . "_" . $intUserID] = CIBlock::GetPermission($arProduct['IBLOCK_ID'], $intUserID);
}
if ($permissions < 'R') {
//.........这里部分代码省略.........
示例5: GetReaders
static function GetReaders($ID, $iblockID = null)
{
static $arValidTasks = null;
static $readersCache = array();
$arReaders = array();
$ID = (int) $ID;
if ($ID <= 0) {
return $arReaders;
}
if (isset($readersCache[$ID])) {
return $readersCache[$ID];
}
if ($arValidTasks == null) {
$arTasks = CWebDavIblock::GetTasks();
$arValidTasks = array();
foreach ($arTasks as $taskLetter => $taskID) {
$arOperations = CTask::GetOperations($taskID, true);
if (array_search('element_read', $arOperations) !== false) {
$arValidTasks[$taskID] = true;
}
}
}
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 $arReaders;
}
$bSocNet = CModule::IncludeModule('socialnetwork');
if (CIBlock::GetArrayByID($iblockID, "RIGHTS_MODE") === "E") {
$ibRights = new CIBlockElementRights($iblockID, $ID);
$arRights = $ibRights->GetRights();
foreach ($arRights as $rightID => $arRight) {
if (isset($arValidTasks[$arRight['TASK_ID']])) {
$arReaders[] = $arRight['GROUP_CODE'];
if ($bSocNet && preg_match('/^SG(\\d+)_[' . SONET_ROLES_OWNER . SONET_ROLES_MODERATOR . SONET_ROLES_USER . ']$/', $arRight['GROUP_CODE'], $matches)) {
$arReaders[] = "SG" . $matches[1];
}
}
}
} else {
$gr_res = CIBlock::GetGroupPermissions($iblockID);
foreach ($gr_res as $group_id => $perm) {
if ($perm >= 'R') {
$arReaders[] = 'G' . $group_id;
}
}
}
$readersCache[$ID] = array_unique($arReaders);
return $readersCache[$ID];
}
示例6: 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);
}
示例7: unset
$arTasks = CIBlockRights::GetRightsList();
$arTaskLetters = CWebDavIblock::GetTasks();
//bad hack. It's not public rights.
if (isset($arTaskLetters['S'])) {
unset($arTasks[$arTaskLetters['S']]);
}
if (isset($arTaskLetters['T'])) {
unset($arTasks[$arTaskLetters['T']]);
}
$arResult['PERMISSIONS'] = $arTasks;
if (!$bCreate) {
$arRightParams = array("count_overwrited" => true);
if (!empty($arResult['ENTITY_PARENTS'])) {
$arRightParams['parents'] = $arResult['ENTITY_PARENTS'];
}
$arCurrent = $obIBlockRights->GetRights($arRightParams);
foreach ($arCurrent as $arRightSet) {
$arNames[] = $arRightSet["GROUP_CODE"];
}
$access = new CAccess();
$arSubjs = $access->GetNames($arNames);
if (!empty($arParams['SOCNET_TYPE']) && !$USER->CanDoOperation('webdav_change_settings') && intval($arParams['SOCNET_ID']) > 0) {
foreach ($arCurrent as $rightID => &$arRight) {
if ($arRight['GROUP_CODE'] === 'G1' && $arRight['IS_INHERITED'] === 'Y' && $arRight['TASK_ID'] === $arTaskLetters['X'] || $arRight['GROUP_CODE'] === 'G2' && $arRight['IS_INHERITED'] === 'Y' && $arRight['TASK_ID'] === $arTaskLetters['D']) {
unset($arCurrent[$rightID]);
// commont rights
continue;
}
if ($arParams['SOCNET_TYPE'] == 'group') {
if ($arRight['GROUP_CODE'] === 'SG' . $arParams['SOCNET_ID'] . '_A' && $arRight['TASK_ID'] === $arTaskLetters['X']) {
$arRight['IS_INHERITED'] = 'Y';