本文整理汇总了PHP中CAccess::UpdateCodes方法的典型用法代码示例。如果您正苦于以下问题:PHP CAccess::UpdateCodes方法的具体用法?PHP CAccess::UpdateCodes怎么用?PHP CAccess::UpdateCodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAccess
的用法示例。
在下文中一共展示了CAccess::UpdateCodes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: OnSearchCheckPermissions
public static function OnSearchCheckPermissions($FIELD)
{
global $USER;
$access = new CAccess();
$access->UpdateCodes();
$res = CAccess::GetUserCodes($USER->GetID(), array("PROVIDER_ID" => "intranet"));
$arResult = array();
while ($arr = $res->Fetch()) {
$arResult[] = $arr["ACCESS_CODE"];
}
return $arResult;
}
示例2: GetAccessCodes
/**
* @return array of access codes, includes AU symbol (if user is authorized)
*/
protected function GetAccessCodes($isUseCache = false)
{
global $USER;
static $cache = array();
$isNeedCAccessUpdate = true;
if ($isUseCache) {
// Cache hits?
if (isset($cache['str' . $this->userId])) {
return $cache['str' . $this->userId];
}
// Prevent call CAccess->UpdateCodes() multiple times per hit,
// except long time period (three seconds) expired.
if ($this->CAccessLastUpdated === false || microtime(true) - $this->CAccessLastUpdated > 3) {
$isNeedCAccessUpdate = true;
} else {
$isNeedCAccessUpdate = false;
}
} else {
$isNeedCAccessUpdate = true;
}
if ($isNeedCAccessUpdate) {
$oAcc = new CAccess();
$oAcc->UpdateCodes();
if ($isUseCache) {
$this->CAccessLastUpdated = microtime(true);
}
unset($oAcc);
}
$rc = CAccess::GetUserCodes($this->userId);
if ($rc === false) {
throw new LearnException('', LearnException::EXC_ERR_ALL_GIVEUP | LearnException::EXC_ERR_ALL_ACCESS_DENIED);
}
$arData = array();
while ($arItem = $rc->Fetch()) {
if ((int) $arItem['USER_ID'] !== $this->userId) {
throw new LearnException('', LearnException::EXC_ERR_ALL_GIVEUP | LearnException::EXC_ERR_ALL_LOGIC | LearnException::EXC_ERR_ALL_ACCESS_DENIED);
}
$arData[] = $arItem['ACCESS_CODE'];
}
if (is_object($USER) && $this->userId === (int) $USER->GetID()) {
$arData[] = 'AU';
}
// Cache in case when $isUseCache === false too.
// Because, this will refresh cache, if it exists before.
$cache['str' . $this->userId] = $arData;
return $arData;
}
示例3: strlen
function _check_rights_sql($min_permission)
{
global $DB, $USER;
$min_permission = strlen($min_permission) == 1 ? $min_permission : "R";
if (is_object($USER)) {
$iUserID = intval($USER->GetID());
$strGroups = $USER->GetGroups();
$bAuthorized = $USER->IsAuthorized();
} else {
$iUserID = 0;
$strGroups = "2";
$bAuthorized = false;
}
$stdPermissions = "\n\t\t\tSELECT IBLOCK_ID\n\t\t\tFROM b_iblock_group IBG\n\t\t\tWHERE IBG.GROUP_ID IN (" . $strGroups . ")\n\t\t\tAND IBG.PERMISSION >= '" . $DB->ForSQL($min_permission) . "'\n\t\t";
if (!defined("ADMIN_SECTION")) {
$stdPermissions .= "\n\t\t\t\tAND (IBG.PERMISSION='X' OR B.ACTIVE='Y')\n\t\t\t";
}
if ($min_permission >= "X") {
$operation = 'element_rights_edit';
} elseif ($min_permission >= "W") {
$operation = 'element_edit';
} elseif ($min_permission >= "R") {
$operation = 'element_read';
} else {
$operation = '';
}
if ($operation) {
$acc = new CAccess();
$acc->UpdateCodes();
}
if ($operation == "element_read") {
$extPermissions = "\n\t\t\t\tSELECT ER.ELEMENT_ID\n\t\t\t\tFROM b_iblock_element_right ER\n\t\t\t\tINNER JOIN b_iblock_right IBR ON IBR.ID = ER.RIGHT_ID\n\t\t\t\t" . ($iUserID > 0 ? "LEFT" : "INNER") . " JOIN b_user_access UA ON UA.ACCESS_CODE = IBR.GROUP_CODE AND UA.USER_ID = " . $iUserID . "\n\t\t\t\tWHERE ER.ELEMENT_ID = BE.ID\n\t\t\t\tAND IBR.OP_EREAD = 'Y'\n\t\t\t\t" . ($bAuthorized || $iUserID > 0 ? "\n\t\t\t\t\tAND (UA.USER_ID IS NOT NULL\n\t\t\t\t\t" . ($bAuthorized ? "OR IBR.GROUP_CODE = 'AU'" : "") . "\n\t\t\t\t\t" . ($iUserID > 0 ? "OR (IBR.GROUP_CODE = 'CR' AND BE.CREATED_BY = " . $iUserID . ")" : "") . "\n\t\t\t\t)" : "") . "\n\t\t\t";
$strResult = "(\n\t\t\t\tB.ID IN ({$stdPermissions})\n\t\t\t\tOR (B.RIGHTS_MODE = 'E' AND EXISTS ({$extPermissions}))\n\t\t\t)";
} elseif ($operation) {
$extPermissions = "\n\t\t\t\tSELECT ER.ELEMENT_ID\n\t\t\t\tFROM b_iblock_element_right ER\n\t\t\t\tINNER JOIN b_iblock_right IBR ON IBR.ID = ER.RIGHT_ID\n\t\t\t\tINNER JOIN b_task_operation T ON T.TASK_ID = IBR.TASK_ID\n\t\t\t\tINNER JOIN b_operation O ON O.ID = T.OPERATION_ID\n\t\t\t\t" . ($iUserID > 0 ? "LEFT" : "INNER") . " JOIN b_user_access UA ON UA.ACCESS_CODE = IBR.GROUP_CODE AND UA.USER_ID = " . $iUserID . "\n\t\t\t\tWHERE ER.ELEMENT_ID = BE.ID\n\t\t\t\tAND O.NAME = '" . $operation . "'\n\t\t\t\t" . ($bAuthorized || $iUserID > 0 ? "\n\t\t\t\t\tAND (UA.USER_ID IS NOT NULL\n\t\t\t\t\t" . ($bAuthorized ? "OR IBR.GROUP_CODE = 'AU'" : "") . "\n\t\t\t\t\t" . ($iUserID > 0 ? "OR (IBR.GROUP_CODE = 'CR' AND BE.CREATED_BY = " . $iUserID . ")" : "") . "\n\t\t\t\t)" : "") . "\n\t\t\t";
$strResult = "(\n\t\t\t\tB.ID IN ({$stdPermissions})\n\t\t\t\tOR (B.RIGHTS_MODE = 'E' AND EXISTS ({$extPermissions}))\n\t\t\t)";
} else {
$strResult = "(\n\t\t\t\tB.ID IN ({$stdPermissions})\n\t\t\t)";
}
return $strResult;
}
示例4: GetAccessCodes
function GetAccessCodes()
{
if (!$this->IsAuthorized()) {
return array('G2');
}
static $arCodes = array();
$USER_ID = intval($this->GetID());
if (!array_key_exists($USER_ID, $arCodes)) {
$access = new CAccess();
$access->UpdateCodes();
$arCodes[$USER_ID] = array();
$res = CAccess::GetUserCodes($USER_ID);
while ($arRes = $res->Fetch()) {
$arCodes[$USER_ID][] = $arRes["ACCESS_CODE"];
}
if ($this->IsAuthorized()) {
$arCodes[$USER_ID][] = "AU";
}
}
return $arCodes[$USER_ID];
}
示例5: Init
public static function Init($Params)
{
global $USER;
$access = new CAccess();
$access->UpdateCodes();
// Owner params
self::$siteId = isset($Params['siteId']) ? $Params['siteId'] : SITE_ID;
self::$type = $Params['type'];
self::$arTypes = CCalendarType::GetList();
self::$bIntranet = CCalendar::IsIntranetEnabled();
self::$bSocNet = self::IsSocNet();
self::$userId = isset($Params['userId']) ? intVal($Params['userId']) : CCalendar::GetCurUserId();
self::$bOwner = self::$type == 'user' || self::$type == 'group';
self::$settings = self::GetSettings();
self::$userSettings = self::GetUserSettings();
self::$pathesForSite = self::GetPathes(self::$siteId);
self::$pathToUser = self::$pathesForSite['path_to_user'];
self::$bSuperpose = $Params['allowSuperpose'] != false && self::$bSocNet;
self::$bAnonym = !$USER || !$USER->IsAuthorized();
self::$userNameTemplate = self::$settings['user_name_template'];
self::$bAMPM = IsAmPmMode();
self::$bWideDate = strpos(FORMAT_DATETIME, 'MMMM') !== false;
if (isset($Params['SectionControlsDOMId'])) {
self::$SectionsControlsDOMId = $Params['SectionControlsDOMId'];
}
if (self::$bOwner && isset($Params['ownerId']) && $Params['ownerId'] > 0) {
self::$ownerId = intVal($Params['ownerId']);
}
self::$bTasks = self::$type == 'user' && $Params['showTasks'] !== false && CModule::IncludeModule('tasks');
if (self::$bTasks && self::$ownerId != self::$userId) {
self::$bTasks = false;
}
self::GetPermissions(array('type' => self::$type, 'bOwner' => self::$bOwner, 'userId' => self::$userId, 'ownerId' => self::$ownerId));
// Cache params
if (isset($Params['cachePath'])) {
self::$cachePath = $Params['cachePath'];
}
if (isset($Params['cacheTime'])) {
self::$cacheTime = $Params['cacheTime'];
}
self::$bCache = self::$cacheTime > 0;
// Urls
$page = preg_replace(array("/EVENT_ID=.*?\\&/i", "/CHOOSE_MR=.*?\\&/i", "/action=.*?\\&/i", "/bx_event_calendar_request=.*?\\&/i", "/clear_cache=.*?\\&/i", "/bitrix_include_areas=.*?\\&/i", "/bitrix_show_mode=.*?\\&/i", "/back_url_admin=.*?\\&/i"), "", $Params['pageUrl'] . '&');
$page = preg_replace(array("/^(.*?)\\&\$/i", "/^(.*?)\\?\$/i"), "\$1", $page);
self::$actionUrl = $page;
if (self::$bOwner && !empty(self::$ownerId)) {
self::$path = self::GetPath(self::$type, self::$ownerId, true);
} else {
self::$path = CCalendar::GetServerPath() . $page;
}
self::$outerUrl = $GLOBALS['APPLICATION']->GetCurPageParam('', array("action", "bx_event_calendar_request", "clear_cache", "bitrix_include_areas", "bitrix_show_mode", "back_url_admin", "SEF_APPLICATION_CUR_PAGE_URL", "EVENT_ID", "CHOOSE_MR"), false);
// Superposing
self::$bCanAddToSuperpose = false;
if (self::$bSuperpose) {
if (self::$type == 'user' || self::$type == 'group') {
self::$bCanAddToSuperpose = true;
}
foreach (self::$arTypes as $t) {
if (is_array(self::$settings['denied_superpose_types']) && !in_array($t['XML_ID'], self::$settings['denied_superpose_types'])) {
self::$arSPTypes[] = $t['XML_ID'];
}
}
self::$bCanAddToSuperpose = is_array(self::$arSPTypes) && in_array(self::$type, self::$arSPTypes);
}
// **** Reserve meeting and reserve video meeting
// *** Meeting room params ***
$RMiblockId = self::$settings['rm_iblock_id'];
self::$allowReserveMeeting = $Params["allowResMeeting"] && $RMiblockId > 0;
if (self::$allowReserveMeeting && !$USER->IsAdmin() && CIBlock::GetPermission($RMiblockId) < "R") {
self::$allowReserveMeeting = false;
}
// *** Video meeting room params ***
$VMiblockId = self::$settings['vr_iblock_id'];
self::$allowVideoMeeting = $Params["allowVideoMeeting"] && $VMiblockId > 0;
if (self::$allowVideoMeeting && !$USER->IsAdmin() && CIBlock::GetPermission($VMiblockId) < "R" || !CModule::IncludeModule("video")) {
self::$allowVideoMeeting = false;
}
}
示例6: GetList
//.........这里部分代码省略.........
&& intval($arParams["USER_ID"]) > 0
)
$arParams["SUBSCRIBE_USER_ID"] = $arParams["USER_ID"];
else
$arParams["SUBSCRIBE_USER_ID"] = $GLOBALS["USER"]->GetID();
}
if (!array_key_exists("MY_ENTITIES", $arParams))
{
foreach($arSocNetAllowedSubscribeEntityTypesDesc as $entity_type_tmp => $arEntityTypeTmp)
if (
array_key_exists("HAS_MY", $arEntityTypeTmp)
&& $arEntityTypeTmp["HAS_MY"] == "Y"
&& array_key_exists("CLASS_MY", $arEntityTypeTmp)
&& array_key_exists("METHOD_MY", $arEntityTypeTmp)
&& strlen($arEntityTypeTmp["CLASS_MY"]) > 0
&& strlen($arEntityTypeTmp["METHOD_MY"]) > 0
&& method_exists($arEntityTypeTmp["CLASS_MY"], $arEntityTypeTmp["METHOD_MY"])
)
$arMyEntities[$entity_type_tmp] = call_user_func(array($arEntityTypeTmp["CLASS_MY"], $arEntityTypeTmp["METHOD_MY"]));
$arParams["MY_ENTITIES"] = $arMyEntities;
}
}
if (
!empty($arParams)
&& array_key_exists("CHECK_RIGHTS", $arParams)
&& $arParams["CHECK_RIGHTS"] == "Y"
&& array_key_exists("USER_ID", $arParams)
)
{
$acc = new CAccess;
$acc->UpdateCodes();
$arSqls["RIGHTS"] = "EXISTS ( SELECT SLR.ID FROM b_sonet_log_right SLR
LEFT JOIN b_user_access UA ON (UA.ACCESS_CODE = SLR.GROUP_CODE AND UA.USER_ID = ".(is_object($USER)? intval($USER->GetID()): 0).")
WHERE LC.LOG_ID = SLR.LOG_ID AND (0=1 ".
(is_object($USER) && CSocNetUser::IsCurrentUserModuleAdmin() ? " OR SLR.GROUP_CODE = 'SA'" : "").
(is_object($USER) && $USER->IsAuthorized() ? " OR (SLR.GROUP_CODE = 'AU')" : "").
" OR (SLR.GROUP_CODE = 'G2')".
(is_object($USER) && $USER->IsAuthorized() ? " OR (UA.ACCESS_CODE = SLR.GROUP_CODE AND UA.USER_ID = ".$USER->GetID().")" : "")."))";
}
if (
!empty($arParams)
&& array_key_exists("CHECK_CRM_RIGHTS", $arParams)
&& $arParams["CHECK_CRM_RIGHTS"] == "Y"
&& array_key_exists("USER_ID", $arParams)
)
{
$arSqls["CRM_RIGHTS"] = "";
}
if (
$arParams["USE_SUBSCRIBE"] == "Y"
&& intval($arParams["SUBSCRIBE_USER_ID"]) > 0
)
{
$arSqls["SUBSCRIBE"] = CSocNetLogEvents::GetSQL(
$arParams["SUBSCRIBE_USER_ID"],
(is_array($arParams["MY_ENTITIES"]) ? $arParams["MY_ENTITIES"] : array()),
$arParams["TRANSPORT"],
$arParams["VISIBLE"],
"LC"
);
示例7: GetUserCodes
public static function GetUserCodes($USER_ID, $arFilter = array())
{
global $DB;
$access = new CAccess();
$access->UpdateCodes(array('USER_ID' => $USER_ID));
$arWhere = array();
foreach ($arFilter as $key => $val) {
$key = strtoupper($key);
switch ($key) {
case "ACCESS_CODE":
if (!is_array($val)) {
$val = array($val);
}
$arIn = array();
foreach ($val as $code) {
if (trim($code) != '') {
$arIn[] = "'" . $DB->ForSQL(trim($code)) . "'";
}
}
if (!empty($arIn)) {
$arWhere[] = "access_code in(" . implode(",", $arIn) . ")";
}
break;
case "PROVIDER_ID":
$arWhere[] = "provider_id='" . $DB->ForSQL($val) . "'";
break;
}
}
$sWhere = '';
if (!empty($arWhere)) {
$sWhere = " and " . implode(" and ", $arWhere);
}
return $DB->Query("select * from b_user_access where user_id=" . intval($USER_ID) . $sWhere);
}
示例8: intval
function _check_rights_sql($min_permission)
{
global $DB, $USER;
$min_permission = (strlen($min_permission)==1) ? $min_permission : "R";
if(is_object($USER))
{
$iUserID = intval($USER->GetID());
$strGroups = $USER->GetGroups();
$bAuthorized = $USER->IsAuthorized();
}
else
{
$iUserID = 0;
$strGroups = "2";
$bAuthorized = false;
}
$stdPermissions = "
SELECT IBLOCK_ID
FROM b_iblock_group IBG
WHERE IBG.GROUP_ID IN (".$strGroups.")
AND IBG.PERMISSION >= '".$DB->ForSQL($min_permission)."'
";
if(!defined("ADMIN_SECTION"))
$stdPermissions .= "
AND (IBG.PERMISSION='X' OR B.ACTIVE='Y')
";
if($min_permission >= "X")
$operation = 'section_rights_edit';
elseif($min_permission >= "W")
$operation = 'section_edit';
elseif($min_permission >= "R")
$operation = 'section_read';
else
$operation = '';
if($operation)
{
$acc = new CAccess;
$acc->UpdateCodes();
}
if($operation == "section_read")
{
$extPermissions = "
SELECT SR.SECTION_ID
FROM b_iblock_section_right SR
INNER JOIN b_iblock_right IBR ON IBR.ID = SR.RIGHT_ID
".($iUserID > 0? "LEFT": "INNER")." JOIN b_user_access UA ON UA.ACCESS_CODE = IBR.GROUP_CODE AND UA.USER_ID = ".$iUserID."
WHERE SR.SECTION_ID = BS.ID
AND IBR.OP_SREAD = 'Y'
".($bAuthorized || $iUserID > 0? "
AND (UA.USER_ID IS NOT NULL
".($bAuthorized? "OR IBR.GROUP_CODE = 'AU'": "")."
".($iUserID > 0? "OR (IBR.GROUP_CODE = 'CR' AND BS.CREATED_BY = ".$iUserID.")": "")."
)": "")."
";
$strResult = "(
B.ID IN ($stdPermissions)
OR (B.RIGHTS_MODE = 'E' AND EXISTS ($extPermissions))
)";
}
elseif($operation)
{
$extPermissions = "
SELECT SR.SECTION_ID
FROM b_iblock_section_right SR
INNER JOIN b_iblock_right IBR ON IBR.ID = SR.RIGHT_ID
INNER JOIN b_task_operation T ON T.TASK_ID = IBR.TASK_ID
INNER JOIN b_operation O ON O.ID = T.OPERATION_ID
".($iUserID > 0? "LEFT": "INNER")." JOIN b_user_access UA ON UA.ACCESS_CODE = IBR.GROUP_CODE AND UA.USER_ID = ".$iUserID."
WHERE SR.SECTION_ID = BS.ID
AND O.NAME = '".$operation."'
".($bAuthorized || $iUserID > 0? "
AND (UA.USER_ID IS NOT NULL
".($bAuthorized? "OR IBR.GROUP_CODE = 'AU'": "")."
".($iUserID > 0? "OR (IBR.GROUP_CODE = 'CR' AND BS.CREATED_BY = ".$iUserID.")": "")."
)": "")."
";
$strResult = "(
B.ID IN ($stdPermissions)
OR (B.RIGHTS_MODE = 'E' AND EXISTS ($extPermissions))
)";
}
else
{
$strResult = "(
B.ID IN ($stdPermissions)
)";
}
return $strResult;
}
示例9: GetList
public static function GetList($arOrder = array("SORT" => "ASC"), $arFilter = array(), $bIncCnt = false)
{
global $DB, $USER;
$strSqlSearch = "";
$bAddSites = false;
foreach ($arFilter as $key => $val) {
$res = CIBlock::MkOperationFilter($key);
$key = strtoupper($res["FIELD"]);
$cOperationType = $res["OPERATION"];
switch ($key) {
case "ACTIVE":
$sql = CIBlock::FilterCreate("B.ACTIVE", $val, "string_equal", $cOperationType);
break;
case "LID":
case "SITE_ID":
$sql = CIBlock::FilterCreate("BS.SITE_ID", $val, "string_equal", $cOperationType);
if (strlen($sql)) {
$bAddSites = true;
}
break;
case "NAME":
case "CODE":
case "XML_ID":
case "PROPERTY_INDEX":
$sql = CIBlock::FilterCreate("B." . $key, $val, "string", $cOperationType);
break;
case "EXTERNAL_ID":
$sql = CIBlock::FilterCreate("B.XML_ID", $val, "string", $cOperationType);
break;
case "TYPE":
$sql = CIBlock::FilterCreate("B.IBLOCK_TYPE_ID", $val, "string", $cOperationType);
break;
case "ID":
case "VERSION":
case "SOCNET_GROUP_ID":
$sql = CIBlock::FilterCreate("B." . $key, $val, "number", $cOperationType);
break;
default:
$sql = "";
break;
}
if (strlen($sql)) {
$strSqlSearch .= " AND (" . $sql . ") ";
}
}
$bCheckPermissions = !array_key_exists("CHECK_PERMISSIONS", $arFilter) || $arFilter["CHECK_PERMISSIONS"] !== "N" || array_key_exists("OPERATION", $arFilter);
$bIsAdmin = is_object($USER) && $USER->IsAdmin();
if ($bCheckPermissions && !$bIsAdmin) {
$min_permission = strlen($arFilter["MIN_PERMISSION"]) == 1 ? $arFilter["MIN_PERMISSION"] : "R";
if (is_object($USER)) {
$iUserID = intval($USER->GetID());
$strGroups = $USER->GetGroups();
$bAuthorized = $USER->IsAuthorized();
} else {
$iUserID = 0;
$strGroups = "2";
$bAuthorized = false;
}
$stdPermissions = "\n\t\t\t\tSELECT IBLOCK_ID\n\t\t\t\tFROM b_iblock_group IBG\n\t\t\t\tWHERE IBG.GROUP_ID IN (" . $strGroups . ")\n\t\t\t\tAND IBG.PERMISSION >= '" . $min_permission . "'\n\t\t\t";
if (!defined("ADMIN_SECTION")) {
$stdPermissions .= "\n\t\t\t\t\tAND (IBG.PERMISSION='X' OR B.ACTIVE='Y')\n\t\t\t\t";
}
if (strlen($arFilter["OPERATION"]) > 0) {
$operation = "'" . $DB->ForSql($arFilter["OPERATION"]) . "'";
} elseif ($min_permission >= "X") {
$operation = "'iblock_edit'";
} elseif ($min_permission >= "U") {
$operation = "'element_edit'";
} elseif ($min_permission >= "S") {
$operation = "'iblock_admin_display'";
} else {
$operation = "'section_read', 'element_read', 'section_element_bind', 'section_section_bind'";
}
if ($operation) {
$acc = new CAccess();
$acc->UpdateCodes();
$extPermissions = "\n\t\t\t\t\tSELECT IBLOCK_ID\n\t\t\t\t\tFROM b_iblock_right IBR\n\t\t\t\t\tINNER JOIN b_task_operation T ON T.TASK_ID = IBR.TASK_ID\n\t\t\t\t\tINNER JOIN b_operation O ON O.ID = T.OPERATION_ID\n\t\t\t\t\t" . ($iUserID > 0 ? "LEFT" : "INNER") . " JOIN b_user_access UA ON UA.ACCESS_CODE = IBR.GROUP_CODE AND UA.USER_ID = " . $iUserID . "\n\t\t\t\t\tWHERE IBR.ENTITY_TYPE = 'iblock'\n\t\t\t\t\tAND O.NAME in (" . $operation . ")\n\t\t\t\t\t" . ($bAuthorized ? "AND (UA.USER_ID IS NOT NULL OR IBR.GROUP_CODE = 'AU')" : "") . "\n\t\t\t\t";
$sqlPermissions = "AND (\n\t\t\t\t\tB.ID IN ({$stdPermissions})\n\t\t\t\t\tOR (B.RIGHTS_MODE = 'E' AND B.ID IN ({$extPermissions}))\n\t\t\t\t)";
} else {
$sqlPermissions = "AND (\n\t\t\t\t\tB.ID IN ({$stdPermissions})\n\t\t\t\t)";
}
} else {
$sqlPermissions = "";
}
if ($bAddSites) {
$sqlJoinSites = "LEFT JOIN b_iblock_site BS ON B.ID=BS.IBLOCK_ID\n\t\t\t\t\tLEFT JOIN b_lang L ON L.LID=BS.SITE_ID";
} else {
$sqlJoinSites = "INNER JOIN b_lang L ON L.LID=B.LID";
}
if (!$bIncCnt) {
$strSql = "\n\t\t\t\tSELECT DISTINCT\n\t\t\t\t\tB.*\n\t\t\t\t\t,B.XML_ID as EXTERNAL_ID\n\t\t\t\t\t," . $DB->DateToCharFunction("B.TIMESTAMP_X") . " as TIMESTAMP_X\n\t\t\t\t\t,L.DIR as LANG_DIR\n\t\t\t\t\t,L.SERVER_NAME\n\t\t\t\tFROM\n\t\t\t\t\tb_iblock B\n\t\t\t\t\t" . $sqlJoinSites . "\n\t\t\t\tWHERE 1 = 1\n\t\t\t\t\t" . $sqlPermissions . "\n\t\t\t\t\t" . $strSqlSearch . "\n\t\t\t";
} else {
$strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tB.*\n\t\t\t\t\t,B.XML_ID as EXTERNAL_ID\n\t\t\t\t\t," . $DB->DateToCharFunction("B.TIMESTAMP_X") . " as TIMESTAMP_X\n\t\t\t\t\t,L.DIR as LANG_DIR\n\t\t\t\t\t,L.SERVER_NAME\n\t\t\t\t\t,COUNT(DISTINCT BE.ID) as ELEMENT_CNT\n\t\t\t\tFROM\n\t\t\t\t\tb_iblock B\n\t\t\t\t\t" . $sqlJoinSites . "\n\t\t\t\t\tLEFT JOIN b_iblock_element BE ON (BE.IBLOCK_ID=B.ID\n\t\t\t\t\t\tAND (\n\t\t\t\t\t\t\t(BE.WF_STATUS_ID=1 AND BE.WF_PARENT_ELEMENT_ID IS NULL )\n\t\t\t\t\t\t\t" . ($arFilter["CNT_ALL"] == "Y" ? " OR BE.WF_NEW='Y' " : "") . "\n\t\t\t\t\t\t)\n\t\t\t\t\t\t" . ($arFilter["CNT_ACTIVE"] == "Y" ? "AND BE.ACTIVE='Y'\n\t\t\t\t\t\tAND (BE.ACTIVE_TO >= " . $DB->CurrentDateFunction() . " OR BE.ACTIVE_TO IS NULL)\n\t\t\t\t\t\tAND (BE.ACTIVE_FROM <= " . $DB->CurrentDateFunction() . " OR BE.ACTIVE_FROM IS NULL)\n\t\t\t\t\t\t" : "") . "\n\t\t\t\t\t)\n\t\t\t\tWHERE 1 = 1\n\t\t\t\t\t" . $sqlPermissions . "\n\t\t\t\t\t" . $strSqlSearch . "\n\t\t\t\tGROUP BY B.ID\n\t\t\t";
}
$arSqlOrder = array();
if (is_array($arOrder)) {
foreach ($arOrder as $by => $order) {
$by = strtolower($by);
$order = strtolower($order);
if ($order != "asc") {
//.........这里部分代码省略.........
示例10: UserHasRightTo
static function UserHasRightTo($IBLOCK_ID, $ID, $permission, $flags = 0)
{
$acc = new CAccess;
$acc->UpdateCodes();
$obRights = new CIBlockElementRights($IBLOCK_ID, 0);
return CIBlockRights::_check_if_user_has_right($obRights, $ID, $permission, $flags);
}
示例11: GetUserOperations
static function GetUserOperations($arID, $USER_ID = 0)
{
global $DB, $USER;
$USER_ID = intval($USER_ID);
if(is_object($USER))
{
if($USER_ID <= 0)
$USER_ID = intval($USER->GetID());
$bAuthorized = $USER->IsAuthorized();
}
else
{
$bAuthorized = false;
}
if ($USER_ID > 0)
{
$acc = new CAccess;
$acc->UpdateCodes();
}
if(!is_array($arID))
$sqlID = array(intval($arID));
elseif(empty($arID))
return array();
else
$sqlID = array_map('intval', $arID);
$rs = $DB->Query("
SELECT ER.ELEMENT_ID ID, O.NAME
FROM b_iblock_element E
INNER JOIN b_iblock_element_right ER ON ER.ELEMENT_ID = E.ID
INNER JOIN b_iblock_right IBR ON IBR.ID = ER.RIGHT_ID
INNER JOIN b_task_operation T ON T.TASK_ID = IBR.TASK_ID
INNER JOIN b_operation O ON O.ID = T.OPERATION_ID
".($USER_ID > 0? "LEFT": "INNER")." JOIN b_user_access UA ON UA.ACCESS_CODE = IBR.GROUP_CODE AND UA.USER_ID = ".$USER_ID."
WHERE E.ID in (".implode(", ", $sqlID).")
".($bAuthorized || $USER_ID > 0? "
AND (UA.USER_ID IS NOT NULL
".($bAuthorized? "OR IBR.GROUP_CODE = 'AU'": "")."
".($USER_ID > 0? "OR (IBR.GROUP_CODE = 'CR' AND E.CREATED_BY = ".$USER_ID.")": "")."
)": "")."
");
$arResult = array();
while($ar = $rs->Fetch())
$arResult[$ar["ID"]][$ar["NAME"]] = $ar["NAME"];
if(is_array($arID))
return $arResult;
elseif(array_key_exists($arID, $arResult))
return $arResult[$arID];
else
return array();
}
示例12: GetList
public static function GetList($Params = array())
{
global $DB;
$access = new CAccess();
$access->UpdateCodes();
$arFilter = $Params['arFilter'];
$arOrder = isset($Params['arOrder']) ? $Params['arOrder'] : array('XML_ID' => 'asc');
$checkPermissions = $Params['checkPermissions'] !== false;
$bCache = CCalendar::CacheTime() > 0;
if ($bCache) {
$cache = new CPHPCache();
$cacheId = serialize(array('type_list', $arFilter, $arOrder));
$cachePath = CCalendar::CachePath() . 'type_list';
if ($cache->InitCache(CCalendar::CacheTime(), $cacheId, $cachePath)) {
$res = $cache->GetVars();
$arResult = $res["arResult"];
$arTypeXmlIds = $res["arTypeXmlIds"];
}
}
if (!$bCache || !isset($arTypeXmlIds)) {
static $arFields = array("XML_ID" => array("FIELD_NAME" => "CT.XML_ID", "FIELD_TYPE" => "string"), "NAME" => array("FIELD_NAME" => "CT.NAME", "FIELD_TYPE" => "string"), "ACTIVE" => array("FIELD_NAME" => "CT.ACTIVE", "FIELD_TYPE" => "string"), "DESCRIPTION" => array("FIELD_NAME" => "CT.DESCRIPTION", "FIELD_TYPE" => "string"), "EXTERNAL_ID" => array("FIELD_NAME" => "CT.EXTERNAL_ID", "FIELD_TYPE" => "string"));
$err_mess = "Function: CCalendarType::GetList<br>Line: ";
$arSqlSearch = array();
$strSqlSearch = "";
if (is_array($arFilter)) {
$filter_keys = array_keys($arFilter);
for ($i = 0, $l = count($filter_keys); $i < $l; $i++) {
$n = strtoupper($filter_keys[$i]);
$val = $arFilter[$filter_keys[$i]];
if (is_string($val) && strlen($val) <= 0) {
continue;
}
if ($n == 'XML_ID') {
if (is_array($val)) {
$strXml = "";
foreach ($val as $xmlId) {
$strXml .= ",'" . CDatabase::ForSql($xmlId) . "'";
}
$arSqlSearch[] = "CT.XML_ID in (" . trim($strXml, ", ") . ")";
} else {
$arSqlSearch[] = GetFilterQuery("CT.XML_ID", $val, 'N');
}
}
if ($n == 'EXTERNAL_ID') {
$arSqlSearch[] = GetFilterQuery("CT.EXTERNAL_ID", $val, 'N');
} elseif (isset($arFields[$n])) {
$arSqlSearch[] = GetFilterQuery($arFields[$n]["FIELD_NAME"], $val);
}
}
}
$strOrderBy = '';
foreach ($arOrder as $by => $order) {
if (isset($arFields[strtoupper($by)])) {
$strOrderBy .= $arFields[strtoupper($by)]["FIELD_NAME"] . ' ' . (strtolower($order) == 'desc' ? 'desc' . (strtoupper($DB->type) == "ORACLE" ? " NULLS LAST" : "") : 'asc' . (strtoupper($DB->type) == "ORACLE" ? " NULLS FIRST" : "")) . ',';
}
}
if (strlen($strOrderBy) > 0) {
$strOrderBy = "ORDER BY " . rtrim($strOrderBy, ",");
}
$strSqlSearch = GetFilterSqlSearch($arSqlSearch);
$strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tCT.*\n\t\t\t\tFROM\n\t\t\t\t\tb_calendar_type CT\n\t\t\t\tWHERE\n\t\t\t\t\t{$strSqlSearch}\n\t\t\t\t{$strOrderBy}";
$res = $DB->Query($strSql, false, $err_mess . __LINE__);
$arResult = array();
$arTypeXmlIds = array();
while ($arRes = $res->Fetch()) {
$arResult[] = $arRes;
$arTypeXmlIds[] = $arRes['XML_ID'];
}
if ($bCache) {
$cache->StartDataCache(CCalendar::CacheTime(), $cacheId, $cachePath);
$cache->EndDataCache(array("arResult" => $arResult, "arTypeXmlIds" => $arTypeXmlIds));
}
}
if ($checkPermissions && count($arTypeXmlIds) > 0) {
$arPerm = self::GetArrayPermissions($arTypeXmlIds);
$res = array();
$arAccessCodes = array();
foreach ($arResult as $type) {
$typeXmlId = $type['XML_ID'];
if (self::CanDo('calendar_type_view', $typeXmlId)) {
$type['PERM'] = array('view' => self::CanDo('calendar_type_view', $typeXmlId), 'add' => self::CanDo('calendar_type_add', $typeXmlId), 'edit' => self::CanDo('calendar_type_edit', $typeXmlId), 'edit_section' => self::CanDo('calendar_type_edit_section', $typeXmlId), 'access' => self::CanDo('calendar_type_access', $typeXmlId));
if (self::CanDo('calendar_type_access', $typeXmlId)) {
$type['ACCESS'] = array();
if (count($arPerm[$typeXmlId]) > 0) {
// Add codes to get they full names for interface
$arAccessCodes = array_merge($arAccessCodes, array_keys($arPerm[$typeXmlId]));
$type['ACCESS'] = $arPerm[$typeXmlId];
}
}
$res[] = $type;
}
}
CCalendar::PushAccessNames($arAccessCodes);
$arResult = $res;
}
return $arResult;
}
示例13: GetUserPerms
public static function GetUserPerms($userID)
{
global $DB;
$userID = intval($userID);
if ($userID <= 0) {
return array();
}
// Prepare user codes if need
$CAccess = new CAccess();
$CAccess->UpdateCodes(array('USER_ID' => $userID));
$obRes = $DB->Query("SELECT RP.* FROM b_crm_role_perms RP INNER JOIN b_crm_role_relation RR ON RR.ROLE_ID = RP.ROLE_ID INNER JOIN b_user_access UA ON UA.ACCESS_CODE = RR.RELATION AND UA.USER_ID = {$userID}", false, 'FILE: ' . __FILE__ . '<br /> LINE: ' . __LINE__);
$arResult = array();
while ($arRow = $obRes->Fetch()) {
$arRow['ATTR'] = trim($arRow['ATTR']);
if ($arRow['FIELD'] == '-') {
if (!isset($arResult[$arRow['ENTITY']][$arRow['PERM_TYPE']][$arRow['FIELD']]) || $arRow['ATTR'] > $arResult[$arRow['ENTITY']][$arRow['PERM_TYPE']][$arRow['FIELD']]) {
$arResult[$arRow['ENTITY']][$arRow['PERM_TYPE']][$arRow['FIELD']] = $arRow['ATTR'];
}
} else {
if (!isset($arResult[$arRow['ENTITY']][$arRow['PERM_TYPE']][$arRow['FIELD']][$arRow['FIELD_VALUE']]) || $arRow['ATTR'] > $arResult[$arRow['ENTITY']][$arRow['PERM_TYPE']][$arRow['FIELD']][$arRow['FIELD_VALUE']]) {
$arResult[$arRow['ENTITY']][$arRow['PERM_TYPE']][$arRow['FIELD']][$arRow['FIELD_VALUE']] = $arRow['ATTR'];
}
}
}
return $arResult;
}
示例14: GetUserAttr
public static function GetUserAttr($iUserID)
{
static $arResult = array();
if (!empty($arResult[$iUserID])) {
return $arResult[$iUserID];
}
$iUserID = (int) $iUserID;
$arResult[$iUserID] = array();
$CAccess = new CAccess();
$CAccess->UpdateCodes(array('USER_ID' => $iUserID));
$obRes = CAccess::GetUserCodes($iUserID);
while ($arCode = $obRes->Fetch()) {
if (strpos($arCode['ACCESS_CODE'], 'DR') !== 0) {
$arResult[$iUserID][strtoupper($arCode['PROVIDER_ID'])][] = $arCode['ACCESS_CODE'];
}
}
if (!empty($arResult[$iUserID]['INTRANET']) && IsModuleInstalled('intranet')) {
foreach ($arResult[$iUserID]['INTRANET'] as $iDepartment) {
if (substr($iDepartment, 0, 1) === 'D') {
$arTree = CIntranetUtils::GetDeparmentsTree(substr($iDepartment, 1), true);
foreach ($arTree as $iSubDepartment) {
$arResult[$iUserID]['SUBINTRANET'][] = 'D' . $iSubDepartment;
}
}
}
}
return $arResult[$iUserID];
}
示例15: GetList
//.........这里部分代码省略.........
ExecuteModuleEventEx($arEvent, array(&$arFields, &$arOrder, &$arFilter, &$arGroupBy, &$arSelectFields, &$arSqls));
}
$r = $obUserFieldsSql->GetFilter();
if (strlen($r) > 0) {
$strSqlUFFilter = " (" . $r . ") ";
}
$arSqls["RIGHTS"] = "";
$arSqls["CRM_RIGHTS"] = "";
if (!empty($arParams) && (array_key_exists("CHECK_RIGHTS", $arParams) && $arParams["CHECK_RIGHTS"] == "Y" || array_key_exists("CHECK_CRM_RIGHTS", $arParams) && $arParams["CHECK_CRM_RIGHTS"] == "Y") && !array_key_exists("USER_ID", $arParams) && is_object($USER)) {
$arParams["USER_ID"] = $USER->GetID();
}
if (!empty($arParams) && array_key_exists("USER_ID", $arParams) && $arParams["CHECK_CRM_RIGHTS"] != "Y") {
$arParams["CHECK_RIGHTS"] = "Y";
}
if (!empty($arParams) && ($arParams["USE_SUBSCRIBE"] == "Y" || $arParams["USE_FOLLOW"] == "Y")) {
if (!array_key_exists("SUBSCRIBE_USER_ID", $arParams)) {
if (array_key_exists("USER_ID", $arParams) && intval($arParams["USER_ID"]) > 0) {
$arParams["SUBSCRIBE_USER_ID"] = $arParams["USER_ID"];
} elseif (is_object($USER)) {
$arParams["SUBSCRIBE_USER_ID"] = $USER->GetID();
}
}
if ($arParams["USE_SUBSCRIBE"] == "Y" && !array_key_exists("MY_ENTITIES", $arParams)) {
foreach ($arSocNetAllowedSubscribeEntityTypesDesc as $entity_type_tmp => $arEntityTypeTmp) {
if (array_key_exists("HAS_MY", $arEntityTypeTmp) && $arEntityTypeTmp["HAS_MY"] == "Y" && array_key_exists("CLASS_MY", $arEntityTypeTmp) && array_key_exists("METHOD_MY", $arEntityTypeTmp) && strlen($arEntityTypeTmp["CLASS_MY"]) > 0 && strlen($arEntityTypeTmp["METHOD_MY"]) > 0 && method_exists($arEntityTypeTmp["CLASS_MY"], $arEntityTypeTmp["METHOD_MY"])) {
$arMyEntities[$entity_type_tmp] = call_user_func(array($arEntityTypeTmp["CLASS_MY"], $arEntityTypeTmp["METHOD_MY"]));
}
}
$arParams["MY_ENTITIES"] = $arMyEntities;
}
}
if (!empty($arParams) && array_key_exists("CHECK_RIGHTS", $arParams) && $arParams["CHECK_RIGHTS"] == "Y" && array_key_exists("USER_ID", $arParams)) {
$acc = new CAccess();
$acc->UpdateCodes();
$arSqls["RIGHTS"] = "EXISTS ( SELECT SLR.ID FROM b_sonet_log_right SLR\n\t\t\t\tLEFT JOIN b_user_access UA ON (UA.ACCESS_CODE = SLR.GROUP_CODE AND UA.USER_ID = " . (is_object($USER) ? intval($USER->GetID()) : 0) . ")\n\t\t\t\tWHERE L.ID = SLR.LOG_ID " . (is_object($USER) && $USER->IsAuthorized() && $arParams["MY_GROUPS_ONLY"] == "Y" ? " AND (\n\t\t\t\t\t\t\t\t(SLR.GROUP_CODE LIKE 'SG%' AND (UA.ACCESS_CODE = SLR.GROUP_CODE AND UA.USER_ID = " . intval($USER->GetID()) . ")) \n\t\t\t\t\t\t\t\tOR SLR.GROUP_CODE = 'U" . intval($USER->GetID()) . "'\n\t\t\t\t\t\t\t)" : " AND (\n\t\t\t\t\t\t\t\t0=1 " . (is_object($USER) && CSocNetUser::IsCurrentUserModuleAdmin() ? " OR SLR.GROUP_CODE = 'SA'" : "") . (is_object($USER) && $USER->IsAuthorized() ? " OR (SLR.GROUP_CODE = 'AU')" : "") . " OR (SLR.GROUP_CODE = 'G2')" . (is_object($USER) && $USER->IsAuthorized() ? " OR (UA.ACCESS_CODE = SLR.GROUP_CODE AND UA.USER_ID = " . intval($USER->GetID()) . ")" : "") . "\n\t\t\t\t\t\t\t)") . ")";
}
if (!empty($arParams) && array_key_exists("CHECK_CRM_RIGHTS", $arParams) && $arParams["CHECK_CRM_RIGHTS"] == "Y" && array_key_exists("USER_ID", $arParams)) {
$permParams = array('ALIAS_PREFIX' => 'L', 'PERM_TYPE' => 'READ', 'FILTER_PARAMS' => isset($arParams['CUSTOM_FILTER_PARAMS']) ? $arParams['CUSTOM_FILTER_PARAMS'] : array(), 'OPTIONS' => array('ENTITY_TYPE_COLUMN' => 'ENTITY_TYPE', 'IDENTITY_COLUMN' => 'ENTITY_ID'));
$altPerms = array();
$events = GetModuleEvents("socialnetwork", "OnBuildSocNetLogPerms");
while ($arEvent = $events->Fetch()) {
ExecuteModuleEventEx($arEvent, array(&$altPerms, $permParams));
}
if (!empty($altPerms)) {
foreach ($altPerms as $permSql) {
if ($permSql === false) {
//Access denied
$dbRes = new CDBResult();
$dbRes->InitFromArray(array());
return $dbRes;
}
if (is_string($permSql) && $permSql !== '') {
if ($arSqls['CRM_RIGHTS'] !== '') {
$arSqls['CRM_RIGHTS'] .= ' AND ';
}
$arSqls['CRM_RIGHTS'] = $permSql;
}
}
}
}
if ($arParams["USE_SUBSCRIBE"] == "Y" && intval($arParams["SUBSCRIBE_USER_ID"]) > 0) {
$arSqls["SUBSCRIBE"] = CSocNetLogEvents::GetSQL($arParams["SUBSCRIBE_USER_ID"], is_array($arParams["MY_ENTITIES"]) ? $arParams["MY_ENTITIES"] : array(), $arParams["TRANSPORT"], $arParams["VISIBLE"]);
$arParams["MIN_ID_JOIN"] = true;
}
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", $strDistinct, $arSqls["SELECT"]);
$strMinIDJoin = "";