} if (isset($g_learn_currentLessonPath)) { unset($g_learn_currentLessonPath); } if (isset($g_learn_parentLessonPath)) { unset($g_learn_parentLessonPath); } if (isset($_POST['LESSON_PATH']) || isset($_GET['LESSON_PATH'])) { if (isset($_POST['LESSON_PATH'])) { $g_learn_currentLessonPath = $_POST['LESSON_PATH']; } else { $g_learn_currentLessonPath = $_GET['LESSON_PATH']; } $oPath = new CLearnPath(); $oPath->ImportUrlencoded($g_learn_currentLessonPath); $arPath = $oPath->GetPathAsArray(); if (count($arPath) >= 2) { // pop current lesson id array_pop($arPath); // remember parent path $oParentPath = new CLearnPath(); $oParentPath->SetPathFromArray($arPath); $g_learn_parentLessonPath = urldecode($oParentPath->ExportUrlencoded()); // pop parent lesson id $g_learn_parentLessonId = array_pop($arPath); // If lesson was edited and unlinked from parent $g_parentLessonId // we must cleanup LESSON_PATH. Also we must cleanup lesson path if // it is wrong due to other reasons. // $arEdgesToParents = CLearnLesson::ListImmediateParents($LESSON_ID); // // $isLinkToParentFound = true;
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; }