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
566e5aa3
Commit
566e5aa3
authored
Mar 27, 2020
by
Robert Lyon
Committed by
Gerrit Code Review
Mar 27, 2020
Browse files
Merge "Bug 1861370: group member search fatal error"
parents
15ed3e6e
b275d510
Changes
6
Hide whitespace changes
Inline
Side-by-side
htdocs/lib/group.php
View file @
566e5aa3
...
...
@@ -1910,41 +1910,43 @@ function group_get_membersearch_data($results, $group, $query, $membershiptype,
$role
=
group_user_access
(
$group
);
$userid
=
$USER
->
get
(
'id'
);
$institution
=
get_field
(
'group'
,
'institution'
,
'id'
,
$group
);
foreach
(
$results
[
'data'
]
as
&
$r
)
{
// Check if any UserRoles are in play
$checks
=
$USER
->
apply_userrole_method
(
'group_leave'
,
array
(
'groupid'
=>
$group
,
'userid'
=>
$r
[
'id'
],
'institution'
=>
$institution
));
foreach
(
$checks
as
$check
)
{
if
(
$check
[
'can_leave'
]
===
false
)
{
continue
2
;
if
(
$results
[
'data'
])
{
foreach
(
$results
[
'data'
]
as
&
$r
)
{
// Check if any UserRoles are in play
$checks
=
$USER
->
apply_userrole_method
(
'group_leave'
,
array
(
'groupid'
=>
$group
,
'userid'
=>
$r
[
'id'
],
'institution'
=>
$institution
));
foreach
(
$checks
as
$check
)
{
if
(
$check
[
'can_leave'
]
===
false
)
{
continue
2
;
}
}
}
if
(
$role
==
'admin'
&&
(
$r
[
'id
'
]
!
=
$userid
||
group_user_can_leave
(
$group
,
$r
[
'id'
])))
{
$r
[
'removeform'
]
=
group_get_removeuser_form
(
$r
[
'id'
],
$group
);
}
// NOTE: this is a quick approximation. We should really check whether,
// for each role in the group, that the user can change to it (using
//
g
ro
up_can_change_role). This only controls whether the 'chang
e
// role' link appears though, so it doesn't matter too much. If the
//
u
se
r clicks on this link, changerole.php does the full check
an
d
// sends them back here saying that the user has no roles they can
// change to anyway.
$r
[
'canchangerole'
]
=
!
group_is_only_admin
(
$group
,
$r
[
'id'
]);
}
if
(
!
empty
(
$membershiptype
)
)
{
if
(
$membershiptype
==
'request'
)
{
foreach
(
$results
[
'data'
]
as
&
$r
)
{
$r
[
'add
form'
]
=
group_get_
add
user_form
(
$r
[
'id'
],
$group
);
$r
[
'denyform'
]
=
group_get_denyuser_form
(
$r
[
'id'
],
$group
);
// TODO: this will suck when there's quite a few on the page,
// would be better to grab all the reasons in one go
$r
[
'reason'
]
=
get_field
(
'group_member_request'
,
'reason'
,
'group'
,
$group
,
'member'
,
$r
[
'id'
]);
if
(
$role
==
'admin'
&&
(
$r
[
'id'
]
!=
$userid
||
group_user_can_leave
(
$group
,
$r
[
'id'
])))
{
$r
[
'removeform
'
]
=
group_get_removeuser_form
(
$r
[
'id'
],
$group
);
}
// NOTE: this is a quick approximation. We should really check whether,
// for each role in the group, that the user can change to it (using
// group_can_change_role). This only controls whether the 'change
// ro
le' link appears though, so it doesn't matter too much. If th
e
// user clicks on this link, changerole.php does the full check and
// se
nds them back here saying that the user has no roles they c
an
// change to anyway.
$r
[
'canchangerole'
]
=
!
group_is_only_admin
(
$group
,
$r
[
'id'
]);
}
if
(
!
empty
(
$membershiptype
))
{
if
(
$membershiptype
==
'request'
)
{
foreach
(
$results
[
'data'
]
as
&
$r
)
{
$r
[
'addform'
]
=
group_get_adduser_form
(
$r
[
'id'
],
$group
);
$r
[
'deny
form'
]
=
group_get_
deny
user_form
(
$r
[
'id'
],
$group
);
// TODO: this will suck when there's quite a few on the page,
// would be better to grab all the reasons in one go
$r
[
'reason'
]
=
get_field
(
'group_member_request'
,
'reason'
,
'group'
,
$group
,
'member'
,
$r
[
'id'
]);
}
}
$smarty
->
assign
(
'membershiptype'
,
$membershiptype
);
}
$smarty
->
assign
(
'membershiptype'
,
$membershiptype
);
}
$results
[
'cdata'
]
=
array_chunk
(
$results
[
'data'
],
2
);
$results
[
'cdata'
]
=
array_chunk
(
$results
[
'data'
],
2
);
}
$results
[
'roles'
]
=
group_get_role_info
(
$group
);
$smarty
->
assign
(
'results'
,
$results
);
$smarty
->
assign
(
'searchurl'
,
$searchurl
);
...
...
htdocs/lib/mahara.php
View file @
566e5aa3
...
...
@@ -5907,3 +5907,13 @@ function notify_landing_removed($landingpage, $deleted=false) {
'url'
=>
$url
,
));
}
function
get_max_offset
(
$offset
,
$limit
,
$count
)
{
$offset
=
$limit
*
floor
(
$offset
/
$limit
);
// check offset is not going beyond last page from pagination
$maxoffset
=
$limit
*
floor
(
$count
/
$limit
);
if
(
$offset
>
$maxoffset
)
{
$offset
=
$maxoffset
;
}
return
$offset
;
}
htdocs/lib/searchlib.php
View file @
566e5aa3
...
...
@@ -464,7 +464,7 @@ function build_admin_user_search_results($search, $offset, $limit) {
'limit'
=>
$limit
,
'jumplinks'
=>
8
,
'numbersincludeprevnext'
=>
2
,
'offset'
=>
$offset
,
'offset'
=>
$results
[
'offset'
]
?
$results
[
'offset'
]
:
$offset
,
'datatable'
=>
'searchresults'
,
'searchresultsheading'
=>
'resultsheading'
,
'jsonscript'
=>
'admin/users/search.json.php'
,
...
...
@@ -993,7 +993,7 @@ function get_group_user_search_results($group, $query, $offset, $limit, $members
$group
,
$queries
,
$constraints
,
$offset
,
$limit
,
$membershiptype
,
$order
,
$friendof
,
$sortoptionidx
,
$nontutor
);
if
(
$results
[
'count'
])
{
if
(
$results
[
'count'
]
&&
$results
[
'data'
]
)
{
$userids
=
array_map
(
function
(
$a
)
{
return
$a
[
"id"
];},
$results
[
'data'
]);
$introductions
=
get_records_sql_assoc
(
"SELECT
\"
owner
\"
, description
FROM
{
artefact
}
...
...
htdocs/lib/user.php
View file @
566e5aa3
...
...
@@ -2196,6 +2196,9 @@ function get_users_data($userids, $getviews=true) {
}
function
build_userlist_html
(
&
$data
,
$searchtype
,
$admingroups
,
$filter
=
''
,
$query
=
''
)
{
if
(
isset
(
$data
[
'count'
])
&&
isset
(
$data
[
'offset'
])
&&
$data
[
'count'
]
<
$data
[
'offset'
])
{
$data
[
'offset'
]
=
$data
[
'count'
];
}
if
(
$data
[
'data'
])
{
$userlist
=
array_map
(
function
(
$u
)
{
return
(
int
)
$u
[
'id'
];
},
$data
[
'data'
]);
$userdata
=
get_users_data
(
$userlist
,
$filter
!=
'pending'
);
...
...
@@ -2221,6 +2224,7 @@ function build_userlist_html(&$data, $searchtype, $admingroups, $filter='', $que
$resultcounttextsingular
=
get_string
(
'user'
,
'group'
);
$resultcounttextplural
=
get_string
(
'users'
,
'group'
);
}
$smarty
->
assign
(
'admingroups'
,
$admingroups
);
safe_require
(
'module'
,
'multirecipientnotification'
);
$smarty
->
assign
(
'mrmoduleactive'
,
PluginModuleMultirecipientnotification
::
is_active
());
...
...
htdocs/lib/web.php
View file @
566e5aa3
...
...
@@ -4369,7 +4369,7 @@ function build_pagination($params) {
// Build the next/last links
$islast
=
$page
=
=
$last
;
$islast
=
$page
>
=
$last
;
$output
.
=
build_pagination_pagelink
(
''
,
' »'
,
...
...
htdocs/search/internal/lib.php
View file @
566e5aa3
...
...
@@ -620,6 +620,8 @@ class PluginSearchInternal extends PluginSearch {
$count
=
get_field_sql
(
'SELECT COUNT(*) FROM {usr} u '
.
$join
.
$where
,
$values
);
$offset
=
get_max_offset
(
$offset
,
$limit
,
$count
);
if
(
$count
>
0
)
{
$data
=
get_records_sql_assoc
(
'
...
...
@@ -792,6 +794,8 @@ class PluginSearchInternal extends PluginSearch {
$count
=
get_field_sql
(
'SELECT COUNT(*)'
.
$from
,
$values
);
$offset
=
get_max_offset
(
$offset
,
$limit
,
$count
);
if
(
$count
>
0
)
{
$data
=
get_records_sql_assoc
(
'
SELECT '
.
$select
.
$from
.
' ORDER BY '
.
$orderby
,
...
...
@@ -1005,6 +1009,8 @@ class PluginSearchInternal extends PluginSearch {
$count
=
get_field_sql
(
'SELECT COUNT(*) '
.
$sql
,
$values
);
$offset
=
get_max_offset
(
$offset
,
$limit
,
$count
);
if
(
$count
>
0
)
{
$sql
=
'SELECT g.* '
.
$sql
.
' ORDER BY name'
;
$data
=
get_records_sql_array
(
$sql
,
$values
,
$offset
,
$limit
);
...
...
Write
Preview
Supports
Markdown
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