From f36cf60988ff94e1e2c6d4964ad8d30d5730a55b Mon Sep 17 00:00:00 2001 From: Julio Date: Thu, 20 Sep 2018 09:36:15 +0200 Subject: [PATCH] Remove unused config settings #2682 --- .codeclimate.yml | 1 - main/announcements/announcements.php | 2 +- main/document/document.php | 2 +- main/exercise/exercise.class.php | 2 +- main/inc/lib/api.lib.php | 2 +- main/inc/lib/document.lib.php | 2 +- main/inc/lib/template.lib.php | 5 +- main/inc/lib/userportal.lib.php | 2 +- main/install/configuration.dist.php | 83 ++----------------- main/install/index.php | 1 - main/lp/learnpath.class.php | 2 +- main/session/index.php | 3 +- src/CoreBundle/Menu/LeftMenuBuilder.php | 3 +- src/CoreBundle/Resources/config/services.yml | 10 +++ .../Settings/AnnouncementSettingsSchema.php | 2 + .../Settings/CertificateSettingsSchema.php | 46 ++++++++++ .../Settings/CourseSettingsSchema.php | 2 + .../Settings/DisplaySettingsSchema.php | 3 +- .../Settings/ExerciseSettingsSchema.php | 1 + .../Settings/LearningPathSettingsSchema.php | 46 ++++++++++ .../Settings/SessionSettingsSchema.php | 3 + 21 files changed, 131 insertions(+), 92 deletions(-) create mode 100644 src/CoreBundle/Settings/CertificateSettingsSchema.php create mode 100644 src/CoreBundle/Settings/LearningPathSettingsSchema.php diff --git a/.codeclimate.yml b/.codeclimate.yml index bf1b0df348..4ade345150 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -64,7 +64,6 @@ plugins: exclude_patterns: - var/cache/ - var/log/ - - app/config/ - config/ - app/SymfonyRequirements.php - app/Migrations/ diff --git a/main/announcements/announcements.php b/main/announcements/announcements.php index 7374f82f18..4a193d654f 100755 --- a/main/announcements/announcements.php +++ b/main/announcements/announcements.php @@ -539,7 +539,7 @@ switch ($action) { $form->addCheckBox('send_to_users_in_session', null, get_lang('SendToUsersInSessions')); } - $config = api_get_configuration_value('announcements_hide_send_to_hrm_users'); + $config = api_get_configuration_value('announcement.hide_send_to_hrm_users'); if ($config === false) { $form->addCheckBox('send_to_hrm_users', null, get_lang('SendAnnouncementCopyToDRH')); diff --git a/main/document/document.php b/main/document/document.php index d5d39ca19e..7f2a9adf85 100755 --- a/main/document/document.php +++ b/main/document/document.php @@ -399,7 +399,7 @@ switch ($action) { $orientation = in_array($certificateOrientation, ['landscape', 'portrait']) ? $certificateOrientation : 'landscape'; - $showHeaderAndFooter = !api_get_configuration_value('hide_header_footer_in_certificate'); + $showHeaderAndFooter = !api_get_configuration_value('certificate.hide_header_footer') === 'true'; } DocumentManager::export_to_pdf($document_id, $course_code, $orientation, $showHeaderAndFooter); diff --git a/main/exercise/exercise.class.php b/main/exercise/exercise.class.php index e3d17bedf2..598f807504 100755 --- a/main/exercise/exercise.class.php +++ b/main/exercise/exercise.class.php @@ -216,7 +216,7 @@ class Exercise $this->lpList = Database::store_result($result, 'ASSOC'); } - $this->force_edit_exercise_in_lp = api_get_configuration_value('force_edit_exercise_in_lp'); + $this->force_edit_exercise_in_lp = api_get_setting('lp.show_invisible_exercise_in_lp_toc') === 'true'; if ($this->exercise_was_added_in_lp) { $this->edit_exercise_in_lp = $this->force_edit_exercise_in_lp == true; diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php index c2cec1ade4..1f7b1651bc 100644 --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -8436,7 +8436,7 @@ function api_warn_hosting_contact($limitName) } /** - * Gets value of a variable from app/config/configuration.php + * Gets value of a variable from config/configuration.php * Variables that are not set in the configuration.php file but set elsewhere: * - virtual_css_theme_folder (vchamilo plugin) * - access_url (global.inc.php) diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index 4d6d951bb5..67063e0b5c 100644 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -341,7 +341,7 @@ class DocumentManager return true; } else { // no forced download, just let the browser decide what to do according to the mimetype - $lpFixedEncoding = api_get_configuration_value('lp_fixed_encoding'); + $lpFixedEncoding = api_get_setting('lp.fixed_encoding') === 'true'; // Commented to let courses content to be cached in order to improve performance: //header('Expires: Wed, 01 Jan 1990 00:00:00 GMT'); diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php index 2d3edf361a..a4a42516d8 100755 --- a/main/inc/lib/template.lib.php +++ b/main/inc/lib/template.lib.php @@ -117,7 +117,7 @@ class Template //$this->set_header_parameters($sendHeaders); //$this->set_footer_parameters(); - $defaultStyle = api_get_configuration_value('default_template'); + $defaultStyle = api_get_setting('display.default_template'); if (!empty($defaultStyle)) { $this->templateFolder = $defaultStyle; } @@ -1293,6 +1293,7 @@ class Template /** * Set header parameters. + * @deprecated * * @param bool $sendHeaders send headers */ @@ -1417,7 +1418,7 @@ class Template $this->assign('pending_survey_url', $pendingSurveyLink); // Certificate Link - $allow = api_get_configuration_value('hide_my_certificate_link'); + $allow = api_get_configuration_value('certificate.hide_my_certificate_link'); if ($allow === false) { $certificateUrl = api_get_path(WEB_CODE_PATH).'gradebook/my_certificates.php'; $certificateLink = Display::url( diff --git a/main/inc/lib/userportal.lib.php b/main/inc/lib/userportal.lib.php index 80b17f4fac..849ea166a1 100755 --- a/main/inc/lib/userportal.lib.php +++ b/main/inc/lib/userportal.lib.php @@ -246,7 +246,7 @@ class IndexManager $items = []; if (!api_is_anonymous() && - api_get_configuration_value('hide_my_certificate_link') === false + api_get_setting('certificate.hide_my_certificate_link') === 'false' ) { $items[] = [ 'icon' => Display::return_icon('graduation.png', get_lang('MyCertificates')), diff --git a/main/install/configuration.dist.php b/main/install/configuration.dist.php index 026de8d5cd..82a0acdbc2 100755 --- a/main/install/configuration.dist.php +++ b/main/install/configuration.dist.php @@ -26,24 +26,12 @@ /** * Database connection settings. */ -// Database host -$_configuration['db_host'] = '{DATABASE_HOST}'; -// Database port -$_configuration['db_port'] = '{DATABASE_PORT}'; -// Database name -$_configuration['main_database'] = '{DATABASE_MAIN}'; -// Database username -$_configuration['db_user'] = '{DATABASE_USER}'; -// Database password -$_configuration['db_password'] = '{DATABASE_PASSWORD}'; // Enable access to database management for platform admins. $_configuration['db_manager_enabled'] = false; /** * Directory settings. */ -// URL to the root of your Chamilo installation, e.g.: http://www.mychamilo.com/ -$_configuration['root_web'] = '{ROOT_WEB}'; // Path to the webroot of system, example: /var/www/ $_configuration['root_sys'] = '{ROOT_SYS}'; @@ -52,29 +40,6 @@ $_configuration['root_sys'] = '{ROOT_SYS}'; // example: chamilo (this means chamilo is installed in /var/www/chamilo/ $_configuration['url_append'] = '{URL_APPEND_PATH}'; -/** - * Login modules settings. - */ -// CAS IMPLEMENTATION -// -> Go to your portal Chamilo > Administration > CAS to activate CAS -// You can leave these lines uncommented even if you don't use CAS authentification -//$extAuthSource["cas"]["login"] = $_configuration['root_sys']."main/auth/cas/login.php"; -//$extAuthSource["cas"]["newUser"] = $_configuration['root_sys']."main/auth/cas/newUser.php"; - -// NEW LDAP IMPLEMENTATION BASED ON external_login info -// -> Uncomment the two lines bellow to activate LDAP AND edit main/auth/external_login/ldap.conf.php for configuration -// $extAuthSource["extldap"]["login"] = $_configuration['root_sys']."main/auth/external_login/login.ldap.php"; -// $extAuthSource["extldap"]["newUser"] = $_configuration['root_sys']."main/auth/external_login/newUser.ldap.php"; -// -// FACEBOOK IMPLEMENTATION BASED ON external_login info -// -> Uncomment the line bellow to activate Facebook Auth AND edit app/config/auth.conf.php for configuration -// $_configuration['facebook_auth'] = 1; -// -// OTHER EXTERNAL LOGIN INFORMATION -// To fetch external login information, uncomment those 2 lines and modify files auth/external_login/newUser.php and auth/external_login/updateUser.php files -// $extAuthSource["external_login"]["newUser"] = $_configuration['root_sys']."main/auth/external_login/newUser.php"; -// $extAuthSource["external_login"]["updateUser"] = $_configuration['root_sys']."main/auth/external_login/updateUser.php"; - /** * Hosting settings - Allows you to set limits to the Chamilo portal when * hosting it for a third party. These settings can be overwritten by an @@ -150,8 +115,6 @@ $_configuration['cdn'] = [ $_configuration['security_key'] = '{SECURITY_KEY}'; // Hash function method $_configuration['password_encryption'] = '{ENCRYPT_PASSWORD}'; -// You may have to restart your web server if you change this -$_configuration['session_stored_in_db'] = false; // Session lifetime $_configuration['session_lifetime'] = SESSION_LIFETIME; // Activation for multi-url access @@ -173,35 +136,10 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE; */ // Uncomment the following to prevent all admins to use the "login as" feature //$_configuration['login_as_forbidden_globally'] = true; -// If session_stored_in_db is false, an alternative session storage mechanism -// can be used, which allows for a volatile storage in Memcache, and a more -// permanent "backup" storage in the database, every once in a while (see -// frequency). This is generally used in HA clusters configurations -// This requires memcache or memcached and the php5-memcache module to be setup -//$_configuration['session_stored_in_db_as_backup'] = true; -// Define the different memcache servers available -//$_configuration['memcache_server'] = array( -// 0 => array( -// 'host' => 'chamilo8', -// 'port' => '11211', -// ), -// 1 => array( -// 'host' => 'chamilo9', -// 'port' => '11211', -// ), -//); -// Define the frequency to which the data must be stored in the database -//$_configuration['session_stored_after_n_times'] = 10; + // If the database is down this css style will be used to show the errors. //$_configuration['theme_fallback'] = 'chamilo'; // (chamilo theme) -// The default template that will be use in the system. -//$_configuration['default_template'] = 'default'; // (main/template/default) -// Hide fields in the main/user/user.php page //$_configuration['hide_user_field_from_list'] = ['fields' => ['username']]; -// Aspell Settings -//$_configuration['aspell_bin'] = '/usr/bin/hunspell'; -//$_configuration['aspell_opts'] = '-a -d en_GB -H -i utf-8'; -//$_configuration['aspell_temp_dir'] = './'; // Custom name_order_conventions //$_configuration['name_order_conventions'] = array( // 'french' => array('format' => 'title last_name first_name', 'sort_by' => 'last_name') @@ -239,34 +177,25 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE; 'birthday' ] ];*/ -// Boost option to ignore encoding check for learning paths -//$_configuration['lp_fixed_encoding'] = 'false'; + // Fix urls changing http with https in scorm packages. //$_configuration['lp_replace_http_to_https'] = false; // Fix embedded videos inside lps, adding an optional popup //$_configuration['lp_fix_embed_content'] = false; // Manage deleted files marked with "DELETED" (by course and only by allowed by admin) //$_configuration['document_manage_deleted_files'] = false; -// Hide tabs in the main/session/index.php page -//$_configuration['session_hide_tab_list'] = array(); -// Show invisible exercise in LP list -//$_configuration['show_invisible_exercise_in_lp_list'] = false; + // Chamilo is installed/downloaded. Packagers can change this // to reflect their packaging method. The default value is 'chamilo'. This will // be reflected on the https://version.chamilo.org/stats page in the future. //$_configuration['packager'] = 'chamilo'; -// If true exercises added in LP can be modified. -//$_configuration['force_edit_exercise_in_lp'] = false; + // List of driver to plugin in ckeditor //$_configuration['editor_driver_list'] = ['PersonalDriver', 'CourseDriver']; -// Hide send to hrm users options in announcements -//$_configuration['announcements_hide_send_to_hrm_users'] = true; -// Hide certificate link in index/userportal pages -//$_configuration['hide_my_certificate_link'] = false; + // Hide header and footer in certificate pdf //$_configuration['hide_header_footer_in_certificate'] = false; -// Security: block direct access from logged in users to contents in OPEN (but not public) courses. Set to true to block -//$_configuration['block_registered_users_access_to_open_course_contents'] = false; + // Allows syncing the database with the current entity schema //$_configuration['sync_db_with_schema'] = false; // When exporting a LP, all files and folders in the same path of an html will be exported too. diff --git a/main/install/index.php b/main/install/index.php index 555c267062..b4ce3bbb1d 100755 --- a/main/install/index.php +++ b/main/install/index.php @@ -558,7 +558,6 @@ if (@$_POST['step2']) { } // For version 1.9 - $urlForm = $_configuration['root_web']; $encryptPassForm = get_config_param('password_encryption'); // Managing the $encryptPassForm if ($encryptPassForm == '1') { diff --git a/main/lp/learnpath.class.php b/main/lp/learnpath.class.php index f7c99cce9f..c5b0b8f057 100755 --- a/main/lp/learnpath.class.php +++ b/main/lp/learnpath.class.php @@ -10116,7 +10116,7 @@ class learnpath $tbl_doc = Database::get_course_table(TABLE_DOCUMENT); $tbl_quiz = Database::get_course_table(TABLE_QUIZ_TEST); $condition_session = api_get_session_condition($session_id, true, true); - $setting = api_get_configuration_value('show_invisible_exercise_in_lp_list'); + $setting = api_get_setting('lp.show_invisible_exercise_in_lp_toc') === 'true'; $activeCondition = ' active <> -1 '; if ($setting) { diff --git a/main/session/index.php b/main/session/index.php index 0166f25109..73c787949f 100755 --- a/main/session/index.php +++ b/main/session/index.php @@ -652,9 +652,10 @@ $tabs = [ $reportingTab, ]; -$tabToHide = api_get_configuration_value('session_hide_tab_list'); +$tabToHide = api_get_setting('session.hide_tab_list'); if (!empty($tabToHide)) { + $tabToHide = explode(',', $tabToHide); foreach ($tabToHide as $columnId) { unset($headers[$columnId]); unset($tabs[$columnId]); diff --git a/src/CoreBundle/Menu/LeftMenuBuilder.php b/src/CoreBundle/Menu/LeftMenuBuilder.php index 01ef4f4fca..13b948511c 100644 --- a/src/CoreBundle/Menu/LeftMenuBuilder.php +++ b/src/CoreBundle/Menu/LeftMenuBuilder.php @@ -343,8 +343,7 @@ class LeftMenuBuilder implements ContainerAwareInterface $checker = $this->container->get('security.authorization_checker'); $translator = $this->container->get('translator'); $settingsManager = $this->container->get('chamilo.settings.manager'); - //$allow = $settingsManager->getSetting('hide_my_certificate_link'); - $allow = api_get_configuration_value('hide_my_certificate_link'); + $allow = $settingsManager->getSetting('certificate.hide_my_certificate_link'); $menu = $factory->createItem('root'); if ($checker->isGranted('IS_AUTHENTICATED_FULLY')) { diff --git a/src/CoreBundle/Resources/config/services.yml b/src/CoreBundle/Resources/config/services.yml index 28a878134e..c2c6b989d2 100644 --- a/src/CoreBundle/Resources/config/services.yml +++ b/src/CoreBundle/Resources/config/services.yml @@ -266,6 +266,11 @@ services: tags: - {name: sylius.settings_schema, alias: chamilo_core.settings.cas, namespace: cas} + chamilo_core.settings.certificate: + class: Chamilo\CoreBundle\Settings\CertificateSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.certificate, namespace: certificate} + chamilo_core.settings.chat: class: Chamilo\CoreBundle\Settings\ChatSettingsSchema tags: @@ -334,6 +339,11 @@ services: tags: - {name: sylius.settings_schema, alias: chamilo_core.settings.language, namespace: language} + chamilo_core.settings.learning_path: + class: Chamilo\CoreBundle\Settings\LearningPathSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.language, namespace: lp} + chamilo_core.settings.mail: class: Chamilo\CoreBundle\Settings\MailSettingsSchema tags: diff --git a/src/CoreBundle/Settings/AnnouncementSettingsSchema.php b/src/CoreBundle/Settings/AnnouncementSettingsSchema.php index 83a091f83c..ccf739c1c9 100644 --- a/src/CoreBundle/Settings/AnnouncementSettingsSchema.php +++ b/src/CoreBundle/Settings/AnnouncementSettingsSchema.php @@ -23,6 +23,7 @@ class AnnouncementSettingsSchema extends AbstractSettingsSchema ->setDefaults( [ 'hide_global_announcements_when_not_connected' => 'false', + 'hide_send_to_hrm_users' => 'true' ] ); @@ -39,6 +40,7 @@ class AnnouncementSettingsSchema extends AbstractSettingsSchema { $builder ->add('hide_global_announcements_when_not_connected', YesNoType::class) + ->add('hide_send_to_hrm_users', YesNoType::class) ; } } diff --git a/src/CoreBundle/Settings/CertificateSettingsSchema.php b/src/CoreBundle/Settings/CertificateSettingsSchema.php new file mode 100644 index 0000000000..0a32b86e21 --- /dev/null +++ b/src/CoreBundle/Settings/CertificateSettingsSchema.php @@ -0,0 +1,46 @@ +setDefaults( + [ + 'hide_my_certificate_link' => 'false', + 'hide_header_footer' => 'false' + ] + ); + + $allowedTypes = [ + 'hide_my_certificate_link' => ['string'], + ]; + $this->setMultipleAllowedTypes($allowedTypes, $builder); + } + + /** + * {@inheritdoc} + */ + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('hide_my_certificate_link', YesNoType::class) + ->add('hide_header_footer', YesNoType::class) + ; + } +} diff --git a/src/CoreBundle/Settings/CourseSettingsSchema.php b/src/CoreBundle/Settings/CourseSettingsSchema.php index 28c4e6f876..81559a991f 100644 --- a/src/CoreBundle/Settings/CourseSettingsSchema.php +++ b/src/CoreBundle/Settings/CourseSettingsSchema.php @@ -109,6 +109,7 @@ class CourseSettingsSchema extends AbstractSettingsSchema 'enable_record_audio' => 'false', 'lp_show_reduced_report' => 'false', 'course_creation_splash_screen' => 'true', + 'block_registered_users_access_to_open_course_contents' => 'false', // @todo ] ) ->setTransformer( @@ -249,6 +250,7 @@ class CourseSettingsSchema extends AbstractSettingsSchema ->add('enable_record_audio', YesNoType::class) ->add('lp_show_reduced_report', YesNoType::class) ->add('course_creation_splash_screen', YesNoType::class) + ->add('block_registered_users_access_to_open_course_contents', YesNoType::class) ; } } diff --git a/src/CoreBundle/Settings/DisplaySettingsSchema.php b/src/CoreBundle/Settings/DisplaySettingsSchema.php index e7244b5b19..4df4a9d0cf 100644 --- a/src/CoreBundle/Settings/DisplaySettingsSchema.php +++ b/src/CoreBundle/Settings/DisplaySettingsSchema.php @@ -52,6 +52,7 @@ class DisplaySettingsSchema extends AbstractSettingsSchema 'hide_logout_button' => 'false', 'show_link_ticket_notification' => 'false', 'icons_mode_svg' => 'false', + 'default_template' => 'default' ] ); @@ -116,7 +117,7 @@ class DisplaySettingsSchema extends AbstractSettingsSchema ->add('hide_logout_button', YesNoType::class) ->add('show_link_ticket_notification', YesNoType::class) ->add('icons_mode_svg', YesNoType::class) - + ->add('default_template') ; } } diff --git a/src/CoreBundle/Settings/ExerciseSettingsSchema.php b/src/CoreBundle/Settings/ExerciseSettingsSchema.php index a43b5b0064..c7c6d66bf3 100644 --- a/src/CoreBundle/Settings/ExerciseSettingsSchema.php +++ b/src/CoreBundle/Settings/ExerciseSettingsSchema.php @@ -31,6 +31,7 @@ class ExerciseSettingsSchema extends AbstractSettingsSchema 'exercise_max_ckeditors_in_page' => '0', 'configure_exercise_visibility_in_course' => 'false', 'exercise_invisible_in_session' => 'false', + 'allow_edit_exercise_in_lp' => 'false', ] ) ; diff --git a/src/CoreBundle/Settings/LearningPathSettingsSchema.php b/src/CoreBundle/Settings/LearningPathSettingsSchema.php new file mode 100644 index 0000000000..27074690c7 --- /dev/null +++ b/src/CoreBundle/Settings/LearningPathSettingsSchema.php @@ -0,0 +1,46 @@ +setDefaults( + [ + 'fixed_encoding' => 'false', + 'show_invisible_exercise_in_lp_toc' => 'false' + ] + ); + + $allowedTypes = [ + 'fixed_encoding' => ['string'], + ]; + $this->setMultipleAllowedTypes($allowedTypes, $builder); + } + + /** + * {@inheritdoc} + */ + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('fixed_encoding', YesNoType::class) + ->add('show_invisible_exercise_in_lp_toc', YesNoType::class) + ; + } +} diff --git a/src/CoreBundle/Settings/SessionSettingsSchema.php b/src/CoreBundle/Settings/SessionSettingsSchema.php index 9d97d1987f..c891ebcdd7 100644 --- a/src/CoreBundle/Settings/SessionSettingsSchema.php +++ b/src/CoreBundle/Settings/SessionSettingsSchema.php @@ -46,6 +46,7 @@ class SessionSettingsSchema extends AbstractSettingsSchema 'session_days_before_coach_access' => '', 'show_session_description' => 'false', 'remove_session_url' => 'false', + 'hide_tab_list' => '' ] ) ; @@ -98,6 +99,8 @@ class SessionSettingsSchema extends AbstractSettingsSchema ->add('session_days_before_coach_access') ->add('show_session_description', YesNoType::class) ->add('remove_session_url', YesNoType::class) + ->add('hide_tab_list') + ; } }