From 69b2f19b6fef793aa607c6d8f4590b93e2565626 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 10 Mar 2010 10:06:46 -0800 Subject: RequireValidatedEmailPlugin fixes: require email on registration form, tidy up i18n infrastructure. --- .../RequireValidatedEmailPlugin.php | 23 +++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php') diff --git a/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php b/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php index 3581f1de9..ccefa14f6 100644 --- a/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php +++ b/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php @@ -54,12 +54,33 @@ class RequireValidatedEmailPlugin extends Plugin $user = User::staticGet('id', $notice->profile_id); if (!empty($user)) { // it's a remote notice if (!$this->validated($user)) { - throw new ClientException(_("You must validate your email address before posting.")); + throw new ClientException(_m("You must validate your email address before posting.")); } } return true; } + /** + * Event handler for registration attempts; rejects the registration + * if email field is missing. + * + * @param RegisterAction $action + * @return bool hook result code + */ + function onStartRegistrationTry($action) + { + $email = $action->trimmed('email'); + + if (empty($email)) { + $action->showForm(_m('You must provide an email address to register.')); + return false; + } + + // Default form will run address format validation and reject if bad. + + return true; + } + /** * Check if a user has a validated email address or has been * otherwise grandfathered in. -- cgit v1.2.3-54-g00ecf