Merge branch 'master' into develop
This commit is contained in:
commit
1ba245258a
@ -53,12 +53,13 @@ $notificationService = new NotificationService($mailService);
|
|||||||
if (!empty($_GET['poll'])) {
|
if (!empty($_GET['poll'])) {
|
||||||
$admin_poll_id = filter_input(INPUT_GET, 'poll', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => POLL_REGEX]]);
|
$admin_poll_id = filter_input(INPUT_GET, 'poll', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => POLL_REGEX]]);
|
||||||
if (strlen($admin_poll_id) === 24) {
|
if (strlen($admin_poll_id) === 24) {
|
||||||
$poll_id = substr($admin_poll_id, 0, 16);
|
$poll = $pollService->findByAdminId($admin_poll_id);
|
||||||
$poll = $pollService->findById($poll_id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$poll) {
|
if ($poll) {
|
||||||
|
$poll_id = $poll->id;
|
||||||
|
} else {
|
||||||
$smarty->assign('error', __('Error', 'This poll doesn\'t exist !'));
|
$smarty->assign('error', __('Error', 'This poll doesn\'t exist !'));
|
||||||
$smarty->display('error.tpl');
|
$smarty->display('error.tpl');
|
||||||
exit;
|
exit;
|
||||||
|
@ -29,6 +29,16 @@ class PollRepository extends AbstractRepository {
|
|||||||
return $poll;
|
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) {
|
public function existsById($poll_id) {
|
||||||
$prepared = $this->prepare('SELECT 1 FROM `' . Utils::table('poll') . '` WHERE id = ?');
|
$prepared = $this->prepare('SELECT 1 FROM `' . Utils::table('poll') . '` WHERE id = ?');
|
||||||
|
|
||||||
|
@ -56,6 +56,14 @@ class PollService {
|
|||||||
return null;
|
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) {
|
function allCommentsByPollId($poll_id) {
|
||||||
return $this->commentRepository->findAllByPollId($poll_id);
|
return $this->commentRepository->findAllByPollId($poll_id);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user