Merge branch 'feature/admin_search_by_mail' into 'develop'

Admin : Recherche de sondages par adresse mail de l'auteur

- Ajout d'un champ pour chercher par adresse mail (type=text par laisser la possibilité de chercher une partie de l'adresse).
- Ajout des critères de recherche dans la requête SQL

See merge request !78
This commit is contained in:
Antonin 2015-10-28 14:25:45 +01:00
commit 6255a55128
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['poll'] = filter_input(INPUT_GET, 'poll', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => POLL_REGEX]]);
$search['title'] = filter_input(INPUT_GET, 'title', FILTER_SANITIZE_STRING); $search['title'] = filter_input(INPUT_GET, 'title', FILTER_SANITIZE_STRING);
$search['name'] = filter_input(INPUT_GET, 'name', FILTER_SANITIZE_STRING); $search['name'] = filter_input(INPUT_GET, 'name', FILTER_SANITIZE_STRING);
$search['mail'] = filter_input(INPUT_GET, 'mail', FILTER_SANITIZE_STRING);
/* PAGE */ /* PAGE */
/* ---- */ /* ---- */

View File

@ -64,7 +64,7 @@ class PollRepository extends AbstractRepository {
/** /**
* Search polls in databse. * 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 $start The number of first entry to select
* @param int $limit The number of entries to find * @param int $limit The number of entries to find
* @return array The found polls * @return array The found polls
@ -78,6 +78,7 @@ SELECT p.*,
WHERE (:id = "" OR p.id LIKE :id) WHERE (:id = "" OR p.id LIKE :id)
AND (:title = "" OR p.title LIKE :title) AND (:title = "" OR p.title LIKE :title)
AND (:name = "" OR p.admin_name LIKE :name) AND (:name = "" OR p.admin_name LIKE :name)
AND (:mail = "" OR p.admin_mail LIKE :mail)
ORDER BY p.title ASC ORDER BY p.title ASC
LIMIT :start, :limit LIMIT :start, :limit
'); ');
@ -85,9 +86,11 @@ SELECT p.*,
$poll = $search['poll'] . '%'; $poll = $search['poll'] . '%';
$title = '%' . $search['title'] . '%'; $title = '%' . $search['title'] . '%';
$name = '%' . $search['name'] . '%'; $name = '%' . $search['name'] . '%';
$mail = '%' . $search['mail'] . '%';
$prepared->bindParam(':id', $poll, PDO::PARAM_STR); $prepared->bindParam(':id', $poll, PDO::PARAM_STR);
$prepared->bindParam(':title', $title, PDO::PARAM_STR); $prepared->bindParam(':title', $title, PDO::PARAM_STR);
$prepared->bindParam(':name', $name, 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(':start', $start, PDO::PARAM_INT);
$prepared->bindParam(':limit', $limit, PDO::PARAM_INT); $prepared->bindParam(':limit', $limit, PDO::PARAM_INT);
$prepared->execute(); $prepared->execute();

View File

@ -19,7 +19,7 @@ class SuperAdminService {
/** /**
* Return the list of all polls. * 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 $page The page index (O = first page)
* @param int $limit The limit size * @param int $limit The limit size
* @return array ['polls' => The {$limit} polls, 'count' => Entries found by the query, 'total' => Total count] * @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" <input type="text" name="poll" id="poll" class="form-control"
value="{$search['poll']|html}"/> value="{$search['poll']|html}"/>
</div> </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"> <div class="form-group">
<label for="name" class="control-label">{__('Admin', 'Author')}</label> <label for="name" class="control-label">{__('Admin', 'Author')}</label>
<input type="text" name="name" id="name" class="form-control" <input type="text" name="name" id="name" class="form-control"
@ -24,9 +33,9 @@
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<div class="form-group"> <div class="form-group">
<label for="title" class="control-label">{__('Admin', 'Title')}</label> <label for="mail" class="control-label">{__('Admin', 'Email')}</label>
<input type="text" name="title" id="title" class="form-control" <input type="text" name="mail" id="mail" class="form-control"
value="{$search['title']|html}"/> value="{$search['mail']|html}"/>
</div> </div>
</div> </div>
</div> </div>