Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
2b59fd92
Commit
2b59fd92
authored
Mar 10, 2010
by
Richard Mansfield
Browse files
Reduce number of user record queries on my friends, find friends
Signed-off-by:
Richard Mansfield
<
richardm@catalyst.net.nz
>
parent
9fa71fb4
Changes
1
Hide whitespace changes
Inline
Side-by-side
htdocs/lib/user.php
View file @
2b59fd92
...
...
@@ -1237,7 +1237,8 @@ function get_new_username($desired) {
*/
function
get_users_data
(
$userlist
,
$getviews
=
true
)
{
global
$USER
;
$sql
=
'SELECT u.id, 0 AS pending, ap.value AS hidenamepref,
$sql
=
'SELECT u.id, u.username, u.preferredname, u.firstname, u.lastname, u.admin, u.staff, u.deleted,
0 AS pending, ap.value AS hidenamepref,
COALESCE((SELECT ap.value FROM {usr_account_preference} ap WHERE ap.usr = u.id AND ap.field = \'messages\'), \'allow\') AS messages,
COALESCE((SELECT ap.value FROM {usr_account_preference} ap WHERE ap.usr = u.id AND ap.field = \'friendscontrol\'), \'auth\') AS friendscontrol,
(SELECT 1 FROM {usr_friend} WHERE ((usr1 = ? AND usr2 = u.id) OR (usr2 = ? AND usr1 = u.id))) AS friend,
...
...
@@ -1248,7 +1249,8 @@ function get_users_data($userlist, $getviews=true) {
LEFT JOIN {usr_account_preference} ap ON (u.id = ap.usr AND ap.field = \'hiderealname\')
WHERE u.id IN ('
.
$userlist
.
')
UNION
SELECT u.id, 1 AS pending, ap.value AS hidenamepref,
SELECT u.id, u.username, u.preferredname, u.firstname, u.lastname, u.admin, u.staff, u.deleted,
1 AS pending, ap.value AS hidenamepref,
COALESCE((SELECT ap.value FROM {usr_account_preference} ap WHERE ap.usr = u.id AND ap.field = \'messages\'), \'allow\') AS messages,
NULL AS friendscontrol,
NULL AS friend,
...
...
@@ -1271,7 +1273,7 @@ function get_users_data($userlist, $getviews=true) {
$record
->
messages
=
(
$record
->
messages
==
'allow'
||
$record
->
friend
&&
$record
->
messages
==
'friends'
||
$USER
->
get
(
'admin'
))
?
1
:
0
;
$record
->
institutions
=
get_institution_string_for_user
(
$record
->
id
);
$record
->
display_name
=
display_name
(
$record
->
id
,
null
,
false
,
!
$allowhidename
||
!
$record
->
hidenamepref
);
$record
->
display_name
=
display_name
(
$record
,
null
,
false
,
!
$allowhidename
||
!
$record
->
hidenamepref
);
}
if
(
!
$data
||
!
$getviews
||
!
$views
=
get_views
(
array_keys
(
$data
),
null
,
null
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment