function &getStudentId()
 {
     require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
     $course_user = array();
     $course_man = new Man_Course();
     $course_user = $course_man->getIdUserOfLevel($_SESSION['idCourse'], 3);
     return $course_user;
 }
 public function completedTask()
 {
     $model = new AssessmentLms();
     $courselist = $model->findAll(array('cu.iduser = :id_user', 'cu.status = :status', 'c.course_type = ":course_type"'), array(':id_user' => Docebo::user()->getId(), ':status' => _CUS_END, ':course_type' => 'assessment'));
     //check courses accessibility
     $keys = array_keys($courselist);
     for ($i = 0; $i < count($keys); $i++) {
         $courselist[$keys[$i]]['can_enter'] = Man_Course::canEnterCourse($courselist[$keys[$i]]);
     }
     $this->render('courselist', array('path_course' => $this->path_course, 'courselist' => $courselist));
 }
 public function add()
 {
     require_once _lms_ . '/lib/lib.course.php';
     //Course info
     $id_course = Get::req('id_course', DOTY_INT, 0);
     $course_info = Man_Course::getCourseInfo($id_course);
     $model = new EditionLms($id_course);
     if (isset($_POST['undo'])) {
         Util::jump_to('index.php?r=edition/show&id_course=' . $model->getIdCourse());
     } elseif (isset($_POST['ins'])) {
         if ($model->addEdition()) {
             Util::jump_to('index.php?r=edition/show&id_course=' . $model->getIdCourse() . '&result=ok');
         }
         Util::jump_to('index.php?r=edition/show&id_course=' . $model->getIdCourse() . '&result=err_ins');
     } else {
         $this->render('add', array('model' => $model, 'course_info' => $course_info));
     }
 }
 public function add()
 {
     if (!$this->permissions['add']) {
         $this->render('invalid', array('message' => $this->_getMessage('no permission'), 'back_url' => 'index.php?r=alms/communication/show'));
         return;
     }
     require_once _lms_ . '/lib/lib.course.php';
     //Course info
     $id_course = Get::req('id_course', DOTY_INT, 0);
     $course_info = Man_Course::getCourseInfo($id_course);
     $model = new EditionAlms($id_course);
     if (isset($_POST['undo'])) {
         Util::jump_to('index.php?r=' . $this->base_link_edition . '/show&id_course=' . $model->getIdCourse());
     } elseif (isset($_POST['ins'])) {
         if ($model->addEdition()) {
             Util::jump_to('index.php?r=' . $this->base_link_edition . '/show&id_course=' . $model->getIdCourse() . '&result=ok');
         }
         Util::jump_to('index.php?r=' . $this->base_link_edition . '/show&id_course=' . $model->getIdCourse() . '&result=err_ins');
     } else {
         $this->render('add', array('model' => $model, 'course_info' => $course_info, 'base_link_course' => $this->base_link_course, 'base_link_edition' => $this->base_link_edition));
     }
 }
Exemple #5
0
 public function getClassrooms($params)
 {
     require_once _lms_ . '/lib/lib.course.php';
     require_once _lms_ . '/lib/lib.date.php';
     $output = array();
     $output['success'] = true;
     $course_id = isset($params['course_id']) ? (int) $params['course_id'] : false;
     $course_code = isset($params['course_code']) ? $params['course_code'] : false;
     if (empty($course_id) && empty($course_code)) {
         return false;
         // return array('success'=>true, 'debug'=>print_r($params, true));
     } else {
         if (empty($course_id) && !empty($course_code)) {
             // grab course info by code:
             $db = DbConn::getInstance();
             $qtxt = "SELECT * FROM %lms_course\r\n\t\t\t\t\tWHERE code='" . $course_code . "'\r\n\t\t\t\t\tLIMIT 0,1";
             $q = $db->query($qtxt);
             $course_info = $db->fetch_assoc($q);
             if (!empty($course_info)) {
                 $course_id = (int) $course_info['idCourse'];
             } else {
                 // course not found
                 return false;
                 // return array('success'=>'true', 'debug'=>print_r($course_info));
             }
         }
     }
     $classroom_man = new DateManager();
     $course_list = $classroom_man->getCourseDate($course_id);
     $course_man = new Man_Course();
     $course = $course_man->getCourseInfo($course_id);
     foreach ($course_list as $key => $course_info) {
         $output[]['course_info'] = array('course_id' => $course['idCourse'], 'date_id' => $course_info['id_date'], 'code' => str_replace('&', '&amp;', $course_info['code']), 'course_name' => str_replace('&', '&amp;', $course_info['name']), 'course_description' => str_replace('&', '&amp;', $course_info['description']), 'status' => $course_info['status'], 'selling' => $course['selling'], 'price' => $course_info['price'], 'subscribe_method' => $course['subscribe_method'], 'sub_start_date' => $course_info['sub_start_date'], 'sub_end_date' => $course_info['sub_end_date'], 'date_begin' => $course_info['date_begin'], 'date_end' => $course_info['date_end'], 'num_day' => $course_info['num_day'], 'classroom' => $course_info['classroom'], 'course_link' => Get::sett('url') . _folder_lms_ . '/index.php?modname=course&amp;op=aula&amp;idCourse=' . $course['idCourse']);
     }
     //$output['debug']=print_r($course_list, true).print_r($course, true);
     return $output;
 }
