1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
clearnaccess.php
См. документацию.
1<?php
2
4{
18 public function SQLClauseForAccessibleLessons ($in_bitmaskOperations, $isUseCache = false, $lessonId = 0, $in_prfx = 'DEFPRFX');
19
20
21 public static function GetNameForTask ($taskId);
22
34 public static function ListAllPossibleRights();
35
36
44 public function IsBaseAccessForCR ($in_bitmaskRequested, $isUseCache = false);
45
46
54 public function IsBaseAccess ($in_bitmaskRequested, $isUseCache = false, $checkForAuthor = false);
55
56
61 public function SetBasePermissions ($in_arPermPairs);
62
63
74 public function GetBasePermissions ();
75
76
87 public function GetLessonPermissions ($in_lessonId);
88
89
103 public function SetLessonsPermissions ($in_arPermissions);
104
105
112 public function IsLessonAccessible ($in_lessonId, $in_bitmaskOperations, $isUseCache = false);
113
114
115 public function GetAccessibleLessonsList($in_bitmaskOperations, $isUseCache = false);
116
117
127 public static function GetSymbolsAccessibleToLesson ($in_lessonId, $in_bitmaskOperations, $isUseCache = false);
128}
129
130
132{
133 protected static $instanceOfSelf = array();
134 protected static $CAccessLastUpdated = false;
135
136 protected $userId = false;
137
138 const OP_LESSON_READ = 0x0001;
139 const OP_LESSON_CREATE = 0x0002;
140 const OP_LESSON_WRITE = 0x0004;
141 const OP_LESSON_REMOVE = 0x0008;
147
148 protected static $arOperations = array(
149 'lesson_read' => self::OP_LESSON_READ,
150 'lesson_create' => self::OP_LESSON_CREATE,
151 'lesson_write' => self::OP_LESSON_WRITE,
152 'lesson_remove' => self::OP_LESSON_REMOVE,
153 'lesson_link_to_parents' => self::OP_LESSON_LINK_TO_PARENTS,
154 'lesson_unlink_from_parents' => self::OP_LESSON_UNLINK_FROM_PARENTS,
155 'lesson_link_descendants' => self::OP_LESSON_LINK_DESCENDANTS,
156 'lesson_unlink_descendants' => self::OP_LESSON_UNLINK_DESCENDANTS,
157 'lesson_manage_rights' => self::OP_LESSON_MANAGE_RIGHTS
158 );
159
160
161 // prevent creating throughs "new"
162 private function __construct($in_userId)
163 {
164 $this->userId = self::StrictlyCastToInteger ($in_userId);
165 }
166
171 public static function GetInstance($in_userId)
172 {
174
175 if ( ! array_key_exists($userId, self::$instanceOfSelf) )
176 self::$instanceOfSelf[$userId] = new CLearnAccess($userId);
177
178 return (self::$instanceOfSelf[$userId]);
179 }
180
181
186 public static function GetAccessSymbolsHashForSiteUser()
187 {
188 global $USER;
189
190 $userId = $USER->GetID();
191 $arCodes = array();
192
193 if ($userId > 0)
194 {
196 $arCodes = $oAccess->GetAccessCodes();
197 }
198 else
199 $arCodes = array('G2'); // G2 - is group included all users (not authorized too)
200
201 $hash = base64_encode (serialize($arCodes));
202
203 return ($hash);
204 }
205
206
207 public static function GetNameForTask($taskId)
208 {
209 $rc = CTask::GetByID($taskId);
210
211 $row = $rc->Fetch();
212
213 if ( ! isset($row['NAME']) )
214 {
215 throw new LearnException ('EA_NOT_EXISTS',
217 }
218
219 $nameUpperCase = mb_strtoupper($row['NAME']);
220
221 return CTask::GetLangTitle($nameUpperCase, "learning");
222 }
223
224
236 public static function ListAllPossibleRights()
237 {
238 $rc = CTask::GetList([], ['MODULE_ID' => 'learning']);
239
240 $arPossibleRights = array();
241 while ($row = $rc->Fetch())
242 {
243 $nameUpperCase = mb_strtoupper($row['NAME']);
244
245 $arPossibleRights[$row['ID']] = array(
246 'name' => $row['NAME'],
247 'name_human' => CTask::GetLangTitle($nameUpperCase, "learning"),
248 'sys' => $row['SYS'],
249 'description' => $row['DESCRIPTION'],
250 'description_human' => CTask::GetLangDescription($nameUpperCase, "", "learning"),
251 'binding' => $row['BINDING']
252 );
253 }
254
255 return ($arPossibleRights);
256 }
257
258
259 public static function GetSymbolsAccessibleToLesson ($in_lessonId, $in_bitmaskOperations, $isUseCache = false)
260 {
261 global $DB;
262 static $cacheSymbols = array();
263
264 if ( ! (is_int($in_bitmaskOperations) && ($in_bitmaskOperations > 0)) )
265 {
266 throw new LearnException ('bitmask must be an integer > 0',
269 }
270
271 $lessonId = (int) $in_lessonId;
272
273 $cacheKey = 'k' . $in_lessonId . '|' . $in_bitmaskOperations;
274
275 if ( ! ($isUseCache && isset($cacheSymbols[$cacheKey])) )
276 {
277 $arSymbols = array();
278 $sqlOperationsNames = self::ParseOperationsForSQL ($in_bitmaskOperations);
279
280 $rc = $DB->Query(
281 "SELECT TLR.SUBJECT_ID AS SYMBOLS
282 FROM b_learn_rights TLR
283 INNER JOIN b_task_operation TTO
284 ON TTO.TASK_ID = TLR.TASK_ID
285 INNER JOIN b_operation XTO
286 ON XTO.ID = TTO.OPERATION_ID
287 WHERE TLR.LESSON_ID = " . $lessonId . "
288 AND XTO.MODULE_ID = 'learning'
289 AND XTO.NAME IN (" . $sqlOperationsNames . ")
290
291 UNION
292
293 SELECT TLRA.SUBJECT_ID AS SYMBOLS
294 FROM b_learn_rights_all TLRA
295 INNER JOIN b_task_operation TTO
296 ON TTO.TASK_ID = TLRA.TASK_ID
297 INNER JOIN b_operation XTO
298 ON XTO.ID = TTO.OPERATION_ID
299 WHERE XTO.MODULE_ID = 'learning'
300 AND XTO.NAME IN (" . $sqlOperationsNames . ")
301 ", true);
302
303 if ($rc === false)
304 {
305 throw new LearnException ('EA_SQLERROR',
308 }
309
310 while ($row = $rc->Fetch())
311 $arSymbols[] = $row['SYMBOLS'];
312
313 $cacheSymbols[$cacheKey] = $arSymbols;
314 }
315
316 return ($cacheSymbols[$cacheKey]);
317 }
318
319
327 public function IsBaseAccessForCR ($in_bitmaskRequested, $isUseCache = false)
328 {
329 return ($this->IsBaseAccess ($in_bitmaskRequested, $isUseCache, true));
330 }
331
332
340 public function IsBaseAccess ($in_bitmaskRequested, $isUseCache = false, $checkForAuthor = false)
341 {
342 global $USER;
343
344 if (is_object($USER)
345 && ( $this->userId === ((int) $USER->GetID()) )
346 && $USER->IsAdmin()
347 )
348 {
349 // Admin can access anything
350 return (true);
351 }
352 elseif (defined('CRON_MODE'))
353 {
354 // Under cron script anybody can access anything
355 return (true);
356 }
357
358 if ( ! (is_int($in_bitmaskRequested) && ($in_bitmaskRequested > 0)) )
359 {
360 throw new LearnException ('bitmask must be an integer > 0',
363 }
364
365 $bitmaskRequested = $in_bitmaskRequested;
366
367 // access codes for user $this->userId
368 $arUserAccessSymbols = $this->GetAccessCodes ($isUseCache);
369
370 if ($checkForAuthor)
371 $arUserAccessSymbols[] = 'CR';
372
373 // bitmask of accessible operations for user
374 $bitmaskBaseAccess = $this->GetBitmaskOperationsForAllLessons($arUserAccessSymbols);
375
376 // check that all bits in $bitmaskRequested are setted in $bitmaskBaseAccess
377 if ( ($bitmaskRequested & $bitmaskBaseAccess) === $bitmaskRequested )
378 return (true);
379 else
380 return (false);
381 }
382
383
388 public function SetBasePermissions ($in_arPermPairs)
389 {
390 global $DB, $USER;
391
392 // Check args
393 if ( ! is_array($in_arPermPairs) )
394 {
395 throw new LearnException ('',
398 }
399
400 // Check & escape for SQL
401 $arPermPairs = array();
402 foreach ($in_arPermPairs as $in_subject_id => $in_task_id)
403 {
404 $subject_id = $DB->ForSQL($in_subject_id);
405 $task_id = self::StrictlyCastToInteger($in_task_id);
406 $arPermPairs[$subject_id] = $task_id;
407 }
408
409 // Check rights (we can access only if is admin and logged in)
410 if ( ! (self::IsLoggedUserCanAccessModuleSettings()
411 && ( ((int) $USER->GetID()) === $this->userId) )
412 )
413 {
414 throw new LearnException ('',
416 }
417
418 // Yes, I know - most of products on MyISAM. So, In God We Trust.
419 $DB->StartTransaction();
420
421 $rc = $DB->Query(
422 "DELETE FROM b_learn_rights_all
423 WHERE 1=1", true);
424
425 if ($rc === false)
426 {
427 $DB->Rollback();
428 throw new LearnException ('EA_SQLERROR',
431 }
432
433 foreach ($arPermPairs as $subject_id => $task_id)
434 {
435 // All data already escaped above!
436 $rc = $DB->Query(
437 "INSERT INTO b_learn_rights_all (SUBJECT_ID, TASK_ID)
438 VALUES ('" . $subject_id . "', " . $task_id . ")", true);
439 if ($rc === false)
440 {
441 $DB->Rollback();
442 throw new LearnException ('EA_SQLERROR',
445 }
446 }
447
448 // Amen
449 $DB->Commit();
450
452 }
453
454
465 public function GetBasePermissions ()
466 {
467 global $DB;
468
469 $rc = $DB->Query(
470 "SELECT SUBJECT_ID, TASK_ID
471 FROM b_learn_rights_all
472 WHERE 1=1");
473
474 if ($rc === false)
475 {
476 throw new LearnException('EA_SQLERROR',
479 }
480
481 $arPermPairs = array();
482 while ($row = $rc->Fetch())
483 $arPermPairs[$row['SUBJECT_ID']] = (int) $row['TASK_ID'];
484
485 return ($arPermPairs);
486 }
487
488
499 public function GetLessonPermissions ($in_lessonId)
500 {
501 global $DB;
502
503 $lessonId = self::StrictlyCastToInteger($in_lessonId);
504
505 $rc = $DB->Query(
506 "SELECT LESSON_ID, SUBJECT_ID, TASK_ID
507 FROM b_learn_rights
508 WHERE LESSON_ID = " . $lessonId . "
509 ");
510
511 if ($rc === false)
512 {
513 throw new LearnException('EA_SQLERROR',
516 }
517
518 $arPermPairs = array();
519 while ($row = $rc->Fetch())
520 $arPermPairs[$row['SUBJECT_ID']] = (int) $row['TASK_ID'];
521
522 return ($arPermPairs);
523 }
524
525
539 public function SetLessonsPermissions ($in_arPermissions)
540 {
541 global $DB;
542
543 // Check args
544 if ( ! is_array($in_arPermissions) )
545 {
546 throw new LearnException ('',
549 }
550
551 // First request for rights will not use cache (this will refresh cache)
552 $isUseCacheForRights = false;
553
554 $arPermissions = array();
555 foreach ($in_arPermissions as $in_lessonId => $arPermPairs)
556 {
557 if ( ! is_array($arPermPairs) )
558 {
559 throw new LearnException ('',
562 }
563
564 $lesson_id = self::StrictlyCastToInteger($in_lessonId);
565
566 // Ensure, that for all requested lessons there is rights for changing rights.
567 if ( ! $this->IsLessonAccessible($lesson_id, self::OP_LESSON_MANAGE_RIGHTS, $isUseCacheForRights) )
569
570 $isUseCacheForRights = true; // use cache for every next request for rights
571
572 // Check params & escape for SQL
573 $arPermissions[$lesson_id] = array();
574 foreach ($arPermPairs as $in_subject_id => $in_task_id)
575 {
576 $subject_id = $DB->ForSQL($in_subject_id);
577 $task_id = self::StrictlyCastToInteger($in_task_id);
578 $arPermissions[$lesson_id][$subject_id] = $task_id;
579 }
580 }
581
582 // Yes, I know - most of products on MyISAM. So, In God We Trust.
583 $DB->StartTransaction();
584
585 // Process setting permissions
586 foreach ($arPermissions as $lesson_id => $arPermPairs)
587 {
588 $subject_id = $arPerm[0];
589 $task_id = $arPerm[1];
590
591 $rc = $DB->Query(
592 "DELETE FROM b_learn_rights
593 WHERE LESSON_ID = $lesson_id", true);
594
595 if ($rc === false)
596 {
597 $DB->Rollback();
598 throw new LearnException ('EA_SQLERROR',
601 }
602
603 foreach ($arPermPairs as $subject_id => $task_id)
604 {
605 // All data already escaped above!
606 $rc = $DB->Query(
607 "INSERT INTO b_learn_rights (LESSON_ID, SUBJECT_ID, TASK_ID)
608 VALUES (" . $lesson_id . ", '" . $subject_id . "', " . $task_id . ")", true);
609 if ($rc === false)
610 {
611 $DB->Rollback();
612 throw new LearnException ('EA_SQLERROR',
615 }
616 }
617 }
618
619 // Amen
620 $DB->Commit();
621
623 }
624
625
626 public function IsLessonAccessible ($in_lessonId, $in_bitmaskOperations, $isUseCache = false)
627 {
628 static $cacheArIds = array();
629
630 $lessonId = intval($in_lessonId);
631 $cacheKey = $in_bitmaskOperations."_".$lessonId;
632
633 if ($isUseCache && array_key_exists($cacheKey, $cacheArIds))
634 {
635 return true;
636 }
637
638 $cacheArIds = array_merge($cacheArIds, $this->GetAccessibleLessonsList($in_bitmaskOperations, $isUseCache, $lessonId));
639 return array_key_exists($cacheKey, $cacheArIds);
640 }
641
642
643 public function GetAccessibleLessonsList($in_bitmaskOperations, $isUseCache = false, $lessonId = 0)
644 {
645 global $DB;
646
647 $sql = $this->SQLClauseForAccessibleLessons($in_bitmaskOperations, $isUseCache, $lessonId);
648
649 $rc = $DB->Query($sql, true);
650
651 if ($rc === false)
652 {
653 throw new LearnException ('EA_SQLERROR',
656 }
657
658 $arIds = array();
659 while ($row = $rc->Fetch())
660 $arIds[$in_bitmaskOperations."_".$row['LESSON_ID']] = (int) $row['LESSON_ID'];
661
662 return ($arIds);
663 }
664
665
679 public function SQLClauseForAccessibleLessons ($in_bitmaskOperations, $isUseCache = false, $lessonId = 0, $in_prfx = 'DEFPRFX')
680 {
681 global $DB;
682 if ( ! (is_int($in_bitmaskOperations) && ($in_bitmaskOperations > 0)) )
683 {
684 throw new LearnException ('bitmask must be an integer > 0',
687 }
688
689 $prfx = $DB->ForSQL ($in_prfx);
690 $userId = (int) $this->userId;
691
692 // access codes for user $this->userId
693 $arUserAccessSymbols = $this->GetAccessCodes ($isUseCache);
694
695 $userAccessSymbols = 'NULL';
696 // convert array to comma-separeted list for sql query (items will be escaped)
697 if (count($arUserAccessSymbols) > 0)
698 $userAccessSymbols = $this->Array2CommaSeparatedListForSQL ($arUserAccessSymbols);
699
706 // Get bitmask of operations granted on all lessons (any user mode)
707 $bitmaskAvailOperationsForAny = $this->GetBitmaskOperationsForAllLessons($arUserAccessSymbols);
708 // Get bitmask of operations granted on all lessons (user-author mode)
709 $bitmaskAvailOperationsForCR = $this->GetBitmaskOperationsForAllLessons(array_merge($arUserAccessSymbols, array('CR')));
710
718 $bitmaskOperationsForAny = $in_bitmaskOperations & ( ~ $bitmaskAvailOperationsForAny );
719 $bitmaskOperationsForCR = $in_bitmaskOperations & ( ~ $bitmaskAvailOperationsForCR );
720
721 // Convert bitmasks to sql comma-separated list of operations' names
722 $sqlOperationsForAny = false;
723 $sqlOperationsForCR = false;
724 if ($bitmaskOperationsForAny !== 0)
725 $sqlOperationsForAny = $this->ParseOperationsForSQL ($bitmaskOperationsForAny);
726 if ($bitmaskOperationsForCR !== 0)
727 $sqlOperationsForCR = $this->ParseOperationsForSQL ($bitmaskOperationsForCR);
728
729 $arSqlWhere = array();
730
731 // Is some operations must be checked for author?
732 if ($sqlOperationsForCR !== false)
733 $arSqlWhere[] = "(${prfx}TLR.SUBJECT_ID = 'CR' AND ${prfx}TLL.CREATED_BY = $userId AND ${prfx}XTO.NAME IN ($sqlOperationsForCR))";
734 else
735 $arSqlWhere[] = "(${prfx}TLL.CREATED_BY = $userId)"; // All requested operations are permitted for author
736
737 if ($sqlOperationsForAny !== false)
738 $arSqlWhere[] = "(${prfx}TLR.SUBJECT_ID IN ($userAccessSymbols) AND ${prfx}XTO.NAME IN ($sqlOperationsForAny))";
739 else
740 $arSqlWhere[] = "(1=1)"; // All requested operations permitted for user $this->userId
741
742 $sqlWhere = implode("\n OR \n", $arSqlWhere);
743
744 $lessonId = intval($lessonId);
745 if ($lessonId > 0)
746 {
747 $sqlWhere = "${prfx}TLL.ID={$lessonId} AND (".$sqlWhere.")";
748 }
749
750 $sql = "SELECT ${prfx}TLL.ID AS LESSON_ID
751 FROM b_learn_lesson ${prfx}TLL
752 LEFT OUTER JOIN b_learn_rights ${prfx}TLR
753 ON ${prfx}TLL.ID = ${prfx}TLR.LESSON_ID
754 LEFT OUTER JOIN b_task_operation ${prfx}TTO
755 ON ${prfx}TLR.TASK_ID = ${prfx}TTO.TASK_ID
756 LEFT OUTER JOIN b_operation ${prfx}XTO
757 ON ${prfx}TTO.OPERATION_ID = ${prfx}XTO.ID
758 WHERE
759 $sqlWhere";
760
761 return ($sql);
762
763 /*
764 prev version of code:
765
766 $userAccessSymbols = $this->GetAccessCodesForSQL ($isUseCache);
767 $sqlOperations = $this->ParseOperationsForSQL ($in_bitmaskOperations);
768 $prfx = $DB->ForSQL ($in_prfx);
769 $userId = $this->userId;
770
771 $sql = "
772 SELECT ${prfx}TLR.LESSON_ID
773 FROM b_learn_rights ${prfx}TLR
774 INNER JOIN b_task_operation ${prfx}TTO
775 ON ${prfx}TLR.TASK_ID = ${prfx}TTO.TASK_ID
776 INNER JOIN b_operation ${prfx}TO
777 ON ${prfx}TTO.OPERATION_ID = ${prfx}TO.ID
778 INNER JOIN b_learn_lesson ${prfx}TLL
779 ON ${prfx}TLL.ID = ${prfx}TLR.LESSON_ID
780 WHERE
781 TO.NAME IN ($sqlOperations)
782 AND
783 (
784 (${prfx}TLR.SUBJECT_ID = 'CR' AND ${prfx}TLL.CREATED_BY = $userId)
785 OR (TLR.SUBJECT_ID IN ($userAccessSymbols))
786 )";
787
788 return ($sql);
789 */
790 }
791
792
793 protected function GetBitmaskOperationsForAllLessons($arUserAccessSymbols)
794 {
795 global $DB;
796 static $cache = array();
797
798 if (!is_array($arUserAccessSymbols) || count($arUserAccessSymbols) < 1)
799 {
800 return 0;
801 }
802
803 $userAccessSymbols = $this->Array2CommaSeparatedListForSQL ($arUserAccessSymbols);
804 if (isset($cache[$userAccessSymbols]))
805 {
806 return $cache[$userAccessSymbols];
807 }
808
809 $rc = $DB->Query (
810 "SELECT XTO.NAME AS OPERATION_NAME
811 FROM b_learn_rights_all TLRA
812 INNER JOIN b_task_operation TTO
813 ON TTO.TASK_ID = TLRA.TASK_ID
814 INNER JOIN b_operation XTO
815 ON XTO.ID = TTO.OPERATION_ID
816 WHERE TLRA.SUBJECT_ID IN ($userAccessSymbols)",
817 true);
818 if ($rc === false)
819 {
820 throw new LearnException ('EA_SQLERROR: ',
823 }
824
825 $bitmaskOperations = 0;
826 while ($arData = $rc->Fetch())
827 {
828 if ( ! isset(self::$arOperations[$arData['OPERATION_NAME']]) )
829 {
830 throw new LearnException ('Unknown operation: ' . $arData['OPERATION_NAME'],
834 }
835
836 $bitmaskOperations = $bitmaskOperations | self::$arOperations[$arData['OPERATION_NAME']];
837 }
838
839 $cache[$userAccessSymbols] = $bitmaskOperations;
840 return ($bitmaskOperations);
841 }
842
843
847 protected static function ParseOperationsForSQL ($in_operations)
848 {
849 static $determinedCache = array();
850
851 if ( ! (is_int($in_operations) && ($in_operations > 0)) )
853
854 $cacheKey = 'str' . $in_operations;
855
856 if ( ! isset ($determinedCache[$cacheKey]) )
857 {
859 foreach (self::$arOperations as $operationName => $operationBitFlag)
860 {
861 if ($in_operations & $operationBitFlag)
862 {
863 $arOperations[] = $operationName;
864 $in_operations -= $operationBitFlag;
865 }
866 }
867
868 // Must be zero. If not => not all operations listed in self::$arOperations
869 // or wrong requested value in $in_operations
870 if ($in_operations !== 0)
872
874 $determinedCache[$cacheKey] = $sql;
875 }
876
877 return ($determinedCache[$cacheKey]);
878 }
879
880
884 protected function GetAccessCodesForSQL ($isUseCache = false)
885 {
886 static $cache = array();
887
888 if ($isUseCache && isset($cache['str' . $this->userId]))
889 return ($cache['str' . $this->userId]);
890
891 $arCodes = $this->GetAccessCodes ($isUseCache);
893
894 // Cache in case when $isUseCache === false too.
895 // Because, this will refresh cache, if it exists before.
896 $cache['str' . $this->userId] = $sql;
897
898 return ($sql);
899 }
900
901
905 protected function GetAccessCodes ($isUseCache = false)
906 {
907 global $USER;
908 static $cache = array();
909 $isNeedCAccessUpdate = true;
910
911 if ($isUseCache)
912 {
913 // Cache hits?
914 if (isset($cache['str' . $this->userId]))
915 return ($cache['str' . $this->userId]);
916
917 // Prevent call CAccess->UpdateCodes() multiple times per hit,
918 // except long time period (three seconds) expired.
919 if ( (static::$CAccessLastUpdated === false)
920 || ( (microtime(true) - static::$CAccessLastUpdated) > 3 )
921 )
922 {
923 $isNeedCAccessUpdate = true;
924 }
925 else
926 $isNeedCAccessUpdate = false;
927 }
928 else
929 $isNeedCAccessUpdate = true;
930
931 if ($isNeedCAccessUpdate)
932 {
933 $oAcc = new CAccess();
934 $oAcc->UpdateCodes();
935
936 if ($isUseCache)
937 static::$CAccessLastUpdated = microtime(true);
938
939 unset ($oAcc);
940 }
941
942 $rc = CAccess::GetUserCodes($this->userId);
943 if ($rc === false)
944 {
945 throw new LearnException('',
948 }
949
950 $arData = array();
951 while ($arItem = $rc->Fetch())
952 {
953 if ( ( (int) $arItem['USER_ID'] ) !== $this->userId )
954 {
955 throw new LearnException('',
959 }
960
961 $arData[] = $arItem['ACCESS_CODE'];
962 }
963
964 if ( is_object($USER) && ( $this->userId === ((int) $USER->GetID()) ) )
965 $arData[] = 'AU';
966
967 // Cache in case when $isUseCache === false too.
968 // Because, this will refresh cache, if it exists before.
969 $cache['str' . $this->userId] = $arData;
970
971 return ($arData);
972 }
973
974
975 protected static function Array2CommaSeparatedListForSQL ($in_arData)
976 {
977 $arData = array_map (array('CLearnAccess', 'EscapeAndAddLateralQuotes'), $in_arData);
978
979 $sql = implode(',', $arData);
980
981 return ($sql);
982 }
983
984
985 protected static function EscapeAndAddLateralQuotes ($txt)
986 {
987 global $DB;
988 return ("'" . $DB->ForSQL($txt) . "'");
989 }
990
991
992 public static function IsLoggedUserCanAccessModuleSettings()
993 {
994 global $USER, $APPLICATION;
995
996 if ($USER->IsAdmin() || ($APPLICATION->GetGroupRight('learning') === 'W'))
997 return (true);
998 else
999 return (false);
1000 }
1001
1002
1003 protected static function StrictlyCastToInteger ($var)
1004 {
1005 if ( ! preg_match("/^[0-9]+$/", (string) $var) )
1006 {
1007 throw new LearnException(
1008 'EA_PARAMS: can\'t b strictly casted to integer, but expected: ' . $var,
1011 }
1012
1013 return ( (int) $var );
1014 }
1015}
$hash
Определения ajax_redirector.php:8
global $APPLICATION
Определения include.php:80
static GetLangTitle($name, $module="main")
Определения task.php:410
static GetLangDescription($name, $desc, $module="main")
Определения task.php:424
static GetByID($ID)
Определения task.php:381
static GetList($arOrder=['MODULE_ID'=> 'asc', 'LETTER'=> 'asc'], $arFilter=[])
Определения task.php:185
Определения clearnaccess.php:132
static GetInstance($in_userId)
Определения clearnaccess.php:171
static $instanceOfSelf
Определения clearnaccess.php:133
GetLessonPermissions($in_lessonId)
Определения clearnaccess.php:499
static ListAllPossibleRights()
Определения clearnaccess.php:236
SQLClauseForAccessibleLessons($in_bitmaskOperations, $isUseCache=false, $lessonId=0, $in_prfx='DEFPRFX')
Определения clearnaccess.php:679
IsLessonAccessible($in_lessonId, $in_bitmaskOperations, $isUseCache=false)
Определения clearnaccess.php:626
const OP_LESSON_CREATE
Определения clearnaccess.php:139
static StrictlyCastToInteger($var)
Определения clearnaccess.php:1003
IsBaseAccessForCR($in_bitmaskRequested, $isUseCache=false)
Определения clearnaccess.php:327
static IsLoggedUserCanAccessModuleSettings()
Определения clearnaccess.php:992
static GetAccessSymbolsHashForSiteUser()
Определения clearnaccess.php:186
static $arOperations
Определения clearnaccess.php:148
static EscapeAndAddLateralQuotes($txt)
Определения clearnaccess.php:985
GetAccessCodes($isUseCache=false)
Определения clearnaccess.php:905
const OP_LESSON_READ
Определения clearnaccess.php:138
const OP_LESSON_UNLINK_FROM_PARENTS
Определения clearnaccess.php:143
const OP_LESSON_MANAGE_RIGHTS
Определения clearnaccess.php:146
GetAccessCodesForSQL($isUseCache=false)
Определения clearnaccess.php:884
const OP_LESSON_WRITE
Определения clearnaccess.php:140
static $CAccessLastUpdated
Определения clearnaccess.php:134
const OP_LESSON_LINK_DESCENDANTS
Определения clearnaccess.php:144
$userId
Определения clearnaccess.php:136
GetBitmaskOperationsForAllLessons($arUserAccessSymbols)
Определения clearnaccess.php:793
const OP_LESSON_UNLINK_DESCENDANTS
Определения clearnaccess.php:145
GetAccessibleLessonsList($in_bitmaskOperations, $isUseCache=false, $lessonId=0)
Определения clearnaccess.php:643
SetBasePermissions($in_arPermPairs)
Определения clearnaccess.php:388
const OP_LESSON_REMOVE
Определения clearnaccess.php:141
GetBasePermissions()
Определения clearnaccess.php:465
IsBaseAccess($in_bitmaskRequested, $isUseCache=false, $checkForAuthor=false)
Определения clearnaccess.php:340
static GetNameForTask($taskId)
Определения clearnaccess.php:207
static Array2CommaSeparatedListForSQL($in_arData)
Определения clearnaccess.php:975
static GetSymbolsAccessibleToLesson($in_lessonId, $in_bitmaskOperations, $isUseCache=false)
Определения clearnaccess.php:259
static ParseOperationsForSQL($in_operations)
Определения clearnaccess.php:847
const OP_LESSON_LINK_TO_PARENTS
Определения clearnaccess.php:142
SetLessonsPermissions($in_arPermissions)
Определения clearnaccess.php:539
Определения learnexception.php:4
const EXC_ERR_ALL_PARAMS
Определения learnexception.php:7
const EXC_ERR_ALL_ACCESS_DENIED
Определения learnexception.php:8
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
GetLessonPermissions($in_lessonId)
static ListAllPossibleRights()
SQLClauseForAccessibleLessons($in_bitmaskOperations, $isUseCache=false, $lessonId=0, $in_prfx='DEFPRFX')
IsLessonAccessible($in_lessonId, $in_bitmaskOperations, $isUseCache=false)
IsBaseAccessForCR($in_bitmaskRequested, $isUseCache=false)
SetBasePermissions($in_arPermPairs)
GetAccessibleLessonsList($in_bitmaskOperations, $isUseCache=false)
IsBaseAccess($in_bitmaskRequested, $isUseCache=false, $checkForAuthor=false)
static GetNameForTask($taskId)
static GetSymbolsAccessibleToLesson($in_lessonId, $in_bitmaskOperations, $isUseCache=false)
SetLessonsPermissions($in_arPermissions)
$oAccess
Определения options.php:19
global $DB
Определения cron_frame.php:29
global $USER
Определения csv_new_run.php:40
$arCodes
Определения options.php:154
$var
Определения payment.php:63
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