From d098fc56a3f146b6eef26234b7781c67c40904e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claes=20Gyllensv=C3=A4rd?= Date: Fri, 31 Aug 2012 09:39:58 +0200 Subject: [PATCH] Issue #967566 by DocuAnt, mariusz.slonina, tsvensson, xjm, tim.plunkett, joestewart, oriol_e9g, letharion. Implement hook_field_extra_fields() to provide user settings for several core modules. --- core/modules/block/block.module | 2 +- core/modules/contact/contact.module | 13 ++++++ .../Tests/ContactUserAccountSettingsTest.php | 45 +++++++++++++++++++ core/modules/language/language.module | 13 ++++++ .../Tests/LanguageUserAccountSettingsTest.php | 45 +++++++++++++++++++ core/modules/overlay/overlay.module | 13 ++++++ .../user/Tests/UserUserAccountSettingsTest.php | 46 ++++++++++++++++++++ core/modules/user/user.module | 20 +++++++++ 8 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 core/modules/contact/lib/Drupal/contact/Tests/ContactUserAccountSettingsTest.php create mode 100644 core/modules/language/lib/Drupal/language/Tests/LanguageUserAccountSettingsTest.php create mode 100644 core/modules/user/lib/Drupal/user/Tests/UserUserAccountSettingsTest.php diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 2592137..26da636 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -631,7 +631,7 @@ function block_form_user_profile_form_alter(&$form, &$form_state) { function block_field_extra_fields() { $extra['user']['user']['form']['block'] = array( 'label' => t('Personalize blocks'), - 'description' => t('Block module form element.'), + 'description' => t('Block module form element. This element may not be present on all user account pages.'), 'weight' => 3, ); diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index 1ba70b9..5063196 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -270,3 +270,16 @@ function contact_form_user_admin_settings_submit($form, &$form_state) { ->set('user_default_enabled', $form_state['values']['contact_default_status']) ->save(); } + +/** + * Implements hook_field_extra_fields(). + */ +function contact_field_extra_fields() { + $extra['user']['user']['form']['contact'] = array( + 'label' => t('Contact settings'), + 'description' => t('Contact module form element. This element may not be present on all user account pages.'), + 'weight' => 5, + ); + + return $extra; +} diff --git a/core/modules/contact/lib/Drupal/contact/Tests/ContactUserAccountSettingsTest.php b/core/modules/contact/lib/Drupal/contact/Tests/ContactUserAccountSettingsTest.php new file mode 100644 index 0000000..71f4195 --- /dev/null +++ b/core/modules/contact/lib/Drupal/contact/Tests/ContactUserAccountSettingsTest.php @@ -0,0 +1,45 @@ + 'Personalized contact settings', + 'description' => 'Tests the contact settings in user accounts.', + 'group' => 'Contact', + ); + } + + public function setUp() { + parent::setUp(); + $admin_user = $this->drupalCreateUser(array('administer users')); + $this->drupalLogin($admin_user); + } + + /** + * Tests that the personalized contact is shown. + */ + function testAccountSettingsPage() { + $this->drupalGet('admin/config/people/accounts/fields'); + $this->assertText(t('Contact settings'), 'Contact setting is present.'); + } +} diff --git a/core/modules/language/language.module b/core/modules/language/language.module index f90ef93..67c36aa 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -596,3 +596,16 @@ function language_url_outbound_alter(&$path, &$options, $original_path) { } } } + +/** + * Implements hook_field_extra_fields(). + */ +function language_field_extra_fields() { + $extra['user']['user']['form']['language'] = array( + 'label' => t('Language settings'), + 'description' => t('Language module form element. This element may not be present on all user account pages.'), + 'weight' => 1, + ); + + return $extra; +} diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageUserAccountSettingsTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageUserAccountSettingsTest.php new file mode 100644 index 0000000..0bfb767 --- /dev/null +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageUserAccountSettingsTest.php @@ -0,0 +1,45 @@ + 'Personalized language settings', + 'description' => 'Tests the language settings in user accounts.', + 'group' => 'Language', + ); + } + + public function setUp() { + parent::setUp(); + $admin_user = $this->drupalCreateUser(array('administer users')); + $this->drupalLogin($admin_user); + } + + /** + * Tests that the personalized language is shown. + */ + function testAccountSettingsPage() { + $this->drupalGet('admin/config/people/accounts/fields'); + $this->assertText(t('Language settings'), 'Personalized language is present.'); + } +} diff --git a/core/modules/overlay/overlay.module b/core/modules/overlay/overlay.module index 3aaed7d..e4c21d8 100644 --- a/core/modules/overlay/overlay.module +++ b/core/modules/overlay/overlay.module @@ -103,6 +103,19 @@ function overlay_form_user_profile_form_alter(&$form, &$form_state) { } /** + * Implements hook_field_extra_fields(). + */ +function overlay_field_extra_fields() { + $extra['user']['user']['form']['overlay_control'] = array( + 'label' => t('Administrative overlay'), + 'description' => t('Overlay module form element. This element may not be present on all user account pages.'), + 'weight' => 4, + ); + + return $extra; +} + +/** * Implements hook_user_presave(). */ function overlay_user_presave($account) { diff --git a/core/modules/user/lib/Drupal/user/Tests/UserUserAccountSettingsTest.php b/core/modules/user/lib/Drupal/user/Tests/UserUserAccountSettingsTest.php new file mode 100644 index 0000000..2c59897 --- /dev/null +++ b/core/modules/user/lib/Drupal/user/Tests/UserUserAccountSettingsTest.php @@ -0,0 +1,46 @@ + 'Personalized user settings', + 'description' => 'Tests the user settings in user accounts.', + 'group' => 'User', + ); + } + + public function setUp() { + parent::setUp(); + $admin_user = $this->drupalCreateUser(array('administer users')); + $this->drupalLogin($admin_user); + } + + /** + * Tests that the personalized user is shown. + */ + function testAccountSettingsPage() { + $this->drupalGet('admin/config/people/accounts/fields'); + $this->assertText(t('User signature'), 'User signature setting is present.'); + $this->assertText(t('User picture'), 'User picture setting is present.'); + } +} diff --git a/core/modules/user/user.module b/core/modules/user/user.module index e90c907..a5ae5a9 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -248,6 +248,26 @@ function user_field_extra_fields() { ), ); + if (variable_get('user_pictures', 1) == 1) { + $return['user']['user']['form'] += array( + 'picture' => array( + 'label' => t('User picture'), + 'description' => t('User module picture form element. This element may not be present on all user account pages.'), + 'weight' => 2, + ), + ); + } + + if (variable_get('user_signatures', 1) == 1) { + $return['user']['user']['form'] += array( + 'signature_settings' => array( + 'label' => t('User signature'), + 'description' => t('User module signature form element. This element may not be present on all user account pages.'), + 'weight' => 1, + ), + ); + } + return $return; } -- 1.7.9.5