Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-21272: move definition of isPasswordUserGenerated to CMS classes #11145

Merged
merged 2 commits into from
Oct 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CRM/Core/BAO/CMSUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static function buildForm(&$form, $gid, $emailPresent, $action = CRM_Core
$form->assign('isCMS', $required);
if (!$userID || $action & CRM_Core_Action::PREVIEW || $action & CRM_Core_Action::PROFILE) {
$form->add('text', 'cms_name', ts('Username'), NULL, $required);
if (($isDrupal && !variable_get('user_email_verification', TRUE)) OR ($isJoomla) OR ($isWordPress)) {
if ($config->userSystem->isPasswordUserGenerated()) {
$form->add('password', 'cms_pass', ts('Password'));
$form->add('password', 'cms_confirm_pass', ts('Confirm Password'));
}
Expand Down Expand Up @@ -197,7 +197,7 @@ public static function formRule($fields, $files, $form) {
$errors[$emailName] = ts('Please specify a valid email address.');
}

if (($isDrupal && !variable_get('user_email_verification', TRUE)) OR ($isJoomla) OR ($isWordPress)) {
if ($config->userSystem->isPasswordUserGenerated()) {
if (empty($fields['cms_pass']) ||
empty($fields['cms_confirm_pass'])
) {
Expand Down
10 changes: 10 additions & 0 deletions CRM/Utils/System/Backdrop.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,16 @@ public function isUserRegistrationPermitted() {
return TRUE;
}

/**
* @inheritDoc
*/
public function isPasswordUserGenerated() {
if (config_get('system.core', 'user_email_verification') == TRUE) {
return FALSE;
}
return TRUE;
}

/**
* @inheritDoc
*/
Expand Down
9 changes: 9 additions & 0 deletions CRM/Utils/System/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,15 @@ public function isUserRegistrationPermitted() {
return FALSE;
}

/**
* Check if user can create passwords or is initially assigned a system-generated one.
*
* @return bool
*/
public function isPasswordUserGenerated() {
return FALSE;
}

/**
* Get user login URL for hosting CMS (method declared in each CMS system class)
*
Expand Down
10 changes: 10 additions & 0 deletions CRM/Utils/System/Drupal8.php
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,16 @@ public function isUserRegistrationPermitted() {
return TRUE;
}

/**
* @inheritDoc
*/
public function isPasswordUserGenerated() {
if (\Drupal::config('user.settings')->get('verify_mail') == TRUE) {
return FALSE;
}
return TRUE;
}

/**
* @inheritDoc
*/
Expand Down
10 changes: 10 additions & 0 deletions CRM/Utils/System/DrupalBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,16 @@ public function isUserRegistrationPermitted() {
return TRUE;
}

/**
* @inheritDoc
*/
public function isPasswordUserGenerated() {
if (variable_get('user_email_verification', TRUE)) {
return FALSE;
}
return TRUE;
}

/**
* @inheritDoc
*/
Expand Down
7 changes: 7 additions & 0 deletions CRM/Utils/System/Joomla.php
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,13 @@ public function isUserRegistrationPermitted() {
return TRUE;
}

/**
* @inheritDoc
*/
public function isPasswordUserGenerated() {
return TRUE;
}

/**
* @inheritDoc
*/
Expand Down
7 changes: 7 additions & 0 deletions CRM/Utils/System/WordPress.php
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,13 @@ public function isUserRegistrationPermitted() {
return TRUE;
}

/**
* @inheritDoc
*/
public function isPasswordUserGenerated() {
return TRUE;
}

/**
* @return mixed
*/
Expand Down