X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fdeleteuser.php;h=42ef4b9f513de031b77f05acaeb2908c2cd96f75;hb=166c1edba97d065d0fd424621305fd016e644c43;hp=32b703aa7f099fe3e79bf067b184ea1c52339183;hpb=bac2d80c919a78d5cafd57f712872a90cda04847;p=quix0rs-gnu-social.git diff --git a/actions/deleteuser.php b/actions/deleteuser.php index 32b703aa7f..42ef4b9f51 100644 --- a/actions/deleteuser.php +++ b/actions/deleteuser.php @@ -64,14 +64,14 @@ class DeleteuserAction extends ProfileFormAction assert(!empty($cur)); // checked by parent if (!$cur->hasRight(Right::DELETEUSER)) { - $this->clientError(_("You cannot delete users.")); + $this->clientError(_('You cannot delete users.')); return false; } $this->user = User::staticGet('id', $this->profile->id); if (empty($this->user)) { - $this->clientError(_("You can only delete local users.")); + $this->clientError(_('You can only delete local users.')); return false; } @@ -131,18 +131,21 @@ class DeleteuserAction extends ProfileFormAction $this->elementStart('fieldset'); $this->hidden('token', common_session_token()); $this->element('legend', _('Delete 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); + 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', _('No'), 'submit form_action-primary', 'no', _("Do not block this user")); $this->submit('form_action-yes', _('Yes'), 'submit form_action-secondary', 'yes', _('Delete this user')); @@ -158,7 +161,17 @@ class DeleteuserAction extends ProfileFormAction function handlePost() { - $this->user->delete(); + if (Event::handle('StartDeleteUser', array($this, $this->user))) { + // Mark the account as deleted and shove low-level deletion tasks + // to background queues. Removing a lot of posts can take a while... + 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)); + } } } -