Commit 9b3beda9 authored by Ruslan Kabalin's avatar Ruslan Kabalin
Browse files

Revert "groupviews: Prevent view submission to oneself (bug #632308)"

As discussed on launchpad: https://bugs.launchpad.net/mahara/+bug/632308

This reverts commits:
    26a69801
    25850d45
    bc84fa4e
    bd320942

.
Signed-off-by: default avatarRuslan Kabalin <ruslan.kabalin@luns.net.uk>
parent f168d45b
......@@ -103,16 +103,12 @@ 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. Own views will
// only be shown if $USER is the only member with view assessment
// permissions.
// Display a list of views submitted to the group
$data['allsubmittedviews'] = View::get_submitted_views($group->id);
}
}
if (group_allows_submission($group->grouptype) &&
count(group_get_members_can_see_submitted_views($group->id)) &&
$userviewdata = View::get_user_views()) {
if (group_allows_submission($group->grouptype) && ($userviewdata = View::get_user_views())) {
// A user can submit more than one view to the same group, but no view can be
// submitted to more than one group.
......
......@@ -1377,7 +1377,7 @@ function group_get_user_course_groups($userid=null) {
global $USER;
$userid = $USER->get('id');
}
if ($groups = get_records_sql_assoc(
if ($groups = get_records_sql_array(
"SELECT g.id, g.name
FROM {group_member} u
INNER JOIN {group} g ON (u.group = g.id AND g.deleted = 0)
......@@ -1386,36 +1386,6 @@ function group_get_user_course_groups($userid=null) {
AND t.submittableto = 1
ORDER BY g.name
", array($userid))) {
foreach (array_keys($groups) as $key) {
if (!count(group_get_members_can_see_submitted_views($key))) {
unset($groups[$key]);
}
}
return $groups;
}
return array();
}
/**
* Returns a list of users that are allowed to see submitted view for the given group.
* $USER is excluded from results.
*
* @param int $groupid ID of group
* @return array
*/
function group_get_members_can_see_submitted_views($groupid) {
global $USER;
$groupid = group_param_groupid($groupid);
if ($groups = get_column_sql(
"SELECT u.member
FROM {group_member} u
INNER JOIN {group} g ON (u.group = g.id AND g.deleted = 0)
INNER JOIN {grouptype} t ON t.name = g.grouptype
INNER JOIN {grouptype_roles} r ON (g.grouptype = r.grouptype AND r.role = u.role)
WHERE g.id = ?
AND t.submittableto = 1 AND r.see_submitted_views = 1 AND u.member != ?
", array($groupid, $USER->get('id')))) {
return $groups;
}
return array();
......
......@@ -2613,18 +2613,10 @@ class View {
}
/**
* 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
/**
* Get views submitted to a group
*/
public static function get_submitted_views($groupid, $userid=null) {
global $USER;
$values = array($groupid);
$where = 'submittedgroup = ?';
......@@ -2632,10 +2624,6 @@ 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
......
......@@ -90,7 +90,7 @@ else {
}
$submittedgroup = (int)$view->get('submittedgroup');
if ($USER->is_logged_in() && $submittedgroup && !count(group_get_members_can_see_submitted_views($submittedgroup))) {
if ($USER->is_logged_in() && $submittedgroup && group_user_can_assess_submitted_views($submittedgroup, $USER->get('id'))) {
// The user is a tutor of the group that this view has
// been submitted to, and is entitled to release the view
$submittedgroup = get_record('group', 'id', $submittedgroup);
......
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