Exemple #6
0
function showprofile()
{
    require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.lms_user_profile.php';
    $lang =& DoceboLanguage::createInstance('catalogue');
    $lang =& DoceboLanguage::createInstance('course');
    $id_user = importVar('id_user');
    $id_course = importVar('id_course');
    $man_course = new Man_Course();
    $course = $man_course->getCourseInfo($id_course);
    $profile = new LmsUserProfile($id_user);
    $profile->init('profile', 'framework', 'modname=login&op=showprofile&id_course' . $id_course . '&id_user='******'ap');
    $GLOBALS['page']->add(getTitleArea($lang->def('_NAME', 'catalogue'), 'catalogue') . '<div class="std_block">' . getBackUi('index.php?modname=login&amp;op=courselist&amp;id_parent=' . $course['idCategory'], $lang->def('_BACK')), 'content');
    $GLOBALS['page']->add('<p class="category_path">' . '<b>' . $lang->def('_CATEGORY_PATH') . ' :</b> ' . $man_course->getCategoryPath($course['idCategory'], $lang->def('_MAIN_CATEGORY'), $lang->def('_TITLE_CATEGORY_JUMP'), 'index.php?modname=login&amp;op=courselist', 'id_parent') . ' &gt; ' . $course['name'] . '</p>' . $profile->getProfile(getLogUserId()) . '</div>', 'content');
}
 function _get_delay_query($type = 'html', $report_data = NULL, $other = '')
 {
     if ($report_data == NULL) {
         $report_data =& $_SESSION['report_tempdata'];
     }
     $rdata =& $report_data['rows_filter'];
     $cdata =& $report_data['columns_filter'];
     $acl_man = new DoceboACLManager();
     $acl_man->include_suspended = TRUE;
     $course_man = new Man_Course();
     $alluser = $rdata['all_users'];
     $jump_url = '';
     $org_chart_subdivision = isset($cdata['org_chart_subdivision']) ? $cdata['org_chart_subdivision'] : false;
     $day_from_subscription = $cdata['day_from_subscription'] != "" ? $cdata['day_from_subscription'] : false;
     $day_until_course_end = $cdata['day_until_course_end'] != "" ? $cdata['day_until_course_end'] : false;
     $date_until_course_end = $cdata['date_until_course_end'] != "" ? $cdata['date_until_course_end'] : false;
     $report_type_completed = isset($cdata['report_type_completed']) ? $cdata['report_type_completed'] : false;
     $report_type_started = isset($cdata['report_type_started']) ? $cdata['report_type_started'] : false;
     $course_selected = $cdata['selected_courses'];
     $all_courses = $cdata['all_courses'];
     $order_by = isset($cdata['order_by']) ? $cdata['order_by'] : 'userid';
     $order_dir = isset($cdata['order_dir']) ? $cdata['order_dir'] : 'asc';
     $show_suspended = isset($cdata['show_suspended']) ? (bool) $cdata['show_suspended'] : false;
     if (!$alluser) {
         $user_selected =& $acl_man->getAllUsersFromIdst($rdata['users']);
     } else {
         $user_selected =& $acl_man->getAllUsersIdst();
     }
     $lang =& DoceboLanguage::createInstance('report', 'framework');
     $lang_u =& DoceboLanguage::CreateInstance('stats', 'lms');
     if (empty($user_selected)) {
         return $lang->def('_NULL_SELECTION');
     }
     if (empty($course_selected) && !$all_courses) {
         return $lang->def('_NULL_COURSE_SELECTION');
     }
     if (1 == 1) {
         $date_now = Format::date(date("Y-m-d H:i:s"));
         //set query suspended users condition
         $query_show_suspended = "u.valid = 1";
         //default condition
         switch ($show_suspended) {
             case "all":
                 $query_show_suspended = "";
                 break;
             case "suspended_only":
                 $query_show_suspended = " AND u.valid = 0 ";
                 break;
             case "active_only":
                 $query_show_suspended = " AND u.valid = 1 ";
                 break;
         }
         //set query order by param
         $_dir = "ASC";
         switch ($order_dir) {
             case "desc":
                 $_dir = "DESC";
                 break;
         }
         $query_order_by = "u.lastname, u.firstname, u.userid";
         switch ($order_by) {
             case 'firstname':
                 $query_order_by = "u.firstname " . $_dir . ", u.userid " . $_dir;
                 break;
             case 'lastname':
                 $query_order_by = "u.lastname " . $_dir . ", u.userid " . $_dir;
                 break;
             case 'email':
                 $query_order_by = "u.email " . $_dir . ", u.userid " . $_dir;
                 break;
             case 'status':
                 $query_order_by = "cu.status " . $_dir . ", u.userid " . $_dir . ", u.lastname " . $_dir;
                 break;
                 //case 'level': $query_order_by = "cu.level ".$_dir.", u.userid ".$_dir.", c.code ".$_dir.""; break;
             //case 'level': $query_order_by = "cu.level ".$_dir.", u.userid ".$_dir.", c.code ".$_dir.""; break;
             case 'date_subscription':
                 $query_order_by = "cu.date_inscr " . $_dir . ", u.userid " . $_dir . ", u.lastname " . $_dir;
                 break;
             case 'date_first_access':
                 $query_order_by = "cu.date_first_access " . $_dir . ", u.userid " . $_dir . ", u.lastname " . $_dir;
                 break;
             case 'date_last_access':
                 $query_order_by = "cu.date_last_access " . $_dir . ", u.userid " . $_dir . ", u.lastname " . $_dir;
                 break;
             case 'date_complete':
                 $query_order_by = "cu.date_complete " . $_dir . ", u.userid " . $_dir . ", u.lastname " . $_dir;
                 break;
         }
         $query_course_user = "******" . $GLOBALS['prefix_lms'] . "_courseuser AS cu " . " JOIN " . $GLOBALS['prefix_fw'] . "_user as u ON cu.idUser = u.idst\r\n\t\t\t\tWHERE cu.idCourse > 0 " . $query_show_suspended . ($alluser ? "" : " AND cu.idUser IN ( " . implode(',', $user_selected) . " ) ") . ($all_courses ? '' : " AND cu.idCourse IN (" . implode(',', $course_selected) . ")") . " ORDER BY " . $query_order_by;
         $re_course_user = sql_query($query_course_user);
         $element_to_print = array();
         $courses_codes = array();
         while (list($id_u, $id_c, $id_e, $date_inscr, $date_first_access, $date_complete, $status, $level, $date_last_access, $u_userid, $u_firstname, $u_lastname, $u_email, $u_valid) = sql_fetch_row($re_course_user)) {
             if ($level == '3') {
                 //$report_type === 'course_started' && $level == '3') {
                 $user_check = false;
                 $now_timestamp = mktime('0', '0', '0', date('m'), date('d'), date('Y'));
                 //check the condition on status (course started and/or completed)
                 $status_condition = $status != _CUS_END;
                 //&& $status != _CUS_SUSPEND;
                 if ($report_type_completed && !$report_type_started) {
                     $status_condition = $status_condition && $status == _CUS_BEGIN;
                 }
                 if ($report_type_started && !$report_type_completed) {
                     $status_condition = $status_condition && $status != _CUS_BEGIN;
                 }
                 if ($day_from_subscription) {
                     if ($status_condition) {
                         $user_timestamp = mktime('0', '0', '0', $date_inscr[5] . $date_inscr[6], $date_inscr[8] . $date_inscr[9] + $day_from_subscription, $date_inscr[0] . $date_inscr[1] . $date_inscr[2] . $date_inscr[3]);
                         if ($user_timestamp < $now_timestamp) {
                             $user_check = true;
                         }
                     }
                 }
                 if ($day_until_course_end) {
                     if ($status_condition) {
                         if ($id_e > 0) {
                             $query = "SELECT date_end" . " FROM " . $GLOBALS['prefix_lms'] . "_course_edition" . " WHERE idCourseEdition = '" . $id_e . "'";
                             list($date_end) = sql_fetch_row(sql_query($query));
                             $user_timestamp = mktime('0', '0', '0', $date_end[5] . $date_end[6], $date_end[8] . $date_end[9] - $day_until_course_end, $date_end[0] . $date_end[1] . $date_end[2] . $date_end[3]);
                             if ($user_timestamp < $now_timestamp) {
                                 $user_check = true;
                             }
                         } else {
                             $query = "SELECT date_end" . " FROM " . $GLOBALS['prefix_lms'] . "_course" . " WHERE idCourse = '" . $id_c . "'";
                             list($date_end) = sql_fetch_row(sql_query($query));
                             $user_timestamp = mktime('0', '0', '0', $date_end[5] . $date_end[6], $date_end[8] . $date_end[9] - $day_until_course_end, $date_end[0] . $date_end[1] . $date_end[2] . $date_end[3]);
                             if ($user_timestamp < $now_timestamp) {
                                 $user_check = true;
                             }
                         }
                     }
                 }
                 if ($date_until_course_end) {
                     if ($status_condition) {
                         if ($id_e > 0) {
                             $query = "SELECT COUNT(*)" . " FROM " . $GLOBALS['prefix_lms'] . "_course_edition" . " WHERE idCourseEdition = '" . $id_e . "'" . " AND date_end < '" . Format::dateDb($date_until_course_end, 'date') . "'";
                             list($control) = sql_fetch_row(sql_query($query));
                             if ($control) {
                                 $user_check = true;
                             }
                         } else {
                             $query = "SELECT COUNT(*)" . " FROM " . $GLOBALS['prefix_lms'] . "_course" . " WHERE idCourse = '" . $id_c . "'" . " AND date_end < '" . Format::dateDb($date_until_course_end, 'date') . "'";
                             list($control) = sql_fetch_row(sql_query($query));
                             if ($control) {
                                 $user_check = true;
                             }
                         }
                     }
                 }
                 if (!$date_until_course_end && !$day_from_subscription && !$date_until_course_end) {
                     if ($status_condition) {
                         $user_check = true;
                     }
                 }
                 if ($user_check) {
                     $course_info = $course_man->getCourseInfo($id_c);
                     //$user_detail = $acl_man->getUser($id_u, false);
                     $element_to_print[$id_c]['name'] = $course_info['name'];
                     $element_to_print[$id_c]['code'] = $course_info['code'];
                     $element_to_print[$id_c]['data'][] = array('idUser' => $id_u, 'idCourse' => $id_c, 'idCourseEdition' => $id_e, 'status' => $status, 'level' => $level, 'userid' => Docebo::aclm()->relativeId($u_userid), 'firstname' => $u_firstname, 'lastname' => $u_lastname, 'mail' => $u_email, 'suspended' => $u_valid <= 0, 'date_subscription' => $date_inscr, 'date_first_access' => $date_first_access, 'date_completed' => $date_complete, 'date_last_access' => $date_last_access);
                 }
             }
         }
         //backward compatibility
         $showed_columns = array();
         foreach ($cdata['showed_columns'] as $_column_key) {
             $showed_columns[] = $this->_check_delay_column($_column_key);
         }
         //print course table
         $this->_printTable_delay($type, $element_to_print, $showed_columns);
         if ($this->use_mail) {
             $this->_loadEmailActions();
         }
     }
 }
 function _get_courses_query($type = 'html', $report_data = NULL, $other = '')
 {
     require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
     require_once dirname(__FILE__) . '/report_tableprinter.php';
     if ($report_data == NULL) {
         $ref =& $_SESSION['report_tempdata'];
     } else {
         $ref =& $report_data;
     }
     $fw = $GLOBALS['prefix_fw'];
     $lms = $GLOBALS['prefix_lms'];
     $sel_all = $ref['rows_filter']['select_all'];
     $sel_type = $ref['rows_filter']['selection_type'];
     $selection = $ref['rows_filter']['selection'];
     $all_courses = $ref['columns_filter']['all_courses'];
     $courses = $ref['columns_filter']['selected_courses'];
     $cols =& $ref['columns_filter']['showed_columns'];
     $acl = new DoceboACLManager();
     $html = '';
     $man = new Man_Course();
     $courses_codes = $man->getAllCourses();
     if ($all_courses) {
         $courses = array();
         foreach ($courses_codes as $key => $val) {
             $courses[] = $key;
         }
     }
     /*
     		if(Docebo::user()->getUserLevelId() != ADMIN_GROUP_GODADMIN) {
     
     			// if the usre is a subadmin with only few course assigned
     			require_once(_base_.'/lib/lib.preference.php');
     			$adminManager = new AdminPreference();
     			$admin_tree = $adminManager->getAdminTree(Docebo::user()->getIdST());
     			$courses = array_intersect($courses, $admin_tree['courses']);
     		}
     */
     $increment = 0;
     if ($cols['completed']) {
         $increment++;
     }
     if ($cols['initinere']) {
         $increment++;
     }
     if ($cols['notstarted']) {
         $increment++;
     }
     if ($cols['show_percentages']) {
         $increment = $increment * 2;
     }
     /*
     		//admin users filter
     		$acl_man = Docebo::user()->getACLManager();
     		$userlevelid = Docebo::user()->getUserLevelId();
     		if ( $userlevelid != ADMIN_GROUP_GODADMIN ) {
     			require_once(_base_.'/lib/lib.preference.php');
     			$adminManager = new AdminPreference();
     			$admin_tree = $adminManager->getAdminTree(Docebo::user()->getIdST());
     			$admin_users = $acl_man->getAllUsersFromSelection($admin_tree);
     			$admin_users = array_unique($admin_users);
     		}*/
     $userlevelid = Docebo::user()->getUserLevelId();
     if ($userlevelid != ADMIN_GROUP_GODADMIN && !Docebo::user()->isAnonymous()) {
         //filter users
         $alluser = false;
         require_once _base_ . '/lib/lib.preference.php';
         $adminManager = new AdminPreference();
         $admin_users = $adminManager->getAdminUsers(Docebo::user()->getIdST());
         //$user_selected = array_intersect($user_selected, $admin_users);
         //unset($admin_users);
         //filter courses
         $admin_courses = $adminManager->getAdminCourse(Docebo::user()->getIdST());
         if ($all_courses) {
             $all_courses = false;
             $rs = sql_query("SELECT idCourse FROM %lms_course");
             $course_selected = array();
             while (list($id_course) = sql_fetch_row($rs)) {
                 $course_selected[] = $id_course;
             }
         }
         if (isset($admin_courses['course'][0])) {
             //No filter
         } elseif (isset($admin_courses['course'][-1])) {
             require_once _lms_ . '/lib/lib.catalogue.php';
             $cat_man = new Catalogue_Manager();
             $user_catalogue = $cat_man->getUserAllCatalogueId(Docebo::user()->getIdSt());
             if (count($user_catalogue) > 0) {
                 $courses = array(0);
                 foreach ($user_catalogue as $id_cat) {
                     $catalogue_course =& $cat_man->getCatalogueCourse($id_cat, true);
                     $courses = array_merge($courses, $catalogue_course);
                 }
                 foreach ($courses as $id_course) {
                     if ($id_course != 0) {
                         $admin_courses['course'][$id_course] = $id_course;
                     }
                 }
             } elseif (Get::sett('on_catalogue_empty', 'off') == 'on') {
                 //No filter
             }
             if (!empty($admin_courses['course'])) {
                 $_clist = array_values($admin_courses['course']);
                 $course_selected = array_intersect($course_selected, $_clist);
             } else {
                 $course_selected = array();
             }
         } else {
             $array_courses = array();
             $array_courses = array_merge($array_courses, $admin_courses['course']);
             if (!empty($admin_courses['coursepath'])) {
                 require_once _lms_ . '/lib/lib.coursepath.php';
                 $path_man = new Catalogue_Manager();
                 $coursepath_course =& $path_man->getAllCourses($admin_courses['coursepath']);
                 $array_courses = array_merge($array_courses, $coursepath_course);
             }
             if (!empty($admin_courses['catalogue'])) {
                 require_once _lms_ . '/lib/lib.catalogue.php';
                 $cat_man = new Catalogue_Manager();
                 foreach ($admin_courses['catalogue'] as $id_cat) {
                     $catalogue_course =& $cat_man->getCatalogueCourse($id_cat, true);
                     $array_courses = array_merge($array_courses, $catalogue_course);
                 }
             }
             $admin_courses['course'] = array_merge($admin_courses['course'], $array_courses);
             if (!empty($admin_courses['course'])) {
                 $_clist = array_values($admin_courses['course']);
                 $course_selected = array_intersect($course_selected, $_clist);
             } else {
                 $course_selected = array();
             }
         }
         unset($admin_courses);
     }
     switch ($sel_type) {
         case 'groups':
             //retrieve all labels
             $orgchart_labels = array();
             $query = "SELECT * FROM " . $fw . "_org_chart WHERE lang_code='" . getLanguage() . "'";
             $res = sql_query($query);
             while ($row = mysql_fetch_assoc($res)) {
                 $orgchart_labels[$row['id_dir']] = $row['translation'];
             }
             $labels = array();
             $query = "SELECT * FROM " . $fw . "_group WHERE (hidden='false' OR groupid LIKE '/oc_%' OR groupid LIKE '/ocd_%') AND type='free'";
             $res = sql_query($query);
             while ($row = mysql_fetch_assoc($res)) {
                 if ($row['hidden'] == 'false') {
                     $labels[$row['idst']] = $acl->relativeId($row['groupid']);
                 } else {
                     $temp = explode("_", $row['groupid']);
                     //echo '<div>'.print_r($temp,true).'</div>';
                     if ($temp[0] == '/oc') {
                         $labels[$row['idst']] = $temp[1] != 0 ? $orgchart_labels[$temp[1]] : '';
                     } elseif ($temp[0] == '/ocd') {
                         $labels[$row['idst']] = $temp[1] != 0 ? $orgchart_labels[$temp[1]] : '';
                     }
                 }
             }
             $tot_size = 2;
             $head1 = array(array('colspan' => 2, 'value' => $this->lang->def('_GROUPS')));
             $head2 = array($this->lang->def('_NAME'), $this->lang->def('_TOTAL'));
             foreach ($courses as $course) {
                 $head1[] = array('value' => ($courses_codes[$course]['code'] ? '[' . $courses_codes[$course]['code'] . '] ' : '') . $courses_codes[$course]['name'], 'colspan' => $increment);
                 if ($cols['completed']) {
                     $head2[] = $this->lang->def('_USER_STATUS_END');
                 }
                 if ($cols['completed'] && $cols['show_percentages']) {
                     $head2[] = _PERCENT_SIMBOL;
                 }
                 if ($cols['initinere']) {
                     $head2[] = $this->lang->def('_USER_STATUS_BEGIN');
                 }
                 if ($cols['initinere'] && $cols['show_percentages']) {
                     $head2[] = _PERCENT_SIMBOL;
                 }
                 if ($cols['notstarted']) {
                     $head2[] = $this->lang->def('_USER_STATUS_SUBS');
                 }
                 if ($cols['notstarted'] && $cols['show_percentages']) {
                     $head2[] = _PERCENT_SIMBOL;
                 }
                 $tot_size += $increment;
             }
             $buffer = new ReportTablePrinter($type, true);
             $buffer->openTable('', '');
             $buffer->openHeader();
             $buffer->addHeader($head1);
             $buffer->addHeader($head2);
             $buffer->closeHeader();
             $tot_users = 0;
             $course_stats = array();
             //for each group, retrieve label and user statistics
             foreach ($selection as $dir_id => $group_id) {
                 $group_users = $acl->getGroupAllUser($group_id);
                 if ($userlevelid != ADMIN_GROUP_GODADMIN && !Docebo::user()->isAnonymous()) {
                     $group_users = array_intersect($group_users, $admin_users);
                 }
                 $users_num = count($group_users);
                 $line = array();
                 $line[] = $labels[$group_id];
                 $line[] = $users_num;
                 $tot_users += $users_num;
                 if (count($group_users) > 0) {
                     $query = "SELECT cu.idUser, cu.idCourse, cu.status " . " FROM " . $lms . "_courseuser as cu, " . $lms . "_course as c, " . $fw . "_user as u " . " WHERE cu.idUser=u.idst AND cu.idCourse=c.idCourse " . " AND u.idst IN (" . implode(",", $group_users) . ") " . (!$all_courses ? " AND c.idCourse IN (" . implode(",", $courses) . " )" : "");
                     $res = sql_query($query);
                     //$tot_completed = 0;
                     while ($row = mysql_fetch_assoc($res)) {
                         if (!isset($course_stats[$row['idCourse']][$group_id])) {
                             $course_stats[$row['idCourse']][$group_id] = array('completed' => 0, 'initinere' => 0, 'notstarted' => 0, 'total' => 0);
                         }
                         switch ((int) $row['status']) {
                             case 2:
                                 $course_stats[$row['idCourse']][$group_id]['completed']++;
                                 break;
                             case 1:
                                 $course_stats[$row['idCourse']][$group_id]['initinere']++;
                                 break;
                             case 0:
                                 $course_stats[$row['idCourse']][$group_id]['notstarted']++;
                                 break;
                         }
                         $course_stats[$row['idCourse']][$group_id]['total']++;
                     }
                     foreach ($courses as $course) {
                         if (isset($course_stats[$course][$group_id])) {
                             if ($course_stats[$course][$group_id]['total'] == 0) {
                                 $dividend = 1;
                             } else {
                                 $dividend = $course_stats[$course][$group_id]['total'];
                             }
                             if ($cols['completed']) {
                                 $line[] = $course_stats[$course][$group_id]['completed'];
                             }
                             if ($cols['completed'] && $cols['show_percentages']) {
                                 $line[] = number_format(100.0 * $course_stats[$course][$group_id]['completed'] / $dividend, 2, ',', '') . _PERCENT_SIMBOL;
                             }
                             if ($cols['initinere']) {
                                 $line[] = $course_stats[$course][$group_id]['initinere'];
                             }
                             if ($cols['initinere'] && $cols['show_percentages']) {
                                 $line[] = number_format(100.0 * $course_stats[$course][$group_id]['initinere'] / $dividend, 2, ',', '') . _PERCENT_SIMBOL;
                             }
                             if ($cols['notstarted']) {
                                 $line[] = $course_stats[$course][$group_id]['notstarted'];
                             }
                             if ($cols['notstarted'] && $cols['show_percentages']) {
                                 $line[] = number_format(100.0 * $course_stats[$course][$group_id]['notstarted'] / $dividend, 2, ',', '') . _PERCENT_SIMBOL;
                             }
                         } else {
                             if ($cols['completed']) {
                                 $line[] = '0';
                             }
                             if ($cols['completed'] && $cols['show_percentages']) {
                                 $line[] = '0,00%';
                             }
                             if ($cols['initinere']) {
                                 $line[] = '0';
                             }
                             if ($cols['initinere'] && $cols['show_percentages']) {
                                 $line[] = '0,00%';
                             }
                             if ($cols['notstarted']) {
                                 $line[] = '0';
                             }
                             if ($cols['notstarted'] && $cols['show_percentages']) {
                                 $line[] = '0,00%';
                             }
                         }
                     }
                     //$line[] = $tot_completed;
                 } else {
                     foreach ($courses as $course) {
                         if ($cols['completed']) {
                             $line[] = '0';
                         }
                         if ($cols['completed'] && $cols['show_percentages']) {
                             $line[] = '0,00%';
                         }
                         if ($cols['initinere']) {
                             $line[] = '0';
                         }
                         if ($cols['initinere'] && $cols['show_percentages']) {
                             $line[] = '0,00%';
                         }
                         if ($cols['notstarted']) {
                             $line[] = '0';
                         }
                         if ($cols['notstarted'] && $cols['show_percentages']) {
                             $line[] = '0,00%';
                         }
                     }
                 }
                 $buffer->addLine($line);
             }
             $buffer->closeBody();
             //echo '<pre>'.print_r($course_stats,true).'</pre>';
             //calc totals
             $foot = array('', $tot_users);
             foreach ($courses as $course) {
                 $completed_total = 0;
                 $initinere_total = 0;
                 $notstarted_total = 0;
                 $total_total = 0;
                 foreach ($selection as $dir_id => $group_id) {
                     $completed_total += isset($course_stats[$course][$group_id]['completed']) ? $course_stats[$course][$group_id]['completed'] : 0;
                     $initinere_total += isset($course_stats[$course][$group_id]['initinere']) ? $course_stats[$course][$group_id]['initinere'] : 0;
                     $notstarted_total += isset($course_stats[$course][$group_id]['notstarted']) ? $course_stats[$course][$group_id]['notstarted'] : 0;
                     $total_total += isset($course_stats[$course][$group_id]['total']) ? $course_stats[$course][$group_id]['total'] : 0;
                 }
                 if ($cols['completed']) {
                     $foot[] = $completed_total;
                 }
                 if ($cols['completed'] && $cols['show_percentages']) {
                     $foot[] = $total_total != 0 ? number_format(100.0 * $completed_total / $total_total, 2, _DECIMAL_SEPARATOR, '') . _PERCENT_SIMBOL : '0' . _DECIMAL_SEPARATOR . '00' . _PERCENT_SIMBOL;
                 }
                 if ($cols['initinere']) {
                     $foot[] = $initinere_total;
                 }
                 if ($cols['initinere'] && $cols['show_percentages']) {
                     $foot[] = $total_total != 0 ? number_format(100.0 * $initinere_total / $total_total, 2, _DECIMAL_SEPARATOR, '') . _PERCENT_SIMBOL : '0' . _DECIMAL_SEPARATOR . '00' . _PERCENT_SIMBOL;
                 }
                 if ($cols['notstarted']) {
                     $foot[] = $notstarted_total;
                 }
                 if ($cols['notstarted'] && $cols['show_percentages']) {
                     $foot[] = $total_total != 0 ? number_format(100.0 * $notstarted_total / $total_total, 2, _DECIMAL_SEPARATOR, '') . _PERCENT_SIMBOL : '0' . _DECIMAL_SEPARATOR . '00' . _PERCENT_SIMBOL;
                 }
             }
             $buffer->setFoot($foot);
             $buffer->closeTable();
             $html .= $buffer->get();
             break;
         case 'users':
             $temp = array();
             // resolve the user selection
             $users =& $acl->getAllUsersFromIdst($selection);
             if ($userlevelid != ADMIN_GROUP_GODADMIN && !Docebo::user()->isAnonymous()) {
                 $users = array_intersect($users, $admin_users);
             }
             if (count($users) <= 0) {
                 $html .= '<p>' . $this->lang->def('_EMPTY_SELECTION') . '</p>';
                 break;
             }
             $query = "SELECT cu.idUser, cu.idCourse, cu.status, u.userId, c.code, u.firstname, u.lastname " . " FROM ( " . $lms . "_courseuser as cu " . " JOIN  " . $lms . "_course as c ON ( cu.idCourse = c.idCourse) ) " . " JOIN " . $fw . "_user as u ON (cu.idUser = u.idst)  " . " WHERE 1 " . " AND cu.idCourse IN (" . implode(",", $courses) . ") " . ($sel_all ? "" : " AND idUser IN (" . implode(",", $users) . ")") . "";
             $res = sql_query($query);
             while ($row = mysql_fetch_array($res)) {
                 if (!isset($temp[$row['idUser']])) {
                     $temp[$row['idUser']] = array('username' => $acl->relativeId($row['userId']), 'fullname' => $row['lastname'] . ' ' . $row['firstname'], 'courses' => array());
                 }
                 $temp[$row['idUser']]['courses'][$row['idCourse']] = $row['status'];
             }
             //echo '<pre>';
             //print_r($temp);
             //draw table
             $tot_size = 1;
             $head2 = array($this->lang->def('_USERNAME'), $this->lang->def('_FULLNAME'));
             $head1 = array(array('colspan' => 2, 'value' => $this->lang->def('_USER')));
             foreach ($courses as $course) {
                 $head1[] = array('value' => ($courses_codes[$course]['code'] ? '[' . $courses_codes[$course]['code'] . '] ' : '') . $courses_codes[$course]['name'], 'colspan' => $increment);
                 if ($cols['completed']) {
                     $head2[] = $this->lang->def('_USER_STATUS_END');
                 }
                 if ($cols['completed'] && $cols['show_percentages']) {
                     $head2[] = _PERCENT_SIMBOL;
                 }
                 if ($cols['initinere']) {
                     $head2[] = $this->lang->def('_USER_STATUS_BEGIN');
                 }
                 if ($cols['initinere'] && $cols['show_percentages']) {
                     $head2[] = _PERCENT_SIMBOL;
                 }
                 if ($cols['notstarted']) {
                     $head2[] = $this->lang->def('_USER_STATUS_SUBS');
                 }
                 if ($cols['notstarted'] && $cols['show_percentages']) {
                     $head2[] = _PERCENT_SIMBOL;
                 }
                 $tot_size += $increment;
             }
             $buffer = new ReportTablePrinter($type, true);
             $buffer->openTable('', '');
             $buffer->openHeader();
             $buffer->addHeader($head1);
             $buffer->addHeader($head2);
             $buffer->closeHeader();
             $completed_total = array();
             $initinere_total = array();
             $notstarted_total = array();
             $courses_total = array();
             foreach ($courses as $course) {
                 $completed_total[$course] = 0;
                 $initinere_total[$course] = 0;
                 $notstarted_total[$course] = 0;
                 $courses_total[$course] = 0;
             }
             $buffer->openBody();
             foreach ($temp as $id_user => $table_row) {
                 $line = array();
                 $line[] = $table_row['username'];
                 $line[] = $table_row['fullname'];
                 foreach ($courses as $course) {
                     if (isset($table_row['courses'][$course])) {
                         if ($cols['completed']) {
                             $line[] = $table_row['courses'][$course] == 2 ? 1 : 0;
                         }
                         if ($cols['completed'] && $cols['show_percentages']) {
                             $line[] = $table_row['courses'][$course] == 2 ? '100' . _DECIMAL_SEPARATOR . '00' . _PERCENT_SIMBOL : '0' . _PERCENT_SIMBOL;
                         }
                         if ($cols['initinere']) {
                             $line[] = $table_row['courses'][$course] == 1 ? 1 : 0;
                         }
                         if ($cols['initinere'] && $cols['show_percentages']) {
                             $line[] = $table_row['courses'][$course] == 1 ? '100' . _DECIMAL_SEPARATOR . '00' . _PERCENT_SIMBOL : '0' . _PERCENT_SIMBOL;
                         }
                         if ($cols['notstarted']) {
                             $line[] = $table_row['courses'][$course] == 0 ? 1 : 0;
                         }
                         if ($cols['notstarted'] && $cols['show_percentages']) {
                             $line[] = $table_row['courses'][$course] == 0 ? '100' . _DECIMAL_SEPARATOR . '00' . _PERCENT_SIMBOL : '0' . _PERCENT_SIMBOL;
                         }
                         switch ((int) $table_row['courses'][$course]) {
                             case 2:
                                 if (isset($completed_total[$course])) {
                                     $completed_total[$course] += 1;
                                 } else {
                                     $completed_course[$course] = 1;
                                 }
                                 break;
                             case 1:
                                 if (isset($initinere_total[$course])) {
                                     $initinere_total[$course] += 1;
                                 } else {
                                     $initinere_course[$course] = 1;
                                 }
                                 break;
                             case 0:
                                 if (isset($notstarted_total[$course])) {
                                     $notstarted_total[$course] += 1;
                                 } else {
                                     $notstarted_course[$course] = 1;
                                 }
                                 break;
                         }
                         if (isset($courses_total[$course])) {
                             $courses_total[$course] += 1;
                         } else {
                             $courses_total[$course] = 1;
                         }
                     } else {
                         if ($cols['completed']) {
                             $line[] = '0';
                         }
                         if ($cols['completed'] && $cols['show_percentages']) {
                             $line[] = '0' . _PERCENT_SIMBOL;
                         }
                         if ($cols['initinere']) {
                             $line[] = '0';
                         }
                         if ($cols['initinere'] && $cols['show_percentages']) {
                             $line[] = '0' . _PERCENT_SIMBOL;
                         }
                         if ($cols['notstarted']) {
                             $line[] = '0';
                         }
                         if ($cols['notstarted'] && $cols['show_percentages']) {
                             $line[] = '0' . _PERCENT_SIMBOL;
                         }
                         if (isset($courses_total[$course])) {
                             $courses_total[$course] += 1;
                         } else {
                             $courses_total[$course] = 1;
                         }
                     }
                 }
                 $buffer->addLine($line);
             }
             $buffer->closeBody();
             $totals_line = array('', '');
             foreach ($courses as $course) {
                 $completed_num = isset($completed_total[$course]) ? $completed_total[$course] : '0';
                 $initinere_num = isset($initinere_total[$course]) ? $initinere_total[$course] : '0';
                 $notstarted_num = isset($notstarted_total[$course]) ? $notstarted_total[$course] : '0';
                 $total_num = isset($courses_total[$course]) ? $courses_total[$course] : '0';
                 if ($cols['completed']) {
                     $totals_line[] = $completed_num;
                 }
                 if ($cols['completed'] && $cols['show_percentages']) {
                     $totals_line[] = $total_num != 0 ? number_format(100.0 * $completed_num / $total_num, 2, _DECIMAL_SEPARATOR, '') . _PERCENT_SIMBOL : '0' . _DECIMAL_SEPARATOR . '00' . _PERCENT_SIMBOL;
                 }
                 if ($cols['initinere']) {
                     $totals_line[] = $initinere_num;
                 }
                 if ($cols['initinere'] && $cols['show_percentages']) {
                     $totals_line[] = $total_num != 0 ? number_format(100.0 * $initinere_num / $total_num, 2, _DECIMAL_SEPARATOR, '') . _PERCENT_SIMBOL : '0' . _DECIMAL_SEPARATOR . '00' . _PERCENT_SIMBOL;
                 }
                 if ($cols['notstarted']) {
                     $totals_line[] = $notstarted_num;
                 }
                 if ($cols['notstarted'] && $cols['show_percentages']) {
                     $totals_line[] = $total_num != 0 ? number_format(100.0 * $notstarted_num / $total_num, 2, _DECIMAL_SEPARATOR, '') . _PERCENT_SIMBOL : '0' . _DECIMAL_SEPARATOR . '00' . _PERCENT_SIMBOL;
                 }
             }
             $buffer->setFoot($totals_line);
             $buffer->closeTable();
             $html .= $buffer->get();
             break;
     }
     return $html;
 }
