if (!defined('LACONICA')) { exit(1); }
-require_once(INSTALLDIR.'/lib/settingsaction.php');
-
-class DeleteprofileAction extends Action { // was SettingsAction...
-
- function get_instructions() {
- return _('You can update your personal profile info here '.
- 'so people know more about you.');
- }
-
- 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
+class DeleteprofileAction extends Action
+{
+ function handle($args)
+ {
+ parent::handle($args);
+ $this->serverError(_('Code not yet ready.'));
+ return;
+ if ('POST' === $_SERVER['REQUEST_METHOD']) {
+ $this->handle_post();
+ }
+ else if ('GET' === $_SERVER['REQUEST_METHOD']) {
+ $this->show_form();
+ }
+ }
- $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 get_instructions()
+ {
+ return _('Export and delete your user information.');
+ }
- 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)
+ {
+ $this->elementStart('div', array('class' => 'feedsdel'));
+ $this->element('p', null, 'Feeds:');
+ $this->elementStart('ul', array('class' => 'xoxo'));
+
+ foreach ($feeds as $key => $value) {
+ $this->common_feed_item($feeds[$key]);
+ }
+ $this->elementEnd('ul');
+ $this->elementEnd('div');
+ }
- function show_feeds_list($feeds) {
- common_element_start('div', array('class' => 'feedsdel'));
- common_element('p', null, 'Feeds:');
- common_element_start('ul', array('class' => 'xoxo'));
+ //TODO move to common.php (and retrace its origin)
+ function common_feed_item($feed)
+ {
+ $user = common_current_user();
+ $nickname = $user->nickname;
+
+ switch($feed['item']) {
+ case 'notices': default:
+ $feed_classname = $feed['type'];
+ $feed_mimetype = "application/".$feed['type']."+xml";
+ $feed_title = "$nickname's ".$feed['version']." notice feed";
+ $feed['textContent'] = "RSS";
+ break;
+
+ case 'foaf':
+ $feed_classname = "foaf";
+ $feed_mimetype = "application/".$feed['type']."+xml";
+ $feed_title = "$nickname's FOAF file";
+ $feed['textContent'] = "FOAF";
+ break;
+ }
+ $this->elementStart('li');
+ $this->element('a', array('href' => $feed['href'],
+ 'class' => $feed_classname,
+ 'type' => $feed_mimetype,
+ 'title' => $feed_title),
+ $feed['textContent']);
+ $this->elementEnd('li');
+ }
- foreach ($feeds as $key => $value) {
- $this->common_feed_item($feeds[$key]);
- }
- common_element_end('ul');
- common_element_end('div');
- }
+ function show_form($msg=null, $success=false)
+ {
+ $this->form_header(_('Delete my account'), $msg, $success);
+ $this->element('h2', null, _('Delete my account confirmation'));
+ $this->show_confirm_delete_form();
+ common_show_footer();
+ }
- //TODO move to common.php (and retrace its origin)
- function common_feed_item($feed) {
+ function show_confirm_delete_form()
+ {
$user = common_current_user();
- $nickname = $user->nickname;
-
- switch($feed['item']) {
- case 'notices': default:
- $feed_classname = $feed['type'];
- $feed_mimetype = "application/".$feed['type']."+xml";
- $feed_title = "$nickname's ".$feed['version']." notice feed";
- $feed['textContent'] = "RSS";
- break;
-
- case 'foaf':
- $feed_classname = "foaf";
- $feed_mimetype = "application/".$feed['type']."+xml";
- $feed_title = "$nickname's FOAF file";
- $feed['textContent'] = "FOAF";
- break;
- }
- common_element_start('li');
- common_element('a', array('href' => $feed['href'],
- 'class' => $feed_classname,
- 'type' => $feed_mimetype,
- 'title' => $feed_title),
- $feed['textContent']);
- common_element_end('li');
- }
-
- function show_delete_form() {
- $user = common_current_user();
$notices = DB_DataObject::factory('notice');
$notices->profile_id = $user->id;
$notice_count = (int) $notices->count();
- common_element_start('form', array('method' => 'POST',
- 'id' => 'delete',
- 'action' =>
- common_local_url('profilesettings')));
+ $this->elementStart('form', array('method' => 'POST',
+ 'id' => 'delete',
+ 'action' =>
+ 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.");
+ $this->hidden('token', common_session_token());
+ $this->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)),
+ 'type' => 'rss',
+ 'version' => 'RSS 1.0',
+ 'item' => 'notices'),
+ 1=>array('href'=>common_local_url('foaf',array('nickname' => $user->nickname)),
+ 'type' => 'rdf',
+ 'version' => 'FOAF',
+ 'item' => 'foaf')));
- $this->show_feeds_list(array(0=>array('href'=>common_local_url('userrss', array('limit' => $notice_count, 'nickname' => $user->nickname)),
- 'type' => 'rss',
- 'version' => 'RSS 1.0',
- 'item' => 'notices'),
- 1=>array('href'=>common_local_url('foaf',array('nickname' => $user->nickname)),
- 'type' => 'rdf',
- 'version' => 'FOAF',
- 'item' => 'foaf')));
+ $this->checkbox('confirmation', _('Check if you are sure you want to delete your account.'));
- common_submit('deleteaccount', _('Delete my account'));
- common_element_end('form');
- }
+ $this->submit('deleteaccount', _('Delete my account'));
+ $this->elementEnd('form');
+ }
- function delete_account_confirmation() {
- // ask confirmation then
- $this->delete_account();
+ 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->arg('confirmation')) {
+ $this->delete_account();
+ }
+ $this->show_form();
}
- function delete_account() {
- $user = common_current_user();
- assert(!is_null($user)); # should already be checked
+ function delete_account()
+ {
+ $user = common_current_user();
+ assert(!is_null($user)); # should already be checked
// deleted later through the profile
/*
$fave = new Fave;
$fave->user_id = $user->id;
- $n_faves_deleted = $fave->delete();
+ $n_faves_deleted = $fave->delete();
$confirmation = new Confirm_address;
$confirmation->user_id = $user->id;
$profile_tagged = new Profile_tag;
$profile_tagged->tagged = $user->id;
$n_profiles_tagged_deleted = $profile_tagged->delete();
-
+
$remember_me = new Remember_me;
$remember_me->user_id = $user->id;
$n_remember_mes_deleted = $remember_me->delete();
$n_users_deleted = $user->delete();
// logout and redirect to public
- common_set_user(NULL);
+ common_set_user(null);
common_real_login(false); # not logged in
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);
+ $this->elementStart('div', 'instructions');
+ $this->raw($output);
+ $this->elementEnd('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');
+ $this->elementStart('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);
+ }
+ $this->elementEnd('ul');
+ }
}
+