From a5d1305535dd0773e62e519f6a9a5f67ed76be75 Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Wed, 24 Dec 2014 09:40:41 +0100 Subject: [PATCH] LogService : WIP --- adminstuds.php | 5 +++-- .../Framadate/Services/AdminPollService.php | 6 +++++- app/classes/Framadate/Services/LogService.php | 15 +++++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 app/classes/Framadate/Services/LogService.php diff --git a/adminstuds.php b/adminstuds.php index a26a08c..c14cb3b 100644 --- a/adminstuds.php +++ b/adminstuds.php @@ -19,6 +19,7 @@ use Framadate\Services\PollService; use Framadate\Services\AdminPollService; use Framadate\Services\InputService; +use Framadate\Services\LogService; use Framadate\Message; use Framadate\Utils; @@ -35,8 +36,9 @@ $editingVoteId = 0; /* Services */ /*----------*/ +$logService = new LogService(); $pollService = new PollService($connect); -$adminPollService = new AdminPollService($connect, $pollService); +$adminPollService = new AdminPollService($connect, $pollService, $logService); $inputService = new InputService(); /* PAGE */ @@ -267,7 +269,6 @@ if (isset($_POST['delete_poll'])) { exit; } if (isset($_POST['confirm_delete_poll'])) { - // TODO Add log if ($adminPollService->deleteEntirePoll($poll_id)) { $message = new Message('success', _('Poll fully deleted.')); } else { diff --git a/app/classes/Framadate/Services/AdminPollService.php b/app/classes/Framadate/Services/AdminPollService.php index 4559ce6..5b18816 100644 --- a/app/classes/Framadate/Services/AdminPollService.php +++ b/app/classes/Framadate/Services/AdminPollService.php @@ -12,10 +12,12 @@ class AdminPollService { private $connect; private $pollService; + private $logService; - function __construct($connect, $pollService) { + function __construct($connect, $pollService, $logService) { $this->connect = $connect; $this->pollService = $pollService; + $this->logService = $logService; } function updatePoll($poll) { @@ -71,6 +73,8 @@ class AdminPollService { * @return bool true is action succeeded */ function deleteEntirePoll($poll_id) { + $poll = $this->connect->findPollById($poll_id); + $this->logService->log("DELETE_POLL", "id$poll->poll_id, format:$poll->format, $poll->admin_name, $poll->admin_mail"); /*$this->connect->deleteVotesByPollId($poll_id); $this->connect->deleteCommentsByPollId($poll_id); $this->connect->deleteSlotsByPollId($poll_id); diff --git a/app/classes/Framadate/Services/LogService.php b/app/classes/Framadate/Services/LogService.php new file mode 100644 index 0000000..afceb48 --- /dev/null +++ b/app/classes/Framadate/Services/LogService.php @@ -0,0 +1,15 @@ +