public function delUserFromEdition($id_user, $id_course, $id_edition) { $level = $this->subscribe_man->getUserLeveInCourse($id_user, $id_course); $this->removeUserFromEdition($id_user, $id_edition, $id_course); if (!$this->controlUserSubscriptions($id_user, $id_course)) { require_once _lms_ . '/lib/lib.subscribe.php'; require_once _lms_ . '/lib/lib.course.php'; $subscribe_man = new CourseSubscribe_Manager(); $subscribe_man->delUserFromCourse($id_user, $id_course); $docebo_course = new DoceboCourse($id_course); $level_idst =& $docebo_course->getCourseLevel($id_course); $this->acl_man->removeFromGroup($level_idst[$level], $id_user); } return true; }
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; }
public function deleteUserSubscription($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); // --------------- delete user subscription: ------------------------ $model = new SubscriptionAlms($course_id, $edition_id, $classroom_id); $docebo_course = new DoceboCourse($course_id); $level_idst = $docebo_course->getCourseLevel($course_id); $old_level = $model->getUserLevel($user_id); $delete_ok = $model->delUser($user_id); if ($delete_ok) { if (empty($edition_id) && empty($classroom_id)) { $acl_man->removeFromGroup($level_idst[$old_level], $user_id); } } if (!$delete_ok) { $output['success'] = false; } else { $output['message'] = 'User has been removed from the course'; } return $output; }
public function updateUserLeveInCourse($id_user, $id_course, $new_level) { $query_lvl = "SELECT idUser, level" . " FROM " . $this->subscribe_table . " WHERE idCourse = " . (int) $id_course . " AND idUser "; $query = "UPDATE " . $this->subscribe_table . " SET level = " . (int) $new_level . " WHERE idCourse = " . (int) $id_course . " AND idUser "; if (is_array($id_user)) { $query .= " IN (" . implode(',', $id_user) . ")"; $query_lvl .= " IN (" . implode(',', $id_user) . ")"; } else { $query .= " = " . (int) $id_user; $query_lvl .= " = " . (int) $id_user; $id_user = array($id_user); } $result = $this->db->query($query); $old_level = array(); while (list($id_user_t, $level) = $this->db->fetch_row($result)) { $old_level[$id_user_t] = $level; } $res = $this->db->query($query); if ($res) { require_once _lms_ . '/lib/lib.course.php'; $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 ($id_user as $id_user_t) { $this->acl_man->removeFromGroup($level_idst[$old_level[$id_user]], $id_user_t); $this->acl_man->addToGroup($level_idst[$new_level], $id_user_t); } } return $res; }
function approveusers() { checkPerm('moderate', false, 'course'); require_once $GLOBALS['where_lms'] . '/lib/lib.course.php'; require_once _base_ . '/lib/lib.preference.php'; $id_course = importVar('id_course', true, 0); $course_info = Man_Course::getCourseInfo($id_course); $edition_id = getCourseEditionId(); $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'; $docebo_course = new DoceboCourse($id_course); $group_levels = $docebo_course->getCourseLevel($id_course); while (list($id_user, $action) = each($_POST['waiting_user'])) { if ($action == 0) { // approved ----------------------------------------------- $text_query = "\r\n\t\t\t\tUPDATE " . $GLOBALS['prefix_lms'] . "_courseuser\r\n\t\t\t\tSET waiting = 0, \r\n\t\t\t\t\tstatus = '" . _CUS_SUBSCRIBED . "'\r\n\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); } backcourse($re ? 'ok' : 'err'); }
public function delUserFromDate($id_user, $id_course, $id_date) { $this->removeUserFromDate($id_user, $id_date, $id_course); if (!$this->controlUserSubscriptions($id_user, $id_course)) { require_once _lms_ . '/lib/lib.course.php'; require_once _lms_ . '/lib/lib.subscribe.php'; $subscribe_man = new CourseSubscribe_Manager(); $level = $this->subscribe_man->getUserLeveInCourse($id_user, $id_course); $subscribe_man->delUserFromCourse($id_user, $id_course); $docebo_course = new DoceboCourse($id_course); $level_idst =& $docebo_course->getCourseLevel($id_course); $this->acl_man->removeFromGroup($level_idst[$level], $id_user); //check if there are overbooked users $cinfo = $this->getDateInfo($id_date); $overbooking_users = $this->getDateOverbookingUsers($id_date); if ($cinfo['overbooking'] > 0 && !empty($overbooking_users)) { if ($cinfo['user_subscribed'] - count($overbooking_users) < $cinfo['max_par']) { $this->setFirstOverbookingUser($id_date); } } } return true; }
function subscribeToCourse($id_user, $id_course, $id_date = 0) { 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 = "******"INSERT INTO " . $GLOBALS['prefix_lms'] . "_courseuser\r\n\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\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 = mysql_query("INSERT INTO " . $GLOBALS['prefix_lms'] . "_courseuser\r\n\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\tVALUES ('" . $id_user . "', '" . $id_course . "', '0', '3', '" . $waiting . "', '" . getLogUserId() . "', '" . date("Y-m-d H:i:s") . "')"); if ($re) { addUserToTimeTable($id_user, $id_course, 0); } } } return true; }
/** * deleteTransaction * @param <int> $id_trans * @param <boolean> $rem_user_subscription * @return boolean */ public function deleteTransaction($id_trans, $rem_user_subscription = false) { $res = false; $transaction_info = $this->getTransactionInfo($id_trans); $id_user = $transaction_info['id_user']; if ($rem_user_subscription) { foreach ($transaction_info['product'] as $prod) { // remove subscription request require_once _lms_ . '/admin/modules/subscribe/subscribe.php'; $man_course = new Man_Course(); if ($prod['activated'] == 0) { $id_course = $prod['id_course']; $edition_id = $prod['id_edition']; $docebo_course = new DoceboCourse($id_course); $group_levels = $docebo_course->getCourseLevel($id_course); $waiting_users = $man_course->getWaitingSubscribed($id_course); $level = $waiting_users['users_info'][$id_user]['level']; $result = removeSubscription($id_course, $id_user, $group_levels[$level], $edition_id); } } } $qtxt = "DELETE FROM %adm_transaction_info WHERE id_trans = " . (int) $id_trans; $q1 = sql_query($qtxt); $qtxt = "DELETE FROM %adm_transaction WHERE id_trans = " . (int) $id_trans; $q2 = sql_query($qtxt); if ($q1 && $q2) { $res = true; } return $res; }
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 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; }
public function dupcourse() { if (!$this->permissions['add']) { $output = array('success' => false, 'message' => $this->_getMessage("no permission")); echo $this->json->encode($output); return; } //TO DO: make it a sqltransaction if possible if (isset($_POST['confirm'])) { $id_dupcourse = Get::req('id_course', DOTY_INT, 0); $id_orgs = array(); $array_new_testobject = array(); // read the old course info $query_sel = "SELECT * FROM %lms_course WHERE 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] = sql_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 %lms_course\n\t\t\t\t( idCategory, code, name, description, lang_code, status, level_show_user,\n\t\t\t\tsubscribe_method, linkSponsor, imgSponsor, img_course, img_material, img_othermaterial,\n\t\t\t\tcourse_demo, mediumTime, permCloseLO, userStatusOp, difficult, show_progress, show_time, show_extra_info,\n\t\t\t\tshow_rules, valid_time, max_num_subscribe, min_num_subscribe,\n\t\t\t\tmax_sms_budget, selling, prize, course_type, policy_point, point_to_all, course_edition, classrooms, certificates,\n\t\t\t\tcreate_date, security_code, imported_from_connection, course_quota, used_space, course_vote, allow_overbooking, can_subscribe,\n\t\t\t\tsub_start_date, sub_end_date, advance, show_who_online, direct_play, autoregistration_code, use_logo_in_courselist )\n\t\t\t\tVALUES\n\t\t\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\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\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\t\t'" . $list_sel['show_rules'] . "', '" . $list_sel['valid_time'] . "', '" . $list_sel['max_num_subscribe'] . "', '" . $list_sel['min_num_subscribe'] . "',\n\t\t\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\t\t'" . date('Y-m-d H:i:s') . "', '" . $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\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) { ob_clean(); ob_start(); echo $this->json->encode(array('success' => false)); die; } // the id of the new course created $new_id_course = $new_course_dup = sql_insert_id(); //Create the new course file if (isset($_POST['image'])) { $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 menu data ----------------------------------------------------- // copy the old course menu into the new one $query_selmen = "SELECT * FROM %lms_menucourse_main WHERE idCourse = '" . $id_dupcourse . "' "; $result_selmen = sql_query($query_selmen); while ($list_selmen = sql_fetch_array($result_selmen)) { $query_dupmen = "INSERT INTO %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_insert_list = array(); $query_selmenun = "SELECT * FROM %lms_menucourse_under WHERE idCourse = '" . $id_dupcourse . "' "; $result_selmenun = sql_query($query_selmenun); while ($new_org = sql_fetch_array($result_selmenun)) { $valore_idn = $new_org['idMain']; $_idMain = $array_seq[$valore_idn]; $query_insert_list[] = "('" . $_idMain . "', '" . $new_course_dup . "', '" . $new_org['sequence'] . "', '" . $new_org['idModule'] . "', '" . $new_org['my_name'] . "')"; } $result_dupmen = true; if (!empty($query_insert_list)) { $query_dupmen = "INSERT INTO %lms_menucourse_under\n\t\t\t\t\t(idMain, idCourse, sequence, idModule, my_name)\n\t\t\t\t\tVALUES " . implode(",", $query_insert_list); $result_dupmen = sql_query($query_dupmen); } //--- end menu ----------------------------------------------------------- function &getCourseLevelSt($id_course) { $map = array(); $levels = CourseLevel::getLevels(); // find all the group created for this menu custom for permission management foreach ($levels as $lv => $name_level) { $group_info = Docebo::aclm()->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 _lms_ . '/lib/lib.course.php'; require_once _lms_ . '/lib/lib.manmenu.php'; require_once _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) { Docebo::aclm()->addToRole($idrole, $group_idst[$lv]); } } } if (isset($_POST['certificate'])) { // duplicate the certificate assigned $query_insert_list = array(); $query_selmenun = "SELECT * FROM %lms_certificate_course WHERE id_course = '" . $id_dupcourse . "' "; $result_selmenun = sql_query($query_selmenun); while ($new_org = sql_fetch_assoc($result_selmenun)) { $query_insert_list[] = "('" . $new_org['id_certificate'] . "', '" . $new_course_dup . "', \n\t\t\t\t\t\t'" . $new_org['available_for_status'] . "', '" . $new_org['point_required'] . "' )"; } $result_dupmen = true; if (!empty($query_insert_list)) { $query_dupmen = "INSERT INTO %lms_certificate_course\n\t\t\t\t\t\t(id_certificate, id_course, available_for_status, point_required)\n\t\t\t\t\t\tVALUES " . implode(",", $query_insert_list); $result_dupmen = sql_query($query_dupmen); } } require_once _lms_ . '/modules/organization/orglib.php'; require_once _lms_ . '/lib/lib.param.php'; require_once _lms_ . '/class.module/track.object.php'; require_once _lms_ . '/class.module/learning.object.php'; $nullVal = NULL; $id_orgs = array(); $map_org = array(); if (isset($_POST['lo'])) { $org_map = array(); $id_orgs = array(); $prereq_map = array(); // retrive all the folders and object, the order by grant that folder are created before the elements contained in them $query = "SELECT * FROM %lms_organization WHERE idCourse = " . (int) $id_dupcourse . " ORDER BY path ASC"; $source_res = sql_query($query); // Go trough all the entry of learning_organization while ($source = sql_fetch_object($source_res)) { // check if LO id is checked if (in_array($source->idOrg, $_POST['lo_list'])) { // if it's an object we must make a copy, if it's a folder we can create a row // inside learning_orgation and save the id for later use if ($source->objectType == '') { // is a folder // create a new row in learning_organization $query_new_org = "INSERT INTO %lms_organization (\n\t\t\t\t\t\t\t\tidParent,\n\t\t\t\t\t\t\t\tpath, lev, title,\n\t\t\t\t\t\t\t\tobjectType, idResource, idCategory, idUser,\n\t\t\t\t\t\t\t\tidAuthor, version, difficult, description,\n\t\t\t\t\t\t\t\tlanguage, resource, objective, dateInsert,\n\t\t\t\t\t\t\t\tidCourse, prerequisites, isTerminator, idParam,\n\t\t\t\t\t\t\t\tvisible, milestone)\n\t\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t('" . (isset($id_orgs[$source->idParent]) ? $id_orgs[$source->idParent] : 0) . "',\n\t\t\t\t\t\t\t\t'" . $source->path . "', '" . $source->lev . "', '" . sql_escape_string($source->title) . "',\n\t\t\t\t\t\t\t\t'" . $source->objectType . "', '" . $source->idResource . "', '" . $source->idCategory . "', '" . $source->idUser . "',\n\t\t\t\t\t\t\t\t'" . $source->idAuthor . "', '" . $source->version . "', '" . $source->difficult . "', '" . sql_escape_string($source->description) . "',\n\t\t\t\t\t\t\t\t'" . $source->language . "', '" . $source->resource . "', '" . $source->objective . "', '" . $source->dateInsert . "',\n\t\t\t\t\t\t\t\t'" . $new_id_course . "', '" . $source->prerequisites . "', '" . $source->isTerminator . "', '" . $source->idParam . "',\n\t\t\t\t\t\t\t\t'" . $source->visible . "', '" . $source->milestone . "')"; $re_new_org = sql_query($query_new_org); $new_id_reference = sql_insert_id(); // map for later use $org_map['folder'][$source->idOrg] = $new_id_reference; } else { // is an object // make a copy $lo = $this->_createLO($source->objectType); $new_id_resource = $lo->copy($source->idResource); // create a new row in learning_organization $query_new_org = "INSERT INTO %lms_organization (\n\t\t\t\t\t\t\t\tidParent, path, lev, title,\n\t\t\t\t\t\t\t\tobjectType, idResource, idCategory, idUser,\n\t\t\t\t\t\t\t\tidAuthor, version, difficult, description,\n\t\t\t\t\t\t\t\tlanguage, resource, objective, dateInsert,\n\t\t\t\t\t\t\t\tidCourse, prerequisites, isTerminator, idParam,\n\t\t\t\t\t\t\t\tvisible, milestone)\n\t\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t('" . (isset($id_orgs[$source->idParent]) ? $id_orgs[$source->idParent] : 0) . "',\n\t\t\t\t\t\t\t\t'" . $source->path . "', '" . $source->lev . "', '" . sql_escape_string($source->title) . "',\n\t\t\t\t\t\t\t\t'" . $source->objectType . "', '" . $new_id_resource . "', '" . $source->idCategory . "', '" . $source->idUser . "',\n\t\t\t\t\t\t\t\t'" . $source->idAuthor . "', '" . $source->version . "', '" . $source->difficult . "', '" . sql_escape_string($source->description) . "',\n\t\t\t\t\t\t\t\t'" . $source->language . "', '" . $source->resource . "', '" . $source->objective . "', '" . $source->dateInsert . "',\n\t\t\t\t\t\t\t\t'" . $new_id_course . "', '" . $source->prerequisites . "', '" . $source->isTerminator . "', '0',\n\t\t\t\t\t\t\t\t'" . $source->visible . "', '" . $source->milestone . "')"; $re_new_org = sql_query($query_new_org); $new_id_reference = sql_insert_id(); // for a learning_object we have to create a row in lo_param as well // with 4.1 or 4.2 we plan to remove this table, but until then we need this $query_lo_par = "INSERT INTO %lms_lo_param (param_name, param_value) VALUES ('idReference', '" . $new_id_reference . "') "; $result_lo_par = sql_query($query_lo_par); $id_lo_par = sql_insert_id(); $query_up_lo = "UPDATE %lms_lo_param SET idParam = '" . $id_lo_par . "' WHERE id = '" . $id_lo_par . "' "; $result_up_lo = sql_query($query_up_lo); $query_up_or = "UPDATE %lms_organization SET idParam = '" . $id_lo_par . "' WHERE idOrg = '" . $new_id_reference . "' "; $result_up_or = sql_query($query_up_or); // map for later use $org_map[$source->objectType][$source->idResource] = $new_id_resource; } // create a map for the olds and new idReferences $id_orgs[$source->idOrg] = $new_id_reference; if ($source->prerequisites != '') { $prereq_map[$new_id_reference] = $source->prerequisites; } } } // updates prerequisites foreach ($prereq_map as $new_id_reference => $old_prerequisites) { $new_prerequisites = array(); $old_prerequisites = explode(",", $old_prerequisites); foreach ($old_prerequisites as $old_p) { //a prerequisite can be a pure number or something like 7=NULL, or 7=incomplete $old_id = intval($old_p); if (isset($id_orgs[$old_id])) { $new_prerequisites[] = str_replace($old_id, $id_orgs[$old_id], $old_p); } } if (!empty($new_prerequisites)) { $query_updcor = "UPDATE %lms_organization " . "SET prerequisites = '" . implode(",", $new_prerequisites) . "' " . "WHERE idOrg = " . $new_id_reference . " "; $result_upcor = sql_query($query_updcor); } } //--- copy forum data -------------------------------------------------- $query_insert_list = array(); $query_selmenun = "SELECT * FROM %lms_forum WHERE idCourse = '" . $id_dupcourse . "' "; $result_selmenun = sql_query($query_selmenun); while ($new_org = sql_fetch_assoc($result_selmenun)) { $query_insert_list[] = "('" . $new_course_dup . "', '" . sql_escape_string($new_org['title']) . "', '" . sql_escape_string($new_org['description']) . "',\n\t\t\t\t\t\t'" . $new_org['locked'] . "', '" . $new_org['sequence'] . "', '" . $new_org['emoticons'] . "')"; } $result_dupmen = true; if (!empty($query_insert_list)) { $query_dupmen = "INSERT INTO %lms_forum\n\t\t\t\t\t\t(idCourse, title, description, locked, sequence, emoticons)\n\t\t\t\t\t\tVALUES " . implode(",", $query_insert_list); $result_dupmen = sql_query($query_dupmen); } //--- end forum -------------------------------------------------------- //--- copy coursereports data ------------------------------------------ //create a conversion table for tests and scoitems coursereports $array_organization = array('test' => array(), 'scoitem' => array()); $arr_items_flat = array('test' => array(), 'scoitem' => array()); $query_org = "SELECT source_of, id_source\n\t\t\t\t\tFROM %lms_coursereport WHERE id_course = '" . $id_dupcourse . "'\n\t\t\t\t\tAND source_of IN ('test', 'scoitem')"; $res_org = sql_query($query_org); while (list($source_of, $id_source) = sql_fetch_row($res_org)) { switch ($source_of) { case 'scoitem': $arr_items_flat['scoitem'][] = $id_source; break; } } if (!empty($arr_items_flat['scoitem'])) { //retrieve idOrgs of scoitems' scormorgs $arr_old_idorg = array(); $arr_old_ident = array(); $query = "SELECT o.idOrg, o.idResource, s.idscorm_item, s.item_identifier\n\t\t\t\t\t\tFROM %lms_organization AS o\n\t\t\t\t\t\tJOIN %lms_scorm_items AS s\n\t\t\t\t\t\tON (o.idResource = s.idscorm_organization)\n\t\t\t\t\t\tWHERE s.idscorm_item IN (" . implode(",", $arr_items_flat['scoitem']) . ")\n\t\t\t\t\t\tAND o.objectType = 'scormorg'"; $res = sql_query($query); while (list($idOrg, $idResource, $idscorm_item, $item_identifier) = sql_fetch_row($res)) { $arr_old_idorg[] = $idOrg; $arr_old_ident[$idOrg . '/' . $item_identifier] = $idscorm_item; } if (!empty($arr_old_idorg)) { $arr_new_idorg = array(); foreach ($arr_old_idorg as $idOrg) { $arr_new_idorg[] = $id_orgs[$idOrg]; } $query = "SELECT o.idOrg, o.idResource, s.idscorm_item, s.item_identifier\n\t\t\t\t\t\t\tFROM %lms_organization AS o\n\t\t\t\t\t\t\tJOIN %lms_scorm_items AS s\n\t\t\t\t\t\t\tON (o.idResource = s.idscorm_organization)\n\t\t\t\t\t\t\tWHERE o.idOrg IN (" . implode(",", $arr_new_idorg) . ")\n\t\t\t\t\t\t\tAND o.objectType = 'scormorg'"; $res = sql_query($query); $new_to_old = array_flip($id_orgs); while (list($idOrg, $idResource, $idscorm_item, $item_identifier) = sql_fetch_row($res)) { $_key = $new_to_old[$idOrg] . '/' . $item_identifier; if (array_key_exists($_key, $arr_old_ident)) { $_index = $arr_old_ident[$_key]; $array_organization['scoitem'][$_index] = $idscorm_item; } } } } $query_insert_list = array(); $query_selmenun = "SELECT * FROM %lms_coursereport WHERE id_course = '" . $id_dupcourse . "' "; $result_selmenun = sql_query($query_selmenun); while ($new_org = sql_fetch_array($result_selmenun)) { $id_source_val = 0; switch ($new_org['source_of']) { case 'test': $id_source_val = !isset($org_map['test'][$new_org['id_source']]) ? 0 : $org_map['test'][$new_org['id_source']]; break; case 'scoitem': $id_source_val = !isset($array_organization['scoitem'][$new_org['id_source']]) || $array_organization['scoitem'][$new_org['id_source']] == "" ? 0 : $array_organization['scoitem'][$new_org['id_source']]; break; } $query_insert_list[] = "('" . $new_course_dup . "', '" . sql_escape_string($new_org['title']) . "', '" . $new_org['max_score'] . "',\n\t\t\t\t\t\t'" . $new_org['required_score'] . "', '" . $new_org['weight'] . "', '" . $new_org['show_to_user'] . "',\n\t\t\t\t\t\t'" . $new_org['use_for_final'] . "', '" . $new_org['sequence'] . "', '" . $new_org['source_of'] . "',\n\t\t\t\t\t\t'" . $id_source_val . "')"; } $result_dupman = true; if (!empty($query_insert_list)) { $query_dupmen = "INSERT INTO %lms_coursereport\n\t\t\t\t\t\t(id_course,title,max_score,required_score,weight,show_to_user,use_for_final,sequence,source_of,id_source)\n\t\t\t\t\t\tVALUES " . implode(",", $query_insert_list); $result_dupmen = sql_query($query_dupmen); } //--- end coursereports ------------------------------------------------ //--- copy htmlfront data ---------------------------------------------- $query_insert_list = array(); $query_selmenun = "SELECT * FROM %lms_htmlfront WHERE id_course = '" . $id_dupcourse . "' "; $result_selmenun = sql_query($query_selmenun); while ($new_org = sql_fetch_array($result_selmenun)) { $query_insert_list[] = "('" . $new_course_dup . "', '" . sql_escape_string($new_org['textof']) . "')"; } $result_dupmen = true; if (!empty($query_insert_list)) { $query_dupmen = "INSERT INTO %lms_htmlfront\n\t\t\t\t\t\t(id_course, textof)\n\t\t\t\t\t\tVALUES " . implode(",", $query_insert_list); $result_dupmen = sql_query($query_dupmen); } //--- end htmlfront ---------------------------------------------------- } if (isset($_POST['advice'])) { $query = "SELECT * FROM %lms_advice WHERE idCourse = " . (int) $id_dupcourse; $result = sql_query($query); if (sql_num_rows($result) > 0) { $query_insert_list = array(); $array_sub = array(); $array_replace = array(); foreach ($id_orgs as $id_old_obj => $id_new_obj) { $array_sub[] = 'id_org=' . $id_old_obj; $array_replace[] = 'id_org=' . $id_new_obj; //convert direct links to LOs. TO DO: make sure you are changing only the correct link urls $array_sub[] = 'id_item=' . $id_old_obj; $array_replace[] = 'id_item=' . $id_new_obj; } while ($row = sql_fetch_assoc($result)) { $new_description = !empty($id_orgs) ? str_replace($array_sub, $array_replace, $row['description']) : $row['description']; $query_insert_list[] = "(NULL, " . (int) $new_course_dup . ", '" . $row['posted'] . "', " . (int) $row['author'] . ", '" . $row['title'] . "', '" . $new_description . "', " . (int) $row['important'] . ")"; } if (!empty($query_insert_list)) { $query = "INSERT INTO %lms_advice\n\t\t\t\t\t\t\t(idAdvice, idCourse, posted, author, title, description, important)\n\t\t\t\t\t\t\tVALUES " . implode(",", $query_insert_list); sql_query($query); } } } ob_clean(); echo $this->json->encode(array('success' => true)); } }
/** * 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; }
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); } }