Exemple #9
0
function assignMenu()
{
    checkPerm('mod');
    require_once _base_ . '/lib/lib.form.php';
    require_once _lms_ . '/lib/lib.course.php';
    if (isset($_POST['assign'])) {
        $id_course = importVar('id_course', true, 0);
        $id_custom = importVar('selected_menu', true, 0);
        $query_course = "SELECT course_type FROM " . $GLOBALS['prefix_lms'] . "_course WHERE idCourse = '" . $id_course . "'";
        list($course_type) = sql_fetch_row(sql_query($query_course));
        if ($course_type === 'classroom') {
            $url = 'index.php?r=alms/classroom/show&result=';
        } else {
            $url = 'index.php?modname=course&op=course_list&result=';
        }
        require_once $GLOBALS['where_lms'] . '/lib/lib.manmenu.php';
        require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
        $acl_man =& Docebo::user()->getAclManager();
        $course_man = new Man_Course();
        $levels =& $course_man->getCourseIdstGroupLevel($id_course);
        if (empty($levels) || implode('', $levels) == '') {
            $levels =& DoceboCourse::createCourseLevel($id_course);
        }
        $course_man->removeCourseRole($id_course);
        $course_man->removeCourseMenu($id_course);
        $course_idst =& $course_man->getCourseIdstGroupLevel($id_course);
        $result = cerateCourseMenuFromCustom($id_custom, $id_course, $course_idst);
        if ($_SESSION['idCourse'] == $id_course) {
            $query = "SELECT module.idModule, main.idMain\r\n\t\t\t\t\t\tFROM ( " . $GLOBALS['prefix_lms'] . "_menucourse_main AS main JOIN\r\n\t\t\t\t\t\t" . $GLOBALS['prefix_lms'] . "_menucourse_under AS un ) JOIN\r\n\t\t\t\t\t\t" . $GLOBALS['prefix_lms'] . "_module AS module\r\n\t\t\t\t\t\tWHERE main.idMain = un.idMain AND un.idModule = module.idModule\r\n\t\t\t\t\t\tAND main.idCourse = '" . (int) $_SESSION['idCourse'] . "'\r\n\t\t\t\t\t\tAND un.idCourse = '" . (int) $_SESSION['idCourse'] . "'\r\n\t\t\t\t\t\tORDER BY main.sequence, un.sequence\r\n\t\t\t\t\t\tLIMIT 0,1";
            list($id_module, $id_main) = sql_fetch_row(sql_query($query));
            $_SESSION['current_main_menu'] = $id_main;
            $_SESSION['sel_module_id'] = $id_module;
            //loading related ST
            Docebo::user()->loadUserSectionST('/lms/course/public/');
            Docebo::user()->SaveInSession();
        }
        Util::jump_to($url . ($result ? 'ok_course' : 'fail_course'));
    } else {
        $lang =& DoceboLanguage::CreateInstance('course', 'lms');
        //list($id_course) = each($_POST['assign_menu_course']);
        $id_course = importVar('id_course', true, 0);
        require_once _base_ . '/lib/lib.form.php';
        require_once $GLOBALS['where_lms'] . '/admin/modules/category/category.php';
        require_once $GLOBALS['where_lms'] . '/admin/modules/category/tree.category.php';
        require_once $GLOBALS['where_lms'] . '/lib/lib.manmenu.php';
        require_once $GLOBALS['where_framework'] . '/lib/lib.sessionsave.php';
        $form = new Form();
        $menu_custom = getAllCustom();
        $sel_custom = key($menu_custom);
        reset($menu_custom);
        $query_course = "SELECT course_type FROM " . $GLOBALS['prefix_lms'] . "_course WHERE idCourse = '" . $id_course . "'";
        list($course_type) = sql_fetch_row(sql_query($query_course));
        if ($course_type === 'classroom') {
            $url = 'index.php?r=alms/classroom/show';
        } else {
            $url = 'index.php?modname=course&op=course_list';
        }
        $title_area = array($url => $lang->def('_COURSE'), $lang->def('_ASSIGN_MENU'));
        $GLOBALS['page']->setWorkingZone('content');
        $GLOBALS['page']->add(getTitleArea($title_area, 'course') . '<div class="std_block">' . $form->openForm('course_creation', 'index.php?modname=course&amp;op=assignMenu') . $form->openElementSpace() . $form->getHidden('id_course', 'id_course', $id_course) . $form->getDropdown($lang->def('_COURSE_MENU_TO_ASSIGN'), 'selected_menu', 'selected_menu', $menu_custom, $sel_custom) . $form->closeElementSpace() . $form->openButtonSpace() . $form->getButton('assign', 'assign', $lang->def('_ASSIGN_USERS')) . $form->getButton('course_undo', 'course_undo', $lang->def('_UNDO')) . $form->closeButtonSpace() . $form->closeForm() . '</div>');
    }
}
function modAssignmentAssignMetaCertificate()
{
    checkPerm('mod');
    require_once _base_ . '/lib/lib.form.php';
    require_once $GLOBALS['where_framework'] . '/lib/lib.directory.php';
    require_once _base_ . '/lib/lib.userselector.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.course_managment.php';
    $lang =& DoceboLanguage::createInstance('certificate', 'lms');
    $id_certificate = importVar('id_certificate', true, 0);
    $id_meta = Get::req('idmeta', DOTY_INT, 0);
    $step = Get::req('step', DOTY_INT, 0);
    $out =& $GLOBALS['page'];
    $out->setWorkingZone('content');
    $acl_man =& Docebo::user()->getAclManager();
    $aclManager = new DoceboACLManager();
    $user_select = new UserSelector();
    $form = new Form();
    $sel = new Course_Manager();
    $course_man = new Man_Course();
    if (isset($_POST['okselector'])) {
        $user_selected = $user_select->getSelection($_POST);
        $_SESSION['meta_certificate']['users'] = $user_selected;
        $step++;
    }
    if (isset($_POST['import_filter'])) {
        $_SESSION['meta_certificate']['course'] = $sel->getCourseSelection($_POST);
        $step++;
    }
    if (isset($_POST['insert'])) {
        $step++;
    }
    if ($step == 3) {
        $array_user =& $aclManager->getAllUsersFromIdst($_SESSION['meta_certificate']['users']);
        $array_user = array_unique($array_user);
        $res = true;
        $user_reset = array();
        $course_reset = array();
        $reasign = array();
        //array reasign
        $query = "SELECT idUser, idCourse" . " FROM " . $GLOBALS['prefix_lms'] . "_certificate_meta_course" . " WHERE idMetaCertificate = '" . $id_meta . "'";
        $result = sql_query($query);
        while (list($id_user, $id_course) = sql_fetch_row($result)) {
            $reasign[$id_user][$id_course] = 1;
        }
        //array user_reset
        $query = "SELECT DISTINCT idUser" . " FROM " . $GLOBALS['prefix_lms'] . "_certificate_meta_course" . " WHERE idMetaCertificate = '" . $id_meta . "'";
        $result = sql_query($query);
        while (list($id_user) = sql_fetch_row($result)) {
            $user_reset[$id_user] = $id_user;
        }
        //array course_reset
        $query = "SELECT DISTINCT idCourse" . " FROM " . $GLOBALS['prefix_lms'] . "_certificate_meta_course" . " WHERE idMetaCertificate = '" . $id_meta . "'";
        $result = sql_query($query);
        while (list($id_course) = sql_fetch_row($result)) {
            $course_reset[$id_course] = $id_course;
        }
        //finish array initialization
        $query_course = "INSERT INTO " . $GLOBALS['prefix_lms'] . "_certificate_meta_course (idMetaCertificate, idUser, idCourse)" . " VALUES ";
        $first = true;
        $array_user_flipped = array_flip($array_user);
        foreach ($user_reset as $id_user) {
            if (!isset($array_user_flipped[$id_user])) {
                $query = "DELETE FROM " . $GLOBALS['prefix_lms'] . "_certificate_meta_course" . " WHERE idUser = '******'" . " AND idMetaCertificate = '" . $id_meta . "'";
                if (!sql_query($query)) {
                    $res = false;
                }
            }
        }
        if (!$res) {
            Util::jump_to('index.php?modname=meta_certificate&op=assign&id_certificate=' . $id_certificate . '&res=error_mod_assign');
        }
        foreach ($course_reset as $id_course) {
            if (!isset($_SESSION['meta_certificate']['course'][$id_course])) {
                $query = "DELETE FROM " . $GLOBALS['prefix_lms'] . "_certificate_meta_course" . " WHERE idCourse = '" . $id_course . "'" . " AND idMetaCertificate = '" . $id_meta . "'";
                if (!sql_query($query)) {
                    $res = false;
                }
            }
        }
        if (!$res) {
            Util::jump_to('index.php?modname=meta_certificate&op=assign&id_certificate=' . $id_certificate . '&res=error_mod_assign');
        }
        reset($_SESSION['meta_certificate']['course']);
        foreach ($array_user as $id_user) {
            foreach ($_SESSION['meta_certificate']['course'] as $id_course) {
                if (isset($_POST['_' . $id_user . '_' . $id_course . '_'])) {
                    if (!isset($reasign[$id_user][$id_course])) {
                        if ($first) {
                            $query_course .= "('" . $id_meta . "', '" . $id_user . "', '" . $id_course . "')";
                            $first = false;
                        } else {
                            $query_course .= ", ('" . $id_meta . "', '" . $id_user . "', '" . $id_course . "')";
                        }
                    }
                } else {
                    if (isset($reasign[$id_user][$id_course])) {
                        $query = "DELETE FROM " . $GLOBALS['prefix_lms'] . "_certificate_meta_course" . " WHERE idUser = '******'" . " AND idCourse = '" . $id_course . "'" . " AND idMetaCertificate = '" . $id_meta . "'";
                        if (!sql_query($query)) {
                            $res = false;
                        }
                    }
                }
            }
        }
        if (!$res) {
            Util::jump_to('index.php?modname=meta_certificate&op=assign&id_certificate=' . $id_certificate . '&res=error_mod_assign');
        }
        $res = sql_query($query_course);
        if ($res) {
            Util::jump_to('index.php?modname=meta_certificate&op=assign&id_certificate=' . $id_certificate . '&res=ok');
        } else {
            Util::jump_to('index.php?modname=meta_certificate&op=assign&id_certificate=' . $id_certificate . '&res=error_mod_assign');
        }
    } elseif ($step == 2) {
        YuiLib::load();
        Util::get_js(Get::rel_path('base') . '/lib/js_utils.js', true, true);
        $tb = new Table(0, $lang->def('_META_CERTIFICATE_NEW_ASSIGN_CAPTION'), $lang->def('_META_CERTIFICATE_NEW_ASSIGN_SUMMARY'));
        $tb->setLink('index.php?modname=meta_certificate&amp;op=modassignment');
        $out->add(getTitleArea($lang->def('_TITLE_META_CERTIFICATE_ASSIGN'), 'certificate') . '<div class="std_block">' . $form->openForm('new_assign_step_2', 'index.php?modname=meta_certificate&amp;op=modassignment') . $form->getHidden('id_certificate', 'id_certificate', $id_certificate) . $form->getHidden('idmeta', 'idmeta', $id_meta) . $form->getHidden('step', 'step', 2) . $form->getHidden('reasign', 'reasign', 1));
        $reasign = array();
        if (!isset($_POST['reasign'])) {
            $query = "SELECT idUser, idCourse" . " FROM " . $GLOBALS['prefix_lms'] . "_certificate_meta_course" . " WHERE idMetaCertificate = '" . $id_meta . "'";
            $result = sql_query($query);
            while (list($id_user, $id_course) = sql_fetch_row($result)) {
                $reasign[$id_user][$id_course] = 1;
            }
        }
        $form_name = 'new_assign_step_2';
        $type_h = array('', '');
        $cont_h = array($lang->def('_FULLNAME'), $lang->def('_USERNAME'));
        foreach ($_SESSION['meta_certificate']['course'] as $id_course) {
            $type_h[] = 'align_center';
            $course_info = $course_man->getCourseInfo($id_course);
            $cont_h[] = $course_info['code'] . ' - ' . $course_info['name'];
        }
        $type_h[] = 'image';
        $cont_h[] = $lang->def('_CHECKALL');
        $type_h[] = 'image';
        $cont_h[] = $lang->def('_UNCHECKALL');
        $tb->setColsStyle($type_h);
        $tb->addHead($cont_h);
        reset($_SESSION['meta_certificate']['course']);
        $array_user =& $aclManager->getAllUsersFromIdst($_SESSION['meta_certificate']['users']);
        $array_user = array_unique($array_user);
        $query = "SELECT idst" . " FROM " . $GLOBALS['prefix_fw'] . "_user" . " WHERE idst IN (" . implode(',', $array_user) . ")" . " ORDER BY userid";
        $result = sql_query($query);
        $array_user = array();
        while (list($id_user) = sql_fetch_row($result)) {
            $array_user[] = $id_user;
        }
        foreach ($array_user as $id_user) {
            $cont = array();
            $user_info = $acl_man->getUser($id_user, false);
            $cont[] = $user_info[ACL_INFO_LASTNAME] . ' ' . $user_info[ACL_INFO_FIRSTNAME];
            $cont[] = $acl_man->relativeId($user_info[ACL_INFO_USERID]);
            foreach ($_SESSION['meta_certificate']['course'] as $id_course) {
                if (isset($_POST['_' . $id_user . '_' . $id_course . '_']) || isset($_POST['select_all']) || isset($reasign[$id_user][$id_course])) {
                    $checked = true;
                } else {
                    $checked = false;
                }
                $cont[] = $form->getCheckbox('', '_' . $id_user . '_' . $id_course . '_', '_' . $id_user . '_' . $id_course . '_', 1, $checked);
            }
            $cont[] = '<a href="javascript:;" onclick="checkall_fromback_meta(\'' . $form_name . '\', \'' . $id_user . '\', true); return false;">' . $lang->def('_CHECKALL') . '</a>';
            $cont[] = '<a href="javascript:;" onclick="checkall_fromback_meta(\'' . $form_name . '\', \'' . $id_user . '\', false); return false;">' . $lang->def('_UNCHECKALL') . '</a>';
            $tb->addBody($cont);
        }
        reset($_SESSION['meta_certificate']['course']);
        $cont = array();
        $cont[] = '';
        $cont[] = '';
        foreach ($_SESSION['meta_certificate']['course'] as $id_course) {
            $cont[] = '<a href="javascript:;" onclick="checkall_meta(\'' . $form_name . '\', \'' . $id_course . '\', true); return false;">' . $lang->def('_CHECKALL') . '</a><br/>' . '<a href="javascript:;" onclick="checkall_meta(\'' . $form_name . '\', \'' . $id_course . '\', false); return false;">' . $lang->def('_UNCHECKALL') . '</a>';
        }
        $cont[] = '';
        $cont[] = '';
        $tb->addBody($cont);
        $out->add($form->openElementSpace() . $tb->getTable() . $form->closeElementSpace() . $form->openButtonSpace() . $form->getButton('select_all', 'select_all', $lang->def('_SELECT_ALL')) . $form->getButton('insert', 'insert', $lang->def('_INSERT')) . $form->getButton('undo_assign', 'undo_assign', $lang->def('_UNDO')) . $form->closeButtonSpace() . $form->closeForm());
    } elseif ($step == 1) {
        $sel->setLink('index.php?modname=meta_certificate&amp;op=modassignment');
        $out->add(getTitleArea($lang->def('_TITLE_META_CERTIFICATE_ASSIGN'), 'certificate') . '<div class="std_block">' . $form->openForm('new_assign_step_1', 'index.php?modname=meta_certificate&amp;op=modassignment') . $form->getHidden('id_certificate', 'id_certificate', $id_certificate) . $form->getHidden('idmeta', 'idmeta', $id_meta) . $form->getHidden('step', 'step', 1) . $form->getHidden('course_reload', 'course_reload', 1));
        if (!isset($_POST['course_reload'])) {
            $query = "SELECT DISTINCT idCourse" . " FROM " . $GLOBALS['prefix_lms'] . "_certificate_meta_course" . " WHERE idMetaCertificate = '" . $id_meta . "'";
            $result = sql_query($query);
            $course_reset = array();
            while (list($id_course) = sql_fetch_row($result)) {
                $course_reset[$id_course] = $id_course;
            }
            $sel->resetCourseSelection($course_reset);
        }
        $sel->loadSelector();
        $out->add(Form::getHidden('update_tempdata', 'update_tempdata', 1) . Form::openButtonSpace() . Form::getBreakRow() . Form::getButton('ok_filter', 'import_filter', $lang->def('_NEXT')) . Form::getButton('undo_filter', 'undo_filter', $lang->def('_UNDO')) . Form::closeButtonSpace() . Form::closeForm() . '</div>');
    } else {
        $user_select->show_orgchart_simple_selector = FALSE;
        $user_select->multi_choice = TRUE;
        $user_select->addFormInfo($form->getHidden('step', 'step', 0) . $form->getHidden('id_certificate', 'id_certificate', $id_certificate) . $form->getHidden('idmeta', 'idmeta', $id_meta) . $form->getHidden('user_reload', 'user_reload', 1));
        $user_select->setPageTitle(getTitleArea($lang->def('_TITLE_META_CERTIFICATE_ASSIGN'), 'certificate') . '<div class="std_block">');
        if (!isset($_POST['user_reload'])) {
            $query = "SELECT DISTINCT idUser" . " FROM " . $GLOBALS['prefix_lms'] . "_certificate_meta_course" . " WHERE idMetaCertificate = '" . $id_meta . "'";
            $result = sql_query($query);
            $user_reset = array();
            while (list($id_user) = sql_fetch_row($result)) {
                $user_reset[$id_user] = $id_user;
            }
            $user_select->resetSelection($user_reset);
        }
        $user_select->loadSelector('index.php?modname=meta_certificate&amp;op=modassignment', false, $lang->def('_USER_FOR_META_CERTIFICATE_ASSIGN'), true);
    }
}
 public function getCourseInfoForSubscription()
 {
     if ($this->id_edition != 0) {
         require_once _lms_ . '/lib/lib.edition.php';
         $edition_man = new EditionManager();
         $edition_info = $edition_man->getEditionInfo($this->id_edition);
         require_once _lms_ . '/lib/lib.course.php';
         $course_info = Man_Course::getCourseInfo($this->id_course);
         $res = array('max_num_subscribe' => $edition_info['max_num_subscribe'], 'subscribe_method' => $course_info['subscribe_method'], 'code' => $edition_info['code'], 'name' => $edition_info['name'], 'medium_time' => $course_info['mediumTime'], 'course_type' => $course_info['course_type'], 'date_begin' => $edition_info['date_begin'], 'date_end' => $edition_info['date_end']);
     } elseif ($this->id_date != 0) {
         require_once _lms_ . '/lib/lib.date.php';
         $date_man = new DateManager();
         $date_info = $date_man->getDateInfo($this->id_date);
         require_once _lms_ . '/lib/lib.course.php';
         $course_info = Man_Course::getCourseInfo($this->id_course);
         $res = array('max_num_subscribe' => $course_info['max_num_subscribe'], 'subscribe_method' => $course_info['subscribe_method'], 'code' => $date_info['code'], 'name' => $date_info['name'], 'medium_time' => $course_info['mediumTime'], 'course_type' => $course_info['course_type'], 'date_begin' => $date_info['date_begin'], 'date_end' => $date_info['date_end']);
     } else {
         require_once _lms_ . '/lib/lib.course.php';
         $course_info = Man_Course::getCourseInfo($this->id_course);
         $res = array('max_num_subscribe' => $course_info['max_num_subscribe'], 'subscribe_method' => $course_info['subscribe_method'], 'code' => $course_info['code'], 'name' => $course_info['name'], 'medium_time' => $course_info['mediumTime'], 'course_type' => $course_info['course_type'], 'date_begin' => $course_info['date_begin'], 'date_end' => $course_info['date_end']);
     }
     return $res;
 }
Exemple #12
0
 function upcourseinfo()
 {
     checkPerm('mod');
     $array_lang = Docebo::langManager()->getAllLangCode();
     $user_status = 0;
     if (isset($_POST['user_status'])) {
         while (list($status) = each($_POST['user_status'])) {
             $user_status |= 1 << $status;
         }
     }
     $file_sponsor = '';
     $file_logo = '';
     $re = true;
     $show_level = 0;
     if (isset($_POST['course_show_level'])) {
         while (list($lv) = each($_POST['course_show_level'])) {
             $show_level |= 1 << $lv;
         }
     }
     $query_course = "\r\n\tUPDATE " . $GLOBALS['prefix_lms'] . "_course \r\n\tSET code = '" . $_POST['course_code'] . "', \r\n\t\tname = '" . $_POST['course_name'] . "', \r\n\t\tdescription = '" . $_POST['course_descr'] . "', \r\n\t\tlang_code = '" . $array_lang[$_POST['course_lang']] . "', \r\n\t\tstatus = '" . (int) $_POST['course_status'] . "', \r\n\t\tlevel_show_user = '******', \r\n\t\tmediumTime = '" . $_POST['course_medium_time'] . "',\r\n\t\tpermCloseLO = '" . $_POST['course_em'] . "', \r\n\t\tuserStatusOp = '" . $user_status . "', \r\n\t\tdifficult = '" . $_POST['course_difficult'] . "', \r\n\t\tshow_progress = '" . (isset($_POST['course_progress']) ? 1 : 0) . "', \r\n\t\tshow_time = '" . (isset($_POST['course_time']) ? 1 : 0) . "', \r\n\t\tshow_extra_info = '" . (isset($_POST['course_advanced']) ? 1 : 0) . "', \r\n\t\tshow_rules = '" . (int) $_POST['course_show_rules'] . "' \r\n\tWHERE idCourse = '" . $_SESSION['idCourse'] . "'";
     if (!sql_query($query_course)) {
         $re = false;
     }
     $acl_man =& Docebo::user()->getAclManager();
     // send alert
     require_once _base_ . '/lib/lib.eventmanager.php';
     $msg_composer = new EventMessageComposer();
     $msg_composer->setSubjectLangText('email', '_ALERT_SUBJECT_MODCOURSE_INFO', false);
     $msg_composer->setBodyLangText('email', '_ALERT_TEXT_MODCOURSE_INFO', array('[url]' => Get::sett('url'), '[course_code]' => $_POST['course_code'], '[course]' => $_POST['course_name']));
     $msg_composer->setBodyLangText('sms', '_ALERT_TEXT_MODCOURSE_INFO_SMS', array('[url]' => Get::sett('url'), '[course_code]' => $_POST['course_code'], '[course]' => $_POST['course_name']));
     require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
     $course_man = new Man_Course();
     $recipients = $course_man->getIdUserOfLevel($_SESSION['idCourse']);
     createNewAlert('CoursePorpModified', 'course', 'add', '1', 'Inserted course ' . $_POST['course_name'], $recipients, $msg_composer);
     Util::jump_to('index.php?modname=course&op=infocourse&result=' . ($re ? 'ok' : 'err'));
 }
Exemple #13
0
/**
 * Save notification of user status in a course
 * @param int $idUser id of the user
 * @param int $idCourse id of the course
 * @param int $status new status
 **/
function saveTrackStatusChange($idUser, $idCourse, $status)
{
    require_once _lms_ . '/lib/lib.course.php';
    list($prev_status) = sql_fetch_row(sql_query("\r\n\t\tSELECT status\r\n\t\tFROM %lms_courseuser\r\n\t\tWHERE idUser = '******' AND idCourse = '" . (int) $idCourse . "'"));
    $extra = '';
    if ($prev_status != $status) {
        switch ($status) {
            case _CUS_SUBSCRIBED:
                //approved subscriptin for example
                $extra = ", date_inscr = NOW()";
                break;
            case _CUS_BEGIN:
                //first access
                UpdatesLms::resetCache();
                $extra = ", date_first_access = NOW()";
                break;
            case _CUS_END:
                //end course
                $extra = ", date_complete = NOW()";
                break;
        }
    }
    if (!sql_query("\r\n\tUPDATE %lms_courseuser\r\n\tSET status = '" . (int) $status . "' " . $extra . "\r\n\tWHERE idUser = '******' AND idCourse = '" . (int) $idCourse . "'")) {
        return false;
    }
    $re = sql_query("\r\n\tSELECT when_do \r\n\tFROM %lms_statuschangelog\r\n\tWHERE status_user = '******' AND \r\n\t\tidUser = '******' AND \r\n\t\tidCourse = '" . (int) $idCourse . "'");
    if (sql_num_rows($re)) {
        sql_query("\r\n\t\t\tUPDATE %lms_statuschangelog\r\n\t\t\tSET when_do = NOW()\r\n\t\t\tWHERE status_user = '******' AND\r\n\t\t\t\tidUser = '******' AND\r\n\t\t\t\tidCourse = '" . (int) $idCourse . "'");
    } else {
        sql_query("\r\n\t\t\tINSERT INTO %lms_statuschangelog\r\n\t\t\tSET status_user = '******',\r\n\t\t\t\tidUser = '******',\r\n\t\t\t\tidCourse = '" . (int) $idCourse . "',\r\n\t\t\t\twhen_do = NOW()");
    }
    if ($prev_status != $status && $status == _CUS_END) {
        // send alert
        require_once _lms_ . '/lib/lib.course.php';
        require_once _base_ . '/lib/lib.eventmanager.php';
        $cd = new DoceboCourse($idCourse);
        $acl_man =& Docebo::user()->getAclManager();
        $teachers = Man_Course::getIdUserOfLevel($idCourse, '6');
        $array_subst = array('[user]' => $acl_man->getUserName($idUser), '[course]' => $cd->getValue('name'));
        $msg_composer = new EventMessageComposer();
        $msg_composer->setSubjectLangText('email', '_USER_END_COURSE_SBJ', false);
        $msg_composer->setBodyLangText('email', '_USER_END_COURSE_TEXT', $array_subst);
        $msg_composer->setBodyLangText('sms', '_USER_END_COURSE_TEXT_SMS', $array_subst);
        // send message to the user subscribed
        createNewAlert('UserCourseEnded', 'status', 'modify', '1', 'User end course', $teachers, $msg_composer);
        //add course's competences scores to user
        $cmodel = new CompetencesAdm();
        $cmodel->assignCourseCompetencesToUser($idCourse, $idUser);
        //increment coursecompleted if this course is in a coursepath
        require_once _lms_ . '/lib/lib.coursepath.php';
        $cpmodel = new CoursePath_Manager();
        $cpmodel->assignComplete($idCourse, $idUser);
    }
    return true;
}
         $highlight = false;
         if (isset($filter['c_filter']['value']) && $filter['c_filter']['value'] != '') {
             $highlight = true;
         }
         $courses[] = array('idCourse' => $row['idCourse'], 'code' => $highlight ? highlightText($row['code'], $filter['c_filter']['value']) : $row['code'], 'name' => $highlight ? highlightText($row['name'], $filter['c_filter']['value']) : $row['name'], 'status' => $row['status'], 'waiting' => $row['pending'] && $moderate ? '<a href="index.php?modname=' . (Docebo::user()->getUserLevelId() == ADMIN_GROUP_PUBLICADMIN ? 'public_subscribe_admin' : 'subscribe') . '&op=waitinguser&id_course=' . $row['idCourse'] . '">' . $row['pending'] . '</a>' : '', 'subscriptions' => $row['course_edition'] != 1 ? isset($row['subscriptions']) ? $row['subscriptions'] : 0 : '--', 'classroom' => $row['course_edition'] == 1 ? '<a href="index.php?r=' . (Docebo::user()->getUserLevelId() == ADMIN_GROUP_PUBLICADMIN ? '' : 'alms/') . 'edition/show&amp;id_course=' . $row['idCourse'] . '">' . (isset($num_edition[$row['idCourse']]) ? $num_edition[$row['idCourse']] : '0') . '</a>' : '', 'certificate' => true, 'competence' => true, 'menu' => true, 'dup' => '<a id="dup_' . $row['idCourse'] . '" href="index.php?modname=' . (Docebo::user()->getUserLevelId() == ADMIN_GROUP_PUBLICADMIN ? 'public_course_admin' : 'course') . '&amp;op=dup_course&id_course=' . $row['idCourse'] . '">' . Get::img('standard/dup.png', $lang->def('_MAKE_A_COPY')) . '</a>', 'mod' => true, 'del' => true);
     }
     $output = array('startIndex' => (int) $startIndex, 'recordsReturned' => count($courses), 'sort' => $sort, 'dir' => $dir, 'totalRecords' => (int) $man_courses->getCoursesCountFiltered($filter), 'pageSize' => (int) $results, 'records' => $courses);
     $json = new Services_JSON();
     aout($json->encode($output));
     break;
 case 'del_row':
     require_once _lms_ . '/lib/lib.course.php';
     $output = array('success' => false);
     $id_course = Get::req('idrow', DOTY_INT, -1);
     if ($id_course > 0) {
         $man_course = new Man_Course();
         $output['success'] = $man_course->deleteCourse($id_course);
     }
     $json = new Services_JSON();
     aout($json->encode($output));
     break;
 case 'set_name':
     $output = array('success' => false);
     $id_course = Get::req('id_course', DOTY_INT, false);
     $new_name = Get::req('new_name', DOTY_STRING, '');
     if (is_numeric($id_course)) {
         if (sql_query("UPDATE " . $GLOBALS['prefix_lms'] . "_course SET name='" . $new_name . "' WHERE idCourse=" . $id_course)) {
             $output['success'] = true;
         }
     }
     aout($json->encode($output));
