/** * Import users into database from a file located on the server. * Function registered as service. * @param string The csv (only csv) file containing users tom import * @param string Security key (as found in configuration file) * @return string Error message */ function import_users_from_file($filepath, $security_key) { $errors_returned = array(0 => 'success', 1 => 'file import does not exist', 2 => 'no users to import', 3 => 'wrong datas in file', 4 => 'security error'); $security = api_get_configuration_value('security_key'); // Check whether this script is launch by server and security key is ok. if (empty($_SERVER['REMOTE_ADDR']) || $_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR'] || $security_key != $security) { return $errors_returned[4]; } // Libraries require_once 'import.lib.php'; // Check is users file exists. if (!is_file($filepath)) { return $errors_returned[1]; } // Get list of users $users = parse_csv_data($filepath); if (count($users) == 0) { return $errors_returned[2]; } // Check the datas for each user $errors = validate_data($users); if (count($errors) > 0) { return $errors_returned[3]; } // Apply modifications in database save_data($users); return $errors_returned[0]; // Import successfull }
/** * Get a list of courses (code, url, title, teacher, language) and return to caller * Function registered as service. Returns strings in UTF-8. * @param string Security key (the Dokeos install's API key) * @param mixed Array or string. Type of visibility of course (public, public-registered, private, closed) * @return array Courses list (code=>[title=>'title',url='http://...',teacher=>'...',language=>''],code=>[...],...) */ function courses_list($security_key, $visibilities = 'public') { $securityFromConfiguration = api_get_configuration_value('security_key'); // Check if this script is launch by server and if security key is ok. if ($security_key != $securityFromConfiguration) { return array('error_msg' => 'Security check failed'); } $vis = array('public' => '3', 'public-registered' => '2', 'private' => '1', 'closed' => '0'); $courses_list = array(); if (!is_array($visibilities)) { $tmp = $visibilities; $visibilities = array($tmp); } foreach ($visibilities as $visibility) { if (!in_array($visibility, array_keys($vis))) { return array('error_msg' => 'Security check failed'); } $courses_list_tmp = CourseManager::get_courses_list(null, null, null, null, $vis[$visibility]); foreach ($courses_list_tmp as $index => $course) { $course_info = CourseManager::get_course_information($course['code']); $courses_list[$course['code']] = array('title' => api_utf8_encode($course_info['title']), 'url' => api_get_path(WEB_COURSE_PATH) . $course_info['directory'] . '/', 'teacher' => api_utf8_encode($course_info['tutor_name']), 'language' => $course_info['course_language']); } } return $courses_list; }
/** * @return array */ public function get_paths_data() { global $paths; $list = $paths[api_get_path(WEB_PATH)]; $list['url_append'] = api_get_configuration_value('url_append'); asort($list); return ['headers' => ['Path', 'constant'], 'data' => $list]; }
/** * @return bool|mixed */ public static function getPasswordEncryption() { $encryptionMethod = self::$encryptionMethod; if (empty($encryptionMethod)) { $encryptionMethod = api_get_configuration_value('password_encryption'); } return $encryptionMethod; }
/** * @return EntityManager */ public function getEntityManager() { if (empty($this->manager)) { $dbParams = array('driver' => 'pdo_mysql', 'host' => api_get_configuration_value('db_host'), 'user' => api_get_configuration_value('db_user'), 'password' => api_get_configuration_value('db_password'), 'dbname' => api_get_configuration_value('main_database')); $database = new \Database(); $database->connect($dbParams, __DIR__ . '/../../', __DIR__ . '/../../'); $this->manager = $database->getManager(); } return $this->manager; }
/** * Set ups DB tables */ public function __construct() { $this->table = Database::get_main_table(TABLE_USERGROUP); $this->usergroup_rel_user_table = Database::get_main_table(TABLE_USERGROUP_REL_USER); $this->usergroup_rel_course_table = Database::get_main_table(TABLE_USERGROUP_REL_COURSE); $this->usergroup_rel_session_table = Database::get_main_table(TABLE_USERGROUP_REL_SESSION); $this->access_url_rel_usergroup = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP); $this->table_course = Database::get_main_table(TABLE_MAIN_COURSE); $this->table_user = Database::get_main_table(TABLE_MAIN_USER); $this->useMultipleUrl = api_get_configuration_value('enable_multiple_url_support_for_classes'); }
function WSHelperVerifyKey($params) { global $debug; $securityFromConfiguration = api_get_configuration_value('security_key'); if (is_array($params)) { $secret_key = $params['secret_key']; } else { $secret_key = $params; } //error_log(print_r($params,1)); $check_ip = false; $ip_matches = false; $ip = trim($_SERVER['REMOTE_ADDR']); // if we are behind a reverse proxy, assume it will send the // HTTP_X_FORWARDED_FOR header and use this IP instead if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { list($ip1) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); $ip = trim($ip1); } if ($debug) { error_log("ip: {$ip}"); } // Check if a file that limits access from webservices exists and contains // the restraining check if (is_file('webservice-auth-ip.conf.php')) { include 'webservice-auth-ip.conf.php'; if ($debug) { error_log("webservice-auth-ip.conf.php file included"); } if (!empty($ws_auth_ip)) { $check_ip = true; $ip_matches = api_check_ip_in_range($ip, $ws_auth_ip); if ($debug) { error_log("ip_matches: {$ip_matches}"); } } } if ($debug) { error_log("checkip " . intval($check_ip)); } if ($check_ip) { $security_key = $securityFromConfiguration; } else { $security_key = $ip . $securityFromConfiguration; //error_log($secret_key.'-'.$security_key); } $result = api_is_valid_secret_key($secret_key, $security_key); //error_log($secret_key.'-'.$security_key); if ($debug) { error_log('WSHelperVerifyKey result: ' . intval($result)); } return $result; }
/** * Checks total platform size * @param bool $debug * * @return bool */ function isTotalPortalSizeBiggerThanLimit($debug = true) { $sizeLimit = api_get_configuration_value('hosting_total_size_limit'); if (empty($sizeLimit)) { return true; } $updateFile = true; $file = api_get_path(SYS_COURSE_PATH) . 'hosting_total_size.php'; // Default data $hostingData = array('frequency' => 86400); $log = null; // Check if file exists and if it is updated if (file_exists($file)) { $hostingDataFromFile = (require $file); // Check time() is UTC if (isset($hostingDataFromFile['updated_at']) && isset($hostingDataFromFile['frequency']) && isset($hostingDataFromFile['size'])) { $hostingData = $hostingDataFromFile; $time = $hostingData['updated_at'] + $hostingData['frequency']; $diff = $time - time(); if ($time > time()) { $log .= "You need to wait {$diff} seconds to update the file \n"; $updateFile = false; } } } // Now get values for total portal size $log .= "Frequency loaded: " . $hostingData['frequency'] . "\n"; if ($updateFile) { $log .= "Updating total size ... \n"; $totalSize = calculateTotalPortalSize($debug); $log .= "Total size calculated: {$totalSize} \n"; $hostingData['updated_at'] = time(); $hostingData['size'] = $totalSize; $writer = new Zend\Config\Writer\PhpArray(); $phpCode = $writer->toString($hostingData); file_put_contents($file, $phpCode); $log .= "File saved in {$file} \n"; } else { $log .= "Total size not updated \n"; $totalSize = $hostingData['size']; } $result = true; if ($totalSize > $sizeLimit) { $log .= "Current total size of {$totalSize} MB is bigger than limit: {$sizeLimit} MB \n"; $result = false; } if ($debug) { echo $log; } return $result; }
/** * @param Schema $schema * * @throws \Doctrine\DBAL\Schema\SchemaException */ public function up(Schema $schema) { // Move some settings from configuration.php to the database // Current settings categories are: // Platform, Course, Session, Languages, User, Tools, Editor, Security, // Tuning, Gradebook, Timezones, Tracking, Search, stylesheets (lowercase), // LDAP, CAS, Shibboleth, Facebook // Setting $_configuration['hide_home_top_when_connected'] = true; $value = api_get_configuration_value('hide_home_top_when_connected'); $this->addSettingCurrent('hide_home_top_when_connected', '', 'radio', 'Platform', $value ? 'true' : 'false', 'HideHomeTopContentWhenLoggedInText', 'HideHomeTopContentWhenLoggedInComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Hide the global announcements for non-connected users //$_configuration['hide_global_announcements_when_not_connected'] = true; $value = api_get_configuration_value('hide_global_announcements_when_not_connected'); $this->addSettingCurrent('hide_global_announcements_when_not_connected', '', 'radio', 'Platform', $value ? 'true' : 'false', 'HideGlobalAnnouncementsWhenNotLoggedInText', 'HideGlobalAnnouncementsWhenNotLoggedInComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Use this course as template for all new courses (define course real ID as value) //$_configuration['course_creation_use_template'] = 14; $value = api_get_configuration_value('course_creation_use_template'); $this->addSettingCurrent('course_creation_use_template', '', 'textfield', 'Course', $value ? $value : '', 'CourseCreationUsesTemplateText', 'CourseCreationUsesTemplateComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Add password strength checker //$_configuration['allow_strength_pass_checker'] = true; $value = api_get_configuration_value('allow_strength_pass_checker'); $this->addSettingCurrent('allow_strength_pass_checker', '', 'radio', 'Security', $value ? 'true' : 'false', 'EnablePasswordStrengthCheckerText', 'EnablePasswordStrengthCheckerComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Enable captcha // $_configuration['allow_captcha'] = true; $value = api_get_configuration_value('allow_captcha'); $this->addSettingCurrent('allow_captcha', '', 'radio', 'Security', $value ? 'true' : 'false', 'EnableCaptchaText', 'EnableCaptchaComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Prevent account from logging in for a certain amount of time // if captcha is wrong for the specified number of times //$_configuration['captcha_number_mistakes_to_block_account'] = 5; $value = api_get_configuration_value('captcha_number_mistakes_to_block_account'); $this->addSettingCurrent('captcha_number_mistakes_to_block_account', '', 'textfield', 'Security', $value ? $value : 5, 'CaptchaNumberOfMistakesBeforeBlockingAccountText', 'CaptchaNumberOfMistakesBeforeBlockingAccountComment', null, '', 1, true, false); // Prevent account from logging in for the specified number of minutes //$_configuration['captcha_time_to_block'] = 5;//minutes $value = api_get_configuration_value('captcha_time_to_block'); $this->addSettingCurrent('captcha_time_to_block', '', 'textfield', 'Security', $value ? $value : 5, 'CaptchaTimeAccountIsLockedText', 'CaptchaTimeAccountIsLockedComment', null, '', 1, true, false); // Allow DRH role to access all content and users from the sessions he follows //$_configuration['drh_can_access_all_session_content'] = true; $value = api_get_configuration_value('drh_can_access_all_session_content'); $this->addSettingCurrent('drh_can_access_all_session_content', '', 'radio', 'Session', $value ? 'true' : 'false', 'DRHAccessToAllSessionContentText', 'DRHAccessToAllSessionContentComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Display group's forum in general forum tool //$_configuration['display_groups_forum_in_general_tool'] = true; $value = api_get_configuration_value('display_groups_forum_in_general_tool'); $this->addSettingCurrent('display_groups_forum_in_general_tool', '', 'radio', 'Tools', $value ? 'true' : 'false', 'ShowGroupForaInGeneralToolText', 'ShowGroupForaInGeneralToolComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Allow course tutors in sessions to add existing students to their session //$_configuration['allow_tutors_to_assign_students_to_session'] = 'false'; $value = api_get_configuration_value('allow_tutors_to_assign_students_to_session'); $this->addSettingCurrent('allow_tutors_to_assign_students_to_session', '', 'radio', 'Session', $value ? 'true' : 'false', 'TutorsCanAssignStudentsToSessionsText', 'TutorsCanAssignStudentsToSessionsComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); }
/** * Get a list of courses (code, url, title, teacher, language) and return to caller * Function registered as service. Returns strings in UTF-8. * @param string User name in Chamilo * @param string Signature (composed of the sha1(username+apikey) * @param mixed Array or string. Type of visibility of course (public, public-registered, private, closed) * @return array Courses list (code=>[title=>'title',url='http://...',teacher=>'...',language=>''],code=>[...],...) */ function WSCourseList($username, $signature, $visibilities = 'public') { if (empty($username) or empty($signature)) { return -1; } $securityFromConfiguration = api_get_configuration_value('security_key'); $info = api_get_user_info_from_username($username); $user_id = $info['user_id']; if (!UserManager::is_admin($user_id)) { return -1; } $list = UserManager::get_api_keys($user_id, 'dokeos'); $key = ''; foreach ($list as $key) { break; } $local_key = $username . $key; if (!api_is_valid_secret_key($signature, $local_key) && !api_is_valid_secret_key($signature, $username . $securityFromConfiguration)) { return -1; // The secret key is incorrect. } //public-registered = open $vis = array('public' => '3', 'public-registered' => '2', 'private' => '1', 'closed' => '0'); $courses_list = array(); if (!is_array($visibilities)) { $visibilities = split(',', $visibilities); } foreach ($visibilities as $visibility) { if (!in_array($visibility, array_keys($vis))) { return array('error_msg' => 'Security check failed'); } $courses_list_tmp = CourseManager::get_courses_list(null, null, null, null, $vis[$visibility]); foreach ($courses_list_tmp as $index => $course) { $course_info = CourseManager::get_course_information($course['code']); $courses_list[] = array('code' => $course['code'], 'title' => api_utf8_encode($course_info['title']), 'url' => api_get_path(WEB_COURSE_PATH) . $course_info['directory'] . '/', 'teacher' => api_utf8_encode($course_info['tutor_name']), 'language' => $course_info['course_language']); } } return $courses_list; }
$categories = Category::load(null, null, $course_code, null, null, $sessionId); if (!empty($categories)) { $gradebookEvaluations = $categories[0]->get_evaluations(); $gradebookLinks = $categories[0]->get_links(); if (count($gradebookEvaluations) === 0 && count($gradebookLinks) === 1 && $gradebookLinks[0]->get_type() == LINK_LEARNPATH && $gradebookLinks[0]->get_ref_id() == $learnPath->lp_id) { $gradebookMinScore = $categories[0]->get_certificate_min_score(); $userScore = $gradebookLinks[0]->calc_score($user_id, 'best'); if ($userScore[0] >= $gradebookMinScore) { Category::register_user_certificate($categories[0]->get_id(), $user_id); } } } } $template = \Chamilo\CoreBundle\Framework\Container::getTwig(); $template->addGlobal('glossary_extra_tools', api_get_setting('glossary.show_glossary_in_extra_tools')); $fixLinkSetting = api_get_configuration_value('lp_fix_embed_content'); $fixLink = ''; if ($fixLinkSetting) { $fixLink = '{type:"script", id:"_fr10", src:"' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/fixlinks.js"}'; } $template->addGlobal('fix_link', $fixLink); $template->addGlobal('glossary_tool_availables', ['true', 'lp', 'exercise_and_lp']); // If the global gamification mode is enabled... $gamificationMode = api_get_setting('platform.gamification_mode'); // ...AND this learning path is set in gamification mode, then change the display $gamificationMode = $gamificationMode && $learnPath->seriousgame_mode; $template->addGlobal('show_glossary_in_documents', api_get_setting('document.show_glossary_in_documents')); $template->addGlobal('jquery_web_path', api_get_jquery_web_path()); $template->addGlobal('jquery_ui_js_web_path', api_get_jquery_ui_js_web_path()); $template->addGlobal('jquery_ui_css_web_path', api_get_jquery_ui_css_web_path()); $template->addGlobal('is_allowed_to_edit', $is_allowed_to_edit);
<?php /* For licensing terms, see /license.txt */ use Chamilo\CoreBundle\Framework\Container; //require_once '../inc/global.inc.php'; api_protect_admin_script(); if (!api_get_configuration_value('document_manage_deleted_files')) { api_not_allowed(true); } $courseInfo = api_get_course_info(); $sessionId = api_get_session_id(); $files = DocumentManager::getDeletedDocuments($courseInfo, $sessionId); $actions = Display::url(get_lang('DownloadAll'), api_get_self() . '?' . api_get_cidreq() . '&action=download_all', ['class' => 'btn btn-default']); $actions .= Display::url(get_lang('DeleteAll'), api_get_self() . '?' . api_get_cidreq() . '&action=delete_all', ['class' => 'btn btn-danger']); $action = isset($_GET['action']) ? $_GET['action'] : ''; $id = isset($_GET['id']) ? intval($_GET['id']) : ''; $currentUrl = api_get_self() . '?' . api_get_cidreq(); switch ($action) { case 'delete': DocumentManager::purgeDocument($id, $courseInfo, $sessionId); Display::addFlash(Display::return_message(get_lang('Deleted'))); header('Location: ' . $currentUrl); exit; break; case 'delete_all': DocumentManager::purgeDocuments($courseInfo, $sessionId); Display::addFlash(Display::return_message(get_lang('Deleted'))); header('Location: ' . $currentUrl); exit; break; case 'download':
/* For licensing terms, see /license.txt */ use Chamilo\CoreBundle\Framework\Container; /** * This script displays a form for registering new users. * @package chamilo.auth */ use ChamiloSession as Session; //quick hack to adapt the registration form result to the selected registration language if (!empty($_POST['language'])) { $_GET['language'] = $_POST['language']; } //require_once '../inc/global.inc.php'; $hideHeaders = isset($_GET['hide_headers']); $allowedFields = ['official_code', 'phone', 'status', 'language', 'extra_fields']; $allowedFieldsConfiguration = api_get_configuration_value('allow_fields_inscription'); if ($allowedFieldsConfiguration !== false) { $allowedFields = $allowedFieldsConfiguration; } $htmlHeadXtra[] = api_get_password_checker_js('#username', '#pass1'); // User is not allowed if Terms and Conditions are disabled and // registration is disabled too. $isNotAllowedHere = api_get_setting('registration.allow_terms_conditions') === 'false' && api_get_setting('registration.allow_registration') === 'false'; if ($isNotAllowedHere) { api_not_allowed(true, get_lang('RegistrationDisabled')); } if (!empty($_SESSION['user_language_choice'])) { $user_selected_language = $_SESSION['user_language_choice']; } elseif (!empty($_SESSION['_user']['language'])) { $user_selected_language = $_SESSION['_user']['language']; } else {
$data_array = $datagen->get_data(GradebookDataGenerator::GDG_SORT_NAME, 0, null, true); if (!empty($data_array)) { $newarray = array(); foreach ($data_array as $data) { $newarray[] = array_slice($data, 1); } foreach ($newarray as $item) { $total_resource_weight = $total_resource_weight + $item['2']; } } } if ($total_resource_weight != $total_weight) { Display::display_warning_message(get_lang('SumOfActivitiesWeightMustBeEqualToTotalWeight')); } } $filter = api_get_configuration_value('certificate_filter_by_official_code'); $userList = array(); $filterForm = null; $certificate_list = array(); if ($filter) { echo '<br />'; $options = UserManager::getOfficialCodeGrouped(); $options = array_merge(array('all' => get_lang('All')), $options); $form = new FormValidator('official_code_filter', 'POST', api_get_self() . '?' . api_get_cidreq() . '&cat_id=' . $cat_id); $form->addElement('select', 'filter', get_lang('OfficialCode'), $options); $form->add_button('submit', get_lang('Submit')); $filterForm = '<br />' . $form->return_form(); if ($form->validate()) { $officialCode = $form->getSubmitValue('filter'); if ($officialCode == 'all') { $certificate_list = get_list_users_certificates($cat_id);
/** * Returns returns person name convention for a given language. * @param string $language The input language. * @param string $type The type of the requested convention. * It may be 'format' for name order convention or 'sort_by' for name sorting convention. * @return mixed Depending of the requested type, * the returned result may be string or boolean; null is returned on error; */ function _api_get_person_name_convention($language, $type) { static $conventions; $language = api_purify_language_id($language); if (!isset($conventions)) { $file = dirname(__FILE__) . '/internationalization_database/name_order_conventions.php'; if (file_exists($file)) { $conventions = (include $file); } else { $conventions = array('english' => array('format' => 'title first_name last_name', 'sort_by' => 'first_name')); } // Overwrite classic conventions $customConventions = api_get_configuration_value('name_order_conventions'); if (!empty($customConventions)) { foreach ($customConventions as $key => $data) { $conventions[$key] = $data; } } $search1 = array('FIRST_NAME', 'LAST_NAME', 'TITLE'); $replacement1 = array('%F', '%L', '%T'); $search2 = array('first_name', 'last_name', 'title'); $replacement2 = array('%f', '%l', '%t'); foreach (array_keys($conventions) as $key) { $conventions[$key]['format'] = str_replace($search1, $replacement1, $conventions[$key]['format']); $conventions[$key]['format'] = _api_validate_person_name_format(_api_clean_person_name(str_replace('%', ' %', str_ireplace($search2, $replacement2, $conventions[$key]['format'])))); $conventions[$key]['sort_by'] = strtolower($conventions[$key]['sort_by']) != 'last_name' ? true : false; } } switch ($type) { case 'format': return is_string($conventions[$language]['format']) ? $conventions[$language]['format'] : '%t %f %l'; case 'sort_by': return is_bool($conventions[$language]['sort_by']) ? $conventions[$language]['sort_by'] : true; } return null; }
/** * @param Schema $schema */ public function up(Schema $schema) { $this->addSql('ALTER TABLE user ADD COLUMN last_login datetime DEFAULT NULL'); // calendar events comments $this->addSql("ALTER TABLE c_calendar_event ADD COLUMN comment TEXT"); // Move some settings from configuration.php to the database // Current settings categories are: // Platform, Course, Session, Languages, User, Tools, Editor, Security, // Tuning, Gradebook, Timezones, Tracking, Search, stylesheets (lowercase), // LDAP, CAS, Shibboleth, Facebook // Allow select the return link in the LP view $value = api_get_configuration_value('allow_lp_return_link'); $this->addSettingCurrent('allow_lp_return_link', '', 'radio', 'Course', $value ? $value : 'true', 'AllowLearningPathReturnLinkTitle', 'AllowLearningPathReturnLinkComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // If true the export link is blocked. $value = api_get_configuration_value('hide_scorm_export_link'); $this->addSettingCurrent('hide_scorm_export_link', '', 'radio', 'Course', $value ? $value : 'false', 'HideScormExportLinkTitle', 'HideScormExportLinkComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // If true the copy link is blocked. //$_configuration['hide_scorm_copy_link'] = false; $value = api_get_configuration_value('hide_scorm_copy_link'); $this->addSettingCurrent('hide_scorm_copy_link', '', 'radio', 'Course', $value ? $value : 'false', 'HideScormCopyLinkTitle', 'HideScormCopyLinkComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // If true the pdf export link is blocked. //$_configuration['hide_scorm_pdf_link'] = false; $value = api_get_configuration_value('hide_scorm_pdf_link'); $this->addSettingCurrent('hide_scorm_pdf_link', '', 'radio', 'Course', $value ? $value : 'false', 'HideScormPdfLinkTitle', 'HideScormPdfLinkComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Default session days before coach access //$_configuration['session_days_before_coach_access'] = 0; $value = api_get_configuration_value('session_days_before_coach_access'); $this->addSettingCurrent('session_days_before_coach_access', '', 'textfield', 'Session', $value ? $value : '0', 'SessionDaysBeforeCoachAccessTitle', 'SessionDaysBeforeCoachAccessComment', null, '', 1, true, false); // Default session days after coach access //$_configuration['session_days_after_coach_access'] = 0; $value = api_get_configuration_value('session_days_after_coach_access'); $this->addSettingCurrent('session_days_after_coach_access', '', 'textfield', 'Session', $value ? $value : '0', 'SessionDaysAfterCoachAccessTitle', 'SessionDaysAfterCoachAccessComment', null, '', 1, true, false); // PDF Logo header in app/Resources/public/css/themes/xxx/images/pdf_logo_header.png //$_configuration['pdf_logo_header'] = false; $value = api_get_configuration_value('pdf_logo_header'); $this->addSettingCurrent('pdf_logo_header', '', 'radio', 'Course', $value ? $value : 'false', 'PdfLogoHeaderTitle', 'PdfLogoHeaderComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Order inscription user list by official_code //$_configuration['order_user_list_by_official_code'] = false; $value = api_get_configuration_value('order_user_list_by_official_code'); $this->addSettingCurrent('order_user_list_by_official_code', '', 'radio', 'Platform', $value ? $value : 'false', 'OrderUserListByOfficialCodeTitle', 'OrderUserListByOfficialCodeComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Default course setting "email_alert_manager_on_new_quiz" //$_configuration['email_alert_manager_on_new_quiz'] = 1; $value = api_get_configuration_value('email_alert_manager_on_new_quiz'); $this->addSettingCurrent('email_alert_manager_on_new_quiz', '', 'radio', 'Course', $value ? $value : 'true', 'AlertManagerOnNewQuizTitle', 'AlertManagerOnNewQuizComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Show official code in exercise report list. //$_configuration['show_official_code_exercise_result_list'] = false; $value = api_get_configuration_value('show_official_code_exercise_result_list'); $this->addSettingCurrent('show_official_code_exercise_result_list', '', 'radio', 'Tools', $value ? $value : 'false', 'ShowOfficialCodeInExerciseResultListTitle', 'ShowOfficialCodeInExerciseResultListComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Hide private courses from course catalog //$_configuration['course_catalog_hide_private'] = false; $value = api_get_configuration_value('course_catalog_hide_private'); $this->addSettingCurrent('course_catalog_hide_private', '', 'radio', 'Platform', $value ? $value : 'false', 'HidePrivateCoursesFromCourseCatalogTitle', 'HidePrivateCoursesFromCourseCatalogComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Display sessions catalog // 0 = show only courses; 1 = show only sessions; 2 = show courses and sessions //$_configuration['catalog_show_courses_sessions'] = 0; $value = api_get_configuration_value('catalog_show_courses_sessions'); $this->addSettingCurrent('catalog_show_courses_sessions', '', 'radio', 'Platform', $value ? $value : '0', 'CoursesCatalogueShowSessionsTitle', 'CoursesCatalogueShowSessionsComment', null, '', 1, true, false, [0 => ['value' => '0', 'text' => 'CatalogueShowOnlyCourses'], 1 => ['value' => '1', 'text' => 'CatalogueShowOnlySessions'], 2 => ['value' => '2', 'text' => 'CatalogueShowCoursesAndSessions']]); // Auto detect language custom pages. // $_configuration['auto_detect_language_custom_pages'] = true; $value = api_get_configuration_value('auto_detect_language_custom_pages'); $this->addSettingCurrent('auto_detect_language_custom_pages', '', 'radio', 'Platform', $value ? $value : 'true', 'AutoDetectLanguageCustomPagesTitle', 'AutoDetectLanguageCustomPagesComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Show reduce LP report //$_configuration['lp_show_reduced_report'] = false; $value = api_get_configuration_value('lp_show_reduced_report'); $this->addSettingCurrent('lp_show_reduced_report', '', 'radio', 'Tools', $value ? $value : 'false', 'LearningPathShowReducedReportTitle', 'LearningPathShowReducedReportComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); //Allow session-to-session copy //$_configuration['allow_session_course_copy_for_teachers'] = true; $value = api_get_configuration_value('allow_session_course_copy_for_teachers'); $this->addSettingCurrent('allow_session_course_copy_for_teachers', '', 'radio', 'Session', $value ? $value : 'false', 'AllowSessionCourseCopyForTeachersTitle', 'AllowSessionCourseCopyForTeachersComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Hide the logout button //$_configuration['hide_logout_button'] = true; $value = api_get_configuration_value('hide_logout_button'); $this->addSettingCurrent('hide_logout_button', '', 'radio', 'Security', $value ? $value : 'false', 'HideLogoutButtonTitle', 'HideLogoutButtonComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Prevent redirecting admin to admin page //$_configuration['redirect_admin_to_courses_list'] = true; $value = api_get_configuration_value('redirect_admin_to_courses_list'); $this->addSettingCurrent('redirect_admin_to_courses_list', '', 'radio', 'Platform', $value ? $value : 'false', 'RedirectAdminToCoursesListTitle', 'RedirectAdminToCoursesListComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Shows the custom course icon instead of the classic green board icon //$_configuration['course_images_in_courses_list'] = false; $value = api_get_configuration_value('course_images_in_courses_list'); $this->addSettingCurrent('course_images_in_courses_list', '', 'radio', 'Course', $value ? $value : 'false', 'CourseImagesInCoursesListTitle', 'CourseImagesInCoursesListComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Which student publication will be taken when connected to the gradebook: first|last //$_configuration['student_publication_to_take_in_gradebook'] = 'first'; $value = api_get_configuration_value('student_publication_to_take_in_gradebook'); $this->addSettingCurrent('student_publication_to_take_in_gradebook', '', 'radio', 'Gradebook', $value ? $value : 'first', 'StudentPublicationSelectionForGradebookTitle', 'StudentPublicationSelectionForGradebookComment', null, '', 1, true, false, [0 => ['value' => 'first', 'text' => 'First'], 1 => ['value' => 'last', 'text' => 'Last']]); // Show a filter by official code //$_configuration['certificate_filter_by_official_code'] = false; $value = api_get_configuration_value('certificate_filter_by_official_code'); $this->addSettingCurrent('certificate_filter_by_official_code', '', 'radio', 'Gradebook', $value ? $value : 'false', 'FilterCertificateByOfficialCodeTitle', 'FilterCertificateByOfficialCodeComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Max quantity of fkceditor allowed in the exercise result page otherwise // Textareas are used. //$_configuration['exercise_max_ckeditors_in_page'] = 0; $value = api_get_configuration_value('exercise_max_ckeditors_in_page'); $this->addSettingCurrent('exercise_max_ckeditors_in_page', '', 'textfield', 'Tools', $value ? $value : '0', 'MaxCKeditorsOnExerciseResultsPageTitle', 'MaxCKeditorsOnExerciseResultsPageComment', null, '', 1, true, false, array()); // Default upload option //$_configuration['document_if_file_exists_option'] = 'rename'; // overwrite $value = api_get_configuration_value('document_if_file_exists_option'); $this->addSettingCurrent('document_if_file_exists_option', '', 'radio', 'Tools', $value ? $value : 'rename', 'DocumentDefaultOptionIfFileExistsTitle', 'DocumentDefaultOptionIfFileExistsComment', null, '', 1, true, false, [0 => ['value' => 'rename', 'text' => 'Rename'], 1 => ['value' => 'overwrite', 'text' => 'Overwrite']]); // Enable add_gradebook_certificates.php cron task //$_configuration['add_gradebook_certificates_cron_task_enabled'] = true; $value = api_get_configuration_value('add_gradebook_certificates_cron_task_enabled'); $this->addSettingCurrent('add_gradebook_certificates_cron_task_enabled', '', 'radio', 'Tools', $value ? $value : 'false', 'GradebookCronTaskGenerationTitle', 'GradebookCronTaskGenerationComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Which OpenBadges backpack send the badges //$_configuration['openbadges_backpack'] = 'https://backpack.openbadges.org/'; $value = api_get_configuration_value('openbadges_backpack'); $this->addSettingCurrent('openbadges_backpack', '', 'textfield', 'Gradebook', $value ? $value : 'https://backpack.openbadges.org/', 'OpenBadgesBackpackUrlTitle', 'OpenBadgesBackpackUrlComment', null, '', 1, true, false, []); // Shows a warning message explaining that the site uses cookies //$_configuration['cookie_warning'] = false; $value = api_get_configuration_value('cookie_warning'); $this->addSettingCurrent('cookie_warning', '', 'radio', 'Tools', $value ? $value : 'false', 'CookieWarningTitle', 'CookieWarningComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // If there are any tool available and the user is not registered hide the group //$_configuration['hide_course_group_if_no_tools_available'] = false; $value = api_get_configuration_value('hide_course_group_if_no_tools_available'); $this->addSettingCurrent('hide_course_group_if_no_tools_available', '', 'radio', 'Tools', $value ? $value : 'false', 'HideCourseGroupIfNoToolAvailableTitle', 'HideCourseGroupIfNoToolAvailableComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Allow student to enroll into a session without an approval needing //$_configuration['catalog_allow_session_auto_subscription'] = false; $value = api_get_configuration_value('catalog_allow_session_auto_subscription'); $this->addSettingCurrent('catalog_allow_session_auto_subscription', '', 'radio', 'Session', $value ? $value : 'false', 'CatalogueAllowSessionAutoSubscriptionTitle', 'CatalogueAllowSessionAutoSubscriptionComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Decode UTF-8 from Web Services (option passed to SOAP) //$_configuration['registration.soap.php.decode_utf8'] = false; $value = api_get_configuration_value('registration.soap.php.decode_utf8'); $this->addSettingCurrent('registration.soap.php.decode_utf8', '', 'radio', 'Platform', $value ? $value : 'false', 'SoapRegistrationDecodeUtf8Title', 'SoapRegistrationDecodeUtf8Comment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Show delete option in attendance //$_configuration['allow_delete_attendance'] = false; $value = api_get_configuration_value('allow_delete_attendance'); $this->addSettingCurrent('allow_delete_attendance', '', 'radio', 'Tools', $value ? $value : 'false', 'AttendanceDeletionEnableTitle', 'AttendanceDeletionEnableComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Enable Gravatar profile image if no local image has been given //$_configuration['gravatar_enabled'] = true; $value = api_get_configuration_value('gravatar_enabled'); $this->addSettingCurrent('gravatar_enabled', '', 'radio', 'Platform', $value ? $value : 'false', 'GravatarPicturesTitle', 'GravatarPicturesComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // If Gravatar is enabled, tells which type of picture we want (default is "mm"). // Options: mm | identicon | monsterid | wavatar //$_configuration['gravatar_type'] = 'mm'; $value = api_get_configuration_value('gravatar_type'); $this->addSettingCurrent('gravatar_type', '', 'radio', 'Platform', $value ? $value : 'mm', 'GravatarPicturesTypeTitle', 'GravatarPicturesTypeComment', null, '', 1, true, false, [0 => ['value' => 'mm', 'text' => 'mystery-man'], 1 => ['value' => 'identicon', 'text' => 'identicon'], 2 => ['value' => 'monsterid', 'text' => 'monsterid'], 3 => ['value' => 'wavatar', 'text' => 'wavatar']]); // Limit for the Session Admin role. The administration page show only // User block -> Add user // Course Sessions block -> Training session list //$_configuration['limit_session_admin_role'] = false; $value = api_get_configuration_value('limit_session_admin_role'); $this->addSettingCurrent('limit_session_admin_role', '', 'radio', 'Session', $value ? $value : 'false', 'SessionAdminPermissionsLimitTitle', 'SessionAdminPermissionsLimitComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Show session description //$_configuration['show_session_description'] = false; $value = api_get_configuration_value('show_session_description'); $this->addSettingCurrent('show_session_description', '', 'radio', 'Session', $value ? $value : 'false', 'ShowSessionDescriptionTitle', 'ShowSessionDescriptionComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Hide only for students the link to export certificates to PDF //$_configuration['hide_certificate_export_link_students'] = false; $value = api_get_configuration_value('hide_certificate_export_link_students'); $this->addSettingCurrent('hide_certificate_export_link_students', '', 'radio', 'Gradebook', $value ? $value : 'false', 'CertificateHideExportLinkStudentTitle', 'CertificateHideExportLinkStudentComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Hide for all user roles the link to export certificates to PDF //$_configuration['hide_certificate_export_link'] = false; $value = api_get_configuration_value('hide_certificate_export_link'); $this->addSettingCurrent('hide_certificate_export_link', '', 'radio', 'Gradebook', $value ? $value : 'false', 'CertificateHideExportLinkTitle', 'CertificateHideExportLinkComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Hide session course coach in dropbox sent to user list //$_configuration['dropbox_hide_course_coach'] = false; $value = api_get_configuration_value('dropbox_hide_course_coach'); $this->addSettingCurrent('dropbox_hide_course_coach', '', 'radio', 'Tools', $value ? $value : 'false', 'DropboxHideCourseCoachTitle', 'DropboxHideCourseCoachComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // If SSO is used, the redirection to the master server is forced. //$_configuration['force_sso_redirect'] = false; $value = api_get_configuration_value('force_sso_redirect'); $this->addSettingCurrent('sso_force_redirect', '', 'radio', 'Security', $value ? $value : 'false', 'SSOForceRedirectTitle', 'SSOForceRedirectComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); // Session course ordering in the the session view. // false = alphabetic order (default) // true = based in the session course list //$_configuration['session_course_ordering'] = false; $value = api_get_configuration_value('session_course_ordering'); $this->addSettingCurrent('session_course_ordering', '', 'radio', 'Session', $value ? $value : 'false', 'SessionCourseOrderingTitle', 'SessionCourseOrderingComment', null, '', 1, true, false, [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]); }
$table->set_header($header_nr++, get_lang('LastName')); } else { $indexList['lastname'] = $header_nr; $table->set_header($header_nr++, get_lang('LastName')); $indexList['firstname'] = $header_nr; $table->set_header($header_nr++, get_lang('FirstName')); } $indexList['username'] = $header_nr; $table->set_header($header_nr++, get_lang('LoginName')); $indexList['groups'] = $header_nr; $table->set_header($header_nr++, get_lang('GroupSingle'), false); if (api_is_allowed_to_edit(null, true) && api_get_setting('allow_user_course_subscription_by_course_admin') == 'true') { } else { $table->set_column_filter(0, 'hide_field'); } $hideFields = api_get_configuration_value('hide_user_field_from_list'); if (!empty($hideFields)) { foreach ($hideFields as $fieldToHide) { if (isset($indexList[$fieldToHide])) { $table->setHideColumn($indexList[$fieldToHide]); } } } if (api_is_allowed_to_edit(null, true)) { $table->set_header($header_nr++, get_lang('Status'), false); $table->set_header($header_nr++, get_lang('Active'), false); if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true') { $table->set_column_filter(9, 'active_filter'); } else { $table->set_column_filter(9, 'active_filter'); }
/** * Use the session duration to allow/block user access see BT#8317 * Needs these DB changes * ALTER TABLE session ADD COLUMN duration int; * ALTER TABLE session_rel_user ADD COLUMN duration int; */ public static function durationPerUserIsEnabled() { return api_get_configuration_value('session_duration_feature'); }
if (empty($courses_and_sessions) && !isset($_GET['history'])) { $controller->tpl->assign('welcome_to_course_block', $controller->return_welcome_to_course_block()); } $controller->tpl->assign('content', $courses_and_sessions); if (api_get_setting('allow_browser_sniffer') == 'true') { if ($_SESSION['sniff_navigator']!="checked") { $controller->tpl->assign('show_sniff', 1); } else { $controller->tpl->assign('show_sniff', 0); } } // Display the Site Use Cookie Warning Validation $useCookieValidation = api_get_configuration_value('cookie_warning'); if ($useCookieValidation) { if (isset($_POST['acceptCookies'])) { api_set_site_use_cookie_warning_cookie(); } else { if (!api_site_use_cookie_warning_cookie_exist()) { if (Template::isToolBarDisplayedForUser()) { $controller->tpl->assign('toolBarDisplayed', true); } else { $controller->tpl->assign('toolBarDisplayed', false); } $controller->tpl->assign('displayCookieUsageWarning', true); } } }
} echo '<div class="actions">'; echo '<a href="index.php?' . api_get_cidreq() . $param_gradebook . '&action=attendance_add">' . Display::return_icon('new_attendance_list.png', get_lang('CreateANewAttendance'), '', ICON_SIZE_MEDIUM) . '</a>'; /*echo '<a href="index.php?'.api_get_cidreq().$param_gradebook.'&action=calendar_logins">'. Display::return_icon('attendance_list.png',get_lang('Logins'),'',ICON_SIZE_MEDIUM).'</a>';*/ echo '</div>'; } $attendance = new Attendance(); if ($attendance->get_number_of_attendances() == 0) { $attendance->set_name(get_lang('Attendances')); $attendance->set_description(get_lang('Attendances')); $attendance->attendance_add(); } $table = new SortableTable('attendance_list', array('Attendance', 'get_number_of_attendances'), array('Attendance', 'get_attendance_data'), $default_column); $table->set_additional_parameters($parameters); $table->set_header(0, '', false, array('style' => 'width:20px;')); $table->set_header(1, get_lang('Name'), true); $table->set_header(2, get_lang('Description'), true); $table->set_header(3, get_lang('CountDoneAttendance'), true, array('style' => 'width:90px;')); if (api_is_allowed_to_edit(null, true)) { $table->set_header(4, get_lang('Actions'), false, array('style' => 'text-align:center')); $actions = array('attendance_set_invisible_select' => get_lang('SetInvisible'), 'attendance_set_visible_select' => get_lang('SetVisible')); $allow = api_get_configuration_value('allow_delete_attendance'); if ($allow) { $actions['attendance_delete_select'] = get_lang('DeleteAllSelectedAttendances'); } $table->set_form_actions($actions); } if ($table->get_total_number_of_items() > 0) { $table->display(); }
/** * Warns an user that the portal reach certain limit. * @param string $limitName */ function api_warn_hosting_contact($limitName) { $hostingParams = api_get_configuration_value(1); $email = null; if (!empty($hostingParams)) { if (isset($hostingParams['hosting_contact_mail'])) { $email = $hostingParams['hosting_contact_mail']; } } if (!empty($email)) { $subject = get_lang('HostingWarningReached'); $body = get_lang('PortalName') . ': ' . api_get_path(WEB_PATH) . " \n "; $body .= get_lang('PortalLimitType') . ': ' . $limitName . " \n "; if (isset($hostingParams[$limitName])) { $body .= get_lang('Value') . ': ' . $hostingParams[$limitName]; } api_mail_html(null, $email, $subject, $body); } }
/** * Export HTML content in a ODF document * @param string $html * @param string $name * @param string $format * * @return bool */ public static function htmlToOdt($html, $name, $format = 'odt') { $unoconv = api_get_configuration_value('unoconv.binaries'); if (empty($unoconv)) { return false; } if (!empty($html)) { $fs = new Filesystem(); $paths = ['root_sys' => api_get_path(SYS_PATH), 'path.temp' => api_get_path(SYS_ARCHIVE_PATH)]; $connector = new Connector(); $drivers = new DriversContainer(); $drivers['configuration'] = array('unoconv.binaries' => $unoconv, 'unoconv.timeout' => 60); $tempFilesystem = TemporaryFilesystem::create(); $manager = new Manager($tempFilesystem, $fs); $alchemyst = new Alchemyst($drivers, $manager); $dataFileSystem = new Data($paths, $fs, $connector, $alchemyst); $content = $dataFileSystem->convertRelativeToAbsoluteUrl($html); $filePath = $dataFileSystem->putContentInTempFile($content, api_replace_dangerous_char($name), 'html'); $try = true; while ($try) { try { $convertedFile = $dataFileSystem->transcode($filePath, $format); $try = false; DocumentManager::file_send_for_download($convertedFile, false, $name . '.' . $format); } catch (Exception $e) { // error_log($e->getMessage()); } } } }
/** * Reads exercise information from the data base * * @author Olivier Brouckaert * @param integer $id - exercise Id * * @return boolean - true if exercise exists, otherwise false */ public function read($id) { $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST); $table_lp_item = Database::get_course_table(TABLE_LP_ITEM); $id = intval($id); if (empty($this->course_id)) { return false; } $sql = "SELECT * FROM {$TBL_EXERCISES} WHERE c_id = " . $this->course_id . " AND id = " . $id; $result = Database::query($sql); // if the exercise has been found if ($object = Database::fetch_object($result)) { $this->id = $id; $this->exercise = $object->title; $this->name = $object->title; $this->title = $object->title; $this->description = $object->description; $this->sound = $object->sound; $this->type = $object->type; if (empty($this->type)) { $this->type = ONE_PER_PAGE; } $this->random = $object->random; $this->random_answers = $object->random_answers; $this->active = $object->active; $this->results_disabled = $object->results_disabled; $this->attempts = $object->max_attempt; $this->feedback_type = $object->feedback_type; $this->propagate_neg = $object->propagate_neg; $this->randomByCat = $object->random_by_category; $this->text_when_finished = $object->text_when_finished; $this->display_category_name = $object->display_category_name; $this->pass_percentage = $object->pass_percentage; $this->sessionId = $object->session_id; $this->is_gradebook_locked = api_resource_is_locked_by_gradebook($id, LINK_EXERCISE); $this->review_answers = isset($object->review_answers) && $object->review_answers == 1 ? true : false; $sql = "SELECT lp_id, max_score\n FROM {$table_lp_item}\n WHERE c_id = {$this->course_id} AND\n item_type = '" . TOOL_QUIZ . "' AND\n path = '" . $id . "'"; $result = Database::query($sql); if (Database::num_rows($result) > 0) { $this->exercise_was_added_in_lp = true; $this->lpList = Database::store_result($result, 'ASSOC'); } $this->force_edit_exercise_in_lp = api_get_configuration_value('force_edit_exercise_in_lp'); if ($this->exercise_was_added_in_lp) { $this->edit_exercise_in_lp = $this->force_edit_exercise_in_lp == true; } else { $this->edit_exercise_in_lp = true; } if ($object->end_time != '0000-00-00 00:00:00') { $this->end_time = $object->end_time; } if ($object->start_time != '0000-00-00 00:00:00') { $this->start_time = $object->start_time; } //control time $this->expired_time = $object->expired_time; //Checking if question_order is correctly set $this->questionList = $this->selectQuestionList(true); //overload questions list with recorded questions list //load questions only for exercises of type 'one question per page' //this is needed only is there is no questions /* // @todo not sure were in the code this is used somebody mess with the exercise tool // @todo don't know who add that config and why $_configuration['live_exercise_tracking'] global $_configuration, $questionList; if ($this->type == ONE_PER_PAGE && $_SERVER['REQUEST_METHOD'] != 'POST' && defined('QUESTION_LIST_ALREADY_LOGGED') && isset($_configuration['live_exercise_tracking']) && $_configuration['live_exercise_tracking']) { $this->questionList = $questionList; }*/ return true; } return false; }
/** * Build the modify-column of the table * @param int The user id * @param string URL params to add to table links * @param array Row of elements to alter * @return string Some HTML-code with modify-buttons */ function modify_filter($user_id, $url_params, $row) { global $charset, $_admins_list; $is_admin = in_array($user_id, $_admins_list); $statusname = api_get_status_langvars(); $user_is_anonymous = false; $current_user_status_label = $row['7']; if ($current_user_status_label == $statusname[ANONYMOUS]) { $user_is_anonymous = true; } $result = ''; if (!$user_is_anonymous) { $icon = Display::return_icon('course.png', get_lang('Courses'), array('onmouseout' => 'clear_course_list (\'div_' . $user_id . '\')')); $result .= '<a href="javascript:void(0)" onclick="load_course_list(\'div_' . $user_id . '\',' . $user_id . ')" > ' . $icon . ' <div class="blackboard_hide" id="div_' . $user_id . '"> </div> </a>'; $icon = Display::return_icon('session.png', get_lang('Sessions'), array('onmouseout' => 'clear_session_list (\'div_s_' . $user_id . '\')')); $result .= '<a href="javascript:void(0)" onclick="load_session_list(\'div_s_' . $user_id . '\',' . $user_id . ')" > ' . $icon . ' <div class="blackboard_hide" id="div_s_' . $user_id . '"> </div> </a>'; } else { $result .= Display::return_icon('course_na.png', get_lang('Courses')) . ' '; $result .= Display::return_icon('course_na.png', get_lang('Sessions')) . ' '; } if (api_is_platform_admin()) { if (!$user_is_anonymous) { $result .= '<a href="user_information.php?user_id=' . $user_id . '">' . Display::return_icon('synthese_view.gif', get_lang('Info')) . '</a> '; } else { $result .= Display::return_icon('synthese_view_na.gif', get_lang('Info')) . ' '; } } //only allow platform admins to login_as, or session admins only for students (not teachers nor other admins) if (api_is_platform_admin() || api_is_session_admin() && $current_user_status_label == $statusname[STUDENT]) { if (!$user_is_anonymous) { if (api_global_admin_can_edit_admin($user_id)) { $result .= '<a href="user_list.php?action=login_as&user_id=' . $user_id . '&sec_token=' . $_SESSION['sec_token'] . '">' . Display::return_icon('login_as.png', get_lang('LoginAs')) . '</a> '; } else { $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')) . ' '; } } else { $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')) . ' '; } } else { $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')) . ' '; } if ($current_user_status_label != $statusname[STUDENT]) { $result .= Display::return_icon('statistics_na.gif', get_lang('Reporting')) . ' '; } else { $result .= '<a href="../mySpace/myStudents.php?student=' . $user_id . '">' . Display::return_icon('statistics.gif', get_lang('Reporting')) . '</a> '; } if (api_is_platform_admin(true)) { $editProfileUrl = Display::getProfileEditionLink($user_id, true); if (!$user_is_anonymous && api_global_admin_can_edit_admin($user_id, null, true)) { $result .= '<a href="' . $editProfileUrl . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a> '; } else { $result .= Display::return_icon('edit_na.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a> '; } } if ($is_admin) { $result .= Display::return_icon('admin_star.png', get_lang('IsAdministrator'), array('width' => ICON_SIZE_SMALL, 'heigth' => ICON_SIZE_SMALL)); } else { $result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator')); } // actions for assigning sessions, courses or users if (api_is_session_admin()) { /*if ($row[0] == api_get_user_id()) { $result .= '<a href="dashboard_add_sessions_to_user.php?user='******'">'.Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')).'</a> '; }*/ } else { if ($current_user_status_label == $statusname[SESSIONADMIN]) { $result .= Display::url(Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')), "dashboard_add_sessions_to_user.php?user={$user_id}"); } else { if ($current_user_status_label == $statusname[DRH] || UserManager::is_admin($user_id) || $current_user_status_label == $statusname[STUDENT_BOSS]) { $result .= Display::url(Display::return_icon('user_subscribe_course.png', get_lang('AssignUsers'), '', ICON_SIZE_SMALL), "dashboard_add_users_to_user.php?user={$user_id}"); } if ($current_user_status_label == $statusname[DRH] || UserManager::is_admin($user_id)) { $result .= Display::url(Display::return_icon('course_add.gif', get_lang('AssignCourses')), "dashboard_add_courses_to_user.php?user={$user_id}"); $result .= Display::url(Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')), "dashboard_add_sessions_to_user.php?user={$user_id}"); } } } if (api_is_platform_admin()) { $result .= ' <a href="' . api_get_path(WEB_AJAX_PATH) . 'agenda.ajax.php?a=get_user_agenda&user_id=' . $user_id . '&modal_size=lg" class="agenda_opener ajax">' . Display::return_icon('month.png', get_lang('FreeBusyCalendar'), array(), ICON_SIZE_SMALL) . '</a>'; $deleteAllowed = !api_get_configuration_value('deny_delete_users'); if ($deleteAllowed) { if ($user_id != api_get_user_id() && !$user_is_anonymous && api_global_admin_can_edit_admin($user_id)) { // you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore. $result .= ' <a href="user_list.php?action=delete_user&user_id=' . $user_id . '&' . $url_params . '&sec_token=' . $_SESSION['sec_token'] . '" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)) . "'" . ')) return false;">' . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>'; } else { $result .= Display::return_icon('delete_na.png', get_lang('Delete'), array(), ICON_SIZE_SMALL); } } } return $result; }
// then check if he has also been given access to the corresponding courses $coursesFollowedList = CourseManager::get_courses_followed_by_drh(api_get_user_id()); $coursesFollowedList = array_keys($coursesFollowedList); if (!in_array(api_get_course_id(), $coursesFollowedList)) { api_not_allowed(true); exit; } } } if ($export_csv) { if (!empty($session_id)) { Session::write('id_session', $session_id); } ob_start(); } $columnsToHideFromSetting = api_get_configuration_value('course_log_hide_columns'); $columnsToHide = empty($columnsToHideFromSetting) ? array(0, 8, 9, 10, 11) : $columnsToHideFromSetting; $columnsToHide = json_encode($columnsToHide); $csv_content = array(); // Scripts for reporting array hide/show columns $js = "<script>\n // hide column and display the button to unhide it\n function foldup(in_id) {\n \$('#reporting_table .data_table tr td:nth-child(' + (in_id + 1) + ')').toggleClass('hide');\n \$('#reporting_table .data_table tr th:nth-child(' + (in_id + 1) + ')').toggleClass('hide');\n \$('div#unhideButtons a:nth-child(' + (in_id + 1) + ')').toggleClass('hide');\n }\n\n // add the red cross on top of each column\n function init_hide() {\n \$('#reporting_table .data_table tr th').each(\n function(index) {\n \$(this).prepend(\n '<div style=\"cursor:pointer\" onclick=\"foldup(' + index + ')\">" . Display::return_icon('visible.png', get_lang('HideColumn'), array('align' => 'absmiddle', 'hspace' => '3px'), ICON_SIZE_SMALL) . "</div>'\n );\n }\n );\n }\n\n // hide some column at startup\n // be sure that these columns always exists\n // see headers = array();\n // tab of header texts\n \$(document).ready( function() {\n init_hide();\n var columnsToHide = " . $columnsToHide . ";\n columnsToHide.forEach(function(id) {\n foldup(id);\n });\n })\n </script>"; $htmlHeadXtra[] = "<style type='text/css'>\n .secLine {background-color : #E6E6E6;}\n .content {padding-left : 15px;padding-right : 15px; }\n .specialLink{color : #0000FF;}\n div#reporting_table table th {\n vertical-align:top;\n }\n</style>"; $htmlHeadXtra[] .= $js; // Database table definitions. //@todo remove this calls $TABLETRACK_ACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS); $TABLETRACK_LINKS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LINKS); $TABLETRACK_DOWNLOADS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS); $TABLETRACK_ACCESS_2 = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS); $TABLETRACK_EXERCISES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); $TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$ip = trim($_SERVER['REMOTE_ADDR']); // if we are behind a reverse proxy, assume it will send the // HTTP_X_FORWARDED_FOR header and use this IP instead if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { list($ip1, $ip2) = split(',', $_SERVER['HTTP_X_FORWARDED_FOR']); $ip = trim($ip1); } // Check if a file that limits access from webservices exists and contains // the restraining check if (is_file(api_get_path(WEB_CODE_PATH) . 'webservices/webservice-auth-ip.conf.php')) { include api_get_path(WEB_CODE_PATH) . 'webservices/webservice-auth-ip.conf.php'; if (!empty($ws_auth_ip)) { $check_ip = true; } } $securityKeyFromParam = api_get_configuration_value('security_key'); if ($check_ip) { $security_key = $securityKeyFromParam; } else { $security_key = $ip . $securityKeyFromParam; } /** * End WSHelperVerifyKey */ $params['secret_key'] = sha1($security_key); // Registration soap wsdl $wsUrl = api_get_path(WEB_CODE_PATH) . 'webservices/registration.soap.php?wsdl'; $options = array('location' => $wsUrl, 'uri' => $wsUrl); /** * WS test */
/** * Returns whether we are in a mode where multiple URLs are configured to work * with course categories * @return bool */ function isMultipleUrlSupport() { return api_get_configuration_value('enable_multiple_url_support_for_course_category'); }
* 1. This script creates users everytime the page is executed using the Chamilo Webservices * 2. The username is generated everytime with a random value from 0 to 1000 * 3. The default user extra field (profile) is "uid" is created when calling the WSCreateUserPasswordCrypted for the first time, you can change this value. * In this field your third party user_id will be registered. See the main/admin/user_fields.php to view the current user fields. * 4. You need to create manually a course called Test(with code TEST) After the user was created the new user will be added to this course via webservices. * */ exit; //Uncomment this in order to execute the page //require_once '../inc/global.inc.php'; $libpath = api_get_path(LIBRARY_PATH); // Create the client instance $url = api_get_path(WEB_CODE_PATH) . "webservices/registration.soap.php?wsdl"; //$url = api_get_path(WEB_CODE_PATH)."webservices/access_url.php?wsdl"; // see the main/inc/configuration.php file to get this value $security_key = api_get_configuration_value('security_key'); $client = new nusoap_client($url, true); /*$client->xml_encoding = 'UTF-8'; $client->http_encoding = 'UTF-8'; $client->charencoding = 'UTF-8';*/ $soap_error = $client->getError(); if (!empty($soap_error)) { $error_message = 'Nusoap object creation failed: ' . $soap_error; throw new Exception($error_message); } $client->setDebugLevel(10000); $client->debug_flag = true; // This should be the IP address of the client $ip_address = $_SERVER['SERVER_ADDR']; $ip_address = "192.168.1.54"; $ip_address = "127.0.0.1";
/** * The theme that will be used if the database is not working. * @return string */ public static function getThemeFallback() { $theme = api_get_configuration_value('theme_fallback'); if (empty($theme)) { $theme = 'chamilo'; } return $theme; }
$maker = 'Scorm'; if (!empty($_REQUEST['content_maker'])) { $maker = Database::escape_string($_REQUEST['content_maker']); } switch ($type) { case 'scorm': require_once 'scorm.class.php'; $oScorm = new scorm(); $manifest = $oScorm->import_package($_FILES['user_file'], $current_dir); if (!$manifest) { throw new \Exception('error import package'); } if (!empty($manifest)) { $oScorm->parse_manifest($manifest); $fixTemplate = api_get_configuration_value('learnpath_fix_xerte_template'); $proxyPath = api_get_configuration_value('learnpath_proxy_url'); if ($fixTemplate && !empty($proxyPath)) { // Check organisations: if (isset($oScorm->manifest['organizations'])) { foreach ($oScorm->manifest['organizations'] as $data) { if (strpos(strtolower($data), 'xerte') !== false) { // Check if template.xml exists: $templatePath = str_replace('imsmanifest.xml', 'template.xml', $manifest); if (file_exists($templatePath) && is_file($templatePath)) { $templateContent = file_get_contents($templatePath); $find = array('href="www.', 'href="https://', 'href="http://', 'url="www.', 'pdfs/download.php?'); $replace = array('href="http://www.', 'target = "_blank" href="' . $proxyPath . '?type=link&src=https://', 'target = "_blank" href="' . $proxyPath . '?type=link&src=http://', 'url="http://www.', 'pdfs/download.php&'); $templateContent = str_replace($find, $replace, $templateContent); file_put_contents($templatePath, $templateContent); } // Fix link generation: