123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326 |
- <?php
- if (!defined('STATUSNET')) {
-
-
- exit(1);
- }
- class DeleteaccountAction extends Action
- {
- private $_complete = false;
- private $_error = null;
-
- function prepare($argarray)
- {
- parent::prepare($argarray);
- $cur = common_current_user();
- if (empty($cur)) {
-
- throw new ClientException(_("Only logged-in users ".
- "can delete their account."), 403);
- }
- if (!$cur->hasRight(Right::DELETEACCOUNT)) {
-
- throw new ClientException(_("You cannot delete your account."), 403);
- }
- return true;
- }
-
- function handle($argarray=null)
- {
- parent::handle($argarray);
- if ($this->isPost()) {
- $this->deleteAccount();
- } else {
- $this->showPage();
- }
- return;
- }
-
- function isReadOnly($args)
- {
- return false;
- }
-
- function lastModified()
- {
-
-
- return null;
- }
-
- function etag()
- {
- return null;
- }
-
- function deleteAccount()
- {
- $this->checkSessionToken();
-
-
- $iamsure = _('I am sure.');
- if ($this->trimmed('iamsure') != $iamsure ) {
-
-
- $this->_error = sprintf(_('You must write "%s" exactly in the box.'), $iamsure);
- $this->showPage();
- return;
- }
- $cur = common_current_user();
-
-
- if (!$cur->hasRole(Profile_role::DELETED)) {
- $cur->grantRole(Profile_role::DELETED);
- }
- $qm = QueueManager::get();
- $qm->enqueue($cur, 'deluser');
-
- common_set_user(null);
- common_real_login(false);
- common_forgetme();
- $this->_complete = true;
- $this->showPage();
- }
-
- function showContent()
- {
- if ($this->_complete) {
- $this->element('p', 'confirmation',
-
- _('Account deleted.'));
- return;
- }
- if (!empty($this->_error)) {
- $this->element('p', 'error', $this->_error);
- $this->_error = null;
- }
- $form = new DeleteAccountForm($this);
- $form->show();
- }
-
- function title()
- {
-
- return _('Delete account');
- }
- }
- class DeleteAccountForm extends Form
- {
-
- function formClass()
- {
- return 'form_profile_delete';
- }
-
- function action()
- {
- return common_local_url('deleteaccount');
- }
-
- function formData()
- {
- $cur = common_current_user();
-
- $msg = '<p>' . _('This will <strong>permanently delete</strong> '.
- 'your account data from this server.') . '</p>';
- if ($cur->hasRight(Right::BACKUPACCOUNT)) {
-
-
- $msg .= '<p>' . sprintf(_('You are strongly advised to '.
- '<a href="%s">back up your data</a>'.
- ' before deletion.'),
- common_local_url('backupaccount')) . '</p>';
- }
- $this->out->elementStart('p');
- $this->out->raw($msg);
- $this->out->elementEnd('p');
-
-
- $iamsure = _("I am sure.");
- $this->out->input('iamsure',
-
- _('Confirm'),
- null,
-
-
- sprintf(_('Enter "%s" to confirm that '.
- 'you want to delete your account.'),$iamsure ));
- }
-
- function formActions()
- {
- $this->out->submit('submit',
-
- _m('BUTTON', 'Delete'),
- 'submit',
- null,
-
- _('Permanently delete your account.'));
- }
- }
|