function savePanel()
{
    checkPerm('mod');
    require_once _base_ . '/lib/lib.form.php';
    require_once _adm_ . '/lib/lib.publicadminmanager.php';
    require_once _lms_ . '/lib/lib.course.php';
    require_once _lms_ . '/lib/lib.date.php';
    require_once _lms_ . '/lib/lib.competences.php';
    $save = Get::req('save', DOTY_MIXED, false);
    $undo = Get::req('undo', DOTY_MIXED, false);
    $update = Get::req('update', DOTY_MIXED, false);
    $db = DbConn::getInstance();
    $lang =& DoceboLanguage::CreateInstance('public_coursepanel', 'lms');
    $man_competences = new Competences_Manager();
    //back page link
    $back_ui = getBackUi('index.php?modname=public_coursepanel&op=coursepanel', $lang->def('_BACK'));
    cout(getTitleArea($lang->def('_COURSEPANEL'), 'coursepanel') . '<div class="std_block">' . $back_ui, 'content');
    $sel_competence = Get::req('sel_competence', DOTY_INT, false);
    $sel_course = Get::req('sel_course', DOTY_INT, false);
    $required_filter = Get::req('required_filter', DOTY_INT, 0);
    $is_retraining = $man_competences->isRetrainingCourse($sel_course, $sel_competence);
    $back_url = "index.php?modname=public_coursepanel&op=coursepanel&sel_competence=" . (int) $sel_competence . "&sel_course=" . (int) $sel_course;
    if ($required_filter > 0) {
        $back_url .= '&required_filter=1';
    }
    $to_consider = Get::req('to_consider', DOTY_MIXED, false);
    if ($to_consider) {
        require_once _base_ . '/lib/lib.json.php';
        $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
        $to_consider = $json->decode(base64_decode($to_consider));
    } else {
        $to_consider = array('users' => array(), 'editions' => array());
    }
    if ($undo) {
        Util::jump_to("index.php");
    } elseif ($save) {
        //change users' subscription to course editions
        $data = Get::req('subscriptions', DOTY_MIXED, array());
        $man_course = new Man_Course();
        $course_info = $man_course->getCourseInfo($sel_course);
        if (!$sel_competence || !$sel_course) {
            //error ...
            Util::jump_to($back_url . "&err=invalid");
        }
        //check the admin level of the current user, if it's not an admin or the idst is invalid, return an error
        $id_pa = getLogUserId();
        if (!$id_pa) {
            Util::jump_to($back_url . "&err=invalid");
        }
        $acl_man = new DoceboACLManager();
        $admin_manager = new PublicAdminManager();
        $array_users = array();
        $idst_associated = $admin_manager->getAdminTree($id_pa);
        $array_users =& $acl_man->getAllUsersFromIdst($idst_associated);
        $array_users = array_unique($array_users);
        if (empty($array_users)) {
            Util::jump_to($back_url . "&err=invalid");
        }
        //filter array of user ids by competence
        $filtered_users = array();
        $query_filter = "SELECT id_user FROM %lms_competence_user WHERE id_user IN (" . implode(",", $array_users) . ") AND id_competence='" . (int) $sel_competence . "'";
        $res_filter = $db->query($query_filter);
        while (list($idst) = $db->fetch_row($res_filter)) {
            $filtered_users[] = $idst;
        }
        $subs_limit = array();
        $subs_count = array();
        if ($course_info['course_type'] == 'elearning') {
            $editions[] = $sel_course;
            $subscribed[$sel_course] = getSubscribed((int) $sel_course);
            $course_info = $man_course->getCourseInfo($sel_course);
            $subs_count[$sel_course] = count($data);
        } elseif ($course_info['course_type'] == 'classroom') {
            //get all combinations id_user - id_date
            $date_man = new DateManager();
            $editions = array();
            $query_editions = "SELECT id_date, id_course, code, name FROM %lms_course_date WHERE id_course='" . (int) $sel_course . "'";
            $res_editions = $db->query($query_editions);
            while (list($id_edition, $id_course, $code, $name) = $db->fetch_row($res_editions)) {
                $editions[] = $id_edition;
                $subscribed[$id_edition] = $date_man->getDateSubscribed($id_edition);
                $date_info = $date_man->getDateInfo($id_edition);
                $subs_limit[$id_edition] = array('max' => $date_info['max_par'], 'subs' => $date_info['user_subscribed']);
                $subs_count[$id_edition] = 0;
            }
        }
        //------------------------------------------------------------------------------
        //count the users to be subscribed/unsubscribed and check subscription limits, if any
        //subtract users to de-subscribe from courses
        foreach ($subscribed as $id_edition => $users_list) {
            foreach ($users_list as $id_user) {
                if ($course_info['course_type'] == 'elearning') {
                    if (!isset($data[$id_user])) {
                        $subs_count[$id_edition]--;
                    }
                } elseif ($course_info['course_type'] == 'classroom') {
                    //check if the current selection match the current subscriptions
                    if (!isset($data[$id_user][$id_edition])) {
                        $subs_count[$id_edition]--;
                    }
                }
            }
        }
        foreach ($data as $user => $edition_list) {
            //id user
            foreach ($edition_list as $edition => $val) {
                //id date edition
                if (isset($subscribed[$edition][$user])) {
                    //already subscribed, do nothing
                } else {
                    $subs_count[$edition]++;
                }
            }
        }
        //check if we have enough room to subscribe users
        //{at the moment, rely on js ...}
        //------------------------------------------------------------------------------
        //unsubscribe deselected users
        foreach ($subscribed as $id_edition => $users_list) {
            foreach ($users_list as $id_user) {
                if ($course_info['course_type'] == 'elearning') {
                    if (!isset($data[$id_user])) {
                        if (in_array($id_user, $to_consider['users']) && in_array($id_edition, $to_consider['editions'])) {
                            $group_levels = DoceboCourse::getCourseLevel($sel_course);
                            $user_levels = getSubscribedLevel($sel_course, false, false, 0);
                            $_res = _removeCourseSubscription($sel_course, $id_user, $group_levels[$user_levels[$id_user]], 0);
                        }
                    }
                } elseif ($course_info['course_type'] == 'classroom') {
                    //check if the current selection match the current subscriptions
                    if (!isset($data[$id_user][$id_edition])) {
                        if (in_array($id_user, $to_consider['users']) && in_array($id_edition, $to_consider['editions'])) {
                            $date_man->removeUserFromDate($id_user, $id_edition, $sel_course);
                        }
                    }
                }
            }
        }
        //------------------------------------------------------------------------------
        //check every single user for inscription
        $count = 0;
        $lv_sel = 3;
        //student level
        $waiting = 0;
        //don't subscribe as "waiting for approvation"
        //retrive id of group of the course for the varioud level
        $level_idst = DoceboCourse::getCourseLevel((int) $sel_course);
        //if the group doesn't exists create it
        if (count($level_idst) == 0 || $level_idst[1] == '') {
            $level_idst =& DoceboCourse::createCourseLevel((int) $sel_course);
        }
        foreach ($data as $user => $edition_list) {
            //id user
            foreach ($edition_list as $edition => $val) {
                //id date edition
                if (isset($subscribed[$edition][$user])) {
                    //already subscribed, do nothing
                } else {
                    //this user is to be subscribed, do it
                    //add to level group of the course
                    $acl_man->addToGroup($level_idst[$lv_sel], $user);
                    // Add in table
                    $re = $db->query("INSERT INTO %lms_courseuser (idUser, idCourse, edition_id, level, waiting, subscribed_by, date_inscr)" . " VALUES ( '" . (int) $user . "', '" . (int) $sel_course . "', '0', '" . $lv_sel . "', '" . $waiting . "', '" . getLogUserId() . "', '" . date("Y-m-d H:i:s") . "' )\t");
                    //additional operations for editions
                    if ($course_info['course_type'] == 'elearning') {
                        //...
                    } elseif ($course_info['course_type'] == 'classroom') {
                        $ret = $date_man->addUserToDate($edition, $user, getLogUserId());
                        if ($ret) {
                            $count++;
                        }
                    }
                }
            }
        }
        Util::jump_to($back_url . "&err=ok&count=" . (int) $count);
    } elseif ($update) {
        $sel_competence = Get::req('sel_competence', DOTY_INT, false);
        $sel_course = Get::req('sel_course', DOTY_INT, false);
        Util::jump_to($back_url);
        //."&sel_competence=".(int)$sel_competence."&sel_course=".(int)$sel_course);
    } else {
        //...
    }
    cout($back_ui . '</div>', 'content');
}
Exemple #16
0
function report_certificate()
{
    require_once _base_ . '/lib/lib.form.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.certificate.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
    require_once _base_ . '/lib/lib.table.php';
    checkPerm('view');
    $out =& $GLOBALS['page'];
    $out->setWorkingZone('content');
    $form = new Form();
    $certificate = new Certificate();
    $lang =& DoceboLanguage::createInstance('certificate', 'lms');
    if (isset($_GET['id_certificate'])) {
        $id_certificate = importVar('id_certificate', true, 0);
        $man_course = new Man_Course();
        $id_course = array();
        $id_course = $certificate->getCourseForCertificate($id_certificate);
        $course_info = array();
        $out->add(getTitleArea(array('index.php?modname=certificate&amp;op=certificate' => $lang->def('_TITLE_CERTIFICATE'), $lang->def('_COURSES'))) . '<div class="std_block">' . getBackUi('index.php?modname=certificate&amp;op=certificate', $lang->def('_BACK')));
        $tb = new Table(Get::sett('visuItem'), $lang->def('_CHOOSE_COURSE'), $lang->def('_COURSE_LIST'));
        $type_h = array('', '', 'min-cell');
        $cont_h = array($lang->def('_CODE'), $lang->def('_NAME'), $lang->def('_CERTIFICATE_REPORT'));
        $tb->setColsStyle($type_h);
        $tb->addHead($cont_h);
        foreach ($id_course as $course_id) {
            $course_info = $man_course->getCourseInfo($course_id);
            $cont = array($course_info['code'], '<a href="index.php?modname=certificate&amp;op=view_report_certificate&amp;id_certificate=' . $id_certificate . '&amp;id_course=' . $course_id . '">' . $course_info['name'] . '</a>', $certificate->getNumberOfCertificateForCourse($id_certificate, $course_info['idCourse']));
            $tb->addBody($cont);
        }
        $out->add($tb->getTable() . '<br/>' . getBackUi('index.php?modname=certificate&amp;op=certificate', $lang->def('_BACK')) . '</div>');
    } else {
        $out->add(getTitleArea($lang->def('_CERTIFICATE_REPORT'), 'certificate') . '<div class="std_block">');
        if (isset($_POST['toggle_filter'])) {
            unset($_POST['name_filter']);
            unset($_POST['code_filter']);
        }
        $out->add($form->openForm('certificate_filter', 'index.php?modname=certificate&amp;op=report_certificate') . $form->openElementSpace() . $form->getTextfield($lang->def('_NAME'), 'name_filter', 'name_filter', '255', isset($_POST['name_filter']) && $_POST['name_filter'] !== '' ? $_POST['name_filter'] : '') . $form->getTextfield($lang->def('_CODE'), 'code_filter', 'code_filter', '255', isset($_POST['code_filter']) && $_POST['code_filter'] !== '' ? $_POST['code_filter'] : '') . $form->closeElementSpace() . $form->openButtonSpace() . $form->getButton('filter', 'filter', $lang->def('_FILTER')) . $form->getButton('toggle_filter', 'toggle_filter', $lang->def('_TOGGLE_FILTER')) . $form->closeButtonSpace() . $form->closeForm());
        if (isset($_POST['filter'])) {
            if ($_POST['name_filter'] !== '' && $_POST['code_filter'] !== '') {
                $certificate_info = $certificate->getCertificateList($_POST['name_filter'], $_POST['code_filter']);
            } elseif ($_POST['name_filter'] !== '') {
                $certificate_info = $certificate->getCertificateList($_POST['name_filter']);
            } elseif ($_POST['code_filter'] !== '') {
                $certificate_info = $certificate->getCertificateList(false, $_POST['code_filter']);
            } else {
                $certificate_info = $certificate->getCertificateList();
            }
        } else {
            $certificate_info = $certificate->getCertificateList();
        }
        $tb = new Table(Get::sett('visuItem'), $lang->def('_CHOOSE_CERTIFICATE'), $lang->def('_CERTIFICATE_LIST'));
        $type_h = array('', '');
        $cont_h = array($lang->def('_CODE'), $lang->def('_NAME'), $lang->def('_DESCRIPTION'));
        $tb->setColsStyle($type_h);
        $tb->addHead($cont_h);
        foreach ($certificate_info as $info_certificate) {
            $cont = array($info_certificate[CERT_CODE], '<a href="index.php?modname=certificate&amp;op=report_certificate&amp;id_certificate=' . $info_certificate[CERT_ID] . '">' . $info_certificate[CERT_NAME] . '</a>', $info_certificate[CERT_DESCR]);
            $tb->addBody($cont);
        }
        $out->add($tb->getTable() . '</div>');
    }
}
Exemple #17
0
 public function getMyCourses($id_user, $params = false)
 {
     require_once _lms_ . '/lib/lib.course.php';
     $output = array();
     $output['success'] = true;
     $search = array('cu.iduser = :id_user');
     $search_params = array(':id_user' => $id_user);
     if (!empty($params['filter'])) {
         switch ($params['filter']) {
             case 'completed':
                 $search[] = 'cu.status = :status';
                 $search_params[':status'] = _CUS_END;
                 break;
             case 'notcompleted':
                 $search[] = 'cu.status >= :status_from';
                 $search_params[':status_from'] = _CUS_SUBSCRIBED;
                 $search[] = 'cu.status < :status_to';
                 $search_params[':status_to'] = _CUS_END;
                 break;
             case 'notstarted':
                 $search[] = 'cu.status = :status';
                 $search_params[':status'] = _CUS_SUBSCRIBED;
                 break;
         }
     }
     $model = new CourseLms();
     $course_list = $model->findAll($search, $search_params);
     //check courses accessibility
     $keys = array_keys($course_list);
     for ($i = 0; $i < count($keys); $i++) {
         $course_list[$keys[$i]]['can_enter'] = Man_Course::canEnterCourse($course_list[$keys[$i]]);
     }
     //$output['log']=var_export($course_list, true);
     foreach ($course_list as $key => $course_info) {
         $output[]['course_info'] = array('course_id' => $course_info['idCourse'], 'course_name' => str_replace('&', '&amp;', $course_info['name']), 'course_description' => str_replace('&', '&amp;', $course_info['description']), 'course_link' => Get::sett('url') . _folder_lms_ . '/index.php?modname=course&amp;op=aula&amp;idCourse=' . $course_info['idCourse']);
     }
     return $output;
 }
Exemple #18
0
 public function delCourse($id_course)
 {
     if ((int) $id_course <= 0) {
         return false;
     }
     require_once _lms_ . '/lib/lib.course.php';
     require_once _base_ . '/lib/lib.upload.php';
     $course_man = new Man_Course();
     //remove course subscribed------------------------------------------
     $levels =& $course_man->getCourseIdstGroupLevel($id_course);
     foreach ($levels as $lv => $idst) {
         Docebo::aclm()->deleteGroup($idst);
     }
     $alluser = getIDGroupAlluser($id_course);
     Docebo::aclm()->deleteGroup($alluser);
     $course_man->removeCourseRole($id_course);
     $course_man->removeCourseMenu($id_course);
     $query = "DELETE FROM %lms_courseuser WHERE idCourse = '" . (int) $id_course . "'";
     $qres = sql_query($query);
     if (!$qres) {
         return false;
     }
     //--- remove course data ---------------------------------------------------
     $query_course = "SELECT imgSponsor, img_course, img_material, img_othermaterial, course_demo, course_type, has_editions\n\t\t\tFROM %lms_course\n\t\t\tWHERE idCourse = '" . (int) $id_course . "'";
     $qres = sql_query($query_course);
     list($file_sponsor, $file_logo, $file_material, $file_othermaterial, $file_demo, $course_type, $course_edition) = sql_fetch_row($qres);
     require_once _base_ . '/lib/lib.upload.php';
     $path = '/appLms/' . Get::sett('pathcourse');
     if (substr($path, -1) != '/' && substr($path, -1) != '\\') {
         $path .= '/';
     }
     sl_open_fileoperations();
     if ($file_sponsor != '') {
         sl_unlink($path . $file_sponsor);
     }
     if ($file_logo != '') {
         sl_unlink($path . $file_logo);
     }
     if ($file_material != '') {
         sl_unlink($path . $file_material);
     }
     if ($file_othermaterial != '') {
         sl_unlink($path . $file_othermaterial);
     }
     if ($file_demo != '') {
         sl_unlink($path . $file_demo);
     }
     sl_close_fileoperations();
     //if the scs exist delete course rooms
     if ($GLOBALS['where_scs'] !== false) {
         require_once _scs_ . '/lib/lib.room.php';
         $re = deleteRoom(false, 'course', $id_course);
     }
     //--- delete classroom or editions -----------------------------------------
     if ($course_type == 'classroom') {
         require_once _lms_ . '/admin/model/ClassroomAlms.php';
         $classroom_model = new ClassroomAlms($id_course);
         $classroom = $classroom_model->classroom_man->getDateIdForCourse($id_course);
         foreach ($classroom as $id_date) {
             if (!$classroom_model->classroom_man->delDate($id_date)) {
                 return false;
             }
         }
     } elseif ($course_edition == 1) {
         require_once _lms_ . '/admin/model/EditionAlms.php';
         $edition_model = new EditionAlms($id_course);
         $editions = $edition_model->classroom_man->getEditionIdFromCourse($id_course);
         foreach ($editions as $id_edition) {
             if (!$edition_model->edition_man->delEdition($id_edition)) {
                 return false;
             }
         }
     }
     //--- end classrooms or editions -------------------------------------------
     //--- clear LOs ------------------------------------------------------------
     require_once _lms_ . '/lib/lib.module.php';
     require_once _lms_ . '/lib/lib.param.php';
     require_once _lms_ . '/class.module/track.object.php';
     $arr_lo_param = array();
     $arr_lo_track = array();
     $arr_org_access = array();
     $query = "SELECT * FROM %lms_organization WHERE idCourse = " . (int) $id_course;
     $ores = sql_query($query);
     while ($obj = sql_fetch_object($ores)) {
         $deleted = true;
         if ($obj->idResource != 0 && $obj->objectType != "") {
             $lo = createLO($obj->objectType);
             $deleted = $lo->del($obj->idResource);
             //delete learning object
         }
         if ($deleted) {
             $arr_lo_track[] = $obj->idOrg;
             $arr_org_access[] = $obj->idOrg;
             //collect org access ids
             $arr_lo_param[] = $obj->idParam;
             //collect idParams ids
         }
     }
     //delete all organizations references for the course
     $query = "DELETE FROM %lms_organization WHERE idCourse = " . (int) $id_course;
     $res = sql_query($query);
     //delete LOs trackings
     if (!empty($arr_lo_track)) {
         $track_object = new Track_Object(false, 'course_lo');
         $track_object->delIdTrackFromCommon($arr_lo_track);
     }
     //delete org accesses
     if (!empty($arr_org_access)) {
         $query = "DELETE FROM %lms_organization_access\n\t\t\t\tWHERE idOrgAccess IN (" . implode(",", $arr_org_access) . ")";
         $res = sql_query($query);
     }
     //delete lo params
     if (!empty($arr_lo_param)) {
         $query = "DELETE FROM %lms_lo_param\n\t\t\t\tWHERE idParam IN (" . implode(",", $arr_lo_param) . ")";
     }
     //--- end LOs --------------------------------------------------------------
     //--- clear coursepath references ------------------------------------------
     require_once _lms_ . '/lib/lib.coursepath.php';
     $cman = new CoursePath_Manager();
     $cman->deleteCourseFromCoursePaths($id_course);
     //--- end coursepath references --------------------------------------------
     //--- clear certificates assignments ---------------------------------------
     require_once _lms_ . '/lib/lib.certificate.php';
     $cman = new Certificate();
     $cman->deleteCourseCertificateAssignments($id_course);
     //--- end certificates assignments -----------------------------------------
     //--- clear labels ---------------------------------------------------------
     $lmodel = new LabelAlms();
     $lmodel->clearCourseLabel($id_course);
     //--- end labels -----------------------------------------------------------
     //--- clear advices --------------------------------------------------------
     require_once _lms_ . '/lib/lib.advice.php';
     $aman = new Man_Advice();
     $aman->deleteAllCourseAdvices($id_course);
     //--- end advices ----------------------------------------------------------
     //--- clear coursereports --------------------------------------------------
     require_once _lms_ . '/lib/lib.coursereport.php';
     $cman = new CourseReportManager();
     $cman->deleteAllReports($id_course);
     //--- end coursereports ----------------------------------------------------
     //--- clear competences ----------------------------------------------------
     $cmodel = new CompetencesAdm();
     $cmodel->deleteAllCourseCompetences($id_course);
     //--- end competences ------------------------------------------------------
     //--- finally delete course from courses table -----------------------------
     if (!sql_query("DELETE FROM %lms_course WHERE idCourse = '" . $id_course . "'")) {
         return false;
     }
     return true;
 }
 public function completedTask()
 {
     $model = new ClassroomLms();
     $filter_text = Get::req('filter_text', DOTY_STRING, "");
     $filter_year = Get::req('filter_year', DOTY_INT, 0);
     $conditions = array('cu.iduser = :id_user', 'cu.status = :status');
     $params = array(':id_user' => (int) Docebo::user()->getId(), ':status' => _CUS_END);
     if (!empty($filter_text)) {
         $conditions[] = "(c.code LIKE '%:keyword%' OR c.name LIKE '%:keyword%')";
         $params[':keyword'] = $filter_text;
     }
     if (!empty($filter_year)) {
         $clist = $model->getUserCoursesByYear(Docebo::user()->getId(), $filter_year);
         if ($clist !== false) {
             $conditions[] = "cu.idCourse IN (" . implode(",", $clist) . ")";
         }
     }
     $courselist = $model->findAll($conditions, $params);
     //check courses accessibility
     $keys = array_keys($courselist);
     for ($i = 0; $i < count($keys); $i++) {
         $courselist[$keys[$i]]['can_enter'] = Man_Course::canEnterCourse($courselist[$keys[$i]]);
     }
     require_once _lms_ . '/lib/lib.middlearea.php';
     $ma = new Man_MiddleArea();
     $this->render('courselist', array('path_course' => $this->path_course, 'courselist' => $courselist, 'use_label' => $ma->currentCanAccessObj('tb_label'), 'display_info' => $this->_getClassDisplayInfo($keys), 'dm' => new DateManager(), 'keyword' => $filter_text));
 }
Exemple #20
0
 function addEvent()
 {
     checkPerm('view');
     require_once _base_ . '/lib/lib.form.php';
     require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
     $lang =& DoceboLanguage::createInstance('reservation');
     $out = $GLOBALS['page'];
     $out->setWorkingZone('content');
     $man_res = new Man_Reservation();
     $man_course = new Man_Course();
     if (isset($_GET['confirm'])) {
         $confirm = importVar('confirm', true, 0);
         $id_course = importVar('id_course', true, 0);
         $id_laboratory = importVar('id_laboratory', true, 0);
         $id_category = importVar('id_category', true, 0);
         $title = importVar('title', false, '');
         $description = importVar('description', false, '');
         $date = importVar('date', false, '');
         $max_user = importVar('max_user', true, 0);
         $deadline = importVar('deadline', false, '');
         $from_time_h = importVar('from_time_h', false, '');
         $from_time_m = importVar('from_time_m', false, '');
         $to_time_h = importVar('to_time_h', false, '');
         $to_time_m = importVar('to_time_m', false, '');
         $date = Format::dateDb($date, 'date');
         $deadline = Format::dateDb($deadline, 'date');
         $from_time = $from_time_h . ':' . $from_time_m . ':00';
         $to_time = $to_time_h . ':' . $to_time_m . ':00';
         if ($date < date('Y-m-d') || $date < $deadline) {
             Util::jump_to('index.php?modname=reservation&op=add_event&amp;error=date');
         }
         if ($from_time >= $to_time) {
             Util::jump_to('index.php?modname=reservation&op=add_event&amp;error=time');
         }
         if ($confirm) {
             $result = $man_res->addEvents($id_course, $id_laboratory, $id_category, $title, $description, $date, $max_user, $deadline, $from_time, $to_time);
         }
         if ($result) {
             Util::jump_to('index.php?modname=reservation&op=view_event');
         }
         Util::jump_to('index.php?modname=reservation&op=add_event&amp;error=laboratory');
     }
     $out->add(getTitleArea($lang->def('_NEW_EVENT'), '', $lang->def('_EVENT')) . '<div class="std_block">');
     $error = importVar('error', false, '');
     if ($error !== '') {
         switch ($error) {
             case 'date':
                 $out->add(getErrorUi($lang->def('_WRONG_DATE')));
                 break;
             case 'time':
                 $out->add(getErrorUi($lang->def('_WRONG_TIME')));
                 break;
             case 'laboratory':
                 $out->add(getErrorUi($lang->def('_LOCATION_BUSY')));
                 break;
         }
     }
     $course = array();
     $course = $man_course->getAllCourses();
     $course_id = array();
     foreach ($course as $sources) {
         $course_id[$sources['id_course']] = $sources['name'];
     }
     $out->add(Form::openForm('form_event', 'index.php?modname=reservation&amp;op=add_event&amp;confirm=1') . Form::openElementSpace() . Form::getTextfield($lang->def('_TITLE'), 'title', 'title', 255) . Form::getTextarea($lang->def('_DESCRIPTION'), 'description', 'description') . Form::getDropdown($lang->def('_COURSE'), 'id_course', 'id_course', $course_id) . Form::getDropdown($lang->def('_LOCATION'), 'id_laboratory', 'id_laboratory', $man_res->getLaboratories()) . Form::getDropdown($lang->def('_CATEGORY'), 'id_category', 'id_category', $man_res->getCategory()) . Form::getDateField($lang->def('_DATE'), 'date', 'date') . Form::getDateField($lang->def('_DEADLINE'), 'deadline', 'deadline') . Form::getTextfield($lang->def('_MAX_USER'), 'max_user', 'max_user', 255) . Form::getLineBox($lang->def('_FROM_TIME'), Form::getInputDropdown('', 'from_time_h', 'from_time_h', $man_res->getHours(), false, false) . ' : ' . Form::getInputDropdown('', 'from_time_m', 'from_time_m', $man_res->getMinutes(), false, false)) . Form::getLineBox($lang->def('_TO_TIME'), Form::getInputDropdown('', 'to_time_h', 'to_time_h', $man_res->getHours(), false, false) . ' : ' . Form::getInputDropdown('', 'to_time_m', 'to_time_m', $man_res->getMinutes(), false, false)) . Form::closeElementSpace() . Form::openButtonSpace() . Form::getButton('send_event', 'send_event', $lang->def('_NEW_EVENT')) . Form::getButton('undo', 'undo', $lang->def('_UNDO')) . Form::closeButtonSpace() . Form::closeForm());
     $out->add('</div>', 'content');
 }
