diff options
author | millette <millette@controlyourself.ca> | 2008-12-04 13:02:33 -0500 |
---|---|---|
committer | millette <millette@controlyourself.ca> | 2008-12-04 13:02:33 -0500 |
commit | 6eb506062189557e5e5f40212c4cc7a1faec27fd (patch) | |
tree | 276f5618d8348d25368e2f49e6bcb411a582e59a /actions/deleteprofile.php | |
parent | 2c7518873eddafcd041fe73a509756155f35ac9a (diff) |
done delete own profile (see other settings)
darcs-hash:20081204180233-099f7-7728ee57876b789278aa1cc35f54e0a422593e5d.gz
Diffstat (limited to 'actions/deleteprofile.php')
-rw-r--r-- | actions/deleteprofile.php | 130 |
1 files changed, 97 insertions, 33 deletions
diff --git a/actions/deleteprofile.php b/actions/deleteprofile.php index 4328dfc2c..99e65ceb7 100644 --- a/actions/deleteprofile.php +++ b/actions/deleteprofile.php @@ -19,36 +19,26 @@ if (!defined('LACONICA')) { exit(1); } -require_once(INSTALLDIR.'/lib/settingsaction.php'); - -class DeleteprofileAction extends Action { // was SettingsAction... +class DeleteprofileAction extends Action { + function handle($args) { + parent::handle($args); + if ('POST' === $_SERVER['REQUEST_METHOD']) { + $this->handle_post(); + } + else if ('GET' === $_SERVER['REQUEST_METHOD']) { + $this->show_form(); + } + } function get_instructions() { - return _('You can update your personal profile info here '. - 'so people know more about you.'); + return _('Export and delete your user information.'); } - function show_form($msg=NULL, $success=false) { - $this->form_header(_('Delete my account'), $msg, $success); - common_element('h2', NULL, _('Delete my account')); - $this->show_delete_form(); - common_show_footer(); - } - - function handle_post() { - - # CSRF protection - - $token = $this->trimmed('token'); - if (!$token || $token != common_session_token()) { - $this->show_form(_('There was a problem with your session token. Try again, please.')); - return; - } - - if ($this->arg('deleteaccount')) { - $this->delete_account_confirmation(); - } - + function form_header($title, $msg=NULL, $success=false) { + common_show_header($title, + NULL, + array($msg, $success), + array($this, 'show_top')); } function show_feeds_list($feeds) { @@ -92,7 +82,14 @@ class DeleteprofileAction extends Action { // was SettingsAction... common_element_end('li'); } - function show_delete_form() { + function show_form($msg=NULL, $success=false) { + $this->form_header(_('Delete my account'), $msg, $success); + common_element('h2', NULL, _('Delete my account confirmation')); + $this->show_confirm_delete_form(); + common_show_footer(); + } + + function show_confirm_delete_form() { $user = common_current_user(); $notices = DB_DataObject::factory('notice'); $notices->profile_id = $user->id; @@ -101,10 +98,10 @@ class DeleteprofileAction extends Action { // was SettingsAction... common_element_start('form', array('method' => 'POST', 'id' => 'delete', 'action' => - common_local_url('profilesettings'))); + common_local_url('deleteprofile'))); common_hidden('token', common_session_token()); - common_element('p', null, "You can copy your notices and contacts by saving the two links belowxbefore deleting your account. Be careful, this operation cannot be undone."); + common_element('p', null, "Last chance to copy your notices and contacts by saving the two links below before deleting your account. Be careful, this operation cannot be undone."); $this->show_feeds_list(array(0=>array('href'=>common_local_url('userrss', array('limit' => $notice_count, 'nickname' => $user->nickname)), @@ -116,13 +113,24 @@ class DeleteprofileAction extends Action { // was SettingsAction... 'version' => 'FOAF', 'item' => 'foaf'))); + common_checkbox('confirmation', _('Check if you are sure you want to delete your account.')); + common_submit('deleteaccount', _('Delete my account')); common_element_end('form'); - } + } + + function handle_post() { + # CSRF protection + $token = $this->trimmed('token'); + if (!$token || $token != common_session_token()) { + $this->show_form(_('There was a problem with your session token. Try again, please.')); + return; + } - function delete_account_confirmation() { - // ask confirmation then - $this->delete_account(); + if ($this->arg('deleteaccount') && $this->arg('confirmation')) { + $this->delete_account(); + } + $this->show_form(); } function delete_account() { @@ -209,4 +217,60 @@ class DeleteprofileAction extends Action { // was SettingsAction... common_forgetme(); # don't log back in! common_redirect(common_local_url('public')); } + + function show_top($arr) { + $msg = $arr[0]; + $success = $arr[1]; + if ($msg) { + $this->message($msg, $success); + } else { + $inst = $this->get_instructions(); + $output = common_markup_to_html($inst); + common_element_start('div', 'instructions'); + common_raw($output); + common_element_end('div'); + } + $this->settings_menu(); + } + + function settings_menu() { + # action => array('prompt', 'title') + $menu = + array('profilesettings' => + array(_('Profile'), + _('Change your profile settings')), + 'emailsettings' => + array(_('Email'), + _('Change email handling')), + 'openidsettings' => + array(_('OpenID'), + _('Add or remove OpenIDs')), + 'smssettings' => + array(_('SMS'), + _('Updates by SMS')), + 'imsettings' => + array(_('IM'), + _('Updates by instant messenger (IM)')), + 'twittersettings' => + array(_('Twitter'), + _('Twitter integration options')), + 'othersettings' => + array(_('Other'), + _('Other options'))); + + $action = $this->trimmed('action'); + common_element_start('ul', array('id' => 'nav_views')); + foreach ($menu as $menuaction => $menudesc) { + if ($menuaction == 'imsettings' && + !common_config('xmpp', 'enabled')) { + continue; + } + common_menu_item(common_local_url($menuaction), + $menudesc[0], + $menudesc[1], + $action == $menuaction); + } + common_element_end('ul'); + } } + |