Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHRAS-3966 admin - users list - add filter for "users with api application" #4422

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/Alchemy/Phrasea/Helper/User/Manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function export()
'filter_model_only' => $this->request->get('filter_model_only') ? true : false,
'filter_mail_locked_only' => $this->request->get('filter_mail_locked_only') ? true : false,
'filter_grace_period_only' => $this->request->get('filter_grace_period_only') ? true : false,
'filter_with_api_only' => $this->request->get('filter_with_api_only') ? true : false,
'srt' => $request->get("srt", \User_Query::SORT_CREATIONDATE),
'ord' => $request->get("ord", \User_Query::ORD_DESC),
'offset_start' => $offset_start,
Expand All @@ -81,6 +82,7 @@ public function export()
->templates_only($this->query_parms['filter_model_only'])
->mail_locked_only($this->query_parms['filter_mail_locked_only'])
->grace_period_only($this->query_parms['filter_grace_period_only'])
->with_api_only($this->query_parms['filter_with_api_only'])
->get_inactives($this->query_parms['inactives'])
->include_templates(false)
->include_invite($this->query_parms['filter_guest_user'])
Expand Down Expand Up @@ -114,6 +116,7 @@ public function search()
'filter_model_only' => $this->request->get('filter_model_only') ? true : false,
'filter_mail_locked_only' => $this->request->get('filter_mail_locked_only') ? true : false,
'filter_grace_period_only' => $this->request->get('filter_grace_period_only') ? true : false,
'filter_with_api_only' => $this->request->get('filter_with_api_only') ? true : false,
'srt' => $this->request->get("srt", \User_Query::SORT_CREATIONDATE),
'ord' => $this->request->get("ord", \User_Query::ORD_DESC),
'per_page' => $results_quantity,
Expand All @@ -136,6 +139,7 @@ public function search()
->templates_only($this->query_parms['filter_model_only'])
->mail_locked_only($this->query_parms['filter_mail_locked_only'])
->grace_period_only($this->query_parms['filter_grace_period_only'])
->with_api_only($this->query_parms['filter_with_api_only'])
->include_invite($this->query_parms['filter_guest_user'])
->phantoms_only($this->query_parms['filter_phantoms_only'])
->on_bases_where_i_am($this->app->getAclForUser($this->app->getAuthenticatedUser()), [\ACL::CANADMIN])
Expand Down
20 changes: 20 additions & 0 deletions lib/classes/User/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class User_Query
protected $templates_only = false;
protected $mail_locked_only = false;
protected $grace_period_only = false;
protected $with_api_only = false;
protected $email_not_null = false;
protected $base_ids = [];
protected $sbas_ids = [];
Expand Down Expand Up @@ -279,6 +280,20 @@ public function grace_period_only($boolean)
return $this;
}

/**
* Restrict only on user with api
*
* @param $boolean
*
* @return $this
*/
public function with_api_only($boolean)
{
$this->with_api_only = !!$boolean;

return $this;
}

/**
* Restrict to user with an email
*
Expand Down Expand Up @@ -985,6 +1000,7 @@ protected function generate_sql_constraints()
$sql = '
FROM Users LEFT JOIN basusr ON (Users.id = basusr.usr_id)
LEFT JOIN sbasusr ON (Users.id = sbasusr.usr_id)
LEFT JOIN ApiApplications ON (Users.id = ApiApplications.creator_id)
WHERE 1 ';

if (! $this->include_special_users) {
Expand Down Expand Up @@ -1022,6 +1038,10 @@ protected function generate_sql_constraints()
$sql .= ' AND Users.nb_inactivity_email > 0 ';
}

if ($this->with_api_only) {
$sql .= ' AND ApiApplications.creator_id IS NOT NULL ';
}

if ($this->emailDomains) {
$sql .= $this->generate_field_constraints('email', $this->emailDomains, 'LIKE');
}
Expand Down
111 changes: 58 additions & 53 deletions resources/locales/messages.de.xlf

Large diffs are not rendered by default.

111 changes: 58 additions & 53 deletions resources/locales/messages.en.xlf

Large diffs are not rendered by default.

111 changes: 58 additions & 53 deletions resources/locales/messages.fr.xlf

Large diffs are not rendered by default.

97 changes: 51 additions & 46 deletions resources/locales/messages.nl.xlf

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/locales/validators.de.xlf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
<file date="2023-11-23T15:53:32Z" source-language="en" target-language="de" datatype="plaintext" original="not.available">
<file date="2023-11-28T07:57:33Z" source-language="en" target-language="de" datatype="plaintext" original="not.available">
<header>
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
Expand Down
2 changes: 1 addition & 1 deletion resources/locales/validators.en.xlf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
<file date="2023-11-23T15:53:48Z" source-language="en" target-language="en" datatype="plaintext" original="not.available">
<file date="2023-11-28T07:57:49Z" source-language="en" target-language="en" datatype="plaintext" original="not.available">
<header>
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
Expand Down
2 changes: 1 addition & 1 deletion resources/locales/validators.fr.xlf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
<file date="2023-11-23T15:54:08Z" source-language="en" target-language="fr" datatype="plaintext" original="not.available">
<file date="2023-11-28T07:58:09Z" source-language="en" target-language="fr" datatype="plaintext" original="not.available">
<header>
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
Expand Down
2 changes: 1 addition & 1 deletion resources/locales/validators.nl.xlf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
<file date="2023-11-23T15:54:30Z" source-language="en" target-language="nl" datatype="plaintext" original="not.available">
<file date="2023-11-28T07:58:32Z" source-language="en" target-language="nl" datatype="plaintext" original="not.available">
<header>
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
Expand Down
6 changes: 6 additions & 0 deletions templates/web/admin/users.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
{{ 'admin::userlist: user in grace period only' | trans }}
<input type="checkbox" name="filter_grace_period_only" {% if parm['filter_grace_period_only'] %} checked="checked" {% endif %} style="margin-left:10px; margin-right:10px;" />
</label>
<label class="checkbox">
{{ 'admin::userlist: user with api application' | trans }}
<input type="checkbox" name="filter_with_api_only" {% if parm['filter_with_api_only'] %} checked="checked" {% endif %} style="margin-left:10px; margin-right:10px;" />
</label>
<br/><br/>
<span style="width:130px;display:inline-block;">{{ 'Filter' | trans }}</span>
<select name="like_field" class="input-medium">
Expand Down Expand Up @@ -240,6 +244,7 @@
<input name="filter_model_only" value="{{parm.filter_model_only}}" type="hidden" />
<input name="filter_mail_locked_only" value="{{parm.filter_mail_locked_only}}" type="hidden" />
<input name="filter_grace_period_only" value="{{ parm.filter_grace_period_only }}" type="hidden" />
<input name="filter_with_api_only" value="{{ parm.filter_with_api_only }}" type="hidden" />
<input name="inactives" value="{{parm.inactives}}" type="hidden" />
</form>

Expand Down Expand Up @@ -301,6 +306,7 @@
<input name="filter_model_only" value="{{parm.filter_model_only}}" type="hidden" />
<input name="filter_mail_locked_only" value="{{parm.filter_mail_locked_only}}" type="hidden" />
<input name="filter_grace_period_only" value="{{ parm.filter_grace_period_only }}" type="hidden" />
<input name="filter_with_api_only" value="{{ parm.filter_with_api_only }}" type="hidden" />
<input name="inactives" value="{{parm.inactives}}" type="hidden" />
<input name="offset_start" value="{{parm.offset_start}}" type="hidden" />
</fieldset>
Expand Down