public function getHistoryConference()
 {
     $query = "SELECT id, idCal, idCourse, name, room_type, starttime, endtime, meetinghours, maxparticipants" . " FROM conference_room" . " WHERE idCourse IN(" . implode(',', $this->getUserCourse()) . ")" . " AND endtime < '" . fromDatetimeToTimestamp(date('Y-m-d H:i:s')) . "'" . " ORDER BY starttime, name";
     $result = sql_query($query);
     $res = array();
     while ($row = sql_fetch_assoc($result)) {
         $res[$row['id']] = $row;
     }
     return $res;
 }
Example #2
0
 public function videoconferenceCounterUpdates()
 {
     $count = array('live' => 0, 'planned' => 0, 'history' => 0);
     $qtxt = "SELECT COUNT(*) " . " FROM conference_room" . " WHERE starttime <= '" . fromDatetimeToTimestamp(date('Y-m-d H:i:s')) . "'" . " AND endtime >= '" . fromDatetimeToTimestamp(date('Y-m-d H:i:s')) . "'" . " AND idCourse IN( SELECT idCourse" . "\t\tFROM %lms_courseuser" . "\t\tWHERE idUser = "******" AND status IN (0,1,2) )";
     if (!($re = $this->db->query($qtxt))) {
         return $count;
     }
     list($count['live']) = $this->db->fetch_row($re);
     $qtxt = "SELECT COUNT(*) " . " FROM conference_room" . " WHERE starttime > '" . fromDatetimeToTimestamp(date('Y-m-d H:i:s')) . "'" . " AND idCourse IN( SELECT idCourse" . "\t\tFROM %lms_courseuser" . "\t\tWHERE idUser = "******" AND status IN (0,1,2) )";
     if (!($re = $this->db->query($qtxt))) {
         return $count;
     }
     list($count['planned']) = $this->db->fetch_row($re);
     $qtxt = "SELECT COUNT(*) " . " FROM conference_room" . " WHERE endtime < '" . fromDatetimeToTimestamp(date('Y-m-d H:i:s')) . "'" . " AND idCourse IN( SELECT idCourse" . "\t\tFROM %lms_courseuser" . "\t\tWHERE idUser = "******" AND status IN (0,1,2) )";
     if (!($re = $this->db->query($qtxt))) {
         return $count;
     }
     list($count['history']) = $this->db->fetch_row($re);
     return $count;
 }
 function getOldRoomNumber($id_course)
 {
     $query = "SELECT COUNT(*)" . " FROM " . $this->_getRoomTable() . "" . " WHERE idCourse = '" . $id_course . "'" . " AND endtime < '" . time() . "'";
     $date = Get::req('filter_date', DOTY_MIXED, '');
     if ($date !== '') {
         $date = substr(Format::dateDb($date, 'date'), 0, 10);
         $query .= " AND starttime >= '" . fromDatetimeToTimestamp($date) . "'" . " AND starttime <= '" . fromDatetimeToTimestamp($date . ' 23:59:59') . "'";
     }
     list($result) = sql_fetch_row(sql_query($query));
     return $result;
 }
Example #4
0
 /**
  * @return 0 if the user password is not elapsed, 1 if the password is elapsed or a force change is
  */
 function isPasswordElapsed()
 {
     //if the password is managed by an external program jump this procedure
     if (Get::sett('ldap_used') == 'on') {
         return 0;
     }
     //change password forced from admin or is the first login. When a new user is created
     // and the setting for a change at irst login is active this flag wil be turned on
     $user_data = $this->aclManager->getUser($this->idst, false);
     if ($user_data[ACL_INFO_FORCE_CHANGE] == 1) {
         return 2;
     }
     // password expiration?
     if (!$user_data[ACL_INFO_PWD_EXPIRE_AT]) {
         return 0;
     }
     if (Get::sett('pass_max_time_valid', '0') != '0') {
         $pwd_expire = fromDatetimeToTimestamp($user_data[ACL_INFO_PWD_EXPIRE_AT]);
         if (time() > $pwd_expire) {
             return 1;
         }
     }
     return 0;
 }
 /**
  * retrive the list of the user thata have seen this profile
  */
 function getUserProfileViewList($id_user, $limit)
 {
     $user_list = array();
     $id_list = array();
     $query = "\r\n\t\tSELECT id_viewer, date_view\r\n\t\tFROM " . $this->_getTableProfileView() . "\r\n\t\tWHERE id_owner = '" . $id_user . "'\r\n\t\tORDER BY date_view DESC\r\n\t\tLIMIT 0," . $limit;
     if (!($re_query = sql_query($query))) {
         return $user_list;
     }
     while ($row = sql_fetch_row($re_query)) {
         $id_list[$row[0]] = $row[0];
         $user_list[$row[0]]['id'] = $row[0];
         $user_list[$row[0]]['username'] = $row[0];
         $user_list[$row[0]]['days_ago'] = (int) ((time() - fromDatetimeToTimestamp($row[1])) / (60 * 60 * 24));
     }
     $user_info =& $this->acl_man->getUsers($id_list);
     foreach ($id_list as $id) {
         $user_list[$id]['username'] = $user_info[$id][ACL_INFO_LASTNAME] . $user_info[$id][ACL_INFO_FIRSTNAME] ? $user_info[$id][ACL_INFO_LASTNAME] . ' ' . $user_info[$id][ACL_INFO_FIRSTNAME] : $this->acl_man->relativeId($user_info[$id][ACL_INFO_USERID]);
     }
     return $user_list;
 }
Example #6
0
function conference_modconf()
{
    $lang =& DoceboLanguage::createInstance('conference', 'lms');
    $id_room = Get::req('id', DOTY_INT, 0);
    $conference = new Conference_Manager();
    $room_info = $conference->roomInfo($id_room);
    if (isset($_POST['update_conf'])) {
        switch ($room_info['room_type']) {
            case 'teleskill':
                $start_date = Format::dateDb($_POST['start_date'], 'date');
                $start_date = substr($start_date, 0, 10);
                $start_time = (strlen($_POST['start_time']['hour']) == 1 ? '0' : '') . $_POST['start_time']['hour'] . ':' . (strlen($_POST['start_time']['minute']) == 1 ? '0' : '') . $_POST['start_time']['minute'] . ':00';
                $start_timestamp = fromDatetimeToTimestamp($start_date . ' ' . $start_time);
                $conference_name = trim($_POST["conference_name"]) ? trim($_POST["conference_name"]) : $lang->def('_VIDEOCONFERENCE');
                $meetinghours = (int) $_POST["meetinghours"];
                $end_timestamp = $start_timestamp + $meetinghours * 3600;
                $maxparticipants = (int) $_POST["maxparticipants"];
                $teleskill = new Teleskill_Management();
                $teleskill->updateRoom($id_room, getLogUserId(), $conference_name, $start_timestamp, $end_timestamp, false, false, $maxparticipants, isset($_POST['bookable']) ? 1 : 0);
                Util::jump_to('index.php?modname=conference&amp;op=list');
                break;
            default:
                Util::jump_to('index.php?modname=conference&amp;op=list');
                break;
        }
    } else {
        cout(getTitleArea($lang->def('_MOD_CONFERENCE')) . '<div class="std_block">');
        switch ($room_info['room_type']) {
            case 'teleskill':
                $teleskill = new Teleskill_Management();
                $teleskill->getModUi($room_info);
                break;
            default:
                Util::jump_to('index.php?modname=conference&amp;op=list');
                break;
        }
        cout('</div>');
    }
}
Example #7
0
    require_once $GLOBALS['where_scs'] . '/lib/lib.teleskill.php';
    $teleskill = new Teleskill_Management();
    $teleskill->clearRoomLog($roomid);
    $dlist_sessions = $dom_answer->getElementsByTagName('session');
    $dlist_sessions = $dlist_sessions->item(0);
    if ((int) $dlist_sessions->getAttribute('uid') != 0 && $dlist_sessions->getAttribute('uid') !== '') {
        $gmt = date('P', fromDatetimeToTimestamp($dlist_sessions->getAttribute('date')));
        $gmt_split = explode(':', $gmt);
        $gmt_offset = (int) $gmt_split[0];
        $query_control = "SELECT COUNT(*)" . " FROM " . $GLOBALS['prefix_scs'] . "_teleskill_log" . " WHERE roomid = '" . $dlist_sessions->getAttribute('roomid') . "'" . " AND idUser = '******'uid') . "'";
        list($control) = sql_fetch_row(sql_query($query_control));
        if ($control) {
            $query = "UPDATE " . $GLOBALS['prefix_scs'] . "_teleskill_log" . " SET role = '" . $dlist_sessions->getAttribute('role') . "'," . " duration = (duration + '" . $dlist_sessions->getAttribute('duration') . "')," . " access = (access + " . ($dlist_sessions->getAttribute('duration') == 0 ? 1 : 0) . ")" . " WHERE roomid = '" . $dlist_sessions->getAttribute('roomid') . "'" . " AND idUser = '******'uid') . "'";
            $result = sql_query($query);
        } else {
            $query = "INSERT INTO " . $GLOBALS['prefix_scs'] . "_teleskill_log (roomid, idUser, role, `date`, duration, access)" . " VALUES ('" . $dlist_sessions->getAttribute('roomid') . "',\r\n\t\t\t\t\t\t'" . (int) $dlist_sessions->getAttribute('uid') . "',\r\n\t\t\t\t\t\t'" . $dlist_sessions->getAttribute('role') . "',\r\n\t\t\t\t\t\t'" . date('Y-m-d H:i:s', fromDatetimeToTimestamp($dlist_sessions->getAttribute('date')) + $gmt_offset * 3600) . "',\r\n\t\t\t\t\t\t'" . $dlist_sessions->getAttribute('duration') . "',\r\n\t\t\t\t\t\t'" . ($dlist_sessions->getAttribute('duration') == 0 ? 1 : 0) . "')";
            $result = sql_query($query);
        }
        if ($result) {
            aout('<?xml version="1.0" encoding="UTF-8"?><ews><errorcode>0</errorcode><errormessage></errormessage></ews>');
        } else {
            aout('<?xml version="1.0" encoding="UTF-8"?><ews><errorcode>1</errorcode><errormessage>Error during insertion in db</errormessage></ews>');
        }
    } else {
        aout('<?xml version="1.0" encoding="UTF-8"?><ews><errorcode>1</errorcode><errormessage>No data found</errormessage></ews>');
    }
} else {
    aout('<?xml version="1.0" encoding="UTF-8"?><ews><errorcode>1</errorcode><errormessage>No data found</errormessage></ews>');
}
// =====================================================================================
// close database connection
Example #8
0
function userCourseList(&$url, $use_tab = true, $page_add = true)
{
    YuiLib::load(array('animation' => 'animation-min.js', 'dragdrop' => 'dragdrop-min.js', 'button' => 'button-min.js', 'container' => 'container-min.js', 'my_window' => 'windows.js'), array('container/assets/skins/sam' => 'container.css', 'button/assets/skins/sam' => 'button.css'));
    if ($page_add) {
        addJs($GLOBALS['where_lms_relative'] . '/modules/coursecatalogue/', 'ajax.coursecatalogue.js');
    }
    require_once _base_ . '/lib/lib.form.php';
    require_once _base_ . '/lib/lib.user_profile.php';
    require_once _base_ . '/lib/lib.navbar.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.preassessment.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.catalogue.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.coursereport.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.coursepath.php';
    require_once $GLOBALS["where_framework"] . "/lib/lib.ajax_comment.php";
    require_once $GLOBALS['where_lms'] . '/lib/lib.classroom.php';
    // pre-loading coursepath ------------------------------------------------------------------
    $path_man = new CoursePath_Manager();
    // search for the coursepath ----------------------------------------------------------
    $user_coursepath = $path_man->getUserSubscriptionsInfo(getLogUserId(), true);
    $coursepath = $path_man->getCoursepathAllInfo(array_keys($user_coursepath));
    if (!empty($coursepath)) {
        // find structures of the course path ---------------------------------------------
        $path_courses = $path_man->getPathStructure(array_keys($coursepath));
        $cp_info = $path_man->getAllCoursesInfo($path_courses['all_paths']);
        /*echo "<pre>\n\n";
        		print_r($cp_info);
        		echo "\n\n</pre>";*/
    }
    // ------------------------------------------------------------------------
    $course_stats = array('total' => 0, 'u_can_enter' => 0, 'with_status' => array(CST_AVAILABLE => 0, CST_EFFECTIVE => 0, CST_CONCLUDED => 0, CST_CANCELLED => 0), 'with_ustatus' => array(_CUS_SUBSCRIBED => 0, _CUS_BEGIN => 0, _CUS_END => 0, _CUS_SUSPEND => 0), 'with_wstatus' => array(_CUS_RESERVED => 0, _CUS_WAITING_LIST => 0), 'with_ulevel' => array(), 'expiring' => 0, 'cert_relesable' => 0);
    // ------------------------------------------------------------------------
    $filter = importVar('filter', false, 'total');
    if ($filter == 'level') {
        $filter_level = importVar('filter_on', true, 0);
    }
    $current_tab = importVar('current_tab', false, 'lo_plan');
    if ($use_tab && $page_add) {
        addCss('style_tab');
        $lo_plan = importVar('lo_plan', false, 0);
        $lo_history = importVar('lo_history', false, 0);
        if ($lo_plan != 0) {
            $current_tab = 'lo_plan';
        }
        if ($lo_history != 0) {
            $current_tab = 'lo_history';
        }
    }
    if ($use_tab && $page_add) {
        addCss('style_tab');
        $lo_plan = importVar('lo_plan', false, 0);
        $lo_history = importVar('lo_history', false, 0);
        if ($lo_plan != 0) {
            $current_tab = 'lo_plan';
        }
        if ($lo_history != 0) {
            $current_tab = 'lo_history';
        }
    }
    require_once $GLOBALS['where_lms'] . '/lib/lib.certificate.php';
    $cert = new Certificate();
    $released = $cert->certificateReleased(getLogUserId());
    $available_cert = $cert->certificateForCourses(false, false);
    // cahce classroom -----------------------------------------------------------------
    $classroom_man = new ClassroomManager();
    $classrooms = $classroom_man->getClassroomNameList();
    $lang =& DoceboLanguage::createInstance('catalogue');
    $lang_c =& DoceboLanguage::createInstance('course');
    $man_course = new Man_Course();
    $subcourse_list = sql_query("" . " SELECT u.idCourse, u.edition_id, level, u.date_inscr, u.date_first_access, " . "\t\tu.date_complete, u.status AS user_status, u.waiting, u.edition_id " . " FROM " . $GLOBALS['prefix_lms'] . "_courseuser AS u" . " WHERE idUser = '******'");
    $subscription = array();
    while ($cinfo = mysql_fetch_assoc($subcourse_list)) {
        $subscription['course'][$cinfo['idCourse']] = $cinfo;
        if ($cinfo['edition_id'] != 0) {
            $subscription['edition'][$cinfo['idCourse']][$cinfo['edition_id']] = $cinfo;
        }
    }
    // searching courses ---------------------------------------------------------------
    $select_course = "" . " SELECT c.idCourse, c.course_type, c.idCategory, c.code, c.name, c.description, c.lang_code, c.difficult, " . "\tc.subscribe_method, c.date_begin, c.date_end, c.max_num_subscribe, " . "\tc.selling, c.prize, c.create_date, c.status AS course_status, c.course_edition, " . "\tc.classrooms, c.img_othermaterial, c.course_demo, c.course_vote, " . "\tc.can_subscribe, c.sub_start_date, c.sub_end_date, c.valid_time, c.userStatusOp, c.show_result, u.status AS user_status, u.level " . ", c.use_logo_in_courselist, c.img_course, c.direct_play ";
    $from_course = " FROM " . $GLOBALS['prefix_lms'] . "_course AS c " . "\t JOIN " . $GLOBALS['prefix_lms'] . "_courseuser AS u ";
    $where_course = " c.idCourse = u.idCourse " . " AND u.idUser = '******' " . " AND ( c.status <> '" . CST_PREPARATION . "' OR u.level > 3 )" . " AND c.course_type <> 'assessment' ";
    $selected_year = 0;
    $selected_search = '';
    if (isset($_POST['apply_filter'])) {
        if ($_POST['year']) {
            $where_course .= " AND c.create_date BETWEEN '" . $_POST['year'] . "-01-01 00:00:00' AND '" . $_POST['year'] . "-12-31 23:59:59'";
            $selected_year = $_POST['year'];
        }
        if ($_POST['search'] !== '') {
            $where_course .= " AND c.name LIKE '%" . $_POST['search'] . "%'";
            $selected_search = $_POST['search'];
        }
    }
    $group_by_course = " GROUP BY c.idCourse ";
    $order_course = " ORDER BY ";
    $tablist = Get::sett('tablist_mycourses', '');
    if ($tablist != '') {
        $arr_order_course = explode(',', $tablist);
        $arr_temp = array();
        foreach ($arr_order_course as $key => $value) {
            switch ($value) {
                case 'status':
                    $arr_temp[] = ' u.status ';
                    break;
                case 'code':
                    $arr_temp[] = ' c.code ';
                    break;
                case 'name':
                    $arr_temp[] = ' c.name ';
                    break;
            }
        }
        $order_course = $order_course . implode(', ', $arr_temp);
    }
    if ($order_course == " ORDER BY ") {
        //default without parameter
        $order_course .= " u.status, c.name ";
    }
    // apply search filter --------------------------------------------------------------
    $all_lang = Docebo::langManager()->getAllLangCode();
    $re_course = sql_query($select_course . $from_course . " WHERE " . $where_course . $group_by_course . $order_course);
    // retrive editions ----------------------------------------------------------------
    $select_edition = " SELECT e.* ";
    $from_edition = " FROM " . $GLOBALS["prefix_lms"] . "_course_editions AS e " . " JOIN " . $GLOBALS["prefix_lms"] . "_courseuser AS u ";
    $where_edition = " WHERE e.status <> '" . CST_PREPARATION . "' AND e.id_edition = u.edition_id ";
    $re_edition = sql_query($select_edition . $from_edition . $where_edition);
    // --------------------------------------------------------------------------------
    $editions = array();
    if ($re_edition) {
        while ($edition_elem = mysql_fetch_assoc($re_edition)) {
            $edition_elem['classrooms'] = isset($classrooms[$edition_elem['classrooms']]) ? $classrooms[$edition_elem['classrooms']] : '';
            $editions[$edition_elem["id_course"]][$edition_elem["id_course"]] = $edition_elem;
        }
    }
    $man_courseuser = new Man_CourseUser();
    $ax_comm = new AjaxComment('course', 'lms');
    $comment_count = $ax_comm->getResourceCommentCount();
    $user_score = $man_courseuser->getUserCourseScored(getLogUserId());
    // -----------------------------------------------------------------------------
    $needed_info_for = array();
    if (!empty($subscription['course'])) {
        $id_course_list = array_keys($subscription['course']);
        // find last access to the courses ---------------------------------------------------------------------
        require_once $GLOBALS['where_lms'] . '/lib/lib.track_user.php';
        $last_access_courses = TrackUser::getLastAccessToCourse(getLogUserId());
        // retrive unreaded advice -----------------------------------------------------------------------------
        require_once $GLOBALS['where_lms'] . '/lib/lib.advice.php';
        $advices = Man_Advice::getCountUnreaded(getLogUserId(), $id_course_list, $last_access_courses);
        // retrive unreaded forum messages ---------------------------------------------------------------------
        require_once $GLOBALS['where_lms'] . '/lib/lib.forum.php';
        $forums = Man_Forum::getCountUnreaded(getLogUserId(), $id_course_list, $last_access_courses);
        // retrive new lesson ----------------------------------------------------------------------------------
        require_once $GLOBALS['where_lms'] . '/lib/lib.orgchart.php';
        $org_chart = OrganizationManagement::getCountUnreaded(getLogUserId(), $id_course_list, $last_access_courses);
        if (!empty($path_courses['all_items'])) {
            $needed_info_for = array_diff($path_courses['all_items'], $id_course_list);
        }
        $first_is_scorm = OrganizationManagement::objectFilter($id_course_list, 'scormorg');
        $enroll_list = sql_query("" . " SELECT u.idCourse, u.edition_id, COUNT(*) as number " . " FROM " . $GLOBALS['prefix_lms'] . "_courseuser AS u" . " WHERE u.idCourse IN (" . implode($id_course_list, ',') . ") " . " AND u.level = '3'" . " AND u.status IN ('" . _CUS_CONFIRMED . "', '" . _CUS_SUBSCRIBED . "', '" . _CUS_BEGIN . "', '" . _CUS_END . "', '" . _CUS_SUSPEND . "', '" . _CUS_WAITING_LIST . "')" . " AND u.absent = '0'" . " GROUP BY u.idCourse, u.edition_id ");
        $enrolled = array();
        while ($cinfo = mysql_fetch_assoc($enroll_list)) {
            $enrolled[$cinfo['idCourse']][$cinfo['edition_id']] = $cinfo['number'];
        }
    }
    // search pre-assessment -----------------------------------------------------------
    $select_assess = "" . " SELECT c.idCourse, c.course_type, c.idCategory, c.code, c.name, c.description, c.lang_code, c.difficult, " . "\tc.subscribe_method, c.date_begin, c.date_end, c.max_num_subscribe, " . "\tc.selling, c.prize, c.create_date, c.status AS course_status, c.course_edition, " . "\tc.classrooms, c.img_othermaterial, c.course_demo, c.course_vote, " . "\tc.can_subscribe, c.sub_start_date, c.sub_end_date, c.valid_time, c.userStatusOp, " . "\tu.level, u.date_inscr, u.date_first_access, u.date_complete, u.status AS user_status, u.waiting, c.advance, u.waiting ";
    $from_assess = " FROM " . $GLOBALS['prefix_lms'] . "_course AS c " . "\t JOIN " . $GLOBALS['prefix_lms'] . "_courseuser AS u ";
    $where_assess = " c.idCourse = u.idCourse " . " AND u.idUser = '******' " . " AND c.course_type = 'assessment' " . " AND  ( c.status <> '" . CST_PREPARATION . "' OR u.level > 3 ) " . ($filter == 'level' ? " AND level = '" . $filter_level . "'" : "");
    //." AND ( u.status <> '"._CUS_END."' OR u.level > 3 ) ";
    $preass_list = sql_query($select_assess . $from_assess . " WHERE " . $where_assess . " ORDER BY c.name ");
    // pre assessment list ---------------------------------------------------------------------------------------
    $i = 0;
    if (mysql_num_rows($preass_list) && $current_tab == 'lo_plan') {
        if ($page_add) {
            $GLOBALS['page']->add('<div id="mycourse_asses">' . '<h1>' . $lang_c->def('_ASSESSMENT_LIST') . '</h1>', 'content');
        }
        while ($cinfo = mysql_fetch_assoc($preass_list)) {
            $cinfo['user_score'] = isset($user_score[$cinfo['idCourse']]) ? $user_score[$cinfo['idCourse']] : NULL;
            if (isset($comment_count[$cinfo['idCourse']])) {
                $cinfo['comment_count'] = $comment_count[$cinfo['idCourse']];
            }
            if ($page_add) {
                $GLOBALS['page']->add(dashmyassess($url, $lang_c, $cinfo, $i++), 'content');
            }
        }
        if ($page_add) {
            $GLOBALS['page']->add('</div>', 'content');
        }
    }
    // page intest ------------------------------------------------------------
    require_once $GLOBALS['where_lms'] . '/lib/lib.levels.php';
    $lvl = CourseLevel::getLevels();
    $title = $lang->def('_COURSE_LIST');
    switch ($filter) {
        case "access":
            $title = $lang->def('_COURSE_YOU_CAN_ACCESS');
            break;
        case "expiring":
            $title = $lang->def('_COURSE_EXPIRING');
            break;
        case "subscribed":
            $title = $lang->def('_COURSE_SUBSCRIBED');
            break;
        case "begin":
            $title = $lang->def('_COURSE_BEGIN');
            break;
        case "end":
            $title = $lang->def('_COURSE_END');
            break;
        case "level":
            $title = str_replace('[level]', $lvl[$_GET['filter_on']], $lang->def('_COURSE_AS'));
            break;
    }
    if ($page_add) {
        $GLOBALS['page']->add('<div id="mycourse_list">' . '<h1>' . $title . '</h1>', 'content');
    }
    $i = 0;
    $direct_play = false;
    while ($cinfo = mysql_fetch_assoc($re_course)) {
        $access = Man_Course::canEnterCourse($cinfo);
        if ($cinfo['direct_play'] == 1) {
            $direct_play = true;
        }
        $course_stats['total']++;
        if ($cinfo['user_status'] == _CUS_RESERVED || $cinfo['user_status'] == _CUS_WAITING_LIST) {
            $course_stats['with_wstatus'][$cinfo['user_status']]++;
        } elseif ($access['can']) {
            $course_stats['u_can_enter']++;
        }
        if (isset($course_stats['with_ustatus'][$cinfo['user_status']])) {
            $course_stats['with_ustatus'][$cinfo['user_status']]++;
        } else {
            $course_stats['with_ustatus'][$cinfo['user_status']] = 1;
        }
        if (!isset($course_stats['with_ulevel'][$cinfo['level']])) {
            $course_stats['with_ulevel'][$cinfo['level']] = 1;
        } else {
            $course_stats['with_ulevel'][$cinfo['level']]++;
        }
        if (isset($available_cert[$cinfo['idCourse']])) {
            while (list($id_cert, $certificate) = each($available_cert[$cinfo['idCourse']])) {
                if (!isset($released[$id_cert]) && $cert->canRelease($certificate[CERT_AV_STATUS], $cinfo['user_status'])) {
                    $course_stats['cert_relesable']++;
                }
            }
        }
    }
    if (mysql_num_rows($re_course)) {
        mysql_data_seek($re_course, 0);
    }
    while ($cinfo = mysql_fetch_assoc($re_course)) {
        $cinfo['edition_list'] = isset($editions[$cinfo['idCourse']]) ? $editions[$cinfo['idCourse']] : array();
        $cinfo['user_score'] = isset($user_score[$cinfo['idCourse']]) ? $user_score[$cinfo['idCourse']] : NULL;
        $cinfo['enrolled'] = isset($enrolled[$cinfo['idCourse']]) ? $enrolled[$cinfo['idCourse']] : false;
        if (isset($comment_count[$cinfo['idCourse']])) {
            $cinfo['comment_count'] = $comment_count[$cinfo['idCourse']];
        }
        $cinfo['classrooms'] = isset($classrooms[$cinfo['classrooms']]) ? $classrooms[$cinfo['classrooms']] : '';
        // advertising --------------------------------------------------------------------------------------------
        $cinfo['to_read']['advice'] = isset($advices[$cinfo['idCourse']]) ? $advices[$cinfo['idCourse']] : 0;
        $cinfo['to_read']['forum'] = isset($forums[$cinfo['idCourse']]) ? $forums[$cinfo['idCourse']] : 0;
        $cinfo['to_read']['lobj'] = isset($org_chart[$cinfo['idCourse']]) ? $org_chart[$cinfo['idCourse']] : 0;
        // 10 days in the future
        $range = time() + 10 * 24 * 60 * 60;
        $expiring = false;
        if ($cinfo['date_end'] != '0000-00-00') {
            $time_end = fromDatetimeToTimestamp($cinfo['date_end']);
            if ($range > $time_end) {
                $expiring = true;
                $course_stats['expiring']++;
            }
        }
        if ($cinfo['valid_time'] != '0' && $cinfo['valid_time'] != '' && $cinfo['date_first_access'] != '') {
            $time_first_access = fromDatetimeToTimestamp($cinfo['date_first_access']);
            if ($range > $time_first_access + $cinfo['valid_time'] * 24 * 3600) {
                $expiring = true;
                $course_stats['expiring']++;
            }
        }
        if (isset($first_is_scorm[$cinfo['idCourse']])) {
            $cinfo['first_is_scorm'] = $first_is_scorm[$cinfo['idCourse']];
        } else {
            $cinfo['first_is_scorm'] = false;
        }
        $access = Man_Course::canEnterCourse($cinfo);
        // --------------------------------------------------------------------
        if (!isset($path_courses['all_items'][$cinfo['idCourse']])) {
            // the course is not related with a coursepath, so i can print it --------------
            if ($filter == 'level') {
                if ($subscription['course'][$cinfo['idCourse']]['level'] == $filter_level) {
                    $dash = dashmycourse($url, $lang_c, $subscription, $cinfo, $i++);
                } else {
                    $dash = '';
                }
            } else {
                $dash = dashmycourse($url, $lang_c, $subscription, $cinfo, $i++);
            }
            if ($use_tab == true) {
                if ($course_stats['with_ustatus'][_CUS_END] == $course_stats['total']) {
                    $current_tab = 'lo_history';
                }
                if ($current_tab == 'lo_history') {
                    if ($cinfo['user_status'] == _CUS_END && $page_add) {
                        $GLOBALS['page']->add($dash, 'content');
                    }
                } else {
                    if (($cinfo['user_status'] != _CUS_END || $cinfo['level'] >= 4) && $page_add) {
                        $GLOBALS['page']->add($dash, 'content');
                    }
                }
            } else {
                switch ($filter) {
                    case "access":
                        if ($access['can'] && $page_add) {
                            $GLOBALS['page']->add($dash, 'content');
                        }
                        break;
                    case "expiring":
                        if ($expiring && $page_add) {
                            $GLOBALS['page']->add($dash, 'content');
                        }
                        break;
                    case "subscribed":
                        if ($cinfo['user_status'] == _CUS_SUBSCRIBED && $page_add) {
                            $GLOBALS['page']->add($dash, 'content');
                        }
                        break;
                    case "begin":
                        if ($cinfo['user_status'] == _CUS_BEGIN && $page_add) {
                            $GLOBALS['page']->add($dash, 'content');
                        }
                        break;
                    case "end":
                        if ($cinfo['user_status'] == _CUS_END && $page_add) {
                            $GLOBALS['page']->add($dash, 'content');
                        }
                        break;
                    case "level":
                        if ($_GET['filter_on'] == $cinfo['level'] && $page_add) {
                            $GLOBALS['page']->add($dash, 'content');
                        }
                        break;
                    default:
                        if ($page_add) {
                            $GLOBALS['page']->add($dash, 'content');
                        }
                }
            }
        } else {
            // the course is related with a coursepath, so i must wait to print it ----------
            //$cinfo['prerequisites'] = $path_courses['all_items'][$cinfo['idCourse']]; // <- useless?
            //$courses =array($cinfo['idCourse']=>$cinfo);
            $prere = $cp_info[$cinfo['idCourse']]["prerequisites"];
            if ($path_man->checkPrerequisites($prere, $subscription)) {
                $cinfo['prerequisites_satisfied'] = true;
            } else {
                $cinfo['prerequisites_satisfied'] = false;
            }
            if ($filter == 'level') {
                if ($subscription['course'][$cinfo['idCourse']]['level'] == $filter_level) {
                    $course_cache[$cinfo['idCourse']] = dashmycourse($url, $lang_c, $subscription, $cinfo, 1, true, 4);
                } else {
                    $course_cache[$cinfo['idCourse']] = '';
                }
            } else {
                $course_cache[$cinfo['idCourse']] = dashmycourse($url, $lang_c, $subscription, $cinfo, 1, true, 4);
            }
        }
        // end else-if -------------------------------------------------------
    }
    //  end while ------------------------------------------------------------
    if ($direct_play && $page_add) {
        $GLOBALS['page']->add('' . '	<link href="' . getPathTemplate() . '/style/shadowbox.css" rel="stylesheet" type="text/css" />' . '<script type="text/javascript" src="' . $GLOBALS['where_framework_relative'] . '/addons/shadowbox/shadowbox-yui.js"></script>' . "\n" . '<script type="text/javascript" src="' . $GLOBALS['where_framework_relative'] . '/addons/shadowbox/shadowbox.js"></script>' . "\n", 'page_head');
        $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_EXIT', 'organization', 'lms') . '"; } }
		    }; 
			Shadowbox.init(options); 
			Shadowbox.close = function() { 
				window.frames[\'shadowbox_content\'].uiPlayer.closePlayer(true, window);
			}
		});
		</script>');
    }
    if ($course_stats['total'] == 0 && $page_add) {
        $GLOBALS['page']->add('' . '<b>' . $lang->def('_NO_COURSE') . '</b> ' . '<br />', 'content');
    }
    if ($page_add) {
        $GLOBALS['page']->add('</div>', 'content');
    }
    // Coursepath --------------------------------------------------------------
    if (!empty($coursepath)) {
        // find structures of the course path ----------------------------------
        $path_slot = $path_man->getPathSlot(array_keys($coursepath));
        // coursepath list -----------------------------------------------------
        if ($page_add) {
            $GLOBALS['page']->add('<div id="mycoursepath_list">' . '<h1>' . $lang->def('_COURSEPATH_LIST') . '</h1>', 'content');
        }
        $i = 0;
        // find course basilar information -------------------------------------
        if (!empty($needed_info_for)) {
            $course_info = $man_course->getAllCourses(false, false, $needed_info_for);
        } else {
            $course_info = array();
        }
        while (list($id_path, $path) = each($coursepath)) {
            $html = '<div class="coursepath_container coursepath_container_simple">';
            $html .= '<h2>' . ($path[COURSEPATH_CODE] != '' ? '[' . $path[COURSEPATH_CODE] . '] ' : '') . $path[COURSEPATH_NAME] . '</h2>';
            if (!isset($path_courses[$id_path]) || empty($path_courses[$id_path])) {
                $html .= $lang->def('_NO_COURSE_ASSIGNED_TO_COURSEPATH') . '<br />';
            } else {
                // display the slots
                foreach ($path_slot[$id_path] as $id_slot => $slot_info) {
                    if ($id_slot == 0) {
                        $html .= '<h3>' . $lang->def('_MANDATORY') . '</h3>';
                        if (!empty($path_courses[$id_path][$id_slot])) {
                            $html .= '<ul class="coursepath_mainslot">';
                        }
                    } else {
                        if ($slot_info['min_selection'] > 0 && $slot_info['max_selection'] > 0) {
                            $title = str_replace(array('[min_selection]', '[max_selection]'), array($slot_info['min_selection'], $slot_info['max_selection']), $lang->def('_COURSE_PATH_SLOT_MIN_MAX'));
                        } elseif ($slot_info['max_selection'] > 0) {
                            $title = str_replace('[max_selection]', $slot_info['max_selection'], $lang->def('_COURSE_PATH_SLOT_MAX'));
                        } else {
                            $title = $lang->def('_COURSE_PATH_SLOT');
                        }
                        $html .= '<h3>' . $title . '</h3>';
                        if (!empty($path_courses[$id_path][$id_slot])) {
                            $html .= '<ul class="coursepath_otherslot">';
                        }
                    }
                    while (list($id) = each($path_courses[$id_path][$id_slot])) {
                        if (isset($course_cache[$id])) {
                            $html .= '<li>' . $course_cache[$id] . '</li>';
                        } else {
                            $html .= '<li>' . dashAcourse($id, 4) . '</li>';
                        }
                    }
                    if (!empty($path_courses[$id_path][$id_slot])) {
                        $html .= '</ul>';
                    }
                }
            }
            $html .= '</div>';
            if ($page_add) {
                $GLOBALS['page']->add($html, 'content');
            }
        }
        if ($page_add) {
            $GLOBALS['page']->add('</div>', 'content');
        }
    }
    if ($course_stats['cert_relesable'] < 0) {
        $course_stats['cert_relesable'] = 0;
    }
    return $course_stats;
}
Example #9
0
function editUserReport($id_user, $id_test, $id_track)
{
    $lang =& DoceboLanguage::createInstance('test');
    //test info---------------------------------------------------------
    list($title, $mod_doanswer, $point_type, $point_required, $question_random_number, $show_score, $show_score_cat, $show_doanswer, $show_solution, $order_type) = sql_fetch_row(sql_query("\r\n\tSELECT  title, mod_doanswer, point_type, point_required, question_random_number, \r\n\t\t\tshow_score, show_score_cat, show_doanswer, \r\n\t\t\tshow_solution, order_type\r\n\tFROM " . $GLOBALS['prefix_lms'] . "_test \r\n\tWHERE idTest = '" . (int) $id_test . "'"));
    list($score, $bonus_score, $date_attempt, $date_attempt_mod, $date_end_attempt) = sql_fetch_row(sql_query("\r\n\tSELECT score, bonus_score, date_attempt, date_attempt_mod, date_end_attempt\r\n\tFROM " . $GLOBALS['prefix_lms'] . "_testtrack \r\n\tWHERE idTrack = '" . (int) $id_track . "'"));
    $point_do = 0;
    $max_score = 0;
    $num_manual = 0;
    $manual_score = 0;
    $quest_sequence_number = 1;
    $report_test = '';
    $point_do_cat = array();
    if ($order_type >= 2) {
        $re_visu_quest = sql_query("SELECT idQuest \r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_testtrack_quest \r\n\t\tWHERE idTrack = '" . (int) $id_track . "' ");
        while (list($id_q) = sql_fetch_row($re_visu_quest)) {
            $quest_see[] = $id_q;
        }
        $query_question = "\r\n\t\tSELECT q.idQuest, q.type_quest, t.type_file, t.type_class, q.idCategory \r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_testquest AS q JOIN " . $GLOBALS['prefix_lms'] . "_quest_type AS t \r\n\t\tWHERE q.idTest = '" . $id_test . "' AND q.type_quest = t.type_quest AND  q.idQuest IN (" . implode($quest_see, ',') . ") \r\n\t\tORDER BY q.sequence";
    } else {
        $query_question = "\r\n\t\tSELECT q.idQuest, q.type_quest, t.type_file, t.type_class, q.idCategory \r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_testquest AS q JOIN " . $GLOBALS['prefix_lms'] . "_quest_type AS t \r\n\t\tWHERE q.idTest = '" . $id_test . "' AND q.type_quest = t.type_quest \r\n\t\tORDER BY q.sequence";
    }
    $reQuest = sql_query($query_question);
    while (list($id_quest, $type_quest, $type_file, $type_class, $id_cat) = sql_fetch_row($reQuest)) {
        require_once $GLOBALS['where_lms'] . '/modules/question/' . $type_file;
        $quest_point_do = 0;
        $quest_obj = eval("return new {$type_class}( {$id_quest} );");
        $quest_point_do = $quest_obj->userScore($id_track);
        $quest_max_score = $quest_obj->getMaxScore();
        if ($type_quest != 'title' && $type_quest != 'break_page') {
            $review = $quest_obj->displayUserResult($id_track, $type_quest != 'title' ? $quest_sequence_number++ : $quest_sequence_number, $quest_sequence_number);
            $report_test .= '<div class="test_quest_review_container">' . $review['quest'];
            if ($review['score'] !== false) {
                $report_test .= '<div class="test_answer_comment_nomargin">' . '<div class="test_score_note">' . $lang->def('_SCORE') . ' : ';
                if ($quest_obj->getScoreSetType() == 'manual' && !$review['manual_assigned']) {
                    $report_test .= $lang->def('_NOT_ASSIGNED');
                } else {
                    if ($review['score'] > 0) {
                        $report_test .= '<span class="test_score_positive">' . $review['score'] . '</span>';
                    } else {
                        $report_test .= '<span class="test_score_negative">' . $review['score'] . '</span>';
                    }
                }
                $report_test .= '</div>' . ($review['comment'] != '' ? $review['comment'] : '') . '</div>';
            }
            $report_test .= '<div class="test_edit_scores">' . Form::getTextfield($lang->def('_NEW_SCORE_FOR_QUESTION'), 'new_user_score_' . $id_quest, 'new_user_score[' . $id_quest . ']', 8, '') . '</div>' . "\n" . '</div>' . "\n";
        }
    }
    $total_time = 0;
    $total_time = fromDatetimeToTimestamp($date_end_attempt) - fromDatetimeToTimestamp($date_attempt);
    if ($total_time > 0) {
        $seconds = $total_time % 60;
        $total_time -= $seconds;
        $minutes = $total_time / 60;
    }
    $GLOBALS['page']->add('<div class="title">' . $lang->def('_TITLE') . ' : ' . $title . '</div>', 'content');
    $GLOBALS['page']->add('<br />' . Form::getTextfield($lang->def('_BONUS_SCORE_FOR_TEST'), 'bonus_score', 'bonus_score', 8, $bonus_score) . '<br />' . ($total_time > 0 ? '<b>' . Lang::t('_DATE_BEGIN', 'standard') . '</b> : ' . Format::date($date_attempt, 'datetime') . '<br />' . '<b>' . Lang::t('_DATE_END', 'standard') . '</b> : ' . Format::date($date_end_attempt, 'datetime') . '<br />' . '<b>' . Lang::t('_TOTAL_TIME', 'test') . '</b> : ' . $minutes . ':' . $seconds . '<br />' . '<br />' : '') . '<div class="test_answer_space">' . $report_test . '</div>', 'content');
}
Example #10
0
 function api_schedule_meeting($idConference, $user_email, $display_name, $confkey, $audiovideosettings, $maxmikes, $maxparticipants, $startdate, $starthour, $startminute, $duration, $extra_conf)
 {
     $query = "SELECT * FROM " . $GLOBALS['prefix_scs'] . "_room WHERE id = '" . $idConference . "'";
     $re_room = $this->_query($query);
     $room = $this->nextRow($re_room);
     $params = new stdClass();
     $params->enterpriseName = 'bbb';
     $params->groupName = 'all';
     $params->accountName = Get::sett('bbb_user', "");
     $params->roomName = 'default';
     $params->startDate = date("M j, Y", fromDatetimeToTimestamp($startdate));
     $params->startHour = ($starthour > 12 ? $starthour - 12 : $starthour) . "";
     $params->startMinute = "" . $startminute;
     $params->timeAMPM = $starthour > 12 ? 'PM' : 'AM';
     //$params->agenda = (string)$room['name'];
     $params->meetingName = (string) $room['name'];
     $params->displayName = 'Fabio';
     $params->meetingRecurrance = 'SINGLE_EVENT';
     // SINGLE_EVENT, DAILY, WEEKLY, MON_DATE
     $params->lobbyEnabled = $extra_conf['lobbyEnabled'];
     //$params->lobbyEnabled = $extra_conf['display_phone_info'];
     //$params->lobbyEnabled = $extra_conf['show_part_list'];
     $params->privateChatEnabled = $extra_conf['privateChatEnabled'];
     $params->publicChatEnabled = $extra_conf['publicChatEnabled'];
     $params->screenShareEnabled = $extra_conf['screenShareEnabled'];
     //$params->lobbyEnabled = $extra_conf['meeting_assistant_visibility'];
     $params->autoAssignMikeOnJoin = $extra_conf['autoAssignMikeOnJoin'];
     $params->whiteboardEnabled = $extra_conf['whiteboardEnabled'];
     $params->documentSharingEnabled = $extra_conf['documentSharingEnabled'];
     //$params->lobbyEnabled = $extra_conf['enable_web_sharing'];
     $params->recordingEnabled = $extra_conf['recordingEnabled'];
     //$params->lobbyEnabled = $extra_conf['allow_attendees_invitation'];
     $params->autoHandsFreeOnAVLoad = $extra_conf['autoHandsFreeOnAVLoad'];
     $params->joinEmailRequired = $extra_conf['joinEmailRequired'];
     $res = $this->_api_request('prtl', 'create_schedule', $params, 'request');
     die;
     if ($res) {
         if (!$res->result) {
             return false;
         }
         return $res;
     }
     return false;
 }
    function updateRoomLog($roomid)
    {
        $xml_answer = false;
        $bw_code = Get::user_acceptlang();
        $request = '<?xml version="1.0" encoding="utf-8"?' . '>
		<ews type="10" lang="' . $bw_code . '">
			<clientcode>' . Get::sett('code_teleskill') . '</clientcode>
			<roomid>' . $roomid . '</roomid>
			<complete>1</complete>
			</ews>';
        $xml_answer = $this->_sendXmlRequest($request);
        if ($xml_answer === false || $xml_answer === '') {
            return array('errorcode' => -1, 'errormessage' => '', 'roomid' => '');
        }
        //Test Answer
        /*$xml_answer =	'<?xml version="1.0" encoding="utf-8"?'.'>'
        		 .'<ews>'
        		.'<errorcode>0</errorcode>'
        		.'<errormessage></errormessage>'
        		.'<sessions>'
        		.'<session sid="1" uid="1039" role="2" date="2008-09-30 11:00:13" duration="3565"/>'
        		.'<session sid="2" uid="1097" role="1" date="2008-09-30 11:05:54" duration="3254"/>'
        		.'<session sid="3" uid="1098" role="1" date="2008-09-30 11:01:18" duration="3148"/>'
        		.'<session sid="4" uid="1099" role="1" date="2008-09-30 11:07:25" duration="3297"/>'
        		.'</sessions>'
        		.'</ews>';*/
        $dom_answer = new DoceboDOMDocument();
        $dom_answer->loadXML(trim($xml_answer));
        $dlist_code = $dom_answer->getElementsByTagName('errorcode');
        $dlist_msg = $dom_answer->getElementsByTagName('errormessage');
        $dnode_code = $dlist_code->item(0);
        $dnode_msg = $dlist_msg->item(0);
        $e_code = $dnode_code->textContent;
        $e_msg = $dnode_msg->textContent;
        if ($e_code == 0) {
            $this->clearRoomLog($roomid);
            $dlist_sessions = $dom_answer->getElementsByTagName('session');
            if ($dlist_sessions->length > 0) {
                $array_element = array();
                for ($i = 0; $i < $dlist_sessions->length; $i++) {
                    $node = $dlist_sessions->item($i);
                    if ((int) $node->getAttribute('uid') != 0) {
                        $gmt = date('P', fromDatetimeToTimestamp($node->getAttribute('date')));
                        $gmt_split = explode(':', $gmt);
                        $gmt_offset = (int) $gmt_split[0];
                        if (isset($array_element[$node->getAttribute('uid')])) {
                            $array_element[$node->getAttribute('uid')]['duration'] += $node->getAttribute('duration');
                            $array_element[$node->getAttribute('uid')]['role'] = $node->getAttribute('role');
                            $array_element[$node->getAttribute('uid')]['access']++;
                        } else {
                            $array_element[$node->getAttribute('uid')]['role'] = $node->getAttribute('role');
                            $array_element[$node->getAttribute('uid')]['date'] = date('Y-m-d H:i:s', fromDatetimeToTimestamp($node->getAttribute('date')) + $gmt_offset * 3600);
                            $array_element[$node->getAttribute('uid')]['duration'] = $node->getAttribute('duration');
                            $array_element[$node->getAttribute('uid')]['access'] = 1;
                        }
                    }
                }
                $query = "INSERT INTO " . $GLOBALS['prefix_scs'] . "_teleskill_log (roomid, idUser, role, date, duration, access)" . " VALUES";
                $first = true;
                foreach ($array_element as $id_user => $values) {
                    if (!$first) {
                        $query .= ", ";
                    } else {
                        $first = false;
                    }
                    $query .= " ('" . $roomid . "',\r\n\t\t\t\t\t\t\t\t'" . (int) $id_user . "',\r\n\t\t\t\t\t\t\t\t'" . $values['role'] . "',\r\n\t\t\t\t\t\t\t\t'" . $values['date'] . "',\r\n\t\t\t\t\t\t\t\t'" . $values['duration'] . "',\r\n\t\t\t\t\t\t\t\t'" . $values['access'] . "')";
                }
                $result = sql_query($query);
                return $result;
            }
            return true;
        }
        return array('errorcode' => $e_code, 'errormessage' => $e_msg, 'roomid' => '');
    }
 public function getusergaptabledata()
 {
     //read from input and prepare filter and pagination variables
     $id_fncrole = Get::req('id_fncrole', DOTY_INT, -1);
     $id_user = Get::req('id_user', DOTY_INT, -1);
     //TO DO: if $id_fncrole <= 0 ...
     $startIndex = Get::req('startIndex', DOTY_INT, 0);
     $results = Get::req('results', DOTY_INT, Get::sett('visuItem', 25));
     $rowsPerPage = Get::req('rowsPerPage', DOTY_INT, $results);
     $sort = Get::req('sort', DOTY_STRING, "");
     $dir = Get::req('dir', DOTY_STRING, "asc");
     $searchFilter = array('user' => $id_user);
     //get total from database and validate the results count
     $total = $this->model->getGapTotal($id_fncrole, $searchFilter);
     if ($startIndex >= $total) {
         if ($total < $results) {
             $startIndex = 0;
         } else {
             $startIndex = $total - $results;
         }
     }
     //set pagination argument
     $pagination = array('startIndex' => $startIndex, 'results' => $results, 'sort' => $sort, 'dir' => $dir);
     //read records from database
     $list = $this->model->getGapList($id_fncrole, $pagination, $searchFilter);
     //prepare the data for sending
     $acl_man = Docebo::user()->getAclManager();
     $output_results = array();
     if (is_array($list) && count($list) > 0) {
         foreach ($list as $idst => $record) {
             //prepare output record
             $_not_obtained = $record->last_assign_date == "";
             $_date_expire = $_not_obtained ? "" : date("Y-m-d H:i:s", fromDatetimeToTimestamp($record->last_assign_date) + $record->expiration * 86400);
             $output_results[] = array('last_assign_date' => $_not_obtained ? "" : Format::date($record->last_assign_date, 'datetime'), 'score_req' => $record->score_requested, 'score_got' => $record->score_got, 'competence' => $record->competence_name, 'id_competence' => $record->id_competence, 'type' => $record->type, 'expiration' => $record->expiration, 'is_expired' => $_not_obtained ? false : $_date_expire < date("Y-m-d H:i:s") && $record->expiration > 0, 'date_expire' => $_not_obtained ? '' : ($record->expiration > 0 ? Format::date($_date_expire, 'datetime') : Lang::t('_NEVER', 'standard')), 'gap' => $record->gap);
         }
     }
     $output = array('totalRecords' => $total, 'startIndex' => $startIndex, 'sort' => $sort, 'dir' => $dir, 'rowsPerPage' => $rowsPerPage, 'results' => count($list), 'records' => $output_results);
     echo $this->json->encode($output);
 }
