From d57baa6cd8b93e9dbb764a31b4d6d25461a917b1 Mon Sep 17 00:00:00 2001 From: Ivan Diaz Date: Wed, 7 Dec 2016 17:24:42 -0300 Subject: [PATCH] Guillermo - staff/dellete[skip ci] --- server/controllers/staff/delete.php | 17 ++++++++++++----- server/data/ERRORS.php | 1 + 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/server/controllers/staff/delete.php b/server/controllers/staff/delete.php index 67b50f89..17fb8042 100644 --- a/server/controllers/staff/delete.php +++ b/server/controllers/staff/delete.php @@ -9,17 +9,24 @@ class DeleteStaffController extends Controller { return [ 'permission' => 'staff_3', 'requestData' => [ - + 'staffId' => [ + 'validation' => DataValidator::dataStoreId('staff'), + 'error' => ERRORS::INVALID_STAFF + ] ] ]; } public function handler() { - $staffId = Controller::request('userId'); - - - + $staffId = Controller::request('staffId'); $staff = Staff::getDataStore($staffId); + + foreach($staff->sharedTicketList as $ticket) { + $ticket->owner = null; + $ticket->unread = true; + $ticket->store(); + } + $staff->delete(); Response::respondSuccess(); } diff --git a/server/data/ERRORS.php b/server/data/ERRORS.php index f0bd8322..5f1c70b0 100644 --- a/server/data/ERRORS.php +++ b/server/data/ERRORS.php @@ -28,4 +28,5 @@ class ERRORS { const ALREADY_BANNED = 'ALREADY_BANNED'; const INVALID_LEVEL = 'INVALID_LEVEL'; const ALREADY_A_STAFF = 'ALREADY_A_STAFF'; + const INVALID_STAFF = 'INVALID_STAFF'; }