Skip to content
GitLab
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
27df8377
Commit
27df8377
authored
Nov 28, 2007
by
Richard Mansfield
Browse files
Filter admin user search by institution for institutional admins
parent
b1ab504a
Changes
4
Hide whitespace changes
Inline
Side-by-side
htdocs/auth/user.php
View file @
27df8377
...
...
@@ -368,7 +368,7 @@ class User {
}
public
function
set_admin_institutions
(
$institutions
)
{
$this
->
set
(
'admininstitutions'
,
array_
fill_keys
(
$institutions
,
true
));
$this
->
set
(
'admininstitutions'
,
array_
combine
(
$institutions
,
$institutions
));
}
}
...
...
@@ -470,7 +470,7 @@ class LiveUser extends User {
$admininstitutions
=
array
();
foreach
(
$institutions
as
$i
)
{
if
(
$i
->
admin
)
{
$admininstitutions
[
$i
->
institution
]
=
true
;
$admininstitutions
[
$i
->
institution
]
=
$i
->
institution
;
}
}
$this
->
institutions
=
$institutions
;
...
...
htdocs/lib/searchlib.php
View file @
27df8377
...
...
@@ -146,7 +146,23 @@ function build_admin_user_search_results($search, $offset, $limit, $sortby, $sor
'type'
=>
'starts'
,
'string'
=>
$search
->
l
);
}
if
(
!
empty
(
$search
->
institution
)
&&
$search
->
institution
!=
'all'
)
{
// Filter by viewable institutions:
if
(
empty
(
$search
->
institution
))
{
$search
->
institution
=
'all'
;
}
global
$USER
;
if
(
!
$USER
->
get
(
'admin'
))
{
$allowed
=
$USER
->
get
(
'admininstitutions'
);
if
(
$search
->
institution
==
'all'
||
!
isset
(
$allowed
[
$search
->
institution
]))
{
$constraints
[]
=
array
(
'field'
=>
'institution'
,
'type'
=>
'in'
,
'list'
=>
$allowed
);
}
else
{
$constraints
[]
=
array
(
'field'
=>
'institution'
,
'type'
=>
'equals'
,
'string'
=>
$search
->
institution
);
}
}
else
if
(
$search
->
institution
!=
'all'
)
{
$constraints
[]
=
array
(
'field'
=>
'institution'
,
'type'
=>
'equals'
,
'string'
=>
$search
->
institution
);
...
...
htdocs/search/internal/lib.php
View file @
27df8377
...
...
@@ -277,7 +277,9 @@ class PluginSearchInternal extends PluginSearch {
foreach
(
$constraints
as
$f
)
{
if
(
$f
[
'field'
]
==
'institution'
)
{
$institutionsearch
.
=
' LEFT OUTER JOIN {usr_institution} i ON i.usr = u.id '
;
if
(
$f
[
'string'
]
==
'mahara'
)
{
if
(
$f
[
'type'
]
==
'in'
)
{
$where
.
=
" AND i.institution IN ('"
.
join
(
"','"
,
$f
[
'list'
])
.
"')"
;
}
else
if
(
$f
[
'string'
]
==
'mahara'
)
{
$where
.
=
' AND i.institution IS NULL'
;
}
else
{
$where
.
=
' AND i.institution'
.
$matchtypes
[
$f
[
'type'
]];
...
...
htdocs/search/solr/lib.php
View file @
27df8377
...
...
@@ -228,8 +228,15 @@ END;
}
$terms
=
array
();
foreach
(
$constraints
as
$f
)
{
$terms
[]
=
$solrfields
[
$f
[
'field'
]]
.
':'
.
strtolower
(
$f
[
'string'
])
.
(
$f
[
'type'
]
!=
'equals'
?
'*'
:
''
);
if
(
$f
[
'type'
]
==
'in'
&&
!
empty
(
$f
[
'list'
]))
{
foreach
(
$f
[
'list'
]
as
&
$string
)
{
$string
=
$solrfields
[
$f
[
'field'
]]
.
':'
.
strtolower
(
$string
);
}
$terms
[]
=
'('
.
join
(
' OR '
,
$f
[
'list'
])
.
')'
;
}
else
{
$terms
[]
=
$solrfields
[
$f
[
'field'
]]
.
':'
.
strtolower
(
$f
[
'string'
])
.
(
$f
[
'type'
]
!=
'equals'
?
'*'
:
''
);
}
}
$q
.
=
join
(
' AND '
,
$terms
);
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment