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
15a84192
Commit
15a84192
authored
Sep 24, 2007
by
Richard Mansfield
Committed by
Nigel McNie
Oct 17, 2007
Browse files
Search emails if @ entered in search term
parent
dd436f49
Changes
2
Hide whitespace changes
Inline
Side-by-side
htdocs/lib/searchlib.php
View file @
15a84192
...
...
@@ -119,15 +119,27 @@ function search_user($query_string, $limit, $offset = 0) {
function
build_admin_user_search_results
(
$search
)
{
$smarty
=
smarty_core
();
$results
=
admin_user_search
(
$search
);
$params
=
array
();
foreach
(
$search
as
$k
=>
$v
)
{
if
(
!
empty
(
$v
)
&&
$k
!=
'offset'
)
{
$params
[]
=
$k
.
'='
.
$v
;
}
}
$params
=
join
(
'&'
,
$params
);
$smarty
->
assign_by_ref
(
'params'
,
$params
);
$paramstring
=
join
(
'&'
,
$params
);
// In admin search, the search string is interpreted as either a
// name search or an email search depending on its contents
if
(
!
empty
(
$search
->
query
))
{
$search
->
name
=
$search
->
query
;
if
(
strpos
(
$search
->
query
,
'@'
)
!==
false
)
{
$search
->
email
=
$search
->
query
;
}
unset
(
$search
->
query
);
}
$results
=
admin_user_search
(
$search
);
$smarty
->
assign_by_ref
(
'params'
,
$paramstring
);
$results
[
'pages'
]
=
ceil
(
$results
[
'count'
]
/
$results
[
'limit'
]);
$results
[
'page'
]
=
$results
[
'offset'
]
/
$results
[
'limit'
];
// $results['pages'];
$lastpage
=
$results
[
'pages'
]
-
1
;
...
...
htdocs/search/internal/lib.php
View file @
15a84192
...
...
@@ -251,33 +251,43 @@ class PluginSearchInternal extends PluginSearch {
public
static
function
admin_search_user_pg
(
$s
)
{
$values
=
array
();
$where
=
'WHERE u.id <> 0 AND u.deleted = 0'
;
if
(
!
empty
(
$s
->
query
))
{
$where
.
=
'
AND ( u.firstname ILIKE \'%\' || ? || \'%\'
OR u.lastname ILIKE \'%\' || ? || \'%\'
)
'
;
$values
=
array
(
$s
->
query
,
$s
->
query
);
$strings
=
array
();
$values
=
array
();
if
(
!
empty
(
$s
->
name
))
{
$strings
[]
=
' u.firstname ILIKE \'%\' || ? || \'%\' OR u.lastname ILIKE \'%\' || ? || \'%\'
'
;
$values
=
array
(
$s
->
name
,
$s
->
name
);
}
else
{
if
(
!
empty
(
$s
->
f
))
{
$
where
.
=
' AND
u.firstname ILIKE ? || \'%\''
;
$
strings
[]
=
'
u.firstname ILIKE ? || \'%\''
;
$values
[]
=
$s
->
f
;
}
if
(
!
empty
(
$s
->
l
))
{
$
where
.
=
' AND
u.lastname ILIKE ? || \'%\''
;
$
strings
[]
=
'
u.lastname ILIKE ? || \'%\''
;
$values
[]
=
$s
->
l
;
}
}
if
(
!
empty
(
$s
->
institution
))
{
$where
.
=
' AND u.institution = ? '
;
$values
[]
=
$s
->
institution
;
if
(
!
empty
(
$strings
))
{
$strings
=
'( '
.
join
(
' AND '
,
$strings
)
.
' )'
;
}
else
{
$strings
=
''
;
}
if
(
!
empty
(
$s
->
email
))
{
$
where
.
=
'
AND
u.email ILIKE \'%\' || ? || \'%\''
;
$
strings
=
$strings
.
'
OR
u.email ILIKE \'%\' || ? || \'%\''
;
$values
[]
=
$s
->
email
;
}
if
(
!
empty
(
$strings
))
{
$where
.
=
' AND ( '
.
$strings
.
' ) '
;
}
if
(
!
empty
(
$s
->
institution
))
{
$where
.
=
' AND u.institution = ? '
;
$values
[]
=
$s
->
institution
;
}
$count
=
get_field_sql
(
'SELECT COUNT(*) FROM {usr} u '
.
$where
,
$values
);
if
(
$count
>
0
)
{
...
...
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