Commit bc84fa4e authored by Ruslan Kabalin's avatar Ruslan Kabalin
Browse files

Do not list own views submitted to the group (bug #632308).



Own views will be shown only if user is the only member of the groups with
view assesment permissions (this can happen if another member with assessment
permissions has been demoted to ordinary members after the view had been
submitted).
Signed-off-by: default avatarRuslan Kabalin <ruslan.kabalin@luns.net.uk>
parent bd320942
......@@ -103,7 +103,9 @@ class PluginBlocktypeGroupViews extends SystemBlocktype {
// shared to the group
$data['sharedviews'] = View::get_sharedviews_data(null, 0, $group->id);
if (group_user_can_assess_submitted_views($group->id, $USER->get('id'))) {
// Display a list of views submitted to the group
// Display a list of views submitted to the group. Own views will
// only be shown if $USER is the only member with view assessment
// permissions.
$data['allsubmittedviews'] = View::get_submitted_views($group->id);
}
}
......
......@@ -2613,10 +2613,18 @@ class View {
}
/**
* Get views submitted to a group
/**
* Get views submitted to a group. Views that belong to $USER are excluded
* unless data for specific user is requested or $USER is the only member
* with view assesment permissions.
*
* @param int $userid ID of user
* @param int $groupid ID of group
* @return array
*/
public static function get_submitted_views($groupid, $userid=null) {
global $USER;
$values = array($groupid);
$where = 'submittedgroup = ?';
......@@ -2624,6 +2632,10 @@ class View {
$values[] = (int) $userid;
$where .= ' AND owner = ?';
}
else if (count(group_get_members_can_see_submitted_views($groupid))) {
$values[] = (int) $USER->get('id');
$where .= ' AND owner <> ?';
}
$viewdata = get_records_sql_assoc('
SELECT
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment