public function updateUserSubscription($params) { require_once _lms_ . '/lib/lib.subscribe.php'; require_once _lms_ . '/lib/lib.course.php'; $output = array(); $output['success'] = true; if (empty($params['idst']) || (int) $params['idst'] <= 0) { return false; // return array('success'=>true, 'debug'=>print_r($params, true)); } else { $user_id = $params['idst']; } $course_id = isset($params['course_id']) ? (int) $params['course_id'] : false; $course_code = isset($params['course_code']) ? $params['course_code'] : false; $edition_id = isset($params['edition_id']) ? (int) $params['edition_id'] : false; $edition_code = isset($params['edition_code']) ? $params['edition_code'] : false; $classroom_id = isset($params['classroom_id']) ? (int) $params['classroom_id'] : false; $classroom_code = isset($params['classroom_code']) ? $params['classroom_code'] : false; $user_level = $this->getUserLevelId(isset($params['user_level']) ? $params['user_level'] : false); $user_status = $this->getUserStatusId(isset($params['user_status']) ? $params['user_status'] : false); $acl_man = Docebo::user()->getAclManager(); $course_man = new Man_Course(); $db = DbConn::getInstance(); $course_info = false; $edition_info = false; $classroom_info = false; $this->fillCourseDataFromParams($params, $db, $course_id, $edition_id, $classroom_id, $course_code, $edition_code, $classroom_code, $course_info, $edition_info, $classroom_info, $output); // --------------- update user subscription: ------------------------ $model = new SubscriptionAlms($course_id, $edition_id, $classroom_id); $docebo_course = new DoceboCourse($course_id); $level_idst = $docebo_course->getCourseLevel($course_id); if (count($level_idst) == 0 || $level_idst[1] == '') { $level_idst = $docebo_course->createCourseLevel($course_id); } $update_ok = true; // -- update level ----- if (!empty($user_level)) { $old_level = $model->getUserLevel($user_id); if (isset($level_idst[$user_level]) && isset($level_idst[$old_level])) { $acl_man->removeFromGroup($level_idst[$old_level], $user_id); $acl_man->addToGroup($level_idst[$user_level], $user_id); $ok = $model->updateUserLevel($user_id, $user_level); if (!$ok) { $update_ok = false; } } } // -- update status ----- if (!empty($user_status)) { $status_arr = $model->getUserStatusList(); if (isset($status_arr[$user_status])) { $ok = $model->updateUserStatus($user_id, $user_status); if (!$ok) { $update_ok = false; } } } if (!$update_ok) { $output['success'] = false; } else { $output['message'] = 'User subscription has been updated'; } return $output; }
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&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 duplicateCourse() { $id_dupcourse = Get::req('id_course', DOTY_INT, 0); // read the old course info $query_sel = "SELECT *\n\tFROM " . $GLOBALS['prefix_lms'] . "_course\n\tWHERE idCourse = '" . $id_dupcourse . "' "; $result_sel = sql_query($query_sel); $list_sel = sql_fetch_array($result_sel); foreach ($list_sel as $k => $v) { $list_sel[$k] = mysql_escape_string($v); } $new_course_dup = 0; $new_file_array = array(); if ($list_sel['imgSponsor'] !== '') { $new_name_array = explode('_', str_replace('course_sponsor_logo_', '', $list_sel['imgSponsor'])); $filename = 'course_sponsor_logo_' . mt_rand(0, 100) . '_' . time() . '_' . str_replace('course_sponsor_logo_' . $new_name_array[0] . '_' . $new_name_array[1] . '_', '', $list_sel['imgSponsor']); $new_file_array[0]['old'] = $list_sel['imgSponsor']; $new_file_array[0]['new'] = $filename; $list_sel['imgSponsor'] = $filename; } if ($list_sel['img_course'] !== '') { $new_name_array = explode('_', str_replace('course_logo_', '', $list_sel['img_course'])); $filename = 'course_logo_' . mt_rand(0, 100) . '_' . time() . '_' . str_replace('course_logo_' . $new_name_array[0] . '_' . $new_name_array[1] . '_', '', $list_sel['img_course']); $new_file_array[1]['old'] = $list_sel['img_course']; $new_file_array[1]['new'] = $filename; $list_sel['img_course'] = $filename; } if ($list_sel['img_material'] !== '') { $new_name_array = explode('_', str_replace('course_user_material_', '', $list_sel['img_material'])); $filename = 'course_user_material_' . mt_rand(0, 100) . '_' . time() . '_' . str_replace('course_user_material_' . $new_name_array[0] . '_' . $new_name_array[1] . '_', '', $list_sel['img_material']); $new_file_array[2]['old'] = $list_sel['img_material']; $new_file_array[2]['new'] = $filename; $list_sel['img_material'] = $filename; } if ($list_sel['img_othermaterial'] !== '') { $new_name_array = explode('_', str_replace('course_otheruser_material_', '', $list_sel['img_othermaterial'])); $filename = 'course_otheruser_material_' . mt_rand(0, 100) . '_' . time() . '_' . str_replace('course_otheruser_material_' . $new_name_array[0] . '_' . $new_name_array[1] . '_', '', $list_sel['img_othermaterial']); $new_file_array[3]['old'] = $list_sel['img_othermaterial']; $new_file_array[3]['new'] = $filename; $list_sel['img_othermaterial'] = $filename; } if ($list_sel['course_demo'] !== '') { $new_name_array = explode('_', str_replace('course_demo_', '', $list_sel['course_demo'])); $filename = 'course_demo_' . mt_rand(0, 100) . '_' . time() . '_' . str_replace('course_demo_' . $new_name_array[0] . '_' . $new_name_array[1] . '_', '', $list_sel['course_demo']); $new_file_array[4]['old'] = $list_sel['course_demo']; $new_file_array[4]['new'] = $filename; $list_sel['course_demo'] = $filename; } // duplicate the entry of learning_course $query_ins = "INSERT INTO " . $GLOBALS['prefix_lms'] . "_course\n\t\t( idCategory, code, name, description, lang_code, status, level_show_user,\n\t\tsubscribe_method, linkSponsor, imgSponsor, img_course, img_material, img_othermaterial,\n\t\tcourse_demo, mediumTime, permCloseLO, userStatusOp, difficult, show_progress, show_time, show_extra_info,\n\t\tshow_rules, valid_time, max_num_subscribe, min_num_subscribe,\n\t\tmax_sms_budget, selling, prize, course_type, policy_point, point_to_all, course_edition, classrooms, certificates,\n\t\tcreate_date, security_code, imported_from_connection, course_quota, used_space, course_vote, allow_overbooking, can_subscribe,\n\t\tsub_start_date, sub_end_date, advance, show_who_online, direct_play, autoregistration_code, use_logo_in_courselist )\n\tVALUES\n\t\t( '" . $list_sel['idCategory'] . "', '" . $list_sel['code'] . "', '" . "Copia di " . $list_sel['name'] . "', '" . $list_sel['description'] . "', '" . $list_sel['lang_code'] . "', '" . $list_sel['status'] . "', '" . $list_sel['level_show_user'] . "',\n\t\t'" . $list_sel['subscribe_method'] . "', '" . $list_sel['linkSponsor'] . "', '" . $list_sel['imgSponsor'] . "', '" . $list_sel['img_course'] . "', '" . $list_sel['img_material'] . "', '" . $list_sel['img_othermaterial'] . "',\n\t\t'" . $list_sel['course_demo'] . "', '" . $list_sel['mediumTime'] . "', '" . $list_sel['permCloseLO'] . "', '" . $list_sel['userStatusOp'] . "', '" . $list_sel['difficult'] . "', '" . $list_sel['show_progress'] . "', '" . $list_sel['show_time'] . "', '" . $list_sel['show_extra_info'] . "',\n\t\t'" . $list_sel['show_rules'] . "', '" . $list_sel['valid_time'] . "', '" . $list_sel['max_num_subscribe'] . "', '" . $list_sel['min_num_subscribe'] . "',\n\t\t'" . $list_sel['max_sms_budget'] . "', '" . $list_sel['selling'] . "', '" . $list_sel['prize'] . "', '" . $list_sel['course_type'] . "', '" . $list_sel['policy_point'] . "', '" . $list_sel['point_to_all'] . "', '" . $list_sel['course_edition'] . "', '" . $list_sel['classrooms'] . "', '" . $list_sel['certificates'] . "',\n\t\t'" . $list_sel['create_date'] . "', '" . $list_sel['security_code'] . "', '" . $list_sel['imported_from_connection'] . "', '" . $list_sel['course_quota'] . "', '" . $list_sel['used_space'] . "', '" . $list_sel['course_vote'] . "', '" . $list_sel['allow_overbooking'] . "', '" . $list_sel['can_subscribe'] . "',\n\t\t'" . $list_sel['sub_start_date'] . "', '" . $list_sel['sub_end_date'] . "', '" . $list_sel['advance'] . "', '" . $list_sel['show_who_online'] . "', '" . $list_sel['direct_play'] . "', '" . $list_sel['autoregistration_code'] . "', '" . $list_sel['use_logo_in_courselist'] . "' )"; $result_ins = sql_query($query_ins); if (!$result_ins) { //Util::jump_to('index.php?modname=course&op=course_list&result=err_course'); return false; } // the id of the new course created $new_course_dup = sql_insert_id(); //Create the new course file $path = Get::sett('pathcourse'); $path = '/appLms/' . Get::sett('pathcourse') . (substr($path, -1) != '/' && substr($path, -1) != '\\' ? '/' : ''); require_once _base_ . '/lib/lib.upload.php'; sl_open_fileoperations(); foreach ($new_file_array as $file_info) { sl_copy($path . $file_info['old'], $path . $file_info['new']); } sl_close_fileoperations(); // copy the old course menu into the new one $query_selmen = "SELECT *\n\tFROM " . $GLOBALS['prefix_lms'] . "_menucourse_main\n\tWHERE idCourse = '" . $id_dupcourse . "' "; $result_selmen = sql_query($query_selmen); while ($list_selmen = sql_fetch_array($result_selmen)) { $query_dupmen = "INSERT INTO " . $GLOBALS['prefix_lms'] . "_menucourse_main " . " (idCourse, sequence, name, image) " . " VALUES " . " ( '" . $new_course_dup . "', '" . $list_selmen['sequence'] . "', '" . $list_selmen['name'] . "', '" . $list_selmen['image'] . "' )"; $result_dupmen = sql_query($query_dupmen); $array_seq[$list_selmen['idMain']] = sql_insert_id(); } $query_selmenun = "SELECT *\n\tFROM " . $GLOBALS['prefix_lms'] . "_menucourse_under\n\tWHERE idCourse = '" . $id_dupcourse . "' "; $result_selmenun = sql_query($query_selmenun); while ($list_selmenun = sql_fetch_array($result_selmenun)) { $valore_idn = $list_selmenun['idMain']; $_idMain = $array_seq[$valore_idn]; $query_dupmen = "INSERT INTO " . $GLOBALS['prefix_lms'] . "_menucourse_under\n\t\t(idMain, idCourse, sequence, idModule, my_name)\n\t\tVALUES\n\t\t('" . $_idMain . "', '" . $new_course_dup . "', '" . $list_selmenun['sequence'] . "', '" . $list_selmenun['idModule'] . "', '" . $list_selmenun['my_name'] . "')"; $result_dupmen = sql_query($query_dupmen); } function &getCourseLevelSt($id_course) { $map = array(); $levels = CourseLevel::getLevels(); $acl_man =& $GLOBALS['current_user']->getAclManager(); // find all the group created for this menu custom for permission management foreach ($levels as $lv => $name_level) { $group_info = $acl_man->getGroup(FALSE, '/lms/course/' . $id_course . '/subscribed/' . $lv); $map[$lv] = $group_info[ACL_INFO_IDST]; } return $map; } function funAccess($functionname, $mode, $returnValue = false, $custom_mod_name = false) { return true; } require_once $GLOBALS['where_lms'] . '/lib/lib.course.php'; require_once $GLOBALS['where_lms'] . '/lib/lib.manmenu.php'; require_once $GLOBALS['where_lms'] . '/lib/lib.subscribe.php'; $docebo_course = new DoceboCourse($id_dupcourse); $subscribe_man = new CourseSubscribe_Manager(); $group_idst =& $docebo_course->createCourseLevel($new_course_dup); $group_of_from =& $docebo_course->getCourseLevel($id_dupcourse); $perm_form =& createPermForCoursebis($group_of_from, $new_course_dup, $id_dupcourse); $levels = $subscribe_man->getUserLevel(); foreach ($levels as $lv => $name_level) { foreach ($perm_form[$lv] as $idrole => $v) { if ($group_idst[$lv] != 0 && $idrole != 0) { $acl_man =& $GLOBALS['current_user']->getAclManager(); $acl_man->addToRole($idrole, $group_idst[$lv]); } } } // duplicate the certificate assigned $query_selmenun = "SELECT *\n\tFROM " . $GLOBALS['prefix_lms'] . "_certificate_course\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'] . "_certificate_course\n\t\t\t(id_certificate, id_course, available_for_status)\n\t\t\tVALUES\n\t\t\t('" . $list_selmenun['id_certificate'] . "', '" . $new_course_dup . "', '" . $list_selmenun['available_for_status'] . "' )"; $result_dupmen = sql_query($query_dupmen); } require_once $GLOBALS['where_lms'] . '/modules/organization/orglib.php'; require_once $GLOBALS['where_lms'] . '/lib/lib.param.php'; require_once $GLOBALS['where_lms'] . '/class.module/track.object.php'; require_once $GLOBALS['where_lms'] . '/class.module/learning.object.php'; function createLO($objectType, $idResource = NULL) { $query = "SELECT className, fileName FROM " . $GLOBALS['prefix_lms'] . "_lo_types WHERE objectType='" . $objectType . "'"; $rs = sql_query($query); list($className, $fileName) = sql_fetch_row($rs); require_once $GLOBALS['where_lms'] . '/class.module/' . $fileName; $lo = new $className($idResource); return $lo; } $nullVal = NULL; $array_cor = array(); $map_org = array(); $tree_course = new OrgDirDb($id_dupcourse); $coll = $tree_course->getFoldersCollection($nullVal); while ($folder = $coll->getNext()) { //if($folder->otherValues[REPOFIELDIDRESOURCE] != 0 ) { if (!empty($folder->otherValues[REPOFIELDOBJECTTYPE])) { $lo = createLO($folder->otherValues[REPOFIELDOBJECTTYPE]); $id_nuovo_lo = $lo->copy($folder->otherValues[REPOFIELDIDRESOURCE]); $id_vecchio = $folder->otherValues[REPOFIELDIDRESOURCE]; $query_selmenun = "SELECT * FROM\n\t\t\t" . $GLOBALS['prefix_lms'] . "_organization\n\t\t\tWHERE idCourse = '" . $id_dupcourse . "'\n\t\t\tAND idResource = '" . $id_vecchio . "' "; $result_selmenun = sql_query($query_selmenun); while ($list_selmenun = mysql_fetch_array($result_selmenun)) { $query_dupmen = "INSERT INTO " . $GLOBALS['prefix_lms'] . "_organization\n\t\t\t\t(idParent, path, lev, title,\n\t\t\t\tobjectType, idResource, idCategory, idUser, idAuthor,\n\t\t\t\tversion, difficult, description, language, resource,\n\t\t\t\tobjective, dateInsert, idCourse, prerequisites, isTerminator,\n\t\t\t\tidParam, visible, milestone)\n\t\t\t\tVALUES\n\t\t\t\t('" . (isset($map_org[$list_selmenun['idParent']]) ? $map_org[$list_selmenun['idParent']] : 0) . "', '" . $list_selmenun['path'] . "', '" . $list_selmenun['lev'] . "', '" . $list_selmenun['title'] . "',\n\t\t\t\t'" . $list_selmenun['objectType'] . "', '" . $id_nuovo_lo . "', '" . $list_selmenun['idCategory'] . "', '" . $list_selmenun['idUser'] . "', '" . $list_selmenun['idAuthor'] . "',\n\t\t\t\t'" . $list_selmenun['version'] . "', '" . $list_selmenun['difficult'] . "', '" . $list_selmenun['description'] . "', '" . $list_selmenun['language'] . "', '" . $list_selmenun['resource'] . "',\n\t\t\t\t'" . $list_selmenun['objective'] . "', '" . $list_selmenun['dateInsert'] . "', '" . $new_course_dup . "', '" . $list_selmenun['prerequisites'] . "', '" . $list_selmenun['isTerminator'] . "',\n\t\t\t\t'" . $list_selmenun['idParam'] . "', '" . $list_selmenun['visible'] . "', '" . $list_selmenun['milestone'] . "')"; $result_dupmen = sql_query($query_dupmen); $id_org = $list_selmenun['idOrg']; $id_last = sql_insert_id(); $array_cor[$id_org] = $id_last; $query_lo_par = "INSERT INTO " . $GLOBALS['prefix_lms'] . "_lo_param\n\t\t\t\t(param_name, param_value)\n\t\t\t\tVALUES\n\t\t\t\t('idReference', '" . $id_last . "') "; $result_lo_par = sql_query($query_lo_par); $id_lo_par = sql_insert_id(); $query_up_lo = "UPDATE " . $GLOBALS['prefix_lms'] . "_lo_param\n\t\t\t\tSET idParam = '" . $id_lo_par . "'\n\t\t\t\tWHERE id = '" . $id_lo_par . "' "; $result_up_lo = sql_query($query_up_lo); $query_up_or = "UPDATE " . $GLOBALS['prefix_lms'] . "_organization\n\t\t\t\tSET\tidParam = '" . $id_lo_par . "'\n\t\t\t\tWHERE idOrg = '" . $id_last . "' "; $result_up_or = sql_query($query_up_or); } } else { // copy folder echo $id_vecchio = $folder->id; $query_selmenun = "SELECT * FROM\n\t\t\t" . $GLOBALS['prefix_lms'] . "_organization\n\t\t\tWHERE idCourse = '" . $id_dupcourse . "'\n\t\t\tAND idOrg = '" . $id_vecchio . "' "; $result_selmenun = sql_query($query_selmenun); $list_selmenun = mysql_fetch_array($result_selmenun); $query_dupmen = " INSERT INTO " . $GLOBALS['prefix_lms'] . "_organization\n\t\t\t(idParent, path, lev, title,\n\t\t\tobjectType, idResource, idCategory, idUser, idAuthor,\n\t\t\tversion, difficult, description, language, resource,\n\t\t\tobjective, dateInsert, idCourse, prerequisites, isTerminator,\n\t\t\tidParam, visible, milestone)\n\t\t\tVALUES\n\t\t\t('" . (isset($map_org[$list_selmenun['idParent']]) ? $map_org[$list_selmenun['idParent']] : 0) . "', '" . $list_selmenun['path'] . "', '" . $list_selmenun['lev'] . "', '" . $list_selmenun['title'] . "',\n\t\t\t'" . $list_selmenun['objectType'] . "', '" . $id_nuovo_lo . "', '" . $list_selmenun['idCategory'] . "', '" . $list_selmenun['idUser'] . "', '" . $list_selmenun['idAuthor'] . "',\n\t\t\t'" . $list_selmenun['version'] . "', '" . $list_selmenun['difficult'] . "', '" . $list_selmenun['description'] . "', '" . $list_selmenun['language'] . "', '" . $list_selmenun['resource'] . "',\n\t\t\t'" . $list_selmenun['objective'] . "', '" . $list_selmenun['dateInsert'] . "', '" . $new_course_dup . "', '" . $list_selmenun['prerequisites'] . "', '" . $list_selmenun['isTerminator'] . "',\n\t\t\t'" . $list_selmenun['idParam'] . "', '" . $list_selmenun['visible'] . "', '" . $list_selmenun['milestone'] . "')"; $result_dupmen = sql_query($query_dupmen); $map_org[$id_vecchio] = sql_insert_id(); } } $query_cor = "SELECT *\n\tFROM " . $GLOBALS['prefix_lms'] . "_organization\n\tWHERE\n\tidCourse = '" . $new_course_dup . "'\n\tAND prerequisites !='' "; $result_cor = sql_query($query_cor); while ($list_cor = sql_fetch_array($result_cor)) { $id_orgup = $list_cor['prerequisites']; $arr_pre = explode(",", $id_orgup); for ($i = 0; $i < sizeof($arr_pre); $i++) { $arr_pre[$i] = str_replace(intval($arr_pre[$i]), $array_cor[intval($arr_pre[$i])], $arr_pre[$i]); } $query_updcor = "UPDATE " . $GLOBALS['prefix_lms'] . "_organization\n\t\t\tSET prerequisites = '"; for ($i = 0; $i < sizeof($arr_pre); $i++) { if ($i != 0) { $query_updcor .= ","; } $query_updcor .= $arr_pre[$i]; } $query_updcor .= "' WHERE idOrg = '" . $list_cor['idOrg'] . "' "; $result_upcor = sql_query($query_updcor); } $query_selmenun = "SELECT * FROM\n\t" . $GLOBALS['prefix_lms'] . "_forum\n\tWHERE idCourse = '" . $id_dupcourse . "' "; $result_selmenun = sql_query($query_selmenun); while ($list_selmenun = sql_fetch_array($result_selmenun)) { $query_dupmen = "INSERT INTO\n\t\t" . $GLOBALS['prefix_lms'] . "_forum\n\t\t(idCourse, title, description, locked, sequence, emoticons)\n\t\tVALUES\n\t\t('" . $new_course_dup . "', '" . $list_selmenun['title'] . "', '" . $list_selmenun['description'] . "',\n\t\t'" . $list_selmenun['locked'] . "', '" . $list_selmenun['sequence'] . "', '" . $list_selmenun['emoticons'] . "')"; $result_dupmen = sql_query($query_dupmen); } $query_selmenun = "SELECT * FROM\n\t" . $GLOBALS['prefix_lms'] . "_coursereport\n\tWHERE id_course = '" . $id_dupcourse . "' "; $sql2 = $query_selmenun; $result_selmenun = sql_query($query_selmenun); while ($list_selmenun = sql_fetch_array($result_selmenun)) { if (!isset($array_organization[$list_selmenun['id_source']]) or $array_organization[$list_selmenun['id_source']] == "") { $array_organization[$list_selmenun['id_source']] = 0; } $query_dupmen = "INSERT INTO\n\t\t" . $GLOBALS['prefix_lms'] . "_coursereport\n\t\t(id_course,title,max_score,required_score,weight,show_to_user,use_for_final,sequence,source_of,id_source)\n\t\tVALUES\n\t\t('" . $new_course_dup . "', '" . $list_selmenun['title'] . "', '" . $list_selmenun['max_score'] . "',\n\t\t'" . $list_selmenun['required_score'] . "', '" . $list_selmenun['weight'] . "', '" . $list_selmenun['show_to_user'] . "', '" . $list_selmenun['use_for_final'] . "', '" . $list_selmenun['sequence'] . "', '" . $list_selmenun['source_of'] . "', '" . $array_organization[$list_selmenun['id_source']] . "')"; $sql2 = $query_dupmen; $result_dupmen = sql_query($query_dupmen); } $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; }
function subscribeToCourse($id_user, $id_course, $id_date = 0) { require_once _lms_ . '/admin/modules/subscribe/subscribe.php'; require_once _lms_ . '/lib/lib.date.php'; require_once _lms_ . '/lib/lib.course.php'; $date_man = new DateManager(); $acl_man =& Docebo::user()->getAclManager(); $query = "SELECT idCourse" . " FROM " . $GLOBALS['prefix_lms'] . "_courseuser" . " WHERE idUser = "******"SELECT subscribe_method FROM " . $GLOBALS['prefix_lms'] . "_course WHERE idCourse = " . $id_course)); $waiting = 0; if ($subscribe_method == '1') { $waiting = 1; } if ($id_date != 0) { if (array_search($id_course, $courses) !== false) { if (array_search($id_date, $dates) === false) { if (!$date_man->addUserToDate($id_date, $id_user, getLogUserId())) { return false; } } } else { $acl_man->addToGroup($level_idst[3], $id_user); $re = sql_query("INSERT INTO " . $GLOBALS['prefix_lms'] . "_courseuser\r\n\t\t\t\t\t\t\t\t\t(idUser, idCourse, edition_id, level, waiting, subscribed_by, date_inscr)\r\n\t\t\t\t\t\t\t\t\tVALUES ('" . $id_user . "', '" . $id_course . "', '0', '3', '" . $waiting . "', '" . getLogUserId() . "', '" . date("Y-m-d H:i:s") . "')"); if ($re) { addUserToTimeTable($id_user, $id_course, 0); if (!$date_man->addUserToDate($id_date, $id_user, getLogUserId())) { return false; } } } } else { if (array_search($id_course, $courses) === false) { $acl_man->addToGroup($level_idst[3], $id_user); $re = sql_query("INSERT INTO " . $GLOBALS['prefix_lms'] . "_courseuser\r\n\t\t\t\t\t\t\t\t\t(idUser, idCourse, edition_id, level, waiting, subscribed_by, date_inscr)\r\n\t\t\t\t\t\t\t\t\tVALUES ('" . $id_user . "', '" . $id_course . "', '0', '3', '" . $waiting . "', '" . getLogUserId() . "', '" . date("Y-m-d H:i:s") . "')"); if ($re) { addUserToTimeTable($id_user, $id_course, 0); } else { return false; } } } return true; }
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&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&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>'); }
public function insCourse() { require_once _base_ . '/lib/lib.upload.php'; require_once _base_ . '/lib/lib.multimedia.php'; require_once _lms_ . '/lib/lib.course.php'; require_once _lms_ . '/lib/lib.manmenu.php'; $array_lang = Docebo::langManager()->getAllLangCode(); $array_lang[] = 'none'; $acl_man =& Docebo::user()->getAclManager(); $id_custom = Get::req('selected_menu', DOTY_INT, 0); // calc quota limit $quota = $_POST['course_quota']; if (isset($_POST['inherit_quota'])) { $quota = Get::sett('course_quota'); $_POST['course_quota'] = COURSE_QUOTA_INHERIT; } $quota = $quota * 1024 * 1024; $path = Get::sett('pathcourse'); $path = '/appLms/' . Get::sett('pathcourse') . (substr($path, -1) != '/' && substr($path, -1) != '\\' ? '/' : ''); if ($_POST['course_name'] == '') { $_POST['course_name'] = Lang::t('_NO_NAME', 'course'); } // restriction on course status ------------------------------------------ $user_status = 0; if (isset($_POST['user_status'])) { while (list($status) = each($_POST['user_status'])) { $user_status |= 1 << $status; } } // level that will be showed in the course -------------------------------- $show_level = 0; if (isset($_POST['course_show_level'])) { while (list($lv) = each($_POST['course_show_level'])) { $show_level |= 1 << $lv; } } // save the file uploaded ------------------------------------------------- $file_sponsor = ''; $file_logo = ''; $file_material = ''; $file_othermaterial = ''; $file_demo = ''; $error = false; $quota_exceeded = false; $total_file_size = 0; if (is_array($_FILES) && !empty($_FILES)) { sl_open_fileoperations(); } // load user material --------------------------------------------------------------------------- $arr_file = $this->manageCourseFile('course_user_material', '', $path, $quota != 0 ? $quota - $total_file_size : false, false); $error |= $arr_file['error']; $quota_exceeded |= $arr_file['quota_exceeded']; $file_material = $arr_file['filename']; $total_file_size = $total_file_size + $arr_file['new_size']; // course otheruser material ------------------------------------------------------------------- $arr_file = $this->manageCourseFile('course_otheruser_material', '', $path, $quota != 0 ? $quota - $total_file_size : false, false); $error |= $arr_file['error']; $quota_exceeded |= $arr_file['quota_exceeded']; $file_othermaterial = $arr_file['filename']; $total_file_size = $total_file_size + $arr_file['new_size']; // course demo----------------------------------------------------------------------------------- $arr_file = $this->manageCourseFile('course_demo', '', $path, $quota != 0 ? $quota - $total_file_size : false, false); $error |= $arr_file['error']; $quota_exceeded |= $arr_file['quota_exceeded']; $file_demo = $arr_file['filename']; $total_file_size = $total_file_size + $arr_file['new_size']; // course sponsor--------------------------------------------------------------------------------- $arr_file = $this->manageCourseFile('course_sponsor_logo', '', $path, $quota != 0 ? $quota - $total_file_size : false, false, true); $error |= $arr_file['error']; $quota_exceeded |= $arr_file['quota_exceeded']; $file_sponsor = $arr_file['filename']; $total_file_size = $total_file_size + $arr_file['new_size']; // course logo----------------------------------------------------------------------------------- $arr_file = $this->manageCourseFile('course_logo', '', $path, $quota != 0 ? $quota - $total_file_size : false, false, true); $error |= $arr_file['error']; $quota_exceeded |= $arr_file['quota_exceeded']; $file_logo = $arr_file['filename']; $total_file_size = $total_file_size + $arr_file['new_size']; // ---------------------------------------------------------------------------------------------- sl_close_fileoperations(); if ($_POST["can_subscribe"] == "2") { $sub_start_date = Format::dateDb($_POST["sub_start_date"], "date"); $sub_end_date = Format::dateDb($_POST["sub_end_date"], "date"); } $date_begin = Format::dateDb($_POST['course_date_begin'], "date"); $date_end = Format::dateDb($_POST['course_date_end'], "date"); // insert the course in database ----------------------------------------------------------- $hour_begin = '-1'; $hour_end = '-1'; if ($_POST['hour_begin']['hour'] != '-1') { $hour_begin = strlen($_POST['hour_begin']['hour']) == 1 ? '0' . $_POST['hour_begin']['hour'] : $_POST['hour_begin']['hour']; if ($_POST['hour_begin']['quarter'] == '-1') { $hour_begin .= ':00'; } else { $hour_begin .= ':' . $_POST['hour_begin']['quarter']; } } if ($_POST['hour_end']['hour'] != '-1') { $hour_end = strlen($_POST['hour_end']['hour']) == 1 ? '0' . $_POST['hour_end']['hour'] : $_POST['hour_end']['hour']; if ($_POST['hour_end']['quarter'] == '-1') { $hour_end .= ':00'; } else { $hour_end .= ':' . $_POST['hour_end']['quarter']; } } $query_course = "\n\t\tINSERT INTO %lms_course\n\t\tSET idCategory \t\t\t= '" . (isset($_POST['idCategory']) ? $_POST['idCategory'] : 0) . "',\n\t\t\tcode \t\t\t\t= '" . $_POST['course_code'] . "',\n\t\t\tname \t\t\t\t= '" . $_POST['course_name'] . "',\n\t\t\tdescription \t\t= '" . $_POST['course_descr'] . "',\n\t\t\tlang_code \t\t\t= '" . $array_lang[$_POST['course_lang']] . "',\n\t\t\tstatus \t\t\t\t= '" . (int) $_POST['course_status'] . "',\n\t\t\tlevel_show_user \t= '" . $show_level . "',\n\t\t\tsubscribe_method \t= '" . (int) $_POST['course_subs'] . "',\n\t\t\tcredits\t\t\t \t= '" . (int) $_POST['credits'] . "',\n\n\t\t\tcreate_date\t\t\t= '" . date("Y-m-d H:i:s") . "',\n\n\t\t\tlinkSponsor \t\t= '" . $_POST['course_sponsor_link'] . "',\n\t\t\timgSponsor \t\t\t= '" . $file_sponsor . "',\n\t\t\timg_course \t\t\t= '" . $file_logo . "',\n\t\t\timg_material \t\t= '" . $file_material . "',\n\t\t\timg_othermaterial \t= '" . $file_othermaterial . "',\n\t\t\tcourse_demo \t\t= '" . $file_demo . "',\n\n\t\t\tmediumTime \t\t\t= '" . $_POST['course_medium_time'] . "',\n\t\t\tpermCloseLO \t\t= '" . $_POST['course_em'] . "',\n\t\t\tuserStatusOp \t\t= '" . $user_status . "',\n\t\t\tdifficult \t\t\t= '" . $_POST['course_difficult'] . "',\n\n\t\t\tshow_progress \t\t= '" . (isset($_POST['course_progress']) ? 1 : 0) . "',\n\t\t\tshow_time \t\t\t= '" . (isset($_POST['course_time']) ? 1 : 0) . "',\n\n\t\t\tshow_who_online\t\t= '" . $_POST['show_who_online'] . "',\n\n\t\t\tshow_extra_info \t= '" . (isset($_POST['course_advanced']) ? 1 : 0) . "',\n\t\t\tshow_rules \t\t\t= '" . (int) $_POST['course_show_rules'] . "',\n\n\t\t\tdirect_play \t\t= '" . (isset($_POST['direct_play']) ? 1 : 0) . "',\n\n\t\t\tdate_begin \t\t\t= '" . $date_begin . "',\n\t\t\tdate_end \t\t\t= '" . $date_end . "',\n\t\t\thour_begin \t\t\t= '" . $hour_begin . "',\n\t\t\thour_end \t\t\t= '" . $hour_end . "',\n\n\t\t\tvalid_time \t\t\t= '" . (int) $_POST['course_day_of'] . "',\n\n\t\t\tmin_num_subscribe \t= '" . (int) $_POST['min_num_subscribe'] . "',\n\t\t\tmax_num_subscribe \t= '" . (int) $_POST['max_num_subscribe'] . "',\n\t\t\tselling \t\t\t= '" . (isset($_POST['course_sell']) ? '1' : '0') . "',\n\t\t\tprize \t\t\t\t= '" . $_POST['course_prize'] . "',\n\n\t\t\tcourse_type \t\t= '" . $_POST['course_type'] . "',\n\n\t\t\tcourse_edition \t\t= '" . (isset($_POST['course_edition']) && $_POST['course_edition'] == 1 ? 1 : 0) . "',\n\n\t\t\tcourse_quota \t\t= '" . $_POST['course_quota'] . "',\n\t\t\tused_space\t\t\t= '" . $total_file_size . "',\n\t\t\tallow_overbooking \t= '" . (isset($_POST["allow_overbooking"]) ? 1 : 0) . "',\n\t\t\tcan_subscribe \t\t= '" . (int) $_POST["can_subscribe"] . "',\n\t\t\tsub_start_date \t\t= " . ($_POST["can_subscribe"] == '2' ? "'" . $sub_start_date . "'" : 'NULL') . ",\n\t\t\tsub_end_date \t\t= " . ($_POST["can_subscribe"] == '2' ? "'" . $sub_end_date . "'" : 'NULL') . ",\n\n\t\t\tadvance \t\t\t= '" . $_POST['advance'] . "',\n\t\t\tshow_result \t\t= '" . (isset($_POST["show_result"]) ? 1 : 0) . "',\n\n\t\t\tuse_logo_in_courselist = '" . (isset($_POST['use_logo_in_courselist']) ? '1' : '0') . "',\n\n\t\t\tauto_unsubscribe = '" . (int) $_POST['auto_unsubscribe'] . "',\n\t\t\tunsubscribe_date_limit = " . (isset($_POST['use_unsubscribe_date_limit']) && $_POST['use_unsubscribe_date_limit'] > 0 ? "'" . Format::dateDb($_POST['unsubscribe_date_limit'], 'date') . "'" : 'NULL') . ""; if (isset($_POST['random_course_autoregistration_code'])) { $control = 1; $str = ''; while ($control) { for ($i = 0; $i < 10; $i++) { $seed = mt_rand(0, 10); if ($seed > 5) { $str .= mt_rand(0, 9); } else { $str .= chr(mt_rand(65, 90)); } } $control_query = "SELECT COUNT(*)" . " " . $GLOBALS['prefix_lms'] . "_course" . " WHERE autoregistration_code = '" . $str . "'"; $control_result = sql_query($control_query); list($result) = sql_fetch_row($control_result); $control = $result; } $query_course .= ", autoregistration_code = '" . $str . "'"; } else { $query_course .= ", autoregistration_code = '" . $_POST['course_autoregistration_code'] . "'"; } if (!sql_query($query_course)) { // course save failed, delete uploaded file 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); } return array('err' => '_err_course'); } // recover the id of the course inserted -------------------------------------------- list($id_course) = sql_fetch_row(sql_query("SELECT LAST_INSERT_ID()")); require_once _lms_ . '/admin/models/LabelAlms.php'; $label_model = new LabelAlms(); $label = Get::req('label', DOTY_INT, 0); $label_model->associateLabelToCourse($label, $id_course); // add this corse to the pool of course visible by the user that have create it ----- if (Docebo::user()->getUserLevelId() != ADMIN_GROUP_GODADMIN) { require_once _base_ . '/lib/lib.preference.php'; $adminManager = new AdminPreference(); $adminManager->addAdminCourse($id_course, Docebo::user()->getIdSt()); } //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' => $_POST['course_name'], 'room_type' => 'course', 'id_source' => $id_course); $re = insertRoom($rules); } $course_idst =& DoceboCourse::createCourseLevel($id_course); // create the course menu ----------------------------------------------------------- if (!cerateCourseMenuFromCustom($id_custom, $id_course, $course_idst)) { return array('err' => '_err_coursemenu'); } $res = array(); if ($quota_exceeded) { $res['limit_reach'] = 1; } if ($error) { $res['err'] = '_err_course'; } else { //AUTO SUBSCRIPTION if (isset($_POST['auto_subscription']) && $_POST['auto_subscription'] == 1) { $userId = Docebo::user()->getIdSt(); if (!$this->autoUserRegister($userId, $id_course)) { die('Error during autosubscription'); } } $res['res'] = '_ok_course'; } return $res; }
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; }
public function activateCourses($id_transaction, $id_user, $activations) { require_once _lms_ . '/lib/lib.subscribe.php'; require_once _lms_ . '/admin/modules/subscribe/subscribe.php'; require_once _lms_ . '/lib/lib.date.php'; require_once _lms_ . '/lib/lib.course.php'; $subscribe_man = new CourseSubscribe_Management(); $date_man = new DateManager(); $acl_man =& Docebo::user()->getAclManager(); $query = "SELECT idCourse" . " FROM " . $this->table_courseuser . " WHERE idUser = "******"UPDATE " . $this->table_transaction_info . " SET activated = 1" . " WHERE id_transaction = " . $id_transaction . " AND id_course = " . $id_course . " AND id_date = " . $id_date; if (!sql_query($query_up)) { return false; } } } else { $query_up = "UPDATE " . $this->table_transaction_info . " SET activated = 1" . " WHERE id_transaction = " . $id_transaction . " AND id_course = " . $id_course . " AND id_date = " . $id_date; if (!sql_query($query_up)) { return false; } } } else { $acl_man->addToGroup($level_idst[3], $id_user); $re = mysql_query("INSERT INTO " . $GLOBALS['prefix_lms'] . "_courseuser\n\t\t\t\t\t\t\t\t\t\t\t(idUser, idCourse, edition_id, level, waiting, subscribed_by, date_inscr)\n\t\t\t\t\t\t\t\t\t\t\tVALUES ('" . $id_user . "', '" . $id_course . "', '0', '3', '0', '" . getLogUserId() . "', '" . date("Y-m-d H:i:s") . "')"); if ($re) { $courses[$id_course] = $id_course; addUserToTimeTable($id_user, $id_course, 0); if (!$date_man->addUserToDate($id_date, $id_user, getLogUserId())) { return false; } else { $query_up = "UPDATE " . $this->table_transaction_info . " SET activated = 1" . " WHERE id_transaction = " . $id_transaction . " AND id_course = " . $id_course . " AND id_date = " . $id_date; if (!sql_query($query_up)) { return false; } } } else { return false; } } } } else { if (array_search($id_course, $courses) !== false) { $query_up = "UPDATE " . $this->table_transaction_info . " SET activated = 1" . " WHERE id_transaction = " . $id_transaction . " AND id_course = " . $id_course . " AND id_date = 0"; if (!sql_query($query_up)) { return false; } } else { $acl_man->addToGroup($level_idst[3], $id_user); $re = mysql_query("INSERT INTO " . $GLOBALS['prefix_lms'] . "_courseuser\n\t\t\t\t\t\t\t\t\t\t(idUser, idCourse, edition_id, level, waiting, subscribed_by, date_inscr)\n\t\t\t\t\t\t\t\t\t\tVALUES ('" . $id_user . "', '" . $id_course . "', '0', '3', '0', '" . getLogUserId() . "', '" . date("Y-m-d H:i:s") . "')"); if ($re) { $courses[$id_course] = $id_course; addUserToTimeTable($id_user, $id_course, 0); $query_up = "UPDATE " . $this->table_transaction_info . " SET activated = 1" . " WHERE id_transaction = " . $id_transaction . " AND id_course = " . $id_course . " AND id_date = 0"; if (!sql_query($query_up)) { return false; } } else { return false; } } } } return true; }
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'); }
public function menu() { if (!$this->permissions['mod']) { $this->render('invalid', array('message' => $this->_getErrorMessage('no permission'), 'back_url' => 'index.php?r=' . $this->base_link_course . '/show')); return; } if (isset($_POST['undo'])) { Util::jump_to('index.php?r=' . $this->base_link_course . '/show'); } $id_course = Get::req('id_course', DOTY_INT, 0); if (isset($_POST['assign'])) { $id_custom = Get::req('selected_menu', DOTY_INT, 0); 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\n\t\t\t\t\t\t\tFROM ( " . $GLOBALS['prefix_lms'] . "_menucourse_main AS main JOIN\n\t\t\t\t\t\t\t" . $GLOBALS['prefix_lms'] . "_menucourse_under AS un ) JOIN\n\t\t\t\t\t\t\t" . $GLOBALS['prefix_lms'] . "_module AS module\n\t\t\t\t\t\t\tWHERE main.idMain = un.idMain AND un.idModule = module.idModule\n\t\t\t\t\t\t\tAND main.idCourse = '" . (int) $_SESSION['idCourse'] . "'\n\t\t\t\t\t\t\tAND un.idCourse = '" . (int) $_SESSION['idCourse'] . "'\n\t\t\t\t\t\t\tORDER BY main.sequence, un.sequence\n\t\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(); } if ($result) { Util::jump_to('index.php?r=' . $this->base_link_course . '/show&res=_up_menu_ok'); } Util::jump_to('index.php?r=' . $this->base_link_course . '/show&res=_up_menu_err'); } else { require_once $GLOBALS['where_lms'] . '/lib/lib.manmenu.php'; $menu_custom = getAllCustom(); $menu_custom = array(0 => Lang::t('_SELECT', 'standard') . ' ...') + $menu_custom; reset($menu_custom); $course_info = $this->model->getInfo($id_course); $course_name = ($course_info['code'] !== '' ? '[' . $course_info['code'] . '] ' : '') . $course_info['name']; $this->render('menu', array('menu_custom' => $menu_custom, 'sel_custom' => 0, 'id_course' => $id_course, 'base_link_course' => $this->base_link_course, 'course_name' => $course_name)); } }
/** * assign a group of user to a preassessment, you can specify if the users are administrator or not * @param int $id_assessment the id of the assessment * @param int $user_type is the identifier of the type of the user, use the constant USER_ASSES_TYPE_ADMIN, USER_ASSES_TYPE_USER * @param array $user_list the list of user that must be assigned to the assesment.If a user is not in this list, but is actually * assigned to the ass. the function will remove the user */ function updateAssessmentUser($id_assessment, $user_type, $user_list) { require_once _lms_ . '/lib/lib.course.php'; require_once _lms_ . '/admin/models/SubscriptionAlms.php'; $docebo_course = new DoceboCourse($id_assessment); $acl_man = Docebo::user()->getAclManager(); $subsciption_model = new SubscriptionAlms($id_assessment, 0, 0); $level_idst = $docebo_course->getCourseLevel($id_assessment); if (count($level_idst) == 0 || $level_idst[1] == '') { $level_idst = $docebo_course->createCourseLevel($id_assessment); } $level = 3; if ($user_type !== 'user') { $level = 6; } $op_result = true; $query = "\r\n\t\tSELECT " . implode($this->user_field, ',') . "\r\n\t\tFROM " . $this->tableUserAssessment() . "\r\n\t\tWHERE " . $this->user_field[USER_ASSES_ID] . " = '" . $id_assessment . "'\r\n\t\t\tAND " . $this->user_field[USER_ASSES_TYPE] . " = '" . $user_type . "'"; $re_query = $this->_query($query); while ($row = $this->fetch_row($re_query)) { if (isset($user_list[$row[USER_ASSES_ID_USER]])) { unset($user_list[$row[USER_ASSES_ID_USER]]); } else { $del_query = "\r\n\t\t\t\tDELETE FROM " . $this->tableUserAssessment() . "\r\n\t\t\t\tWHERE " . $this->user_field[USER_ASSES_ID] . " = '{$id_assessment}'\r\n\t\t\t\t\t AND " . $this->user_field[USER_ASSES_ID_USER] . " = '" . $row[USER_ASSES_ID_USER] . "'"; $op_result &= $this->_query($del_query); $acl_man->removeFromGroup($level_idst[$level], $row[USER_ASSES_ID_USER]); $subsciption_model->delUser($row[USER_ASSES_ID_USER]); } } // end while reset($user_list); while (list(, $id_user) = each($user_list)) { $upd_query = "\r\n\t\t\tINSERT INTO " . $this->tableUserAssessment() . "\r\n\t\t\t( \t" . $this->user_field[USER_ASSES_ID] . ",\r\n\t\t\t\t" . $this->user_field[USER_ASSES_ID_USER] . ",\r\n\t\t\t\t" . $this->user_field[USER_ASSES_TYPE] . " ) VALUES\r\n\t\t\t( \t'" . $id_assessment . "',\r\n\t\t\t\t'" . $id_user . "',\r\n\t\t\t\t'" . $user_type . "' )"; $op_result &= $this->_query($upd_query); $acl_man->addToGroup($level_idst[$level], $id_user); $subsciption_model->subscribeUser($id_user, $level, false); } return $op_result; }
function approveusers() { if (!$this->permissions['moderate']) { die("You can't access"); } require_once _lms_ . '/lib/lib.course.php'; require_once _base_ . '/lib/lib.preference.php'; $id_course = Get::req('id_course', DOTY_INT, 0); $course_info = Man_Course::getCourseInfo($id_course); $edition_id = Get::req('id_edition', DOTY_INT, 0); $re = true; $approve_user = array(); $deny_user = array(); if (isset($_POST['waiting_user'])) { $man_course = new Man_Course(); $waiting_users =& $man_course->getWaitingSubscribed($id_course); $tot_deny = array(); require_once _lms_ . '/lib/lib.course.php'; require_once _lms_ . '/admin/modules/subscribe/subscribe.php'; $docebo_course = new DoceboCourse($id_course); $group_levels = $docebo_course->getCourseLevel($id_course); if (count($group_levels) == 0 || $group_levels[1] == '') { $group_levels =& $docebo_course->createCourseLevel($id_course); } while (list($id_user, $action) = each($_POST['waiting_user'])) { if ($action == 0) { // approved ----------------------------------------------- $text_query = "\r\n\t\t\t\t\tUPDATE " . $GLOBALS['prefix_lms'] . "_courseuser\r\n\t\t\t\t\tSET waiting = 0,\r\n\t\t\t\t\t\tstatus = '" . _CUS_SUBSCRIBED . "'\r\n\t\t\t\t\tWHERE idCourse = '" . $id_course . "' AND idUser = '******' "; $text_query .= "AND edition_id='" . $edition_id . "'"; $result = sql_query($text_query); if ($result) { $approve_user[] = $id_user; } $re &= $result; } elseif ($action == 1) { // refused -------------------------------------------------- $level = $waiting_users['users_info'][$id_user]['level']; $sub_by = $waiting_users['users_info'][$id_user]['subscribed_by']; $result = removeSubscription($id_course, $id_user, $group_levels[$level], $edition_id); if ($sub_by != 0 && $id_user != $sub_by) { if (isset($tot_deny[$sub_by])) { $tot_deny[$sub_by]++; } else { $tot_deny[$sub_by] = 1; } } if ($result) { $deny_user[] = $id_user; } $re &= $result; } } } if (!empty($tot_deny)) { while (list($id_user, $inc) = each($tot_deny)) { $pref = new UserPreferences($id_user); $max_subscribe = $pref->getAdminPreference('admin_rules.max_course_subscribe'); $pref->setPreference('admin_rules.max_course_subscribe', $max_subscribe + $inc); } } require_once _base_ . '/lib/lib.eventmanager.php'; $array_subst = array('[url]' => Get::sett('url'), '[course]' => $course_info['name']); if (!empty($approve_user)) { $msg_composer = new EventMessageComposer(); $msg_composer->setSubjectLangText('email', '_APPROVED_SUBSCRIBED_SUBJECT', false); $msg_composer->setBodyLangText('email', '_APPROVED_SUBSCRIBED_TEXT', $array_subst); $msg_composer->setBodyLangText('email', "\n\n" . $_POST['subscribe_accept'], array(), true); $msg_composer->setBodyLangText('sms', '_APPROVED_SUBSCRIBED_TEXT_SMS', $array_subst); // send message to the user subscribed createNewAlert('UserCourseInserted', 'subscribe', 'approve', '1', 'User course approve', $approve_user, $msg_composer, true); } if (!empty($deny_user)) { $msg_composer = new EventMessageComposer(); $msg_composer->setSubjectLangText('email', '_DENY_SUBSCRIBED_SUBJECT', false); $msg_composer->setBodyLangText('email', '_DENY_SUBSCRIBED_TEXT', $array_subst); $msg_composer->setBodyLangText('email', "\n\n" . $_POST['subscribe_refuse'], array(), true); $msg_composer->setSubjectLangText('sms', '_DENY_SUBSCRIBED_SUBJECT_SMS', false); $msg_composer->setBodyLangText('sms', '_DENY_SUBSCRIBED_TEXT_SMS', $array_subst); // send message to the user subscribed createNewAlert('UserCourseInserted', 'subscribe', 'deny', '1', 'User course deny', $deny_user, $msg_composer, true); } Util::jump_to('index.php?r=' . $this->link_course . '/show&res=' . ($re ? 'ok' : 'err')); }
public function subscribeToCourse() { $id_course = Get::req('id_course', DOTY_INT, 0); $id_date = Get::req('id_date', DOTY_INT, 0); $id_edition = Get::req('id_edition', DOTY_INT, 0); $id_user = Docebo::user()->getIdSt(); $docebo_course = new DoceboCourse($id_course); require_once _lms_ . '/admin/models/SubscriptionAlms.php'; $model = new SubscriptionAlms($id_course, $id_edition, $id_date); $course_info = $model->getCourseInfoForSubscription(); $userinfo = $this->acl_man->getUser($id_user); $level_idst =& $docebo_course->getCourseLevel($id_course); if (count($level_idst) == 0 || $level_idst[1] == '') { $level_idst =& $docebo_course->createCourseLevel($id_course); } $waiting = 0; if ($course_info['subscribe_method'] != 2) { $waiting = 1; } $userlevel_subscrip = $this->get_userlevel_subscription($id_user); //UG //UG $this->acl_man->addToGroup($level_idst[3], $id_user); $this->acl_man->addToGroup($level_idst[$userlevel_subscrip], $id_user); //UG //UG if($model->subscribeUser($id_user, 3, $waiting)) if ($model->subscribeUser($id_user, $userlevel_subscrip, $waiting)) { $res['success'] = true; $res['new_status_code'] = ''; if ($id_edition != 0 || $id_date != 0) { $must_change_status = $this->model->controlSubscriptionRemaining($id_course); $res['new_status'] = ''; if (!$must_change_status) { $res['new_status'] = '<p class="cannot_subscribe">' . Lang::t('_NO_EDITIONS', 'catalogue') . '</p>'; } } else { if ($waiting == 1) { $res['new_status'] = '<p class="cannot_subscribe">' . Lang::t('_WAITING', 'catalogue') . '</p>'; $res['new_status_code'] = 'waiting'; } else { $res['new_status'] = '<p class="subscribed">' . Lang::t('_USER_STATUS_ENTER', 'catalogue') . '</p>'; $res['new_status_code'] = 'subscribed'; } } $array_subst = array('[url]' => Get::sett('url'), '[course]' => $course_info['name'], '[firstname]' => $userinfo[ACL_INFO_FIRSTNAME], '[lastname]' => $userinfo[ACL_INFO_LASTNAME]); // message to user that is waiting require_once _base_ . '/lib/lib.eventmanager.php'; $msg_composer = new EventMessageComposer('subscribe', 'lms'); $msg_composer->setSubjectLangText('email', '_NEW_USER_SUBS_WAITING_SUBJECT', false); $msg_composer->setBodyLangText('email', '_NEW_USER_SUBS_WAITING_TEXT', $array_subst); $msg_composer->setSubjectLangText('sms', '_NEW_USER_SUBS_WAITING_SUBJECT_SMS', false); $msg_composer->setBodyLangText('sms', '_NEW_USER_SUBS_WAITING_TEXT_SMS', $array_subst); $acl =& Docebo::user()->getAcl(); $acl_man =& $this->acl_man; $recipients = array(); $idst_group_god_admin = $acl->getGroupST(ADMIN_GROUP_GODADMIN); $recipients = $acl_man->getGroupMembers($idst_group_god_admin); $idst_group_admin = $acl->getGroupST(ADMIN_GROUP_ADMIN); $idst_admin = $acl_man->getGroupMembers($idst_group_admin); require_once _adm_ . '/lib/lib.adminmanager.php'; foreach ($idst_admin as $id_user) { $adminManager = new AdminManager(); $acl_manager =& $acl_man; $idst_associated = $adminManager->getAdminTree($id_user); $array_user =& $acl_manager->getAllUsersFromIdst($idst_associated); $array_user = array_unique($array_user); $array_user[] = $array_user[0]; unset($array_user[0]); $control_user = array_search(getLogUserId(), $array_user); $query = "SELECT COUNT(*)" . " FROM " . Get::cfg('prefix_fw') . "_admin_course" . " WHERE idst_user = '******'" . " AND type_of_entry = 'course'" . " AND id_entry = '" . $id_course . "'"; list($control_course) = mysql_fetch_row(mysql_query($query)); /*if($control) $recipients[] = $id_user;*/ $query = "SELECT COUNT(*)" . " FROM " . Get::cfg('prefix_fw') . "_admin_course" . " WHERE idst_user = '******'" . " AND type_of_entry = 'coursepath'" . " AND id_entry IN" . " (" . " SELECT id_path" . " FROM " . Get::cfg('prefix_lms') . "_coursepath_courses" . " WHERE id_item = '" . $id_course . "'" . " )"; list($control_coursepath) = mysql_fetch_row(mysql_query($query)); /*if($control) $recipients[] = $id_user;*/ $query = "SELECT COUNT(*)" . " FROM " . Get::cfg('prefix_fw') . "_admin_course" . " WHERE idst_user = '******'" . " AND type_of_entry = 'catalogue'" . " AND id_entry IN" . " (" . " SELECT idCatalogue" . " FROM " . Get::cfg('prefix_lms') . "_catalogue_entry" . " WHERE idEntry = '" . $id_course . "'" . " )"; list($control_catalogue) = mysql_fetch_row(mysql_query($query)); if ($control_user && ($control_course || $control_coursepath || $control_catalogue)) { $recipients[] = $id_user; } } $recipients = array_unique($recipients); createNewAlert('UserCourseInsertModerate', 'subscribe', 'insert', '1', 'User subscribed with moderation', $recipients, $msg_composer); $res['message'] = UIFeedback::info(Lang::t('_SUBSCRIPTION_CORRECT', 'catalogue'), true); } else { $this->acl_man->removeFromGroup($level_idst[3], $id_user); $res['success'] = false; $res['message'] = UIFeedback::error(Lang::t('_SUBSCRIPTION_ERROR', 'catalogue'), true); } echo $this->json->encode($res); }
public function makeOrder() { $wire = Get::req('wire', DOTY_INT, 0); $cart = $_SESSION['lms_cart']; require_once _lms_ . '/lib/lib.cart.php'; if (Learning_Cart::cartItemCount() > 0) { $id_trans = $this->model->createTransaction(); } else { $id_trans = false; } if ($id_trans === false) { $result = array('success' => false, 'message' => UIFeedback::error(Lang::t('_ERROR_CREATE_TRANS', 'catalogue'), true)); } else { $course_info = $this->model->getCartList(true); $total_price = 0; foreach ($cart as $id_course => $extra) { $docebo_course = new DoceboCourse($id_course); require_once _lms_ . '/admin/models/SubscriptionAlms.php'; $level_idst =& $docebo_course->getCourseLevel($id_course); if (count($level_idst) == 0 || $level_idst[1] == '') { $level_idst =& $docebo_course->createCourseLevel($id_course); } $waiting = 1; $this->acl_man->addToGroup($level_idst[3], Docebo::user()->getIdSt()); if (isset($extra['classroom'])) { foreach ($extra['classroom'] as $id_date) { $model = new SubscriptionAlms($id_course, 0, $id_date); if (!$model->subscribeUser(Docebo::user()->getIdSt(), 3, $waiting)) { $this->acl_man->removeFromGroup($level_idst[3], Docebo::user()->getIdSt()); } elseif ($this->model->addTransactionCourse($id_trans, $id_course, $id_date, 0, $course_info[$id_course . '_' . $id_date . '_0'])) { unset($_SESSION['lms_cart'][$id_course]['classroom'][$id_date]); $query = "UPDATE %lms_courseuser" . " SET status = '-2'" . " WHERE idUser = "******" AND idCourse = " . $id_course; sql_query($query); $total_price += $course_info[$id_course . '_' . $id_date . '_0']['price']; } } } elseif (isset($extra['edition'])) { foreach ($extra['edition'] as $id_edition) { $model = new SubscriptionAlms($id_course, $id_edition, 0); if (!$model->subscribeUser(Docebo::user()->getIdSt(), 3, $waiting)) { $this->acl_man->removeFromGroup($level_idst[3], Docebo::user()->getIdSt()); } elseif ($this->model->addTransactionCourse($id_trans, $id_course, 0, $id_edition, $course_info[$id_course . '_0_' . $id_edition])) { unset($_SESSION['lms_cart'][$id_course]['edition'][$id_edition]); $query = "UPDATE %lms_courseuser" . " SET status = '-2'" . " WHERE idUser = "******" AND idCourse = " . $id_course; sql_query($query); $total_price += $course_info[$id_course . '_0_' . $id_edition]['price']; } } } else { $model = new SubscriptionAlms($id_course, 0, 0); if (!$model->subscribeUser(Docebo::user()->getIdSt(), 3, $waiting)) { $this->acl_man->removeFromGroup($level_idst[3], Docebo::user()->getIdSt()); } elseif ($this->model->addTransactionCourse($id_trans, $id_course, 0, 0, $course_info[$id_course . '_0_0'])) { unset($_SESSION['lms_cart'][$id_course]); $query = "UPDATE %lms_courseuser" . " SET status = '-2'" . " WHERE idUser = "******" AND idCourse = " . $id_course; sql_query($query); $total_price += $course_info[$id_course . '_0_0']['price']; } } } require_once _lms_ . '/lib/lib.cart.php'; if (Learning_Cart::cartItemCount() == 0) { $_SESSION['lms_cart'] = array(); } $_SESSION['cart_transaction'] = $id_trans; $result = array('success' => true, 'message' => UIFeedback::info(Lang::t('_TRANS_CREATED', 'catalogue'), true), 'id_transaction' => $id_trans, 'total_price' => $total_price, 'link' => Get::sett('url') . _folder_lms_ . '/index.php?r=cart/show&id_transaction=' . $id_trans . '&cart=' . $_SESSION['cart_id']); } if ($wire) { if ($result['success']) { Util::jump_to('index.php?r=cart/wireInfo&id_transaction=' . $id_trans); } Util::jump_to('index.php?r=cart/show&error=1'); } else { echo $this->json->encode($result); } }