Skip to content

Commit

Permalink
Fix stupid break in adminstuds
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierperez committed Oct 28, 2015
1 parent 6d8353b commit 15640a6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion adminstuds.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function sendUpdateNotification($poll, $mailService, $type) {
$admin_poll_id = filter_input(INPUT_GET, 'poll', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => POLL_REGEX]]);
if (strlen($admin_poll_id) === 24) {
$poll_id = substr($admin_poll_id, 0, 16);
$poll = $pollService->findById($poll_id);
$poll = $pollService->findByAdminId($admin_poll_id);
}
}

Expand Down
10 changes: 10 additions & 0 deletions app/classes/Framadate/Repositories/PollRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ function findById($poll_id) {
return $poll;
}

public function findByAdminId($admin_poll_id) {
$prepared = $this->prepare('SELECT * FROM `' . Utils::table('poll') . '` WHERE admin_id = ?');

$prepared->execute(array($admin_poll_id));
$poll = $prepared->fetch();
$prepared->closeCursor();

return $poll;
}

public function existsById($poll_id) {
$prepared = $this->prepare('SELECT 1 FROM `' . Utils::table('poll') . '` WHERE id = ?');

Expand Down
8 changes: 8 additions & 0 deletions app/classes/Framadate/Services/PollService.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ function findById($poll_id) {
return null;
}

public function findByAdminId($admin_poll_id) {
if (preg_match('/^[\w\d]{24}$/i', $admin_poll_id)) {
return $this->pollRepository->findByAdminId($admin_poll_id);
}

return null;
}

function allCommentsByPollId($poll_id) {
return $this->commentRepository->findAllByPollId($poll_id);
}
Expand Down

0 comments on commit 15640a6

Please sign in to comment.