Exemple #21
0
            if ($prerequisites !== '') {
                $num_prerequisites = count(explode(',', $prerequisites));
                $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) {
                    $unlock = false;
                }
            }
        }
        if ($course_info['status'] == _CUS_END) {
            $ico_style = 'subs_actv';
            $ico_text = '_COURSE_COMPLETED';
        } elseif (!$unlock) {
            $ico_style = 'subs_locked';
            $ico_text = '_COURSE_LOCKED';
        } else {
            $ico_style = 'subs_noac';
            $ico_text = '_COURSE_ACTIVE';
        }
        $query_control_info = "SELECT c.idCourse, c.course_type, c.idCategory, c.code, c.name, c.description, c.difficult, c.status AS course_status, c.course_edition, " . "\tc.max_num_subscribe, c.create_date, " . "\tc.direct_play, c.img_othermaterial, c.course_demo, c.use_logo_in_courselist, c.img_course, c.lang_code, " . "\tc.course_vote, " . "\tc.date_begin, c.date_end, c.valid_time, c.show_result, c.userStatusOp," . "\tcu.status AS user_status, cu.level, cu.date_inscr, cu.date_first_access, cu.date_complete, cu.waiting" . " FROM %lms_course AS c " . " JOIN %lms_courseuser AS cu ON (c.idCourse = cu.idCourse) " . " WHERE c.idCourse = " . $id_course;
        $accesso_control_info = sql_fetch_assoc(sql_query($query_control_info));
        $course_access = Man_Course::canEnterCourse($accesso_control_info, $id_path);
        echo '<tr>' . '<td><span class="ico-sprite ' . $ico_style . '"><span>' . Lang::t($ico_text, 'coursepath') . '</span></span></td>' . '<td class="course_type">' . Lang::t('_' . strtoupper($course_info['course_type']), 'coursepath') . '</td>' . '<td>' . ($course_access['can'] ? '<a class="std_link" href="index.php?modname=course&amp;op=aula&amp;idCourse=' . $course_info['idCourse'] . '">' : '') . $course_info['name'] . ($course_access['can'] ? '</a>' : '') . '</td>' . '</tr>';
    }
    echo '</table>' . '</div>' . '<div class="nofloat"></div>' . '</div>';
    if ($first) {
        $first = false;
    } else {
        echo '<br />';
    }
}
 function add_row($row, $pk)
 {
     $id_course = false;
     if ($row['code'] == '') {
         $row['code'] = $this->default_cols['code'];
     }
     if ($row['name'] == '') {
         $row['name'] = $this->default_cols['name'];
     }
     if ($row['description'] == '') {
         $row['description'] = $this->default_cols['description'];
     }
     if ($row['lang_code'] == '') {
         $row['lang_code'] = $this->default_cols['lang_code'];
     }
     if ($row['status'] == '') {
         $row['status'] = $this->default_cols['status'];
     }
     if ($row['subscribe_method'] == '') {
         $row['subscribe_method'] = $this->default_cols['subscribe_method'];
     }
     if ($row['permCloseLO'] == '') {
         $row['permCloseLO'] = $this->default_cols['permCloseLO'];
     }
     if ($row['difficult'] == '') {
         $row['difficult'] = $this->default_cols['difficult'];
     }
     if ($row['show_progress'] == '') {
         $row['show_progress'] = $this->default_cols['show_progress'];
     }
     if ($row['show_time'] == '') {
         $row['show_time'] = $this->default_cols['show_time'];
     }
     if ($row['show_extra_info'] == '') {
         $row['show_extra_info'] = $this->default_cols['show_extra_info'];
     }
     if ($row['show_rules'] == '') {
         $row['show_rules'] = $this->default_cols['show_rules'];
     }
     if ($row['date_begin'] == '') {
         $row['date_begin'] = $this->default_cols['date_begin'];
     }
     if ($row['date_end'] == '') {
         $row['date_end'] = $this->default_cols['date_end'];
     }
     if ($row['valid_time'] == '') {
         $row['valid_time'] = $this->default_cols['valid_time'];
     }
     if ($row['max_num_subscribe'] == '') {
         $row['max_num_subscribe'] = $this->default_cols['max_num_subscribe'];
     }
     if ($row['prize'] == '') {
         $row['prize'] = $this->default_cols['prize'];
     }
     if ($row['selling'] == '') {
         $row['selling'] = $this->default_cols['selling'];
     }
     // check if the course identified by the pk alredy exits
     $id_course = $this->get_row_by_pk($pk);
     if ($id_course === false) {
         $this->last_error = 'Error in search query : ( ' . mysql_error() . ' )';
         return false;
     }
     if ($id_course === 'jump') {
         return true;
     }
     $is_add = false;
     if ($id_course === 0) {
         $is_add = true;
         // course is to add
         $query_course = "\r\n\t\t\tINSERT INTO " . $GLOBALS['prefix_lms'] . "_course \r\n\t\t\tSET idCategory = '0', \r\n\t\t\t\tcode = '" . addslashes($row['code']) . "', \r\n\t\t\t\tname = '" . addslashes($row['name']) . "', \r\n\t\t\t\tdescription = '" . $row['description'] . "', \r\n\t\t\t\tlang_code = '" . $row['lang_code'] . "', \r\n\t\t\t\tstatus = '" . $row['status'] . "', \r\n\t\t\t\tsubscribe_method = '" . $row['subscribe_method'] . "',\r\n\t\t\t\tpermCloseLO = '" . $row['permCloseLO'] . "', \r\n\t\t\t\tdifficult = '" . $row['difficult'] . "', \r\n\t\t\t\tshow_progress = '" . $row['show_progress'] . "', \r\n\t\t\t\tshow_time = '" . $row['show_time'] . "', \r\n\t\t\t\tshow_extra_info = '" . $row['show_extra_info'] . "', \r\n\t\t\t\tshow_rules = '" . $row['show_rules'] . "', \r\n\t\t\t\tdate_begin = '" . $row['date_begin'] . "', \r\n\t\t\t\tdate_end = '" . $row['date_end'] . "', \r\n\t\t\t\tvalid_time = '" . $row['valid_time'] . "',\r\n\t\t\t\tmax_num_subscribe = '" . $row['max_num_subscribe'] . "', \r\n\t\t\t\tprize = '" . $row['prize'] . "',\r\n\t\t\t\tselling = '" . $row['selling'] . "',\r\n\t\t\t\timported_from_connection = '" . $this->get_name() . "'";
         if (!sql_query($query_course)) {
             $this->last_error = 'Error in insert query : ( ' . mysql_error() . ' )' . '<!-- ' . $query_course . ' -->';
             return false;
         }
         $id_course = mysql_insert_id();
         // import the menu
         if (Docebo::user()->getUserLevelId() != ADMIN_GROUP_GODADMIN) {
             $re &= sql_query("\r\n\t\t\t\tINSERT INTO " . $GLOBALS['prefix_fw'] . "_admin_course \r\n\t\t\t\t( id_entry, type_of_entry, idst_user ) VALUES \r\n\t\t\t\t( '" . $id_course . "', 'course', '" . getLogUserId() . "') ");
         }
         //if the scs exist create a room
         if ($GLOBALS['where_scs'] !== false) {
             require_once $GLOBALS['where_scs'] . '/lib/lib.room.php';
             $rules = array('room_name' => $row['name'], 'room_type' => 'course', 'id_source' => $id_course);
             $admin_rules = getAdminRules();
             $rules = array_merge($rules, $admin_rules);
             $re = insertRoom($rules);
         }
         $course_idst = DoceboCourse::createCourseLevel($id_course);
         require_once $GLOBALS['where_lms'] . '/lib/lib.manmenu.php';
         if (!cerateCourseMenuFromCustom($this->std_menu_to_assign, $id_course, $course_idst)) {
             $this->last_error = 'Error in menu assignament';
             return false;
         }
     } else {
         // course is to update
         $query_course = "\r\n\t\t\tUPDATE " . $GLOBALS['prefix_lms'] . "_course \r\n\t\t\tSET code = '" . addslashes($row['code']) . "', \r\n\t\t\t\tname = '" . addslashes($row['name']) . "', \r\n\t\t\t\tdescription = '" . $row['description'] . "', \r\n\t\t\t\tlang_code = '" . $row['lang_code'] . "', \r\n\t\t\t\tstatus = '" . $row['status'] . "', \r\n\t\t\t\tsubscribe_method = '" . $row['subscribe_method'] . "',\r\n\t\t\t\tpermCloseLO = '" . $row['permCloseLO'] . "', \r\n\t\t\t\tdifficult = '" . $row['difficult'] . "', \r\n\t\t\t\tshow_progress = '" . $row['show_progress'] . "', \r\n\t\t\t\tshow_time = '" . $row['show_time'] . "', \r\n\t\t\t\tshow_extra_info = '" . $row['show_extra_info'] . "', \r\n\t\t\t\tshow_rules = '" . $row['show_rules'] . "', \r\n\t\t\t\tdate_begin = '" . $row['date_begin'] . "', \r\n\t\t\t\tdate_end = '" . $row['date_end'] . "', \r\n\t\t\t\tvalid_time = '" . $row['valid_time'] . "',\r\n\t\t\t\tmax_num_subscribe = '" . $row['max_num_subscribe'] . "', \r\n\t\t\t\tprize = '" . $row['prize'] . "',\r\n\t\t\t\tselling = '" . $row['selling'] . "'\r\n\t\t\tWHERE idCourse = '" . $id_course . "'";
         if (!sql_query($query_course)) {
             $this->last_error = 'Error in update query : ( ' . mysql_error() . ' )' . '<!-- ' . $query_course . ' -->';
             return false;
         }
     }
     if ($id_course != false) {
         if ($this->cache_inserted) {
             $this->arr_id_inserted[] = $id_course;
         }
         if ($this->sendnotify == 1) {
             // send notify
             if ($is_add) {
                 require_once $GLOBALS['where_framework'] . '/lib/lib.eventmanager.php';
                 $msg_composer = new EventMessageComposer();
                 $msg_composer->setSubjectLangText('email', '_ALERT_SUBJECT', false);
                 $msg_composer->setBodyLangText('email', '_ALERT_TEXT', array('[url]' => Get::sett('url'), '[course_code]' => $row['code'], '[course]' => $row['name']));
                 $msg_composer->setBodyLangText('sms', '_ALERT_TEXT_SMS', array('[url]' => Get::sett('url'), '[course_code]' => $row['code'], '[course]' => $row['name']));
                 require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
                 $course_man = new Man_Course();
                 $recipients = $course_man->getIdUserOfLevel($id_course);
                 createNewAlert('CoursePropModified', 'course', 'add', '1', 'Inserted course ' . $_POST['course_name'], $recipients, $msg_composer);
             }
         }
         return true;
     }
     $this->last_error = 'Unknow error';
     return false;
 }
