From: demeritcowboy Date: Thu, 20 May 2021 12:34:21 +0000 (-0400) Subject: make more oo-ey X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=0e69cbc373c8cf4de95eb028ff67526b4d9d3350;p=civicrm-core.git make more oo-ey --- diff --git a/CRM/Contact/Form/Task/Useradd.php b/CRM/Contact/Form/Task/Useradd.php index 4aa24ce2ad..27a4ff7dd4 100644 --- a/CRM/Contact/Form/Task/Useradd.php +++ b/CRM/Contact/Form/Task/Useradd.php @@ -71,9 +71,9 @@ class CRM_Contact_Form_Task_Useradd extends CRM_Core_Form { $this->add('text', 'cms_name', ts('Username'), ['class' => 'huge']); $this->addRule('cms_name', ts('Username is required'), 'required'); - // For WordPress only, comply with how WordPress sets passwords via magic link + // WordPress may or may not require setting passwords via magic link, depending on its configuration. // For other CMS, output the password fields - if ($config->userFramework !== 'WordPress' || ($config->userFramework === 'WordPress' && !$config->userSystem->isUserRegistrationPermitted())) { + if ($config->userSystem->showPasswordFieldWhenAdminCreatesUser()) { $this->add('password', 'cms_pass', ts('Password'), ['class' => 'huge']); $this->add('password', 'cms_confirm_pass', ts('Confirm Password'), ['class' => 'huge']); $this->addRule('cms_pass', ts('Password is required'), 'required'); diff --git a/CRM/Utils/System/Base.php b/CRM/Utils/System/Base.php index 80ffa437e2..e08bad2c06 100644 --- a/CRM/Utils/System/Base.php +++ b/CRM/Utils/System/Base.php @@ -1057,4 +1057,12 @@ abstract class CRM_Utils_System_Base { public function invalidateRouteCache() { } + /** + * Should the admin be able to set the password when creating a user + * or does the CMS want it a different way. + */ + public function showPasswordFieldWhenAdminCreatesUser() { + return TRUE; + } + } diff --git a/CRM/Utils/System/WordPress.php b/CRM/Utils/System/WordPress.php index 26acbb1a8a..d69c0fcc21 100644 --- a/CRM/Utils/System/WordPress.php +++ b/CRM/Utils/System/WordPress.php @@ -1462,4 +1462,12 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { add_action('profile_update', [$civicrm->users, 'update_user']); } + /** + * Depending on configuration, either let the admin enter the password + * when creating a user or let the user do it via email link. + */ + public function showPasswordFieldWhenAdminCreatesUser() { + return !$this->isUserRegistrationPermitted(); + } + }