Admin: Search in polls by author's mail address

This commit is contained in:
Olivier Perez 2015-10-28 13:06:02 +01:00
parent 16c3c70f5a
commit 2cfeb385bb
4 changed files with 18 additions and 5 deletions

View File

@ -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 */
/* ---- */

View File

@ -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();

View File

@ -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]

View File

@ -16,6 +16,15 @@
<input type="text" name="poll" id="poll" class="form-control"
value="{$search['poll']|html}"/>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="title" class="control-label">{__('Admin', 'Title')}</label>
<input type="text" name="title" id="title" class="form-control"
value="{$search['title']|html}"/>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="name" class="control-label">{__('Admin', 'Author')}</label>
<input type="text" name="name" id="name" class="form-control"
@ -24,9 +33,9 @@
</div>
<div class="col-md-6">
<div class="form-group">
<label for="title" class="control-label">{__('Admin', 'Title')}</label>
<input type="text" name="title" id="title" class="form-control"
value="{$search['title']|html}"/>
<label for="mail" class="control-label">{__('Admin', 'Email')}</label>
<input type="text" name="mail" id="mail" class="form-control"
value="{$search['mail']|html}"/>
</div>
</div>
</div>