From 0a8d771c1132c4fe5df50b28a99a531c4c077597 Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Mon, 21 Feb 2011 00:20:23 +0100 Subject: [PATCH] Add UI for adding secondary email addresses --- src/IDF/Form/UserAccount.php | 16 ++++++++++++++++ src/IDF/templates/idf/user/myaccount.html | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/src/IDF/Form/UserAccount.php b/src/IDF/Form/UserAccount.php index 2474aeb..2a9914f 100644 --- a/src/IDF/Form/UserAccount.php +++ b/src/IDF/Form/UserAccount.php @@ -163,6 +163,13 @@ class IDF_Form_UserAccount extends Pluf_Form 'widget' => 'Pluf_Form_Widget_TextareaInput', 'help_text' => __('Paste a SSH or monotone public key. Be careful to not provide your private key here!') )); + + $this->fields['secondary_mail'] = new Pluf_Form_Field_Email( + array('required' => false, + 'label' => __('Add a secondary mail address'), + 'initial' => '', + 'help_text' => __('You will get a mail to confirm that you own the address you specify.'), + )); } /** @@ -400,6 +407,15 @@ class IDF_Form_UserAccount extends Pluf_Form return $this->cleaned_data['email']; } + function clean_secondary_mail() + { + $this->cleaned_data['secondary_mail'] = mb_strtolower(trim($this->cleaned_data['secondary_mail'])); + if (Pluf::factory('IDF_EmailAddress')->get_user_for_email_address($this->cleaned_data['secondary_mail']) != null) { + throw new Pluf_Form_Invalid(sprintf(__('The email "%s" is already used.'), $this->cleaned_data['secondary_mail'])); + } + return $this->cleaned_data['secondary_mail']; + } + function clean_public_key() { $this->cleaned_data['public_key'] = diff --git a/src/IDF/templates/idf/user/myaccount.html b/src/IDF/templates/idf/user/myaccount.html index a1de2b1..f84dbec 100644 --- a/src/IDF/templates/idf/user/myaccount.html +++ b/src/IDF/templates/idf/user/myaccount.html @@ -100,6 +100,14 @@ {$form.f.public_key.help_text} +{trans "Secondary Emails"} + +{$form.f.secondary_mail.labelTag}: +{if $form.f.secondary_mail.errors}{$form.f.secondary_mail.fieldErrors}{/if} +{$form.f.secondary_mail|unsafe}
+{$form.f.secondary_mail.help_text} + + {trans 'Extra password'}: {$ext_pass}