if (isset($g_learn_parentLessonId)) { $arEdgeProperties = array('SORT' => $_POST['EDGE_SORT']); } $arFields = array("ACTIVE" => $ACTIVE !== 'Y' ? 'N' : 'Y', "NAME" => $NAME, "KEYWORDS" => $KEYWORDS, "CODE" => $CODE, "DETAIL_PICTURE" => $arDETAIL_PICTURE, "DETAIL_TEXT" => $DETAIL_TEXT, "DETAIL_TEXT_TYPE" => $DETAIL_TEXT_TYPE, "PREVIEW_PICTURE" => $arPREVIEW_PICTURE, "PREVIEW_TEXT" => $PREVIEW_TEXT, "PREVIEW_TEXT_TYPE" => $PREVIEW_TEXT_TYPE); if ($CONTENT_SOURCE == "file") { $arFields["DETAIL_TEXT_TYPE"] = "file"; $arFields["LAUNCH"] = $LAUNCH; } $USER_FIELD_MANAGER->EditFormAddFields('LEARNING_LESSONS', $arFields); $res = true; try { if ($LESSON_ID > 0) { CLearnLesson::Update($LESSON_ID, $arFields); // If we are in context of parent lesson => update edges properties if (isset($g_learn_parentLessonId) && $g_learn_parentLessonId > 0) { CLearnLesson::RelationUpdate($g_learn_parentLessonId, $LESSON_ID, $arEdgeProperties); } } else { // If we are in context of parent lesson => create linked lesson if (isset($g_learn_parentLessonId) && $g_learn_parentLessonId > 0) { $arNewEdgeProperties = array('SORT' => 500); if (isset($arEdgeProperties['SORT'])) { $arNewEdgeProperties['SORT'] = $arEdgeProperties['SORT']; } $LESSON_ID = CLearnLesson::Add($arFields, false, $g_learn_parentLessonId, $arNewEdgeProperties); } else { $LESSON_ID = CLearnLesson::Add($arFields); } $res = $LESSON_ID > 0; } // PUBLISH_PROHIBITED available in context of most parent course only
public function SaveInlineEditedItems() { if (!$this->IsNeedSaveInlineEditedItems()) { return $this; } if (check_bitrix_sessid() !== true) { throw new CLearnRenderAdminUnilessonListException('', CLearnRenderAdminUnilessonListException::C_ACCESS_DENIED); } foreach ($_POST['FIELDS'] as $lessonId => $arFields) { $arEdgeProperties = array(); $wasError = false; try { // skip not changed items if (!$this->oList->IsUpdated($lessonId)) { continue; } // throws exception if access denied $this->EnsureLessonUpdateAccess($lessonId); $courseId = CLearnLesson::GetLinkedCourse($lessonId); // Depends on current list mode, we must update sort index // of element (only for course) or sort index of relation between // child and parent lessons. // So, we must rename SORT to COURSE_SORT or EDGE_SORT if (array_key_exists('SORT', $arFields)) { if ($this->IsListAnyCoursesMode() && $courseId !== false) { $arFields['COURSE_SORT'] = $arFields['SORT']; } elseif ($this->IsListChildLessonsMode()) { $arFields['EDGE_SORT'] = $arFields['SORT']; } else { throw new CLearnRenderAdminUnilessonListException('', CLearnRenderAdminUnilessonListException::C_LOGIC | CLearnRenderAdminUnilessonListException::C_ACTION_UPDATE_FAIL); } unset($arFields['SORT']); } if (isset($arFields['EDGE_SORT'])) { if (isset($_GET['PARENT_LESSON_ID'])) { $arEdgeProperties['SORT'] = $arFields['EDGE_SORT']; } unset($arFields['EDGE_SORT']); } // PUBLISH_PROHIBITED if (array_key_exists('PUBLISH_PROHIBITED', $arFields)) { // PUBLISH_PROHIBITED available in context of most parent course only if ($this->contextCourseLessonId !== false && in_array($arFields['PUBLISH_PROHIBITED'], array('N', 'Y'), true)) { $isProhibited = true; if ($arFields['PUBLISH_PROHIBITED'] === 'N') { $isProhibited = false; } CLearnLesson::PublishProhibitionSetTo($lessonId, $this->contextCourseLessonId, $isProhibited); } unset($arFields['PUBLISH_PROHIBITED']); } // Courses must be updated throws CCourse::Update(); if ($courseId === false) { CLearnLesson::Update($lessonId, $arFields); } else { $ob = new CCourse(); if (!$ob->Update($courseId, $arFields)) { throw new CLearnRenderAdminUnilessonListException('', CLearnRenderAdminUnilessonListException::C_ACTION_UPDATE_FAIL); } unset($ob); } if (isset($_GET['PARENT_LESSON_ID']) && count($arEdgeProperties) > 0) { CLearnLesson::RelationUpdate($_GET['PARENT_LESSON_ID'], $lessonId, $arEdgeProperties); } } catch (CLearnRenderAdminUnilessonListException $e) { $wasError = true; $errorText = $e->getMessage(); $errorCode = $e->getCode(); } catch (Exception $e) { $wasError = true; $errorText = $e->getMessage(); $errorCode = 0; // Because we checks below only CLearnRenderAdminUnilessonListException codes } if ($wasError) { if ($errorCode & CLearnRenderAdminUnilessonListException::C_ACCESS_DENIED) { // Access denied $errmsg = GetMessage('LEARNING_SAVE_ERROR') . ': ' . GetMessage('LEARNING_ACCESS_D'); if (strlen($errorText) > 0) { $errmsg .= ': ' . $errorText; } } else { // Some error occured during update operation $errmsg = GetMessage('LEARNING_SAVE_ERROR') . $lessonId; if (strlen($errorText) > 0) { $errmsg .= ' (' . $errorText . ')'; } } $this->oList->AddUpdateError($errmsg, $lessonId); } } return $this; }