• Модуль: learning
  • Путь к файлу: ~/bitrix/modules/learning/classes/general/clearnparsepermissionsfromfilter.php
  • Класс: CLearnParsePermissionsFromFilter
  • Вызов: CLearnParsePermissionsFromFilter::SQLForAccessibleLessons
public function SQLForAccessibleLessons()
{
	// SQL exists only if check permissions must be done
	if ($this->bCheckPerm === false)
	{
		throw new LearnException ('', 
			LearnException::EXC_ERR_ALL_LOGIC 
			| LearnException::EXC_ERR_ALL_GIVEUP);
	}

	// Is not cached yet?
	if ($this->cachedSQL === false)
	{
		$this->cachedSQL = $this->oAccess->SQLClauseForAccessibleLessons ($this->requestedOperations);

		global $USER;
		if (is_object($USER) && method_exists($USER, "GetID") && intval($USER->GetID()) > 0)
		{
			$rs = CLearningGroup::getList(
				array(),
				array(
					"MEMBER_ID" => intval($USER->GetID()),
					"ACTIVE" => "Y",
					"ACTIVE_DATE" => "Y"
				)
			);

			$availableCourses = array();
			while ($group = $rs->fetch())
			{
				$availableCourses[] = $group["COURSE_LESSON_ID"];
			}

			if (count($availableCourses) > 0)
			{
				$this->cachedSQL .= " UNION SELECT ID as LESSON_ID
					FROM b_learn_lesson
					WHERE ID IN (".join(",", $availableCourses).")";
			}
		}
	}

	return ($this->cachedSQL);
}