public function getEditions($params) { require_once _lms_ . '/lib/lib.course.php'; require_once _lms_ . '/lib/lib.edition.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)); } } } $edition_man = new EditionManager(); $course_list = $edition_man->getEditionsInfoByCourses($course_id); $course_man = new Man_Course(); $course = $course_man->getCourseInfo($course_id); foreach ($course_list[$course_id] as $key => $course_info) { $output[]['course_info'] = array('course_id' => $course['idCourse'], 'edition_id' => $course_info['id_edition'], 'code' => str_replace('&', '&', $course_info['code']), 'course_name' => str_replace('&', '&', $course_info['name']), 'course_description' => str_replace('&', '&', $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_date_begin'], 'sub_end_date' => $course_info['sub_date_end'], 'date_begin' => $course_info['date_begin'], 'date_end' => $course_info['date_end'], 'course_link' => Get::sett('url') . _folder_lms_ . '/index.php?modname=course&op=aula&idCourse=' . $course['idCourse']); } //$output['debug']=print_r($course_list, true).print_r($course, true); return $output; }
} $query_selmenun = "SELECT *\n\tFROM " . $GLOBALS['prefix_lms'] . "_htmlfront\n\tWHERE id_course = '" . $id_dupcourse . "' "; $result_selmenun = sql_query($query_selmenun); while ($list_selmenun = sql_fetch_array($result_selmenun)) { $query_dupmen = "INSERT INTO " . $GLOBALS['prefix_lms'] . "_htmlfront\n\t\t(id_course, textof)\n\t\tVALUES\n\t\t('" . $new_course_dup . "', '" . mysql_escape_string($list_selmenun['textof']) . "')"; $result_dupmen = sql_query($query_dupmen); } //Util::jump_to('index.php?modname=course&op=course_list&result=ok_course'); return true; } switch ($op) { case "course_autocomplete": require_once _lms_ . '/lib/lib.edition.php'; require_once _lms_ . '/lib/lib.date.php'; require_once _base_ . '/lib/lib.json.php'; $ed_man = new EditionManager(); $dt_man = new DateManager(); $json = new Services_JSON(); $output = array('courses' => array()); $filter = Get::req('query', DOTY_STRING, ""); $results = Get::req('results', DOTY_INT, Get::sett('visuItem', 25)); if ($filter != "") { $query = "SELECT idCourse, code, name, course_type, course_edition FROM %lms_course " . " WHERE code LIKE '%" . $filter . "%' OR name LIKE '%" . $filter . "%' ORDER BY code, name " . ($results > 0 ? " LIMIT 0, " . (int) $results : ""); $res = sql_query($query); if ($res) { while (list($id_course, $code, $name, $course_type, $course_edition) = sql_fetch_row($res)) { //construct record for course instance $record = array('cname' => ($code != "" ? '[' . $code . '] ' : '') . $name, 'id_course' => $id_course, 'code' => $code, 'name' => $name, 'code_highlight' => Layout::highlight($code, $filter), 'name_highlight' => Layout::highlight($name, $filter)); //detect if the course is of type classroom or has editions //TO DO: optimization, do not put queries in iterations if ($course_type == 'elearning' && $course_edition > 0) {
/** * @param int $id_course the id of the course * @param bool $subdived_for_level if is true the array is in the form * [id_lv] => ([] => id_user, [] => id_user, ...), [id_lv] => ([] => id_user, ...) * @param int $id_level if is not false the array contains only a list of id_user of the level passed * @param bool $exclude_waiting if true exclude the user in wait status * * @return array contains the id_user of the user subscribed, the structure is dependent of the other param */ function getSubscribedInfo($id_course, $subdived_for_level = false, $id_level = false, $exclude_waiting = false, $status = false, $edition_id = false, $sort = false, $user_filter = '', $group_all_members = false, $limit = false, $date_id = false) { $acl_man =& Docebo::user()->getAclManager(); $id_users = array(); $query_courseuser = "******" . $GLOBALS['prefix_lms'] . "_courseuser AS c"; if ($sort || $user_filter !== '') { $query_courseuser .= " JOIN " . $GLOBALS['prefix_fw'] . "_user AS u ON u.idst = c.idUser"; } $query_courseuser .= " WHERE c.idCourse = '" . $id_course . "'"; if ($exclude_waiting) { $query_courseuser .= " AND c.waiting = 0"; } if ($id_level !== false) { $query_courseuser .= " AND c.level = '" . $id_level . "'"; } if ($status !== false) { $query_courseuser .= " AND c.status = '" . $status . "'"; } if ($group_all_members !== false) { $query_courseuser .= " AND c.idUser IN (" . implode(',', $group_all_members) . ")"; } if ($edition_id !== false && $edition_id > 0) { require_once _lms_ . '/lib/lib.edition.php'; $ed_man = new EditionManager(); $ed_users = $ed_man->getEditionSubscribed($edition_id); if (!empty($ed_users)) { $query_courseuser .= " AND c.idUser IN (" . implode(",", $ed_users) . ")"; } } if ($date_id !== false && $date_id > 0) { require_once _lms_ . '/lib/lib.date.php'; $date_man = new DateManager(); $dt_users_arr = $date_man->getUserForPresence($date_id); $dt_users = array_keys($dt_users_arr); if (!empty($dt_users)) { $query_courseuser .= " AND c.idUser IN (" . implode(",", $dt_users) . ")"; } else { // se per quella data o edizione non è iscritto nessun utente $query_courseuser .= " AND c.idUser IN (-1)"; } } if ($user_filter !== '') { $query_courseuser .= " AND (u.firstname LIKE '%" . $user_filter . "%' OR u.lastname LIKE '%" . $user_filter . "%' OR u.userid LIKE '%" . $user_filter . "%')"; } if ($sort) { $query_courseuser .= " ORDER BY u.lastname, u.firstname, u.userid"; } if ($limit !== false) { $query_courseuser .= " LIMIT " . (int) $limit . ", " . (int) Get::sett('visuItem'); } $re_courseuser = sql_query($query_courseuser); while (list($id_user, $lv, $is_waiting, $status, $absent) = sql_fetch_row($re_courseuser)) { if ($subdived_for_level === false) { $id_users[$id_user] = array('idUser' => $id_user, 'level' => $lv, 'waiting' => $is_waiting, 'status' => $status, 'absent' => $absent); } else { if ($is_waiting) { $id_users['waiting'][$id_user] = array('idUser' => $id_user, 'level' => $lv, 'waiting' => $is_waiting, 'status' => $status, 'absent' => $absent); } else { $id_users[$lv][$id_user] = array('idUser' => $id_user, 'level' => $lv, 'waiting' => $is_waiting, 'status' => $status, 'absent' => $absent); } } } return $id_users; }
public function updateUserStatus($id_user, $new_status) { if ($this->id_edition != 0) { require_once _lms_ . '/lib/lib.subscribe.php'; $subscribe_man = new CourseSubscribe_Manager(); if ($new_status == _CUS_END) { require_once _lms_ . '/lib/lib.edition.php'; $edition_man = new EditionManager(); $edition_man->setEditionFinished($this->id_edition, $id_user); } return $subscribe_man->updateUserStatusInCourse($id_user, $this->id_course, $new_status); } elseif ($this->id_date != 0) { require_once _lms_ . '/lib/lib.subscribe.php'; $subscribe_man = new CourseSubscribe_Manager(); if ($new_status == _CUS_END) { require_once _lms_ . '/lib/lib.date.php'; $date_man = new DateManager(); $date_man->setDateFinished($this->id_date, $id_user); } return $subscribe_man->updateUserStatusInCourse($id_user, $this->id_course, $new_status); } else { require_once _lms_ . '/lib/lib.subscribe.php'; $subscribe_man = new CourseSubscribe_Manager(); return $subscribe_man->updateUserStatusInCourse($id_user, $this->id_course, $new_status); } }
} if (isset($filter['c_flatview']['value'])) { $filter_status['c_flatview'] = $filter['c_flatview']['value']; } else { $filter_status['c_flatview'] = $_SESSION['course_category']['filter_status']['c_flatview']; } if (isset($filter['c_waiting']['value'])) { $filter_status['c_waiting'] = $filter['c_waiting']['value']; } else { $filter_status['c_waiting'] = $_SESSION['course_category']['filter_status']['c_waiting']; } $_SESSION['course_category']['filter_status'] = $filter_status; require_once _lms_ . '/lib/lib.course.php'; $man_courses = new Man_Course(); require_once _lms_ . '/lib/lib.edition.php'; $edition_manager = new EditionManager(); $num_edition = $edition_manager->getEditionNumber(); $course_status = array(CST_PREPARATION => $lang->def('_CST_PREPARATION'), CST_AVAILABLE => $lang->def('_CST_AVAILABLE'), CST_EFFECTIVE => $lang->def('_CST_CONFIRMED'), CST_CONCLUDED => $lang->def('_CST_CONCLUDED'), CST_CANCELLED => $lang->def('_CST_CANCELLED')); $courses = array(); $course_list =& $man_courses->getCoursesRequest($startIndex, $results, $sort, $dir, $filter); require_once _lms_ . '/lib/lib.permission.php'; if (Docebo::user()->getUserLevelId() == ADMIN_GROUP_PUBLICADMIN) { $moderate = checkPerm('moderate', true, 'public_course_admin', 'lms'); } elseif (Docebo::user()->getUserLevelId() == ADMIN_GROUP_ADMIN) { $moderate = checkPerm('moderate', true, 'course', 'lms'); } else { $moderate = true; } while ($row = sql_fetch_assoc($course_list)) { $row['status'] = $course_status[$row['status']]; $highlight = false;
public function sel_users_coursepath_actionTask() { $id_path = Get::Req('id_path', DOTY_INT, 0); if ($id_path <= 0) { //... return; } $selection = Get::req('userselector_input', DOTY_MIXED, true); $new_selection = $selection['coursepath_subscriptions']; $old_selection = $this->model->getCoursePathSubscriptionsList($id_path); $new_selection = explode(",", $new_selection); $new_selection = $this->acl_man->getAllUsersFromSelection($new_selection); $_common = array_intersect($new_selection, $old_selection); $_to_add = array_diff($new_selection, $_common); $_to_del = array_diff($old_selection, $_common); $res = true; if (!$res) { $result = 'err_subscribe'; } else { $result = 'ok_subcribe'; } require_once _lms_ . '/lib/lib.coursepath.php'; $path_man = new CoursePath_Manager(); //1 - get list of the courses of the coursepath $base_url = 'index.php?r=' . $this->link . '/show_coursepath&id_path=' . (int) $id_path; $courses = $path_man->getAllCourses(array($id_path)); if (empty($courses)) { Util::jump_to($base_url); } //2 - check if there are any editions or classrooms require_once $GLOBALS['where_lms'] . '/lib/lib.course.php'; $course_man = new Man_Course(); $classroom = $course_man->getAllCourses(false, 'classroom', $courses); $edition = $course_man->getAllCourses(false, 'edition', $courses); //3 - if yes, then make a second step in order to choose editions and classrooms if (!empty($classroom) || !empty($edition)) { $classroom_list = array(); if (!empty($classroom)) { require_once _lms_ . '/lib/lib.date.php'; $date_man = new DateManager(); foreach ($classroom as $id_course => $info) { $classrooms = $date_man->getCourseDate($id_course, true); $classrooms_for_dropdown = array(); $classrooms_for_dropdown[0] = Lang::t('_NO_CLASSROOM_SUBSCRIPTION', 'coursepath'); foreach ($classrooms as $classroom_info) { $classrooms_for_dropdown[$classroom_info['id_date']] = $classroom_info['code'] . ' - ' . $classroom_info['name'] . ' - ' . Format::date($classroom_info['date_begin'], 'date') . ' - ' . Format::date($classroom_info['date_end'], 'date'); } $classroom_list[] = array('id_course' => $id_course, 'label' => $info['name'], 'list' => $classrooms_for_dropdown); //cout(Form::getDropdown(Lang::t('_EDITION_SELECTION', 'coursepath').' : '.$info['code'].' - '.$info['name'], 'classroom_'.$id_course, 'classroom_'.$id_course, $edition_for_dropdown)); } } $edition_list = array(); if (!empty($edition)) { require_once _lms_ . '/lib/lib.edition.php'; $edition_man = new EditionManager(); foreach ($edition as $id_course => $info) { $editions = $edition_man->getEditionsInfoByCourses($id_course); $editions_for_dropdown = array(); $editions_for_dropdown[0] = Lang::t('_NONE', 'coursepath'); foreach ($editions[$id_course] as $edition_info) { $editions_for_dropdown[$edition_info['id_edition']] = $edition_info['code'] . ' - ' . $edition_info['name'] . ' - ' . Format::date($edition_info['date_begin'], 'date') . ' - ' . Format::date($edition_info['date_end'], 'date'); } $edition_list[] = array('id_course' => $id_course, 'label' => $info['name'], 'list' => $edition_for_dropdown); //cout(Form::getDropdown(Lang::t('_EDITION_SELECTION', 'coursepath').' : '.$info['code'].' - '.$info['name'], 'edition_'.$id_course, 'edition_'.$id_course, $edition_for_dropdown)); } } $this->render('choose_editions_coursepath', array('id_path' => $id_path, 'courses_list' => $courses, 'editions_list' => $edition_list, 'classrooms_list' => $classroom_list, 'users_to_add' => $_to_add, 'users_to_del' => $_to_del, 'path_name' => $this->model->getCoursepathNameForSubscription($id_path))); } else { $path_man->subscribeUserToCoursePath($id_path, $_to_add); require_once _lms_ . '/lib/lib.course.php'; foreach ($courses as $id_course) { $docebo_course = new DoceboCourse($id_course); $level_idst =& $docebo_course->getCourseLevel($id_course); if (count($level_idst) == 0 || $level_idst[1] == '') { $level_idst =& $docebo_course->createCourseLevel($id_course); } foreach ($_to_add as $id_user) { $level = 3; //student $waiting = false; //$this->acl_man->addToGroup($level_idst[$level], $id_user); $this->_addToCourseGroup($level_idst[$level], $id_user); $this->model->id_course = $id_course; $this->model->subscribeUser($id_user, $level, $waiting); } } Util::jump_to('index.php?r=' . $this->link . '/show_coursepath&id_path=' . (int) $id_path . '&res=' . $result); } }
function addsubscriptionedition() { require_once _lms_ . '/lib/lib.subscribe.php'; require_once _lms_ . '/lib/lib.coursepath.php'; $cpath_man = new CoursePath_Manager(); $subs_man = new CourseSubscribe_Management(); $id_path = Get::req('id_path', DOTY_INT, 0); $user_selected = unserialize(urldecode(Get::req('users', DOTY_MIXED, array()))); $courses = $cpath_man->getAllCourses(array($id_path)); if (isset($_POST['undo']) || !isset($_POST['save'])) { Util::jump_to('index.php?modname=coursepath&op=addsubscription&id_path=' . $id_path); } $re = true; $query_pathlist = "\r\n\tSELECT path_name, subscribe_method\r\n\tFROM " . $GLOBALS['prefix_lms'] . "_coursepath\r\n\tWHERE id_path = '" . $id_path . "'\r\n\tORDER BY path_name "; list($path_name, $subscribe_method) = sql_fetch_row(sql_query($query_pathlist)); if ($subscribe_method != 1 && !checkPerm('moderate', true)) { $waiting = 1; } else { $waiting = 0; } $users_subsc = array(); $course_man = new Man_Course(); $assessment = $course_man->getAllCourses(false, 'assessment', $courses); $classroom = $course_man->getAllCourses(false, 'classroom', $courses); $edition = $course_man->getAllCourses(false, 'edition', $courses); $array_id_date = array(); $array_id_edition = array(); if (!empty($classroom)) { foreach ($classroom as $id_course => $info) { if (Get::req('classroom_' . $id_course, DOTY_INT, 0) != 0) { $array_id_date[Get::req('classroom_' . $id_course, DOTY_INT, 0)] = Get::req('classroom_' . $id_course, DOTY_INT, 0); } } } if (!empty($edition)) { foreach ($edition as $id_course => $info) { if (Get::req('edition_' . $id_course, DOTY_INT, 0) != 0) { $array_id_edition[Get::req('edition_' . $id_course, DOTY_INT, 0)] = Get::req('edition_' . $id_course, DOTY_INT, 0); } } } require_once _lms_ . '/lib/lib.date.php'; $date_man = new DateManager(); require_once _lms_ . '/lib/lib.edition.php'; $edition_man = new EditionManager(); while (list(, $id_user) = each($user_selected)) { $text_query = "\r\n\t\tINSERT INTO " . $GLOBALS['prefix_lms'] . "_coursepath_user\r\n\t\t( id_path, idUser, waiting, subscribed_by ) VALUES\r\n\t\t( '" . $id_path . "', '" . $id_user . "', '" . $waiting . "', '" . getLogUserId() . "' )"; $re_s = sql_query($text_query); if ($re_s == true) { $users_subsc[] = $id_user; } $re &= $re_s; if (!empty($assessment)) { foreach ($assessment as $id_assessment => $assessment_info) { sql_query("INSERT INTO %lms_assessment_user (id_assessment, id_user, type_of) VALUES ('" . $id_assessment . "', '" . $id_user . "', 'user')"); } reset($assessment); } if (!empty($array_id_date)) { foreach ($array_id_date as $id_date) { $date_man->addUserToDate($id_date, $id_user, Docebo::user()->getIdSt()); } reset($array_id_date); } if (!empty($array_id_edition)) { foreach ($array_id_edition as $id_edition) { $edition_man->addUserToEdition($id_edition, $id_user, Docebo::user()->getIdSt()); } reset($array_id_edition); } } // now subscribe user to all the course if ($waiting == 0) { $re &= $subs_man->multipleSubscribe($users_subsc, $courses, 3); } Util::jump_to('index.php?modname=coursepath&op=pathlist&result=' . ($re ? 'ok' : 'err')); }