- Модуль: learning
- Путь к файлу: ~/bitrix/modules/learning/classes/general/clearnaccessmacroses.php
- Класс: CLearnAccessMacroses
- Вызов: CLearnAccessMacroses::CanUserViewLessonAsPublic
static function CanUserViewLessonAsPublic ($arParams, $allowAccessViaLearningGroups = true)
{
// Parse options (user_id from $arParams will be automaticaly resolved)
$options = self::ParseParamsWithUser(
$arParams,
array(
'COURSE_ID' => array(
'type' => 'strictly_castable_to_integer',
'mandatory' => true
),
'LESSON_ID' => array(
'type' => 'strictly_castable_to_integer',
'mandatory' => true
)
)
);
// Is it course?
$linkedLessonId = CCourse::CourseGetLinkedLesson($options['COURSE_ID']);
if ($linkedLessonId === false)
return (false); // Access denied
$lessonId = $options['LESSON_ID'];
$breakOnLessonId = $linkedLessonId; // save resources
// Is lesson included into given course?
$isLessonChildOfCourse = false;
$arOPathes = CLearnLesson::GetListOfParentPathes ($lessonId, $breakOnLessonId);
foreach ($arOPathes as $oPath)
{
$topLessonId = $oPath->GetTop();
if (($topLessonId !== false) && ($topLessonId == $linkedLessonId))
{
$isLessonChildOfCourse = true;
break;
}
}
if ( ! $isLessonChildOfCourse )
return (false); // Access denied
// Check permissions for course
$isCourseAccessible = self::CanUserViewLessonContent (array('lesson_id' => $linkedLessonId), $allowAccessViaLearningGroups);
// Permissions for all lessons/chapters in public are equivalent to course permissions
return ($isCourseAccessible);
}