Exemple #23
0
function dashmycourse(&$url, $lang, &$subscription, $cinfo, $index)
{
    require_once $GLOBALS['where_lms'] . '/lib/lib.levels.php';
    $lvl = CourseLevel::getLevels();
    $arr_status = array(_CUS_RESERVED => $lang->def('_T_USER_STATUS_RESERVED'), _CUS_WAITING_LIST => $lang->def('_WAITING_USERS'), _CUS_CONFIRMED => $lang->def('_T_USER_STATUS_CONFIRMED'), _CUS_SUBSCRIBED => $lang->def('_T_USER_STATUS_SUBS'), _CUS_BEGIN => $lang->def('_T_USER_STATUS_BEGIN'), _CUS_END => $lang->def('_T_USER_STATUS_END'));
    DoceboLanguage::createInstance('course', 'lms');
    $arr_coursestatus = array(CST_PREPARATION => $lang->def('_CST_PREPARATION', 'course', 'lms'), CST_AVAILABLE => $lang->def('_CST_AVAILABLE', 'course', 'lms'), CST_EFFECTIVE => $lang->def('_CST_CONFIRMED', 'course', 'lms'), CST_CONCLUDED => $lang->def('_CST_CONCLUDED', 'course', 'lms'), CST_CANCELLED => $lang->def('_CST_CANCELLED', 'course', 'lms'));
    $course_type = $cinfo['course_type'];
    $there_material = array();
    if ($cinfo['img_othermaterial'] != '') {
        $there_material[] = '&id_course=' . $cinfo['idCourse'];
    }
    // course title -----------------------------------------------------
    $cinfo = array_merge($cinfo, $subscription['course'][$cinfo['idCourse']]);
    // -----------------------------------------------------------------
    $courseuser_st = -10;
    $html = '';
    $intest = '';
    if (!isset($subscription['edition'][$cinfo['idCourse']])) {
        $access = Man_Course::canEnterCourse($cinfo);
        $lb_param = "";
        if ($cinfo['first_is_scorm'][0] != '' && $cinfo['first_is_scorm'][0] != '0') {
            $lb_param .= ";width=" . $cinfo['first_is_scorm'][0] . "";
        }
        if ($cinfo['first_is_scorm'][1] != '' && $cinfo['first_is_scorm'][1] != '0') {
            $lb_param .= ";height=" . $cinfo['first_is_scorm'][1] . "";
        }
        $intest .= '<h2>';
        if ($access['can']) {
            $intest .= '' . ($cinfo['lang_code'] && $cinfo['lang_code'] != 'none' ? '<img src="' . getPathImage('cms') . 'language/' . $cinfo['lang_code'] . '.png" alt="' . $cinfo['lang_code'] . '" /> ' : '') . '<a class="course_enter" href="index.php?modname=course&amp;op=aula&amp;idCourse=' . $cinfo['idCourse'] . '" ' . ($cinfo['direct_play'] == 1 && $cinfo['level'] <= 3 && $cinfo['first_is_scorm'] ? ' rel="shadowbox' . $lb_param . '" title="' . $cinfo['name'] . '"' : ' title="' . $lang->def('_ENTER') . '"') . '>' . $cinfo['name'] . '</a>';
        } else {
            $intest .= '<img class="image_lock" id="locked_' . $cinfo['idCourse'] . '" src="' . getPathImage() . 'course/lock.gif" alt="' . $lang->def('_NOENTER') . '" />' . ($cinfo['lang_code'] && $cinfo['lang_code'] != 'none' ? '<img src="' . getPathImage('cms') . 'language/' . $cinfo['lang_code'] . '.png" alt="' . $cinfo['lang_code'] . '" /> ' : '') . $cinfo['name'] . '';
        }
        $intest .= '</h2>';
        // not editon
        //if($cinfo['level'] >= 4) {
        $intest .= '<p class="course_support_info">' . str_replace(array('[course_type]', '[create_date]', '[enrolled]', '[course_status]'), array($course_type, createDateDistance($cinfo['create_date'], 'catalogue', true), isset($cinfo['enrolled'][0]) ? $cinfo['enrolled'][0] : 0, $arr_coursestatus[$cinfo['course_status']]), $lang->def('_COURSE_INTRO')) . ($cinfo['date_begin'] != '0000-00-00' || $cinfo['date_end'] != '0000-00-00' ? str_replace(array('[date_begin]', '[date_end]'), array(Format::date($cinfo['date_begin'], 'date'), Format::date($cinfo['date_end'], 'date')), $lang->def('_COURSE_DATE')) : '') . '</p>';
        //}
        if ($cinfo['classrooms'] != '') {
            $intest .= '<p class="course_support_info">' . str_replace(array('[classrooms_name]', '[classrooms_location]'), array($cinfo['classrooms']['classroom'], $cinfo['classrooms']['location']), $lang->def('_IN_THE_CLASSROOM')) . '</p>';
        }
        $intest .= '<p class="course_support_info">' . $arr_status[$cinfo['user_status']] . ($cinfo['level'] >= 4 ? str_replace('[level]', $lvl[$cinfo['level']], $lang->def('_USER_LVL')) . ' ' . (trim($cinfo['code']) != '' ? '<br />[' . $cinfo['code'] . '] ' : '') : '') . '</p>';
        if (isset($access['expiring_in']) && $access['expiring_in'] != false && $access['expiring_in'] < 30) {
            $intest .= '<p class="course_support_info">' . str_replace('[expiring_in]', $access['expiring_in'], $lang->def('_EXPIRING_IN')) . '</p>';
        }
        if ($cinfo['show_result'] && $cinfo['user_status'] > _CUS_SUBSCRIBED && $cinfo['user_status'] < _CUS_SUSPEND) {
            $intest .= '<p class="course_support_info show_results">' . '<a href="index.php?modname=course&amp;op=aula&amp;idCourse=' . $cinfo['idCourse'] . '&amp;showresult=1">' . $lang->def('_SHOW_RESULTS') . '</a>' . '</p>';
        }
        $courseuser_st = $cinfo['user_status'];
    } elseif (count($subscription['edition'][$cinfo['idCourse']]) == 1) {
        // edition unique--------------------------------------------------------------------------------
        list($ed_id, $sub_info) = each($subscription['edition'][$cinfo['idCourse']]);
        $ed_info =& $cinfo['edition_list'][$ed_id];
        $cinfo['date_begin'] = $ed_info['date_begin'];
        $cinfo['date_end'] = $ed_info['date_end'];
        $access = Man_Course::canEnterCourse($cinfo);
        if ($ed_info['date_begin'] == '0000-00-00') {
            $ed_info['date_begin'] = '';
        }
        if ($ed_info['date_end'] == '0000-00-00') {
            $ed_info['date_end'] = '';
        }
        $intest = '<h2>';
        if ($access['can']) {
            $intest .= '<a class="course_enter" href="index.php?modname=course&amp;op=aula&amp;idCourse=' . $cinfo['idCourse'] . '&amp;id_e=' . $ed_id . '" ' . 'title="' . $lang->def('_ENTER') . '">' . ($cinfo['lang_code'] && $cinfo['lang_code'] != 'none' ? '<img src="' . getPathImage('cms') . 'language/' . $cinfo['lang_code'] . '.png" alt="' . $cinfo['lang_code'] . '" /> ' : '') . $ed_info['name'] . ($ed_info['date_begin'] != '' || $ed_info['date_end'] != '' ? ' <span>( ' . Format::date($ed_info['date_begin'], 'date') . ' ' . Format::date($ed_info['date_end'], 'date') . ' )</span> ' : '') . '</a>';
        } else {
            $intest .= '<img id="locked_' . $cinfo['idCourse'] . '" src="' . getPathImage() . 'course/lock.gif" alt="' . $lang->def('_NOENTER') . '" />' . ($cinfo['lang_code'] && $cinfo['lang_code'] != 'none' ? '<img src="' . getPathImage('cms') . 'language/' . $cinfo['lang_code'] . '.png" alt="' . $cinfo['lang_code'] . '" /> ' : '') . (trim($ed_info['code']) != '' ? '[' . $ed_info['code'] . '] ' : '') . $ed_info['name'] . ($ed_info['date_begin'] != '' || $ed_info['date_end'] != '' ? ' <span>( ' . Format::date($ed_info['date_begin'], 'date') . ' ' . Format::date($ed_info['date_end'], 'date') . ' )</span> ' : '');
        }
        $intest .= '</h2>';
        //if($sub_info['level'] >= 4) {
        $intest .= '<p class="course_support_info">' . str_replace(array('[course_type]', '[create_date]', '[enrolled]', '[course_status]'), array($ed_info['edition_type'], createDateDistance($cinfo['create_date'], 'catalogue', true), $cinfo['enrolled'][$ed_id], $arr_coursestatus[$ed_info['status']]), $lang->def('_COURSE_INTRO')) . '</p>';
        //}
        if ($ed_info['classrooms'] != '') {
            $intest .= '<p class="course_support_info">' . str_replace(array('[classrooms_name]', '[classrooms_location]'), array($ed_info['classrooms']['classroom'], $ed_info['classrooms']['location']), $lang->def('_IN_THE_CLASSROOM')) . '</p>';
        }
        $intest .= '<p class="course_support_info">' . $arr_status[$sub_info['user_status']] . str_replace('[level]', $lvl[$sub_info['level']], $lang->def('_USER_LVL')) . ' ' . (trim($cinfo['code']) != '' && $sub_info['level'] >= 4 ? '<br />[' . $cinfo['code'] . '] ' : '') . '</p>';
        if ($access['expiring_in'] != false && $access['expiring_in'] < 30) {
            $intest .= '<p class="course_support_info">' . str_replace('[expiring_in]', $access['expiring_in'], $lang->def('_EXPIRING_IN')) . '</p>';
        }
        $courseuser_st = $sub_info['user_status'];
    } else {
        // more than one edition ------------------------------------------------------------------------
        foreach ($subscription['edition'][$cinfo['idCourse']] as $ed_id => $sub_info) {
            //list($ed_id, $sub_info)  = each($subscription['edition'][$cinfo['idCourse']]);
            $ed_info =& $cinfo['edition_list'][$ed_id];
            $cinfo['date_begin'] = $ed_info['date_begin'];
            $cinfo['date_end'] = $ed_info['date_end'];
            $access = Man_Course::canEnterCourse($cinfo);
            if ($ed_info['date_begin'] == '0000-00-00') {
                $ed_info['date_begin'] = '';
            }
            if ($ed_info['date_end'] == '0000-00-00') {
                $ed_info['date_end'] = '';
            }
            $intest .= '<h2>';
            if ($access['can']) {
                $intest .= '<a class="course_enter" href="index.php?modname=course&amp;op=aula&amp;idCourse=' . $cinfo['idCourse'] . '&amp;id_e=' . $ed_id . '" ' . 'title="' . $lang->def('_ENTER') . '">' . ($cinfo['lang_code'] && $cinfo['lang_code'] != 'none' ? '<img src="' . getPathImage('cms') . 'language/' . $cinfo['lang_code'] . '.png" alt="' . $cinfo['lang_code'] . '" /> ' : '') . $ed_info['name'] . ($ed_info['date_begin'] != '' || $ed_info['date_end'] != '' ? ' <span>( ' . Format::date($ed_info['date_begin'], 'date') . ' ' . Format::date($ed_info['date_end'], 'date') . ' )</span> ' : '') . '</a>';
            } else {
                $intest .= '<img id="locked_' . $cinfo['idCourse'] . '" src="' . getPathImage() . 'course/lock.gif" alt="' . $lang->def('_NOENTER') . '" />' . ($cinfo['lang_code'] && $cinfo['lang_code'] != 'none' ? '<img src="' . getPathImage('cms') . 'language/' . $cinfo['lang_code'] . '.png" alt="' . $cinfo['lang_code'] . '" /> ' : '') . (trim($ed_info['code']) != '' ? '[' . $ed_info['code'] . '] ' : '') . $ed_info['name'] . ($ed_info['date_begin'] != '' || $ed_info['date_end'] != '' ? ' <span>( ' . Format::date($ed_info['date_begin'], 'date') . ' ' . Format::date($ed_info['date_end'], 'date') . ' )</span> ' : '');
            }
            $intest .= '</h2>';
            //if($sub_info['level'] >= 4) {
            $intest .= '<p class="course_support_info">' . str_replace(array('[course_type]', '[create_date]', '[enrolled]', '[course_status]'), array($ed_info['edition_type'], createDateDistance($cinfo['create_date'], 'catalogue', true), $cinfo['enrolled'][$ed_id], $arr_coursestatus[$ed_info['status']]), $lang->def('_COURSE_INTRO')) . '</p>';
            //}
            if ($ed_info['classrooms'] != '') {
                $intest .= '<p class="course_support_info">' . str_replace(array('[classrooms_name]', '[classrooms_location]'), array($ed_info['classrooms']['classroom'], $ed_info['classrooms']['location']), $lang->def('_IN_THE_CLASSROOM')) . '</p>';
            }
            $intest .= '<p class="course_support_info">' . $arr_status[$sub_info['user_status']] . str_replace('[level]', $lvl[$sub_info['level']], $lang->def('_USER_LVL')) . (trim($cinfo['code']) != '' && $sub_info['level'] >= 4 ? '<br />[' . $cinfo['code'] . '] ' : '') . '</p>';
        }
        if ($access['expiring_in'] != false && $access['expiring_in'] < 30) {
            $intest .= '<p class="course_support_info">' . str_replace('[expiring_in]', $access['expiring_in'], $lang->def('_EXPIRING_IN')) . '</p>';
        }
        $courseuser_st = $courseuser_st < $sub_info['user_status'] ? $sub_info['user_status'] : $courseuser_st;
    }
    // -----------------------------------------------------------------------------------------
    $html = '<div class="course_container' . (Get::sett('use_social_courselist') == 'on' ? ' double_height' : '') . ($index == 0 ? ' course_container_first' : '') . ($courseuser_st == _CUS_SUBSCRIBED ? ' cc_inprogress' : '') . ($courseuser_st == _CUS_BEGIN ? ' cc_begin' : '') . '">';
    if ($cinfo['use_logo_in_courselist'] == '1' && $cinfo['img_course'] != '' || Get::sett('use_social_courselist') == 'on') {
        $html .= '<div class="course_info_container">';
    }
    if ($cinfo['use_logo_in_courselist'] == '1' && $cinfo['img_course'] != '') {
        $html .= '<ul class="course_score"><li>';
        $html .= '<img height="70" src="' . $GLOBALS['where_files_relative'] . '/doceboLms/' . Get::sett('pathcourse') . $cinfo['img_course'] . '" alt="' . $lang->def('_COURSE_LOGO') . '" />';
        $html .= '</li></ul>';
    }
    $html .= $intest;
    $li = '';
    $li .= '<li class="advice_to_read">' . '<img src="' . getPathImage('lms') . 'coursecatalogue/' . ($cinfo['to_read']['advice'] != 0 ? 'adv_advice' : 'no_advice') . '.jpg" ' . ' title="' . str_replace('[advice]', $cinfo['to_read']['advice'], $lang->def('_ADVERT_ADVICE')) . '" ' . ' alt="' . str_replace('[advice]', $cinfo['to_read']['advice'], $lang->def('_ADVERT_ADVICE')) . '" />' . '</li>';
    $li .= '<li class="forum_to_read">' . '<img src="' . getPathImage('lms') . 'coursecatalogue/' . ($cinfo['to_read']['forum'] != 0 ? 'adv_forum' : 'no_forum') . '.jpg" ' . ' title="' . str_replace('[forum]', $cinfo['to_read']['forum'], $lang->def('_ADVERT_FORUM')) . '" ' . ' alt="' . str_replace('[forum]', $cinfo['to_read']['forum'], $lang->def('_ADVERT_FORUM')) . '" />' . '</li>';
    $li .= '<li class="lobj_to_read">' . '<img src="' . getPathImage('lms') . 'coursecatalogue/' . ($cinfo['to_read']['lobj'] != 0 ? 'adv_lobj' : 'no_lobj') . '.jpg" ' . ' title="' . str_replace('[lobj]', $cinfo['to_read']['lobj'], $lang->def('_ADVERT_LOBJ')) . '" ' . ' alt="' . str_replace('[lobj]', $cinfo['to_read']['lobj'], $lang->def('_ADVERT_LOBJ')) . '" />' . '</li>';
    if ($li != '') {
        $html .= '<ul class="course_advertising">' . $li . '</ul>';
    }
    // course related extra option -------------------------------------------------------------
    if (Get::sett('use_social_courselist') == 'on' || !empty($there_material)) {
        $li = '';
        if (Get::sett('use_social_courselist') == 'on') {
            $li .= '<li class="course_comment">' . '<a href="javascript:;" onclick="openComment(\'' . $cinfo['idCourse'] . '\'); return false;">' . '<span>' . $lang->def('_COMMENTS') . ' (' . (isset($cinfo['comment_count']) ? $cinfo['comment_count'] : '0') . ')</span></a>' . '</li>';
        }
        // the course material -----------------------------------------------------------------
        if (!empty($there_material)) {
            if (count($there_material) == 1) {
                // direct download of material -------------------------------------------------
                $li .= '<li class="course_materials">' . '<a href="' . $url->getUrl('op=donwloadmaterials' . array_pop($there_material)) . '">' . '<span>' . $lang->def('_MATERIALS') . '</span></a>' . '</li>';
            } else {
                // popup download of material --------------------------------------------------
                $li .= '<li class="course_materials">' . '<a href="javascript:;" onclick="openWindowWithAction(\'' . $cinfo['idCourse'] . '\', \'course_materials\'); return false;">' . '<span>' . $lang->def('_MATERIALS') . '</span></a>' . '</li>';
            }
        }
        if ($li != '') {
            $html .= '<ul class="course_related_actions">' . $li . '</ul>';
        }
    }
    /*if ($cinfo['direct_play'] == 1) {
    		$html .= '<p class="showresults">'
    			.'<a href="index.php?modname=course&amp;op=showresults&amp;id_course='.$cinfo['idCourse'].'">'
    			.'<span>'.$lang->def('_SHOW_RESULTS').'</span></a>'
    			.'</p>';
    	}*/
    // score and subscribe action ------------------------------------------------------------
    if (Get::sett('use_social_courselist') == 'on') {
        $html .= '<ul class="course_score">';
        $html .= '<li class="current_score"><span>' . $lang->def('_SCORE') . '</span><br />' . '<strong id="course_score_' . $cinfo['idCourse'] . '">' . $cinfo['course_vote'] . '</strong></li>';
        if ($cinfo['waiting'] == 0) {
            $html .= '<li class="score_it">' . '<a class="good" href="javascript:;" ' . 'onclick="course_vote(\'' . $cinfo['idCourse'] . '\', \'good\'); return false;" ' . 'title="' . $lang->def('_VOTE_GOOD_TITLE') . '">' . '<img id="score_image_good_' . $cinfo['idCourse'] . '" src="' . getPathImage() . 'coursecatalogue/good' . ($cinfo['user_score'] == '1' ? '_grey' : '') . '.png" alt="' . $lang->def('_VOTE_GOOD_ALT') . ' : ' . strip_tags($cinfo['name']) . '" />' . '</a> ' . '<a class="bad" href="javascript:;" ' . 'onclick="course_vote(\'' . $cinfo['idCourse'] . '\', \'bad\'); return false;" ' . 'title="' . $lang->def('_VOTE_BAD_TITLE') . '">' . '<img id="score_image_bad_' . $cinfo['idCourse'] . '" src="' . getPathImage() . 'coursecatalogue/bad' . ($cinfo['user_score'] == '-1' ? '_grey' : '') . '.png" alt="' . $lang->def('_VOTE_BAD_ALT') . ' : ' . strip_tags($cinfo['name']) . '" />' . '</a>' . '</li>';
        } else {
            $li .= '<li class="score_it" id="score_action_' . $cinfo['idCourse'] . '">' . '<img src="' . getPathImage() . 'coursecatalogue/good_grey.png" alt="' . $lang->def('_VOTE_GOOD_ALT') . ' : ' . strip_tags($cinfo['name']) . '" /> ' . '<img src="' . getPathImage() . 'coursecatalogue/bad_grey.png" alt="' . $lang->def('_VOTE_BAD_ALT') . ' : ' . strip_tags($cinfo['name']) . '" />' . '</li>';
        }
        $html .= '</ul>';
    }
    if ($cinfo['use_logo_in_courselist'] == '1' && $cinfo['img_course'] != '' || Get::sett('use_social_courselist') == 'on') {
        $html .= '</div>';
    }
    $html .= '</div>';
    return $html;
}
Exemple #24
0
 public function delDate($id_date)
 {
     $res = false;
     $id_course = $this->getDateCourse($id_date);
     $subscribed = $this->getDateSubscribed($id_date);
     foreach ($subscribed as $id_user) {
         $control = $this->removeUserFromDate($id_user, $id_date, $id_course);
         if (!$control) {
             require_once _lms_ . '/admin/modules/subscribe/subscribe.php';
             require_once _lms_ . '/lib/lib.course.php';
             $docebo_course = new DoceboCourse($id_course);
             $course_man = new Man_Course();
             $course_info = $course_man->getCourseInfo($id_course);
             $date_begin = $course_info["date_begin"];
             $date_end = $course_info["date_end"];
             $group_levels = $docebo_course->getCourseLevel($id_course);
             $user_levels = getSubscribedLevel($id_course, false, false, 0);
             removeSubscription($id_course, $id_user, $group_levels[$user_levels[$id_user]], 0, $date_begin, $date_end);
         }
     }
     if ($this->clearDateDay($id_date)) {
         $query = "DELETE FROM " . $this->date_table . " WHERE id_date = " . $id_date;
         $res = sql_query($query);
     }
     return $res;
 }
 /**
  * execute the connection to source
  **/
 function connect()
 {
     $this->lang = DoceboLanguage::createInstance('rg_report');
     // perform the query for data retriving
     $course_man = new Man_Course();
     $this->acl_man = new DoceboACLManager();
     $p_dr = new PeopleDataRetriever($GLOBALS['dbConn'], $GLOBALS['prefix_fw']);
     $re_people = $p_dr->getAllRowsIdst();
     $this->_readed_end = false;
     $this->row_index = 0;
     $user_selected = array();
     if (!$re_people) {
         $this->_readed_end = true;
         return TRUE;
     }
     while (list($idst) = sql_fetch_row($re_people)) {
         $user_selected[$idst] = $idst;
     }
     $this->users_info = $this->acl_man->getUsers($user_selected);
     $this->id_courses = $course_man->getAllCourses();
     $this->num_iscr = array();
     $this->num_nobegin = array();
     $this->num_itinere = array();
     $this->num_end = array();
     $this->time_in_course = array();
     $effective_user = array();
     $query_course_user = "******" . $GLOBALS['prefix_lms'] . "_courseuser AS cu \r\n\t\tWHERE idUser IN ( " . implode(',', $user_selected) . " ) ";
     $re_course_user = sql_query($query_course_user);
     while (list($id_u, $id_c, $fisrt_access, $date_complete) = sql_fetch_row($re_course_user)) {
         if (isset($this->num_iscr[$id_c])) {
             ++$this->num_iscr[$id_c];
         } else {
             $this->num_iscr[$id_c] = 1;
         }
         if ($fisrt_access === NULL) {
             //never enter
             if (isset($this->num_nobegin[$id_c])) {
                 ++$this->num_nobegin[$id_c];
             } else {
                 $this->num_nobegin[$id_c] = 1;
             }
         } elseif ($date_complete === NULL) {
             //enter
             if (isset($this->num_itinere[$id_c])) {
                 ++$this->num_itinere[$id_c];
             } else {
                 $this->num_itinere[$id_c] = 1;
             }
         } else {
             //complete
             if (isset($this->num_end[$id_c])) {
                 ++$this->num_end[$id_c];
             } else {
                 $this->num_end[$id_c] = 1;
             }
         }
         $effective_user[] = $id_u;
     }
     if (!empty($effective_user)) {
         $query_time = "\r\n\t\t\tSELECT idCourse, SUM(UNIX_TIMESTAMP(lastTime) - UNIX_TIMESTAMP(enterTime)) \r\n\t\t\tFROM " . $GLOBALS['prefix_lms'] . "_tracksession \r\n\t\t\tWHERE idUser IN ( " . implode(',', $effective_user) . " )\r\n\t\t\tGROUP BY idCourse ";
         $re_time = sql_query($query_time);
         while (list($id_c, $time_num) = sql_fetch_row($re_time)) {
             $this->time_in_course[$id_c] = $time_num;
         }
     }
     return TRUE;
 }
