Partial move of settings from configuration.php to table settings_current - refs #7538

1.10.x
Yannick Warnier 10 years ago
parent fbce1a11a2
commit e7e854f23d
  1. 5
      main/admin/user_add.php
  2. 6
      main/auth/inscription.php
  3. 3
      main/auth/profile.php
  4. 20
      main/inc/lib/api.lib.php
  5. 5
      main/inc/lib/course.lib.php
  6. 14
      main/inc/lib/userportal.lib.php
  7. 5
      main/inc/local.inc.php
  8. 24
      main/install/configuration.dist.php
  9. 18
      main/install/data.sql
  10. 2
      main/install/database.sql
  11. 3
      main/user/add_users_to_session.php
  12. 3
      main/user/resume_session.php
  13. 3
      main/user/session_list.php
  14. 5
      main/user/user.php
  15. 217
      src/Chamilo/CoreBundle/Migrations/Schema/V110/Version20150507152600.php

@ -22,7 +22,8 @@ $htmlHeadXtra[] = api_get_password_checker_js('#username', '#password');
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/tag/jquery.fcbkcomplete.js" type="text/javascript" language="javascript"></script>';
$htmlHeadXtra[] = '<link href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/tag/style.css" rel="stylesheet" type="text/css" />';
if (isset($_configuration['allow_strength_pass_checker']) && $_configuration['allow_strength_pass_checker']) {
$checkPass = api_get_setting('allow_strength_pass_checker');
if ($checkPass == 'true') {
$htmlHeadXtra[] = '
<script>
$(document).ready(function() {
@ -183,7 +184,7 @@ $group[] = $form->createElement('password', 'password', null, array('id'=> 'pass
$form->addGroup($group, 'password', get_lang('Password'), '');
if (isset($_configuration['allow_strength_pass_checker']) && $_configuration['allow_strength_pass_checker']) {
if ($checkPass) {
$form->addElement('label', null, '<div id="password_progress" style="display:none"></div>');
}

@ -109,7 +109,8 @@ if ($user_already_registered_show_terms == false) {
// PASSWORD
$form->addElement('password', 'pass1', get_lang('Pass'), array('id' => 'pass1', 'size' => 20, 'autocomplete' => 'off'));
if (isset($_configuration['allow_strength_pass_checker']) && $_configuration['allow_strength_pass_checker']) {
$checkPass = api_get_setting('allow_strength_pass_checker');
if ($checkPass == 'true') {
$form->addElement('label', null, '<div id="password_progress"></div>');
}
@ -150,7 +151,8 @@ if ($user_already_registered_show_terms == false) {
$form->addElement('radio', 'status', null, get_lang('RegAdmin'), COURSEMANAGER);
}
$allowCaptcha = isset($_configuration['allow_captcha']) ? $_configuration['allow_captcha'] : false;
$captcha = api_get_setting('allow_captcha');
$allowCaptcha = $captcha == 'true';
if ($allowCaptcha) {
$ajax = api_get_path(WEB_AJAX_PATH).'form.ajax.php?a=get_captcha';

@ -255,7 +255,8 @@ if (is_platform_authentication() && is_profile_editable() && api_get_setting('pr
$form->addElement('password', 'password0', array(get_lang('Pass'), get_lang('Enter2passToChange')), array('size' => 40));
$form->addElement('password', 'password1', get_lang('NewPass'), array('id'=> 'password1', 'size' => 40));
if (isset($_configuration['allow_strength_pass_checker']) && $_configuration['allow_strength_pass_checker']) {
$checkPass = api_get_setting('allow_strength_pass_checker');
if ($checkPass == 'true') {
$form->addElement('label', null, '<div id="password_progress"></div>');
}
$form->addElement('password', 'password2', get_lang('Confirmation'), array('size' => 40));

@ -994,15 +994,11 @@ function api_is_facebook_auth_activated() {
* Return the $_configuration of displaying group forum in the general forum tool of a course or not
* is true by default
* @return bool
* @todo : in 1.10 replace this with a platform parameter in the database
*/
function apiGetDisplayGroupsForumInGeneralTool() {
global $_configuration;
if (isset($_configuration['display_groups_forum_in_general_tool'])) {
return $_configuration['display_groups_forum_in_general_tool'];
}
return true;
$a = api_get_setting('display_groups_forum_in_general_tool');
return $a == 'true';
}
/**
@ -7131,7 +7127,8 @@ function api_get_user_info_from_official_code($official_code = '')
function api_get_password_checker_js($usernameInputId, $passwordInputid)
{
global $_configuration;
$useStrengthPassChecker = isset($_configuration['allow_strength_pass_checker']) ? $_configuration['allow_strength_pass_checker'] : false;
$checkPass = api_get_setting('allow_strength_pass_checker');
$useStrengthPassChecker = $checkPass == 'true';
if ($useStrengthPassChecker == false) {
return null;
@ -7195,7 +7192,7 @@ function api_block_account_captcha($username)
return false;
}
global $_configuration;
$minutesToBlock = isset($_configuration['captcha_time_to_block']) ? $_configuration['captcha_time_to_block'] : 10;
$minutesToBlock = api_get_setting('captcha_time_to_block');
$time = time() + $minutesToBlock*60;
UserManager::update_extra_field_value($userInfo['user_id'], 'captcha_blocked_until_date', api_get_utc_datetime($time));
}
@ -7270,11 +7267,8 @@ function api_remove_tags_with_space($in_html, $in_double_quote_replace = true) {
*/
function api_drh_can_access_all_session_content()
{
global $_configuration;
if (isset($_configuration['drh_can_access_all_session_content'])) {
return $_configuration['drh_can_access_all_session_content'];
}
return false;
$a = api_get_setting('drh_can_access_all_session_content');
return $a == 'true';
}
/**

@ -124,13 +124,14 @@ class CourseManager
}
// If parameter defined, copy the contents from a specific
// template course into this new course
if (!empty($_configuration['course_creation_use_template'])) {
$template = api_get_setting('course_creation_use_template');
if (!empty($template)) {
// Include the necessary libraries to generate a course copy
require_once api_get_path(SYS_CODE_PATH) . 'coursecopy/classes/CourseBuilder.class.php';
require_once api_get_path(SYS_CODE_PATH) . 'coursecopy/classes/CourseRestorer.class.php';
require_once api_get_path(SYS_CODE_PATH) . 'coursecopy/classes/CourseSelectForm.class.php';
// Call the course copy object
$originCourse = api_get_course_info_by_id($_configuration['course_creation_use_template']);
$originCourse = api_get_course_info_by_id($template);
$originCourse['official_code'] = $originCourse['code'];
$cb = new CourseBuilder(null, $originCourse);
$course = $cb->build(null, $originCourse['code']);

@ -92,7 +92,11 @@ class IndexManager
}
function return_announcements($show_slide = true) {
// Display System announcements
//// Display System announcements
$hideAnnouncements = api_get_setting('hide_global_announcements_when_not_connected');
if ($hideAnnouncements == 'true' && empty($userId)) {
return null;
}
$announcement = isset($_GET['announcement']) ? $_GET['announcement'] : null;
$announcement = intval($announcement);
@ -234,9 +238,8 @@ class IndexManager
$html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
} else {
// Hiding home top when user not connected.
if (isset($_configuration['hide_home_top_when_connected']) &&
$_configuration['hide_home_top_when_connected'] && !empty($userId)
) {
$hideTop = api_get_setting('hide_home_top_when_connected');
if ($hideTop == 'true' && !empty($userId)) {
return $html;
}
@ -747,7 +750,8 @@ class IndexManager
global $_configuration;
// Captcha
$allowCaptcha = isset($_configuration['allow_captcha']) ? $_configuration['allow_captcha'] : false;
$captcha = api_get_setting('allow_captcha');
$allowCaptcha = $captcha == 'true';
if ($allowCaptcha) {
$useCaptcha = isset($_SESSION['loginFailed']) ? $_SESSION['loginFailed'] : null;

@ -250,7 +250,8 @@ if (!empty($_SESSION['_user']['user_id']) && !($login || $logout)) {
$result = Database::query($sql);
$captchaValidated = true;
$allowCaptcha = isset($_configuration['allow_captcha']) ? $_configuration['allow_captcha'] : false;
$captcha = api_get_setting('allow_captcha');
$allowCaptcha = $captcha == 'true';
if (Database::num_rows($result) > 0) {
$uData = Database::fetch_array($result, 'ASSOC');
@ -448,7 +449,7 @@ if (!empty($_SESSION['_user']['user_id']) && !($login || $logout)) {
$_SESSION['loginFailedCount'] = 1;
}
$numberMistakesToBlockAccount = isset($_configuration['captcha_number_mistakes_to_block_account']) ? $_configuration['captcha_number_mistakes_to_block_account'] : 10;
$numberMistakesToBlockAccount = api_get_setting('captcha_number_mistakes_to_block_account');
if (isset($_SESSION['loginFailedCount'])) {
if ($_SESSION['loginFailedCount'] >= $numberMistakesToBlockAccount) {

@ -159,32 +159,12 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
/**
* Settings to be included as settings_current in future versions
*/
// Hide the main home section for connected users (to show announcements instead)
//$_configuration['hide_home_top_when_connected'] = true;
// Hide the global announcements for non-connected users
//$_configuration['hide_global_announcements_when_not_connected'] = true;
// Use this course as template for all new courses (define course real ID as value)
//$_configuration['course_creation_use_template'] = 14;
// Uncomment the following to prevent all admins to use the "login as" feature
//$_configuration['login_as_forbidden_globally'] = true;
// Add password strength checker
//$_configuration['allow_strength_pass_checker'] = true;
// Enable captcha
//$_configuration['enable_captcha'] = true;
//$_configuration['allow_captcha'] = true;
// 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;
// Prevent account from logging in for the specified number of minutes
//$_configuration['captcha_time_to_block'] = 5;//minutes
// Allow DRH role to access all content and users from the sessions he follows
//$_configuration['drh_can_access_all_session_content'] = true;
// Display group's forum in general forum tool
//$_configuration['display_groups_forum_in_general_tool'] = true;
// Boost query on last connection time
//$_configuration['save_user_last_login'] = true;
// Allow course tutors in sessions to add existing students to their session
//$_configuration['allow_tutors_to_assign_students_to_session'] = 'false';
// Allow select the return link in the LP view
//$_configuration['allow_lp_return_link'] = false;
// If true the export link is blocked.

@ -1627,4 +1627,20 @@ INSERT INTO sequence_type_entity VALUES
(2,'Quiz', 'Quiz and Tests','c_quiz'),
(3,'LpItem', 'Items of a Learning Path','c_lp_item');
UPDATE settings_current SET selected_value = '1.10.0.37' WHERE variable = 'chamilo_database_version';
-- Version 1.10.0.40
INSERT INTO settings_current
(variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable)
VALUES
('hide_home_top_when_connected', '', 'radio', 'Platform', 'false', 'HideHomeTopContentWhenLoggedInText', 'HideHomeTopContentWhenLoggedInComment', NULL, '', true),
('hide_global_announcements_when_not_connected','','radio','Platform','true', 'HideGlobalAnnouncementsWhenNotLoggedInText','HideGlobalAnnouncementsWhenNotLoggedInComment',NULL,'', true),
('course_creation_use_template','','radio','Course','','CourseCreationUsesTemplateText','CourseCreationUsesTemplateComment',NULL,'',true),
('allow_strength_pass_checker','','radio','Security','true','EnablePasswordStrengthCheckerText','EnablePasswordStrengthCheckerComment',NULL,'',true),
('allow_captcha','','radio','Security','true','EnableCaptchaText','EnableCaptchaComment',NULL,'',true),
('captcha_number_mistakes_to_block_account','','text','Security',5,'CaptchaNumberOfMistakesBeforeBlockingAccountText','CaptchaNumberOfMistakesBeforeBlockingAccountComment',NULL,'',true),
('captcha_time_to_block','','text','Security',5,'CaptchaTimeAccountIsLockedText','CaptchaTimeAccountIsLockedComment',NULL,'',true),
('drh_can_access_all_session_content','','radio','Session','true','DRHAccessToAllSessionContentText','DRHAccessToAllSessionContentComment',NULL,'',true),
('display_groups_forum_in_general_tool','','radio','Tools','true','ShowGroupForaInGeneralToolText','ShowGroupForaInGeneralToolComment',NULL,'',true),
('allow_tutors_to_assign_students_to_session','','radio','Session','false','TutorsCanAssignStudentsToSessionsText','TutorsCanAssignStudentsToSessionsComment',NULL,'',true);
UPDATE settings_current SET selected_value = '1.10.0.39' WHERE variable = 'chamilo_database_version';

@ -4603,5 +4603,5 @@ CREATE TABLE c_attendance_calendar_rel_group (
-- Version
LOCK TABLES settings_current WRITE;
UPDATE settings_current SET selected_value = '1.10.0.36' WHERE variable = 'chamilo_database_version';
UPDATE settings_current SET selected_value = '1.10.0.39' WHERE variable = 'chamilo_database_version';
UNLOCK TABLES;

@ -26,7 +26,8 @@ if (api_is_platform_admin()) {
$interbreadcrumb[] = array('url' => 'session_list.php','name' => get_lang('SessionList'));
$interbreadcrumb[] = array('url' => "resume_session.php?id_session=".$id_session,"name" => get_lang('SessionOverview'));
}
if($_configuration['allow_tutors_to_assign_students_to_session'] == 'true') {
$allowTutors = api_get_setting('allow_tutors_to_assign_students_to_session');
if($allowTutors == 'true') {
// Database Table Definitions
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);

@ -18,7 +18,8 @@ SessionManager::protect_teacher_session_edit($id_session);
$tool_name = get_lang('SessionOverview');
if($_configuration['allow_tutors_to_assign_students_to_session'] == 'true') {
$allowTutors = api_get_setting('allow_tutors_to_assign_students_to_session');
if($allowTutors == 'true') {
// Database Table Definitions
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_rel_class = Database::get_main_table(TABLE_MAIN_SESSION_CLASS);

@ -23,7 +23,8 @@ $idChecked = $_REQUEST['idChecked'];
$tool_name = get_lang('SessionList');
Display::display_header($tool_name);
if($_configuration['allow_tutors_to_assign_students_to_session'] == 'true') {
$allowTutors = api_get_setting('allow_tutors_to_assign_students_to_session');
if($allowTutors == 'true') {
$error_message = ''; // Avoid conflict with the global variable $error_msg (array type) in add_course.conf.php.
if (isset($_GET['action']) && $_GET['action'] == 'show_message') {

@ -507,9 +507,8 @@ if (api_is_allowed_to_edit(null, true)) {
$actions .= ' <a class="btn btn-default" href="class.php?'.api_get_cidreq().'">'.get_lang('Classes').'</a>';
}
if (api_is_allowed_to_edit() &&
isset($_configuration['allow_tutors_to_assign_students_to_session']) &&
$_configuration['allow_tutors_to_assign_students_to_session'] == 'true') {
$allowTutors = api_get_setting('allow_tutors_to_assign_students_to_session');
if (api_is_allowed_to_edit() && $allowTutors == 'true') {
$actions .= ' <a class="btn btn-default" href="session_list.php?'.api_get_cidreq().'">'.get_lang('Sessions').'</a>';
}

@ -0,0 +1,217 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Migrations\Schema\V110;
use Chamilo\CoreBundle\Entity\SettingsCurrent;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20150507152600
*
* @package Chamilo\CoreBundle\Migrations\Schema\v1
*/
class Version20150507152600 extends AbstractMigrationChamilo
{
/**
* @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,
'',
null,
true,
null,
[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,
'',
null,
true,
null,
[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',
'',
'radio',
'Course',
($value?$value:''),
'CourseCreationUsesTemplateText',
'CourseCreationUsesTemplateComment',
null,
'',
null,
true,
null,
[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,
'',
null,
true,
null,
[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,
'',
null,
true,
null,
[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',
'',
'text',
'Security',
($value?$value:5),
'CaptchaNumberOfMistakesBeforeBlockingAccountText',
'CaptchaNumberOfMistakesBeforeBlockingAccountComment',
null,
'',
null,
true,
null
);
// 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',
'',
'text',
'Security',
($value?$value:5),
'CaptchaTimeAccountIsLockedText',
'CaptchaTimeAccountIsLockedComment',
null,
'',
null,
true,
null
);
// 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,
'',
null,
true,
null,
[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,
'',
null,
true,
null,
[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,
'',
null,
true,
null,
[0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
);
}
/**
* We don't allow downgrades yet
* @param Schema $schema
*/
public function down(Schema $schema)
{
}
}
Loading…
Cancel
Save