123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- <?php
- if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
- }
- class DeleteuserAction extends ProfileFormAction
- {
- var $user = null;
-
- function prepare($args)
- {
- if (!parent::prepare($args)) {
- return false;
- }
- $cur = common_current_user();
- assert(!empty($cur));
- if (!$cur->hasRight(Right::DELETEUSER)) {
-
- $this->clientError(_('You cannot delete users.'));
- }
- $this->user = User::getKV('id', $this->profile->id);
- if (empty($this->user)) {
-
- $this->clientError(_('You can only delete local users.'));
- }
- return true;
- }
-
- function handle($args)
- {
- if ($_SERVER['REQUEST_METHOD'] == 'POST') {
- if ($this->arg('no')) {
- $this->returnToPrevious();
- } elseif ($this->arg('yes')) {
- $this->handlePost();
- $this->returnToPrevious();
- } else {
- $this->showPage();
- }
- }
- }
- function showContent() {
- $this->areYouSureForm();
- $block = new AccountProfileBlock($this, $this->profile);
- $block->show();
- }
- function title() {
-
- return _m('TITLE','Delete user');
- }
- function showNoticeForm() {
-
- }
-
- function areYouSureForm()
- {
- $id = $this->profile->id;
- $this->elementStart('form', array('id' => 'deleteuser-' . $id,
- 'method' => 'post',
- 'class' => 'form_settings form_entity_block',
- 'action' => common_local_url('deleteuser')));
- $this->elementStart('fieldset');
- $this->hidden('token', common_session_token());
-
- $this->element('legend', _('Delete user'));
- if (Event::handle('StartDeleteUserForm', array($this, $this->user))) {
- $this->element('p', null,
-
- _('Are you sure you want to delete this user? '.
- 'This will clear all data about the user from the '.
- 'database, without a backup.'));
- $this->element('input', array('id' => 'deleteuserto-' . $id,
- 'name' => 'profileid',
- 'type' => 'hidden',
- 'value' => $id));
- foreach ($this->args as $k => $v) {
- if (substr($k, 0, 9) == 'returnto-') {
- $this->hidden($k, $v);
- }
- }
- Event::handle('EndDeleteUserForm', array($this, $this->user));
- }
- $this->submit('form_action-no',
-
- _m('BUTTON','No'),
- 'submit form_action-primary',
- 'no',
-
- _('Do not delete this user.'));
- $this->submit('form_action-yes',
-
- _m('BUTTON','Yes'),
- 'submit form_action-secondary',
- 'yes',
-
- _('Delete this user.'));
- $this->elementEnd('fieldset');
- $this->elementEnd('form');
- }
-
- function handlePost()
- {
- if (Event::handle('StartDeleteUser', array($this, $this->user))) {
-
-
- if (!$this->user->hasRole(Profile_role::DELETED)) {
- $this->user->grantRole(Profile_role::DELETED);
- }
- $qm = QueueManager::get();
- $qm->enqueue($this->user, 'deluser');
- Event::handle('EndDeleteUser', array($this, $this->user));
- }
- }
- }
|