make more oo-ey
authordemeritcowboy <demeritcowboy@hotmail.com>
Thu, 20 May 2021 12:34:21 +0000 (08:34 -0400)
committerdemeritcowboy <demeritcowboy@hotmail.com>
Thu, 20 May 2021 12:34:21 +0000 (08:34 -0400)
CRM/Contact/Form/Task/Useradd.php
CRM/Utils/System/Base.php
CRM/Utils/System/WordPress.php

index 4aa24ce2adb00436860c0be7422518dc4018747b..27a4ff7dd4a7aa0d7badcaffb87e0ef1cac85891 100644 (file)
@@ -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');
index 80ffa437e22e6cf25332410c280a542d68be8951..e08bad2c069a0a7ee567575011cda4f79baa7a15 100644 (file)
@@ -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;
+  }
+
 }
index 26acbb1a8aa1a80d278ea5064bd13b889d8e0d51..d69c0fcc21af2c28f86f7e0806cd19d4f0af88c5 100644 (file)
@@ -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();
+  }
+
 }