From b1896c2484358fa4ad1988c1dd505496bf2a7afb Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 20 Aug 2018 15:24:51 +0200 Subject: [PATCH] Remove use of is_profile_editable() replace by DB setting New setting DB "profile.is_editable" --- config/packages/twig.yaml | 1 - main/auth/profile.php | 13 +++++++------ src/CoreBundle/Settings/ProfileSettingsSchema.php | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/config/packages/twig.yaml b/config/packages/twig.yaml index 8940ac6398..87a8f0183f 100644 --- a/config/packages/twig.yaml +++ b/config/packages/twig.yaml @@ -15,7 +15,6 @@ twig: news_list: messages_count: message_link: - is_profile_editable: administrator_name: execution_stats: course_session_block: diff --git a/main/auth/profile.php b/main/auth/profile.php index 4c6c927285..3be4aefbd8 100755 --- a/main/auth/profile.php +++ b/main/auth/profile.php @@ -80,7 +80,7 @@ if (api_get_setting('allow_message_tool') === 'true') { EOF; } -$tool_name = is_profile_editable() ? get_lang('ModifProfile') : get_lang('ViewProfile'); +$tool_name = api_get_setting('profile.is_editable') === 'true' ? get_lang('ModifProfile') : get_lang('ViewProfile'); $table_user = Database::get_main_table(TABLE_MAIN_USER); /* @@ -182,7 +182,7 @@ if (api_get_setting('registration', 'email') == 'true' && api_get_setting('profi } // OPENID URL -if (is_profile_editable() && api_get_setting('openid_authentication') == 'true') { +if (api_get_setting('profile.is_editable') === 'true' && api_get_setting('openid_authentication') == 'true') { $form->addElement('text', 'openid', get_lang('OpenIDURL'), ['size' => 40]); if (api_get_setting('profile', 'openid') !== 'true') { $form->freeze('openid'); @@ -200,7 +200,8 @@ $form->applyFilter('phone', 'trim'); $form->applyFilter('phone', 'html_filter'); // PICTURE -if (is_profile_editable() && api_get_setting('profile', 'picture') == 'true') { +if (api_get_setting('profile.is_editable') === 'true' && + api_get_setting('profile', 'picture') === 'true') { $form->addFile( 'picture', [ @@ -236,7 +237,7 @@ if (api_get_setting('profile', 'language') !== 'true') { } // THEME -if (is_profile_editable() && api_get_setting('user_selected_theme') == 'true') { +if (api_get_setting('profile.is_editable') === 'true' && api_get_setting('user_selected_theme') === 'true') { $form->addElement('SelectTheme', 'theme', get_lang('Theme')); if (api_get_setting('profile', 'theme') !== 'true') { $form->freeze('theme'); @@ -308,7 +309,7 @@ if (api_get_setting('extended_profile') === 'true') { // PASSWORD, if auth_source is platform if (is_platform_authentication() && - is_profile_editable() && + api_get_setting('profile.is_editable') === 'true' && api_get_setting('profile', 'password') == 'true' ) { $form->addElement('password', 'password0', [get_lang('Pass'), get_lang('Enter2passToChange')], ['size' => 40]); @@ -356,7 +357,7 @@ if (api_get_setting('profile', 'apikeys') == 'true') { ); } // SUBMIT -if (is_profile_editable()) { +if (api_get_setting('profile.is_editable') === 'true') { $form->addButtonUpdate(get_lang('SaveSettings'), 'apply_change'); } else { $form->freeze(); diff --git a/src/CoreBundle/Settings/ProfileSettingsSchema.php b/src/CoreBundle/Settings/ProfileSettingsSchema.php index 8ba229689c..dbdff2f6a8 100644 --- a/src/CoreBundle/Settings/ProfileSettingsSchema.php +++ b/src/CoreBundle/Settings/ProfileSettingsSchema.php @@ -36,6 +36,7 @@ class ProfileSettingsSchema extends AbstractSettingsSchema 'enable_profile_user_address_geolocalization' => '', 'allow_show_skype_account' => '', 'allow_show_linkedin_url' => '', + 'is_editable' => 'true' ] ) ->setTransformer( @@ -91,7 +92,7 @@ class ProfileSettingsSchema extends AbstractSettingsSchema ->add('enable_profile_user_address_geolocalization', YesNoType::class) ->add('allow_show_skype_account', YesNoType::class) ->add('allow_show_linkedin_url', YesNoType::class) - + ->add('is_editable', YesNoType::class) ; } }