Ejemplo n.º 1
0
 public static function OnGetRatingContentOwner($arParams)
 {
     if ($arParams['ENTITY_TYPE_ID'] == 'LEARN_LESSON') {
         $arFilter = array('LESSON_ID' => intval($arParams['ENTITY_ID']));
         $Item = CLearnLesson::GetList($arOrder = array(), $arFilter);
         if ($arItem = $Item->Fetch()) {
             return $arItem['CREATED_BY'];
         } else {
             return 0;
         }
     }
     return false;
 }
Ejemplo n.º 2
0
 /**
  * simple & stupid stub
  * @deprecated
  */
 public static function GetList($arOrder = 'will be ignored', $arFilter = array())
 {
     // We must replace '...ID' => '...LESSON_ID',
     // where '...' is some operation (such as '!', '<=', etc.)
     foreach ($arFilter as $key => $value) {
         // If key ends with 'ID'
         if (strlen($key) >= 2 && strtoupper(substr($key, -2)) === 'ID') {
             // And prefix before 'ID' doesn't contains letters
             if (!preg_match("/[a-zA-Z_]+/", substr($key, 0, -2))) {
                 $prefix = '';
                 if (strlen($key) > 2) {
                     $prefix = substr($key, 0, -2);
                 }
                 $arFields[$prefix . 'LESSON_ID'] = $arFilter[$key];
                 unset($arFilter[$key]);
             }
         }
     }
     return CLearnLesson::GetList(array(), $arFilter);
 }
Ejemplo n.º 3
0
     $this->AbortResultCache();
     ShowError(GetMessage("LEARNING_COURSE_DENIED"));
     return;
 }
 // Resolve links "?COURSE_ID={SELF}". Don't relay on it, this behaviour
 // can be changed in future without any notifications.
 if (isset($arCourse['DETAIL_TEXT'])) {
     $arCourse['DETAIL_TEXT'] = CLearnHelper::PatchLessonContentLinks($arCourse['DETAIL_TEXT'], $arCourse['ID']);
 }
 if (isset($arCourse['PREVIEW_TEXT'])) {
     $arCourse['PREVIEW_TEXT'] = CLearnHelper::PatchLessonContentLinks($arCourse['PREVIEW_TEXT'], $arCourse['ID']);
 }
 $rsChapter = false;
 //Chapter
 if (isset($arParams["CHAPTER_ID"])) {
     $rsChapter = CLearnLesson::GetList(array(), array("LESSON_ID" => $arParams["CHAPTER_ID"], "ACTIVE" => "Y", "CHECK_PERMISSIONS" => 'N'));
 }
 if ($rsChapter === false || !($arChapter = $rsChapter->GetNext())) {
     $this->AbortResultCache();
     ShowError(GetMessage("LEARNING_CHAPTER_DENIED"));
     return;
 }
 //Images
 $arChapter["PREVIEW_PICTURE_ARRAY"] = CFile::GetFileArray($arChapter["PREVIEW_PICTURE"]);
 $arChapter["DETAIL_PICTURE_ARRAY"] = CFile::GetFileArray($arChapter["DETAIL_PICTURE"]);
 // Resolve links "?COURSE_ID={SELF}". Don't relay on it, this behaviour
 // can be changed in future without any notifications.
 if (isset($arChapter['DETAIL_TEXT'])) {
     $arChapter['DETAIL_TEXT'] = CLearnHelper::PatchLessonContentLinks($arChapter['DETAIL_TEXT'], $arParams['COURSE_ID']);
 }
 if (isset($arChapter['PREVIEW_TEXT'])) {
Ejemplo n.º 4
0
$LESSON_ID = $oPath->GetBottom();
if ($LESSON_ID === false) {
    CAdminMessage::ShowMessage(GetMessage('LEARNING_BAD_LESSON'));
    require $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/epilog_admin.php';
    exit;
}
$uriLessonPath = $oPath->ExportUrlencoded();
unset($lessonPath);
if (isset($from) && strlen($from) > 0) {
    $str_from = "&from=" . htmlspecialcharsbx($from);
} else {
    $str_from = "";
}
$oAccess = CLearnAccess::GetInstance($USER->GetID());
$bAccessLessonModify = $oAccess->IsLessonAccessible($LESSON_ID, CLearnAccess::OP_LESSON_WRITE);
$lesson = CLearnLesson::GetList(array(), array('LESSON_ID' => $LESSON_ID));
$arLesson = $lesson->Fetch();
$oTree = CLearnLesson::GetTree($LESSON_ID, array('EDGE_SORT' => 'asc'), array(), false);
$arSubLessons = $oTree->GetTreeAsList();
$arSubLessonsIDs = array();
foreach ($arSubLessons as $arSubLesson) {
    $arSubLessonsIDs[] = (int) $arSubLesson['LESSON_ID'];
}
$arSubLessonsIDs[] = (int) $LESSON_ID;
if (!$bAccessLessonModify) {
    $APPLICATION->SetTitle(GetMessage('LEARNING_QUESTION'));
    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 . GetFilterParams("filter_") . '&LESSON_PATH=' . $uriLessonPath, "TITLE" => GetMessage("LEARNING_BACK_TO_ADMIN")));
    $context = new CAdminContextMenu($aContext);
    $context->Show();
    CAdminMessage::ShowMessage(GetMessage("LEARNING_BAD_LESSON"));
