예제 #1
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
if (!CModule::IncludeModule('learning')) {
    return false;
}
//Params
$arParams["COURSE_ID"] = isset($arParams["COURSE_ID"]) && intval($arParams["COURSE_ID"]) > 0 ? intval($arParams["COURSE_ID"]) : intval($_REQUEST["COURSE_ID"]);
$arParams["SELF_TEST_TEMPLATE"] = strlen($arParams["SELF_TEST_TEMPLATE"]) > 0 ? htmlspecialcharsbx($arParams["SELF_TEST_TEMPLATE"]) : "self.php?SELF_TEST_ID=#SELF_TEST_ID#";
$CHAPTER_ID = isset($arParams["CHAPTER_ID"]) && intval($arParams["CHAPTER_ID"]) > 0 ? $arParams["CHAPTER_ID"] : $_REQUEST["CHAPTER_ID"];
if (CLearnPath::IsUrlencodedPath($CHAPTER_ID)) {
    $path = new CLearnPath();
    $path->ImportUrlencoded($CHAPTER_ID);
    $arParams['CHAPTER_ID'] = (int) $path->GetBottom();
} elseif (substr($CHAPTER_ID, 0, 1) === '0') {
    $arParams['CHAPTER_ID'] = (int) substr($CHAPTER_ID, 1);
} else {
    $arParams['CHAPTER_ID'] = (int) CLearnLesson::LessonIdByChapterId($CHAPTER_ID);
}
if (!(isset($arParams['LESSON_PATH']) && strlen($arParams['LESSON_PATH']))) {
    $arParams['LESSON_PATH'] = '';
    if (isset($_REQUEST['LESSON_PATH']) && strlen($_REQUEST['LESSON_PATH'])) {
        $arParams['LESSON_PATH'] = $_REQUEST['LESSON_PATH'];
    }
}
$strUrlencodedLessonPath = '';
if (strlen($arParams['LESSON_PATH']) > 0) {
    $strUrlencodedLessonPath = 'LESSON_PATH=' . $arParams['LESSON_PATH'];
}
예제 #2
0
     foreach (explode("&", $arSearchURL["query"]) as $param) {
         list($name, $value) = explode("=", $param);
         $searchParams .= "<input type=\"hidden\" name=\"" . htmlspecialcharsEx($name) . "\" value=\"" . htmlspecialcharsEx($value) . "\" />";
     }
 }
 $APPLICATION->SetPageProperty("learning_search_params", $searchParams);
 $lessonID = 0;
 if ($arVariables["LESSON_ID"] > 0) {
     $lessonID = intval($arVariables["LESSON_ID"]);
 } else {
     // Lesson is not given, so try get chapter_id
     if (isset($_REQUEST['CHAPTER_ID'])) {
         if (CLearnPath::IsUrlencodedPath($_REQUEST['CHAPTER_ID'])) {
             $LESSON_PATH = new CLearnPath();
             $LESSON_PATH->ImportUrlencoded($_REQUEST['CHAPTER_ID']);
             $lessonID = (int) $LESSON_PATH->GetBottom();
         } elseif (substr($_REQUEST['CHAPTER_ID'], 0, 1) === '0') {
             $lessonID = (int) substr($_REQUEST['CHAPTER_ID'], 1);
         } else {
             $lessonID = (int) CLearnLesson::LessonIdByChapterId($_REQUEST['CHAPTER_ID']);
         }
     }
 }
 $linkedLessonId = false;
 if ($arParams["COURSE_ID"] > 0) {
     $linkedLessonId = CCourse::CourseGetLinkedLesson($arParams["COURSE_ID"]);
 }
 if ($arParams["CHECK_PERMISSIONS"] !== 'N') {
     $isAccessible = false;
     try {
         if ($lessonID > 0) {
예제 #3
0
$arResult = array("ITEMS" => array(), "COURSE" => $arCourse);
//Set Title
$arParams["SET_TITLE"] = $arParams["SET_TITLE"] == "N" ? "N" : "Y";
if ($arParams["SET_TITLE"] == "Y") {
    $APPLICATION->SetTitle($arResult["COURSE"]["NAME"]);
}
$parent =& $this->GetParent();
//Course description item
$url = CComponentEngine::MakePathFromTemplate($arParams["COURSE_DETAIL_TEMPLATE"], array("COURSE_ID" => $arParams["COURSE_ID"]));
$arResult["ITEMS"][] = array("NAME" => GetMessage("LEARNING_COURSE_DESCRIPTION"), "URL" => $url, "TYPE" => "CD", "SELECTED" => $parent->arResult["VARIABLES"]["INDEX"] == "Y", "DEPTH_LEVEL" => 1);
$CHAPTER_ID = $parent->arResult["VARIABLES"]["CHAPTER_ID"];
if ($CHAPTER_ID > 0) {
    if (CLearnPath::IsUrlencodedPath($CHAPTER_ID)) {
        $oTmp = new CLearnPath();
        $oTmp->ImportUrlencoded($CHAPTER_ID);
        $CHAPTER_ID = (int) $oTmp->GetBottom();
    } elseif (substr($CHAPTER_ID, 0, 1) === '0') {
        $CHAPTER_ID = (int) substr($CHAPTER_ID, 1);
    } else {
        $CHAPTER_ID = (int) CLearnLesson::LessonIdByChapterId($CHAPTER_ID);
    }
} else {
    $CHAPTER_ID = false;
}
$lessonCount = 0;
$lessonCurrent = 0;
// Get Course Content
$arContents = CLearnCacheOfLessonTreeComponent::GetData($arParams['COURSE_ID']);
foreach ($arContents as $arContent) {
    if ($arContent["TYPE"] == "CH") {
        $itemURL = CComponentEngine::MakePathFromTemplate($arParams["CHAPTER_DETAIL_TEMPLATE"], array("CHAPTER_ID" => '0' . $arContent["ID"], "COURSE_ID" => $arParams["COURSE_ID"]));
예제 #4
0
    require $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/epilog_admin.php';
    // system's epilog
    exit;
}
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/learning/prolog.php";
IncludeModuleLangFile(__FILE__);
ClearVars();
$lessonPath = '';
if (isset($_POST['LESSON_PATH'])) {
    $lessonPath = $_POST['LESSON_PATH'];
} elseif (isset($_GET['LESSON_PATH'])) {
    $lessonPath = $_GET['LESSON_PATH'];
}
$oPath = new CLearnPath();
$oPath->ImportUrlencoded($lessonPath);
$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));
예제 #5
0
        //				unset ($_GET['LESSON_PATH']);
        //
        //			unset ($g_learn_parentLessonId, $g_learn_parentLessonPath, $g_learn_currentLessonPath);
        //		}
    }
    unset($oPath, $oParentPath, $arPath);
}
// This argument transmitted when pended new lesson creation
if (isset($_GET['PROPOSE_RETURN_LESSON_PATH'])) {
    if (isset($g_learn_parentLessonPath)) {
        throw new LearnException('EA_LOGIC: PROPOSE_RETURN_LESSON_PATH and ' . 'LESSON_PATH are mutually exclusive arguments.', LearnException::EXC_ERR_ALL_LOGIC);
    }
    $g_learn_parentLessonPath = $_GET['PROPOSE_RETURN_LESSON_PATH'];
    $oPath = new CLearnPath();
    $oPath->ImportUrlencoded($g_learn_parentLessonPath);
    $g_learn_parentLessonId = $oPath->GetBottom();
    if ($g_learn_parentLessonId === false) {
        throw new LearnException('EA_LOGIC: PROPOSE_RETURN_LESSON_PATH given, ' . 'but there is no parent lesson in path', LearnException::EXC_ERR_ALL_LOGIC);
    }
}
// Place to $topCourseLessonId lesson id of top course, if top lesson is course.
$topCourseLessonId = false;
if (isset($g_learn_parentLessonPath) && strlen($g_learn_parentLessonPath)) {
    try {
        $oPath = new CLearnPath();
        $oPath->ImportUrlencoded($g_learn_parentLessonPath);
        $topLessonId = $oPath->GetTop();
        // Is lesson the course?
        if (CLearnLesson::GetLinkedCourse($topLessonId) !== false) {
            $topCourseLessonId = $topLessonId;
        }
예제 #6
0
 public function ProcessActionsOnList()
 {
     if (isset($_POST['action']) && strlen($_POST['action']) !== 0) {
         $action = $_POST['action'];
     } elseif (isset($_GET['action']) && strlen($_GET['action']) !== 0) {
         $action = $_GET['action'];
     } elseif (isset($_POST['action_button']) && strlen($_POST['action_button']) !== 0) {
         $action = $_POST['action_button'];
     } elseif (isset($_GET['action_button']) && strlen($_GET['action_button']) !== 0) {
         $action = $_GET['action_button'];
     } else {
         return $this;
     }
     // nothing to do
     $arID = $this->oList->GroupAction();
     if ($arID === false) {
         return $this;
     }
     // no items selected
     if (check_bitrix_sessid() !== true) {
         throw new CLearnRenderAdminUnilessonListException('', CLearnRenderAdminUnilessonListException::C_ACCESS_DENIED);
     }
     if ($_POST['action_target'] === 'selected') {
         $arID = array();
         $rsData = $this->fetchDataFromDb();
         while ($arRes = $rsData->Fetch()) {
             $arID[] = $arRes['LESSON_ID'];
         }
     }
     foreach ($arID as $lessonId) {
         // If not int or string can't be strictly casted to int
         if (!(is_numeric($lessonId) && is_int($lessonId + 0))) {
             continue;
         }
         $lessonId += 0;
         $wasError = false;
         $preventSelectionOnError = false;
         try {
             switch ($action) {
                 case 'unlink':
                     // !!! In case of unlinking in $lessonId not Lesson's id, but it's full path
                     $oPath = new CLearnPath();
                     $oPath->ImportUrlencoded($lessonId);
                     $arPath = $oPath->GetPathAsArray();
                     if (count($arPath) < 2) {
                         throw new CLearnRenderAdminUnilessonListException('', CLearnRenderAdminUnilessonListException::C_LOGIC);
                     }
                     $childLessonId = $oPath->GetBottom();
                     $parentLessonId = $oPath->GetBottom();
                     if ($parentLessonId === false || $childLessonId === false) {
                         // something goes wrong
                         throw new CLearnRenderAdminUnilessonListException('', CLearnRenderAdminUnilessonListException::C_LOGIC);
                     }
                     $this->EnsureLessonUnlinkAccess($parentLessonId, $childLessonId);
                     // throws an exception on error
                     CLearnLesson::RelationRemove($parentLessonId, $childLessonId);
                     break;
                 case 'disband':
                     @set_time_limit(0);
                     $courseId = CLearnLesson::GetLinkedCourse($lessonId);
                     if ($courseId !== false && CCourse::IsCertificatesExists($courseId)) {
                         throw new Exception(GetMessage(LEARNING_COURSE_UNREMOVABLE_CAUSE_OF_CERTIFICATES));
                     }
                     $this->EnsureLessonDisbandAccess($lessonId);
                     CLearnLesson::Delete($lessonId);
                     break;
                 case 'delete':
                 case 'recursive_delete':
                     $preventSelectionOnError = true;
                     // prevent switch table to "selection mode" when cannot delete item in list
                     @set_time_limit(0);
                     $courseId = CLearnLesson::GetLinkedCourse($lessonId);
                     if ($courseId !== false && CCourse::IsCertificatesExists($courseId)) {
                         throw new Exception(GetMessage(LEARNING_COURSE_UNREMOVABLE_CAUSE_OF_CERTIFICATES));
                     }
                     try {
                         // firstly, simulate to check permissions
                         CLearnLesson::DeleteRecursiveLikeHardlinks(array('lesson_id' => $lessonId, 'simulate' => true));
                         // If all is OK, try to really remove it
                         CLearnLesson::DeleteRecursiveLikeHardlinks($lessonId);
                     } catch (LearnException $e) {
                         if ($e->GetCode() === LearnException::EXC_ERR_ALL_ACCESS_DENIED) {
                             throw new CLearnRenderAdminUnilessonListException('', CLearnRenderAdminUnilessonListException::C_ACCESS_DENIED);
                         } else {
                             // bubble exception
                             throw new LearnException($e->GetMessage(), $e->GetCode());
                         }
                     }
                     break;
                 case 'activate':
                 case 'deactivate':
                     if (strtolower($action) === 'deactivate') {
                         $this->EnsureLessonDeactivateAccess($lessonId);
                         $arFields = array('ACTIVE' => 'N');
                     } elseif (strtolower($action) === 'activate') {
                         $this->EnsureLessonActivateAccess($lessonId);
                         $arFields = array('ACTIVE' => 'Y');
                     } else {
                         throw new CLearnRenderAdminUnilessonListException('WTFAYD,#Pro#?!', CLearnRenderAdminUnilessonListException::C_ACCESS_DENIED);
                     }
                     // Is item course or not?
                     $courseId = CLearnLesson::GetLinkedCourse($lessonId);
                     if ($courseId === false) {
                         // not course
                         CLearnLesson::Update($lessonId, $arFields);
                     } else {
                         $oCourse = new CCourse();
                         $rc = $oCourse->Update($courseId, $arFields);
                         unset($oCourse);
                         if ($rc === false) {
                             throw new Exception();
                         }
                     }
                     break;
                 default:
                     throw new Exception();
                     break;
             }
         } 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 ($e->getCode() & CLearnRenderAdminUnilessonListException::C_ACCESS_DENIED) {
                 // Access denied
                 $errmsg = GetMessage('LEARNING_SAVE_ERROR') . '#' . $lessonId . ': ' . 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 . ')';
                 }
             }
             if ($preventSelectionOnError) {
                 $this->oList->AddUpdateError($errmsg);
             } else {
                 $this->oList->AddUpdateError($errmsg, $lessonId);
             }
         }
     }
     return $this;
 }