From a092aac32d061c8f6265c9975040e9f8c0b96f55 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 6 Feb 2010 12:59:41 +0100 Subject: [PATCH] add events to fine-tune user deletion --- EVENTS.txt | 16 ++++++++++++++++ actions/deleteuser.php | 31 ++++++++++++++++++------------- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/EVENTS.txt b/EVENTS.txt index 6bf12bf13f..b4fc4cbebe 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -714,3 +714,19 @@ StartRobotsTxt: Before outputting the robots.txt page EndRobotsTxt: After the default robots.txt page (good place for customization) - &$action: RobotstxtAction being shown +StartDeleteUserForm: starting the data in the form for deleting a user +- $action: action being shown +- $user: user being deleted + +EndDeleteUserForm: Ending the data in the form for deleting a user +- $action: action being shown +- $user: user being deleted + +StartDeleteUser: handling the post for deleting a user +- $action: action being shown +- $user: user being deleted + +EndDeleteUser: handling the post for deleting a user +- $action: action being shown +- $user: user being deleted + diff --git a/actions/deleteuser.php b/actions/deleteuser.php index 32b703aa7f..c4f84fad2d 100644 --- a/actions/deleteuser.php +++ b/actions/deleteuser.php @@ -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,9 @@ class DeleteuserAction extends ProfileFormAction function handlePost() { - $this->user->delete(); + if (Event::handle('StartDeleteUser', array($this, $this->user))) { + $this->user->delete(); + Event::handle('EndDeleteUser', array($this, $this->user)); + } } } -