示例#1
0
 function server_info()
 {
     $lang =& DoceboLanguage::createInstance('configuration', 'framework');
     $php_conf = ini_get_all();
     $intest = '<div>' . '<div class="label_effect">';
     $html = '<div class="conf_line_title">' . $lang->def('_SERVERINFO') . '</div>' . config_line($lang->def('_SERVER_ADDR'), $_SERVER['SERVER_ADDR']) . config_line($lang->def('_SERVER_PORT'), $_SERVER['SERVER_PORT']) . config_line($lang->def('_SERVER_NAME'), $_SERVER['SERVER_NAME']) . config_line($lang->def('_SERVER_ADMIN'), $_SERVER['SERVER_ADMIN']) . config_line($lang->def('_SERVER_SOFTWARE'), $_SERVER['SERVER_SOFTWARE']) . '<br />' . '<div class="conf_line_title">' . $lang->def('_SERVER_MYSQL') . '</div>' . config_line($lang->def('_MYSQL_VERS'), mysql_get_server_info()) . '<br />' . '<div class="conf_line_title">' . $lang->def('_PHPINFO') . '</div>' . config_line($lang->def('_PHPVERSION'), phpversion()) . config_line($lang->def('_SAFEMODE'), $php_conf['safe_mode']['local_value'] ? $lang->def('_ON') : $lang->def('_OFF')) . config_line($lang->def('_REGISTER_GLOBAL'), $php_conf['register_globals']['local_value'] ? $lang->def('_ON') : $lang->def('_OFF')) . config_line($lang->def('_MAGIC_QUOTES_GPC'), $php_conf['magic_quotes_gpc']['local_value'] ? $lang->def('_ON') : $lang->def('_OFF')) . config_line($lang->def('_UPLOAD_MAX_FILESIZE'), $php_conf['upload_max_filesize']['local_value']) . config_line($lang->def('_POST_MAX_SIZE'), $php_conf['post_max_size']['local_value']) . config_line($lang->def('_MAX_EXECUTION_TIME'), $php_conf['max_execution_time']['local_value'] . 's') . config_line($lang->def('_LDAP'), extension_loaded('ldap') ? $lang->def('_ON') : '<span class="font_red">' . $lang->def('_OFF') . ' ' . $lang->def('_USEFULL_ONLY_IF') . '</span>') . config_line($lang->def('_PHP_TIMEZONE'), @date_default_timezone_get());
     if (version_compare(phpversion(), "5.0.0") == -1) {
         echo config_line($lang->def('_DOMXML'), extension_loaded('domxml') ? $lang->def('_ON') : '<span class="font_red">' . $lang->def('_OFF') . ' (' . $lang->def('_NOTSCORM') . ')</span>');
     }
     if (version_compare(phpversion(), "5.2.0", ">")) {
         echo config_line($lang->def('_ALLOW_URL_INCLUDE'), $php_conf['allow_url_include']['local_value'] ? '<span class="font_red">' . $lang->def('_ON') . '</span>' : $lang->def('_OFF'));
     }
     if (Get::cfg('uploadType') == 'ftp') {
         if (function_exists("ftp_connect")) {
             require_once _base_ . '/lib/lib.upload.php';
             $re_con = sl_open_fileoperations();
             echo config_line($lang->def('_UPLOADFTP'), $re_con ? $lang->def('_FTPOK') : '<span class="font_red">' . $lang->def('_FTPERR') . '</span>');
             if ($re_con) {
                 sl_close_fileoperations();
             }
         } else {
             echo config_line($lang->def('_UPLOADFTP'), '<span class="font_red">' . $lang->def('_FTPERR') . '</span>');
         }
     }
     echo '<div class="nofloat"></div><br />';
     return $html;
 }
示例#2
0
 function deleteAttach($attach)
 {
     require_once _base_ . '/lib/lib.upload.php';
     $path = _PATH_MESSAGE;
     sl_open_fileoperations();
     $re = sl_unlink($path . $attach);
     sl_close_fileoperations();
     return $re;
 }
示例#3
0
 function saveAttachment($attach)
 {
     require_once _base_ . '/lib/lib.upload.php';
     $path = _PATH_MESSAGE;
     $file = '';
     sl_open_fileoperations();
     if (isset($attach['tmp_name']['attach']) && $attach['tmp_name']['attach'] != '') {
         $file = getLogUserId() . '_' . mt_rand(0, 100) . '_' . time() . '_' . $attach['name']['attach'];
         if (!sl_upload($attach['tmp_name']['attach'], $path . $file)) {
             $error = 1;
             $file = '';
         }
     }
     sl_close_fileoperations();
     if (!$error) {
         return $file;
     }
     return false;
 }
 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));
     }
 }
示例#5
0
 function save_file($file)
 {
     require_once _base_ . '/lib/lib.upload.php';
     $path = '/appLms/htmlpages/';
     if ($file['name'] != '') {
         $savefile = $_SESSION['idCourse'] . '_' . rand(0, 100) . '_' . time() . '_' . $file['name'];
         if (!file_exists($GLOBALS['where_files_relative'] . $path . $savefile)) {
             sl_open_fileoperations();
             if (!sl_upload($file['tmp_name'], $path . $savefile)) {
                 $savefile = '';
             }
             sl_close_fileoperations();
             return $savefile;
         }
     }
     return '';
 }
示例#6
0
 public function delLabel($id_common_label)
 {
     if (!$this->toggleLabelAssociation($id_common_label)) {
         return false;
     }
     $file_name = $this->getLabelFile($id_common_label);
     $path = '/appLms/label/';
     require_once _base_ . '/lib/lib.upload.php';
     if ($file_name !== '' && sl_file_exists($path . $file_name)) {
         sl_open_fileoperations();
         sl_unlink($path . $file_name);
         sl_close_fileoperations();
     }
     $query = "DELETE FROM %lms_label" . " WHERE id_common_label = " . (int) $id_common_label;
     return sql_query($query);
 }
 public function mod()
 {
     if (!$this->permissions['mod']) {
         $this->render('invalid', array('message' => $this->_getMessage('no permission'), 'back_url' => 'index.php?r=alms/label/show'));
         return;
     }
     $id_common_label = Get::req('id_common_label', DOTY_INT, 0);
     if (isset($_POST['undo'])) {
         Util::jump_to('index.php?r=alms/label/show');
     }
     $all_languages = Docebo::langManager()->getAllLangCode();
     $res = true;
     if (isset($_POST['update'])) {
         require_once _base_ . '/lib/lib.upload.php';
         $path = '/appLms/label/';
         if (isset($_POST['del_label_image'])) {
             $file_name = $this->model->getLabelFile($id_common_label);
             if ($file_name !== '' && sl_file_exists($path . $file_name)) {
                 sl_open_fileoperations();
                 sl_unlink($path . $file_name);
                 sl_close_fileoperations();
             }
             $file_name = '';
         } else {
             $file_name = $this->model->getLabelFile($id_common_label);
         }
         if ($_FILES['label_image']['error'] == 0) {
             $extension = end(explode('.', $_FILES['label_image']['name']));
             $file_name = 'label_image_' . $id_common_label . '.' . $extension;
             sl_open_fileoperations();
             $file_name_del = $this->model->getLabelFile($id_common_label);
             if ($file_name_del !== '' && sl_file_exists($path . $file_name_del)) {
                 sl_unlink($path . $file_name_del);
             }
             sl_upload($_FILES['label_image']['tmp_name'], $path . $file_name);
             sl_close_fileoperations();
         }
         foreach ($all_languages as $lang_code) {
             $title = Get::req($lang_code . '_title', DOTY_MIXED, '');
             $description = Get::req($lang_code . '_description', DOTY_MIXED, '');
             $tmp_res = $this->model->updateLabel($id_common_label, $lang_code, $title, $description, $file_name);
             if (!$tmp_res) {
                 $res = false;
             }
         }
         if ($res) {
             Util::jump_to('index.php?r=alms/label/show&res=_ok_mod');
         }
         Util::jump_to('index.php?r=alms/label/show&err=_err_mod');
     }
     $label_info = $this->model->getLabelInfo($id_common_label);
     $params = array('model' => $this->model, 'all_languages' => $all_languages, 'label_info' => $label_info, 'id_common_label' => $id_common_label);
     $this->render('mod', $params);
 }
示例#8
0
 function send_certificate($id_certificate, $id_user, $id_course, $array_substituton = false, $download = true, $from_multi = false)
 {
     $id_meta = Get::req('idmeta', DOTY_INT, 0);
     if (!isset($_GET['idmeta'])) {
         $query_certificate = "\r\n\t\t\tSELECT cert_file\r\n\t\t\tFROM " . $GLOBALS['prefix_lms'] . "_certificate_assign\r\n\t\t\tWHERE id_certificate = '" . $id_certificate . "'\r\n\t\t\t\t AND id_course = '" . $id_course . "'\r\n\t\t\t\t AND id_user = '******' ";
     } else {
         $query_certificate = "\r\n\t\t\tSELECT cert_file\r\n\t\t\tFROM " . $GLOBALS['prefix_lms'] . "_certificate_meta_assign\r\n\t\t\tWHERE idUser = '******'\r\n\t\t\tAND idMetaCertificate = '" . $id_meta . "'";
     }
     $re = sql_query($query_certificate);
     echo mysql_error();
     if (mysql_num_rows($re) > 0) {
         if (!$download) {
             return;
         }
         require_once _base_ . '/lib/lib.download.php';
         list($cert_file) = sql_fetch_row($re);
         sendFile(CERTIFICATE_PATH, $cert_file);
         return;
     }
     $query_certificate = "\r\n\t\tSELECT name, cert_structure, base_language, orientation, bgimage\r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_certificate\r\n\t\tWHERE id_certificate = '" . $id_certificate . "'";
     list($name, $cert_structure, $base_language, $orientation, $bgimage) = sql_fetch_row(sql_query($query_certificate));
     require_once _base_ . '/lib/lib.upload.php';
     if ($array_substituton !== false) {
         $cert_structure = str_replace(array_keys($array_substituton), $array_substituton, $cert_structure);
     }
     $cert_structure = fillSiteBaseUrlTag($cert_structure);
     $cert_file = $id_course . '_' . $id_certificate . '_' . $id_user . '_' . time() . '_' . $name . '.pdf';
     sl_open_fileoperations();
     if (!($fp = sl_fopen(CERTIFICATE_PATH . $cert_file, 'w'))) {
         sl_close_fileoperations();
         return false;
     }
     if (!fwrite($fp, $this->getPdf($cert_structure, $name, $bgimage, $orientation, false, false, true))) {
         sl_close_fileoperations();
         return false;
     }
     fclose($fp);
     sl_close_fileoperations();
     //save the generated file in database
     if (!isset($_GET['idmeta'])) {
         $query = "INSERT INTO " . $GLOBALS['prefix_lms'] . "_certificate_assign " . " ( id_certificate, id_course, id_user, on_date, cert_file ) " . " VALUES " . " ( '" . $id_certificate . "', '" . $id_course . "', '" . $id_user . "', '" . date("Y-m-d H:i:s") . "', '" . addslashes($cert_file) . "' ) ";
     } else {
         $query = "INSERT INTO " . $GLOBALS['prefix_lms'] . "_certificate_meta_assign " . " ( idUser, idMetaCertificate, idCertificate, on_date, cert_file ) " . " VALUES " . " ('" . $id_user . "', '" . $id_meta . "', '" . $id_certificate . "', '" . date("Y-m-d H:i:s") . "', '" . addslashes($cert_file) . "' ) ";
     }
     if (!sql_query($query)) {
         return false;
     }
     if ($from_multi) {
         return;
     }
     $this->getPdf($cert_structure, $name, $bgimage, $orientation, $download, false);
 }
示例#9
0
 /**
  * save a new avatar for the user
  */
 function saveAvatarData($id_user, $file_descriptor, $max_width, $max_height)
 {
     if (!$this->deleteAvatarData($id_user)) {
         return false;
     }
     if (!isset($file_descriptor['error'])) {
         return false;
     }
     if ($file_descriptor['error'] != UPLOAD_ERR_OK) {
         return false;
     }
     if ($file_descriptor['name'] == '') {
         return false;
     }
     require_once _base_ . '/lib/lib.upload.php';
     require_once _base_ . '/lib/lib.multimedia.php';
     $savefile = $id_user . 'a_' . mt_rand(0, 100) . '_' . time() . '_' . $file_descriptor['name'];
     if (file_exists($GLOBALS['where_files_relative'] . $this->getPAPath() . $savefile)) {
         return false;
     }
     sl_open_fileoperations();
     if (createImageFromTmp($file_descriptor['tmp_name'], $this->getPAPath() . $savefile, $file_descriptor['name'], $max_width, $max_height, true) != 0) {
         sl_close_fileoperations();
         return false;
     }
     sl_close_fileoperations();
     if (!$this->acl_man->updateUser($id_user, false, false, false, false, false, $savefile, false)) {
         sl_unlink(substr($this->getPAPath(), 1) . $savefile);
         return false;
     }
     return true;
 }
示例#10
0
function insitem()
{
    //checkPerm( 'view', FALSE, 'storage' );
    require_once _base_ . '/lib/lib.upload.php';
    require_once _base_ . '/addons/pclzip/pclzip.lib.php';
    require_once dirname(__FILE__) . '/RendererDb.php';
    require_once dirname(__FILE__) . '/CPManager.php';
    $back_url = urldecode($_POST['back_url']);
    // there is a file?
    if ($_FILES['attach']['name'] == '') {
        $_SESSION['last_error'] = _FILEUNSPECIFIED;
        Util::jump_to('' . $back_url . '&create_result=0');
    }
    $path = str_replace('\\', '/', '/appLms/' . Get::sett('pathscorm'));
    $savefile = getLogUserId() . '_' . rand(0, 100) . '_' . time() . '_' . $_FILES['attach']['name'];
    if (!file_exists($GLOBALS['where_files_relative'] . $path . $savefile)) {
        sl_open_fileoperations();
        if (!sl_upload($_FILES['attach']['tmp_name'], $path . $savefile)) {
            //if( !move_uploaded_file($_FILES['attach']['tmp_name'], $GLOBALS['where_files_relative'].$path.$savefile ) ) {
            sl_close_fileoperations();
            $_SESSION['last_error'] = _ERROR_UPLOAD;
            Util::jump_to('' . $back_url . '&create_result=0');
        }
    } else {
        sl_close_fileoperations();
        $_SESSION['last_error'] = _ERROR_UPLOAD;
        Util::jump_to('' . $back_url . '&create_result=0');
    }
    // compute filepath
    $filepath = $path . $savefile . STRPOSTCONTENT;
    // extract zip file
    $zip = new PclZip($path . $savefile);
    // check disk quota --------------------------------------------------
    if (isset($_SESSION['idCourse']) && defined("LMS")) {
        $zip_content = $zip->listContent();
        $zip_extracted_size = 0;
        while (list(, $file_info) = each($zip_content)) {
            $zip_extracted_size += $file_info['size'];
        }
        $quota = $GLOBALS['course_descriptor']->getQuotaLimit();
        $used = $GLOBALS['course_descriptor']->getUsedSpace();
        if (Util::exceed_quota(false, $quota, $used, $zip_extracted_size)) {
            sl_unlink($path . $savefile);
            $_SESSION['last_error'] = Lang::t('_QUOTA_EXCEDED');
            Util::jump_to('' . $back_url . '&create_result=0');
        }
        $GLOBALS['course_descriptor']->addFileToUsedSpace(false, $zip_extracted_size);
    }
    // extract zip ------------------------------------------------------
    $zip->extract(PCLZIP_OPT_PATH, $filepath);
    if ($zip->errorCode() != PCLZIP_ERR_NO_ERROR && $zip->errorCode() != 1) {
        sl_unlink($path . $savefile);
        $_SESSION['last_error'] = _ERROR_UPLOAD;
        sl_close_fileoperations();
        Util::jump_to('' . $back_url . '&create_result=0');
    }
    /* remove zip file */
    sl_unlink($path . $savefile);
    sl_close_fileoperations();
    $cpm = new CPManager();
    // try to open content package
    if (!$cpm->Open($GLOBALS['where_files_relative'] . $filepath)) {
        $_SESSION['last_error'] = 'Error: ' . $cpm->errText . ' [' . $cpm->errCode . ']';
        Util::jump_to('' . $back_url . '&create_result=0');
    }
    // and parse the manifest
    if (!$cpm->ParseManifest()) {
        $_SESSION['last_error'] = 'Error: ' . $cpm->errText . ' [' . $cpm->errCode . ']';
        Util::jump_to('' . $back_url . '&create_result=0');
    }
    // create entry in content package table
    $query = "INSERT INTO " . $GLOBALS['prefix_lms'] . "_scorm_package" . " (idpackage,idProg,path,defaultOrg,idUser,scormVersion) VALUES" . " ('" . addslashes($cpm->identifier) . "','0','" . $savefile . STRPOSTCONTENT . "','" . addslashes($cpm->defaultOrg) . "','" . (int) getLogUserId() . "','" . $cpm->scorm_version . "')";
    if (!($result = sql_query($query))) {
        $_SESSION['last_error'] = _OPERATION_FAILURE;
        Util::jump_to('' . $back_url . '&create_result=0');
    }
    $idscorm_package = mysql_insert_id();
    // create the n entries in resources table
    for ($i = 0; $i < $cpm->GetResourceNumber(); $i++) {
        $info = $cpm->GetResourceInfo($cpm->GetResourceIdentifier($i));
        $query = "INSERT INTO " . $GLOBALS['prefix_lms'] . "_scorm_resources (idsco,idscorm_package,scormtype,href)" . " VALUES ('" . addslashes($info['identifier']) . "','" . (int) $idscorm_package . "','" . $info['scormtype'] . "','" . addslashes($info['href']) . "')";
        $result = sql_query($query);
        if (!$result) {
            $_SESSION['last_error'] = _OPERATION_FAILURE;
            Util::jump_to('' . $back_url . '&create_result=0');
        } else {
            if (mysql_affected_rows() == 0) {
                $_SESSION['last_error'] = _OPERATION_FAILURE;
                Util::jump_to('' . $back_url . '&create_result=0');
            }
        }
    }
    $rdb = new RendererDb($GLOBALS['dbConn'], $GLOBALS['prefix_lms'], $idscorm_package);
    $orgElems = $cpm->orgElems;
    // save all organizations
    for ($iOrg = 0; $iOrg < $orgElems->getLength(); $iOrg++) {
        $org = $orgElems->item($iOrg);
        $cpm->RenderOrganization($org->getAttribute('identifier'), $rdb);
    }
    if ($_POST['lesson_resources'] == 'import' || $cpm->defaultOrg == '-resource-') {
        // save flat organization with resources
        $cpm->RenderOrganization('-resource-', $rdb);
    }
    $so = new Scorm_Organization($cpm->defaultOrg, $idscorm_package, $GLOBALS['dbConn']);
    if ($so->err_code > 0) {
        $_SESSION['last_error'] = 'Error: ' . $so->getErrorText() . ' [' . $so->getErrorCode() . ']';
        Util::jump_to('' . $back_url . '&create_result=0');
    } else {
        //Util::jump_to( ''.$back_url.'&id_lo='.$so->idscorm_organization.'&create_result=1' );
        Util::jump_to('' . $back_url . '&id_lo=' . $idscorm_package . '&create_result=2');
    }
}
示例#11
0
 function importToGroup_step2()
 {
     require_once _base_ . '/lib/lib.upload.php';
     // ----------- file upload -----------------------------------------
     if ($_FILES['file_import']['name'] == '') {
         $_SESSION['last_error'] = Lang::t('_FILEUNSPECIFIED');
         Util::jump_to('index.php?modname=directory&amp;op=listgroup&import_result=-1');
     } else {
         $path = '/appCore/';
         $savefile = mt_rand(0, 100) . '_' . time() . '_' . $_FILES['file_import']['name'];
         if (!file_exists($GLOBALS['where_files_relative'] . $path . $savefile)) {
             sl_open_fileoperations();
             if (!sl_upload($_FILES['file_import']['tmp_name'], $path . $savefile)) {
                 sl_close_fileoperations();
                 $_SESSION['last_error'] = Lang::t('_ERROR_UPLOAD');
                 Util::jump_to('index.php?modname=directory&amp;op=listgroup&import_result=-1');
             }
             sl_close_fileoperations();
         } else {
             $_SESSION['last_error'] = Lang::t('_ERROR_UPLOAD');
             Util::jump_to('index.php?modname=directory&amp;op=listgroup&import_result=-1');
         }
     }
     require_once _base_ . '/lib/lib.form.php';
     $form = new Form();
     $tree = getTitleArea($this->lang->def('_ORG_CHART_IMPORT_USERS', 'organization_chart'), 'directory_group') . '<div class="std_block">' . $form->openForm('directory_importgroupuser', 'index.php?modname=directory&amp;op=import_groupuser_3', false, false, 'multipart/form-data');
     $tree .= $form->openElementSpace();
     require_once $GLOBALS['where_framework'] . '/modules/org_chart/import.org_chart.php';
     $separator = importVar('import_separator', false, ',');
     $first_row_header = isset($_POST['import_first_row_header']) ? $_POST['import_first_row_header'] == 'true' : FALSE;
     $import_charset = importVar('import_charset', false, 'UTF-8');
     if (trim($import_charset) === '') {
         $import_charset = 'UTF-8';
     }
     $src = new DeceboImport_SourceCSV(array('filename' => $GLOBALS['where_files_relative'] . $path . $savefile, 'separator' => $separator, 'first_row_header' => $first_row_header, 'import_charset' => $import_charset));
     $dst = new ImportGroupUser(array('dbconn' => $GLOBALS['dbConn']));
     $src->connect();
     $dst->connect();
     $importer = new DoceboImport();
     $importer->setSource($src);
     $importer->setDestination($dst);
     $tree .= $importer->getUIMap();
     $tree .= $form->getHidden('filename', 'filename', $GLOBALS['where_files_relative'] . $path . $savefile);
     $tree .= $form->getHidden('import_first_row_header', 'import_first_row_header', $first_row_header ? 'true' : 'false');
     $tree .= $form->getHidden('import_separator', 'import_separator', $separator);
     $tree .= $form->getHidden('import_charset', 'import_charset', $import_charset);
     $tree .= $form->closeElementSpace() . $form->openButtonSpace() . $form->getButton('next_importusers_3', 'next_importusers_3', $this->lang->def('_NEXT')) . $form->getButton('import_groupcancel', 'import_groupcancel', $this->lang->def('_UNDO')) . $form->closeButtonSpace();
     $tree .= Form::closeForm() . '</div>';
     $GLOBALS['page']->add($tree, 'content');
 }
示例#12
0
 function upfiles()
 {
     checkPerm('mod');
     $lang =& DoceboLanguage::createInstance('course');
     require_once _base_ . '/lib/lib.upload.php';
     if ($_POST['title'] == "") {
         $_POST['title'] = $lang->def('_NOTITLE');
     }
     $savefile = '';
     if ($_FILES['attach']['name'] != '') {
         list($old_file) = sql_fetch_row(sql_query("\r\n\t\tSELECT path \r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_course_file \r\n\t\tWHERE id_course='" . $_SESSION['idCourse'] . "' AND id_file='" . (int) $_POST['id_file'] . "'"));
         $GLOBALS['course_descriptor']->subFileToUsedSpace($GLOBALS['where_files_relative'] . _PATH_COURSE . $old_file);
         $quota = $GLOBALS['course_descriptor']->getQuotaLimit();
         $used = $GLOBALS['course_descriptor']->getUsedSpace();
         sl_unlink(_PATH_COURSE . $old_file);
         if (Util::exceed_quota($_FILES['attach']['tmp_name'], $quota, $used)) {
             $GLOBALS['page']->add(getErrorUi($lang->def('_QUOTA_EXCEDED')));
             return;
         }
         $savefile = $_SESSION['idCourse'] . '_' . mt_rand(0, 100) . '_' . time() . '_' . $_FILES['attach']['name'];
         if (!file_exists($GLOBALS['where_files_relative'] . _PATH_COURSE . $savefile)) {
             sl_open_fileoperations();
             if (!sl_upload($_FILES['attach']['tmp_name'], _PATH_COURSE . $savefile)) {
                 sl_close_fileoperations();
                 $GLOBALS['page']->add(getErrorUi($lang->def('_ERROR_UPLOAD')));
                 return;
             }
             sl_close_fileoperations();
         } else {
             $GLOBALS['page']->add(getErrorUi($lang->def('_ERROR_UPLOAD')));
             return;
         }
     }
     $insertQuery = "\r\n\tUPDATE " . $GLOBALS['prefix_lms'] . "_course_file \r\n\tSET id_course = '" . (int) $_SESSION["idCourse"] . "', \r\n\t\ttitle = '" . $_POST['title'] . "'";
     if ($savefile != '') {
         $insertQuery .= ", path = '" . $savefile . "'";
     }
     $insertQuery .= " WHERE id_file = '" . (int) $_POST['id_file'] . "'";
     if (!sql_query($insertQuery)) {
         $GLOBALS['page']->add(getErrorUi($lang->def('_OPERATION_FAILURE')));
         sl_unlink(_PATH_COURSE . $savefile);
         return;
     }
     $GLOBALS['course_descriptor']->addFileToUsedSpace($GLOBALS['where_files_relative'] . _PATH_COURSE . $savefile);
     Util::jump_to('index.php?modname=course&op=infocourse');
 }
 public function importusers()
 {
     $base_url = 'index.php?r=' . $this->link . '/show';
     //check permissions
     if (!$this->permissions['add_user']) {
         Util::jump_to($base_url);
     }
     $idOrg = Get::req('id', DOTY_INT, -1);
     if ($idOrg < 0) {
         return false;
     }
     $step = Get::req('step', DOTY_INT, 1);
     $params = array('id_org' => $idOrg, 'step' => $step);
     $undo = Get::req('import_groupcancel', DOTY_MIXED, false);
     if ($undo) {
         Util::jump_to($base_url);
     }
     switch ($step) {
         case 1:
             $params['orgchart_list'] = $this->model->getOrgChartDropdownList(Docebo::user()->getIdSt());
             break;
         case 2:
             require_once _base_ . '/lib/lib.upload.php';
             // ----------- file upload -----------------------------------------
             if ($_FILES['file_import']['name'] == '') {
                 //$_SESSION['last_error'] = Lang::t('_FILEUNSPECIFIED');
                 Util::jump_to($base_url . '&err=no_file');
             } else {
                 $path = '/appCore/';
                 $savefile = mt_rand(0, 100) . '_' . time() . '_' . $_FILES['file_import']['name'];
                 if (!file_exists(Get::rel_path('base') . '/files' . $path . $savefile)) {
                     sl_open_fileoperations();
                     if (!sl_upload($_FILES['file_import']['tmp_name'], $path . $savefile)) {
                         sl_close_fileoperations();
                         //$_SESSION['last_error'] = Lang::t('_ERROR_UPLOAD');
                         Util::jump_to($base_url . '&err=no_upload');
                     }
                     sl_close_fileoperations();
                 } else {
                     $_SESSION['last_error'] = Lang::t('_ERROR_UPLOAD');
                     Util::jump_to($base_url . '&err=no_upload');
                 }
             }
             require_once _adm_ . '/modules/org_chart/import.org_chart.php';
             $separator_info = Get::req('import_separator', DOTY_STRING, ',');
             $separator = false;
             switch ($separator_info) {
                 case "comma":
                     $separator = ",";
                     break;
                 case "dotcomma":
                     $separator = ";";
                     break;
                 case "manual":
                     $separator = Get::req('import_separator_manual', DOTY_STRING, "");
                     break;
             }
             $first_row_header = Get::req('import_first_row_header', DOTY_STRING, 'false') == 'true';
             $import_charset = Get::req('import_charset', DOTY_STRING, 'UTF-8');
             if (trim($import_charset) === '') {
                 $import_charset = 'UTF-8';
             }
             $pwd_force_change_policy = Get::req('pwd_force_change_policy', DOTY_STRING, 'do_nothing');
             $src = new DeceboImport_SourceCSV(array('filename' => $GLOBALS['where_files_relative'] . $path . $savefile, 'separator' => $separator, 'first_row_header' => $first_row_header, 'import_charset' => $import_charset));
             $dst = new ImportUser(array('dbconn' => $GLOBALS['dbConn'], 'tree' => $idOrg, 'pwd_force_change_policy' => $pwd_force_change_policy, 'send_alert' => 0, 'insert_update' => 0));
             $src->connect();
             $dst->connect();
             $importer = new DoceboImport();
             $importer->setSource($src);
             $importer->setDestination($dst);
             $params['UIMap'] = $importer->getUIMap();
             $params['filename'] = $GLOBALS['where_files_relative'] . $path . $savefile;
             $params['first_row_header'] = $first_row_header;
             $params['separator'] = $separator;
             $params['import_charset'] = $import_charset;
             $params['pwd_force_change_policy'] = $pwd_force_change_policy;
             break;
         case 3:
             $filename = Get::req('filename', DOTY_STRING, "");
             if ($filename == "") {
                 return false;
             }
             $separator = Get::req('import_separator', DOTY_STRING, ',');
             $first_row_header = Get::req('import_first_row_header', DOTY_STRING, 'false') == 'true';
             $import_charset = Get::req('import_charset', DOTY_STRING, 'UTF-8');
             if (trim($import_charset) === '') {
                 $import_charset = 'UTF-8';
             }
             require_once _adm_ . '/modules/org_chart/import.org_chart.php';
             $src = new DeceboImport_SourceCSV(array('filename' => $filename, 'separator' => $separator, 'first_row_header' => $first_row_header, 'import_charset' => $import_charset));
             $dst = new ImportUser(array('dbconn' => $GLOBALS['dbConn'], 'tree' => $idOrg, 'pwd_force_change_policy' => Get::req('pwd_force_change_policy', DOTY_STRING, 'do_nothing'), 'send_alert' => Get::pReq('send_alert', DOTY_INT, 0), 'insert_update' => Get::pReq('insert_update', DOTY_INT, 0)));
             $src->connect();
             $dst->connect();
             $importer = new DoceboImport();
             $importer->setSource($src);
             $importer->setDestination($dst);
             $importer->parseMap();
             $results = $importer->doImport();
             $users = $dst->getNewImportedIdst();
             //apply enroll rules
             if (!empty($users)) {
                 $enrollrules = new EnrollrulesAlms();
                 $enrollrules->newRules('_NEW_IMPORTED_USER', $users, 'all', $idOrg);
             }
             $src->close();
             $dst->close();
             $buffer = "";
             if (count($results) > 1) {
                 require_once _base_ . '/lib/lib.table.php';
                 $buffer .= Lang::t('_ERRORS', 'admin_directory') . ': <b>' . (count($results) - 1) . '</b><br/>';
                 $table = new Table(Get::sett('visuItem', 25), Lang::t('_ERRORS', 'admin_directory'), Lang::t('_ERRORS', 'admin_directory'));
                 $table->setColsStyle(array('', ''));
                 $table->addHead(array(Lang::t('_ROW', 'admin_directory'), Lang::t('_DESCRIPTION', 'admin_directory')));
                 foreach ($results as $key => $err_val) {
                     if ($key != 0) {
                         $table->addBody(array($key, $err_val));
                     }
                 }
                 $buffer .= $table->getTable();
             }
             if ($buffer === '') {
                 $buffer = '<br/><br/>';
             }
             $params['backUi'] = getBackUi($base_url, Lang::t('_BACK', 'standard'));
             $params['resultUi'] = Lang::t('_IMPORT', 'standard') . ': <b>' . ($first_row_header ? $results[0] - 1 : $results[0]) . '</b><br />';
             $params['results'] = $results;
             $params['table'] = $buffer;
             // remove uploaded file:
             require_once _base_ . '/lib/lib.upload.php';
             sl_open_fileoperations();
             unlink($filename);
             sl_close_fileoperations();
             break;
     }
     $this->render('importusers', $params);
 }
示例#14
0
 function saveCurriculum($id_portfolio, $id_user, $file_descriptor)
 {
     $curriculum_file = '';
     if (!isset($file_descriptor['error'])) {
         return false;
     }
     if ($file_descriptor['error'] != UPLOAD_ERR_OK) {
         return false;
     }
     if ($file_descriptor['name'] == '') {
         return false;
     }
     require_once _base_ . '/lib/lib.upload.php';
     $curriculum_file = $id_user . '_' . mt_rand(0, 100) . '_' . time() . '_' . $file_descriptor['name'];
     if (!file_exists($GLOBALS['where_files_relative'] . $this->getCurriculumPath() . $curriculum_file)) {
         sl_open_fileoperations();
         $upload = sl_upload($file_descriptor['tmp_name'], $this->getCurriculumPath() . $curriculum_file);
         sl_close_fileoperations();
         if (!$upload) {
             return false;
         }
     }
     $sel_query = "\r\n\t\tSELECT curriculum_file \r\n\t\tFROM " . $this->getTableCurriculum() . " \r\n\t\tWHERE id_portfolio = '" . $id_portfolio . "' \r\n\t\t\tAND id_user = '******' ";
     if (!($re_curriculum = $this->_query($sel_query))) {
         die('table problem ' . mysql_error());
         return false;
     }
     if (!mysql_num_rows($re_curriculum)) {
         $query = "\r\n\t\t\tINSERT INTO " . $this->getTableCurriculum() . " \r\n\t\t\t( id_portfolio, id_user, curriculum_file, update_date ) VALUES \r\n\t\t\t(\t'" . $id_portfolio . "', \r\n\t\t\t\t'" . $id_user . "', \r\n\t\t\t\t'" . $curriculum_file . "',\r\n\t\t\t\t'" . date("Y-m-d H:i:s") . "' )";
     } else {
         list($old_curriculum_file) = sql_fetch_row($re_curriculum);
         sl_unlink($old_curriculum_file);
         $query = "\r\n\t\t\tUPDATE " . $this->getTableCurriculum() . "\r\n\t\t\tSET curriculum_file = '" . $curriculum_file . "',\r\n\t\t\t\tupdate_date  = '" . date("Y-m-d H:i:s") . "'\r\n\t\t\tWHERE   id_portfolio = '" . $id_portfolio . "' \r\n\t\t\t\tAND id_user = '******'";
     }
     if (!$this->_query($query)) {
         die('table problem 2');
         return false;
     }
     return true;
 }