Example #13
0
 /**
  * this function need the user course stat and calculate if the user can enter into the course or not
  * return the access status and the reason for a blocked access
  *
  * @return array 	on key 'can'' => true or false
  * 					on key 'reason' => it's possible to find this values : 'prerequisites', 'waiting',
  * 						'course_date', 'course_valid_time', 'user_status', 'course_status'
  * 					on key 'expiring_in' => report the day remaining before the course expire
  *
  */
 function canEnterCourse(&$course, $id_path = 0)
 {
     $db = DbConn::getInstance();
     // control if the user is in a status that cannot enter
     $now = time();
     $expiring = false;
     // if course has editions, evaluate these first of all
     if ($course['course_edition'] == "1") {
         // retrieve editions
         $select_edition = " SELECT e.date_begin, e.date_end ";
         $select_edition .= " FROM " . $GLOBALS["prefix_lms"] . "_course_editions AS e " . " JOIN " . $GLOBALS["prefix_lms"] . "_course_editions_user AS u ";
         $select_edition .= " WHERE e.status IN ('" . CST_AVAILABLE . "','" . CST_EFFECTIVE . "') AND e.id_course = '" . $course['idCourse'] . "' AND e.id_edition = u.id_edition AND u.id_user = '******'";
         $re_edition = sql_query($select_edition);
         $canEnd = false;
         $canStart = false;
         // evaluate date_begin and date_end only for active editions
         // if no editions is active returns subscription_expired
         while ($edition_elem = mysql_fetch_assoc($re_edition)) {
             if (is_null($edition_elem['date_end']) || $edition_elem['date_end'] == '0000-00-00' || strcmp(date('Y-m-d'), $edition_elem['date_end']) <= 0) {
                 $canEnd = $canEnd || true;
             }
             if ($canEnd && (is_null($edition_elem['date_begin']) || $edition_elem['date_begin'] == '0000-00-00' || strcmp(date('Y-m-d'), $edition_elem['date_begin']) >= 0)) {
                 $canStart = $canStart || true;
             }
         }
         if (!$canEnd) {
             return array('can' => false, 'reason' => 'course_edition_date_end');
         }
         if (!$canStart) {
             return array('can' => false, 'reason' => 'course_edition_date_begin', 'expiring_in' => 1);
         }
     }
     if ($course['date_end'] != '0000-00-00') {
         $time_end = fromDatetimeToTimestamp($course['date_end']);
         $exp_time = $time_end - $now;
         if ($exp_time > 0) {
             $expiring = round($exp_time / (24 * 60 * 60));
         }
     }
     if ($course['valid_time'] != '0' && $course['valid_time'] != '' && $course['date_first_access'] != '' && $course['level'] <= 3) {
         $time_first_access = fromDatetimeToTimestamp($course['date_first_access']);
         $exp_time = $time_first_access + $course['valid_time'] * 24 * 3600 - $now;
         $expiring = round($exp_time / (24 * 60 * 60));
         $expiring = $expiring == -0 ? 0 : $expiring;
         if ($exp_time < 0) {
             return array('can' => false, 'reason' => 'time_elapsed', 'expiring_in' => $expiring);
         }
     }
     $query = "SELECT date_begin_validity, date_expire_validity, status, level" . " FROM " . $GLOBALS['prefix_lms'] . "_courseuser" . " WHERE idCourse = '" . $course['idCourse'] . "'" . " AND idUser = '******'";
     list($date_begin_validity, $date_expire_validity, $status, $level) = $db->fetch_row(sql_query($query));
     if (!is_null($date_begin_validity) && $date_begin_validity !== '0000-00-00 00:00:00' && strcmp(date('Y-m-d H:i:s'), $date_begin_validity) <= 0) {
         return array('can' => false, 'reason' => 'subscription_not_started', 'expiring_in' => $expiring);
     }
     if (!is_null($date_expire_validity) && $date_expire_validity !== '0000-00-00 00:00:00' && strcmp(date('Y-m-d H:i:s'), $date_expire_validity) >= 0) {
         return array('can' => false, 'reason' => 'subscription_expired', 'expiring_in' => $expiring);
     }
     if ($course['course_status'] == CST_CANCELLED) {
         return array('can' => false, 'reason' => 'course_status', 'expiring_in' => $expiring);
     }
     if ($course['course_status'] == CST_PREPARATION) {
         if ($level > 3) {
             return array('can' => true, 'reason' => 'user_status', 'expiring_in' => $expiring);
         } else {
             return array('can' => false, 'reason' => 'course_status', 'expiring_in' => $expiring);
         }
     }
     if ($course['course_status'] == CST_CONCLUDED) {
         if ($status == _CUS_END || $level > 3) {
             return array('can' => true, 'reason' => 'user_status', 'expiring_in' => $expiring);
         } else {
             return array('can' => false, 'reason' => 'course_status', 'expiring_in' => $expiring);
         }
     }
     //if($course['user_status'] == _CUS_CANCELLED) return array('can' => false, 'reason' => 'user_status');
     if ($course['level'] > 3) {
         return array('can' => true, 'reason' => '', 'expiring_in' => $expiring);
     }
     if (isset($course['prerequisites_satisfied']) && $course['prerequisites_satisfied'] == false) {
         return array('can' => false, 'reason' => 'prerequisites', 'expiring_in' => $expiring);
     }
     if (isset($course['waiting']) && $course['waiting'] >= 1) {
         return array('can' => false, 'reason' => 'waiting', 'expiring_in' => $expiring);
     }
     // control if the course is elapsed
     if ($course['date_begin'] != '0000-00-00') {
         $time_begin = fromDatetimeToTimestamp($course['date_begin']);
         if ($now < $time_begin) {
             return array('can' => false, 'reason' => 'course_date', 'expiring_in' => $expiring);
         }
     }
     if ($course['date_end'] != '0000-00-00') {
         $time_end = fromDatetimeToTimestamp($course['date_end']);
         if ($now > $time_end) {
             return array('can' => false, 'reason' => 'course_date', 'expiring_in' => $expiring);
         }
     }
     if ($course['valid_time'] != '0' && $course['valid_time'] != '' && $course['date_first_access'] != '') {
         $time_first_access = fromDatetimeToTimestamp($course['date_first_access']);
         if ($now > $time_first_access + $course['valid_time'] * 24 * 3600) {
             return array('can' => true, 'reason' => 'course_valid_time', 'expiring_in' => $expiring);
         }
     }
     if ($course['userStatusOp'] & 1 << $course['user_status']) {
         return array('can' => false, 'reason' => 'user_status', 'expiring_in' => $expiring);
     }
     //Control user coursepath prerequisite
     $query = "SELECT cc.prerequisites " . " FROM %lms_coursepath_courses AS cc " . " JOIN %lms_coursepath_user AS cu ON cc.id_path = cu.id_path " . " WHERE cu.idUser = "******" " . " AND cc.id_item = " . (int) $course['idCourse'] . " " . ($id_path != 0 ? " AND cc.id_path = " . (int) $id_path : '');
     $result = sql_query($query);
     $control_cicle = 0;
     while (list($prerequisites) = sql_fetch_row($result)) {
         if ($prerequisites !== '') {
             $num_prerequisites = count(explode(',', $prerequisites));
             $control_cicle++;
             $query = "SELECT COUNT(*) " . " FROM %lms_courseuser " . " WHERE idCourse IN (" . $prerequisites . ") " . " AND idUser = "******" " . " AND status = " . _CUS_END;
             list($control) = sql_fetch_row(sql_query($query));
             if ($control >= $num_prerequisites) {
                 return array('can' => true, 'reason' => 'prerequisites', 'expiring_in' => $expiring);
             }
         }
     }
     if ($control_cicle > 0) {
         return array('can' => false, 'reason' => 'prerequisites', 'expiring_in' => $expiring);
     }
     // user is not a tutor or a prof and the course isn't active
     if ($course['course_status'] != 1 && $course['level'] < 4) {
         return array('can' => true, 'reason' => 'course_status', 'expiring_in' => $expiring);
     }
     return array('can' => true, 'reason' => '', 'expiring_in' => $expiring);
 }
