Exemplo n.º 1
0
    $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'];
        }
    }
}
if ($LESSON_ID === false) {
    require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
    CAdminMessage::ShowMessage(GetMessage('LEARNING_BAD_LESSON'));
    require $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/epilog_admin.php';
Exemplo n.º 2
0
}
//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 ? "&" : "?";
            $deleteReturnUrl .= "LESSON_PATH=" . $lessonPath;
        } else {
Exemplo n.º 3
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;
 }