Created from #1775842: [meta] Convert all variables to state and/or config systems.

register_pending_approval_admin user.module

Files: 
CommentFileSizeAuthor
#15 register_pending_approval_admin-1804926-15.patch3.61 KBedrupal
PASSED: [[SimpleTest]]: [MySQL] 50,668 pass(es).
[ View ]
#15 interdiff-7-15.txt2.35 KBedrupal
#7 register_pending_approval_admin-1804926-7.patch3.63 KBtyphonius
PASSED: [[SimpleTest]]: [MySQL] 49,286 pass(es).
[ View ]
#4 register_pending_approval_admin-1804926-1.patch1.4 KBela.m
PASSED: [[SimpleTest]]: [MySQL] 46,432 pass(es).
[ View ]
#1 register_pending_approval_admin-1804926-1.patch1.39 KBrbayliss
PASSED: [[SimpleTest]]: [MySQL] 42,132 pass(es).
[ View ]

Comments

rbayliss’s picture

Status:Active» Needs review
StatusFileSize
new1.39 KB
PASSED: [[SimpleTest]]: [MySQL] 42,132 pass(es).
[ View ]
alexpott’s picture

Status:Needs review» Needs work
  body: "[user:name] has applied for an account. [user:edit-url]"

This is not precisely the same as it was in Drupal 7. It should be:

  body: "[user:name] has applied for an account.\n\n[user:edit-url]"
ela.m’s picture

Assigned:Unassigned» ela.m
ela.m’s picture

Status:Needs work» Needs review
StatusFileSize
new1.4 KB
PASSED: [[SimpleTest]]: [MySQL] 46,432 pass(es).
[ View ]

Just added the "\n\n"s..

ela.m’s picture

Assigned:ela.m» Unassigned
aspilicious’s picture

I'm so confused about this. Where does this ever gets called? Can it be set in the UI? Where?

typhonius’s picture

StatusFileSize
new3.63 KB
PASSED: [[SimpleTest]]: [MySQL] 49,286 pass(es).
[ View ]

It's not actually set in the UI anywhere but after a bit of a trace I think I've found where it gets called.

register_pending_approval_admin is the mail key set when admin approval is required for user registration and the mail is going to the admin. This is called from the user module.
The drupal_mail function calls any functions which are of the type $module . '_mail' (user_mail function).

Within user_mail the subject and body are created by calling _user_mail_text with the $key (register_pending_approval_admin) followed by .subject or .body respectively.

_user_mail_text then does a config lookup with what is passed to it (register_pending_approval_admin.subject etc).

Perhaps then this should be a user configurable setting - to allow the email sent to admins when there is a new user awaiting approval to be customised?

I'm still relatively new to the whole CMI scene so my user_update_N function may not be correct. As far as I can tell though, that config does need to be set as it does get called.

edrupal’s picture

It looks like this functionality is also being addressed by patch 809806-Register pending approval admin mails not configurable.patch in issue Register pending approval admin mails not configurable?.

No idea which is the better approach.

Please ignore, I was getting my versions confused.

edrupal’s picture

The last section of the patch in #7 above failed to apply for me (the user.install changes)

typhonius’s picture

It may need rerolling for updates to HEAD

alexpott’s picture

Status:Needs review» Needs work
+++ b/core/modules/user/user.installundefined
@@ -1042,3 +1042,20 @@ function _user_install_picture_field(array $settings = array()) {
+function user_update_8017() {
+  $config_key = 'user.mail';
+  $config = config($config_key);
+  $config_data = array(
+    'register_pending_approval_admin.body' => "[user:name] has applied for an account.\n\n[user:edit-url]",
+    'register_pending_approval_admin.subject' => 'Account details for [user:name] at [site:name] (pending admin approval)',
+  );
+  $config->set($config_key, $config_data);
+  $config->save();
+}

This function needs to migrate the variable from Drupal 7. There is a helper function to do this. See http://api.drupal.org/api/drupal/core!modules!user!user.install/function... for how to do this.

Actually this is a special case since the user.mail.yml in already updated by user_update_8006() so you can just add the two new variables to the conversion function.

alexpott’s picture

Title:Convert register_pending_approval_admin to config/state system.» Convert register_pending_approval_admin email to config system and provide the ability to configure it in UI.
tstoeckler’s picture

YesCT’s picture

Issue tags:+Needs reroll

in case @edrupal or anyone else wants to try a reroll, here is the doc page for rerolls http://drupal.org/patch/reroll

edrupal’s picture

StatusFileSize
new2.35 KB
new3.61 KB
PASSED: [[SimpleTest]]: [MySQL] 50,668 pass(es).
[ View ]

I've had a go at re-rolling the patch in #7. Also made the following changes:

  1. Slight correction to the help text for the new field on the UI.
  2. Moved the new variables from user_update_8017() to user_update_8006 as suggested by @alexpott (Have I understood what's needed correctly?)

Ed

typhonius’s picture

Status:Needs work» Needs review

Setting the issue status to 'needs review' will trigger the review bot to test the patch.

Berdir’s picture

Status:Needs review» Reviewed & tested by the community

Looks good to me. Does not have upgrade test coverage, but I don't think that we need explicit coverage for every single trivial variable.

YesCT’s picture

YesCT’s picture

YesCT’s picture

Since it had been 5 days, and d8 is moving fast, I used the re-test link on the most recent patch to have to testbot test it again. That way we can reroll it if needed.

catch’s picture

Status:Reviewed & tested by the community» Fixed

Committed/pushed to 8.x, thanks!

Automatically closed -- issue fixed for 2 weeks with no activity.