コード例 #1
0
    }
    $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'];
}
if (isset($_POST['PARENT_LESSON_ID'])) {
    $g_learn_parentLessonId = $_POST['PARENT_LESSON_ID'];
コード例 #2
0
 public function __construct()
 {
     global $USER;
     $this->oAccess = CLearnAccess::GetInstance($USER->GetID());
     // Removes all global variables with prefix "str_"
     ClearVars();
     $parentLessonId = -2;
     // by default, magic number '-2' is means 'List lessons, without relation to parent'
     $oPath = false;
     if (isset($_GET['LESSON_PATH']) && strlen($_GET['LESSON_PATH']) > 0) {
         $oPath = new CLearnPath();
         $oPath->ImportUrlencoded($_GET['LESSON_PATH']);
         // if most top lesson is a course => than we are in context of this course
         $rootAncestorLessonId = $oPath->GetTop();
         if ($rootAncestorLessonId !== false) {
             $rc = CLearnLesson::GetLinkedCourse($rootAncestorLessonId);
             if ($rc !== false) {
                 $this->contextCourseLessonId = (int) $rootAncestorLessonId;
             }
             // lesson id of course
         }
     }
     if (isset($_POST['PARENT_LESSON_ID'])) {
         $parentLessonId = $_POST['PARENT_LESSON_ID'];
     } elseif (isset($_GET['PARENT_LESSON_ID'])) {
         $parentLessonId = $_GET['PARENT_LESSON_ID'];
     } elseif ($oPath !== false) {
         $parentLessonId = $oPath->GetBottom();
         if ($parentLessonId === false) {
             $parentLessonId = -2;
         }
         // by default, magic number '-2' is means 'List lessons, without relation to parent'
     }
     $this->requestedParentLessonId = $parentLessonId;
     // Determine current list mode
     if ($parentLessonId >= 1) {
         $this->listMode = self::ListChildLessonsMode;
     } elseif ($parentLessonId == -1) {
         // magic number '-1' is means 'List courses'
         $this->listMode = self::ListAnyCoursesMode;
     } else {
         $this->listMode = self::ListAnyLessonsMode;
     }
     // by default
     $orderBy = false;
     $order = 'asc';
     if (isset($_POST['by'])) {
         $orderBy = $_POST['by'];
     } elseif (isset($_GET['by'])) {
         $orderBy = $_GET['by'];
     }
     if (isset($_POST['order'])) {
         $order = $_POST['order'];
     } elseif (isset($_GET['order'])) {
         $order = $_GET['order'];
     }
     $order = strtolower($order);
     if ($orderBy !== false && ($order === 'asc' || $order === 'desc')) {
         $this->arSortOrder = array($orderBy => $order);
     }
     $this->search_mode = false;
     $this->search_mode_type = 'childs_candidates';
     // by default;
     if (isset($_GET['search_retpoint'])) {
         $this->search_mode = true;
         $this->search_retpoint = $_GET['search_retpoint'];
         $this->hrefSearchRetPoint = '&search_retpoint=' . htmlspecialcharsbx($this->search_retpoint);
         if (isset($_GET['search_mode_type'])) {
             if ($_GET['search_mode_type'] === 'parents_candidates') {
                 $this->search_mode_type = 'parents_candidates';
             } elseif ($_GET['search_mode_type'] === 'attach_question_to_lesson') {
                 $this->search_mode_type = 'attach_question_to_lesson';
             }
         }
     }
 }