Ejemplo n.º 5
0
 $rsCourse = CCourse::GetList(array(), array("ID" => $arParams["COURSE_ID"], "ACTIVE" => "Y", "CHECK_PERMISSIONS" => 'N'));
 if (!($arCourse = $rsCourse->GetNext())) {
     $this->AbortResultCache();
     ShowError(GetMessage("LEARNING_COURSE_DENIED"));
     return;
 }
 // Resolve links "?COURSE_ID={SELF}". Don't relay on it, this behaviour
 // can be changed in future without any notifications.
 if (isset($arCourse['DETAIL_TEXT'])) {
     $arCourse['DETAIL_TEXT'] = CLearnHelper::PatchLessonContentLinks($arCourse['DETAIL_TEXT'], $arParams['COURSE_ID']);
 }
 if (isset($arCourse['PREVIEW_TEXT'])) {
     $arCourse['PREVIEW_TEXT'] = CLearnHelper::PatchLessonContentLinks($arCourse['PREVIEW_TEXT'], $arParams['COURSE_ID']);
 }
 // Lesson
 $rsLesson = CLearnLesson::GetList(array(), array('LESSON_ID' => $arParams['LESSON_ID'], 'ACTIVE' => 'Y', 'CHECK_PERMISSIONS' => 'N'));
 if (!($arLesson = $rsLesson->GetNext())) {
     $this->AbortResultCache();
     ShowError(GetMessage("LEARNING_LESSON_DENIED"));
     return;
 }
 // Images
 $arLesson["PREVIEW_PICTURE_ARRAY"] = CFile::GetFileArray($arLesson["PREVIEW_PICTURE"]);
 $arLesson["DETAIL_PICTURE_ARRAY"] = CFile::GetFileArray($arLesson["DETAIL_PICTURE"]);
 // Resolve links "?COURSE_ID={SELF}". Don't relay on it, this behaviour
 // can be changed in future without any notifications.
 if (isset($arLesson['DETAIL_TEXT'])) {
     $arLesson['DETAIL_TEXT'] = CLearnHelper::PatchLessonContentLinks($arLesson['DETAIL_TEXT'], $arParams['COURSE_ID']);
 }
 if (isset($arLesson['PREVIEW_TEXT'])) {
     $arLesson['PREVIEW_TEXT'] = CLearnHelper::PatchLessonContentLinks($arLesson['PREVIEW_TEXT'], $arParams['COURSE_ID']);
Ejemplo n.º 6
0
 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;
 }
Ejemplo n.º 7
0
 private function fetchDataFromDb()
 {
     if ($this->IsSearchMode()) {
         $searchMode = $this->getSearchMode();
         if ($searchMode === 'parents_candidates') {
             //exit('1');
             $accessOperations = CLearnAccess::OP_LESSON_READ | CLearnAccess::OP_LESSON_LINK_DESCENDANTS;
         } elseif ($searchMode === 'childs_candidates') {
             //exit('2');
             $accessOperations = CLearnAccess::OP_LESSON_READ | CLearnAccess::OP_LESSON_LINK_TO_PARENTS;
         } elseif ($searchMode === 'attach_question_to_lesson') {
             $accessOperations = CLearnAccess::OP_LESSON_WRITE;
         } else {
             $accessOperations = CLearnAccess::OP_LESSON_READ;
         }
     } else {
         $accessOperations = CLearnAccess::OP_LESSON_READ;
     }
     $this->arFilter['ACCESS_OPERATIONS'] = $accessOperations;
     // fetch data
     if ($this->IsListChildLessonsMode()) {
         // shows only childs of requested lesson uid
         $CDBResult = CLearnLesson::GetListOfImmediateChilds($this->requestedParentLessonId, $this->arSortOrder, $this->arFilter);
     } elseif ($this->IsListAnyLessonsMode()) {
         $CDBResult = CLearnLesson::GetList($this->arSortOrder, $this->arFilter);
     } elseif ($this->IsListAnyCoursesMode()) {
         $CDBResult = CCourse::GetList($this->arSortOrder, $this->arFilter);
     }
     return $CDBResult;
 }
