// Get lesson data as immediate child of parent lesson. // It needs for getting edges data (SORT). $result = CLearnLesson::GetListOfImmediateChilds($str_PARENT_LESSON_ID, array(), array('LESSON_ID' => $LESSON_ID)); // get data for current lesson only } } else { if (isset($str_PARENT_LESSON_ID)) { unset($str_PARENT_LESSON_ID); } if ($LESSON_ID > 0) { $result = CLearnLesson::GetByID($LESSON_ID); } } // Now $str_PARENT_LESSON_ID exists only if in GET and/or POST request was PARENT_LESSON_ID if ($topCourseLessonId !== false && $LESSON_ID > 0) { if (CLearnLesson::IsPublishProhibited($LESSON_ID, $topCourseLessonId)) { $str_PUBLISH_PROHIBITED = 'Y'; } } if (!($result && $result->ExtractFields("str_"))) { $LESSON_ID = 0; } if ($bVarsFromForm) { $ACTIVE = $ACTIVE != "Y" ? "N" : "Y"; /** * Resolving dependencies for new data structure * was: * $DB->InitTableVarsForEdit("b_learn_lesson", "", "str_"); */ $arVarsOnForm = array('TIMESTAMP_X', 'ACTIVE', 'CODE', 'NAME', 'KEYWORDS', 'PREVIEW_TEXT', 'PREVIEW_TEXT_TYPE', 'DETAIL_TEXT', 'DETAIL_TEXT_TYPE', 'LAUNCH'); // Only in context of parent lesson
public function _GetCourseContent($parentLessonId, $DEPTH_LEVEL = 1) { global $DB; $res = CLearnLesson::GetListOfImmediateChilds($parentLessonId, array('EDGE_SORT' => 'asc')); while ($arRes = $res->Fetch()) { $arRes['ID'] = $arRes['LESSON_ID']; // for compatibility if ($arRes['IS_CHILDS'] == '1') { $itemType = 'CHA'; } else { $itemType = 'LES'; } if (CLearnLesson::IsPublishProhibited($arRes['LESSON_ID'], $parentLessonId)) { $arRes['META_PUBLISH_PROHIBITED'] = 'Y'; } else { $arRes['META_PUBLISH_PROHIBITED'] = 'N'; } $r = ++$this->RefID; $this->arItems[$r] = $this->_CreateContent($itemType, $arRes, $r); $this->strItems .= '<item identifier="' . $itemType . $r . '" identifierref="RES' . $r . '"><title>' . htmlspecialcharsbx($arRes["NAME"]) . '</title>'; $this->strResourses .= '<resource identifier="RES' . $r . '" type="webcontent" href="res' . $r . '.xml">' . $this->_GetResourceFiles($r) . '</resource>'; $this->createQuestionItems($arRes["ID"]); // Load content recursively for chapters if ($arRes['IS_CHILDS'] == '1') { $this->_GetCourseContent($arRes["ID"], $DEPTH_LEVEL + 1); } $this->strItems .= "</item>"; } }
public static function RenderForm($oAccess, $LESSON_ID, $arOPathes) { global $APPLICATION; $curDir = $APPLICATION->GetCurDir(); if (substr($curDir, -1) !== '/') { $curDir .= '/'; } ?> <script type="text/javascript"> function module_learning_js_admin_function_add_parent(lesson_id, name) { module_learning_js_admin_function_add_child_or_parent('LEARNING_LIST_OF_PARENTS', 'RELATION_PARENT[]', lesson_id, name); //alert ('called: module_learning_js_admin_function_add_parent(' + lesson_id + name + ')'); } function module_learning_js_admin_function_add_child(lesson_id, name) { module_learning_js_admin_function_add_child_or_parent('LEARNING_LIST_OF_DESCENDANTS', 'RELATION_CHILD[]', lesson_id, name); //alert ('called: module_learning_js_admin_function_add_child(' + lesson_id + ')'); } function module_learning_js_admin_function_add_child_or_parent(targetNode, fieldName, lesson_id, name) { var elemId = 'RELATION_PARENT_LID_' + lesson_id; var oDIV = BX.create('DIV', {'props': {'id': elemId}}); var oA = BX.create( 'SPAN', { 'props': { 'className': 'access-delete', }, 'style': { position: 'relative', top: '3px', marginRight: '1px' }, 'events': { 'click': function() { document.getElementById(elemId).parentNode.removeChild(document.getElementById(elemId)); } } } ); var oINPUT = BX.create( 'INPUT', { 'props': { 'type': 'hidden', 'name': fieldName, 'value': lesson_id } } ); var oSPAN = BX.create( 'SPAN', { 'text': '[' + lesson_id + '] ' + name } ); var oSPAN_space = BX.create( 'SPAN', { 'text': ' ' } ); oDIV.appendChild(oA); oDIV.appendChild(oSPAN_space); oDIV.appendChild(oINPUT); oDIV.appendChild(oSPAN); BX(targetNode).appendChild(oDIV); } </script> <?php $arChilds = array(); $key = 0; $isChapter = $isCourse = false; $resChilds = CLearnLesson::GetListOfImmediateChilds($LESSON_ID); while ($arChild = $resChilds->Fetch()) { $isChapter = true; // this lesson is chapter, because there is descendants $arChilds['RELATION_CHILD_' . $key++] = array('elemName' => 'RELATION_CHILD[]', 'lessonId' => $arChild['LESSON_ID'], 'Name' => '[<a href="' . htmlspecialcharsbx($curDir) . 'learn_unilesson_edit.php?lang=' . LANG . '&LESSON_ID=' . ($arChild['LESSON_ID'] + 0) . '&LESSON_PATH=' . (int) $arChild['LESSON_ID'] . '" target=_blank>' . (int) $arChild['LESSON_ID'] . '</a>] ' . htmlspecialcharsbx($arChild['NAME'])); } // Is course? $isCourse = CLearnLesson::GetLinkedCourse($LESSON_ID) !== false; ?> <div style="padding:10px;"> <div id="LEARNING_LIST_OF_PARENTS" style="padding:10px 0;"> <h3><?php echo GetMessage('LEARNING_LIST_OF_PARENTS') . ':'; ?> </h3> <?php $arParents = array(); $resParents = CLearnLesson::GetListOfImmediateParents($LESSON_ID); while ($arParent = $resParents->Fetch()) { $arParents['RELATION_PARENT_' . $key++] = array('elemName' => 'RELATION_PARENT[]', 'lessonId' => $arParent['LESSON_ID'], 'Name' => '[<a href="' . htmlspecialcharsbx($curDir) . 'learn_unilesson_edit.php?lang=' . LANG . '&LESSON_ID=' . ($arParent['LESSON_ID'] + 0) . '&LESSON_PATH=' . (int) $arParent['LESSON_ID'] . '" target=_blank>' . (int) $arParent['LESSON_ID'] . '</a>] ' . htmlspecialcharsbx($arParent['NAME'])); } foreach ($arParents as $elemId => $arElem) { ?> <div id="<?php echo $elemId; ?> "> <?php if (($oAccess->IsBaseAccess(CLearnAccess::OP_LESSON_UNLINK_FROM_PARENTS) || $oAccess->IsLessonAccessible($LESSON_ID, CLearnAccess::OP_LESSON_UNLINK_FROM_PARENTS)) && ($oAccess->IsBaseAccess(CLearnAccess::OP_LESSON_UNLINK_DESCENDANTS) || $oAccess->IsLessonAccessible($arElem['lessonId'], CLearnAccess::OP_LESSON_UNLINK_DESCENDANTS))) { ?> <span onclick="document.getElementById('<?php echo $elemId; ?> ').parentNode.removeChild(document.getElementById('<?php echo $elemId; ?> '))" class="access-delete" style="position:relative; top:3px; margin-right:1px;" > </span> <?php } ?> <input type="hidden" name="<?php echo $arElem['elemName']; ?> " value="<?php echo (int) $arElem['lessonId']; ?> "> <span style="font-style:italic;"><?php echo $arElem['Name']; ?> </span> </div> <?php } ?> </div> <?php if ($oAccess->IsBaseAccess(CLearnAccess::OP_LESSON_LINK_TO_PARENTS) || $oAccess->IsLessonAccessible($LESSON_ID, CLearnAccess::OP_LESSON_LINK_TO_PARENTS)) { ?> <div style="padding:0px;"> <a href="javascript:void(0);" class="bx-action-href" onclick="window.open('<?php echo addslashes(htmlspecialcharsbx($curDir)); ?> learn_unilesson_admin.php?lang=<?php echo LANGUAGE_ID; ?> &search_retpoint=module_learning_js_admin_function_add_parent&search_mode_type=parents_candidates', 'module_learning_js_admin_window_select_lessons_for_relations', 'scrollbars=yes,resizable=yes,width=960,height=500,top='+Math.floor((screen.height - 560)/2-14)+',left='+Math.floor((screen.width - 960)/2-5));" ><?php echo GetMessage('LEARNING_ADD_ELEMENT'); ?> </a> </div> <?php } ?> <div style="height:25px;"> </div> <div id="LEARNING_LIST_OF_DESCENDANTS" style="padding:10px 0;"> <h3><?php echo GetMessage('LEARNING_LIST_OF_DESCENDANTS') . ':'; ?> </h3> <?php foreach ($arChilds as $elemId => $arElem) { ?> <div id="<?php echo $elemId; ?> "> <?php if (($oAccess->IsBaseAccess(CLearnAccess::OP_LESSON_UNLINK_DESCENDANTS) || $oAccess->IsLessonAccessible($LESSON_ID, CLearnAccess::OP_LESSON_UNLINK_DESCENDANTS)) && ($oAccess->IsBaseAccess(CLearnAccess::OP_LESSON_UNLINK_FROM_PARENTS) || $oAccess->IsLessonAccessible($arElem['lessonId'], CLearnAccess::OP_LESSON_UNLINK_FROM_PARENTS))) { ?> <a href="javascript:void(0);" onclick="document.getElementById('<?php echo $elemId; ?> ').parentNode.removeChild(document.getElementById('<?php echo $elemId; ?> '))" class="access-delete"></a> <?php } ?> <input type="hidden" name="<?php echo $arElem['elemName']; ?> " value="<?php echo (int) $arElem['lessonId']; ?> "> <span style="font-style:italic;"><?php echo $arElem['Name']; ?> </span> </div> <?php } ?> </div> <?php if ($oAccess->IsBaseAccess(CLearnAccess::OP_LESSON_LINK_DESCENDANTS) || $oAccess->IsLessonAccessible($LESSON_ID, CLearnAccess::OP_LESSON_LINK_DESCENDANTS)) { ?> <div style="padding:0px;"> <a href="javascript:void(0);" class="bx-action-href" onclick="window.open('<?php echo addslashes(htmlspecialcharsbx($curDir)); ?> learn_unilesson_admin.php?lang=<?php echo LANGUAGE_ID; ?> &search_retpoint=module_learning_js_admin_function_add_child', 'module_learning_js_admin_window_select_lessons_for_relations', 'scrollbars=yes,resizable=yes,width=960,height=500,top='+Math.floor((screen.height - 560)/2-14)+',left='+Math.floor((screen.width - 960)/2-5));" ><?php echo GetMessage('LEARNING_ADD_ELEMENT'); ?> </a> </div> <?php } ?> <div style="height:25px;"> </div> <hr> <div id="LEARNING_LIST_OF_ALL_PARENT_PATHES" style="padding:10px 0;"> <?php $cntParentPathes = count($arOPathes); $langPhraseBase = 'LEARNING_LIST_OF_ALL_PARENT_PATHES_FOR_'; $lessonType = 'LESSON'; if ($isCourse) { $lessonType = 'COURSE'; } elseif ($isChapter) { $lessonType = 'CHAPTER'; } $isEmpty = ''; if ($cntParentPathes === 0) { $isEmpty = '_IS_EMPTY'; } echo '<h3>' . GetMessage($langPhraseBase . $lessonType . $isEmpty) . '</h3>'; if ($cntParentPathes > 0) { $pattern = '[<a href="' . addslashes(htmlspecialcharsbx($curDir)) . 'learn_unilesson_edit.php?lang=' . LANG . '&LESSON_ID=#LESSON_ID#&LESSON_PATH=#LESSON_ID#" target="_blank">#LESSON_ID#</a>] #NAME#'; foreach ($arOPathes as $oPath) { echo $oPath->GetPathAsHumanReadableString(' / ', $pattern); if ($oPath->Count() >= 1) { if (CLearnLesson::IsPublishProhibited($LESSON_ID, $oPath->GetTop())) { echo ' <span style="color:grey;">(' . GetMessage('LEARNING_LESSON_IS_PUBLISH_PROHIBITED') . ')</span>'; } } echo '<br>'; } } ?> </div> </div> <?php }
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; }