Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RAP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IA2
RAP
Commits
719e7463
Commit
719e7463
authored
5 years ago
by
Sonia Zorba
Browse files
Options
Downloads
Patches
Plain Diff
Added WS list users functionalities
parent
92a77b86
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
classes/datalayer/UserDAO.php
+7
-0
7 additions, 0 deletions
classes/datalayer/UserDAO.php
classes/datalayer/mysql/MySQLUserDAO.php
+41
-0
41 additions, 0 deletions
classes/datalayer/mysql/MySQLUserDAO.php
include/rest-web-service.php
+12
-3
12 additions, 3 deletions
include/rest-web-service.php
with
60 additions
and
3 deletions
classes/datalayer/UserDAO.php
+
7
−
0
View file @
719e7463
...
@@ -61,6 +61,13 @@ interface UserDAO {
...
@@ -61,6 +61,13 @@ interface UserDAO {
*/
*/
function
searchUser
(
$searchText
);
function
searchUser
(
$searchText
);
/**
* Retrieve a list of all users having given identifiers.
* @param array $identifiers
* @return array
*/
function
getUsers
(
array
$identifiers
):
array
;
/**
/**
* Perform a join request.
* Perform a join request.
* @param type $userId1 the user that will receive all identities
* @param type $userId1 the user that will receive all identities
...
...
This diff is collapsed.
Click to expand it.
classes/datalayer/mysql/MySQLUserDAO.php
+
41
−
0
View file @
719e7463
...
@@ -174,6 +174,47 @@ class MySQLUserDAO extends BaseMySQLDAO implements UserDAO {
...
@@ -174,6 +174,47 @@ class MySQLUserDAO extends BaseMySQLDAO implements UserDAO {
$stmt
->
bindParam
(
':surname'
,
$searchParam
);
$stmt
->
bindParam
(
':surname'
,
$searchParam
);
$stmt
->
bindParam
(
':namesurname'
,
$searchParam
);
$stmt
->
bindParam
(
':namesurname'
,
$searchParam
);
return
$this
->
getUsersListFromStatement
(
$stmt
);
}
public
function
getUsers
(
array
$identifiers
):
array
{
if
(
count
(
$identifiers
)
===
0
)
{
return
[];
}
$dbh
=
$this
->
getDBHandler
();
$query
=
"SELECT `user_id`, (u.`primary_identity` = i.`id`) AS `primary`,"
.
" i.`id`, `type`, `typed_id`, `email`, `name`, `surname`, `institution`, `eppn`"
.
" FROM identity i"
.
" JOIN `user` u on u.id = i.user_id"
.
" WHERE i.user_id IN ("
;
$first
=
true
;
foreach
(
$identifiers
as
$id
)
{
if
(
!
$first
)
{
$query
.
=
','
;
}
$query
.
=
':id_'
.
$id
;
if
(
$first
)
{
$first
=
!
$first
;
}
}
$query
.
=
')'
;
$stmt
=
$dbh
->
prepare
(
$query
);
foreach
(
$identifiers
as
$id
)
{
$stmt
->
bindParam
(
':id_'
.
$id
,
$id
);
}
return
$this
->
getUsersListFromStatement
(
$stmt
);
}
private
function
getUsersListFromStatement
(
\PDOStatement
$stmt
)
:
array
{
$stmt
->
execute
();
$stmt
->
execute
();
$userMap
=
array
();
$userMap
=
array
();
...
...
This diff is collapsed.
Click to expand it.
include/rest-web-service.php
+
12
−
3
View file @
719e7463
...
@@ -65,8 +65,17 @@ Flight::route('GET ' . $WS_PREFIX . '/user', function() {
...
@@ -65,8 +65,17 @@ Flight::route('GET ' . $WS_PREFIX . '/user', function() {
$locator
->
getOAuth2RequestHandler
()
->
validateToken
();
$locator
->
getOAuth2RequestHandler
()
->
validateToken
();
$searchText
=
Flight
::
request
()
->
query
[
'search'
];
$searchText
=
Flight
::
request
()
->
query
[
'search'
];
if
(
$searchText
!==
null
)
{
$users
=
$locator
->
getUserDAO
()
->
searchUser
(
$searchText
);
$users
=
$locator
->
getUserDAO
()
->
searchUser
(
$searchText
);
}
else
{
$identifiers
=
Flight
::
request
()
->
query
[
'identifiers'
];
if
(
$identifiers
===
null
)
{
throw
new
\RAP\BadRequestException
(
"Missing identifiers parameters"
);
}
$identifiers
=
explode
(
','
,
$identifiers
);
$users
=
$locator
->
getUserDAO
()
->
getUsers
(
$identifiers
);
}
Flight
::
json
(
$users
);
Flight
::
json
(
$users
);
});
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment