Lists immediate parents.
<?php $arParents = ThisClass::ListImmediateNeighbours (1); var _dump ($arParents); ?>
<?php
{
public static function Delete ($id);
public static function GetByID($id);
$lessonId,
$arOrder =
array (
'EDGE_SORT' =>
'asc'),
$publishProhibitionMode = true
);
public static function RelationGet ($parentLessonId, $childLessonId);
public static function RelationRemove ($parentLessonId, $childLessonId);
$breakBeforeLessonId =
false, $arIgnoreEdges =
array());
}
{
$isCourse = false,
$parentLessonId = true,
$isCheckPermissions = true,
$checkPermissionsForUserId = -1
)
{
$isAccessGranted = false;
if ($isCheckPermissions)
{
array(
'user_id' => $checkPermissionsForUserId)
)
)
{
if ($parentLessonId === true)
{
$isAccessGranted = true;
}
else
{
'parent_lesson_id' => $parentLessonId,
'user_id' => $checkPermissionsForUserId
)
)
)
{
$isAccessGranted = true;
}
}
}
}
else
$isAccessGranted = true;
if ( ! $isAccessGranted )
{
throw new LearnException(
'EA_ACCESS_DENIED',
}
if ($isCourse)
{
}
return (false);
foreach(
GetModuleEvents(
'learning',
'OnBeforeLessonAdd',
true) as $arEvent)
if (
)
{
$lessonId = false;
$e = new CAdminException($arMsg);
$GLOBALS[
"APPLICATION"]->ThrowException($e);
}
else
if ($lessonId)
{
if ($isCourse)
{
}
else
{
if ($parentLessonId !== true)
}
}
if (!$isCourse)
{
\Bitrix\Learning\Integration\Search::indexLesson($lessonId);
}
return ($lessonId);
}
{
$arCourseFields =
array();
&& ( ! array_key_exists(
'COURSE_SORT',
$arFields))
)
{
}
$additionalParams =
array (
'COURSE_SORT',
'ACTIVE_FROM',
'ACTIVE_TO', 'RATING', 'RATING_TYPE', 'SCORM');
foreach ($additionalParams as $paramName)
{
{
$arCourseFields[$paramName] =
$arFields[$paramName];
}
}
return ($arCourseFields);
}
{
$arAllowedFields =
array (
'COURSE_SORT',
'ACTIVE_FROM',
'ACTIVE_TO',
'RATING',
'RATING_TYPE',
'SCORM');
if ( ! $forUpdate )
{
$defaultsValues =
array (
'COURSE_SORT' => 500,
'ACTIVE_FROM' => NULL,
'ACTIVE_TO' => NULL,
'RATING' => 'N',
'RATING_TYPE' => NULL,
'SCORM' => 'N'
);
{
if ( ! array_key_exists($fieldName,
$arFields) )
}
}
if ( ( ! $forUpdate) || array_key_exists(
'COURSE_SORT',
$arFields) )
if ( ( ! $forUpdate) || isset(
$arFields[
'ACTIVE_FROM']) )
{
)
{
}
}
if ( ( ! $forUpdate) || isset(
$arFields[
'ACTIVE_TO']) )
{
)
{
}
}
if ( ( ! $forUpdate) || array_key_exists(
'RATING',
$arFields) )
{
}
if ( ( ! $forUpdate) || array_key_exists(
'RATING_TYPE',
$arFields) )
{
&&
( ! in_array (
array (
'like',
'standart_text',
'like_graphic',
'standart'),
true)
)
)
{
}
}
if ( ( ! $forUpdate) || array_key_exists(
'SCORM',
$arFields) )
{
}
foreach ($arAllowedFields as $fieldName)
{
}
return ($rc);
}
{
)
{
else
}
return (false);
if ($courseId !== false)
{
}
foreach(
GetModuleEvents(
'learning',
'OnBeforeLessonUpdate',
true) as $arEvent)
if (
)
{
$lessonId = false;
$e = new CAdminException($arMsg);
$GLOBALS[
"APPLICATION"]->ThrowException($e);
return(false);
}
if ($courseId !== false)
{
if (array_key_exists('COURSE_SORT', $arCourseFields))
$arFieldsToDb['SORT'] = "'" . (int) ($arCourseFields['COURSE_SORT'] + 0) . "'";
if (array_key_exists('ACTIVE_FROM', $arCourseFields))
{
if (($arCourseFields['ACTIVE_FROM'] === NULL) || ($arCourseFields['ACTIVE_FROM'] === ''))
$arFieldsToDb['ACTIVE_FROM'] = 'NULL';
else
$arFieldsToDb[
'ACTIVE_FROM'] =
$DB->CharToDateFunction($arCourseFields[
'ACTIVE_FROM']);
}
if (array_key_exists('ACTIVE_TO', $arCourseFields))
{
if (($arCourseFields['ACTIVE_TO'] === NULL) || ($arCourseFields['ACTIVE_TO'] === ''))
$arFieldsToDb['ACTIVE_TO'] = 'NULL';
else
$arFieldsToDb[
'ACTIVE_TO'] =
$DB->CharToDateFunction($arCourseFields[
'ACTIVE_TO']);
}
if (array_key_exists('RATING', $arCourseFields))
$arFieldsToDb[
'RATING'] =
"'" .
$DB->ForSql($arCourseFields[
'RATING']) .
"'";
if (array_key_exists('RATING_TYPE', $arCourseFields))
{
if ($arCourseFields['RATING_TYPE'] === NULL)
$arFieldsToDb['RATING_TYPE'] = 'NULL';
else
$arFieldsToDb[
'RATING_TYPE'] =
"'" .
$DB->ForSql($arCourseFields[
'RATING_TYPE']) .
"'";
}
if (array_key_exists('SCORM', $arCourseFields))
$arFieldsToDb[
'SCORM'] =
"'" .
$DB->ForSql($arCourseFields[
'SCORM']) .
"'";
if (
count($arFieldsToDb) > 0)
{
$rc =
$DB->Update (
'b_learn_course', $arFieldsToDb,
"WHERE ID='" . (int) ($courseId + 0) . "'", __LINE__, false,
false);
if ($rc === false)
}
}
foreach(
GetModuleEvents(
'learning',
'OnAfterLessonUpdate',
true) as $arEvent)
\Bitrix\Learning\Integration\Search::indexLesson($id);
return true;
}
{
$simulate = false;
$check_permissions = true;
$user_id = -1;
if (is_array($lesson_id))
{
$lesson_id,
'type' => 'strictly_castable_to_integer',
'mandatory' => true
),
'type' => 'boolean',
'mandatory' => false,
'default_value' => $simulate
),
'check_permissions' =>
array(
'type' => 'boolean',
'mandatory' => false,
'default_value' => $check_permissions
),
'type' => 'strictly_castable_to_integer',
'mandatory' => false,
'default_value' => $user_id
)
)
);
$check_permissions =
$options[
'check_permissions'];
}
else
$lesson_id = (int) $lesson_id;
if ($check_permissions)
{
if ($user_id === -1)
{
if ( ! (is_object(
$USER) && method_exists(
$USER,
'GetID')) )
{
throw new LearnException(
'EA_OTHER: $USER isn\'t available.',
}
$user_id = (int)
$USER->GetID();
}
}
return (
array($lesson_id, $simulate, $check_permissions, $user_id));
}
{
list ($root_lesson_id, $simulate, $check_permissions, $user_id) =
$arCandidatesToRemove =
array();
$arDescendantsList = $oTree->GetLessonsIdListInTree();
foreach ($arDescendantsList as $lesson_id)
{
foreach ($arEdges as $arEdgeData)
$arParents[] = (int) $arEdgeData['PARENT_LESSON'];
$arCandidatesToRemove[(int) $lesson_id] = $arParents;
}
$arCandidatesToRemove[$root_lesson_id] =
array();
do
{
$lessonsWithdrawn = 0;
foreach ($arCandidatesToRemove as $lesson_id => $arParents)
{
foreach ($arParents as $parent_lesson_id)
{
if ( ! array_key_exists((int) $parent_lesson_id, $arCandidatesToRemove) )
{
unset($arCandidatesToRemove[(int) $lesson_id]);
$lessonsWithdrawn++;
break;
}
}
}
}
while ($lessonsWithdrawn > 0);
foreach ($arCandidatesToRemove as $lesson_id => $arParents)
{
try
{
'lesson_id' => $lesson_id,
'simulate' => $simulate,
'check_permissions' => $check_permissions,
'user_id' => $user_id
)
);
}
catch (LearnException $e)
{
;
{
array(
'LESSON_ID' => $lesson_id,
'CHECK_PERMISSIONS' =>
'N'),
self::GET_LIST_ALL
);
if ( ! $rsLesson->fetch() )
{
;
}
else
{
throw new LearnException ($e->GetMessage(), $e->GetCode());
}
}
else
{
throw new LearnException ($e->GetMessage(), $e->GetCode());
}
}
}
}
final public static function Delete ($lesson_id)
{
list ($lesson_id, $simulate, $check_permissions, $user_id) =
if ($check_permissions)
{
{
throw new LearnException(
'EA_ACCESS_DENIED',
}
}
if ($check_permissions)
{
$IsLessonAccessibleFor_OP_LESSON_UNLINK_DESCENDANTS =
$IsLessonAccessibleFor_OP_LESSON_UNLINK_FROM_PARENTS =
}
foreach(
GetModuleEvents(
'learning',
'OnBeforeLessonDelete',
true) as $arEvent)
foreach ($arNeighboursEdges as $arEdge)
{
$child_lesson_id = (int) $arEdge['CHILD_LESSON'];
$parent_lesson_id = (int) $arEdge['PARENT_LESSON'];
if ($check_permissions)
{
$IsLessonAccessible = false;
if ($child_lesson_id === $lesson_id)
{
$IsLessonAccessible = $IsLessonAccessibleFor_OP_LESSON_UNLINK_FROM_PARENTS
}
elseif ($parent_lesson_id === $lesson_id)
{
$IsLessonAccessible = $IsLessonAccessibleFor_OP_LESSON_UNLINK_DESCENDANTS
}
else
{
throw new LearnException(
'EA_FATAL: $lesson_id (' . $lesson_id
. ') not equal to one of: $child_lesson_id ('
. $child_lesson_id . '), $parent_lesson_id ('
. $parent_lesson_id . ')',
}
if ( ! $IsLessonAccessible )
{
throw new LearnException(
'EA_ACCESS_DENIED',
}
if ($simulate === false)
}
}
if ($linkedCourseId !== false)
{
if ($simulate === false)
{
if ( !
$DB->Query(
"DELETE FROM b_learn_course_site WHERE COURSE_ID = " . (
int) $linkedCourseId,
true) )
if ($rc === false)
{
throw new LearnException (
'EA_OTHER: lesson is unremovable because linked course is in use.',
}
}
}
if ($simulate === false)
{
"SELECT PREVIEW_PICTURE, DETAIL_PICTURE
FROM b_learn_lesson
WHERE ID = " . (int) $lesson_id,
true);
if ($r === false)
{
throw new LearnException(
'EA_SQLERROR',
}
{
throw new LearnException(
'EA_SQLERROR',
}
array(
'LESSON_ID' => $lesson_id)
);
while($arQ = $q->Fetch())
{
{
throw new LearnException(
'EA_QUESTION_NOT_REMOVED',
}
}
'AUDIT_TYPE_ID' => 'LEARNING_REMOVE_ITEM',
'MODULE_ID' => 'learning',
'ITEM_ID' => 'L #' . $lesson_id,
'DESCRIPTION' => 'lesson removed'
));
if (CModule::IncludeModule('search'))
{
CSearch::deleteIndex("learning", "U\\_%", "L".$lesson_id, null);
}
}
if ($simulate === false)
{
foreach(
GetModuleEvents(
'learning',
'OnAfterLessonDelete',
true) as $arEvent)
}
}
final public static function GetByID($id)
{
return (self::GetList(
array(),
array(
'LESSON_ID' => $id)));
}
{
if ($courseId !== false)
{
"SELECT SORT, ACTIVE_FROM, ACTIVE_TO, RATING, RATING_TYPE, SCORM
FROM b_learn_course
WHERE ID = '" . (int) ($courseId + 0) . "'",
true
);
if ($rc === false)
$arCourseData = $rc->Fetch();
if ( ($arCourseData === false) || ( ! isset($arCourseData['SORT']) ) )
$arData = array_merge($arData, $arCourseData);
}
if ( isset($arData['ACTIVE'])
&& is_bool($arData['ACTIVE'])
)
{
if ($arData['ACTIVE'])
$arData['ACTIVE'] = 'Y';
else
$arData['ACTIVE'] = 'N';
}
$arData['LESSON_ID'] = $arData['ID'];
return ($arData);
}
{
if ( ! isset($arMap['L' . $lessonId]) )
return (false);
return ($arMap['L' . $lessonId]);
}
{
$bCacheHit = false;
static $ttl = 1800;
static $cacheId = 'fixed_cache_id';
static $cachePath = '/learning/coursetolessonmap/';
$oCache = new CPHPCache();
if ( ! $bRefreshCache )
{
if ($oCache->InitCache($ttl, $cacheId, $cachePath))
{
$arCached = $oCache->GetVars();
if (isset($arCached['arMap']) && is_array($arCached['arMap']))
{
$arMap = $arCached['arMap'];
$bCacheHit = true;
}
}
}
if (( ! $bCacheHit ) || $bRefreshCache)
{
$oCache->CleanDir($cachePath);
$oCache->InitCache($ttl, $cacheId, $cachePath);
$oCache->StartDataCache($ttl, $cacheId, $cachePath);
$oCache->EndDataCache(
array(
'arMap' => $arMap));
}
return ($arMap);
}
{
$bRefreshCache = true;
}
{
"SELECT ID, LINKED_LESSON_ID
FROM b_learn_course
WHERE 1 = 1",
true
);
if ($rc === false)
{
throw new LearnException (
'EA_SQLERROR',
}
while ($arData = $rc->Fetch())
{
if ( ($arData['ID'] <= 0) || ($arData['LINKED_LESSON_ID'] <= 0) )
continue;
$arMap['C' . $arData['ID']] = (int) $arData['LINKED_LESSON_ID'];
$arMap['L' . $arData['LINKED_LESSON_ID']] = (int) $arData['ID'];
}
return ($arMap);
}
{
$ACTIVE_FROM = $ACTIVE_TO = 'NULL';
if (($arCourseFields['ACTIVE_FROM'] !== NULL) && ($arCourseFields['ACTIVE_FROM'] !== ''))
$ACTIVE_FROM =
$DB->CharToDateFunction($arCourseFields[
'ACTIVE_FROM']);
if (($arCourseFields['ACTIVE_TO'] !== NULL) && ($arCourseFields['ACTIVE_TO'] !== ''))
$ACTIVE_TO =
$DB->CharToDateFunction($arCourseFields[
'ACTIVE_TO']);
'LINKED_LESSON_ID' => "'" . (int) ($lessonId + 0) . "'",
'SORT' => "'" . (int) ($arCourseFields['COURSE_SORT'] + 0) . "'",
'ACTIVE_FROM' => $ACTIVE_FROM,
'ACTIVE_TO' => $ACTIVE_TO,
'RATING' =>
"'" .
$DB->ForSql($arCourseFields[
'RATING']) .
"'",
'RATING_TYPE' => ( ($arCourseFields[
'RATING_TYPE'] === NULL) ?
'NULL' : (
"'" .
$DB->ForSql($arCourseFields[
'RATING_TYPE']) .
"'") ),
'SCORM' =>
"'" .
$DB->ForSql($arCourseFields[
'SCORM']) .
"'"
);
$rc =
$DB->Insert (
'b_learn_course',
$arFieldsToDb,
__LINE__,
false,
"",
false
);
if ($rc === false)
return ( (int) $rc);
}
{
if ($linkedLessonId === false)
{
return false;
}
if ( ($certificate === false) || ($certificate->GetNext()) )
return false;
if ($tests === false)
return (false);
while ($arTest = $tests->Fetch())
{
return false;
}
$linkedLessonId,
self::PUBLISH_PROHIBITION_PURGE_ALL_LESSONS_IN_COURSE_CONTEXT
| self::PUBLISH_PROHIBITION_PURGE_LESSON_IN_ALL_COURSE_CONTEXT
);
"DELETE FROM b_learn_course
WHERE ID=" . (string) ((int) $courseId),
true
);
if ($rc === false)
if ($rc === 0)
}
{
$args = func_get_args();
foreach ($args as $arg)
{
if (
( ! is_numeric($arg) )
|| ( ! is_int($arg + 0) )
)
{
throw new LearnException ('EA_PARAMS',
}
}
return (true);
}
{
Bitrix\Learning\Integration\Search::indexLesson($parentLessonId);
Bitrix\Learning\Integration\Search::indexLesson($childLessonId);
}
{
}
final public static function RelationGet ($parentLessonId, $childLessonId)
{
return ($rc);
}
final public static function RelationRemove ($parentLessonId, $childLessonId)
{
Bitrix\Learning\Integration\Search::indexLesson($parentLessonId);
Bitrix\Learning\Integration\Search::indexLesson($childLessonId);
}
{
}
{
}
{
}
{
$obUserFieldsSql = new CUserTypeSQL();
$obUserFieldsSql->SetEntity('LEARNING_LESSONS', 'TL.ID');
$obUserFieldsSql->SetSelect($arSelectFields);
$obUserFieldsSql->SetOrder($arOrder);
$bReplaceCourseId = false;
if (isset(
$arFilter[
'#REPLACE_COURSE_ID_TO_ID']))
{
$bReplaceCourseId = true;
unset(
$arFilter[
'#REPLACE_COURSE_ID_TO_ID']);
}
$oPermParser =
new CLearnParsePermissionsFromFilter (
$arFilter);
'lesson_id' => 'TL.ID',
'site_id' => 'TL.ID',
'name' => 'TL.NAME',
'code' => 'TL.CODE',
'active' => 'TL.ACTIVE',
'created' => 'TL.DATE_CREATE',
'date_create' => 'TL.DATE_CREATE',
'created_by' => 'TL.CREATED_BY',
'timestamp_x' => 'TL.TIMESTAMP_X',
'course_id' => 'TC.ID',
'course_sort' => 'TC.SORT',
'active_from' => 'TC.ACTIVE_FROM',
'sort' => 'TC.SORT',
'linked_lesson_id' => 'TC.LINKED_LESSON_ID'
);
self::GET_LIST_ALL,
self::GET_LIST_IMMEDIATE_CHILDS_OF,
self::GET_LIST_IMMEDIATE_PARENTS_OF,
self::GET_LIST_IMMEDIATE_CHILDS_OF | self::GET_LIST_IMMEDIATE_PARENTS_OF
);
$argsCheck = is_array($arOrder)
&& is_array($arSelectFields)
&& in_array($mode, $allowedModes, true)
if ( ! $argsCheck )
'LESSON_ID' => 'TL.ID',
'SITE_ID' => 'CASE WHEN (1 > 0) THEN \'no site\' ELSE \'0\' END',
'WAS_CHAPTER_ID' => 'TL.WAS_CHAPTER_ID',
'KEYWORDS' => 'TL.KEYWORDS',
'CHILDS_CNT' => '(SELECT COUNT(*) FROM b_learn_lesson_edges TLES WHERE TLES.SOURCE_NODE = TL.ID)',
'IS_CHILDS' => 'CASE WHEN (SELECT COUNT(*) FROM b_learn_lesson_edges TLES WHERE TLES.SOURCE_NODE = TL.ID) > 0 THEN \'1\' ELSE \'0\' END',
'SORT' => 'TC.SORT',
'TIMESTAMP_X' =>
$DB->DateToCharFunction(
'TL.TIMESTAMP_X'),
'DATE_CREATE' =>
$DB->DateToCharFunction(
'TL.DATE_CREATE'),
'CREATED_USER_NAME' =>
$DB->Concat(
"'('",
'TU.LOGIN',
"') '",
'TU.NAME',
"' '",
'TU.LAST_NAME'),
'CREATED_BY' => 'TL.CREATED_BY',
'ACTIVE' => 'TL.ACTIVE',
'NAME' => 'TL.NAME',
'PREVIEW_PICTURE' => 'TL.PREVIEW_PICTURE',
'PREVIEW_TEXT' => 'TL.PREVIEW_TEXT',
'PREVIEW_TEXT_TYPE' => 'TL.PREVIEW_TEXT_TYPE',
'DETAIL_TEXT' => 'TL.DETAIL_TEXT',
'DETAIL_PICTURE' => 'TL.DETAIL_PICTURE',
'DETAIL_TEXT_TYPE' => 'TL.DETAIL_TEXT_TYPE',
'LAUNCH' => 'TL.LAUNCH',
'CODE' => 'TL.CODE',
'ACTIVE_FROM' =>
$DB->DateToCharFunction(
'TC.ACTIVE_FROM'),
'ACTIVE_TO' =>
$DB->DateToCharFunction(
'TC.ACTIVE_TO'),
'RATING' => 'TC.RATING',
'RATING_TYPE' => 'TC.RATING_TYPE',
'SCORM' => 'TC.SCORM',
'LINKED_LESSON_ID' => 'TC.LINKED_LESSON_ID',
'COURSE_ID' => 'TC.ID',
'COURSE_SORT' => 'TC.SORT'
);
if (
count($arOrder) == 0)
$arOrder['TIMESTAMP_X'] = 'DESC';
$SqlSearchLang = '';
{
else
{
}
$SqlSearchLang = "''";
foreach ($arLID as $v)
$SqlSearchLang .=
", '" .
$DB->ForSql($v) .
"'";
}
$r = $obUserFieldsSql->GetFilter();
if ($r <> '')
$arSqlSearch[] = "(".$r.")";
$sqlSearch = '';
foreach ($arSqlSearch as $value)
{
if ($value <> '')
$sqlSearch .=
' AND ' .
$value;
}
$modeSQL_join = $modeSQL_where = '';
$modeSQL_defaultSortField = "TC.SORT";
if ($mode & self::GET_LIST_IMMEDIATE_PARENTS_OF)
{
$modeSQL_join .=
"\nINNER JOIN b_learn_lesson_edges TLE
ON TLE.SOURCE_NODE = TL.ID\n";
$modeSQL_where .= "\nAND TLE.TARGET_NODE = " . ($lessonId + 0) . "\n";
$arFieldsMap['EDGE_SORT'] = 'TLE.SORT';
$arFieldsMap['SORT'] = 'TLE.SORT';
}
if ($mode & self::GET_LIST_IMMEDIATE_CHILDS_OF)
{
$modeSQL_join .=
"\nINNER JOIN b_learn_lesson_edges TLE
ON TLE.TARGET_NODE = TL.ID\n";
$modeSQL_where .= "\nAND TLE.SOURCE_NODE = " . ($lessonId + 0) . "\n";
$arMap['childs_cnt'] = 'CHILDS_CNT';
$arMap['is_childs'] = 'IS_CHILDS';
$arMap['edge_sort'] = 'TLE.SORT';
$arMap['sort'] = $arMap['edge_sort'];
$modeSQL_defaultSortField = "TLE.SORT";
$arFieldsMap['EDGE_SORT'] = 'TLE.SORT';
$arFieldsMap['SORT'] = 'TLE.SORT';
}
if ($bReplaceCourseId)
$arFieldsMap['ID'] = $arFieldsMap['COURSE_ID'];
if (
count($arSelectFields) == 0)
$arSelectFields = array_keys($arFieldsMap);
foreach ($arOrder as $by =>
$order)
{
$fieldName = mb_strtoupper($by);
if ( ! in_array($fieldName, $arSelectFields) )
$arSelectFields[] = $fieldName;
}
$strSqlSelect = '';
$bFirstPass = true;
$bDefaultSortFieldSelected = false;
foreach ($arSelectFields as $selectFieldName)
{
if (mb_substr($selectFieldName, 0, 3) === 'UF_')
continue;
if (!$bFirstPass)
$strSqlSelect .= ', ';
else
$bFirstPass = false;
if (!isset($arFieldsMap[$selectFieldName]))
{
throw new LearnException(
'EA_OTHER: UNKNOWN FIELD: ' . $selectFieldName,
}
$strSqlSelect .= $arFieldsMap[$selectFieldName] . ' AS ' . $selectFieldName;
if (
($selectFieldName === 'SORT')
&& ($arFieldsMap[$selectFieldName] === $modeSQL_defaultSortField)
)
{
$bDefaultSortFieldSelected = true;
}
}
if ( ! $bDefaultSortFieldSelected )
{
if ($strSqlSelect !== '')
$strSqlSelect .= ', ';
$strSqlSelect .= $modeSQL_defaultSortField . ' AS SORT';
}
$strSqlSelect .= $obUserFieldsSql->GetSelect();
$sqlLangConstraint = '';
if (mb_strlen($SqlSearchLang) > 2)
{
$sqlLangConstraint = "
AND
EXISTS
(
SELECT 'x' FROM b_learn_course_site TCS
WHERE TC.ID = TCS.COURSE_ID AND TCS.SITE_ID IN (" . $SqlSearchLang . ")
)
";
}
$strSqlFrom = "FROM b_learn_lesson TL
LEFT JOIN b_learn_course TC
ON TC.LINKED_LESSON_ID = TL.ID
LEFT JOIN b_user TU
ON TU.ID = TL.CREATED_BY "
. $modeSQL_join
. $obUserFieldsSql->GetJoin("TL.ID")
. " WHERE 1 = 1 "
. $sqlLangConstraint
. $modeSQL_where;
if ($oPermParser->IsNeedCheckPerm())
$strSqlFrom .= " AND TL.ID IN (" . $oPermParser->SQLForAccessibleLessons() . ") ";
$strSqlFrom .= $sqlSearch;
$sql = "SELECT " . $strSqlSelect . " " . $strSqlFrom;
foreach($arOrder as $by =>
$order)
{
$by = mb_strtolower($by);
if ($s = $obUserFieldsSql->getOrder(mb_strtolower($by)))
$arSqlOrder[] =
' ' . $s .
' ' .
$order .
' ';
if (mb_substr($by, 0, 3) !== 'uf_')
{
if ( ! isset($arMap[$by]) )
{
throw new LearnException(
'EA_PARAMS: unknown order by field: "' . $by . '"',
);
}
}
$arSqlOrder[] =
' ' . $arMap[$by] .
' ' .
$order .
' ';
}
$sql .= ' ORDER BY ' . implode(', ', $arSqlOrder);
if (is_array($arNavParams) && ( ! empty($arNavParams) ) )
{
if (isset($arNavParams['nTopCount']) && ((int) $arNavParams['nTopCount'] > 0))
{
$sql =
$DB->TopSql($sql, (
int) $arNavParams[
'nTopCount']);
}
else
{
$res_cnt =
$DB->Query(
"SELECT COUNT(TL.ID) as C " . $strSqlFrom);
$res_cnt = $res_cnt->fetch();
$rc =
$res->NavQuery($sql, $res_cnt[
'C'], $arNavParams,
true);
if ($rc === false)
}
}
else
}
{
return (self::GetListUni($arOrder,
$arFilter, $arSelectFields, self::GET_LIST_ALL, -1, $arNavParams));
}
{
return (self::GetListUni($arOrder,
$arFilter, $arSelectFields, self::GET_LIST_IMMEDIATE_CHILDS_OF, $lessonId, $arNavParams));
}
{
return (self::GetListUni($arOrder,
$arFilter, $arSelectFields, self::GET_LIST_IMMEDIATE_PARENTS_OF, $lessonId, $arNavParams));
}
final public static function GetTree (
$lessonId,
$arOrder =
array (
'EDGE_SORT' =>
'asc'),
$publishProhibitionMode = true,
$arSelectFields =
array()
)
{
return (
new CLearnLessonTree ($lessonId, $arOrder,
$arFilter, $publishProhibitionMode, $arSelectFields));
}
{
{
$cOperationType =
$res[
"OPERATION"];
{
case 'COURSE_ID':
break;
case 'COURSE_SORT':
break;
case 'EDGE_SORT':
if ($mode & self::GET_LIST_IMMEDIATE_CHILDS_OF)
else
break;
case 'SORT':
if ($mode & self::GET_LIST_IMMEDIATE_CHILDS_OF)
{
}
else
{
}
break;
case 'LINKED_LESSON_ID':
break;
case 'CHILDS_CNT':
$arSqlSearch[] =
CLearnHelper::FilterCreate(
'(SELECT COUNT(*) FROM b_learn_lesson_edges TLES WHERE TLES.SOURCE_NODE = TL.ID)',
$val,
'number', $bFullJoin, $cOperationType);
break;
case 'ACTIVE_FROM':
case 'ACTIVE_TO':
{
$arSqlSearch[] =
"(TC." .
$key .
" " . ($cOperationType ==
"N" ?
"<" :
">=")
.
$DB->CharToDateFunction(
$DB->ForSql(
$val),
"FULL")
. ($cOperationType == "N" ? "" : " OR TC.ACTIVE_FROM IS NULL")
. ")";
}
break;
case "ACTIVE_DATE":
{
$arSqlSearch[] = ($cOperationType == "N" ? " NOT" : "")
.
"((TC.ACTIVE_TO >= " .
$DB->GetNowFunction()
.
" OR TC.ACTIVE_TO IS NULL) AND (TC.ACTIVE_FROM <= " .
$DB->GetNowFunction()
. " OR TC.ACTIVE_FROM IS NULL))";
}
break;
case "DATE_ACTIVE_TO":
case "DATE_ACTIVE_FROM":
break;
case 'RATING_TYPE':
break;
case 'RATING':
case 'SCORM':
break;
case 'WAS_CHAPTER_ID':
break;
case 'LESSON_ID':
break;
case 'CREATED_BY':
break;
case 'NAME':
case 'CODE':
case 'LAUNCH':
case 'DETAIL_TEXT':
case 'DETAIL_TEXT_TYPE':
case 'PREVIEW_TEXT':
case 'PREVIEW_TEXT_TYPE':
break;
case 'CREATED_USER_NAME':
$val,
'string', $bFullJoin, $cOperationType);
break;
case 'KEYWORDS':
break;
case 'ACTIVE':
break;
case 'TIMESTAMP_X':
case 'DATE_CREATE':
break;
case 'SITE_ID':
break;
case 'CHECK_PERMISSIONS':
case 'CHECK_PERMISSIONS_FOR_USER_ID':
case 'ACCESS_OPERATIONS':
break;
default:
if (mb_substr(
$key, 0, 3) !==
'UF_')
break;
}
}
return $arSqlSearch;
}
{
if ( ! self::_EnsureArgsStrictlyCastableToIntegers ($lessonId) )
"SELECT COUNT(TARGET_NODE) AS CHILDS_COUNT
FROM b_learn_lesson_edges
WHERE SOURCE_NODE = '" . (int) ($lessonId + 0) . "'",
true
);
if ($rc === false)
$arData = $rc->Fetch();
if ( ($arData === false) || ( ! isset($arData['CHILDS_COUNT']) ) )
return ( (int) ($arData['CHILDS_COUNT'] + 0) );
}
{
'WAS_CHAPTER_ID' => $chapterId,
'CHECK_PERMISSIONS' => 'N'
),
self::GET_LIST_ALL
);
if ($rc === false)
$row = $rc->Fetch();
if ( ! isset($row['LESSON_ID']) )
return (false);
else
return ( (int) $row['LESSON_ID'] );
}
final public static function GetListOfAncestors ($lessonId, $stopAtLessonId =
false, $stopBeforeLessonId =
false, $arIgnoreEdges =
array())
{
foreach ($arOPathes as $oPath)
$arAncestors = array_merge($arAncestors, array_map('intval', $oPath->GetPathAsArray()));
array_unique($arAncestors);
return ($arAncestors);
}
final public static function GetListOfParentPathes ($lessonId, $breakOnLessonId =
false, $breakBeforeLesson =
false, $arIgnoreEdges =
array())
{
);
$arAlreadyProcessedLessons =
array($lessonId);
if ($breakOnLessonId !== false)
{
foreach ($arEdges as $arEdge)
$arAlreadyProcessedLessons[] = (int) $arEdge['PARENT_LESSON'];
}
if ($breakBeforeLesson !== false)
$arAlreadyProcessedLessons[] = (int) $breakBeforeLesson;
foreach ($arAllPathes as $arPathBackward)
{
$arPath = array_reverse($arPathBackward);
$o->PopBottom();
if ($o->Count() > 0)
$arObjPathes[] = $o;
}
return ($arObjPathes);
}
{
$must_be_stopped = 0x1;
{
foreach ($arEdges as $arEdge)
{
$parentLessonId = (int) $arEdge['PARENT_LESSON'];
if ( ! in_array($parentLessonId, $arAlreadyProcessedLessons, true) )
{
$isEdgeIgnored = false;
foreach ($arIgnoreEdges as $arIgnoreEdge)
{
if (
($arIgnoreEdge['PARENT_LESSON'] == $arEdge['PARENT_LESSON'])
&& ($arIgnoreEdge['CHILD_LESSON'] == $arEdge['CHILD_LESSON'])
)
{
$isEdgeIgnored = true;
break;
}
}
if ( ! $isEdgeIgnored )
{
$arParents[] = $parentLessonId;
$arAlreadyProcessedLessons[] = $parentLessonId;
}
}
}
$must_be_stopped &= (int) (
count($arParents) === 0);
foreach ($arParents as $parentLessonId)
{
$parentLessonId = (int) $parentLessonId;
{
$arPathTmp[] = $parentLessonId;
$arPathesNew[] = $arPathTmp;
}
else
{
$arPathesNew[
$key][] = $parentLessonId;
}
}
}
if ($must_be_stopped)
return ($arPathesNew);
return (self::GetListOfParentPathesRecursive($arPathesNew, $arAlreadyProcessedLessons, $arIgnoreEdges));
}
{
$lessonId = (int) $in_lessonId;
$contextCourseLessonId = (int) $in_contextCourseLessonId;
"SELECT COURSE_LESSON_ID
FROM b_learn_publish_prohibition
WHERE COURSE_LESSON_ID = $contextCourseLessonId
AND PROHIBITED_LESSON_ID = $lessonId
",
true
);
if ($rc === false)
$arData = $rc->Fetch();
if ($arData === false)
return (false);
return (true);
}
{
if ( ! is_bool($in_isProhibited) )
{
throw new LearnException ('EA_PARAMS: isProhibited',
}
$lessonId = (int) $in_lessonId;
$contextCourseLessonId = (int) $in_contextCourseLessonId;
if ($isProhibitedNow !== $in_isProhibited)
{
if ($in_isProhibited)
{
$sql = "INSERT INTO b_learn_publish_prohibition
(COURSE_LESSON_ID, PROHIBITED_LESSON_ID)
VALUES ($contextCourseLessonId, $lessonId)";
}
else
{
$sql = "DELETE FROM b_learn_publish_prohibition
WHERE COURSE_LESSON_ID = $contextCourseLessonId
AND PROHIBITED_LESSON_ID = $lessonId";
}
$rc =
$DB->Query($sql,
true);
if ($rc === false)
Bitrix\Learning\Integration\Search::indexLesson($lessonId);
return (true);
}
return (false);
}
{
$lessonId = (int) $in_lessonId;
$purgeMode = (int) $in_purgeMode;
if ( ! in_array(
$purgeMode,
self::PUBLISH_PROHIBITION_PURGE_ALL_LESSONS_IN_COURSE_CONTEXT,
self::PUBLISH_PROHIBITION_PURGE_LESSON_IN_ALL_COURSE_CONTEXT,
self::PUBLISH_PROHIBITION_PURGE_BOTH
),
true
)
)
{
throw new LearnException ('EA_PARAMS: purgeMode',
}
$arSqlCondition =
array();
if ($purgeMode & self::PUBLISH_PROHIBITION_PURGE_ALL_LESSONS_IN_COURSE_CONTEXT)
$arSqlCondition[] = 'COURSE_LESSON_ID = ' . $lessonId;
if ($purgeMode & self::PUBLISH_PROHIBITION_PURGE_LESSON_IN_ALL_COURSE_CONTEXT)
$arSqlCondition[] = 'PROHIBITED_LESSON_ID = ' . $lessonId;
if (
count($arSqlCondition) > 0)
{
$sqlCondition = implode(' OR ', $arSqlCondition);
"DELETE FROM b_learn_publish_prohibition
WHERE " . $sqlCondition,
true);
if ($rc === false)
}
}
{
$arAncestors[] = (int) $in_parentLessonId;
$arAncestorsInt =
array();
foreach ($arAncestors as $ancestroId)
$arAncestorsInt[] = (int) $ancestroId;
"SELECT COURSE_LESSON_ID, PROHIBITED_LESSON_ID
FROM b_learn_publish_prohibition
WHERE COURSE_LESSON_ID IN (" . implode (',', $arAncestorsInt) . ")"
,
true);
if ($rc === false)
'PARENT_LESSON' => (int) $in_parentLessonId,
'CHILD_LESSON' => (int) $in_childLessonId
)
);
$arCache_ancestorsOfLesson =
array();
while ($arData = $rc->Fetch())
{
$prohibitedLessonId = (int) $arData['PROHIBITED_LESSON_ID'];
$contextLessonId = (int) $arData['COURSE_LESSON_ID'];
if ( ! isset($arCache_ancestorsOfLesson[$prohibitedLessonId]) )
{
$arCache_ancestorsOfLesson[$prohibitedLessonId] =
$prohibitedLessonId,
false,
false,
$arIgnoreEdges
);
}
if ( ! in_array($contextLessonId, $arCache_ancestorsOfLesson[$prohibitedLessonId], true) )
{
}
}
}
}
if($_SERVER $defaultValue['REQUEST_METHOD']==="GET" &&!empty($RestoreDefaults) && $bizprocPerms==="W" &&check_bitrix_sessid())
static GetList($arOrder=array(), $arFilter=array(), $arNavParams=array())
static GetList($arOrder=array(), $arFilter=array(), $arNavParams=array())
static CourseGetLinkedLesson($courseId)
static GetList($arOrder=array(), $arFilter=array(), $bHz=false, $arNavParams=array(), $arSelect=array())
static GetInstance($in_userId)
const OP_LESSON_UNLINK_FROM_PARENTS
const OP_LESSON_UNLINK_DESCENDANTS
static CanUserAddLessonToParentLesson($arParams)
static CanUserAddLessonWithoutParentLesson($arParams=array())
static Update($id, $arInFields)
static Create($arInFields)
static GetProperty($parentNodeId, $childNodeId, $propertyName)
static SetProperty($parentNodeId, $childNodeId, $propertyName, $value)
static Link($parentNodeId, $childNodeId, $arProperties)
static ListImmediateNeighbours($nodeId)
static Unlink($parentNodeId, $childNodeId)
static ListImmediateChilds($nodeId)
static ListImmediateParents($nodeId)
static FilterCreate($fname, $vals, $type, &$bFullJoin, $cOperationType=false, $bSkipEmpty=true)
static MkOperationFilter($key)
const PUBLISH_PROHIBITION_PURGE_BOTH
static _ExtractAdditionalCourseFields(&$arFields)
static PublishProhibitionPurge_OnBeforeRelationRemove($in_parentLessonId, $in_childLessonId)
static GetLinkedCourse($lessonId)
static _EnsureArgsStrictlyCastableToIntegers()
const GET_LIST_IMMEDIATE_PARENTS_OF
static _CanonizeAndCheckAdditionalParamsForAddCourse($arFields, $forUpdate=false)
static ListImmediateParents($lessonId)
static Delete($lesson_id)
static RelationGet($parentLessonId, $childLessonId)
static GetCourseToLessonMap($bRefreshCache=false)
static GetCourseToLessonMap_ReloadCache()
static GetListUni($arOrder=array(), $arFilter=array(), $arSelectFields=array(), $mode=self::GET_LIST_ALL, $lessonId=-1, $arNavParams=array())
static _funcDelete_ParseOptions($lesson_id)
static DeleteRecursiveLikeHardlinks($in_data)
static GetListOfParentPathes($lessonId, $breakOnLessonId=false, $breakBeforeLesson=false, $arIgnoreEdges=array())
static GetFilter($arFilter=array(), $mode)
static Add($arFields, $isCourse=false, $parentLessonId=true, $arProperties=array('SORT'=> 500), $isCheckPermissions=true, $checkPermissionsForUserId=-1)
static RelationAdd($parentLessonId, $childLessonId, $arProperties)
static IsPublishProhibited($in_lessonId, $in_contextCourseLessonId)
static ListImmediateChilds($lessonId)
static GetListOfAncestors($lessonId, $stopAtLessonId=false, $stopBeforeLessonId=false, $arIgnoreEdges=array())
static GetCourseToLessonMap_LoadFromDB()
static PublishProhibitionPurge($in_lessonId, $in_purgeMode)
const GET_LIST_IMMEDIATE_CHILDS_OF
static CourseBecomeLesson($courseId)
static RelationUpdate($parentLessonId, $childLessonId, $arProperties)
static PublishProhibitionSetTo($in_lessonId, $in_contextCourseLessonId, $in_isProhibited)
static CountImmediateChilds($lessonId)
static ListImmediateNeighbours($lessonId)
static BecomeCourse($lessonId, $arFields)
static GetListOfParentPathesRecursive($arPathes, &$arAlreadyProcessedLessons, $arIgnoreEdges=array())
static GetListOfImmediateChilds($lessonId, $arOrder=array(), $arFilter=array(), $arSelectFields=array(), $arNavParams=array())
static LessonIdByChapterId($chapterId)
static GetListOfImmediateParents($lessonId, $arOrder=array(), $arFilter=array(), $arSelectFields=array(), $arNavParams=array())
const PUBLISH_PROHIBITION_PURGE_ALL_LESSONS_IN_COURSE_CONTEXT
static Update($id, $arFields)
static GetTree( $lessonId, $arOrder=array('EDGE_SORT'=> 'asc'), $arFilter=array(), $publishProhibitionMode=true, $arSelectFields=array())
static GetList($arOrder=array(), $arFilter=array(), $arSelectFields=array(), $arNavParams=array())
static RelationRemove($parentLessonId, $childLessonId)
const PUBLISH_PROHIBITION_PURGE_LESSON_IN_ALL_COURSE_CONTEXT
static StaticParser($arOptions, $arParseParams)
const EXC_ERR_ALL_ACCESS_DENIED
const EXC_ERR_LL_UNREMOVABLE_CL
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
global $USER_FIELD_MANAGER
static GetLinkedCourse($lessonId)
static GetListOfImmediateChilds($lessonId, $arOrder=array(), $arFilter=array(), $arSelectFields=array())
static ListImmediateParents($lessonId)
static IsPublishProhibited($lessonId, $contextCourseLessonId)
static RelationGet($parentLessonId, $childLessonId)
static Add($arFields, $isCourse=false, $parentLessonId=true, $arProperties=array('SORT'=> 500))
static PublishProhibitionSetTo($lessonId, $contextCourseLessonId, $isProhibited)
static GetTree( $lessonId, $arOrder=array('EDGE_SORT'=> 'asc'), $arFilter=array(), $publishProhibitionMode=true)
static RelationAdd($parentLessonId, $childLessonId, $arProperties)
static DeleteRecursiveLikeHardlinks($id)
static ListImmediateChilds($lessonId)
static RelationUpdate($parentLessonId, $childLessonId, $arProperties)
static GetListOfParentPathes($lessonId, $breakOnLessonId=false, $breakBeforeLessonId=false, $arIgnoreEdges=array())
static CountImmediateChilds($lessonId)
static ListImmediateNeighbours($lessonId)
static GetListOfImmediateParents($lessonId, $arOrder=array(), $arFilter=array(), $arSelectFields=array())
static Update($id, $arFields)
static GetList($arOrder=array(), $arFilter=array())
static RelationRemove($parentLessonId, $childLessonId)
ExecuteModuleEventEx($arEvent, $arParams=[])
DelDuplicateSort(&$arSort)
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
GetMessage($name, $aReplace=null)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if(empty($signedUserToken)) $key
</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."%"
$GLOBALS['_____370096793']
if( $site[ 'SERVER_NAME']==='') if($site['SERVER_NAME']==='') $arProperties