Admin: Enable the multi-URL feature by default (just create a new URL to unlock all related features)

pull/5671/head
Yannick Warnier 4 months ago
parent 81195b84c8
commit cb2c2fddee
  1. 6
      public/main/admin/index.php
  2. 9
      public/main/admin/settings.lib.php
  3. 21
      public/main/inc/lib/api.lib.php
  4. 2
      public/main/inc/lib/usergroup.lib.php
  5. 6
      public/main/install/configuration.dist.php
  6. 14
      src/CoreBundle/Controller/Admin/IndexBlocksController.php
  7. 1
      tests/scripts/multi_url_conversion.php

@ -377,10 +377,8 @@ if (api_is_platform_admin()) {
$items[] = ['url' => 'extra_field_list.php', 'label' => get_lang('Extra fields')]; $items[] = ['url' => 'extra_field_list.php', 'label' => get_lang('Extra fields')];
if (!empty($_configuration['multiple_access_urls'])) { if (api_is_global_platform_admin()) {
if (api_is_global_platform_admin()) { $items[] = ['url' => 'access_urls.php', 'label' => get_lang('Configure multiple access URL')];
$items[] = ['url' => 'access_urls.php', 'label' => get_lang('Configure multiple access URL')];
}
} }
if ('true' == api_get_plugin_setting('dictionary', 'enable_plugin_dictionary')) { if ('true' == api_get_plugin_setting('dictionary', 'enable_plugin_dictionary')) {

@ -1091,13 +1091,6 @@ function generateSettingsForm($settings, $settings_by_access_list)
); );
$url_id = api_get_current_access_url_id(); $url_id = api_get_current_access_url_id();
/*
if (!empty($_configuration['multiple_access_urls']) && api_is_global_platform_admin() && $url_id == 1) {
$group = array();
$group[] = $form->createElement('button', 'mark_all', get_lang('Select all'));
$group[] = $form->createElement('button', 'unmark_all', get_lang('Unselect all'));
$form->addGroup($group, 'buttons_in_action_right');
}*/
$default_values = []; $default_values = [];
$url_info = api_get_access_url($url_id); $url_info = api_get_access_url($url_id);
@ -1114,7 +1107,7 @@ function generateSettingsForm($settings, $settings_by_access_list)
$addedSettings[] = $row['variable']; $addedSettings[] = $row['variable'];
if (!empty($_configuration['multiple_access_urls'])) { if (api_get_multiple_access_url()) {
if (api_is_global_platform_admin()) { if (api_is_global_platform_admin()) {
if (0 == $row['access_url_locked']) { if (0 == $row['access_url_locked']) {
if (1 == $url_id) { if (1 == $url_id) {

@ -716,9 +716,7 @@ function api_get_path($path = '', $configuration = [])
); );
} }
if (isset($configuration['multiple_access_urls']) && if (api_get_multiple_access_url()) {
$configuration['multiple_access_urls']
) {
// To avoid that the api_get_access_url() function fails since global.inc.php also calls the main_api.lib.php // To avoid that the api_get_access_url() function fails since global.inc.php also calls the main_api.lib.php
if (isset($configuration['access_url']) && !empty($configuration['access_url'])) { if (isset($configuration['access_url']) && !empty($configuration['access_url'])) {
// We look into the DB the function api_get_access_url // We look into the DB the function api_get_access_url
@ -5970,16 +5968,23 @@ function api_get_course_url($courseId = null, $sessionId = null, $groupId = null
} }
/** /**
* Check if the current portal has the $_configuration['multiple_access_urls'] parameter on. * Check if there is more than the default URL defined in the access_url table.
*/ */
function api_get_multiple_access_url(): bool function api_get_multiple_access_url(): bool
{ {
global $_configuration; static $accessUrlEnabled;
if (isset($_configuration['multiple_access_urls']) && $_configuration['multiple_access_urls']) { if (!isset($accessUrlEnabled)) {
return true; $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL);
$sql = "SELECT id FROM $table";
$res = Database::query($sql);
if (Database::num_rows($res) > 1) {
$accessUrlEnabled = true;
} else {
$accessUrlEnabled = false;
}
} }
return false; return $accessUrlEnabled;
} }
function api_is_multiple_url_enabled(): bool function api_is_multiple_url_enabled(): bool

@ -59,7 +59,7 @@ class UserGroupModel extends Model
$this->access_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $this->access_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$this->table_course = Database::get_main_table(TABLE_MAIN_COURSE); $this->table_course = Database::get_main_table(TABLE_MAIN_COURSE);
$this->table_user = Database::get_main_table(TABLE_MAIN_USER); $this->table_user = Database::get_main_table(TABLE_MAIN_USER);
$this->useMultipleUrl = api_get_configuration_value('multiple_access_urls'); $this->useMultipleUrl = api_get_multiple_access_url();
if ($this->allowTeachers()) { if ($this->allowTeachers()) {
$this->columns[] = 'author_id'; $this->columns[] = 'author_id';
} }

@ -49,12 +49,6 @@ $_configuration['hosting_total_size_limit'] = 0;
// Security word for password recovery // Security word for password recovery
$_configuration['security_key'] = '{SECURITY_KEY}'; $_configuration['security_key'] = '{SECURITY_KEY}';
// Activation for multi-url access
// When enabling multi-url, settings can be configured by multi-url using a simple
// sub-element. E.g. $_configuration['session_lifetime'][1] = true; could be turned into
// something like $_configuration['session_lifetime'][2] = false; to affect only URL
// with ID 2. The ID can be found in the access_url table.
//$_configuration['multiple_access_urls'] = true;
$_configuration['software_name'] = 'Chamilo'; $_configuration['software_name'] = 'Chamilo';
$_configuration['software_url'] = 'https://chamilo.org/'; $_configuration['software_url'] = 'https://chamilo.org/';
// Deny the elimination of users // Deny the elimination of users

@ -441,14 +441,12 @@ class IndexBlocksController extends BaseController
'label' => $this->translator->trans('Extra fields'), 'label' => $this->translator->trans('Extra fields'),
]; ];
if (!empty(api_get_configuration_value('multiple_access_urls'))) { if (api_is_global_platform_admin()) {
if (api_is_global_platform_admin()) { $items[] = [
$items[] = [ 'class' => 'item-access-url',
'class' => 'item-access-url', 'url' => $this->generateUrl('legacy_main', ['name' => 'admin/access_urls.php']),
'url' => $this->generateUrl('legacy_main', ['name' => 'admin/access_urls.php']), 'label' => $this->translator->trans('Configure multiple access URL'),
'label' => $this->translator->trans('Configure multiple access URL'), ];
];
}
} }
if ('true' === api_get_plugin_setting('dictionary', 'enable_plugin_dictionary')) { if ('true' === api_get_plugin_setting('dictionary', 'enable_plugin_dictionary')) {

@ -120,4 +120,3 @@ $resU = Database::query($sqlU);
echo "Table $tableAccessUrlRelUserGroup updated".PHP_EOL; echo "Table $tableAccessUrlRelUserGroup updated".PHP_EOL;
echo "Database updated.".PHP_EOL; echo "Database updated.".PHP_EOL;
echo "Please set \$_configuration['multiple_access_urls'] to true in the app/config/configuration.php file".PHP_EOL;

Loading…
Cancel
Save