Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
fed63dff
Commit
fed63dff
authored
11 years ago
by
Robin Appelman
Browse files
Options
Downloads
Plain Diff
Merge pull request #6315 from owncloud/ingroup-cache
cache the result from inGroup
parents
77b68505
8a86837e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/private/group/group.php
+18
-7
18 additions, 7 deletions
lib/private/group/group.php
with
18 additions
and
7 deletions
lib/private/group/group.php
+
18
−
7
View file @
fed63dff
...
...
@@ -18,7 +18,12 @@ class Group {
/**
* @var \OC\User\User[] $users
*/
private
$users
;
private
$users
=
array
();
/**
* @var bool $usersLoaded
*/
private
$usersLoaded
;
/**
* @var \OC_Group_Backend[] | \OC_Group_Database[] $backend
...
...
@@ -26,7 +31,7 @@ class Group {
private
$backends
;
/**
* @var \OC\Hooks\PublicEmitter $emitter
;
* @var \OC\Hooks\PublicEmitter $emitter
*/
private
$emitter
;
...
...
@@ -58,7 +63,7 @@ class Group {
* @return \OC\User\User[]
*/
public
function
getUsers
()
{
if
(
$this
->
users
)
{
if
(
$this
->
users
Loaded
)
{
return
$this
->
users
;
}
...
...
@@ -74,6 +79,7 @@ class Group {
}
$this
->
users
=
$this
->
getVerifiedUsers
(
$userIds
);
$this
->
usersLoaded
=
true
;
return
$this
->
users
;
}
...
...
@@ -84,8 +90,12 @@ class Group {
* @return bool
*/
public
function
inGroup
(
$user
)
{
if
(
isset
(
$this
->
users
[
$user
->
getUID
()]))
{
return
true
;
}
foreach
(
$this
->
backends
as
$backend
)
{
if
(
$backend
->
inGroup
(
$user
->
getUID
(),
$this
->
gid
))
{
$this
->
users
[
$user
->
getUID
()]
=
$user
;
return
true
;
}
}
...
...
@@ -185,6 +195,7 @@ class Group {
* @return \OC\User\User[]
*/
public
function
searchDisplayName
(
$search
,
$limit
=
null
,
$offset
=
null
)
{
$users
=
array
();
foreach
(
$this
->
backends
as
$backend
)
{
if
(
$backend
->
implementsActions
(
OC_GROUP_BACKEND_GET_DISPLAYNAME
))
{
$userIds
=
array_keys
(
$backend
->
displayNamesInGroup
(
$this
->
gid
,
$search
,
$limit
,
$offset
));
...
...
@@ -229,17 +240,17 @@ class Group {
/**
* @brief returns all the Users from an array that really exists
* @param $userIds an array containing user IDs
* @return an Array with the userId as Key and \OC\User\User as value
* @param
string[]
$userIds an array containing user IDs
* @return
\OC\User\User[]
an Array with the userId as Key and \OC\User\User as value
*/
private
function
getVerifiedUsers
(
$userIds
)
{
if
(
!
is_array
(
$userIds
))
{
if
(
!
is_array
(
$userIds
))
{
return
array
();
}
$users
=
array
();
foreach
(
$userIds
as
$userId
)
{
$user
=
$this
->
userManager
->
get
(
$userId
);
if
(
!
is_null
(
$user
))
{
if
(
!
is_null
(
$user
))
{
$users
[
$userId
]
=
$user
;
}
}
...
...
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