示例#15
0
function edit_files($mode = "edit")
{
    require_once _base_ . '/lib/lib.upload.php';
    require_once _base_ . '/lib/lib.form.php';
    $form = new Form();
    $out =& $GLOBALS['page'];
    $out->setWorkingZone('content');
    $lang =& DoceboLanguage::createInstance('project', "lms");
    // Controllo che l'utente non cerchi di entrare in progetti a cui non e' iscritto.
    $id = $_GET["id"];
    $itemid = importVar("itemid");
    $myprj = user_projects(Docebo::user()->getIdSt());
    $view_perm = checkPerm('view', true);
    if ($view_perm && in_array($id, $myprj) && (is_owner(Docebo::user()->getIdSt(), $id) || is_admin(Docebo::user()->getIdSt(), $id))) {
        //area title
        $out->add(getTitleArea($lang->def("_PROJECT_MANAGER"), "project"));
        $out->add('<div class="std_block">');
        if ($mode == "edit") {
            $goto = "prjedititem";
        }
        if ($mode == "new") {
            $goto = "prjadditem";
        }
        if (isset($_POST["applychanges"])) {
            $ftitle = $_POST["ftitle"];
            $fver = $_POST["fver"];
            $fdesc = $_POST["fdesc"];
            if ($mode == "new") {
                $ok = 1;
                //save file
                sl_open_fileoperations();
                if (!isset($_FILES['attach']) || $_FILES['attach']['name'] == '') {
                    $savefile = '';
                } else {
                    $savefile = $_SESSION['idCourse'] . '_' . mt_rand(0, 100) . '_' . time() . '_' . $_FILES['attach']['name'];
                    if (!file_exists(_FPATH_INTERNAL . $savefile)) {
                        if (!sl_upload($_FILES['attach']['tmp_name'], _FPATH_INTERNAL . $savefile)) {
                            $savefile = '';
                            $ok = 0;
                        }
                    } else {
                        $savefile = '';
                        $ok = 0;
                    }
                }
                sl_close_fileoperations();
                if ($ok && $savefile != "") {
                    $query = sql_query("INSERT INTO " . $GLOBALS["prefix_lms"] . "_prj_files (pid,fname,ftitle,fver,fdesc) VALUES('{$id}','" . (get_magic_quotes_gpc() ? $savefile : mysql_escape_string($savefile)) . "','{$ftitle}','{$fver}','{$fdesc}');");
                }
            }
            if ($mode == "edit") {
                $query = sql_query("UPDATE " . $GLOBALS["prefix_lms"] . "_prj_files SET ftitle='{$ftitle}',fver='{$fver}',fdesc='{$fdesc}' WHERE id='{$itemid}' LIMIT 1;");
            }
            Util::jump_to(" index.php?modname=project&op=showprj&id={$id}");
        }
        $url = "index.php?modname=project&amp;op=showprj&amp;id=" . $id;
        $out->add(getBackUi($url, $lang->def('_BACK')));
        if ($mode == "edit") {
            $query = sql_query("SELECT * FROM " . $GLOBALS["prefix_lms"] . "_prj_files WHERE pid='{$id}' AND id='{$itemid}';");
            if ($query && mysql_num_rows($query) > 0) {
                $row = mysql_fetch_array($query);
            }
            $label = $lang->def("_SAVE");
        } else {
            if ($mode == "new") {
                $row = array();
                $label = $lang->def("_SAVE");
            }
        }
        $ftitle = isset($row["ftitle"]) ? $row["ftitle"] : '';
        $fver = isset($row["fver"]) ? $row["fver"] : '';
        $fdesc = isset($row["fdesc"]) ? $row["fdesc"] : '';
        $url = "index.php?modname=project&amp;op={$goto}&amp;type=file&amp;id={$id}&amp;itemid=" . $itemid;
        $out->add($form->openForm("form_name", $url, "", "", "multipart/form-data"));
        $out->add($form->openElementSpace());
        if ($mode == "new") {
            $out->add($form->getFilefield($lang->def("_FILE"), "attach", "attach"));
        }
        $out->add($form->getTextfield($lang->def("_TITLE"), "ftitle", "ftitle", 255, $ftitle));
        $out->add($form->getTextfield($lang->def("_VERSION"), "fver", "fver", 255, $fver));
        $out->add($form->getSimpleTextarea($lang->def("_DESCRIPTION"), "fdesc", "fdesc", $fdesc));
        $out->add($form->getHidden("applychanges", "applychanges", 1));
        $out->add($form->closeElementSpace());
        $out->add($form->openButtonSpace());
        $out->add($form->getButton('save', 'save', $label));
        $out->add($form->getButton('undo', 'undo', $lang->def('_UNDO')));
        $out->add($form->closeButtonSpace());
        $out->add($form->closeForm());
        $out->add('<br /></div>');
        return 0;
        $out->add("<form method=\"post\" action=\"index.php?modname=project&amp;op={$goto}&amp;type=file&amp;id={$id}&amp;itemid={$itemid}\" enctype=\"multipart/form-data\">\n" . '<input type="hidden" id="authentic_request_prj" name="authentic_request" value="' . Util::getSignature() . '" />');
        $query = sql_query("SELECT * FROM " . $GLOBALS["prefix_lms"] . "_prj_files WHERE pid='{$id}' AND id='{$itemid}';");
        if ($query && mysql_num_rows($query) > 0 || $mode == "new") {
            if ($mode == "edit") {
                $row = mysql_fetch_array($query);
            }
            if ($mode == "new") {
                $row = array();
            }
            $out->add("<table><tr>\n");
            if ($mode != "edit") {
                $out->add($lang->def("_FILE") . ":<br /><input type=\"file\" id=\"attach\" name=\"attach\" size=\"50\" /><br /><br />\n");
            }
            $out->add($lang->def("_TITLE") . ": <input type=\"text\" size=\"40\" id=\"ttitle\" name=\"ftitle\" value=\"" . (isset($row["ftitle"]) ? $row["ftitle"] : '') . "\" /></td>\n");
            $out->add("</tr><tr><td>" . $lang->def("_VERSION") . "\n ");
            $out->add("<input type=\"text\" size=\"35\" id=\"fver\" name=\"fver\" value=\"" . (isset($row["fver"]) ? $row["fver"] : '') . "\" /></td>\n");
            $out->add("</tr><tr><td colspan=\"2\"><textarea rows=\"6\" cols=\"30\" id=\"fdesc\" name=\"fdesc\">\n");
            $out->add(isset($row["fdesc"]) ? $row["fdesc"] : '');
            $out->add("</textarea>\n");
            $out->add("</td></tr></table><br />\n");
        }
        if ($mode == "edit") {
            $label = $lang->def("_SAVE");
        }
        if ($mode == "new") {
            $label = $lang->def("_SAVE");
        }
        $out->add("<input type=\"hidden\" id=\"applychanges\" name=\"applychanges\" value=\"1\" />\n");
        $out->add("<input class=\"button\" type=\"submit\" value=\"" . $label . "\" />\n");
        $out->add("</form><br />\n");
        //$out->add("<div align=\"center\"><b>[ <a href=\"index.php?modname=project&amp;op=showprj&amp;id=$id\">".$lang->def("_BACK")."</a> ]</b></div>\n");
        $url = "index.php?modname=project&amp;op=showprj&amp;id=" . $id;
        $out->add(getBackUi($url, $lang->def('_BACK')));
        $out->add('<br /></div>');
    } else {
        $out->add("You can't access");
    }
}
示例#16
0
function save_file($file)
{
    require_once _base_ . '/lib/lib.upload.php';
    $path = '/appLms/' . Get::sett('pathforum');
    if ($file['name'] != '') {
        $savefile = PUBLIC_FORUM_COURSE_ID . '_' . rand(0, 100) . '_' . time() . '_' . $file['name'];
        if (!file_exists($GLOBALS['where_files_relative'] . $path . $savefile)) {
            sl_open_fileoperations();
            if (!sl_upload($file['tmp_name'], $path . $savefile)) {
                $savefile = '';
            }
            sl_close_fileoperations();
            return $savefile;
        }
    }
    return '';
}
示例#17
0
function importCode_step2()
{
    require_once _base_ . '/lib/lib.upload.php';
    require_once $GLOBALS['where_framework'] . '/lib/lib.import.php';
    require_once _base_ . '/lib/lib.table.php';
    if ($_FILES['file_import']['name'] == '') {
        Util::jump_to('index.php?modname=code&amp;op=list&result=err');
    } else {
        $path = '/appCore/';
        $savefile = mt_rand(0, 100) . '_' . time() . '_' . $_FILES['file_import']['name'];
        if (!file_exists($GLOBALS['where_files_relative'] . $path . $savefile)) {
            sl_open_fileoperations();
            if (!sl_upload($_FILES['file_import']['tmp_name'], $path . $savefile)) {
                sl_close_fileoperations();
                Util::jump_to('index.php?modname=code&amp;op=list&result=err');
            }
            sl_close_fileoperations();
        } else {
            Util::jump_to('index.php?modname=directory&amp;op=listgroup&import_result=-1');
        }
    }
    $lang =& DoceboLanguage::createInstance('code');
    $code_manager = new CodeManager();
    $id_code_group = Get::req('id_code_group', DOTY_INT, '0');
    cout(getTitleArea($lang->def('_CODE')) . '<div class="std_block">');
    $separator = Get::req('import_separator', DOTY_MIXED, ',');
    $first_row_header = isset($_POST['import_first_row_header']) ? $_POST['import_first_row_header'] == 'true' : FALSE;
    $import_charset = Get::req('import_charset', DOTY_MIXED, 'UTF-8');
    if (trim($import_charset) === '') {
        $import_charset = 'UTF-8';
    }
    $src = new DeceboImport_SourceCSV(array('filename' => $GLOBALS['where_files_relative'] . $path . $savefile, 'separator' => $separator, 'first_row_header' => $first_row_header, 'import_charset' => $import_charset));
    $src->connect();
    $code_added = array();
    $code_error = array();
    $code_present = array();
    if (is_array($row = $src->get_first_row()) && !empty($row)) {
        $code = addslashes($row[0]);
        $result = $code_manager->addCode($code, $id_code_group);
        if ($result === 'dup') {
            $code_present[] = $code;
        } elseif ($result) {
            $code_added[] = $code;
        } else {
            $code_error[] = $code;
        }
    }
    while (is_array($row = $src->get_next_row()) && !empty($row)) {
        $code = addslashes($row[0]);
        $result = $code_manager->addCode($code, $id_code_group);
        if ($result === 'dup') {
            $code_present[] = $code;
        } elseif ($result) {
            $code_added[] = $code;
        } else {
            $code_error[] = $code;
        }
    }
    $src->close();
    unset($row);
    sl_open_fileoperations();
    sl_unlink($path . $savefile);
    sl_close_fileoperations();
    cout(getBackUi('index.php?modname=code&amp;op=list', $lang->def('_BACK')) . '<br/>' . $lang->def('_CODE_ADDED') . ' : ' . count($code_added) . '<br/>' . $lang->def('_CODE_PRESENT') . ' : ' . count($code_present) . '<br/>' . $lang->def('_CODE_ERROR') . ' : ' . count($code_error) . '<br/>');
    if (count($code_present)) {
        $tb = new Table(false, $lang->def('_CODE_PRESENT'), $lang->def('_CODE_PRESENT'));
        $type_h = array('align_center');
        $cont_h = array($lang->def('_CODE'));
        $tb->setColsStyle($type_h);
        $tb->addHead($cont_h);
        foreach ($code_present as $code) {
            $cont = array();
            $cont[] = stripslashes($code);
            $tb->addBody($cont);
        }
        cout($tb->getTable());
    }
    if (count($code_error)) {
        $tb = new Table(false, $lang->def('_CODE_ERROR'), $lang->def('_CODE_ERROR'));
        $type_h = array('align_center');
        $cont_h = array($lang->def('_CODE'));
        $tb->setColsStyle($type_h);
        $tb->addHead($cont_h);
        foreach ($code_error as $code) {
            $cont = array();
            $cont[] = stripslashes($code);
            $tb->addBody($cont);
        }
        cout($tb->getTable());
    }
    cout(getBackUi('index.php?modname=code&amp;op=list', $lang->def('_BACK')) . '</div>');
}
示例#18
0
 public function delCourse($id_course)
 {
     if ((int) $id_course <= 0) {
         return false;
     }
     require_once _lms_ . '/lib/lib.course.php';
     require_once _base_ . '/lib/lib.upload.php';
     $course_man = new Man_Course();
     //remove course subscribed------------------------------------------
     $levels =& $course_man->getCourseIdstGroupLevel($id_course);
     foreach ($levels as $lv => $idst) {
         Docebo::aclm()->deleteGroup($idst);
     }
     $alluser = getIDGroupAlluser($id_course);
     Docebo::aclm()->deleteGroup($alluser);
     $course_man->removeCourseRole($id_course);
     $course_man->removeCourseMenu($id_course);
     $query = "DELETE FROM %lms_courseuser WHERE idCourse = '" . (int) $id_course . "'";
     $qres = sql_query($query);
     if (!$qres) {
         return false;
     }
     //--- remove course data ---------------------------------------------------
     $query_course = "SELECT imgSponsor, img_course, img_material, img_othermaterial, course_demo, course_type, has_editions\n\t\t\tFROM %lms_course\n\t\t\tWHERE idCourse = '" . (int) $id_course . "'";
     $qres = sql_query($query_course);
     list($file_sponsor, $file_logo, $file_material, $file_othermaterial, $file_demo, $course_type, $course_edition) = sql_fetch_row($qres);
     require_once _base_ . '/lib/lib.upload.php';
     $path = '/appLms/' . Get::sett('pathcourse');
     if (substr($path, -1) != '/' && substr($path, -1) != '\\') {
         $path .= '/';
     }
     sl_open_fileoperations();
     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);
     }
     sl_close_fileoperations();
     //if the scs exist delete course rooms
     if ($GLOBALS['where_scs'] !== false) {
         require_once _scs_ . '/lib/lib.room.php';
         $re = deleteRoom(false, 'course', $id_course);
     }
     //--- delete classroom or editions -----------------------------------------
     if ($course_type == 'classroom') {
         require_once _lms_ . '/admin/model/ClassroomAlms.php';
         $classroom_model = new ClassroomAlms($id_course);
         $classroom = $classroom_model->classroom_man->getDateIdForCourse($id_course);
         foreach ($classroom as $id_date) {
             if (!$classroom_model->classroom_man->delDate($id_date)) {
                 return false;
             }
         }
     } elseif ($course_edition == 1) {
         require_once _lms_ . '/admin/model/EditionAlms.php';
         $edition_model = new EditionAlms($id_course);
         $editions = $edition_model->classroom_man->getEditionIdFromCourse($id_course);
         foreach ($editions as $id_edition) {
             if (!$edition_model->edition_man->delEdition($id_edition)) {
                 return false;
             }
         }
     }
     //--- end classrooms or editions -------------------------------------------
     //--- clear LOs ------------------------------------------------------------
     require_once _lms_ . '/lib/lib.module.php';
     require_once _lms_ . '/lib/lib.param.php';
     require_once _lms_ . '/class.module/track.object.php';
     $arr_lo_param = array();
     $arr_lo_track = array();
     $arr_org_access = array();
     $query = "SELECT * FROM %lms_organization WHERE idCourse = " . (int) $id_course;
     $ores = sql_query($query);
     while ($obj = sql_fetch_object($ores)) {
         $deleted = true;
         if ($obj->idResource != 0 && $obj->objectType != "") {
             $lo = createLO($obj->objectType);
             $deleted = $lo->del($obj->idResource);
             //delete learning object
         }
         if ($deleted) {
             $arr_lo_track[] = $obj->idOrg;
             $arr_org_access[] = $obj->idOrg;
             //collect org access ids
             $arr_lo_param[] = $obj->idParam;
             //collect idParams ids
         }
     }
     //delete all organizations references for the course
     $query = "DELETE FROM %lms_organization WHERE idCourse = " . (int) $id_course;
     $res = sql_query($query);
     //delete LOs trackings
     if (!empty($arr_lo_track)) {
         $track_object = new Track_Object(false, 'course_lo');
         $track_object->delIdTrackFromCommon($arr_lo_track);
     }
     //delete org accesses
     if (!empty($arr_org_access)) {
         $query = "DELETE FROM %lms_organization_access\n\t\t\t\tWHERE idOrgAccess IN (" . implode(",", $arr_org_access) . ")";
         $res = sql_query($query);
     }
     //delete lo params
     if (!empty($arr_lo_param)) {
         $query = "DELETE FROM %lms_lo_param\n\t\t\t\tWHERE idParam IN (" . implode(",", $arr_lo_param) . ")";
     }
     //--- end LOs --------------------------------------------------------------
     //--- clear coursepath references ------------------------------------------
     require_once _lms_ . '/lib/lib.coursepath.php';
     $cman = new CoursePath_Manager();
     $cman->deleteCourseFromCoursePaths($id_course);
     //--- end coursepath references --------------------------------------------
     //--- clear certificates assignments ---------------------------------------
     require_once _lms_ . '/lib/lib.certificate.php';
     $cman = new Certificate();
     $cman->deleteCourseCertificateAssignments($id_course);
     //--- end certificates assignments -----------------------------------------
     //--- clear labels ---------------------------------------------------------
     $lmodel = new LabelAlms();
     $lmodel->clearCourseLabel($id_course);
     //--- end labels -----------------------------------------------------------
     //--- clear advices --------------------------------------------------------
     require_once _lms_ . '/lib/lib.advice.php';
     $aman = new Man_Advice();
     $aman->deleteAllCourseAdvices($id_course);
     //--- end advices ----------------------------------------------------------
     //--- clear coursereports --------------------------------------------------
     require_once _lms_ . '/lib/lib.coursereport.php';
     $cman = new CourseReportManager();
     $cman->deleteAllReports($id_course);
     //--- end coursereports ----------------------------------------------------
     //--- clear competences ----------------------------------------------------
     $cmodel = new CompetencesAdm();
     $cmodel->deleteAllCourseCompetences($id_course);
     //--- end competences ------------------------------------------------------
     //--- finally delete course from courses table -----------------------------
     if (!sql_query("DELETE FROM %lms_course WHERE idCourse = '" . $id_course . "'")) {
         return false;
     }
     return true;
 }