Example #14
0
 function confirmRegister($platform, $options)
 {
     $lang =& DoceboLanguage::createInstance('register', $platform);
     $acl_man =& Docebo::user()->getAclManager();
     $acl =& Docebo::user()->getAcl();
     if (!isset($_GET['random_code'])) {
     }
     $random_code = $_GET['random_code'];
     if (strpos($random_code, '?') !== false) {
         $random_code = substr($random_code, 0, strpos($random_code, '?'));
     }
     $request = $acl_man->getTempUserInfo(false, $random_code);
     if (time() > fromDatetimeToTimestamp($request['request_on']) + 3600 * (int) $options['hour_request_limit']) {
         $out = '<div class="reg_err_data">' . $lang->def('_REG_ELAPSEDREQUEST', 'register') . '</div>';
         $time_limit = time() - 3600 * (int) $options['hour_request_limit'];
         if (Get::sett('registration_code_type', '0') == 'code_module') {
             // free the code from the old association
             require_once _adm_ . '/lib/lib.code.php';
             $code_manager = new CodeManager();
             $code_manager->resetUserAssociation($code, $request['idst']);
         }
         $acl_man->deleteTempUser(false, false, $time_limit, true);
         return $out;
     }
     if ($options['register_type'] == 'self' || $options['register_type'] == 'self_optin') {
         if ($acl_man->registerUser(addslashes($request['userid']), addslashes($request['firstname']), addslashes($request['lastname']), $request['pass'], addslashes($request['email']), '', '', true, $request['idst'], '', '', $request['facebook_id'], $request['twitter_id'], $request['linkedin_id'], $request['google_id'])) {
             // $google_id
             // remove temporary enter
             $acl_man->deleteTempUser($request['idst'], false, false, false);
             $acl_man->updateUser($request['idst'], FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, date("Y-m-d H:i:s"));
             // subscribe to base group
             $idst_usergroup = $acl_man->getGroup(false, ADMIN_GROUP_USER);
             $idst_usergroup = $idst_usergroup[ACL_INFO_IDST];
             $idst_oc = $acl_man->getGroup(false, '/oc_0');
             $idst_oc = $idst_oc[ACL_INFO_IDST];
             $idst_ocd = $acl_man->getGroup(false, '/ocd_0');
             $idst_ocd = $idst_ocd[ACL_INFO_IDST];
             $acl_man->addToGroup($idst_usergroup, $request['idst']);
             $acl_man->addToGroup($idst_oc, $request['idst']);
             $acl_man->addToGroup($idst_ocd, $request['idst']);
             //  aggiunta notifica UserNewWaiting
             require_once _base_ . "/lib/lib.eventmanager.php";
             // set as recipients all who can approve a waiting user
             $msg_c_new = new EventMessageComposer();
             $msg_c_new->setSubjectLangText('email', '_TO_NEW_USER_SBJ', false);
             $msg_c_new->setBodyLangText('email', '_TO_NEW_USER_TEXT', array('[url]' => Get::sett('url')));
             $msg_c_new->setBodyLangText('sms', '_TO_NEW_USER_TEXT_SMS', array('[url]' => Get::sett('url')));
             $idst_approve = $acl->getRoleST('/framework/admin/directory/approve_waiting_user');
             $recipients = $acl_man->getAllRoleMembers($idst_approve);
             if (!empty($recipients)) {
                 createNewAlert('UserNewWaiting', 'directory', 'edit', '1', 'User waiting for approvation', $recipients, $msg_c_new);
             }
             // end
             $out = '<div class="reg_success">' . $lang->def('_REG_YOUR_ABI_TO_ACCESS', 'register') . '</div>';
             return $out;
         } else {
             $out = '<div class="reg_err_data">' . $lang->def('_REG_CONFIRM_FAILED', 'register') . '</div>';
             return $out;
         }
     } elseif ($options['register_type'] == 'moderate') {
         if ($acl_man->confirmTempUser($request['idst'])) {
             if (Get::sett('use_code_module') == 'on') {
                 require_once $GLOBALS['where_framework'] . '/lib/lib.code.php';
                 $code_manager = new CodeManager();
                 $code = $code_manager->getCodeAssociate($request['idst']);
                 if ($code !== false) {
                     $array_course = $code_manager->getCourseAssociateWithCode($code);
                     $array_folder = $code_manager->getOrgAssociateWithCode($code);
                     if (count($array_course)) {
                         foreach ($array_course as $id_course) {
                             require_once $GLOBALS['where_lms'] . '/lib/lib.subscribe.php';
                             $subscribe = new CourseSubscribe_Management();
                             $subscribe->subscribeUser($request['idst'], $id_course, '3');
                         }
                     }
                     if (count($array_folder)) {
                         foreach ($array_folder as $id_folder) {
                             $group = $acl_man->getGroup($id_folder, false);
                             $group_d = $acl_man->getGroup(false, '/ocd_' . str_replace('/oc_', '', $group[ACL_INFO_GROUPID]));
                             if ($group) {
                                 $acl_man->addToGroup($group[ACL_INFO_IDST], $request['idst']);
                             }
                             if ($group_d) {
                                 $acl_man->addToGroup($group_d[ACL_INFO_IDST], $request['idst']);
                             }
                         }
                     }
                 }
             }
             $out = '<div class="reg_success">' . Lang::t('_REG_WAIT_FOR_ADMIN_OK', 'register') . '</div>';
             // send alert to admin that can approve
             require_once _base_ . "/lib/lib.eventmanager.php";
             // set as recipients all who can approve a waiting user
             $msg_c_approve = new EventMessageComposer();
             $msg_c_approve->setSubjectLangText('email', '_TO_APPROVE_USER_SBJ', false);
             $msg_c_approve->setBodyLangText('email', '_TO_APPROVE_USER_TEXT', array('[url]' => Get::sett('url')));
             $msg_c_approve->setBodyLangText('sms', '_TO_APPROVE_USER_TEXT_SMS', array('[url]' => Get::sett('url')));
             $idst_approve = $acl->getRoleST('/framework/admin/directory/approve_waiting_user');
             $recipients = $acl_man->getAllRoleMembers($idst_approve);
             if (!empty($recipients)) {
                 createNewAlert('UserNewModerated', 'directory', 'edit', '1', 'User waiting for approvation', $recipients, $msg_c_approve);
             }
             return $out;
         } else {
             $out = '<div class="reg_err_data">' . $lang->def('_REG_CONFIRM_FAILED', 'register') . '</div>';
             return $out;
         }
     }
 }
Example #15
0
function getArrayGap($from, $to, $convert = false)
{
    // yyyy-mm-dd hh:mm:ss
    // 0123456789012345678
    if ($convert !== false) {
        $from = fromDatetimeToTimestamp($from);
        $to = fromDatetimeToTimestamp($to);
    }
    $distance = abs($from - $to);
    $gap = $distance = (int) ($distance / 60);
    //< 1 hour print minutes
    if ($distance >= 0 && $distance < 60) {
        return $distance . ' ' . Lang::t('_MINUTES');
    }
    //minutes -> hour
    $distance = (int) ($distance / 60);
    if ($distance >= 0 && $distance < 60) {
        return $distance . ' ' . Lang::t('_HOURS');
    }
    //hour -> day
    $distance = (int) ($distance / 24);
    if ($distance >= 0 && $distance < 30) {
        return $distance . ' ' . Lang::t('_DAYS');
    }
    //echo > 1 month
    return Lang::t('_ONEMONTH');
}