Exemplo n.º 1
0
function assignMenu()
{
    checkPerm('mod');
    require_once _base_ . '/lib/lib.form.php';
    require_once _lms_ . '/lib/lib.course.php';
    if (isset($_POST['assign'])) {
        $id_course = importVar('id_course', true, 0);
        $id_custom = importVar('selected_menu', true, 0);
        $query_course = "SELECT course_type FROM " . $GLOBALS['prefix_lms'] . "_course WHERE idCourse = '" . $id_course . "'";
        list($course_type) = sql_fetch_row(sql_query($query_course));
        if ($course_type === 'classroom') {
            $url = 'index.php?r=alms/classroom/show&result=';
        } else {
            $url = 'index.php?modname=course&op=course_list&result=';
        }
        require_once $GLOBALS['where_lms'] . '/lib/lib.manmenu.php';
        require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
        $acl_man =& Docebo::user()->getAclManager();
        $course_man = new Man_Course();
        $levels =& $course_man->getCourseIdstGroupLevel($id_course);
        if (empty($levels) || implode('', $levels) == '') {
            $levels =& DoceboCourse::createCourseLevel($id_course);
        }
        $course_man->removeCourseRole($id_course);
        $course_man->removeCourseMenu($id_course);
        $course_idst =& $course_man->getCourseIdstGroupLevel($id_course);
        $result = cerateCourseMenuFromCustom($id_custom, $id_course, $course_idst);
        if ($_SESSION['idCourse'] == $id_course) {
            $query = "SELECT module.idModule, main.idMain\r\n\t\t\t\t\t\tFROM ( " . $GLOBALS['prefix_lms'] . "_menucourse_main AS main JOIN\r\n\t\t\t\t\t\t" . $GLOBALS['prefix_lms'] . "_menucourse_under AS un ) JOIN\r\n\t\t\t\t\t\t" . $GLOBALS['prefix_lms'] . "_module AS module\r\n\t\t\t\t\t\tWHERE main.idMain = un.idMain AND un.idModule = module.idModule\r\n\t\t\t\t\t\tAND main.idCourse = '" . (int) $_SESSION['idCourse'] . "'\r\n\t\t\t\t\t\tAND un.idCourse = '" . (int) $_SESSION['idCourse'] . "'\r\n\t\t\t\t\t\tORDER BY main.sequence, un.sequence\r\n\t\t\t\t\t\tLIMIT 0,1";
            list($id_module, $id_main) = sql_fetch_row(sql_query($query));
            $_SESSION['current_main_menu'] = $id_main;
            $_SESSION['sel_module_id'] = $id_module;
            //loading related ST
            Docebo::user()->loadUserSectionST('/lms/course/public/');
            Docebo::user()->SaveInSession();
        }
        Util::jump_to($url . ($result ? 'ok_course' : 'fail_course'));
    } else {
        $lang =& DoceboLanguage::CreateInstance('course', 'lms');
        //list($id_course) = each($_POST['assign_menu_course']);
        $id_course = importVar('id_course', true, 0);
        require_once _base_ . '/lib/lib.form.php';
        require_once $GLOBALS['where_lms'] . '/admin/modules/category/category.php';
        require_once $GLOBALS['where_lms'] . '/admin/modules/category/tree.category.php';
        require_once $GLOBALS['where_lms'] . '/lib/lib.manmenu.php';
        require_once $GLOBALS['where_framework'] . '/lib/lib.sessionsave.php';
        $form = new Form();
        $menu_custom = getAllCustom();
        $sel_custom = key($menu_custom);
        reset($menu_custom);
        $query_course = "SELECT course_type FROM " . $GLOBALS['prefix_lms'] . "_course WHERE idCourse = '" . $id_course . "'";
        list($course_type) = sql_fetch_row(sql_query($query_course));
        if ($course_type === 'classroom') {
            $url = 'index.php?r=alms/classroom/show';
        } else {
            $url = 'index.php?modname=course&op=course_list';
        }
        $title_area = array($url => $lang->def('_COURSE'), $lang->def('_ASSIGN_MENU'));
        $GLOBALS['page']->setWorkingZone('content');
        $GLOBALS['page']->add(getTitleArea($title_area, 'course') . '<div class="std_block">' . $form->openForm('course_creation', 'index.php?modname=course&amp;op=assignMenu') . $form->openElementSpace() . $form->getHidden('id_course', 'id_course', $id_course) . $form->getDropdown($lang->def('_COURSE_MENU_TO_ASSIGN'), 'selected_menu', 'selected_menu', $menu_custom, $sel_custom) . $form->closeElementSpace() . $form->openButtonSpace() . $form->getButton('assign', 'assign', $lang->def('_ASSIGN_USERS')) . $form->getButton('course_undo', 'course_undo', $lang->def('_UNDO')) . $form->closeButtonSpace() . $form->closeForm() . '</div>');
    }
}
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 4
0
 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));
     }
 }