示例#19
0
function delReleased()
{
    checkPerm('mod');
    require_once _base_ . '/lib/lib.form.php';
    require_once _base_ . '/lib/lib.upload.php';
    $id_certificate = importVar('id_certificate', true, 0);
    $id_meta = importVar('idmeta', true, 0);
    $id_user = importVar('iduser', true, 0);
    $lang =& DoceboLanguage::createInstance('certificate', 'lms');
    $acl_man =& Docebo::user()->getAclManager();
    if (Get::req('confirm', DOTY_INT, 0) == 1) {
        $query = "SELECT cert_file" . " FROM " . $GLOBALS['prefix_lms'] . "_certificate_meta_assign" . " WHERE idUser = '******'" . " AND idMetaCertificate = '" . $id_meta . "'";
        list($cert_file) = sql_fetch_row(sql_query($query));
        $path = '/appLms/certificate/';
        sl_open_fileoperations();
        $res = sl_unlink($path . $cert_file);
        sl_close_fileoperations();
        if (!$res) {
            Util::jump_to('index.php?modname=meta_certificate&op=create&id_certificate=' . $id_certificate . '&result=err_del_cert');
        }
        $query = "DELETE FROM " . $GLOBALS['prefix_lms'] . "_certificate_meta_assign" . " WHERE idUser = '******'" . " AND idMetaCertificate = '" . $id_meta . "'";
        if (!sql_query($query)) {
            Util::jump_to('index.php?modname=meta_certificate&op=create&id_certificate=' . $id_certificate . '&result=err_del_cert');
        } else {
            Util::jump_to('index.php?modname=meta_certificate&op=create&id_certificate=' . $id_certificate . '&result=ok');
        }
    } else {
        list($name, $descr) = sql_fetch_row(sql_query("\r\n\t\tSELECT name, description\r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_certificate\r\n\t\tWHERE id_certificate = '" . $id_certificate . "'"));
        $user_info = $acl_man->getUser($id_user, false);
        $user = $user_info[ACL_INFO_LASTNAME] . ' ' . $user_info[ACL_INFO_FIRSTNAME] . ' (' . $acl_man->relativeId($user_info[ACL_INFO_USERID]) . ')';
        $form = new Form();
        $page_title = array('index.php?modname=meta_certificate&amp;op=meta_certificate' => $lang->def('_TITLE_CERTIFICATE'), $lang->def('_DEL_RELEASED'));
        $GLOBALS['page']->add(getTitleArea($page_title, 'certificate') . '<div class="std_block">' . $form->openForm('del_certificate', 'index.php?modname=meta_certificate&amp;op=del_released') . $form->getHidden('id_certificate', 'id_certificate', $id_certificate) . $form->getHidden('idmeta', 'idmeta', $id_meta) . $form->getHidden('iduser', 'iduser', $id_user) . getDeleteUi($lang->def('_AREYOUSURE'), '<span>' . $lang->def('_NAME') . ' : </span>' . $name . '<br />' . '<span>' . $lang->def('_DESCRIPTION') . ' : </span>' . $descr . '<br />' . '<span>' . $lang->def('_USER') . ' : </span>' . $user, false, 'confirm', 'undo') . $form->closeForm() . '</div>', 'content');
    }
}
示例#20
0
 /**
  * store the value inserted by a user into the database, if a entry exists it will be overwrite
  *
  * @param	int		$id_user 		the user
  * @param	int		$no_overwrite 	if a entry exists do not overwrite it
  *
  * @return 	bool 	true if operation success false otherwise
  *
  * @access public
  */
 function store($id_user, $no_overwrite)
 {
     require_once _base_ . '/lib/lib.upload.php';
     $path = '/appCore/field/';
     $file = '';
     sl_open_fileoperations();
     if (isset($_FILES['field_' . $this->getFieldType()]['tmp_name'][$this->id_common]) && $_FILES['field_' . $this->getFieldType()]['tmp_name'][$this->id_common] != '') {
         $file = $id_user . '_' . $this->id_common . '_' . time() . '_' . $_FILES['field_' . $this->getFieldType()]['name'][$this->id_common];
         if (!sl_upload($_FILES['field_' . $this->getFieldType()]['tmp_name'][$this->id_common], $path . $file)) {
             $error = 1;
             $file = '';
         }
     }
     sl_close_fileoperations();
     if (empty($_FILES['field_' . $this->getFieldType()]['name'][$this->id_common])) {
         return true;
     }
     $re_entry = sql_query("\r\n\t\tSELECT user_entry\r\n\t\tFROM " . $this->_getUserEntryTable() . "\r\n\t\tWHERE id_user = '******' AND\r\n\t\t\tid_common = '" . (int) $this->id_common . "' AND\r\n\t\t\tid_common_son = '0'");
     $some_entry = mysql_num_rows($re_entry);
     list($old_file) = sql_fetch_row($re_entry);
     if ($some_entry) {
         if ($no_overwrite) {
             return true;
         }
         sl_unlink($path . $old_file);
         if (!sql_query("\r\n\t\t\tUPDATE " . $this->_getUserEntryTable() . "\r\n\t\t\tSET user_entry = '" . addslashes($file) . "'\r\n\t\t\tWHERE id_user = '******' AND\r\n\t\t\tid_common = '" . (int) $this->id_common . "' AND\r\n\t\t\tid_common_son = '0'")) {
             return false;
         }
     } else {
         if (!sql_query("\r\n\t\t\tINSERT INTO " . $this->_getUserEntryTable() . "\r\n\t\t\t( id_user, id_common, id_common_son, user_entry ) VALUES\r\n\t\t\t(\t'" . (int) $id_user . "',\r\n\t\t\t\t'" . (int) $this->id_common . "',\r\n\t\t\t\t'0',\r\n\t\t\t\t'" . $file . "')")) {
             return false;
         }
     }
     return true;
 }
示例#21
0
 function deleteFile($id_file)
 {
     require_once _base_ . '/lib/lib.upload.php';
     require_once _base_ . '/lib/lib.user.php';
     $user_data = new DoceboUser();
     $file_info = $this->getFileInfo($id_file);
     sl_open_fileoperations();
     sl_unlink($this->getFilePath() . $file_info[MYFILE_FILE_NAME]);
     sl_close_fileoperations();
     $query = "\r\n\t\tDELETE FROM " . $this->getFilesTable() . "\r\n\t\tWHERE owner = '" . $this->id_user . "' AND id_file = '" . $id_file . "'";
     if (!$this->_query($query)) {
         return false;
     }
     $result = $user_data->updateUserUsedSpace($this->id_user);
     return true;
 }
