From 2cfeb385bb854d5ee7e7f5c34eb4bc72d79c2647 Mon Sep 17 00:00:00 2001 From: Olivier Perez Date: Wed, 28 Oct 2015 13:06:02 +0100 Subject: [PATCH] Admin: Search in polls by author's mail address --- admin/polls.php | 1 + .../Framadate/Repositories/PollRepository.php | 5 ++++- .../Framadate/Services/SuperAdminService.php | 2 +- tpl/admin/polls.tpl | 15 ++++++++++++--- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/admin/polls.php b/admin/polls.php index 198b7cf..8bb5779 100644 --- a/admin/polls.php +++ b/admin/polls.php @@ -64,6 +64,7 @@ $page = ($page >= 1) ? $page : 1; $search['poll'] = filter_input(INPUT_GET, 'poll', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => POLL_REGEX]]); $search['title'] = filter_input(INPUT_GET, 'title', FILTER_SANITIZE_STRING); $search['name'] = filter_input(INPUT_GET, 'name', FILTER_SANITIZE_STRING); +$search['mail'] = filter_input(INPUT_GET, 'mail', FILTER_SANITIZE_STRING); /* PAGE */ /* ---- */ diff --git a/app/classes/Framadate/Repositories/PollRepository.php b/app/classes/Framadate/Repositories/PollRepository.php index 95debe4..415ccfa 100644 --- a/app/classes/Framadate/Repositories/PollRepository.php +++ b/app/classes/Framadate/Repositories/PollRepository.php @@ -64,7 +64,7 @@ class PollRepository extends AbstractRepository { /** * Search polls in databse. * - * @param array $search Array of search : ['id'=>..., 'title'=>..., 'name'=>...] + * @param array $search Array of search : ['id'=>..., 'title'=>..., 'name'=>..., 'mail'=>...] * @param int $start The number of first entry to select * @param int $limit The number of entries to find * @return array The found polls @@ -78,6 +78,7 @@ SELECT p.*, WHERE (:id = "" OR p.id LIKE :id) AND (:title = "" OR p.title LIKE :title) AND (:name = "" OR p.admin_name LIKE :name) + AND (:mail = "" OR p.admin_mail LIKE :mail) ORDER BY p.title ASC LIMIT :start, :limit '); @@ -85,9 +86,11 @@ SELECT p.*, $poll = $search['poll'] . '%'; $title = '%' . $search['title'] . '%'; $name = '%' . $search['name'] . '%'; + $mail = '%' . $search['mail'] . '%'; $prepared->bindParam(':id', $poll, PDO::PARAM_STR); $prepared->bindParam(':title', $title, PDO::PARAM_STR); $prepared->bindParam(':name', $name, PDO::PARAM_STR); + $prepared->bindParam(':mail', $mail, PDO::PARAM_STR); $prepared->bindParam(':start', $start, PDO::PARAM_INT); $prepared->bindParam(':limit', $limit, PDO::PARAM_INT); $prepared->execute(); diff --git a/app/classes/Framadate/Services/SuperAdminService.php b/app/classes/Framadate/Services/SuperAdminService.php index 3945f07..51863a9 100644 --- a/app/classes/Framadate/Services/SuperAdminService.php +++ b/app/classes/Framadate/Services/SuperAdminService.php @@ -19,7 +19,7 @@ class SuperAdminService { /** * Return the list of all polls. * - * @param array $search Array of search : ['id'=>..., 'title'=>..., 'name'=>...] + * @param array $search Array of search : ['id'=>..., 'title'=>..., 'name'=>..., 'mail'=>...] * @param int $page The page index (O = first page) * @param int $limit The limit size * @return array ['polls' => The {$limit} polls, 'count' => Entries found by the query, 'total' => Total count] diff --git a/tpl/admin/polls.tpl b/tpl/admin/polls.tpl index 2963ed2..d7a00df 100644 --- a/tpl/admin/polls.tpl +++ b/tpl/admin/polls.tpl @@ -16,6 +16,15 @@ + +
+
+ + +
+
+
- - + +