function chat() { checkPerm('view'); $lang =& DoceboLanguage::createInstance('chat'); require_once $GLOBALS['where_scs'] . '/lib/lib.chat.php'; $chat_man = new ChatManager(); $id_room = $chat_man->getIdRoom('lms', 'course', $_SESSION['idCourse']); if (!$id_room) { require_once $GLOBALS['where_scs'] . '/lib/lib.room.php'; $course_name = $GLOBALS['course_descriptor']->getValue('name'); $rules = array('room_name' => $course_name, 'room_type' => 'course', 'id_source' => $_SESSION['idCourse']); $id_room = insertRoom($rules); } // show only the room of the current course $chat_man->setRoomFilter(array($id_room)); //$users = $chat_man->getRoomUserOnline('lms', $id_room); $GLOBALS['page']->add(getTitleArea($lang->def('_CHAT'), 'advice') . '<div class="std_block">' . '<div>' . $lang->def('_CHAT_DESCRIPTION') . '</div><br />' . '<div>' . $chat_man->getOpenChatCommand($lang->def('_OPENCHAT'), $lang->def('_OPENCHAT_WA'), 'lms', $id_room) . '</div>' . '</div>', 'content'); }
function insroom() { require_once $GLOBALS['where_scs'] . '/lib/lib.room.php'; $re = insertRoom($_POST['rules']); Util::jump_to('index.php?modname=room&op=room&result=' . ($re ? 'ok' : 'err')); }
function insCourse() { require_once _base_ . '/lib/lib.upload.php'; require_once _base_ . '/lib/lib.multimedia.php'; require_once $GLOBALS['where_lms'] . '/lib/lib.course.php'; require_once $GLOBALS['where_lms'] . '/lib/lib.manmenu.php'; if ($_POST['course_type'] === 'classroom') { $url = 'index.php?r=alms/classroom/show&result='; } else { $url = 'index.php?modname=course&op=course_list&result='; } $array_lang = Docebo::langManager()->getAllLangCode(); $array_lang[] = 'none'; $acl_man =& Docebo::user()->getAclManager(); $id_custom = importVar('selected_menu'); // 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', 'lms'); } // 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 = 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 = 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 = 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 = 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 = 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 = "\r\n\tINSERT INTO " . $GLOBALS['prefix_lms'] . "_course\r\n\tSET idCategory \t\t\t= '" . (isset($_POST['idCategory']) ? $_POST['idCategory'] : 0) . "',\r\n\t\tcode \t\t\t\t= '" . $_POST['course_code'] . "',\r\n\t\tname \t\t\t\t= '" . $_POST['course_name'] . "',\r\n\t\tdescription \t\t= '" . $_POST['course_descr'] . "',\r\n\t\tlang_code \t\t\t= '" . $array_lang[$_POST['course_lang']] . "',\r\n\t\tstatus \t\t\t\t= '" . (int) $_POST['course_status'] . "',\r\n\t\tlevel_show_user \t= '" . $show_level . "',\r\n\t\tsubscribe_method \t= '" . (int) $_POST['course_subs'] . "',\r\n\r\n\t\tcreate_date\t\t\t= '" . date("Y-m-d H:i:s") . "',\r\n\r\n\t\tlinkSponsor \t\t= '" . $_POST['course_sponsor_link'] . "',\r\n\t\timgSponsor \t\t\t= '" . $file_sponsor . "',\r\n\t\timg_course \t\t\t= '" . $file_logo . "',\r\n\t\timg_material \t\t= '" . $file_material . "',\r\n\t\timg_othermaterial \t= '" . $file_othermaterial . "',\r\n\t\tcourse_demo \t\t= '" . $file_demo . "',\r\n\r\n\t\tmediumTime \t\t\t= '" . $_POST['course_medium_time'] . "',\r\n\t\tpermCloseLO \t\t= '" . $_POST['course_em'] . "',\r\n\t\tuserStatusOp \t\t= '" . $user_status . "',\r\n\t\tdifficult \t\t\t= '" . $_POST['course_difficult'] . "',\r\n\r\n\t\tshow_progress \t\t= '" . (isset($_POST['course_progress']) ? 1 : 0) . "',\r\n\t\tshow_time \t\t\t= '" . (isset($_POST['course_time']) ? 1 : 0) . "',\r\n\r\n\t\tshow_who_online\t\t= '" . $_POST['show_who_online'] . "',\r\n\r\n\t\tshow_extra_info \t= '" . (isset($_POST['course_advanced']) ? 1 : 0) . "',\r\n\t\tshow_rules \t\t\t= '" . (int) $_POST['course_show_rules'] . "',\r\n\r\n\t\tdirect_play \t\t= '" . (isset($_POST['direct_play']) ? 1 : 0) . "',\r\n\r\n\t\tdate_begin \t\t\t= '" . $date_begin . "',\r\n\t\tdate_end \t\t\t= '" . $date_end . "',\r\n\t\thour_begin \t\t\t= '" . $hour_begin . "',\r\n\t\thour_end \t\t\t= '" . $hour_end . "',\r\n\r\n\t\tvalid_time \t\t\t= '" . (int) $_POST['course_day_of'] . "',\r\n\r\n\t\tmin_num_subscribe \t= '" . (int) $_POST['min_num_subscribe'] . "',\r\n\t\tmax_num_subscribe \t= '" . (int) $_POST['max_num_subscribe'] . "',\r\n\t\tselling \t\t\t= '" . (isset($_POST['course_sell']) ? '1' : '0') . "',\r\n\t\tprize \t\t\t\t= '" . $_POST['course_prize'] . "',\r\n\r\n\t\tcourse_type \t\t= '" . $_POST['course_type'] . "',\r\n\r\n\t\tcourse_edition \t\t= '" . (isset($_POST['course_edition']) ? 1 : 0) . "',\r\n\r\n\t\tcourse_quota \t\t= '" . $_POST['course_quota'] . "',\r\n\t\tused_space\t\t\t= '" . $total_file_size . "',\r\n\t\tallow_overbooking \t= '" . (isset($_POST["allow_overbooking"]) ? 1 : 0) . "',\r\n\t\tcan_subscribe \t\t= '" . (int) $_POST["can_subscribe"] . "',\r\n\t\tsub_start_date \t\t= " . ($_POST["can_subscribe"] == '2' ? "'" . $sub_start_date . "'" : 'NULL') . ",\r\n\t\tsub_end_date \t\t= " . ($_POST["can_subscribe"] == '2' ? "'" . $sub_end_date . "'" : 'NULL') . ",\r\n\r\n\t\tadvance \t\t\t= '" . $_POST['advance'] . "',\r\n\t\tshow_result \t\t= '" . (isset($_POST["show_result"]) ? 1 : 0) . "',\r\n\r\n\t\tuse_logo_in_courselist = '" . (isset($_POST['use_logo_in_courselist']) ? '1' : '0') . "'"; 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); } Util::jump_to($url . '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); //$admin_rules = getAdminRules(); //$rules = array_merge($rules, $admin_rules); $re = insertRoom($rules); } $course_idst =& DoceboCourse::createCourseLevel($id_course); // create the course menu ----------------------------------------------------------- if (!cerateCourseMenuFromCustom($id_custom, $id_course, $course_idst)) { Util::jump_to($url . 'err_coursemenu'); } /* // send alert ------------------------------------------------------------------------------- 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]' => $_POST['course_code'], '[course]' => $_POST['course_name'] ) ); $msg_composer->setBodyLangText('sms', '_ALERT_TEXT_SMS', array( '[url]' => Get::sett('url'), '[course_code]' => $_POST['course_code'], '[course]' => $_POST['course_name'] ) ); require_once($GLOBALS['where_lms'] . '/lib/lib.course.php'); $course_man = new Man_Course(); $recipients = $course_man->getIdUserOfLevel($id_course); createNewAlert( 'CoursePropModified', 'course', 'add', '1', 'Inserted course '.$_POST['course_name'], $recipients, $msg_composer ); */ Util::jump_to($url . ($error ? 'err_course' : 'ok_course') . ($quota_exceeded ? '&limit_reach=1' : '')); }
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; }
/** * Created by PhpStorm. * User: William * Date: 1/2/14 * Time: 12:52 PM */ require_once "../database/database.php"; require_once "../database/rooms.php"; require_once "../model/room.php"; if (!isset($_POST['txtRoomName'])) { //Exit if a room name wasn't provided exit; } if (!isset($_POST['txtBuildingId'])) { //Exit if a building id wasn't provided exit; } //Get the name of the room that the user wants to add to the database $name = $_POST['txtRoomName']; //Get the id of the building that the user wants to add the room to $buildingId = $_POST['txtBuildingId']; //Check to see if the user included a description. If not, create an empty string if (isset($_POST['txtRoomDesc'])) { $description = $_POST['txtRoomDesc']; } else { $description = ""; } //Insert the devices into the database echo insertRoom($buildingId, $name, $description);
<?php include '../model/roomdb.php'; //CRUD Chat if ($_POST['method'] == 'insertRoom') { insertRoom(); } if ($_POST['method'] == 'showAllRooms') { showAllRooms(); } if ($_POST['method'] == 'showMyRooms') { showMyRooms(); } if ($_POST['method'] == 'updateRoom') { updateRoom(); } if ($_POST['method'] == 'addUserToRoom') { addUserToRoom(); } if ($_POST['method'] == 'deleteRoom') { deleteRoom(); } if ($_POST['method'] == 'showUsersInChatRoom') { showUsersInChatRoom(); }