function selSendTo()
{
    checkPerm('view');
    // [TODO] check write or mod. permissions
    // http://127.0.0.1:82/claudio/lms_cvs/appCore/index.php?modname=public_newsletter_admin&op=selsendto&id_send=1
    if (isset($_GET["id_send"]) && $_GET["id_send"] > 0) {
        $id_send = $_GET["id_send"];
    } else {
        die("Newsletter setup error.");
    }
    require_once $GLOBALS['where_lms'] . "/class.module/class.public_user_admin.php";
    $mdir = new Module_Public_User_Admin();
    require_once _base_ . '/lib/lib.preference.php';
    $adminManager = new AdminPreference();
    $admin_tree = $adminManager->getAdminTree(Docebo::user()->getIdST());
    $admin_users = $acl_man->getAllUsersFromIdst($admin_tree);
    $mdir->setUserFilter('user', $admin_users);
    $mdir->setUserFilter('group', $admin_tree);
    $out =& $GLOBALS['page'];
    $out->setWorkingZone("content");
    $lang =& DoceboLanguage::createInstance('admin_newsletter', 'framework');
    $back_url = "index.php?modname=public_newsletter_admin&amp;op=selsendto&amp;id_send=" . $id_send;
    if (isset($_POST['okselector'])) {
        $arr_selection = $mdir->getSelection($_POST);
        $send_to_idst = array();
        foreach ($arr_selection as $idstMember) {
            $arr = Docebo::aclm()->getGroupAllUser($idstMember);
            if (is_array($arr) && count($arr) > 0) {
                $send_to_idst = array_merge($arr, $send_to_idst);
                $send_to_idst = array_unique($send_to_idst);
            } else {
                $send_to_idst[] = $idstMember;
            }
            $send_to_idst = array_intersect($send_to_idst, $admin_users);
        }
        foreach ($send_to_idst as $key => $val) {
            $qtxt = "INSERT INTO " . $GLOBALS["prefix_fw"] . "_newsletter_sendto (id_send, idst, stime) ";
            $qtxt .= "VALUES ('" . (int) $id_send . "', '" . (int) $val . "', NOW())";
            $q = sql_query($qtxt);
        }
        $qtxt = "SELECT language FROM " . $GLOBALS["prefix_fw"] . "_newsletter WHERE id='" . $id_send . "'";
        $q = sql_query($qtxt);
        list($lang) = sql_fetch_row($q);
        if ($lang != _ANY_LANG_CODE) {
            $tot = count(Docebo::aclm()->getUsersIdstByLanguage($lang, $send_to_idst));
        } else {
            $tot = count($send_to_idst);
        }
        $qtxt = "UPDATE " . $GLOBALS["prefix_fw"] . "_newsletter SET tot='" . $tot . "' WHERE id='{$id_send}'";
        $q = sql_query($qtxt);
        $back_url = "index.php?modname=public_newsletter_admin&amp;op=summary&amp;tot=" . $tot . "&amp;id_send=" . $id_send;
        Util::jump_to(str_replace("&amp;", "&", $back_url));
    } else {
        if (isset($_POST['cancelselector'])) {
            $info = get_send_info($id_send);
            $file = $info['file'];
            $path = '/appCore/newsletter/';
            require_once _base_ . '/lib/lib.upload.php';
            if ($file != '') {
                sl_open_fileoperations();
                sl_unlink($path . $file);
                sl_close_fileoperations();
            }
            Util::jump_to('index.php?modname=newsletter&op=newsletter');
        } else {
            if (isset($_GET['load'])) {
                $mdir->resetSelection(array());
            }
            $url = "index.php?modname=public_newsletter_admin&amp;op=selsendto&amp;id_send=" . $id_send . "&amp;stayon=1";
            $mdir->show_user_selector = TRUE;
            $mdir->show_group_selector = TRUE;
            if (Get::sett('use_org_chart') == '1') {
                $mdir->show_orgchart_selector = TRUE;
                $mdir->show_orgchart_simple_selector = TRUE;
            } else {
                $mdir->show_orgchart_selector = FALSE;
            }
            $acl_manager =& Docebo::user()->getAclManager();
            if (defined("IN_LMS")) {
                $id_course = (int) $_SESSION['idCourse'];
                $arr_idstGroup = $acl_manager->getGroupsIdstFromBasePath('/lms/course/' . $id_course . '/subscribed/');
                $mdir->setUserFilter('group', $arr_idstGroup);
                $mdir->setGroupFilter('path', '/lms/course/' . $id_course . '/group');
                $mdir->show_orgchart_selector = FALSE;
            }
            // Exclude anonymous user!
            $mdir->setUserFilter('exclude', array($acl_manager->getAnonymousId()));
            $mdir->loadSelector($url, array(Lang::t('_NEWSLETTER', 'admin_newsletter'), Lang::t('_RECIPIENTS', 'admin_newsletter')), "", TRUE);
        }
    }
}
示例#23
0
function removeCourseEdition($id_course_edition)
{
    require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
    $query_course_edition = "\r\n\tSELECT img_material,img_othermaterial,idCourse\r\n\tFROM " . $GLOBALS['prefix_lms'] . "_course_edition\r\n\tWHERE idCourseEdition = '" . $id_course_edition . "'";
    $res = sql_query($query_course_edition);
    $course_ed_info = mysql_fetch_array($res);
    $old_material = $course_ed_info["img_material"];
    $old_othermaterial = $course_ed_info["img_othermaterial"];
    $id_course = $course_ed_info["idCourse"];
    require_once _base_ . '/lib/lib.upload.php';
    $path = '/appLms/' . Get::sett('pathcourse');
    if (substr($path, -1) != '/' && substr($path, -1) != '\\') {
        $path = $path . '/';
    }
    sl_open_fileoperations();
    if ($old_material != '') {
        if (!sl_unlink($path . $old_material)) {
            return false;
        }
    }
    if ($old_othermaterial != '') {
        if (!sl_unlink($path . $old_othermaterial)) {
            return false;
        }
    }
    sl_close_fileoperations();
    if (!sql_query("DELETE FROM " . $GLOBALS['prefix_lms'] . "_course_edition WHERE idCourseEdition = '{$id_course_edition}'")) {
        return false;
    }
    $query_control = "SELECT idUser" . " FROM " . $GLOBALS['prefix_lms'] . "_courseuser" . " WHERE edition_id <> 0" . " AND edition_id <> {$id_course_edition}" . " AND idUser IN " . " (" . " SELECT idUser" . " FROM " . $GLOBALS['prefix_lms'] . "_courseuser" . " WHERE edition_id = '" . $id_course_edition . "'" . " )";
    $result_control = sql_fetch_row($query_control);
    $array_user_to_delete = array();
    $array_idst_group = array();
    if (mysql_num_rows($result_control)) {
        $array_user = array();
        while (list($id_user) = sql_fetch_row($result_control)) {
            $array_user[] = $id_user;
        }
        $query_user_to_delet = "SELECT idUser" . " FROM " . $GLOBALS['prefix_lms'] . "_courseuser" . " WHERE edition_id = '" . $id_course_edition . "'" . " AND idUser NOT IN (" . implode(', ', $array_user) . ")";
        $result_user_to_delet = sql_query($query_user_to_delet);
        while (list($id_user) = sql_fetch_row($result_user_to_delet)) {
            $array_user_to_delete[] = $id_user;
        }
    } else {
        $query_user = "******" . " FROM " . $GLOBALS['prefix_lms'] . "_courseuser" . " WHERE edition_id = '" . $id_course_edition . "'";
        $result_user = sql_query($query_user);
        while (list($id_user) = sql_fetch_row($result_user)) {
            $array_user_to_delete[] = $id_user;
        }
    }
    $query_group = "SELECT idst" . " FROM " . $GLOBALS['prefix_fw'] . "_group" . " WHERE groupid LIKE '%/lms/course/" . $id_course . "/%'";
    $result_group = sql_query($query_group);
    while (list($id_group) = sql_fetch_row($result_group)) {
        $array_idst_group[] = $id_group;
    }
    $query_delete = "DELETE FROM " . $GLOBALS['prefix_fw'] . "_group_member" . " WHERE idst IN (" . implode(', ', $array_idst_group) . ")" . " AND idstMember IN (" . implode(', ', $array_user_to_delete) . ")";
    if (!sql_query($query_delete)) {
        return false;
    }
    if (!sql_query("DELETE FROM " . $GLOBALS['prefix_lms'] . "_courseuser WHERE edition_id = '{$id_course_edition}' AND idCourse = '{$id_course}'")) {
        return false;
    }
    $acl_manager =& Docebo::user()->getAclManager();
    $group = '/lms/course_edition/' . $id_course_edition . '/subscribed';
    $group_idst = $acl_manager->getGroupST($group);
    $acl_manager->deleteGroup($group_idst);
    return true;
}
示例#24
0
function loadImportCourseUser2()
{
    require_once _base_ . '/lib/lib.upload.php';
    require_once $GLOBALS['where_framework'] . '/lib/lib.import.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
    require_once _base_ . '/lib/lib.table.php';
    $lang =& DoceboLanguage::CreateInstance('subscribe', 'lms');
    $back_url = 'index.php?modname=course&op=course_list';
    $acl_man =& Docebo::user()->getAclManager();
    $out =& $GLOBALS['page'];
    $out->setWorkingZone('content');
    $id_course = importVar('id_course', true, 0);
    $id_course_edition = importVar('edition', true, 0);
    $level_idst =& getCourseLevel($id_course);
    if (count($level_idst) == 0) {
        $level_idst =& DoceboCourse::createCourseLevel($id_course);
    }
    // ----------- file upload -----------------------------------------
    if ($_FILES['file_import']['name'] == '') {
        $_SESSION['last_error'] = Lang::t('_FILEUNSPECIFIED');
        Util::jump_to($back_url . '&import_result=-1');
    } else {
        $path = '/appCore/';
        $savefile = mt_rand(0, 100) . '_' . time() . '_' . $_FILES['file_import']['name'];
        if (!file_exists($GLOBALS['where_files_relative'] . $path . $savefile)) {
            sl_open_fileoperations();
            if (!sl_upload($_FILES['file_import']['tmp_name'], $path . $savefile)) {
                sl_close_fileoperations();
                $_SESSION['last_error'] = Lang::t('_ERROR_UPLOAD');
                Util::jump_to($back_url . '&import_result=-1');
            }
            sl_close_fileoperations();
        } else {
            $_SESSION['last_error'] = Lang::t('_ERROR_UPLOAD');
            Util::jump_to($back_url . '&create_result=-1');
        }
    }
    $out->add(getTitleArea($lang->def('_SUBSCRIBE')) . '<div class="std_block">');
    $separator = importVar('import_separator', false, ',');
    if ($separator == '') {
        $separator = ',';
    }
    $first_row_header = importVar('import_first_row_header', false, false);
    $import_charset = importVar('import_charset', false, 'UTF-8');
    if (trim($import_charset) === '') {
        $import_charset = 'UTF-8';
    }
    $src = new DeceboImport_SourceCSV(array('filename' => $GLOBALS['where_files_relative'] . $path . $savefile, 'separator' => $separator, 'first_row_header' => $first_row_header, 'import_charset' => $import_charset));
    $src->connect();
    $user_added = 0;
    $user_error = 0;
    $user_not_needed = 0;
    $id_user_added = array();
    $counter = 0;
    if (is_array($row = $src->get_first_row()) && !empty($row)) {
        $user_info = $acl_man->getUser(false, $row[0]);
        if ($user_info) {
            $id_user = $user_info[ACL_INFO_IDST];
            // Add in group for permission
            $acl_man->addToGroup($level_idst['3'], $id_user);
            // Add to edition group
            if ($id_course_edition > 0) {
                $group = '/lms/course_edition/' . $id_course_edition . '/subscribed';
                $group_idst = $acl_man->getGroupST($group);
                if ($group_idst === FALSE) {
                    $group_idst = $acl_man->registerGroup($group, 'all the user of a course edition', true, "course");
                }
                $acl_man->addToGroup($group_idst, $id_user);
            }
            // Add in table
            $re = sql_query("\r\n\t\t\tINSERT INTO " . $GLOBALS['prefix_lms'] . "_courseuser\r\n\t\t\t( idUser, idCourse, edition_id, level, waiting, subscribed_by, date_inscr )\r\n\t\t\tVALUES\r\n\t\t\t( '" . $id_user . "', '" . $id_course . "', '" . $id_course_edition . "', '3', '0', '" . getLogUserId() . "', '" . date("Y-m-d H:i:s") . "' )\t");
            if ($re) {
                addUserToTimeTable($id_user, $id_course, $id_course_edition);
                $user_added++;
                $id_user_added[$counter]['id_user'] = $id_user;
                $id_user_added[$counter]['status'] = '_CORRECT';
            } else {
                $query = "SELECT COUNT(*)" . " FROM " . $GLOBALS['prefix_lms'] . "_courseuser" . " WHERE idUser = '******'" . " AND idCourse = '" . $id_course . "'" . " AND edition_id = '" . $id_course_edition . "'";
                list($control) = sql_fetch_row(sql_query($query));
                if ($control) {
                    $user_not_needed++;
                    $id_user_added[$counter]['id_user'] = $id_user;
                    $id_user_added[$counter]['status'] = '_NOT_NEEDED';
                } else {
                    $user_error++;
                    $id_user_added[$counter]['id_user'] = $id_user;
                    $id_user_added[$counter]['status'] = '_OPERATION_FAILURE';
                }
            }
            $counter++;
        } else {
            $user_error++;
            $id_user_added[$counter]['id_user'] = $id_user;
            $id_user_added[$counter]['status'] = '_OPERATION_FAILURE';
        }
    }
    while (is_array($row = $src->get_next_row()) && !empty($row)) {
        $user_info = $acl_man->getUser(false, $row[0]);
        if ($user_info) {
            $id_user = $user_info[ACL_INFO_IDST];
            // Add in group for permission
            $acl_man->addToGroup($level_idst['3'], $id_user);
            // Add to edition group
            if ($id_course_edition > 0) {
                $group = '/lms/course_edition/' . $id_course_edition . '/subscribed';
                $group_idst = $acl_man->getGroupST($group);
                if ($group_idst === FALSE) {
                    $group_idst = $acl_man->registerGroup($group, 'all the user of a course edition', true, "course");
                }
                $acl_man->addToGroup($group_idst, $id_user);
            }
            // Add in table
            $re = sql_query("\r\n\t\t\tINSERT INTO " . $GLOBALS['prefix_lms'] . "_courseuser\r\n\t\t\t( idUser, idCourse, edition_id, level, waiting, subscribed_by, date_inscr )\r\n\t\t\tVALUES\r\n\t\t\t( '" . $id_user . "', '" . $id_course . "', '" . $id_course_edition . "', '3', '0', '" . getLogUserId() . "', '" . date("Y-m-d H:i:s") . "' )\t");
            if ($re) {
                addUserToTimeTable($id_user, $id_course, $id_course_edition);
                $user_added++;
                $id_user_added[$counter]['id_user'] = $id_user;
                $id_user_added[$counter]['status'] = '_CORRECT';
            } else {
                $query = "SELECT COUNT(*)" . " FROM " . $GLOBALS['prefix_lms'] . "_courseuser" . " WHERE idUser = '******'" . " AND idCourse = '" . $id_course . "'" . " AND edition_id = '" . $id_course_edition . "'";
                list($control) = sql_fetch_row(sql_query($query));
                if ($control) {
                    $user_not_needed++;
                    $id_user_added[$counter]['id_user'] = $id_user;
                    $id_user_added[$counter]['status'] = '_NOT_NEEDED';
                } else {
                    $user_error++;
                    $id_user_added[$counter]['id_user'] = $id_user;
                    $id_user_added[$counter]['status'] = '_OPERATION_FAILURE';
                }
            }
            $counter++;
        } else {
            $user_error++;
            $id_user_added[$counter]['id_user'] = $id_user;
            $id_user_added[$counter]['status'] = '_OPERATION_FAILURE';
        }
    }
    $src->close();
    unset($row);
    $type_h = array('align_center', 'align_center', 'align_center', 'align_center');
    $cont_h = array($lang->def('_USERNAME'), $lang->def('_LASTNAME'), $lang->def('_FIRSTNAME'), $lang->def('_INSER_STATUS'));
    $tb = new Table(false, $lang->def('_USER_SUBSCRIBED'), $lang->def('_USER_SUBSCRIBED'));
    $tb->addHead($cont_h, $type_h);
    while (list(, $id_user_added_detail) = each($id_user_added)) {
        $cont = array();
        $user_info = $acl_man->getUser($id_user_added_detail['id_user'], false);
        $cont[] = $acl_man->relativeId($user_info[ACL_INFO_USERID]);
        $cont[] = $user_info[ACL_INFO_FIRSTNAME];
        $cont[] = $user_info[ACL_INFO_LASTNAME];
        $cont[] = $lang->def($id_user_added_detail['status']);
        $tb->addBody($cont);
    }
    sl_open_fileoperations();
    sl_unlink($path . $savefile);
    sl_close_fileoperations();
    $out->add(getBackUi($back_url, $lang->def('_BACK')) . '<b>' . $lang->def('_INSERT_CORRECT') . ' : ' . '</b>' . $user_added . ' ' . '<b>' . $lang->def('_OPERATION_FAILURE') . ' : ' . '</b>' . $user_error . ' ' . '<b>' . $lang->def('_INSERT_NOT_NEEDED') . ' : ' . '</b>' . $user_not_needed . '<br/>' . '<br/>' . $tb->getTable() . '<br/>' . getBackUi($back_url, $lang->def('_BACK')) . '</div>');
}
示例#25
0
function ins_personal_media()
{
    if (!canAccessPersonalMedia()) {
        die("You can't access!");
    }
    include_once _base_ . '/lib/lib.upload.php';
    include_once _base_ . '/lib/lib.multimedia.php';
    $url = getPopupBaseUrl() . "&amp;op=personal";
    $user_id = Docebo::user()->getIdSt();
    $is_streaming = FALSE;
    if (isset($_FILES["file"]["name"]) && !empty($_FILES["file"]["name"])) {
        $fname = $_FILES["file"]["name"];
        $size = $_FILES["file"]["size"];
        $tmp_fname = $_FILES["file"]["tmp_name"];
        $real_fname = $user_id . '_' . mt_rand(0, 100) . '_' . time() . '_' . $fname;
    } else {
        $media_url = $_POST["media_url"];
        $fname = "";
        $real_fname = "";
        if (!empty($media_url)) {
            $is_streaming = TRUE;
            if (isYouTube($media_url)) {
                $fname = str_replace("http://www.", "", strtolower($media_url));
            } else {
                $fname = basename($media_url);
                $fname = strpos($fname, "?") !== FALSE ? preg_replace("/(\\?.*)/", "", $fname) : $fname;
            }
        }
    }
    if (!$is_streaming) {
        $valid_ext = array("png", "mng", "gif", "jpg", "jpeg", "wmv", "flv", "mov", "mp3", "swf", "mp4");
        $ext = strtolower(end(explode(".", $fname)));
        if (!in_array($ext, $valid_ext)) {
            Util::jump_to($url . '&result=invalid_ext');
        }
        sl_open_fileoperations();
        $f1 = sl_upload($tmp_fname, _USER_FPATH_INTERNAL . $real_fname);
        sl_close_fileoperations();
        if (!$f1) {
            // upload error
            Util::jump_to($url . '&result=upload_err');
        }
    }
    $qtxt = "INSERT INTO " . $GLOBALS["prefix_fw"] . "_user_file ";
    $qtxt .= " ( user_idst, type, fname, real_fname, media_url, size, uldate ) VALUES ";
    $qtxt .= " ('" . $user_id . "', 'image', '" . $fname . "', '" . addslashes($real_fname) . "', '" . $media_url . "', '" . $size . "', NOW())";
    $q = sql_query($qtxt);
    Util::jump_to($url . '&result=' . ($q ? 'upload_ok' : 'upload_err'));
}
示例#26
0
 function deleteFile($id_file)
 {
     require_once _base_ . '/lib/lib.upload.php';
     $old_file = sql_fetch_row($this->getFileInfo($id_file));
     sl_open_fileoperations();
     sl_unlink($this->getFilePath() . $old_file[LR_FILE_NAME]);
     sl_close_fileoperations();
     $query = "" . " DELETE FROM " . $this->_tableFile() . " " . " WHERE id_author = " . (int) $old_file[LR_FILE_AUTHOR] . " " . " \t\tAND id_file = " . (int) $id_file . "";
     if (!sql_query($query)) {
         return false;
     }
     return true;
 }
