Add UI for adding secondary email addresses

This commit is contained in:
Patrick Georgi 2011-02-21 00:20:23 +01:00
parent 5afd073ff3
commit 0a8d771c11
2 changed files with 24 additions and 0 deletions

View File

@ -163,6 +163,13 @@ class IDF_Form_UserAccount extends Pluf_Form
'widget' => 'Pluf_Form_Widget_TextareaInput', 'widget' => 'Pluf_Form_Widget_TextareaInput',
'help_text' => __('Paste a SSH or monotone public key. Be careful to not provide your private key here!') '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']; 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() function clean_public_key()
{ {
$this->cleaned_data['public_key'] = $this->cleaned_data['public_key'] =

View File

@ -100,6 +100,14 @@
<span class="helptext">{$form.f.public_key.help_text}</span> <span class="helptext">{$form.f.public_key.help_text}</span>
</td> </td>
</tr> </tr>
<tr><td colspan="2" class="separator">{trans "Secondary Emails"}</td></tr>
<tr>
<th>{$form.f.secondary_mail.labelTag}:</th>
<td>{if $form.f.secondary_mail.errors}{$form.f.secondary_mail.fieldErrors}{/if}
{$form.f.secondary_mail|unsafe}<br />
<span class="helptext">{$form.f.secondary_mail.help_text}</span>
</td>
</tr>
<tr class="pass-info" id="extra-password"> <tr class="pass-info" id="extra-password">
<th>{trans 'Extra password'}:</th> <th>{trans 'Extra password'}:</th>
<td><span class="mono">{$ext_pass}</span><br /> <td><span class="mono">{$ext_pass}</span><br />