public static function CanUserViewLessonAsPublic($arParams) { // Parse options (user_id from $arParams will be automaticaly resolved) $options = self::ParseParamsWithUser($arParams, array('COURSE_ID' => array('type' => 'strictly_castable_to_integer', 'mandatory' => true), 'LESSON_ID' => array('type' => 'strictly_castable_to_integer', 'mandatory' => true))); // Is it course? $linkedLessonId = CCourse::CourseGetLinkedLesson($options['COURSE_ID']); if ($linkedLessonId === false) { return false; } // Access denied $lessonId = $options['LESSON_ID']; $breakOnLessonId = $linkedLessonId; // save resources // Is lesson included into given course? $isLessonChildOfCourse = false; $arOPathes = CLearnLesson::GetListOfParentPathes($lessonId, $breakOnLessonId); foreach ($arOPathes as $oPath) { $topLessonId = $oPath->GetTop(); if ($topLessonId !== false && $topLessonId == $linkedLessonId) { $isLessonChildOfCourse = true; break; } } if (!$isLessonChildOfCourse) { return false; } // Access denied // Check permissions for course $isCourseAccessible = self::CanUserViewLessonContent(array('lesson_id' => $linkedLessonId)); // Permissions for all lessons/chapters in public are equivalent to course permissions return $isCourseAccessible; }
foreach ($arVarsOnForm as $k => $varName) { if (!is_array(${$varName})) { ${'str_' . $varName} = htmlspecialcharsbx(${$varName}); } else { $tmp = array(); foreach (${$varName} as $key => $value) { $tmp[$key] = htmlspecialcharsbx($value); } ${'str_' . $varName} = $tmp; unset($tmp); } } } $aTabs = array(array("DIV" => "edit1", "ICON" => "main_user_edit", "TAB" => GetMessage("LEARNING_EDIT_PARAM_SECTION"), "TITLE" => GetMessage("LEARNING_EDIT_PARAM_SECTION")), array("DIV" => "edit2", "ICON" => "main_user_edit", "TAB" => GetMessage("LEARNING_ADMIN_TAB2"), "TITLE" => GetMessage("LEARNING_ADMIN_TAB2_EX")), array("DIV" => "edit3", "ICON" => "main_user_edit", "TAB" => GetMessage("LEARNING_ADMIN_TAB3"), "TITLE" => GetMessage("LEARNING_ADMIN_TAB3_EX"))); if ($LESSON_ID > 0 && CLearnAccessMacroses::CanUserViewLessonRelations(array('lesson_id' => $LESSON_ID))) { $arOPathes = CLearnLesson::GetListOfParentPathes($LESSON_ID); $tabName = GetMessage("LEARNING_ADMIN_TAB4"); $aTabs[] = array("DIV" => "edit4", "ICON" => "main_user_edit", "TAB" => $tabName, "TITLE" => GetMessage("LEARNING_ADMIN_TAB4_EX")); } if ($LESSON_ID > 0 && CLearnAccessMacroses::CanUserViewLessonRights(array('lesson_id' => $LESSON_ID))) { $aTabs[] = array("DIV" => "edit5", "ICON" => "main_user_edit", "TAB" => GetMessage("LEARNING_PERMISSIONS"), "TITLE" => GetMessage("LEARNING_PERMISSIONS")); } $aTabs[] = $USER_FIELD_MANAGER->EditFormTab('LEARNING_LESSONS'); //$tabControl = new CAdminTabControl("lessonTabControl", $aTabs); $tabControl = new CAdminForm("lessonTabControl", $aTabs); require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php"; if ($message) { echo $message->Show(); } if (!$bBadCourse) { // Back to lessons list available only if there is parentLessonPath exists
public static function OnSearchReindex($NS = array(), $oCallback = null, $callback_method = '') { global $DB; static $arCourseToSiteCache = array(); $arResult = array(); $arAllSitesPathes = array(); $elementStartId = 0; $indexElementType = 'C'; // start reindex from courses $by = $order = ''; $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']); if ($linkedLessonId === false) { continue; } $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; } if ($arCourse["DETAIL_TEXT_TYPE"] !== 'text') { $detailText = CSearch::KillTags($arCourse['DETAIL_TEXT']); } else { $detailText = strip_tags($arCourse['DETAIL_TEXT']); } 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); while ($arLessonFromDb = $rsLessons->Fetch()) { $arLessonsWithCourse = array(); // list of lessons in context of some course $arOParentPathes = CLearnLesson::GetListOfParentPathes($arLessonFromDb['LESSON_ID']); foreach ($arOParentPathes as $oParentPath) { $arParentLessons = $oParentPath->GetPathAsArray(); foreach ($arParentLessons as $lessonId) { $linkedCourseId = CLearnLesson::GetLinkedCourse($lessonId); if ($linkedCourseId !== false && $linkedCourseId > 0) { $arLessonsWithCourse[] = array_merge($arLessonFromDb, array('PARENT_COURSE_ID' => $linkedCourseId)); } } } foreach ($arLessonsWithCourse as $arLesson) { try { $arGroupPermissions = CLearnAccess::GetSymbolsAccessibleToLesson($arLesson['LESSON_ID'], CLearnAccess::OP_LESSON_READ); $courseId = $arLesson['PARENT_COURSE_ID']; if (!isset($arCourseToSiteCache[$courseId])) { $strSql = "SELECT SITE_ID FROM b_learn_course_site WHERE COURSE_ID=" . (int) $courseId; $rc = $DB->Query($strSql, true); if ($rc === false) { continue; } $arCourseToSiteCache[$courseId] = array(); while ($arCourseSite = $rc->fetch()) { $arCourseToSiteCache[$courseId][] = $arCourseSite['SITE_ID']; } } $arAllowedSites = $arCourseToSiteCache[$courseId]; if (empty($arAllowedSites)) { continue; } $arSiteIds = array(); $lessonType = 'L'; if ($arLesson['IS_CHILDS']) { $lessonType = 'H'; } foreach ($arAllSitesPathes as $siteId => $arSitePathesByLessonType) { if (!in_array($siteId, $arAllowedSites, true)) { continue; } foreach ($arSitePathesByLessonType as $someLessonType => $arPathes) { // skip wrong types of lessons if ($lessonType !== $someLessonType) { continue; } foreach ($arPathes as $k => $path) { 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 } if ($arLesson["DETAIL_TEXT_TYPE"] !== 'text') { $detailText = CSearch::KillTags($arLesson['DETAIL_TEXT']); } else { $detailText = strip_tags($arLesson['DETAIL_TEXT']); } 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; }
if ($oAccess->IsBaseAccess(CLearnAccess::OP_LESSON_CREATE)) { $Perm = 'X'; } else { $APPLICATION->SetTitle(GetMessage('LEARNING_ACCESS_D')); require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php"; $aContext = array(array("ICON" => "btn_list", "TEXT" => GetMessage("LEARNING_BACK_TO_ADMIN"), "LINK" => "learn_unilesson_admin.php?lang=" . LANG . '&PARENT_LESSON_ID=-1' . GetFilterParams("filter_"), "TITLE" => GetMessage("LEARNING_BACK_TO_ADMIN"))); $context = new CAdminContextMenu($aContext); $context->Show(); CAdminMessage::ShowMessage(GetMessage("LEARNING_ACCESS_D")); require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php"; die; } } $aTabs = array(array("DIV" => "edit1", "TAB" => GetMessage("LEARNING_ADMIN_TAB1"), "ICON" => "main_user_edit", "TITLE" => GetMessage("LEARNING_ADMIN_TAB1_EX")), array("DIV" => "edit2", "TAB" => GetMessage("LEARNING_ADMIN_TAB3"), "ICON" => "main_user_edit", "TITLE" => GetMessage("LEARNING_ADMIN_TAB3_EX")), array("DIV" => "edit3", "TAB" => GetMessage("LEARNING_ADMIN_TAB4"), "ICON" => "main_user_edit", "TITLE" => GetMessage("LEARNING_ADMIN_TAB4_EX"))); if ($COURSE_ID > 0 && ($linkedLessonId = CCourse::CourseGetLinkedLesson($COURSE_ID))) { $arOPathes = CLearnLesson::GetListOfParentPathes($linkedLessonId); $arOPathes_cnt = count($arOPathes); $tabName = GetMessage("LEARNING_ADMIN_TAB5"); if ($arOPathes_cnt > 1) { $tabName .= ' (' . $arOPathes_cnt . ')'; } $aTabs[] = array("DIV" => "edit4", "ICON" => "main_user_edit", "TAB" => $tabName, "TITLE" => GetMessage("LEARNING_ADMIN_TAB5_EX")); } $aTabs[] = array("DIV" => "edit5", "ICON" => "main_user_edit", "TAB" => GetMessage("LEARNING_PERMISSIONS"), "TITLE" => GetMessage("LEARNING_PERMISSIONS")); $aTabs[] = $USER_FIELD_MANAGER->EditFormTab('LEARNING_LESSONS'); $tabControl = new CAdminForm("courseTabControl", $aTabs, true, $bDenyAutosave); if ($_SERVER["REQUEST_METHOD"] == "POST" && $Perm >= "X" && strlen($_POST["Update"]) > 0 && check_bitrix_sessid()) { $course = new CCourse(); $arPREVIEW_PICTURE = $_FILES["PREVIEW_PICTURE"]; $arPREVIEW_PICTURE["del"] = $PREVIEW_PICTURE_del; $arPREVIEW_PICTURE["MODULE_ID"] = "learning";
public function BuildList() { global $USER; $filterParams = GetFilterParams('filter_'); // list's footer $this->oList->AddFooter(array(array('title' => GetMessage('MAIN_ADMIN_LIST_SELECTED'), 'value' => $this->rsData->SelectedRowsCount()), array('counter' => true, 'title' => GetMessage('MAIN_ADMIN_LIST_CHECKED'), 'value' => '0'))); $oParentPath = new CLearnPath(); if (isset($_GET['LESSON_PATH'])) { $oParentPath->ImportUrlencoded($_GET['LESSON_PATH']); } $arParentPath = $oParentPath->GetPathAsArray(); // building list while ($arRes = $this->rsData->NavNext(false)) { $oCurPath = new CLearnPath(); $oCurPath->SetPathFromArray(array_merge($arParentPath, array($arRes['LESSON_ID']))); $urlCurPath = $oCurPath->ExportUrlencoded(); unset($oCurPath); // PUBLISH_PROHIBITED available in context of most parent course only if ($this->contextCourseLessonId !== false) { $arRes['PUBLISH_PROHIBITED'] = 'N'; if (CLearnLesson::IsPublishProhibited($arRes['LESSON_ID'], $this->contextCourseLessonId)) { $arRes['PUBLISH_PROHIBITED'] = 'Y'; } } $arRes['SITE_ID'] = ''; $courseId = CLearnLesson::GetLinkedCourse($arRes['LESSON_ID']); if ($courseId !== false) { $hrefPrefix = 'learn_course_edit.php?COURSE_ID=' . $courseId; $resCourseSites = CCourse::GetSite($courseId); while ($arCourseSites = $resCourseSites->Fetch()) { if ($arRes['SITE_ID'] != '') { $arRes['SITE_ID'] .= ' / '; } $arRes['SITE_ID'] .= htmlspecialcharsbx($arCourseSites['LID']); } } else { $hrefPrefix = 'learn_unilesson_edit.php?LESSON_ID=' . $arRes['LESSON_ID'] . '&LESSON_PATH=' . urlencode($urlCurPath); } $actionEditLesson = $hrefPrefix . '&lang=' . LANG . $filterParams; $rowAction = false; $rowTitle = ''; if (!$this->IsSearchMode()) { $rowAction = 'learn_unilesson_admin.php?lang=' . LANG . '&set_filter=Y' . '&PARENT_LESSON_ID=' . ($arRes['LESSON_ID'] + 0) . '&LESSON_PATH=' . $urlCurPath . '&' . $this->hrefSearchRetPoint; $rowTitle = GetMessage('LEARNING_TRAVERSE'); // "Traverse list of immediate childs" if (!$arRes['IS_CHILDS']) { $rowAction = $actionEditLesson; $rowTitle = GetMessage('LEARNING_EDIT_TITLE'); } } $row =& $this->oList->AddRow($arRes['LESSON_ID'], $arRes, $rowAction, $rowTitle); $arParents = $arChilds = array(); $htmlParents = $htmlChilds = ''; $rsParents = CLearnLesson::GetListOfImmediateParents($arRes['LESSON_ID'], array(), array('CHECK_PERMISSIONS' => 'N')); while ($arParent = $rsParents->Fetch()) { $arParents[] = $arParent['NAME']; } $arParents = array_map('htmlspecialcharsbx', $arParents); if (count($arParents) > 0) { $htmlParents = implode('<hr width="100%" size="1">', $arParents); } else { $htmlParents = ' '; } $rsChilds = CLearnLesson::GetListOfImmediateChilds($arRes['LESSON_ID'], array(), array('CHECK_PERMISSIONS' => 'N')); while ($arChild = $rsChilds->Fetch()) { $arChilds[] = $arChild['NAME']; } $arChilds = array_map('htmlspecialcharsbx', $arChilds); if (count($arChilds) > 0) { $htmlChilds = implode('<hr width="100%" size="1">', $arChilds); } else { $htmlChilds = ' '; } if (isset($arRes['LINKED_LESSON_ID']) && $arRes['LINKED_LESSON_ID'] > 0) { $icon = 'learning_icon_courses'; } elseif (count($arChilds) > 0) { $icon = 'learning_icon_chapters'; } else { $icon = 'learning_icon_lessons'; } if (!$this->IsSearchMode()) { $row->AddViewField('NAME', '<span class="adm-list-table-icon-link"><span class="adm-submenu-item-link-icon adm-list-table-icon ' . $icon . '"></span>' . ($rowAction === false ? '<span class="adm-list-table-link">' . htmlspecialcharsbx($arRes['NAME']) . '</span>' : '<a href="' . $rowAction . '" class="adm-list-table-link">' . htmlspecialcharsbx($arRes['NAME']) . '</a>') . '</span>'); } else { $actionUseLesson = "(function()\n\t\t\t\t\t{\n\t\t\t\t\t\tvar fnName = '" . str_replace(array("'", ';', ',', "\n", "\r"), '', htmlspecialcharsbx($this->search_retpoint)) . "';\n\t\t\t\t\t\tif ( ! (window.opener && window.opener[fnName]) )\n\t\t\t\t\t\t\treturn;\n\n\t\t\t\t\t\twindow.opener[fnName]('" . (int) $arRes['LESSON_ID'] . "', '" . CUtil::JSEscape(htmlspecialcharsbx($arRes['NAME'])) . "');\n\t\t\t\t\t\twindow.close();\n\t\t\t\t\t})();\n\t\t\t\t\t"; $row->AddViewField('NAME', '<a href="javascript:void(0);" class="adm-list-table-icon-link" onclick="' . $actionUseLesson . '"><span class="adm-submenu-item-link-icon adm-list-table-icon ' . $icon . '"></span><span class="adm-list-table-link">' . htmlspecialcharsbx($arRes['NAME']) . '</span></a>'); } $row->AddViewField('PARENTS', $htmlParents); $row->AddEditField('PARENTS', ' '); $row->AddViewField('CHILDS', $htmlChilds); $row->AddEditField('CHILDS', ' '); // this is very heavy statistic, so will be a good idea to add settings to the module, which turn off this statistics $oLearnTree = CLearnLesson::GetTree($arRes['LESSON_ID']); $arTree = $oLearnTree->GetTreeAsList(); $depth = -1; $chapterCount = 0; $lessonsCount = 0; $questionsCount = CLQuestion::GetCount(array('LESSON_ID' => (int) $arRes['LESSON_ID'])); foreach ($arTree as $arLessonData) { if ($arLessonData['IS_CHILDS']) { ++$chapterCount; } else { ++$lessonsCount; } if ((int) $arLessonData['#DEPTH_IN_TREE'] > $depth) { $depth = (int) $arLessonData['#DEPTH_IN_TREE']; } $questionsCount += CLQuestion::GetCount(array('LESSON_ID' => (int) $arLessonData['LESSON_ID'])); } // PUBLISH_PROHIBITED available in context of most parent course only if ($this->contextCourseLessonId !== false) { if ($this->IsLessonUpdateAccess($arRes['LESSON_ID']) === true) { $row->AddInputField('PUBLISH_PROHIBITED', array('size' => '35')); $row->AddCheckField('PUBLISH_PROHIBITED'); } else { $row->AddCheckField('PUBLISH_PROHIBITED', true); } } // Render CARDINALITY fields $htmlDepth = (int) ($depth + 1); $htmlChapters = (string) (int) $chapterCount . ' [<a href="learn_unilesson_edit.php?lang=' . LANG . '&PROPOSE_RETURN_LESSON_PATH=' . $urlCurPath . '" title="' . GetMessage('LEARNING_UNILESSON_ADD') . '"' . '>+</a>]'; $htmlLessons = (string) (int) $lessonsCount . ' [<a href="learn_unilesson_edit.php?lang=' . LANG . '&PROPOSE_RETURN_LESSON_PATH=' . $urlCurPath . '" title="' . GetMessage('LEARNING_UNILESSON_ADD') . '"' . '>+</a>]'; $htmlQuestions = '<a href="learn_question_admin.php?lang=' . LANG . '&filter=Y&set_filter=Y' . '&PARENT_LESSON_ID=' . ($arRes['LESSON_ID'] + 0) . '&LESSON_PATH=' . $urlCurPath . '" title="' . GetMessage('LEARNING_QUESTION_ALT') . '">' . (int) $questionsCount . '</a>' . ' [' . '<a href="learn_question_edit.php?lang=' . LANG . '&LESSON_PATH=' . $urlCurPath . '&QUESTION_TYPE=S' . '&filter=Y&set_filter=Y' . '&from=learn_menu"' . ' title="' . GetMessage('LEARNING_QUESTION_ADD') . '">+</a>' . ']'; $row->AddViewField('CARDINALITY_DEPTH', $htmlDepth); $row->AddViewField('CARDINALITY_CHAPTERS', $htmlChapters); $row->AddViewField('CARDINALITY_LESSONS', $htmlLessons); $row->AddViewField('CARDINALITY_QUESTIONS', $htmlQuestions); if ($courseId !== false) { $testsCount = (int) CTest::GetCount(array('COURSE_ID' => $courseId)); $htmlTests = '<a href="learn_test_admin.php?lang=' . LANG . '&COURSE_ID=' . $courseId . '&PARENT_LESSON_ID=' . (int) $arRes['LESSON_ID'] . '&LESSON_PATH=' . $urlCurPath . '&filter=Y&set_filter=Y"' . '>' . $testsCount . '</a>' . ' [<a href="learn_test_edit.php?lang=' . LANG . '&COURSE_ID=' . $courseId . '&PARENT_LESSON_ID=' . (int) $arRes['LESSON_ID'] . '&LESSON_PATH=' . $urlCurPath . '&filter=Y&set_filter=Y" title="' . GetMessage('LEARNING_QUESTION_ADD') . '"' . '>+</a>]'; $row->AddViewField('CARDINALITY_TESTS', $htmlTests); } if (!$this->IsSearchMode() && $this->IsLessonUpdateAccess($arRes['LESSON_ID']) === true) { $row->AddInputField('NAME', array('size' => '35')); // SORT field editing possibly only for courses and for lessons in relation to parent lesson if ($this->IsListChildLessonsMode() || $this->IsListAnyCoursesMode()) { $row->AddInputField('SORT', array('size' => '3')); } $row->AddCheckField('ACTIVE'); $row->AddInputField('CODE'); } else { $row->AddCheckField('ACTIVE', false); } $row->AddViewField('CREATED_USER_NAME', $arRes['CREATED_USER_NAME']); $arActions = array(); if (!$this->IsSearchMode()) { if ($this->IsLessonUpdateAccess($arRes['LESSON_ID']) === true) { $editTxt = GetMessage('MAIN_ADMIN_MENU_EDIT'); } else { $editTxt = GetMessage('MAIN_ADMIN_MENU_OPEN'); } // Actions $arActions[] = array('ICON' => 'edit', 'TEXT' => $editTxt, 'ACTION' => $this->oList->ActionRedirect($actionEditLesson)); $arActions[] = array("SEPARATOR" => true); $arActions[] = array('ICON' => 'list', 'TEXT' => GetMessage('LEARNING_QUESTION_ALT') . ' (' . ($questionsCount + 0) . ')', 'ACTION' => $this->oList->ActionRedirect('learn_question_admin.php?lang=' . LANG . '&filter=Y&set_filter=Y' . '&PARENT_LESSON_ID=' . ($arRes['LESSON_ID'] + 0) . '&LESSON_PATH=' . urlencode($urlCurPath))); /* $arActions[] = array( "ICON"=>"copy", "TEXT"=>GetMessage("MAIN_ADMIN_ADD_COPY"), "ACTION"=>$this->oList->ActionRedirect("learn_course_edit.php?COPY_ID=".$f_ID)); */ $isDeleteCmdDisabled = true; $isDisbandCmdDisabled = true; $deleteMSG = ''; $disbandMSG = ''; $actionDisband = ''; $action = ''; if ($arRes['CHILDS_CNT'] > 0) { $deleteMSG = GetMessage('LEARNING_ADMIN_MENU_DELETE_RECURSIVE') . ' (' . (string) (int) $arRes['CHILDS_CNT'] . ')'; } else { $deleteMSG = GetMessage("MAIN_ADMIN_MENU_DELETE"); } $disbandMSG = GetMessage('LEARNING_ADMIN_MENU_DISBAND'); $isEnoughRightsForDisbandLesson = false; try { $this->EnsureLessonDisbandAccess($arRes['LESSON_ID']); $isEnoughRightsForDisbandLesson = true; } catch (CLearnRenderAdminUnilessonListException $e) { if ($e->GetCode() & CLearnRenderAdminUnilessonListException::C_ACCESS_DENIED) { } else { // bubble exception throw new CLearnRenderAdminUnilessonListException($e->GetMessage(), $e->GetCode()); } } // If we can unlink all neighbours and remove lesson if ($isEnoughRightsForDisbandLesson) { $arOPathes = CLearnLesson::GetListOfParentPathes($arRes['LESSON_ID']); $parentPathesCnt = count($arOPathes); // prepare "Disband" command $isDisbandCmdDisabled = false; $actionDisband = $this->oList->ActionDoGroup($arRes['LESSON_ID'], 'disband', 'PARENT_LESSON_ID=' . ($this->requestedParentLessonId + 0)); if ($parentPathesCnt >= 1) { $actionDisband = "if(confirm('" . str_replace('#CNT#', $parentPathesCnt, GetMessageJS('LEARNING_CONFIRM_DISBAND_LESSON_WITH_PARENT_PATHES')) . "')) " . '{ ' . $actionDisband . ' }'; } $actionDisband = "if(confirm('" . GetMessageJS('LEARNING_ADMIN_MENU_DISBAND_QUESTION') . "')) " . '{ ' . $actionDisband . ' }'; // prepare "Remove" command $isDeleteCmdDisabled = false; if ($arRes['CHILDS_CNT'] > 0) { $action = $this->oList->ActionDoGroup($arRes['LESSON_ID'], 'recursive_delete', 'PARENT_LESSON_ID=' . ($this->requestedParentLessonId + 0)); } else { // If no childs => "delete" is equal to "disband" $action = $this->oList->ActionDoGroup($arRes['LESSON_ID'], 'disband', 'PARENT_LESSON_ID=' . ($this->requestedParentLessonId + 0)); } if ($parentPathesCnt >= 1) { $deleteMSG .= ' [' . $parentPathesCnt . ']'; $action = "if(confirm('" . str_replace('#CNT#', $parentPathesCnt, GetMessageJS("LEARNING_CONFIRM_DEL_LESSON_WITH_PARENT_PATHES")) . "')) " . $action; } else { $action = "if(confirm('" . GetMessageJS('LEARNING_CONFIRM_DEL_MESSAGE') . "')) " . $action; } } // We can "disband" only lessons, that contains childs $arActions[] = array("SEPARATOR" => true); if ($arRes['CHILDS_CNT'] > 0) { $arActions[] = array('ICON' => 'delete', 'TEXT' => $disbandMSG, 'ACTION' => $actionDisband, 'DISABLED' => $isDisbandCmdDisabled, 'TITLE' => GetMessage('LEARNING_ADMIN_MENU_DISBAND_TITLE')); } $arActions[] = array('ICON' => 'delete', 'TEXT' => $deleteMSG, 'ACTION' => $action, 'DISABLED' => $isDeleteCmdDisabled); } else { $arActions[] = array('ICON' => 'list', 'TEXT' => GetMessage('LEARNING_SELECT'), 'ACTION' => $actionUseLesson); } $row->AddActions($arActions); } return $this; }