if (!$ma->currentCanAccessObj('tb_elearning')) { Util::jump_to('index.php?r=lms/classroom/show'); } Util::jump_to('index.php?r=' . _after_login_); } // end login } } else { Util::jump_to('../index.php'); } } break; case "logout": require_once $GLOBALS['where_lms'] . '/lib/lib.track_user.php'; if (!Docebo::user()->isAnonymous() && isset($_SESSION['idCourse'])) { TrackUser::setActionTrack(getLogUserId(), $_SESSION['idCourse'], '', ''); } //i need to save the language of the user in order to use it again after logout $language = Lang::get(); if (!Docebo::user()->isAnonymous()) { TrackUser::logoutSessionCourseTrack(); $_SESSION = array(); session_destroy(); // load standard language module and put it global $glang =& DoceboLanguage::createInstance('standard', 'framework'); // Recreate Anonymous user $GLOBALS['current_user'] =& DoceboUser::createDoceboUserFromSession('public_area'); $GLOBALS['logout'] = true; require_once _base_ . '/lib/lib.platform.php'; $pm =& PlatformManager::createInstance(); $pm->doCommonOperations("logout");
function logoutSessionCourseTrack() { if (isset($_SESSION['idCourse'])) { TrackUser::setActionTrack(getLogUserId(), $_SESSION['idCourse'], '_LOGOUT', 'view'); } }
function organization_display(&$treeView) { // print conainer div and form require_once $GLOBALS['where_lms'] . '/lib/lib.track_user.php'; TrackUser::setActionTrack(getLogUserId(), $_SESSION['idCourse'], 'organization', 'view'); global $modname, $op; $GLOBALS['page']->setWorkingZone('content'); $GLOBALS['page']->add('<div class="std_block">'); $GLOBALS['page']->add('<form id="orgshow" method="post"' . ' action="index.php?modname=' . $modname . '&op=' . $op . '"' . ' >' . "\n" . '<input type="hidden" id="authentic_request_org" name="authentic_request" value="' . Util::getSignature() . '" />'); if (funAccess('moditem', 'MOD', TRUE, 'organization')) { $treeView->withActions = TRUE; } else { $tdb = $treeView->getTreeDb(); } $GLOBALS['page']->add($treeView->load()); if (funAccess('moditem', 'MOD', TRUE, 'organization')) { $GLOBALS['page']->add($treeView->loadActions()); } $GLOBALS['page']->add('</form>'); // print form for import action $GLOBALS['page']->add('</div>'); YuiLib::load(array(), array()); /* addCss('shadowbox'); Util::get_js(Get::rel_path('base').'/addons/shadowbox/shadowbox-yui.js', true, true); Util::get_js(Get::rel_path('base').'/addons/shadowbox/shadowbox.js', true, true); $GLOBALS['page']->add( '' .'<script type="text/javascript"> YAHOO.util.Event.onDOMReady(function() { var options = { listenOverlay:false, overlayOpacity:"0.8", loadingImage:"'.getPathImage('lms').'standard/loading.gif", overlayBgImage:"'.getPathImage('lms').'standard/overlay-85.png", text: {close: "'. Lang::t('_CLOSE').'", cancel: "'. Lang::t('_UNDO').'", loading:"'. Lang::t('_LOADING').'" }, onOpen: function (gallery) { window.onbeforeunload = function() { return "'. Lang::t('_CONFIRM').'"; } } }; Shadowbox.init(options); Shadowbox.close = function() { window.onbeforeunload = null; window.frames[\'shadowbox_content\'].uiPlayer.closePlayer(true, window); } }); </script>' ); */ $GLOBALS['page']->add('<script type="text/javascript">' . "var lb = new LightBox();\r\n var Config = {};\r\n Config.langs = {_CLOSE: '" . Lang::t('_CLOSE', 'standard') . "'};\r\n lb.init(Config);" . '</script>'); }
function logIntoCourse($id_course, $gotofirst_page = true) { // Reset previous opened track session if any if (!Docebo::user()->isAnonymous() && isset($_SESSION['idCourse'])) { require_once _lms_ . '/lib/lib.track_user.php'; TrackUser::setActionTrack(getLogUserId(), $_SESSION['idCourse'], '', ''); } // Unset possibile previous session setting if (isset($_SESSION['direct_play'])) { unset($_SESSION['direct_play']); } $re_course = sql_query("\r\n\tSELECT level, status, waiting\r\n\tFROM %lms_courseuser\r\n\tWHERE idCourse = " . (int) $id_course . " AND idUser = "******""); list($level_c, $status_user, $waiting_user) = sql_fetch_row($re_course); Docebo::setCourse($id_course); $course_info = Docebo::course()->getAllInfo(); $course_info['course_status'] = $course_info['status']; $course_info['user_status'] = $status_user; $course_info['waiting'] = $waiting_user; $course_info['level'] = $level_c; // Can the user enter into the course ? if (!Man_Course::canEnterCourse($course_info)) { return false; } // Disable tracking for ghost level $_SESSION['is_ghost'] = $course_info['level'] == 2 ? true : false; // If it's the first time we need to change the course status if ($course_info['user_status'] == _CUS_SUBSCRIBED) { require_once _lms_ . '/lib/lib.stats.php'; saveTrackStatusChange(getLogUserId(), $id_course, _CUS_BEGIN); } // Setup some session data $_SESSION['timeEnter'] = date("Y-m-d H:i:s"); $_SESSION['idCourse'] = $id_course; $_SESSION['levelCourse'] = $course_info['level']; //we need to redo this //$_SESSION['idEdition'] = $id_e; Docebo::user()->loadUserSectionST('/lms/course/private/' . $course_info['level'] . '/'); Docebo::user()->SaveInSession(); // Initialize the session into the course TrackUser::createSessionCourseTrack(); $first_page = firstPage(); $_SESSION['current_main_menu'] = $first_page['idMain']; $_SESSION['sel_module_id'] = $first_page['idModule']; $jumpurl = 'index.php?modname=' . $first_page['modulename'] . '&op=' . $first_page['op'] . '&id_module_sel=' . $first_page['idModule']; // course in direct play or assessment if ($course_info['direct_play'] == 1 || $course_info['course_type'] == 'assessment') { if ($_SESSION['levelCourse'] >= 4) { // direct play with a teacher, basically it's not ok // check if we are managing the LOs from admin: if yes, jump into the test management if ($course_info['course_type'] == 'assessment' && Get::req('from_admin', DOTY_INT, 0) > 0) { // enter the assessment course and go to test editing if there is a test with no question in it $query = "SELECT idOrg, idResource " . " FROM %lms_organization " . " WHERE idCourse = " . (int) $_SESSION['idCourse'] . " AND objectType = 'test' " . " ORDER BY path ASC, title ASC " . " LIMIT 0,1"; $res = sql_query($query); if ($res && sql_num_rows($res) > 0) { list($id_org, $id_test) = sql_fetch_row($res); if ($id_test > 0) { require_once _lms_ . '/lib/lib.test.php'; $tman = new TestManagement($id_test); if ($tman->getNumberOfQuestion() <= 0) { Util::jump_to('index.php?modname=test&op=modtestgui&idTest=' . $id_test . '&back_url=' . urlencode($jumpurl)); } } } } } else { // direct play with a student // i need to play directly the course if it's not completed and is the only object of the course require_once _lms_ . '/lib/lib.orgchart.php'; $orgman = new OrganizationManagement($_SESSION['idCourse']); $first_lo =& $orgman->getInfoWhereType(false, $_SESSION['idCourse']); if (count($first_lo) == 1) { $_SESSION['direct_play'] = 1; $obj = array_shift($first_lo); Util::jump_to('index.php?modname=organization&op=custom_playitem&id_item=' . $obj['id_org'] . ''); } elseif (count($first_lo) >= 2) { $obj = array_shift($first_lo); // if we have more than an object we need to play the first one until it's completed $query = "SELECT status FROM %lms_commontrack WHERE idReference = " . (int) $obj['id_org'] . " AND idUser = "******"assessment") { //check if we are managing the LOs from admin: if yes, jump into the test management if (Get::req('from_admin', DOTY_INT, 0) > 0) { //enter the assessment course and go to test editing $query = "SELECT idOrg, idResource FROM %lms_organization WHERE idCourse=".(int)$_SESSION['idCourse']." AND objectType='test' " ." ORDER BY path ASC, title ASC LIMIT 0,1"; $res = sql_query($query); if ($res && sql_num_rows($res)>0) { list($id_org, $id_test) = sql_fetch_row($res); if ($id_test > 0) { require_once(_lms_.'/lib/lib.test.php'); $tman = new TestManagement($id_test); if ($tman->getNumberOfQuestion() <= 0) { Util::jump_to('index.php?modname=test&op=modtestgui&idTest='.$id_test.'&back_url='.urlencode($jumpurl)); } } } } } if($gotofirst_page) Util::jump_to($jumpurl); else return true; } switch($course_info['course_type']) { case "assessment" : { if($_SESSION['levelCourse'] <= 3) { // i need to play directly the test require_once($GLOBALS['where_lms'].'/lib/lib.orgchart.php'); $orgman = new OrganizationManagement($_SESSION['idCourse']); $test =& $orgman->getInfoWhereType('test', $_SESSION['idCourse']); if(count($test) == 1) { $obj = array_shift($test); $_SESSION['test_assessment'] = 1; Util::jump_to('index.php?modname=organization&op=custom_playitem&id_item='.$obj['id_org'].''); } if($gotofirst_page) Util::jump_to($jumpurl); else return true; } else { if($gotofirst_page) { //... Util::jump_to($jumpurl); } else return true; } };break; default: { if($gotofirst_page) Util::jump_to($jumpurl); else return true; } } /* not used in // now analyze the course type and select the acton to perform if(isset($_GET['showresult'])) { require_once(_lms_.'/lib/lib.orgchart.php'); $orgman = new OrganizationManagement($_SESSION['idCourse']); $scorm =& $orgman->getInfoWhereType('scormorg', $_SESSION['idCourse']); if(count($scorm) == '1') { $obj = array_shift($scorm); Util::jump_to('index.php?modname=organization&op=scorm_track&id_user='******'&id_org='.$obj['id_resource'].'&back='.$GLOBALS['course_descriptor']->getValue('direct_play')); } Util::jump_to('index.php?modname=course&op=showresults&id_course='.$_SESSION['idCourse']); } */ }
function checkPermForCourse($mode, $id_course, $return_value = false, $use_mod_name = false) { if ($use_mod_name != false) { $mod_name = $use_mod_name; } else { $mod_name = $GLOBALS['modname']; } switch ($mode) { case "OP": case "view": $suff = 'view'; break; case "NEW": case "add": $suff = 'add'; break; case "MOD": case "mod": $suff = 'mod'; break; case "REM": case "del": $suff = 'del'; break; default: $suff = $mode; } $role = '/' . Get::cur_plat() . '/course/private/' . $id_course . '/' . $mod_name . '/' . $suff; if (!$return_value && isset($_SESSION['idCourse'])) { TrackUser::setActionTrack(getLogUserId(), $_SESSION['idCourse'], $mod_name, $suff); } if (Docebo::user()->matchUserRole($role)) { return true; } else { if ($return_value) { return false; } else { die("You can't access"); } } }
define("LMS", true); define("IN_FORMA", true); define("_deeppath_", '../../../'); require dirname(__FILE__) . '/' . _deeppath_ . 'base.php'; // start buffer ob_start(); // initialize require _base_ . '/lib/lib.bootstrap.php'; Boot::init(BOOT_DATETIME); // not a pagewriter but something similar $GLOBALS['operation_result'] = ''; if (!function_exists("aout")) { function aout($string) { $GLOBALS['operation_result'] .= $string; } } // here all the specific code ========================================================== require_once $GLOBALS['where_lms'] . '/lib/lib.track_user.php'; TrackUser::setActionTrack(getLogUserId(), $_SESSION['idCourse'], 'scorm', 'close'); // update the tracking // ===================================================================================== // close database connection // finalize Boot::finalize(); // remove all the echo ob_clean(); // Print out the page echo $GLOBALS['operation_result']; // flush buffer ob_end_flush();