Example #1
0
    unset($rsContent, $arContent, $rsCourse, $arCourse, $rsChapter, $arChapter);
    $this->IncludeComponentTemplate();
}
//Set Title
$arParams["SET_TITLE"] = $arParams["SET_TITLE"] == "N" ? "N" : "Y";
if ($arParams["SET_TITLE"] == "Y") {
    $APPLICATION->SetTitle($arResult["CHAPTER"]["NAME"]);
}
$bCanEdit = CLearnAccessMacroses::CanUserEditLesson(array('lesson_id' => $arParams['CHAPTER_ID'])) || $USER->IsAdmin();
if ($bCanEdit) {
    $deleteReturnUrl = "";
    if ($parent = $this->GetParent()) {
        $parentLessonId = 0;
        $lessonPath = "";
        if (strlen($arParams["LESSON_PATH"]) > 0) {
            $path = new CLearnPath();
            $path->ImportUrlencoded($arParams["LESSON_PATH"]);
            $path->PopBottom();
            $lessonPath = $path->ExportUrlencoded();
            $lessonId = $path->PopBottom();
            $edgesToParents = CLearnLesson::ListImmediateParents($arParams['CHAPTER_ID']);
            foreach ($edgesToParents as $arEdgeToParent) {
                if ((int) $arEdgeToParent['PARENT_LESSON'] === (int) $lessonId) {
                    $parentLessonId = $lessonId;
                    break;
                }
            }
        }
        if ($parentLessonId) {
            $deleteReturnUrl = CComponentEngine::MakePathFromTemplate($parent->arResult["FOLDER"] . $parent->arResult["URL_TEMPLATES"]["chapter.detail"], array("CHAPTER_ID" => "0" . $parentLessonId, "COURSE_ID" => $arParams["COURSE_ID"]));
            $deleteReturnUrl .= strpos($deleteReturnUrl, "?") !== false ? "&" : "?";
Example #2
0
 $searchParams = "";
 if ($arSearchURL["query"]) {
     foreach (explode("&", $arSearchURL["query"]) as $param) {
         list($name, $value) = explode("=", $param);
         $searchParams .= "<input type=\"hidden\" name=\"" . htmlspecialcharsEx($name) . "\" value=\"" . htmlspecialcharsEx($value) . "\" />";
     }
 }
 $APPLICATION->SetPageProperty("learning_search_params", $searchParams);
 $lessonID = 0;
 if ($arVariables["LESSON_ID"] > 0) {
     $lessonID = intval($arVariables["LESSON_ID"]);
 } else {
     // Lesson is not given, so try get chapter_id
     if (isset($_REQUEST['CHAPTER_ID'])) {
         if (CLearnPath::IsUrlencodedPath($_REQUEST['CHAPTER_ID'])) {
             $LESSON_PATH = new CLearnPath();
             $LESSON_PATH->ImportUrlencoded($_REQUEST['CHAPTER_ID']);
             $lessonID = (int) $LESSON_PATH->GetBottom();
         } elseif (substr($_REQUEST['CHAPTER_ID'], 0, 1) === '0') {
             $lessonID = (int) substr($_REQUEST['CHAPTER_ID'], 1);
         } else {
             $lessonID = (int) CLearnLesson::LessonIdByChapterId($_REQUEST['CHAPTER_ID']);
         }
     }
 }
 $linkedLessonId = false;
 if ($arParams["COURSE_ID"] > 0) {
     $linkedLessonId = CCourse::CourseGetLinkedLesson($arParams["COURSE_ID"]);
 }
 if ($arParams["CHECK_PERMISSIONS"] !== 'N') {
     $isAccessible = false;
$message = null;
$bVarsFromForm = false;
$ID = intval($ID);
$filter_lesson_id = intval($filter_lesson_id);
$lessonPath = '';
if (isset($_POST['LESSON_PATH'])) {
    $lessonPath = $_POST['LESSON_PATH'];
} elseif (isset($_GET['LESSON_PATH'])) {
    $lessonPath = $_GET['LESSON_PATH'];
} else {
    $result = CLQuestion::GetByID($ID);
    $arData = $result->Fetch();
    $oPath = new CLearnPath($arData['LESSON_ID']);
    $lessonPath = $oPath->ExportUrlencoded();
}
$oPath = new CLearnPath();
$oPath->ImportUrlencoded($lessonPath);
$uriLessonPath = $oPath->ExportUrlencoded();
$NEW_LESSON_ID = false;
$LESSON_ID = false;
if ($ID == 0) {
    $LESSON_ID = $oPath->PopBottom();
} else {
    // Get lesson id from item data
    $result = CLQuestion::GetByID($ID);
    $arQuestionData = $result->ExtractFields("str_");
    if ($arQuestionData) {
        $LESSON_ID = $arQuestionData['LESSON_ID'];
        if (isset($_POST['LESSON_ID']) && $_POST['LESSON_ID'] >= 1 && $_POST['LESSON_ID'] != $LESSON_ID) {
            $NEW_LESSON_ID = (int) $_POST['LESSON_ID'];
        }
Example #4
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
if (!CModule::IncludeModule('learning')) {
    return false;
}
//Params
$arParams["COURSE_ID"] = isset($arParams["COURSE_ID"]) && intval($arParams["COURSE_ID"]) > 0 ? intval($arParams["COURSE_ID"]) : intval($_REQUEST["COURSE_ID"]);
$arParams["SELF_TEST_TEMPLATE"] = strlen($arParams["SELF_TEST_TEMPLATE"]) > 0 ? htmlspecialcharsbx($arParams["SELF_TEST_TEMPLATE"]) : "self.php?SELF_TEST_ID=#SELF_TEST_ID#";
$CHAPTER_ID = isset($arParams["CHAPTER_ID"]) && intval($arParams["CHAPTER_ID"]) > 0 ? $arParams["CHAPTER_ID"] : $_REQUEST["CHAPTER_ID"];
if (CLearnPath::IsUrlencodedPath($CHAPTER_ID)) {
    $path = new CLearnPath();
    $path->ImportUrlencoded($CHAPTER_ID);
    $arParams['CHAPTER_ID'] = (int) $path->GetBottom();
} elseif (substr($CHAPTER_ID, 0, 1) === '0') {
    $arParams['CHAPTER_ID'] = (int) substr($CHAPTER_ID, 1);
} else {
    $arParams['CHAPTER_ID'] = (int) CLearnLesson::LessonIdByChapterId($CHAPTER_ID);
}
if (!(isset($arParams['LESSON_PATH']) && strlen($arParams['LESSON_PATH']))) {
    $arParams['LESSON_PATH'] = '';
    if (isset($_REQUEST['LESSON_PATH']) && strlen($_REQUEST['LESSON_PATH'])) {
        $arParams['LESSON_PATH'] = $_REQUEST['LESSON_PATH'];
    }
}
$strUrlencodedLessonPath = '';
if (strlen($arParams['LESSON_PATH']) > 0) {
    $strUrlencodedLessonPath = 'LESSON_PATH=' . $arParams['LESSON_PATH'];
}
Example #5
0
 /**
  * @access public
  */
 public static final function GetListOfParentPathes($lessonId, $breakOnLessonId = false, $breakBeforeLesson = false, $arIgnoreEdges = array())
 {
     $arPathes = array(array($lessonId));
     $arAlreadyProcessedLessons = array($lessonId);
     if ($breakOnLessonId !== false) {
         // This lesson must be interpreted as parentless.
         // This behaviour can be emulated by adding to
         // $arAlreadyProcessedLessons all immediate parents
         // of this lesson.
         $arEdges = self::ListImmediateParents($breakOnLessonId);
         foreach ($arEdges as $arEdge) {
             $arAlreadyProcessedLessons[] = (int) $arEdge['PARENT_LESSON'];
         }
     }
     if ($breakBeforeLesson !== false) {
         $arAlreadyProcessedLessons[] = (int) $breakBeforeLesson;
     }
     $arAllPathes = self::GetListOfParentPathesRecursive($arPathes, $arAlreadyProcessedLessons, $arIgnoreEdges);
     $arObjPathes = array();
     foreach ($arAllPathes as $arPathBackward) {
         $arPath = array_reverse($arPathBackward);
         $o = new CLearnPath($arPath);
         $o->PopBottom();
         // remove $lessonId
         // skip empty pathes
         if ($o->Count() > 0) {
             $arObjPathes[] = $o;
         }
     }
     return $arObjPathes;
 }
        CAdminMessage::ShowMessage(GetMessage('LEARNING_MODULE_NOT_FOUND'));
    }
    require $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/epilog_admin.php';
    // system's epilog
    exit;
}
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/learning/prolog.php";
IncludeModuleLangFile(__FILE__);
ClearVars();
$lessonPath = '';
if (isset($_POST['LESSON_PATH'])) {
    $lessonPath = $_POST['LESSON_PATH'];
} elseif (isset($_GET['LESSON_PATH'])) {
    $lessonPath = $_GET['LESSON_PATH'];
}
$oPath = new CLearnPath();
$oPath->ImportUrlencoded($lessonPath);
$LESSON_ID = $oPath->GetBottom();
if ($LESSON_ID === false) {
    CAdminMessage::ShowMessage(GetMessage('LEARNING_BAD_LESSON'));
    require $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/epilog_admin.php';
    exit;
}
$uriLessonPath = $oPath->ExportUrlencoded();
unset($lessonPath);
if (isset($from) && strlen($from) > 0) {
    $str_from = "&from=" . htmlspecialcharsbx($from);
} else {
    $str_from = "";
}
$oAccess = CLearnAccess::GetInstance($USER->GetID());
Example #7
0
}
//arResult
$arResult = array("ITEMS" => array(), "COURSE" => $arCourse);
//Set Title
$arParams["SET_TITLE"] = $arParams["SET_TITLE"] == "N" ? "N" : "Y";
if ($arParams["SET_TITLE"] == "Y") {
    $APPLICATION->SetTitle($arResult["COURSE"]["NAME"]);
}
$parent =& $this->GetParent();
//Course description item
$url = CComponentEngine::MakePathFromTemplate($arParams["COURSE_DETAIL_TEMPLATE"], array("COURSE_ID" => $arParams["COURSE_ID"]));
$arResult["ITEMS"][] = array("NAME" => GetMessage("LEARNING_COURSE_DESCRIPTION"), "URL" => $url, "TYPE" => "CD", "SELECTED" => $parent->arResult["VARIABLES"]["INDEX"] == "Y", "DEPTH_LEVEL" => 1);
$CHAPTER_ID = $parent->arResult["VARIABLES"]["CHAPTER_ID"];
if ($CHAPTER_ID > 0) {
    if (CLearnPath::IsUrlencodedPath($CHAPTER_ID)) {
        $oTmp = new CLearnPath();
        $oTmp->ImportUrlencoded($CHAPTER_ID);
        $CHAPTER_ID = (int) $oTmp->GetBottom();
    } elseif (substr($CHAPTER_ID, 0, 1) === '0') {
        $CHAPTER_ID = (int) substr($CHAPTER_ID, 1);
    } else {
        $CHAPTER_ID = (int) CLearnLesson::LessonIdByChapterId($CHAPTER_ID);
    }
} else {
    $CHAPTER_ID = false;
}
$lessonCount = 0;
$lessonCurrent = 0;
// Get Course Content
$arContents = CLearnCacheOfLessonTreeComponent::GetData($arParams['COURSE_ID']);
foreach ($arContents as $arContent) {
Example #8
0
 $APPLICATION->SetPageProperty("learning_search_url", htmlspecialcharsEx($arSearchURL["path"]));
 $searchParams = "";
 if ($arSearchURL["query"]) {
     foreach (explode("&", $arSearchURL["query"]) as $param) {
         list($name, $value) = explode("=", $param);
         $searchParams .= "<input type=\"hidden\" name=\"" . htmlspecialcharsEx($name) . "\" value=\"" . htmlspecialcharsEx($value) . "\" />";
     }
 }
 $APPLICATION->SetPageProperty("learning_search_params", $searchParams);
 $lessonID = 0;
 if ($arVariables["LESSON_ID"] > 0) {
     $lessonID = intval($arVariables["LESSON_ID"]);
 } elseif (isset($arVariables['CHAPTER_ID'])) {
     // Lesson is not given, so try get chapter_id
     if (CLearnPath::IsUrlencodedPath($arVariables['CHAPTER_ID'])) {
         $LESSON_PATH = new CLearnPath();
         $LESSON_PATH->ImportUrlencoded($arVariables['CHAPTER_ID']);
         $lessonID = (int) $LESSON_PATH->GetBottom();
     } elseif (substr($arVariables['CHAPTER_ID'], 0, 1) === '0') {
         $lessonID = (int) substr($arVariables['CHAPTER_ID'], 1);
     } else {
         $lessonID = (int) CLearnLesson::LessonIdByChapterId($arVariables['CHAPTER_ID']);
     }
 }
 $linkedLessonId = false;
 if ($arParams["COURSE_ID"] > 0) {
     $linkedLessonId = CCourse::CourseGetLinkedLesson($arParams["COURSE_ID"]);
 }
 if ($arParams["CHECK_PERMISSIONS"] !== 'N') {
     $isAccessible = false;
     try {
    if (isset($g_learn_parentLessonPath)) {
        throw new LearnException('EA_LOGIC: PROPOSE_RETURN_LESSON_PATH and ' . 'LESSON_PATH are mutually exclusive arguments.', LearnException::EXC_ERR_ALL_LOGIC);
    }
    $g_learn_parentLessonPath = $_GET['PROPOSE_RETURN_LESSON_PATH'];
    $oPath = new CLearnPath();
    $oPath->ImportUrlencoded($g_learn_parentLessonPath);
    $g_learn_parentLessonId = $oPath->GetBottom();
    if ($g_learn_parentLessonId === false) {
        throw new LearnException('EA_LOGIC: PROPOSE_RETURN_LESSON_PATH given, ' . 'but there is no parent lesson in path', LearnException::EXC_ERR_ALL_LOGIC);
    }
}
// Place to $topCourseLessonId lesson id of top course, if top lesson is course.
$topCourseLessonId = false;
if (isset($g_learn_parentLessonPath) && strlen($g_learn_parentLessonPath)) {
    try {
        $oPath = new CLearnPath();
        $oPath->ImportUrlencoded($g_learn_parentLessonPath);
        $topLessonId = $oPath->GetTop();
        // Is lesson the course?
        if (CLearnLesson::GetLinkedCourse($topLessonId) !== false) {
            $topCourseLessonId = $topLessonId;
        }
    } catch (Exception $e) {
        $topCourseLessonId = false;
    }
    unset($oPath, $topLessonId);
}
// This argument can be transmitted on POST submit of form when creating new lesson
if (isset($_GET['PARENT_LESSON_ID'])) {
    $_POST['PARENT_LESSON_ID'] = $_GET['PARENT_LESSON_ID'];
}
 public function BuildListContextMenu()
 {
     $aContext = array();
     $parentLessonId = false;
     // Button "level up" available only if LESSON_PATH available and parent exists in it
     if (isset($_GET['LESSON_PATH']) && strlen($_GET['LESSON_PATH']) > 0) {
         $PROPOSE_RETURN_LESSON_PATH = '&PROPOSE_RETURN_LESSON_PATH=' . urlencode($_GET['LESSON_PATH']);
         $oPath = new CLearnPath();
         $oPath->ImportUrlencoded($_GET['LESSON_PATH']);
         $arPath = $oPath->GetPathAsArray();
         $arUpPath = $arPath;
         $count_arUpPath = count($arUpPath);
         if (isset($arUpPath[$count_arUpPath - 1])) {
             $parentLessonId = $arUpPath[$count_arUpPath - 1];
         }
         // Is parent node exists
         if ($count_arUpPath >= 2) {
             // "Level up"
             array_pop($arUpPath);
             $oUpPath = new CLearnPath();
             $oUpPath->SetPathFromArray($arUpPath);
             $aContext[] = array('ICON' => 'btn_up', 'TEXT' => GetMessage('LEARNING_A_UP'), 'LINK' => 'learn_unilesson_admin.php?lang=' . LANG . '&set_filter=Y' . '&PARENT_LESSON_ID=' . htmlspecialcharsbx($arUpPath[count($arUpPath) - 1]) . '&LESSON_PATH=' . $oUpPath->ExportUrlencoded() . '&' . $this->hrefSearchRetPoint, 'TITLE' => GetMessage('LEARNING_A_UP'));
         } else {
             // To all lessons list
             $aContext[] = array('ICON' => 'btn_up', 'TEXT' => GetMessage('LEARNING_ALL_LESSONS'), 'LINK' => 'learn_unilesson_admin.php?lang=' . LANG . '&set_filter=Y' . '&PARENT_LESSON_ID=-2' . '&' . $this->hrefSearchRetPoint, 'TITLE' => GetMessage('LEARNING_ALL_LESSONS'));
         }
         unset($arPath, $oPath, $arUpPath, $oUpPath);
     } else {
         $PROPOSE_RETURN_LESSON_PATH = '';
     }
     if (!$this->IsSearchMode()) {
         /**
          * User can create lesson if he has base access for creating AND:
          * 1) no parent lesson
          * OR
          * 2) if user creating lesson linked to some parent on which user has access
          * to link childs, and user has access to link his created lesson to parent
          */
         $isAccessCreate = false;
         try {
             if ($this->oAccess->IsBaseAccess(CLearnAccess::OP_LESSON_CREATE)) {
                 if ($parentLessonId === false) {
                     $isAccessCreate = true;
                 } elseif ($this->oAccess->IsBaseAccess(CLearnAccess::OP_LESSON_LINK_DESCENDANTS | CLearnAccess::OP_LESSON_LINK_TO_PARENTS) || $this->oAccess->IsLessonAccessible($parentLessonId, CLearnAccess::OP_LESSON_LINK_DESCENDANTS) && $this->oAccess->IsBaseAccessForCR(CLearnAccess::OP_LESSON_LINK_TO_PARENTS)) {
                     $isAccessCreate = true;
                 }
             }
         } catch (Exception $e) {
         }
         if ($isAccessCreate) {
             // btn add new course
             $aContext[] = array('ICON' => 'btn_new', 'TEXT' => GetMessage('LEARNING_ADD_COURSE'), 'LINK' => 'learn_course_edit.php?lang=' . LANG . $PROPOSE_RETURN_LESSON_PATH, 'TITLE' => GetMessage('LEARNING_ADD_COURSE_ALT'));
             // btn add new unilesson (non-course)
             $aContext[] = array('ICON' => 'btn_new', 'TEXT' => GetMessage('LEARNING_UNILESSON_ADD'), 'LINK' => 'learn_unilesson_edit.php?lang=' . LANG . $PROPOSE_RETURN_LESSON_PATH, 'TITLE' => GetMessage('LEARNING_UNILESSON_ADD'));
         }
     }
     $this->oList->AddAdminContextMenu($aContext);
     return $this;
 }
Example #11
0
 /**
  * WARNING: tree build algorithm skips duplicated lessons, so
  * if there is some duplicates lessons, only one of them
  * will be in resulted tree.
  */
 protected function BuildTreeRecursive($rootLessonId, $arOrder, $arFilter, $depth = 0, $parentChapterId = NULL, $arSelectFields, $arRootPath)
 {
     $oPath = new CLearnPath();
     $arLessons = array();
     $CDBResult = CLearnLesson::GetListOfImmediateChilds($rootLessonId, $arOrder, $arFilter, $arSelectFields);
     while (($arData = $CDBResult->Fetch()) !== false) {
         // Skip lessons that are already in tree (prevent cycling)
         if (in_array($arData['LESSON_ID'], $this->arLessonsInTree)) {
             continue;
         }
         // Skip lessons prohibited for publishing
         if (in_array((int) $arData['LESSON_ID'], $this->arPublishProhibitedLessons, true)) {
             continue;
         }
         // Path as array for current LESSON_ID
         $arCurrentLessonPath = $arRootPath;
         $arCurrentLessonPath[] = (int) $arData['LESSON_ID'];
         $oPath->SetPathFromArray($arCurrentLessonPath);
         $strUrlencodedCurrentLessonPath = $oPath->ExportUrlencoded();
         // Register lesson
         $this->arLessonsInTree[] = $arData['LESSON_ID'];
         $this->arLessonsAsList[] = array_merge($arData, array('#DEPTH_IN_TREE' => $depth, '#LESSON_PATH' => $strUrlencodedCurrentLessonPath));
         // hack: we don't know yet, what index name must be for element in array.
         // And we must preserve order in array elements (for compatibility).
         // But we will know index name after BuildTreeRecursive will be called, which
         // adds to array new elements. So create bother elements, and after remove unneeded.
         $this->arLessonsAsListOldMode['LE' . $arData['LESSON_ID']] = array();
         $this->arLessonsAsListOldMode['CH' . $arData['LESSON_ID']] = array();
         $item = $arData;
         $item['#childs'] = array();
         $lessonType_oldDataModel = 'LE';
         if ($arData['IS_CHILDS']) {
             $lessonType_oldDataModel = 'CH';
             $item['#childs'] = $this->BuildTreeRecursive($arData['LESSON_ID'], $arOrder, $arFilter, $depth + 1, $arData['LESSON_ID'], $arSelectFields, $arCurrentLessonPath);
             // It still can be zero childs due to $arFilter, publish prohibition or prevent cycling instead of non-zero $arData['IS_CHILDS']
             if (count($item['#childs']) == 0) {
                 $lessonType_oldDataModel = 'LE';
             }
         }
         // remove unneeded element caused by hack above
         if ($lessonType_oldDataModel === 'LE') {
             unset($this->arLessonsAsListOldMode['CH' . $arData['LESSON_ID']]);
         } else {
             unset($this->arLessonsAsListOldMode['LE' . $arData['LESSON_ID']]);
         }
         $this->arLessonsAsListOldMode[$lessonType_oldDataModel . $arData['LESSON_ID']] = array_merge($arData, array('ID' => $arData['LESSON_ID'], 'CHAPTER_ID' => $parentChapterId, 'SORT' => $arData['EDGE_SORT'], 'TYPE' => $lessonType_oldDataModel, 'DEPTH_LEVEL' => $depth + 1, '#LESSON_PATH' => $strUrlencodedCurrentLessonPath));
         $arLessons[] = $item;
     }
     return $arLessons;
 }
Example #12
0
if ($arParams['LESSON_ID'] > 0) {
    $arRatingData = CRatings::GetRatingVoteResult('LEARN_LESSON', $arParams['LESSON_ID']);
    $ratingTransistor = serialize($arRatingData);
}
$delayed = false;
$courseLessonId = CCourse::CourseGetLinkedLesson($arParams['COURSE_ID']);
if (CLearnParsePermissionsFromFilter::isRegisteredAsAvailableCourse($courseLessonId)) {
    $arGroupsPeriods = CLearnAccessMacroses::getActiveLearningGroupsPeriod($courseLessonId, $USER->getId());
    if ($arGroupsPeriods['IS_EXISTS']) {
        $arResult['LEARNING_GROUP_ACTIVE_FROM'] = $arGroupsPeriods['ACTIVE_FROM'];
        $arResult['LEARNING_GROUP_ACTIVE_TO'] = $arGroupsPeriods['ACTIVE_TO'];
        $activeFromMap = CLearnAccessMacroses::getActiveLearningChaptersPeriod($courseLessonId, $USER->getId());
        if ($activeFromMap !== false) {
            $arResult['LEARNING_GROUP_CHAPTERS_ACTIVE_FROM'] = $activeFromMap;
        }
        $oPath = new CLearnPath();
        $oPath->ImportUrlencoded($arParams['LESSON_PATH']);
        $arPath = $oPath->GetPathAsArray();
        if (count($arPath) >= 2) {
            $secondLevelLesson = $arPath[1];
            if (isset($arResult['LEARNING_GROUP_CHAPTERS_ACTIVE_FROM'][$secondLevelLesson])) {
                $activeFrom = $arResult['LEARNING_GROUP_CHAPTERS_ACTIVE_FROM'][$secondLevelLesson];
                $bTzWasDisabled = !CTimeZone::enabled();
                if ($bTzWasDisabled) {
                    CTimeZone::enable();
                }
                $tzOffset = CTimeZone::getOffset();
                if ($bTzWasDisabled) {
                    CTimeZone::disable();
                }
                // Adjust unix timestamp to bitrix-timestamp for correct comparision below
Example #13
0
function __learning_admin_get_menu($THIS, $arPath = array(), $deep = 0, &$immediateChildsIds, $loadOnlySpecialEntities = false)
{
    $immediateChildsIds = array();
    // puts here ids of all immediate childs
    $deep = (int) $deep;
    // Index in path for current parentLessonId
    $indexInPath = $deep - 1;
    // Path doesn't include top root element ('all courses' or 'all unilessons')
    $arMenu = array();
    //$urlPath = $oPath->ExportUrlencoded();
    // current lesson id (not exists only for top root)
    if (isset($arPath[$deep])) {
        $currentLessonIdInPath = (int) $arPath[$deep];
    } else {
        $currentLessonIdInPath = false;
    }
    // Path to current element
    $arCurrentDeepPath = array();
    foreach ($arPath as $key => $value) {
        if ($key === $deep) {
            break;
        }
        $arCurrentDeepPath[] = $value;
    }
    if ($deep === 0) {
        // We are at the top level, so we must get list of all courses
        $CDBResult = CCourse::GetList(array('COURSE_SORT' => 'ASC'));
    } else {
        // If not parent with such indexInPath => we are deep too much.
        if (!isset($arPath[$indexInPath])) {
            return $arMenu;
        }
        // no items
        $parentLessonId = $arPath[$indexInPath];
        $oCurrentDeepPath = new CLearnPath();
        $oCurrentDeepPath->SetPathFromArray(array_merge($arCurrentDeepPath));
        $urlPath = $oCurrentDeepPath->ExportUrlencoded();
        $arMenu[] = array("text" => GetMessage("LEARNING_QUESTION"), "url" => "learn_question_admin.php?lang=" . LANG . '&PARENT_LESSON_ID=' . ($parentLessonId + 0) . '&LESSON_PATH=' . $urlPath . "&from=learn_menu", "icon" => "learning_icon_question", "more_url" => array("learn_question_admin.php?lang=" . LANG . '&PARENT_LESSON_ID=' . ($parentLessonId + 0) . '&LESSON_PATH=' . $urlPath . "&from=learn_menu", "learn_question_edit.php?lang=" . LANG . '&LESSON_PATH=' . $urlPath . "&from=learn_menu", "learn_question_admin.php?lang=" . LANG . '&PARENT_LESSON_ID=' . ($parentLessonId + 0) . '&LESSON_PATH=' . $urlPath, "learn_question_edit.php?lang=" . LANG . '&LESSON_PATH=' . $urlPath, "learn_question_admin.php?lang=" . LANG . '&LESSON_PATH=' . $urlPath), "title" => GetMessage("LEARNING_QUESTION_LIST"));
        $CDBResult = CLearnLesson::GetListOfImmediateChilds($parentLessonId, array('EDGE_SORT' => 'ASC'));
        // determine, is parent a course (only for courses in subroot level)?
        if ($deep === 1) {
            $immediateParentCourse = CLearnLesson::GetLinkedCourse($parentLessonId);
            if ($immediateParentCourse !== false) {
                // immediate parent is a course, so we must add entity 'Tests'
                $arMenu[] = array('text' => GetMessage('LEARNING_TESTS'), 'url' => 'learn_test_admin.php?lang=' . LANG . '&filter=Y&set_filter=Y' . '&COURSE_ID=' . ($immediateParentCourse + 0) . '&PARENT_LESSON_ID=' . ($parentLessonId + 0) . '&LESSON_PATH=' . $urlPath, 'icon' => 'learning_icon_tests', 'more_url' => array('learn_test_admin.php?lang=' . LANG . '&set_filter=Y' . '&COURSE_ID=' . ($immediateParentCourse + 0) . '&PARENT_LESSON_ID=' . ($parentLessonId + 0) . '&LESSON_PATH=' . $urlPath, 'learn_test_edit.php?lang=' . LANG . '&filter=Y&set_filter=Y' . '&COURSE_ID=' . ($immediateParentCourse + 0) . '&PARENT_LESSON_ID=' . ($parentLessonId + 0) . '&LESSON_PATH=' . $urlPath), 'title' => GetMessage('LEARNING_TESTS_LIST'));
                unset($urlPath);
                unset($oCurrentDeepPath);
            }
        }
    }
    if ($loadOnlySpecialEntities) {
        return $arMenu;
    }
    // When listing courses, limit it's count
    if ($deep === 0) {
        $items = 0;
        $learning_menu_max_courses = (int) COption::GetOptionString("learning", "menu_max_courses", "10");
    }
    while ($arData = $CDBResult->GetNext()) {
        // When listing courses, limit it's count
        if ($deep === 0) {
            if ($items >= $learning_menu_max_courses) {
                // add element 'other courses'
                $arMenu[] = array('text' => GetMessage('LEARNING_MENU_COURSES_OTHER'), 'url' => 'learn_unilesson_admin.php?lang=' . LANG . '&PARENT_LESSON_ID=-1', 'title' => GetMessage('LEARNING_MENU_COURSES_ALT'), 'more_url' => array('learn_test_admin.php', 'learn_test_edit.php', 'learn_unilesson_admin.php', 'learn_unilesson_edit.php', 'learn_question_admin.php', 'learn_question_edit.php'));
                // stop adding courses to menu
                break;
            }
            $items++;
        }
        $arSubImmediateChildsIds = false;
        $arCurItemPath = $arCurrentDeepPath;
        $arCurItemPath[] = $arData['LESSON_ID'] + 0;
        // Remember all immediate childs
        $immediateChildsIds[] = $arData['LESSON_ID'] + 0;
        $oCurItemPath = new CLearnPath();
        $oCurItemPath->SetPathFromArray($arCurItemPath);
        $urlCurItemPath = $oCurItemPath->ExportUrlencoded();
        $arItem = array('text' => $arData['NAME'], 'url' => 'learn_unilesson_admin.php?lang=' . LANG . '&PARENT_LESSON_ID=' . ($arData['LESSON_ID'] + 0) . '&LESSON_PATH=' . $oCurItemPath->ExportUrlencoded(), 'title' => $arData['NAME'], 'items_id' => 'menu_learning_courses_new_' . implode('_', $arCurItemPath), "icon" => "learning_icon_courses", 'module_id' => 'learning', 'more_url' => array('learn_unilesson_admin.php?lang=' . LANG . '&set_filter=Y' . '&PARENT_LESSON_ID=' . ($arData['LESSON_ID'] + 0) . '&LESSON_PATH=' . $urlCurItemPath, 'learn_unilesson_admin.php?lang=' . LANG . '&PARENT_LESSON_ID=' . ($arData['LESSON_ID'] + 0) . '&LESSON_PATH=' . $urlCurItemPath, 'learn_unilesson_admin.php?lang=' . LANG . '&set_filter=Y' . '&LESSON_PATH=' . $urlCurItemPath, 'learn_question_admin.php?lang=' . LANG . '&filter=Y&set_filter=Y' . '&LESSON_PATH=' . $urlCurItemPath, 'learn_question_edit.php?lang=' . LANG . '&set_filter=Y' . '&LESSON_PATH=' . $urlCurItemPath, 'learn_unilesson_edit.php?lang=' . LANG . '&LESSON_ID=' . ($arData['LESSON_ID'] + 0) . '&LESSON_PATH=' . $urlCurItemPath, 'learn_unilesson_edit.php?lang=' . LANG . '&PARENT_LESSON_ID=' . ($arData['LESSON_ID'] + 0) . '&LESSON_PATH=' . $urlCurItemPath));
        $arItem['items'] = array();
        if ($deep === 0 && isset($arData['LINKED_LESSON_ID']) && $arData['LINKED_LESSON_ID'] > 0) {
            $arItem['page_icon'] = $arItem['icon'] = 'learning_icon_courses';
            $arItem['dynamic'] = true;
            $loadOnlySpecialEntities = false;
            // Load child items only for lesson in current path
            if ($arData['LESSON_ID'] == $currentLessonIdInPath) {
                $arItem['items'] = __learning_admin_get_menu($THIS, $arPath, $deep + 1, $arSubImmediateChildsIds);
            }
        } else {
            $loadOnlySpecialEntities = false;
            $childsCnt = CLearnLesson::CountImmediateChilds($arData['LESSON_ID']);
            $questionsCnt = CLQuestion::GetCount(array('LESSON_ID' => (int) $arData['LESSON_ID']));
            if ($childsCnt > 0) {
                $arItem['page_icon'] = $arItem['icon'] = 'learning_icon_chapters';
            } else {
                $arItem['page_icon'] = $arItem['icon'] = 'learning_icon_lessons';
            }
            $arItem['dynamic'] = true;
            // Load child items only for lesson in current path
            if ($arData['LESSON_ID'] == $currentLessonIdInPath) {
                $arItem['items'] = __learning_admin_get_menu($THIS, $arPath, $deep + 1, $arSubImmediateChildsIds);
            }
        }
        // now, adds items into more_url (it needs when edit form for childs opened)
        if (is_array($arSubImmediateChildsIds)) {
            $oSubItemPath = new CLearnPath();
            foreach ($arSubImmediateChildsIds as $k => $v) {
                // determine path for every child
                $arSubItemPath = $arCurItemPath;
                $arSubItemPath[] = $v;
                // child id added to current path
                $oSubItemPath->SetPathFromArray($arSubItemPath);
                $arItem['more_url'][] = 'learn_unilesson_edit.php?lang=' . LANG . '&filter=Y&set_filter=Y' . '&LESSON_ID=' . ($v + 0) . '&LESSON_PATH=' . $oSubItemPath->ExportUrlencoded();
            }
            unset($oSubItemPath);
            $arSubImmediateChildsIds = false;
        }
        $arMenu[] = $arItem;
        unset($oCurItemPath, $arCurItemPath, $urlCurItemPath, $arItem);
    }
    return $arMenu;
}
Example #14
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
if (!CModule::IncludeModule('learning')) {
    return false;
}
//Params
$arParams["COURSE_ID"] = isset($arParams["COURSE_ID"]) && intval($arParams["COURSE_ID"]) > 0 ? intval($arParams["COURSE_ID"]) : intval($_REQUEST["COURSE_ID"]);
$arParams["SELF_TEST_TEMPLATE"] = strlen($arParams["SELF_TEST_TEMPLATE"]) > 0 ? htmlspecialcharsbx($arParams["SELF_TEST_TEMPLATE"]) : "self.php?SELF_TEST_ID=#SELF_TEST_ID#";
$CHAPTER_ID = isset($arParams["CHAPTER_ID"]) && intval($arParams["CHAPTER_ID"]) > 0 ? $arParams["CHAPTER_ID"] : $_REQUEST["CHAPTER_ID"];
if (CLearnPath::IsUrlencodedPath($CHAPTER_ID)) {
    $arParams['LESSON_PATH'] = new CLearnPath();
    $arParams['LESSON_PATH']->ImportUrlencoded($CHAPTER_ID);
    $arParams['CHAPTER_ID'] = (int) $arParams['LESSON_PATH']->GetBottom();
} elseif (substr($CHAPTER_ID, 0, 1) === '0') {
    $arParams['CHAPTER_ID'] = (int) substr($CHAPTER_ID, 1);
} else {
    $arParams['CHAPTER_ID'] = (int) CLearnLesson::LessonIdByChapterId($CHAPTER_ID);
}
if (!(isset($arParams['LESSON_PATH']) && strlen($arParams['LESSON_PATH']))) {
    $arParams['LESSON_PATH'] = '';
    if (isset($_REQUEST['LESSON_PATH']) && strlen($_REQUEST['LESSON_PATH'])) {
        $arParams['LESSON_PATH'] = $_REQUEST['LESSON_PATH'];
    }
}
$strUrlencodedLessonPath = '';
if (strlen($arParams['LESSON_PATH']) > 0) {
    $strUrlencodedLessonPath = 'LESSON_PATH=' . $arParams['LESSON_PATH'];
}
Example #15
0
 function OnSearchReindex($NS = array(), $oCallback = null, $callback_method = '')
 {
     global $DB;
     $arResult = array();
     $arAllSitesPathes = array();
     $oPath = new CLearnPath();
     $elementStartId = 0;
     $indexElementType = 'C';
     // start reindex from courses
     $by = $order = '';
     $lastProcessedCourseId = false;
     $sites = CLang::GetList($by, $order, array('TYPE' => 'C'));
     while ($site = $sites->Fetch()) {
         $arAllSitesPathes[$site['LID']] = array('C' => CCourse::GetSitePathes($site['LID'], 'C'), 'H' => CCourse::GetSitePathes($site['LID'], 'H'), 'L' => CCourse::GetSitePathes($site['LID'], 'L'));
     }
     $arCoursesFilter = array();
     $arLessonsFilter = array('LINKED_LESSON_ID' => '');
     if ($NS['MODULE'] === 'learning' && strlen($NS['ID']) > 0) {
         $indexElementType = substr($NS['ID'], 0, 1);
         $elementStartId = (int) substr($NS['ID'], 1);
         if (strlen($NS['SITE_ID']) > 0) {
             $arCoursesFilter['SITE_ID'] = $NS['SITE_ID'];
         }
     }
     $arCoursesFilter['>ID'] = $elementStartId;
     if ($indexElementType === 'C') {
         $rsCourse = CCourse::GetList(array('ID' => 'ASC'), $arCoursesFilter);
         while ($arCourse = $rsCourse->Fetch()) {
             try {
                 $arCourse["SITE_ID"] = CCourse::GetSiteId($arCourse['ID']);
                 $arPathes = $arAllSitesPathes[$arCourse['SITE_ID']]['C'];
                 $linkedLessonId = CCourse::CourseGetLinkedLesson($arCourse['ID']);
                 $arGroupPermissions = CLearnAccess::GetSymbolsAccessibleToLesson($linkedLessonId, CLearnAccess::OP_LESSON_READ);
             } catch (LearnException $e) {
                 continue;
                 // skip indexation of this item
             }
             $arSiteIds = array();
             foreach ($arPathes as $k => $path) {
                 $arCourse["PATH"] = $path;
                 $Url = str_replace("#COURSE_ID#", $arCourse["ID"], $arCourse["PATH"]);
                 $arSiteIds[$arCourse['SITE_ID']] = $Url;
             }
             $lastProcessedCourseId = $arCourse['ID'];
             $detailText = '';
             if ($arCourse["DETAIL_TEXT_TYPE"] !== 'text') {
                 $detailText = CSearch::KillTags($arCourse['DETAIL_TEXT']);
             } else {
                 $detailText = strip_tags($arCourse['DETAIL_TEXT']);
             }
             $dataBody = '';
             if (strlen($detailText) > 0) {
                 $dataBody = $detailText;
             } else {
                 $dataBody = $arCourse['NAME'];
             }
             $Result = array("ID" => "C" . $arCourse["ID"], "LAST_MODIFIED" => $arCourse["TIMESTAMP_X"], "TITLE" => $arCourse["NAME"], "BODY" => $dataBody, "SITE_ID" => $arSiteIds, "PERMISSIONS" => $arGroupPermissions, "COURSE_ID" => "C" . $arCourse["ID"]);
             if ($oCallback) {
                 $res = call_user_func(array($oCallback, $callback_method), $Result);
                 if (!$res) {
                     return "C" . $arCourse["ID"];
                 }
             } else {
                 $arResult[] = $Result;
             }
         }
         // Reindex of courses finished. Let's reindex lessons now.
         $indexElementType = 'U';
         $elementStartId = 0;
     }
     $arLessonsFilter['>LESSON_ID'] = $elementStartId;
     if ($indexElementType === 'U') {
         $rsLessons = CLearnLesson::GetList(array('LESSON_ID' => 'ASC'), $arLessonsFilter);
         $arLessonsWithCourse = array();
         // list of lessons in context of some course
         while ($arLesson = $rsLessons->Fetch()) {
             $arOParentPathes = CLearnLesson::GetListOfParentPathes($arLesson['LESSON_ID']);
             foreach ($arOParentPathes as $oParentPath) {
                 $mostParentLesson = $oParentPath->GetTop();
                 $linkedCourseId = CLearnLesson::GetLinkedCourse($mostParentLesson);
                 if ($linkedCourseId !== false) {
                     $arLessonsWithCourse[] = array_merge($arLesson, array('PARENT_COURSE_ID' => $linkedCourseId));
                 }
             }
         }
         foreach ($arLessonsWithCourse as $arLesson) {
             try {
                 $arGroupPermissions = CLearnAccess::GetSymbolsAccessibleToLesson($arLesson['LESSON_ID'], CLearnAccess::OP_LESSON_READ);
                 $arSiteIds = array();
                 $lessonType = 'L';
                 if ($arLesson['IS_CHILDS']) {
                     $lessonType = 'H';
                 }
                 foreach ($arAllSitesPathes as $siteId => $arSitePathesByLessonType) {
                     foreach ($arSitePathesByLessonType as $someLessonType => $arPathes) {
                         // skip wrong types of lessons
                         if ($lessonType !== $someLessonType) {
                             continue;
                         }
                         foreach ($arPathes as $k => $path) {
                             $oPath->SetPath($arLesson['LESSON_ID']);
                             if ($lessonType == 'H') {
                                 $Url = str_replace("#CHAPTER_ID#", '0' . $arLesson['LESSON_ID'], $path);
                             } else {
                                 $Url = str_replace("#LESSON_ID#", $arLesson['LESSON_ID'], $path);
                             }
                             $Url = str_replace("#COURSE_ID#", $arLesson['PARENT_COURSE_ID'], $Url);
                             $arSiteIds[$siteId] = $Url;
                         }
                     }
                 }
             } catch (LearnException $e) {
                 continue;
                 // skip indexation of this item
             }
             $detailText = '';
             if ($arLesson["DETAIL_TEXT_TYPE"] !== 'text') {
                 $detailText = CSearch::KillTags($arLesson['DETAIL_TEXT']);
             } else {
                 $detailText = strip_tags($arLesson['DETAIL_TEXT']);
             }
             $dataBody = '';
             if (strlen($detailText) > 0) {
                 $dataBody = $detailText;
             } else {
                 $dataBody = $arLesson['NAME'];
             }
             $Result = array("ID" => 'U' . $arLesson['LESSON_ID'], "LAST_MODIFIED" => $arLesson['TIMESTAMP_X'], "TITLE" => $arLesson['NAME'], "BODY" => $dataBody, "SITE_ID" => $arSiteIds, "PERMISSIONS" => $arGroupPermissions);
             if ($oCallback) {
                 $res = call_user_func(array($oCallback, $callback_method), $Result);
                 if (!$res) {
                     return 'U' . $arLesson['LESSON_ID'];
                 }
             } else {
                 $arResult[] = $Result;
             }
         }
     }
     if ($oCallback) {
         $rc = false;
     } else {
         $rc = $arResult;
     }
     return $rc;
 }
Example #16
0
 $APPLICATION->SetPageProperty("learning_search_url", htmlspecialcharsEx($arSearchURL["path"]));
 $searchParams = "";
 if ($arSearchURL["query"]) {
     foreach (explode("&", $arSearchURL["query"]) as $param) {
         list($name, $value) = explode("=", $param);
         $searchParams .= "<input type=\"hidden\" name=\"" . htmlspecialcharsEx($name) . "\" value=\"" . htmlspecialcharsEx($value) . "\" />";
     }
 }
 $APPLICATION->SetPageProperty("learning_search_params", $searchParams);
 if ($arVariables["LESSON_ID"] > 0) {
     $lessonID = intval($arVariables["LESSON_ID"]);
 } else {
     // Lesson is not given, so try get chapter_id
     if (isset($_REQUEST['CHAPTER_ID'])) {
         if (CLearnPath::IsUrlencodedPath($_REQUEST['CHAPTER_ID'])) {
             $LESSON_PATH = new CLearnPath();
             $LESSON_PATH->ImportUrlencoded($_REQUEST['CHAPTER_ID']);
             $lessonID = (int) $arParams['LESSON_PATH']->GetBottom();
         } elseif (substr($_REQUEST['CHAPTER_ID'], 0, 1) === '0') {
             $lessonID = (int) substr($_REQUEST['CHAPTER_ID'], 1);
         } else {
             $lessonID = (int) CLearnLesson::LessonIdByChapterId($_REQUEST['CHAPTER_ID']);
         }
     }
 }
 $linkedLessonId = false;
 if ($arParams["COURSE_ID"] > 0) {
     $linkedLessonId = CCourse::CourseGetLinkedLesson($arParams["COURSE_ID"]);
 }
 if ($arParams["CHECK_PERMISSIONS"] !== 'N') {
     $isAccessible = false;