Move settings from app/config into a setting schema #2680

- Removed PREFIX_IMAGE_FILENAME_WITH_UID the uid is always included (default behaviour)
- Removed KEEP_THE_NAME_WHEN_CHANGE_IMAGE the image name is kept (default behaviour)
- Moved CHECK_PASS_EASY_TO_FIND to platform settings as security.check_password
- Removed CONFVAL_ASK_FOR_OFFICIAL_CODE true by default
pull/2715/head
Julio 7 years ago
parent 678d020eac
commit ff9a0f0edb
  1. 29
      app/config/profile.conf.dist.php
  2. 3
      main/inc/lib/formvalidator/FormValidator.class.php
  3. 9
      main/inc/lib/usergroup.lib.php
  4. 8
      main/inc/lib/usermanager.lib.php
  5. 22
      main/survey/fillsurvey.php
  6. 1
      src/CoreBundle/Settings/PlatformSettingsSchema.php
  7. 2
      src/CoreBundle/Settings/SecuritySettingsSchema.php
  8. 1
      tests/behat/README.md

@ -10,32 +10,17 @@
// Autentication, password
define('CHECK_PASS_EASY_TO_FIND', false);
$profileIsEditable = true;
// User photos
define('PREFIX_IMAGE_FILENAME_WITH_UID', true); // If true, filename of images on server begin with uid of the user.
define('RESIZE_IMAGE_TO_THIS_HEIGTH', 180);
define('IMAGE_THUMBNAIL_WIDTH', 100);
// Replacing user photos
define('KEEP_THE_NAME_WHEN_CHANGE_IMAGE', true);
// true -> the new image have the name of previous.
// false -> a new name is build for each upladed image.
define('KEEP_THE_OLD_IMAGE_AFTER_CHANGE', true);
// true -> if KEEP_THE_NAME_WHEN_CHANGE_IMAGE is true, the previous image is rename before.
// false -> only the last image still on server.
// Official code
// Don't forget to change name of offical code in your organization
// See $langOfficialCode within the language file 'registration'
define('CONFVAL_ASK_FOR_OFFICIAL_CODE', true); // not used but name fixed
define('CONFVAL_CHECK_OFFICIAL_CODE', false);
/* if CONFVAL_CHECK_OFFICIAL_CODE is true, build here the
function personal_check_official_code($code, $valueToReturnIfOk, $valueToReturnIfBad) {
return $stateOfficialCode = true;
}
*/
// For stats
define('NB_LINE_OF_EVENTS', 15);
// Replacing user photos
define('KEEP_THE_NAME_WHEN_CHANGE_IMAGE', true);
// true -> the new image have the name of previous.
// false -> a new name is build for each upladed image.
define('KEEP_THE_OLD_IMAGE_AFTER_CHANGE', true);
// true -> if KEEP_THE_NAME_WHEN_CHANGE_IMAGE is true, the previous image is rename before.
// false -> only the last image still on server.

