If secondary mails exist, print them in account settings, and allow to delete them

This commit is contained in:
Patrick Georgi 2011-02-20 23:57:48 +01:00
parent 46fda14e08
commit 5afd073ff3
3 changed files with 36 additions and 0 deletions

View File

@ -127,12 +127,14 @@ class IDF_Views_User
$form = new IDF_Form_UserAccount(null, $params);
}
$keys = $request->user->get_idf_key_list();
$mailaddrs = Pluf::factory('IDF_EmailAddress')->get_email_addresses_for_user($request->user);
return Pluf_Shortcuts_RenderToResponse('idf/user/myaccount.html',
array('page_title' => __('Your Account'),
'api_key' => $api_key,
'ext_pass' => $ext_pass,
'keys' => $keys,
'mailaddrs' => $mailaddrs,
'form' => $form),
$request);
}
@ -157,6 +159,26 @@ class IDF_Views_User
return new Pluf_HTTP_Response_Redirect($url);
}
/**
* Delete a mail address.
*
* This is redirecting to the preferences
*/
public $deleteMail_precond = array('Pluf_Precondition::loginRequired');
public function deleteMail($request, $match)
{
$url = Pluf_HTTP_URL_urlForView('IDF_Views_User::myAccount');
if ($request->method == 'POST') {
$address = Pluf_Shortcuts_GetObjectOr404('IDF_EmailAddress', $match[1]);
if ($address->user != $request->user->id) {
return new Pluf_HTTP_Response_Forbidden($request);
}
$address->delete();
$request->user->setMessage(__('The address has been deleted.'));
}
return new Pluf_HTTP_Response_Redirect($url);
}
/**
* Enter the key to change an email address.
*

View File

@ -471,6 +471,11 @@ $ctl[] = array('regex' => '#^/preferences/email/ak/(.*)/$#',
'model' => 'IDF_Views_User',
'method' => 'changeEmailDo');
$ctl[] = array('regex' => '#^/preferences/email/(\d+)/delete/$#',
'base' => $base,
'model' => 'IDF_Views_User',
'method' => 'deleteMail');
$ctl[] = array('regex' => '#^/preferences/key/(\d+)/delete/$#',
'base' => $base,
'model' => 'IDF_Views_User',

View File

@ -129,6 +129,15 @@
</tr>{/foreach}
</table>
{/if}
{if count($mailaddrs)>1}
<table summary=" " class="recent-issues">
<tr><th colspan="2">{trans 'Your additional email addresses'}</th></tr>
{foreach $mailaddrs as $mail}{if $mail.id != -1}<tr><td>
{$mail.address}</td><td> <form class="star" method="post" action="{url 'IDF_Views_User::deleteMail', array($mail.id)}"><input type="image" src="{media '/idf/img/trash.png'}" name="submit" value="{trans 'Delete this address'}" /></form>
</td>
</tr>{/if}{/foreach}
</table>
{/if}
{/block}
{block context}
<div class="issue-submit-info">