示例#27
0
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&amp;op=course_list&result=ok_course');
    return true;
}
示例#28
0
function manageCertificateFile($new_file_id, $old_file, $path, $delete_old, $is_image = false)
{
    require_once _base_ . '/lib/lib.upload.php';
    $arr_new_file = isset($_FILES[$new_file_id]) && $_FILES[$new_file_id]['tmp_name'] != '' ? $_FILES[$new_file_id] : false;
    $return = array('filename' => $old_file, 'new_size' => 0, 'old_size' => 0, 'error' => false, 'quota_exceeded' => false);
    sl_open_fileoperations();
    if (($delete_old || $arr_new_file !== false) && $old_file != '') {
        sl_unlink($path . $old_file);
    }
    // the flag for file delete is checked or a new file was uploaded ---------------------
    if (!empty($arr_new_file)) {
        // if present load the new file --------------------------------------------------------
        $filename = $new_file_id . '_' . mt_rand(0, 100) . '_' . time() . '_' . $arr_new_file['name'];
        if (!sl_upload($arr_new_file['tmp_name'], $path . $filename)) {
            return false;
        } else {
            return $filename;
        }
    }
    sl_close_fileoperations();
    return '';
}
示例#29
0
$html .= '<li>' . Lang::t('_POST_MAX_SIZE', 'configuration') . ':&nbsp;<b>' . $php_conf['post_max_size']['local_value'] . '</b>';
$html .= '<li>' . Lang::t('_MAX_EXECUTION_TIME', 'configuration') . ':&nbsp;<b>' . $php_conf['max_execution_time']['local_value'] . 's' . '</b>';
$html .= '<li>' . Lang::t('_LDAP', 'configuration') . ':&nbsp;<b>' . (extension_loaded('ldap') ? Lang::t('_ON', 'standard') : '<span class="red">' . Lang::t('_OFF', 'standard') . ' ' . Lang::t('_USEFULL_ONLY_IF', 'configuration') . '</span>') . '</b>';
if (version_compare(phpversion(), "5.0.0") == -1) {
    $html .= '<li>' . Lang::t('_DOMXML', 'configuration') . ':&nbsp;<b>' . (extension_loaded('domxml') ? Lang::t('_ON', 'standard') : '<span class="red">' . Lang::t('_OFF') . ' (' . Lang::t('_NOTSCORM', 'configuration') . ')</span>') . '</b>';
}
if (version_compare(phpversion(), "5.2.0", ">")) {
    $html .= '<li>' . Lang::t('_ALLOW_URL_INCLUDE', 'configuration') . ':&nbsp;<b>' . ($php_conf['allow_url_include']['local_value'] ? '<span class="red">' . Lang::t('_ON') . '</span>' : Lang::t('_OFF')) . '</b>';
}
if (Get::sett('uploadType', '') == 'ftp') {
    if (function_exists("ftp_connect")) {
        require_once $GLOBALS['where_framework'] . '/lib/lib.upload.php';
        $re_con = sl_open_fileoperations();
        $html .= '<li>' . Lang::t('_UPLOADFTP', 'configuration') . ':&nbsp;<b>' . ($re_con ? Lang::t('_FTPOK', 'configuration') : '<span class="red">' . Lang::t('_FTPERR', 'configuration') . '</span>') . '<b>';
        if ($re_con) {
            sl_close_fileoperations();
        }
    } else {
        $html .= '<li>' . Lang::t('_UPLOADFTP', 'configuration') . ':&nbsp;<b><span class="red">' . Lang::t('_FTPERR') . '</span></b>';
    }
}
$html .= '<li>' . Lang::t('_OPENSSL', 'configuration') . ':&nbsp;<b>' . (extension_loaded('openssl') ? Lang::t('_ON', 'standard') : '<span class="red">' . Lang::t('_OFF', 'standard') . ' ' . Lang::t('_WARINNG_SOCIAL', 'configuration') . '</span>') . '</b>';
$html .= '<li>' . Lang::t('_ALLOW_URL_FOPEN', 'configuration') . ':&nbsp;<b>' . ($php_conf['allow_url_fopen']['local_value'] ? Lang::t('_ON') : '<span class="red">' . Lang::t('_OFF', 'standard') . ' ' . Lang::t('_WARINNG_SOCIAL', 'configuration') . '</span>') . '</b>';
$html .= '</ul>';
$html .= '</div>';
if (isset($json)) {
    $params = array('success' => true, 'header' => $title, 'body' => $html);
    echo $json->encode($params);
} else {
    echo getTitleArea($title);
    echo '<div class="std_block">' . $html . '</div>';
 public function import_csv()
 {
     if (!$this->permissions['subscribe_course']) {
         $this->render('invalid', array('message' => $this->_getErrorMessage('no permission'), 'back_url' => 'index.php?r=' . $this->link_course . '/show'));
         return;
     }
     require_once _base_ . '/lib/lib.form.php';
     //Step info
     $step = Get::req('step', DOTY_INT, 1);
     if (isset($_POST['next'])) {
         $step++;
     }
     if (isset($_POST['back'])) {
         $step--;
     }
     if (isset($_POST['undo'])) {
         $step = 0;
     }
     switch ($step) {
         case '0':
             Util::jump_to('index.php?r=' . $this->link_course . '/show');
             break;
         case '1':
             $course_info = $this->model->getCourseInfoForSubscription();
             $course_name = ($course_info['code'] !== '' ? '[' . $course_info['code'] . '] ' : '') . $course_info['name'];
             $params = array('table' => $tb, 'id_course' => $this->id_course, 'id_date' => $this->id_date, 'id_edition' => $this->id_edition, 'course_name' => $course_name, 'model' => $this->model);
             $this->render('import_csv_step_1', $params);
             break;
         case '2':
             require_once _lms_ . '/lib/lib.course.php';
             require_once _base_ . '/lib/lib.upload.php';
             require_once _adm_ . '/lib/lib.import.php';
             $separator = Get::req('import_separator', DOTY_MIXED, ',');
             $first_row_header = Get::req('import_first_row_header', DOTY_BOOL, false);
             $import_charset = Get::req('import_charset', DOTY_MIXED, 'UTF-8');
             $docebo_course = new DoceboCourse($this->id_course);
             $level_idst =& $docebo_course->getCourseLevel($this->id_course);
             if (count($level_idst) == 0 || $level_idst[1] == '') {
                 $level_idst =& $docebo_course->createCourseLevel($this->id_course);
             }
             $back_url = 'index.php?r=' . $this->link . '/show&id_course=' . $this->id_course . '&id_edition=' . $this->id_edition . '&id_date=' . $this->id_date;
             // ----------- file upload -----------------------------------------
             if ($_FILES['file_import']['name'] == '') {
                 $_SESSION['last_error'] = Lang::t('_FILEUNSPECIFIED');
                 jumpTo($back_url . '&err=_file_unspecified');
             } else {
                 $path = '/appCore/';
                 $savefile = mt_rand(0, 100) . '_' . time() . '_' . $_FILES['file_import']['name'];
                 if (!file_exists($GLOBALS['where_files_relative'] . $path . $savefile)) {
                     sl_open_fileoperations();
                     if (!sl_upload($_FILES['file_import']['tmp_name'], $path . $savefile)) {
                         sl_close_fileoperations();
                         $_SESSION['last_error'] = Lang::t('_ERROR_UPLOAD', 'subscribe');
                         jumpTo($back_url . '&err=_err_upload');
                     }
                     sl_close_fileoperations();
                 } else {
                     $_SESSION['last_error'] = Lang::t('_ERROR_UPLOAD', 'subscribe');
                     jumpTo($back_url . '&err=_err_upload');
                 }
             }
             $src = new DeceboImport_SourceCSV(array('filename' => $GLOBALS['where_files_relative'] . $path . $savefile, 'separator' => $separator, 'first_row_header' => $first_row_header, 'import_charset' => $import_charset));
             $src->connect();
             $user_added = 0;
             $user_error = 0;
             $user_not_needed = 0;
             $id_user_added = array();
             $counter = 0;
             $course_info = $this->model->getCourseInfoForSubscription();
             $can_subscribe = true;
             $max_num_subscribe = $course_info['max_num_subscribe'];
             $subscribe_method = $course_info['subscribe_method'];
             if (Docebo::user()->getUserLevelId() != ADMIN_GROUP_GODADMIN) {
                 $limited_subscribe = Docebo::user()->preference->getAdminPreference('admin_rules.limit_course_subscribe');
                 $max_subscribe = Docebo::user()->preference->getAdminPreference('admin_rules.max_course_subscribe');
                 $direct_subscribe = Docebo::user()->preference->getAdminPreference('admin_rules.direct_course_subscribe');
                 if ($limited_subscribe == 'on') {
                     $limited_subscribe = true;
                 } else {
                     $limited_subscribe = false;
                 }
                 if ($direct_subscribe == 'on') {
                     $direct_subscribe = true;
                 } else {
                     $direct_subscribe = false;
                 }
             } else {
                 $limited_subscribe = false;
                 $max_subscribe = 0;
                 $direct_subscribe = true;
             }
             if (is_array($row = $src->get_first_row()) && !empty($row)) {
                 $user_info = $this->acl_man->getUser(false, $row[0]);
                 if ($user_info) {
                     $id_user = $user_info[ACL_INFO_IDST];
                     if ($can_subscribe) {
                         require_once _lms_ . '/lib/lib.course.php';
                         $docebo_course = new DoceboCourse($this->id_course);
                         $level_idst =& $docebo_course->getCourseLevel($this->id_course);
                         if (count($level_idst) == 0 || $level_idst[1] == '') {
                             $level_idst =& $docebo_course->createCourseLevel($this->id_course);
                         }
                         if (!$direct_subscribe) {
                             $waiting = 1;
                         } else {
                             $waiting = 0;
                         }
                         if (!$limited_subscribe || $max_subscribe) {
                             //$this->acl_man->addToGroup($level_idst['3'], $id_user);
                             $this->_addToCourseGroup($level_idst['3'], $id_user);
                             if ($this->model->subscribeUser($id_user, '3', $waiting)) {
                                 $user_added++;
                                 $id_user_added[$counter]['id_user'] = $row[0];
                                 $id_user_added[$counter]['status'] = '_CORRECT';
                                 $user_subscribed[] = $id_user;
                                 $max_subscribe--;
                             } else {
                                 $query = "SELECT COUNT(*)" . " FROM " . $GLOBALS['prefix_lms'] . "_courseuser" . " WHERE idUser = '******'" . " AND idCourse = '" . $this->id_course . "'";
                                 list($control) = sql_fetch_row(sql_query($query));
                                 if ($control) {
                                     $user_not_needed++;
                                     $id_user_added[$counter]['id_user'] = $row[0];
                                     $id_user_added[$counter]['status'] = '_NOT_NEEDED';
                                 } else {
                                     $user_error++;
                                     $id_user_added[$counter]['id_user'] = $row[0];
                                     $id_user_added[$counter]['status'] = '_OPERATION_FAILURE';
                                     $this->acl_man->removeFromGroup($level_idst['3'], $id_user);
                                 }
                             }
                         }
                     }
                 } else {
                     $user_error++;
                     $id_user_added[$counter]['id_user'] = $row[0];
                     $id_user_added[$counter]['status'] = '_OPERATION_FAILURE';
                 }
                 $counter++;
             }
             while (is_array($row = $src->get_next_row()) && !empty($row)) {
                 $user_info = $this->acl_man->getUser(false, $row[0]);
                 if ($user_info) {
                     $id_user = $user_info[ACL_INFO_IDST];
                     if ($can_subscribe) {
                         require_once _lms_ . '/lib/lib.course.php';
                         $docebo_course = new DoceboCourse($this->id_course);
                         $level_idst =& $docebo_course->getCourseLevel($this->id_course);
                         if (count($level_idst) == 0 || $level_idst[1] == '') {
                             $level_idst =& $docebo_course->createCourseLevel($this->id_course);
                         }
                         if (!$direct_subscribe) {
                             $waiting = 1;
                         } else {
                             $waiting = 0;
                         }
                         if (!$limited_subscribe || $max_subscribe) {
                             //$this->acl_man->addToGroup($level_idst['3'], $id_user);
                             $this->_addToCourseGroup($level_idst['3'], $id_user);
                             if ($this->model->subscribeUser($id_user, '3', $waiting)) {
                                 $user_added++;
                                 $id_user_added[$counter]['id_user'] = $row[0];
                                 $id_user_added[$counter]['status'] = '_CORRECT';
                                 $user_subscribed[] = $id_user;
                                 $max_subscribe--;
                             } else {
                                 $query = "SELECT COUNT(*)" . " FROM " . $GLOBALS['prefix_lms'] . "_courseuser" . " WHERE idUser = '******'" . " AND idCourse = '" . $this->id_course . "'";
                                 list($control) = sql_fetch_row(sql_query($query));
                                 if ($control) {
                                     $user_not_needed++;
                                     $id_user_added[$counter]['id_user'] = $row[0];
                                     $id_user_added[$counter]['status'] = '_NOT_NEEDED';
                                 } else {
                                     $user_error++;
                                     $id_user_added[$counter]['id_user'] = $row[0];
                                     $id_user_added[$counter]['status'] = '_OPERATION_FAILURE';
                                     $this->acl_man->removeFromGroup($level_idst['3'], $id_user);
                                 }
                             }
                         }
                     }
                 } else {
                     $user_error++;
                     $id_user_added[$counter]['id_user'] = $row[0];
                     $id_user_added[$counter]['status'] = '_OPERATION_FAILURE';
                 }
                 $counter++;
             }
             $src->close();
             unset($row);
             require_once _base_ . '/lib/lib.table.php';
             $type_h = array('align_center', 'align_center', 'align_center', 'align_center');
             $cont_h = array(Lang::t('_USERNAME', 'subscribe'), Lang::t('_LASTNAME', 'subscribe'), Lang::t('_FIRSTNAME', 'subscribe'), Lang::t('_INSER_STATUS', 'subscribe'));
             $tb = new Table(false, Lang::t('_USER_SUBSCRIBED', 'subscribe'), Lang::t('_USER_SUBSCRIBED', 'subscribe'));
             $tb->addHead($cont_h, $type_h);
             while (list(, $id_user_added_detail) = each($id_user_added)) {
                 $cont = array();
                 $user_info = $this->acl_man->getUser(false, $id_user_added_detail['id_user']);
                 $cont[] = $this->acl_man->relativeId($user_info[ACL_INFO_USERID]);
                 $cont[] = $user_info[ACL_INFO_FIRSTNAME];
                 $cont[] = $user_info[ACL_INFO_LASTNAME];
                 $cont[] = Lang::t($id_user_added_detail['status'], 'subscribe');
                 $tb->addBody($cont);
             }
             sl_open_fileoperations();
             sl_unlink($GLOBALS['where_files_relative'] . $path . $savefile);
             sl_close_fileoperations();
             $course_info = $this->model->getCourseInfoForSubscription();
             $course_name = ($course_info['code'] !== '' ? '[' . $course_info['code'] . '] ' : '') . $course_info['name'];
             $params = array('table' => $tb, 'id_course' => $this->id_course, 'id_date' => $this->id_date, 'id_edition' => $this->id_edition, 'course_name' => $course_name, 'back_link' => getBackUi('index.php?r=' . $this->link . '/show&id_course=' . $this->id_course . '&id_edition=' . $this->id_edition . '&id_date=' . $this->id_date, Lang::t('_BACK', 'subscribe')));
             $this->render('import_csv_step_2', $params);
             break;
     }
 }