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
a8fb8033
Commit
a8fb8033
authored
11 years ago
by
Robin Appelman
Browse files
Options
Downloads
Patches
Plain Diff
cache instances of \OC\User\User
parent
542bcf91
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/user/manager.php
+11
-5
11 additions, 5 deletions
lib/user/manager.php
with
11 additions
and
5 deletions
lib/user/manager.php
+
11
−
5
View file @
a8fb8033
...
...
@@ -30,6 +30,8 @@ class Manager extends PublicEmitter {
*/
private
$backends
=
array
();
private
$cachedUsers
=
array
();
/**
* @param \OC_User_Backend $backend
*/
...
...
@@ -55,9 +57,13 @@ class Manager extends PublicEmitter {
* @return \OC\User\User
*/
public
function
get
(
$uid
)
{
if
(
isset
(
$this
->
cachedUsers
[
$uid
]))
{
return
$this
->
cachedUsers
[
$uid
];
}
foreach
(
$this
->
backends
as
$backend
)
{
if
(
$backend
->
userExists
(
$uid
))
{
return
new
User
(
$uid
,
$backend
,
$this
);
$this
->
cachedUsers
[
$uid
]
=
new
User
(
$uid
,
$backend
,
$this
);
return
$this
->
cachedUsers
[
$uid
];
}
}
return
null
;
...
...
@@ -90,7 +96,7 @@ class Manager extends PublicEmitter {
$backendUsers
=
$backend
->
getUsers
(
$pattern
,
$limit
,
$offset
);
if
(
is_array
(
$backendUsers
))
{
foreach
(
$backendUsers
as
$uid
)
{
$users
[]
=
new
User
(
$uid
,
$backend
,
$this
);
$users
[]
=
$this
->
get
(
$uid
);
if
(
!
is_null
(
$limit
))
{
$limit
--
;
}
...
...
@@ -126,7 +132,7 @@ class Manager extends PublicEmitter {
$backendUsers
=
$backend
->
getDisplayNames
(
$pattern
,
$limit
,
$offset
);
if
(
is_array
(
$backendUsers
))
{
foreach
(
$backendUsers
as
$uid
=>
$displayName
)
{
$users
[]
=
new
User
(
$uid
,
$backend
,
$this
);
$users
[]
=
$this
->
get
(
$uid
);
if
(
!
is_null
(
$limit
))
{
$limit
--
;
}
...
...
@@ -159,7 +165,7 @@ class Manager extends PublicEmitter {
// Allowed are: "a-z", "A-Z", "0-9" and "_.@-"
if
(
preg_match
(
'/[^a-zA-Z0-9 _\.@\-]/'
,
$uid
))
{
throw
new
\Exception
(
'Only the following characters are allowed in a username:'
.
' "a-z", "A-Z", "0-9", and "_.@-"'
);
.
' "a-z", "A-Z", "0-9", and "_.@-"'
);
}
// No empty username
if
(
trim
(
$uid
)
==
''
)
{
...
...
@@ -179,7 +185,7 @@ class Manager extends PublicEmitter {
foreach
(
$this
->
backends
as
$backend
)
{
if
(
$backend
->
implementsActions
(
\OC_USER_BACKEND_CREATE_USER
))
{
$backend
->
createUser
(
$uid
,
$password
);
$user
=
new
User
(
$uid
,
$backend
,
$this
);
$user
=
$this
->
get
(
$uid
);
$this
->
emit
(
'\OC\User'
,
'postCreateUser'
,
array
(
$user
,
$password
));
return
$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