Exemple #26
0
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'].'&amp;back='.$GLOBALS['course_descriptor']->getValue('direct_play'));
    	}
    	Util::jump_to('index.php?modname=course&op=showresults&id_course='.$_SESSION['idCourse']);
    }
    */
}
Exemple #27
0
function sessiondetails()
{
    checkPerm('view');
    require_once _base_ . '/lib/lib.table.php';
    $idst_user = importVar('id', true, 0);
    $id_enter = importVar('id_enter', true, 0);
    $p_ini = importVar('p_ini');
    $link = 'index.php?modname=statistic&amp;op=sessiondetails&amp;id=' . $idst_user . '&amp;id_enter=' . $id_enter;
    $nav_bar = new NavBar('ini', Get::sett('visuItem'), 0, 'link');
    $nav_bar->setLink($link . '&amp;p_ini=' . $p_ini);
    $ini = $nav_bar->getSelectedElement();
    $lang =& DoceboLanguage::createInstance('statistic', 'lms');
    $acl_man = Docebo::user()->getAclManager();
    $user_info =& $acl_man->getUser($idst_user, false);
    $query_track = "\r\n\tSELECT g.function, g.type, g.timeof, UNIX_TIMESTAMP(g.timeof) AS unix_time \r\n\tFROM " . $GLOBALS['prefix_lms'] . "_trackingeneral AS g\r\n\tWHERE g.idCourse = '" . (int) $_SESSION['idCourse'] . "' AND g.idUser = '******' AND " . " ( g.idEnter = '" . $id_enter . "' OR (  g.idEnter = 0 AND g.session_id = '" . importVar('sid') . "' ) ) " . " ORDER BY g.timeof \r\n\tLIMIT " . $ini . ", " . Get::sett('visuItem');
    $re_tracks = sql_query($query_track);
    $query_tot_track = "\r\n\tSELECT COUNT(*) \r\n\tFROM " . $GLOBALS['prefix_lms'] . "_trackingeneral \r\n\tWHERE idCourse = '" . (int) $_SESSION['idCourse'] . "' AND idUser = '******' AND idEnter = '" . $id_enter . "'";
    list($tot_elem) = sql_fetch_row(sql_query($query_tot_track));
    $nav_bar->setElementTotal($tot_elem);
    // Find modulename -> name int his course
    require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
    $course_man = new Man_Course();
    $mods_names =& $course_man->getModulesName($_SESSION['idCourse']);
    $page_title = array('index.php?modname=statistic&amp;op=statistic' => $lang->def('_STATISTICS'), 'index.php?modname=statistic&amp;op=userdetails&amp;id=' . $idst_user . '&amp;p_ini=' . $p_ini => $user_info[ACL_INFO_LASTNAME] . $user_info[ACL_INFO_FIRSTNAME] ? $user_info[ACL_INFO_LASTNAME] . ' ' . $user_info[ACL_INFO_FIRSTNAME] : $acl_man->relativeId($user_info[ACL_INFO_USERID]), $lang->def('_VIEW_SESSION_DETAILS'));
    $GLOBALS['page']->add(getTitleArea($page_title, 'statistic') . '<div class="std_block">' . getBackUi('index.php?modname=statistic&amp;op=userdetails&amp;id=' . $idst_user . '&amp;p_ini=' . $p_ini, $lang->def('_BACK')), 'content');
    $tb = new Table(0, $lang->def('_VIEW_SESSION_DETAILS'), $lang->def('_VIEW_SESSION_DETAILS'));
    $type_h = array('', '', '');
    $cont_h = array($lang->def('_DATE'), $lang->def('_TYPE_OF_OPERATION'), $lang->def('_TIME_IN'));
    $tb->setColsStyle($type_h);
    $tb->addHead($cont_h);
    $type_h[2] = 'align_right';
    $tb->setColsStyle($type_h);
    $total_sec = 0;
    $read_previous = false;
    while ($read = mysql_fetch_assoc($re_tracks)) {
        if ($read_previous !== false) {
            $time_in = $read['unix_time'] - $read_previous['unix_time'];
            $hours = (int) ($time_in / 3600);
            $minutes = (int) ($time_in % 3600 / 60);
            $seconds = (int) ($time_in % 60);
            if ($minutes < 10) {
                $minutes = '0' . $minutes;
            }
            if ($seconds < 10) {
                $seconds = '0' . $seconds;
            }
            $readable = $hours . 'h ' . $minutes . 'm ' . $seconds . 's ';
            $cont = array(Format::date($read_previous['timeof'], false, true), '<span class="text_bold">' . (isset($mods_names[$read_previous['function']]) ? $mods_names[$read_previous['function']] : $read_previous['function']) . '</span> [' . $read_previous['type'] . ']', $readable);
            $tb->addBody($cont);
        }
        $read_previous = $read;
    }
    $query_last_track = "\r\n\tSELECT g.function, g.type, g.timeof, UNIX_TIMESTAMP(g.timeof) AS unix_time \r\n\tFROM " . $GLOBALS['prefix_lms'] . "_trackingeneral AS g\r\n\tWHERE g.idCourse = '" . (int) $_SESSION['idCourse'] . "' AND g.idUser = '******' AND g.idEnter = '" . $id_enter . "' \r\n\tLIMIT " . ($ini + Get::sett('visuItem')) . ", 1";
    $re_track = sql_query($query_last_track);
    if (mysql_num_rows($re_track) > 0) {
        $read = mysql_fetch_assoc($re_track);
        $time_in = $read['unix_time'] - $read_previous['unix_time'];
        $hours = (int) ($time_in / 3600);
        $minutes = (int) ($time_in % 3600 / 60);
        $seconds = (int) ($time_in % 60);
        if ($minutes < 10) {
            $minutes = '0' . $minutes;
        }
        if ($seconds < 10) {
            $seconds = '0' . $seconds;
        }
        $readable = $hours . 'h ' . $minutes . 'm ' . $seconds . 's ';
    } else {
        $readable = '';
    }
    $cont = array(Format::date($read_previous['timeof']), '<span class="text_bold">' . (isset($mods_names[$read_previous['function']]) ? $mods_names[$read_previous['function']] : $read_previous['function']) . '</span> [' . $read_previous['type'] . ']', $readable);
    $tb->addBody($cont);
    $GLOBALS['page']->add($tb->getTable() . $nav_bar->getNavBar() . getBackUi('index.php?modname=statistic&amp;op=userdetails&amp;id=' . $idst_user . '&amp;p_ini=' . $p_ini, $lang->def('_BACK')) . '</div>', 'content');
}
 /**
  * Unsubscribe a group of users to a course
  * @param array 	$arr_user 	the id of the users
  * @param int 		$id_course 	the id of the course
  *
  * @return bool true if success, false otherwise
  */
 function unsubscribeUsersEd($arr_users, $id_edition, $id_course = false)
 {
     if (empty($arr_users)) {
         return true;
     }
     if ($id_course == false) {
         require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
         $man = new Man_Course();
         $info = $man->getEditionInfo($id_edition);
         $id_course = $info['idCourse'];
     }
     $group_levels =& $this->course_man->getCourseIdstGroupLevel($id_course);
     $user_level = $this->course_man->getLevelsOfUsers($id_course, $arr_users);
     $re = $this->_query("\r\n\t\tDELETE FROM " . $GLOBALS['prefix_lms'] . "_courseuser\r\n\t\tWHERE idUser IN ( " . implode(',', $arr_users) . " ) AND idCourse = '" . $id_course . "' AND editon_id = '" . $id_edition . "'");
     $survivor = array();
     $query = "\r\n\t\tSELECT idUser\r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_courseuser\r\n\t\tWHERE idUser IN ( " . implode(',', $arr_users) . " ) AND idCourse = '" . $id_course . "'";
     $re_query = sql_query($query);
     while (list($idu) = sql_fetch_row($re_query)) {
         $survivor[$idu] = $idu;
     }
     while (list(, $id_user) = each($arr_users)) {
         if (isset($user_level[$id_user]) && !isset($survivor[$id_user])) {
             $lv = $user_level[$id_user];
             $this->acl_man->removeFromGroup($group_levels[$lv], $id_user);
         }
     }
     return $re;
 }
Exemple #29
0
function modTransaction()
{
    require_once _base_ . '/lib/lib.table.php';
    require_once _base_ . '/lib/lib.form.php';
    require_once _base_ . '/lib/lib.dialog.php';
    require_once _lms_ . '/lib/lib.course.php';
    require_once _lms_ . '/lib/lib.date.php';
    $lang =& DoceboLanguage::createInstance('transaction');
    $acl_man = Docebo::user()->getAclManager();
    $man_transaction = new Man_Transaction();
    $course_man = new Man_Course();
    $date_man = new DateManager();
    $id_transaction = Get::req('id', DOTY_INT, 0);
    $transaction_info = $man_transaction->getTransactionInfo($id_transaction);
    if (isset($_POST['update'])) {
        $payment_status = Get::req('payment_status', DOTY_INT, 0);
        $course_status = Get::req('course_status', DOTY_INT, 0);
        $note = Get::req('note', DOTY_MIXED, '');
        if ($man_transaction->updateTransaction($id_transaction, $payment_status, $course_status, $note)) {
            if (isset($_POST['confirm'])) {
                $activations = array();
                foreach ($_POST['confirm'] as $id => $n) {
                    list($id_course, $id_date) = explode('_', $id);
                    if ($id_date != 0) {
                        $activations[$id_course]['dates'][$id_date] = $id_date;
                    } else {
                        $activations[$id_course] = $id_course;
                    }
                }
                if ($man_transaction->activateCourses($id_transaction, $transaction_info['id_user'], $activations)) {
                    Util::jump_to('index.php?modname=transaction&op=transaction&res=ok');
                }
            } else {
                Util::jump_to('index.php?modname=transaction&op=transaction&res=ok');
            }
        }
        Util::jump_to('index.php?modname=transaction&op=transaction&res=err_up');
    }
    $array_title = array('index.php?modname=transaction&amp;op=transaction' => $lang->def('_TRANSACTION'), $lang->def('_MOD_TRANSACTION'));
    //Status info & note
    $array_payment_status = array('-1' => $lang->def('_CANCELLED'), '0' => $lang->def('_WAITING_PAYMENT'), '1' => $lang->def('_PARTIAL_PAID'), '2' => $lang->def('_PAID'));
    $array_course_status = array('-1' => $lang->def('_CANCELLED'), '0' => $lang->def('_NO_COURSE_ACTIVATED'), '1' => $lang->def('_SOME_COURSE_ACTIVATED'), '2' => $lang->def('_ALL_COURSE_ACTIVATED'));
    cout(getTitleArea($array_title) . '<div class="std_block">' . Form::openForm('transaction_info', 'index.php?modname=transaction&amp;op=mod&amp;id=' . $id_transaction) . Form::openElementSpace() . Form::getDropdown($lang->def('_PAYMENT_STATUS_FILTER'), 'payment_status', 'payment_status', $array_payment_status, $transaction_info['payment_status']) . Form::getDropdown($lang->def('_COURSE_STATUS_FILTER'), 'course_status', 'course_status', $array_course_status, $transaction_info['course_status']) . Form::getSimpleTextarea($lang->def('_NOTES'), 'note', 'note', $transaction_info['note']) . Form::closeElementSpace());
    //User info
    $user_info = $acl_man->getUser($transaction_info['id_user'], false);
    $tb_user = new Table(0, $lang->def('_USER_INFO'), $lang->def('_USER_INFO'));
    $cont_h = array($lang->def('_USERNAME'), $lang->def('_FIRSTNAME'), $lang->def('_LASTNAME'), $lang->def('_EMAIL'));
    $type_h = array('', '', '', '');
    $tb_user->setColsStyle($type_h);
    $tb_user->addHead($cont_h);
    $tb_user->addBody(array($acl_man->relativeId($user_info[ACL_INFO_USERID]), $user_info[ACL_INFO_FIRSTNAME], $user_info[ACL_INFO_LASTNAME], $user_info[ACL_INFO_EMAIL]));
    cout('<br />' . $tb_user->getTable());
    //Payment info if we need it
    //Product info
    $tb_product = new Table(0, $lang->def('_PRODUCT_INFO'), $lang->def('_PRODUCT_INFO'));
    $cont_h = array($lang->def('_CODE'), $lang->def('_NAME'), $lang->def('_DATE_BEGIN'), $lang->def('_DATE_END'), $lang->def('_COURSE_PRIZE'), $lang->def('_CONFIRM_COURSE'));
    $type_h = array('', '', '', '', '', '');
    $tb_product->setColsStyle($type_h);
    $tb_product->addHead($cont_h);
    $transaction_course = $man_transaction->getTransactionCourses($id_transaction);
    foreach ($transaction_course as $id_course => $details) {
        if (is_array($details)) {
            foreach ($details['dates'] as $id_date) {
                $date_info = $date_man->getDateInfo($id_date);
                $checked = false;
                $other = '';
                if ($man_transaction->controlActivation($id_transaction, $id_course, $id_date)) {
                    $checked = true;
                    $other = 'disabled="disabled"';
                }
                $tb_product->addBody(array($date_info['code'], $date_info['name'], Format::date($date_info['date_begin']), Format::date($date_info['date_end']), $date_info['price'], Form::getInputCheckbox($id_course . '_' . $id_date, 'confirm[' . $id_course . '_' . $id_date . ']', 1, $checked, $other)));
            }
        } else {
            $course_info = $course_man->getCourseInfo($id_course);
            $checked = false;
            $other = '';
            if ($man_transaction->controlActivation($id_transaction, $id_course)) {
                $checked = true;
                $other = 'disabled="disabled"';
            }
            $tb_product->addBody(array($course_info['code'], $course_info['name'], $course_info['date_begin'] !== '0000-00-00' ? Format::date($course_info['date_begin'], 'date') . ($course_info['hour_begin'] !== '-1' ? $course_info['hour_begin'] : '') : '', $course_info['date_end'] !== '0000-00-00' ? Format::date($course_info['date_end'], 'date') . ($course_info['hour_end'] !== '-1' ? $course_info['hour_end'] : '') : '', $course_info['prize'] == '' ? '0' : $course_info['prize'], Form::getInputCheckbox($id_course . '_0', 'confirm[' . $id_course . '_0]', 1, $checked, $other)));
        }
    }
    cout('<br />' . $tb_product->getTable() . Form::openButtonSpace() . Form::getButton('update', 'update', $lang->def('_UPDATE')) . Form::getButton('back_mod', 'back_mod', $lang->def('_BACK')) . Form::closeButtonSpace() . Form::closeForm());
    cout('</div>');
}
Exemple #30
0
function subscribeFromCourse()
{
    require_once _base_ . '/lib/lib.form.php';
    require_once $GLOBALS['where_framework'] . '/lib/lib.directory.php';
    require_once _base_ . '/lib/lib.userselector.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.course_managment.php';
    $lang =& DoceboLanguage::CreateInstance('subscribe', 'lms');
    $back_url = 'index.php?modname=course&op=course_list';
    $acl_man =& Docebo::user()->getAclManager();
    $out =& $GLOBALS['page'];
    $out->setWorkingZone('content');
    $id_course = Get::req('id_course', DOTY_INT, 0);
    $edition_id = Get::req('edition_id', DOTY_INT, 0);
    $alert = Get::req('alert', DOTY_INT, 0);
    $delete_prev = Get::req('delete_from_prev', DOTY_INT, 0);
    $sel = new Course_Manager();
    if (isset($_POST['subscribe_import'])) {
        $course_info = Man_Course::getCourseInfo($id_course);
        $level_idst =& getCourseLevel($id_course);
        if (count($level_idst) == 0) {
            $level_idst =& DoceboCourse::createCourseLevel($id_course);
        }
        $course_selected = $sel->getCourseSelection($_POST);
        if (empty($course_selected)) {
            Util::jump_to('index.php?modname=course&op=course_list&result=err');
        }
        $id_course = Get::req('id_course', DOTY_INT, 0);
        $level = Get::req('level', DOTY_INT, 0);
        $status = Get::req('status', DOTY_INT, 0);
        $gsel = array();
        foreach ($course_selected as $trash => $id) {
            $gsel[$id] = getCourseLevel($id);
        }
        $query = "SELECT idUser, idCourse, level" . " FROM " . $GLOBALS['prefix_lms'] . "_courseuser" . " WHERE idCourse IN (" . implode(',', $course_selected) . ")";
        if ($level) {
            $query .= " AND level = '" . $level . "'";
        }
        if ($status != '-2') {
            $query .= " AND status = '" . $status . "'";
        }
        $result = sql_query($query);
        $array_user = array();
        $user_subscribed = array();
        while (list($id_user, $id_prev_course, $lv_sel) = sql_fetch_row($result)) {
            if ($delete_prev) {
                removeSubscription($id_prev_course, $id_user, $gsel[$id_prev_course][$lv_sel]);
            }
            // Add in group for permission
            $acl_man->addToGroup($level_idst[$lv_sel], $id_user);
            // Add in table
            $re = sql_query("\r\n\t\t\tINSERT INTO " . $GLOBALS['prefix_lms'] . "_courseuser\r\n\t\t\t( idUser, idCourse, edition_id, level, waiting, subscribed_by, date_inscr )\r\n\t\t\tVALUES\r\n\t\t\t( '" . $id_user . "', '" . $id_course . "', '" . $edition_id . "', '" . $lv_sel . "', '0', '" . getLogUserId() . "', '" . date("Y-m-d H:i:s") . "' )\t");
            if ($re) {
                $user_subscribed[] = $id_user;
                addUserToTimeTable($id_user, $id_course, $edition_id);
            }
        }
        Docebo::user()->loadUserSectionST('/lms/course/private/');
        Docebo::user()->SaveInSession();
        require_once _base_ . '/lib/lib.eventmanager.php';
        $array_subst = array('[url]' => Get::sett('url'), '[course]' => $course_info['name'], '[medium_time]' => $course_info['mediumTime'], '[course_name]' => $course_info['name'], '[course_code]' => $course['code']);
        if (!empty($user_subscribed) && $alert) {
            // message to user that is subscribed
            $msg_composer = new EventMessageComposer();
            $msg_composer->setSubjectLangText('email', '_NEW_USER_SUBSCRIBED_SUBJECT', false);
            $msg_composer->setBodyLangText('email', '_NEW_USER_SUBSCRIBED_TEXT', $array_subst);
            $msg_composer->setBodyLangText('sms', '_NEW_USER_SUBSCRIBED_TEXT_SMS', $array_subst);
            // send message to the user subscribed
            createNewAlert('UserCourseInserted', 'subscribe', 'insert', '1', 'User subscribed', $user_subscribed, $msg_composer);
        }
        Util::jump_to('index.php?modname=course&op=course_list&result=ok');
    }
    $sel->setLink('index.php?modname=meta_certificate&amp;op=new_assign');
    $sel->show_coursepath_selector = false;
    $sel->show_catalogue_selector = false;
    $array_level = CourseLevel::getLevels();
    $array_level['0'] = $lang->def('_ALL');
    $arr_status = array('-2' => $lang->def('_ALL'), _CUS_CONFIRMED => $lang->def('_USER_STATUS_CONFIRMED'), _CUS_SUBSCRIBED => $lang->def('_USER_STATUS_SUBS'), _CUS_BEGIN => $lang->def('_USER_STATUS_BEGIN'), _CUS_END => $lang->def('_USER_STATUS_END'), _CUS_SUSPEND => $lang->def('_SUSPENDED'), _CUS_CANCELLED => $lang->def('_USER_STATUS_CANCELLED'));
    $out->add(getTitleArea($lang->def('_IMPORT_FROM_COURSE')) . '<div class="std_block">' . Form::openForm('course_selection', 'index.php?modname=subscribe&amp;op=subscribe_from_course') . Form::openElementSpace() . Form::getDropdown($lang->def('_LEVEL_TO_IMPORT'), 'level', 'level', $array_level, isset($_POST['level']) ? $_POST['level'] : '0') . Form::getDropdown($lang->def('_STATUS_TO_IMPORT'), 'status', 'status', $arr_status, isset($_POST['status']) ? $_POST['status'] : '-2') . Form::getCheckbox($lang->def('_SEND_ALERT'), 'alert', 'alert', '1', $delete_prev) . Form::getCheckbox($lang->def('_DELETE'), 'delete_from_prev', 'delete_from_prev', '1', $delete_prev) . Form::closeElementSpace());
    $sel->loadSelector(false);
    $out->add(Form::getHidden('id_course', 'id_course', $id_course) . Form::getHidden('edition_id', 'edition_id', $edition_id) . Form::openButtonSpace() . Form::getBreakRow() . Form::getButton('subscribe_import', 'subscribe_import', $lang->def('_SUBSCRIBE')) . Form::getButton('undo_course', 'undo_course', $lang->def('_UNDO')) . Form::closeButtonSpace() . Form::closeForm() . '</div>');
}