1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
clearnparsepermissionsfromfilter.php
См. документацию.
1<?php
2
3// Process permissions
5{
6 protected $requestedUserId = false;
7 protected $bCheckPerm = false;
8 protected $cachedSQL = false;
9 protected $requestedOperations = false;
10 protected $oAccess = false;
11 private static $availableLessons = array();
12
13
15 {
16 $loggedUserId = false;
17
18 // Skip checking permissions?
19 if (isset($arFilter['CHECK_PERMISSIONS']) && ($arFilter['CHECK_PERMISSIONS'] === 'N'))
20 return;
21
22 // Determine requested operations
23 $this->requestedOperations = self::ParseRequestedOperations ($arFilter);
24
25 // Determine logged in user
26 global $USER;
27 if (is_object($USER) && method_exists($USER, 'GetID'))
28 $loggedUserId = (int) $USER->GetID();
29
30 $this->requestedUserId = self::DetermineRequestedUserId ($arFilter, $loggedUserId);
31
32 // If user_id === current logged user_id, and he is admin => skip checking permissions
33 if (($this->requestedUserId === $loggedUserId) && $USER->IsAdmin())
34 return; // skip checking permissions
35
36 $this->oAccess = CLearnAccess::GetInstance($this->requestedUserId);
37
38 // If base (shared) user rights covers requested operations => nothing to check.
39 if ($this->oAccess->IsBaseAccess ($this->requestedOperations))
40 return; // skip checking permissions
41
42 // Checking of permissions must be.
43 $this->bCheckPerm = true;
44 }
45
46
47 protected static function DetermineRequestedUserId ($arFilter, $loggedUserId)
48 {
49 // If user_id given - use it, instead of logged-in user_id
50 if ( isset($arFilter['CHECK_PERMISSIONS_FOR_USER_ID']) )
51 $requestedUserId = (int) $arFilter['CHECK_PERMISSIONS_FOR_USER_ID'];
52 elseif ($loggedUserId !== false)
53 $requestedUserId = $loggedUserId;
54 else
55 {
56 // No user logged in and no user given: this is logic error.
57 throw new LearnException ('EA_LOGIC',
60 }
61
62 return ($requestedUserId);
63 }
64
65
66 protected static function ParseRequestedOperations ($arFilter)
67 {
68 // firstly, ensure that no MIN_PERMISSION given (it's orphaned request)
69 if (array_key_exists('MIN_PERMISSION', $arFilter))
70 {
71 throw new LearnException (
72 'EA_PARAMS: outdated "MIN_PERMISSION" key used.',
75 }
76
77 // Determine requested operations
78 if ( ! isset($arFilter['ACCESS_OPERATIONS']) )
79 {
80 // no requested operations given, it means that only OP_LESSON_READ opeartions requested.
82 }
83 else
84 {
85 // requested operations MUST be an integer, because of bitmask nature.
86 // and must be > 0
87 if (
88 ( ! is_int($arFilter['ACCESS_OPERATIONS']) )
89 || ( ! ($arFilter['ACCESS_OPERATIONS'] > 0) )
90 )
91 {
92 throw new LearnException (
93 'EA_PARAMS: bitmask ACCESS_OPERATIONS must be an integer and > 0.',
96 }
97
98 // requested operations
99 $requestedOperations = $arFilter['ACCESS_OPERATIONS'];
100 }
101
102 return ($requestedOperations);
103 }
104
105
106 public function SQLForAccessibleLessons()
107 {
108 // SQL exists only if check permissions must be done
109 if ($this->bCheckPerm === false)
110 {
111 throw new LearnException ('',
114 }
115
116 // Is not cached yet?
117 if ($this->cachedSQL === false)
118 {
119 $this->cachedSQL = $this->oAccess->SQLClauseForAccessibleLessons ($this->requestedOperations);
120
121 global $USER;
122 if (is_object($USER) && method_exists($USER, "GetID") && intval($USER->GetID()) > 0)
123 {
125 array(),
126 array(
127 "MEMBER_ID" => intval($USER->GetID()),
128 "ACTIVE" => "Y",
129 "ACTIVE_DATE" => "Y"
130 )
131 );
132
133 $availableCourses = array();
134 while ($group = $rs->fetch())
135 {
136 $availableCourses[] = $group["COURSE_LESSON_ID"];
137 }
138
139 if (count($availableCourses) > 0)
140 {
141 $this->cachedSQL .= " UNION SELECT ID as LESSON_ID
142 FROM b_learn_lesson
143 WHERE ID IN (".join(",", $availableCourses).")";
144 }
145 }
146 }
147
148 return ($this->cachedSQL);
149 }
150
151 public function IsNeedCheckPerm()
152 {
153 return ($this->bCheckPerm);
154 }
155}
static GetInstance($in_userId)
Определения clearnaccess.php:171
const OP_LESSON_READ
Определения clearnaccess.php:138
static DetermineRequestedUserId($arFilter, $loggedUserId)
static ParseRequestedOperations($arFilter)
static getList($arOrder, $arFilter, $arSelect=array(), $arNavParams=array())
Определения group.php:169
Определения learnexception.php:4
const EXC_ERR_ALL_PARAMS
Определения learnexception.php:7
const EXC_ERR_ALL_LOGIC
Определения learnexception.php:5
const EXC_ERR_ALL_GIVEUP
Определения learnexception.php:6
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
global $USER
Определения csv_new_run.php:40
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$rs
Определения action.php:82
$arFilter
Определения user_search.php:106