From 4c359f2a0e6fda82376da08f47a0c91311769b80 Mon Sep 17 00:00:00 2001 From: Brian Teeman Date: Wed, 15 Jun 2022 09:39:30 +0100 Subject: [PATCH 1/3] [4.2] user profile dob field To test enable the user profile plugin and update the date of birth field for your user account --- administrator/components/com_admin/script.php | 2 + .../language/en-GB/plg_user_profile.ini | 3 +- plugins/user/profile/forms/profile.xml | 5 +- plugins/user/profile/src/Field/DobField.php | 67 ------------------- 4 files changed, 7 insertions(+), 70 deletions(-) delete mode 100644 plugins/user/profile/src/Field/DobField.php diff --git a/administrator/components/com_admin/script.php b/administrator/components/com_admin/script.php index 79b0dbb71fe1f..148f19903463f 100644 --- a/administrator/components/com_admin/script.php +++ b/administrator/components/com_admin/script.php @@ -6474,6 +6474,8 @@ public function deleteUnexistingFiles($dryRun = false, $suppressOutput = false) '/plugins/twofactorauth/yubikey/tmpl/form.php', '/plugins/twofactorauth/yubikey/yubikey.php', '/plugins/twofactorauth/yubikey/yubikey.xml', + // From 4.2 + '/plugins/user/profile/src/Field/DobField.php', ); $folders = array( diff --git a/administrator/language/en-GB/plg_user_profile.ini b/administrator/language/en-GB/plg_user_profile.ini index a2c2a57c1b375..9c752b56d7ad7 100644 --- a/administrator/language/en-GB/plg_user_profile.ini +++ b/administrator/language/en-GB/plg_user_profile.ini @@ -12,6 +12,8 @@ PLG_USER_PROFILE_FIELD_ADDRESS1_LABEL="Address 1" PLG_USER_PROFILE_FIELD_ADDRESS2_LABEL="Address 2" PLG_USER_PROFILE_FIELD_CITY_LABEL="City" PLG_USER_PROFILE_FIELD_COUNTRY_LABEL="Country" +PLG_USER_PROFILE_FIELD_DOB_DESCRIPTION="Year-Month-Day, eg 2019-01-27." ; Adapt to the format you entered in the 'DATE_FORMAT_CALENDAR_DATE' +PLG_USER_PROFILE_FIELD_DOB_HINT="YYYY-MM-DD" ; Adapt to the format you entered in the 'DATE_FORMAT_CALENDAR_DATE' PLG_USER_PROFILE_FIELD_DOB_LABEL="Date of Birth" PLG_USER_PROFILE_FIELD_FAVORITE_BOOK_LABEL="Favourite Book" PLG_USER_PROFILE_FIELD_NAME_PROFILE_REQUIRE_USER="User profile fields for profile edit form" @@ -27,5 +29,4 @@ PLG_USER_PROFILE_FILL_FIELD_DESC_SITE="If required, please fill this field." PLG_USER_PROFILE_OPTION_AGREE="Agree" PLG_USER_PROFILE_OPTION_DO_NOT_AGREE="I do not agree" PLG_USER_PROFILE_SLIDER_LABEL="User Profile" -PLG_USER_PROFILE_SPACER_DOB="The date of birth entered should use the format Year-Month-Day, eg 2019-01-27." ; Adapt to the format you entered in the 'DATE_FORMAT_CALENDAR_DATE' PLG_USER_PROFILE_XML_DESCRIPTION="User Profile Plugin" diff --git a/plugins/user/profile/forms/profile.xml b/plugins/user/profile/forms/profile.xml index 38a1bfce5c5e5..fa6d0a724ecc8 100644 --- a/plugins/user/profile/forms/profile.xml +++ b/plugins/user/profile/forms/profile.xml @@ -89,9 +89,10 @@ - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -namespace Joomla\Plugin\User\Profile\Field; - -\defined('JPATH_PLATFORM') or die; - -use Joomla\CMS\Factory; -use Joomla\CMS\Form\Field\CalendarField; -use Joomla\CMS\Language\Text; -use Joomla\CMS\Layout\FileLayout; - -/** - * Provides input for "Date of Birth" field - * - * @package Joomla.Plugin - * @subpackage User.profile - * @since 3.3.7 - */ -class DobField extends CalendarField -{ - /** - * The form field type. - * - * @var string - * @since 3.3.7 - */ - protected $type = 'Dob'; - - /** - * Method to get the field label markup. - * - * @return string The field label markup. - * - * @since 3.3.7 - */ - protected function getLabel() - { - $label = parent::getLabel(); - - // Get the info text from the XML element, defaulting to empty. - $text = $this->element['info'] ? (string) $this->element['info'] : ''; - $text = $this->translateLabel ? Text::_($text) : $text; - - if ($text) - { - $app = Factory::getApplication(); - $view = $app->input->getString('view', ''); - - // Only display the tip when editing profile - if ($view === 'registration' || $view === 'profile' || $app->isClient('administrator')) - { - $layout = new FileLayout('plugins.user.profile.fields.dob'); - $info = $layout->render(array('text' => $text)); - $label = $info . $label; - } - } - - return $label; - } -} From b88bcf7f07d6662958e6d7d678df874c48f5e726 Mon Sep 17 00:00:00 2001 From: Brian Teeman Date: Wed, 15 Jun 2022 10:45:12 +0100 Subject: [PATCH 2/3] layouts --- administrator/components/com_admin/script.php | 5 ++++ layouts/plugins/user/profile/fields/dob.php | 24 ------------------- 2 files changed, 5 insertions(+), 24 deletions(-) delete mode 100644 layouts/plugins/user/profile/fields/dob.php diff --git a/administrator/components/com_admin/script.php b/administrator/components/com_admin/script.php index 148f19903463f..5579f731a7c11 100644 --- a/administrator/components/com_admin/script.php +++ b/administrator/components/com_admin/script.php @@ -6476,6 +6476,7 @@ public function deleteUnexistingFiles($dryRun = false, $suppressOutput = false) '/plugins/twofactorauth/yubikey/yubikey.xml', // From 4.2 '/plugins/user/profile/src/Field/DobField.php', + '/layouts/plugins/user/profile/fields/dob.php', ); $folders = array( @@ -7837,6 +7838,10 @@ public function deleteUnexistingFiles($dryRun = false, $suppressOutput = false) '/plugins/twofactorauth/totp', '/plugins/twofactorauth', '/libraries/vendor/nyholm/psr7/doc', + // From 4.2 + '/layouts/plugins/user/profile/fields', + '/layouts/plugins/user/profile', + '/layouts/plugins/user/', ); $status['files_checked'] = $files; diff --git a/layouts/plugins/user/profile/fields/dob.php b/layouts/plugins/user/profile/fields/dob.php deleted file mode 100644 index 2aa0f0e429944..0000000000000 --- a/layouts/plugins/user/profile/fields/dob.php +++ /dev/null @@ -1,24 +0,0 @@ - - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -defined('_JEXEC') or die; - -extract($displayData); - -/** - * Layout variables - * ----------------- - * @var string $text infotext to be displayed - */ - -// Closing the opening .control-group and .control-label div so we can add our info text on own line ?> - -
- -
From a7a5c6a241433acd21e4f9344167105e9955de25 Mon Sep 17 00:00:00 2001 From: Brian Teeman Date: Wed, 15 Jun 2022 18:08:48 +0100 Subject: [PATCH 3/3] Update script.php --- administrator/components/com_admin/script.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/administrator/components/com_admin/script.php b/administrator/components/com_admin/script.php index 5579f731a7c11..79b0dbb71fe1f 100644 --- a/administrator/components/com_admin/script.php +++ b/administrator/components/com_admin/script.php @@ -6474,9 +6474,6 @@ public function deleteUnexistingFiles($dryRun = false, $suppressOutput = false) '/plugins/twofactorauth/yubikey/tmpl/form.php', '/plugins/twofactorauth/yubikey/yubikey.php', '/plugins/twofactorauth/yubikey/yubikey.xml', - // From 4.2 - '/plugins/user/profile/src/Field/DobField.php', - '/layouts/plugins/user/profile/fields/dob.php', ); $folders = array( @@ -7838,10 +7835,6 @@ public function deleteUnexistingFiles($dryRun = false, $suppressOutput = false) '/plugins/twofactorauth/totp', '/plugins/twofactorauth', '/libraries/vendor/nyholm/psr7/doc', - // From 4.2 - '/layouts/plugins/user/profile/fields', - '/layouts/plugins/user/profile', - '/layouts/plugins/user/', ); $status['files_checked'] = $files;