@ -1723,8 +1723,7 @@ EOT;
*/
public function addPasswordRule($elementName, $groupName = '')
{
// Constant defined in old config/profile.conf.php
if (CHECK_PASS_EASY_TO_FIND === true) {
if (api_get_setting('security.check_password') == 'true') {
$message = get_lang('PassTooEasy').': '.api_generate_password();
if (!empty($groupName)) {

@ -1392,7 +1392,7 @@ class UserGroup extends Model
// Let us delete them.
if (!empty($old_file)) {
if (KEEP_THE_OLD_IMAGE_AFTER_CHANGE) {
if (api_get_setting('platform.keep_old_images_after_delete') == 'true') {
$prefix = 'saved_'.date('Y_m_d_H_i_s').'_'.uniqid('').'_';
@rename($path.'small_'.$old_file, $path.$prefix.'small_'.$old_file);
@rename($path.'medium_'.$old_file, $path.$prefix.'medium_'.$old_file);
@ -1421,15 +1421,14 @@ class UserGroup extends Model
}
// This is the common name for the new photos.
if (KEEP_THE_NAME_WHEN_CHANGE_IMAGE && !empty($old_file)) {
if (!empty($old_file)) {
$old_extension = strtolower(substr(strrchr($old_file, '.'), 1));
$filename = in_array($old_extension, $allowed_types) ? substr($old_file, 0, -strlen($old_extension)) : $old_file;
$filename = (substr($filename, -1) == '.') ? $filename.$extension : $filename.'.'.$extension;
} else {
$filename = api_replace_dangerous_char($filename);
if (PREFIX_IMAGE_FILENAME_WITH_UID) {
$filename = uniqid('').'_'.$filename;
}
$filename = uniqid('').'_'.$filename;
// We always prefix user photos with user ids, so on setting
// api_get_setting('split_users_upload_directory') === 'true'
// the correspondent directories to be found successfully.

@ -2027,7 +2027,7 @@ class UserManager
// Let us delete them.
if ($old_file != 'unknown.jpg') {
if (KEEP_THE_OLD_IMAGE_AFTER_CHANGE) {
if (api_get_setting('platform.keep_old_images_after_delete') == 'true') {
$prefix = 'saved_'.date('Y_m_d_H_i_s').'_'.uniqid('').'_';
@rename($path.'small_'.$old_file, $path.$prefix.'small_'.$old_file);
@rename($path.'medium_'.$old_file, $path.$prefix.'medium_'.$old_file);
@ -2056,15 +2056,13 @@ class UserManager
}
// This is the common name for the new photos.
if (KEEP_THE_NAME_WHEN_CHANGE_IMAGE && $old_file != 'unknown.jpg') {
if ($old_file != 'unknown.jpg') {
$old_extension = strtolower(substr(strrchr($old_file, '.'), 1));
$filename = in_array($old_extension, $allowed_types) ? substr($old_file, 0, -strlen($old_extension)) : $old_file;
$filename = (substr($filename, -1) == '.') ? $filename.$extension : $filename.'.'.$extension;
} else {
$filename = api_replace_dangerous_char($filename);
if (PREFIX_IMAGE_FILENAME_WITH_UID) {
$filename = uniqid('').'_'.$filename;
}
$filename = uniqid('').'_'.$filename;
// We always prefix user photos with user ids, so on setting
// api_get_setting('split_users_upload_directory') === 'true'
// the correspondent directories to be found successfully.

@ -446,18 +446,16 @@ if ($survey_data['form_fields'] != '' &&
if (isset($list['official_code']) && $list['official_code'] == 1) {
// OFFICIAL CODE
if (CONFVAL_ASK_FOR_OFFICIAL_CODE) {
$form->addElement('text', 'official_code', get_lang('OfficialCode'), ['size' => 40]);
if (api_get_setting('profile', 'officialcode') !== 'true') {
$form->freeze('official_code');
}
$form->applyFilter('official_code', 'stripslashes');
$form->applyFilter('official_code', 'trim');
if (api_get_setting('registration', 'officialcode') == 'true' &&
api_get_setting('profile', 'officialcode') == 'true'
) {
$form->addRule('official_code', get_lang('ThisFieldIsRequired'), 'required');
}
$form->addElement('text', 'official_code', get_lang('OfficialCode'), ['size' => 40]);
if (api_get_setting('profile', 'officialcode') !== 'true') {
$form->freeze('official_code');
}
$form->applyFilter('official_code', 'stripslashes');
$form->applyFilter('official_code', 'trim');
if (api_get_setting('registration', 'officialcode') == 'true' &&
api_get_setting('profile', 'officialcode') == 'true'
) {
$form->addRule('official_code', get_lang('ThisFieldIsRequired'), 'required');
}
}

@ -46,6 +46,7 @@ class PlatformSettingsSchema extends AbstractSettingsSchema
'pdf_logo_header' => '',
'allow_my_files' => 'true',
'registered' => 'false',
'keep_old_images_after_delete' => 'true',
'load_term_conditions_section' => 'login',
//'server_type' => 'prod', replaced by value in .env
'show_full_skill_name_on_skill_wheel' => 'false',

@ -31,6 +31,7 @@ class SecuritySettingsSchema extends AbstractSettingsSchema
'captcha_number_mistakes_to_block_account' => '',
'captcha_time_to_block' => '',
'prevent_multiple_simultaneous_login' => 'false',
'check_password' => 'false'
]
);
$allowedTypes = [
@ -57,6 +58,7 @@ class SecuritySettingsSchema extends AbstractSettingsSchema
->add('captcha_number_mistakes_to_block_account', 'text')
->add('captcha_time_to_block', 'text')
->add('prevent_multiple_simultaneous_login', YesNoType::class)
->add('check_password', YesNoType::class)
;
}

@ -34,7 +34,6 @@ cd /tmp && wget https://chromedriver.storage.googleapis.com/2.35/chromedriver_li
- Social network tool must be available (allow_social_tool = true)
- Student can register to the system (allow_registration = yes)
- Teacher can register to the system (allow_registration_as_teacher = yes)
- The CHECK_PASS_EASY_TO_FIND in app/config/profile.conf.php must be set to false
### Run tests

Loading…
Cancel
Save