Ejemplo n.º 8
0
 $rsQuestion = CLQuestion::GetByID($arTestResult["QUESTION_ID"]);
 if ($arQuestion = $rsQuestion->GetNext()) {
     // Resolve links "?COURSE_ID={SELF}". Don't relay on it, this behaviour
     // can be changed in future without any notifications.
     if (isset($arQuestion['DESCRIPTION'])) {
         $arQuestion['DESCRIPTION'] = CLearnHelper::PatchLessonContentLinks($arQuestion['DESCRIPTION'], $arParams['COURSE_ID']);
     }
     if ($arQuestion["QUESTION_TYPE"] != "T") {
         if ($arTest["SHOW_ERRORS"] == "Y" && $result["CORRECT"] == "N" && $result["ANSWERED"] == "Y" && $arQuestion["INCORRECT_MESSAGE"]) {
             $sessIncorrectMessage = $arQuestion;
             if ($arTest["NEXT_QUESTION_ON_ERROR"] == "N" && $arTest["PASSAGE_TYPE"] == 2) {
                 $arResult["REDIRECT_PAGE"] = str_replace("#PAGE_ID#", array_key_exists($arParams["PAGE_NUMBER_VARIABLE"], $_REQUEST) ? $arResult["NAV"]["PAGE_NUMBER"] - 1 : 1, $arResult["PAGE_TEMPLATE"]);
             }
         }
     } elseif ($arQuestion["EMAIL_ANSWER"] == "Y") {
         $rsLesson = CLearnLesson::GetList(array(), array("LESSON_ID" => $arQuestion['LESSON_ID'], "CHECK_PERMISSIONS" => "N"));
         if ($arLesson = $rsLesson->GetNext()) {
             $rsTeacher = CUser::GetByID($arLesson["CREATED_BY"]);
             if ($arTeacher = $rsTeacher->GetNext()) {
                 $courseName = "";
                 $rsCourse = CCourse::GetByID($arTest["COURSE_ID"]);
                 if ($arCourse = $rsCourse->GetNext()) {
                     $courseName = $arCourse["NAME"];
                 }
                 $arEventFields = array("ID" => $testResultID, "ATTEMPT_ID" => $sessAttemptID, "TEST_NAME" => $arTest["NAME"], "COURSE_NAME" => $courseName, "USER" => "(" . $USER->GetLogin() . ")" . (strlen($USER->GetFullName()) > 0 ? " " . $USER->GetFullName() : ""), "DATE" => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), time()), "QUESTION_TEXT" => $arQuestion["NAME"], "ANSWER_TEXT" => $_REQUEST["answer"], "EMAIL_FROM" => COption::GetOptionString("main", "email_from", "*****@*****.**"), "EMAIL_TO" => $arTeacher["EMAIL"], "MESSAGE_TITLE" => GetMessage("LEARNING_NEW_TEXT_ANSWER"));
                 $arrSITE = LANG;
                 CEvent::Send("NEW_LEARNING_TEXT_ANSWER", $arrSITE, $arEventFields, "N");
             }
         }
     }
 }
 public function FetchData()
 {
     if ($this->IsSearchMode()) {
         $searchMode = $this->getSearchMode();
         if ($searchMode === 'parents_candidates') {
             //exit('1');
             $accessOperations = CLearnAccess::OP_LESSON_READ | CLearnAccess::OP_LESSON_LINK_DESCENDANTS;
         } elseif ($searchMode === 'childs_candidates') {
             //exit('2');
             $accessOperations = CLearnAccess::OP_LESSON_READ | CLearnAccess::OP_LESSON_LINK_TO_PARENTS;
         } elseif ($searchMode === 'attach_question_to_lesson') {
             $accessOperations = CLearnAccess::OP_LESSON_WRITE;
         } else {
             $accessOperations = CLearnAccess::OP_LESSON_READ;
         }
     } else {
         $accessOperations = CLearnAccess::OP_LESSON_READ;
     }
     $this->arFilter['ACCESS_OPERATIONS'] = $accessOperations;
     // fetch data
     if ($this->IsListChildLessonsMode()) {
         // shows only childs of requested lesson uid
         $CDBResult = CLearnLesson::GetListOfImmediateChilds($this->requestedParentLessonId, $this->arSortOrder, $this->arFilter);
     } elseif ($this->IsListAnyLessonsMode()) {
         $CDBResult = CLearnLesson::GetList($this->arSortOrder, $this->arFilter);
     } elseif ($this->IsListAnyCoursesMode()) {
         $CDBResult = CCourse::GetList($this->arSortOrder, $this->arFilter);
     }
     $this->rsData = new CAdminResult($CDBResult, $this->tableID);
     // navigation setup
     $this->rsData->NavStart();
     $this->oList->NavText($this->rsData->GetNavPrint(''));
     return $this;
 }