diff --git a/adminstuds.php b/adminstuds.php index 14a1798..d5f9cab 100644 --- a/adminstuds.php +++ b/adminstuds.php @@ -367,9 +367,9 @@ if (!empty($_GET['delete_column'])) { $slot->title = $ex[0]; $slot->moment = $ex[1]; - $result = $adminPollService->deleteDateSlot($poll_id, $slot); + $result = $adminPollService->deleteDateSlot($poll, $slot); } else { - $result = $adminPollService->deleteClassicSlot($poll_id, $column); + $result = $adminPollService->deleteClassicSlot($poll, $column); } if ($result) { @@ -397,10 +397,10 @@ if (isset($_POST['confirm_add_slot'])) { $newmoment = strip_tags($_POST['newmoment']); $ex = explode('/', $newdate); - $result = $adminPollService->addSlot($poll_id, mktime(0, 0, 0, $ex[1], $ex[0], $ex[2]), $newmoment); + $result = $adminPollService->addDateSlot($poll_id, mktime(0, 0, 0, $ex[1], $ex[0], $ex[2]), $newmoment); } else { $newslot = strip_tags($_POST['choice']); - $result = $adminPollService->addSlot($poll_id, $newslot, null); + $result = $adminPollService->addClassicSlot($poll_id, $newslot); } if ($result) { @@ -411,7 +411,7 @@ if (isset($_POST['confirm_add_slot'])) { } // Retrieve data -$slots = $pollService->allSlotsByPollId($poll_id); +$slots = $pollService->allSlotsByPoll($poll); $votes = $pollService->allVotesByPollId($poll_id); $comments = $pollService->allCommentsByPollId($poll_id); diff --git a/app/classes/Framadate/Repositories/SlotRepository.php b/app/classes/Framadate/Repositories/SlotRepository.php index fcd11c2..7d69e00 100644 --- a/app/classes/Framadate/Repositories/SlotRepository.php +++ b/app/classes/Framadate/Repositories/SlotRepository.php @@ -61,7 +61,7 @@ class SlotRepository extends AbstractRepository { } function listByPollId($poll_id) { - $prepared = $this->prepare('SELECT * FROM `' . Utils::table('slot') . '` WHERE poll_id = ? ORDER BY title'); + $prepared = $this->prepare('SELECT * FROM `' . Utils::table('slot') . '` WHERE poll_id = ? ORDER BY id'); $prepared->execute(array($poll_id)); return $prepared->fetchAll(); diff --git a/app/classes/Framadate/Services/AdminPollService.php b/app/classes/Framadate/Services/AdminPollService.php index 4760f8a..fb020bc 100644 --- a/app/classes/Framadate/Services/AdminPollService.php +++ b/app/classes/Framadate/Services/AdminPollService.php @@ -105,17 +105,17 @@ class AdminPollService { /** * Delete a slot from a poll. * - * @param $poll_id int The ID of the poll - * @param $slot object The slot informations (datetime + moment) + * @param object $poll The ID of the poll + * @param object $slot The slot informations (datetime + moment) * @return bool true if action succeeded */ - public function deleteDateSlot($poll_id, $slot) { - $this->logService->log('DELETE_SLOT', 'id:' . $poll_id . ', slot:' . json_encode($slot)); + public function deleteDateSlot($poll, $slot) { + $this->logService->log('DELETE_SLOT', 'id:' . $poll->id . ', slot:' . json_encode($slot)); $datetime = $slot->title; $moment = $slot->moment; - $slots = $this->pollService->allSlotsByPollId($poll_id); + $slots = $this->pollService->allSlotsByPoll($poll); if (count($slots) === 1) { return false; @@ -143,21 +143,21 @@ class AdminPollService { // Remove votes $this->connect->beginTransaction(); - $this->voteRepository->deleteByIndex($poll_id, $indexToDelete); + $this->voteRepository->deleteByIndex($poll->id, $indexToDelete); if (count($newMoments) > 0) { - $this->slotRepository->update($poll_id, $datetime, implode(',', $newMoments)); + $this->slotRepository->update($poll->id, $datetime, implode(',', $newMoments)); } else { - $this->slotRepository->deleteByDateTime($poll_id, $datetime); + $this->slotRepository->deleteByDateTime($poll->id, $datetime); } $this->connect->commit(); return true; } - public function deleteClassicSlot($poll_id, $slot_title) { - $this->logService->log('DELETE_SLOT', 'id:' . $poll_id . ', slot:' . $slot_title); + public function deleteClassicSlot($poll, $slot_title) { + $this->logService->log('DELETE_SLOT', 'id:' . $poll->id . ', slot:' . $slot_title); - $slots = $this->pollService->allSlotsByPollId($poll_id); + $slots = $this->pollService->allSlotsByPoll($poll); if (count($slots) === 1) { return false; @@ -176,15 +176,15 @@ class AdminPollService { // Remove votes $this->connect->beginTransaction(); - $this->voteRepository->deleteByIndex($poll_id, $indexToDelete); - $this->slotRepository->deleteByDateTime($poll_id, $slot_title); + $this->voteRepository->deleteByIndex($poll->id, $indexToDelete); + $this->slotRepository->deleteByDateTime($poll->id, $slot_title); $this->connect->commit(); return true; } /** - * Add a new slot to the poll. And insert default values for user's votes. + * Add a new slot to a date poll. And insert default values for user's votes. *