Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'MDL-60433-33' of git://github.com/jleyva/moodle into MO…
…ODLE_33_STABLE
  • Loading branch information
David Monllao committed Oct 30, 2017
2 parents 20668b9 + 2ec1b93 commit c957f2c
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 85 deletions.
32 changes: 7 additions & 25 deletions mod/data/classes/external.php
Expand Up @@ -264,7 +264,6 @@ public static function get_data_access_information($databaseid, $groupid = 0) {
'warnings' => $warnings 'warnings' => $warnings
); );


$groupmode = groups_get_activity_groupmode($cm);
if (!empty($params['groupid'])) { if (!empty($params['groupid'])) {
$groupid = $params['groupid']; $groupid = $params['groupid'];
// Determine is the group is visible to user. // Determine is the group is visible to user.
Expand All @@ -273,12 +272,9 @@ public static function get_data_access_information($databaseid, $groupid = 0) {
} }
} else { } else {
// Check to see if groups are being used here. // Check to see if groups are being used here.
$groupmode = groups_get_activity_groupmode($cm);
if ($groupmode) { if ($groupmode) {
$groupid = groups_get_activity_group($cm); $groupid = groups_get_activity_group($cm);
// Determine is the group is visible to user (this is particullary for the group 0 -> all groups).
if (!groups_group_visible($groupid, $course, $cm)) {
throw new moodle_exception('notingroup');
}
} else { } else {
$groupid = 0; $groupid = 0;
} }
Expand Down Expand Up @@ -399,11 +395,8 @@ public static function get_entries($databaseid, $groupid = 0, $returncontents =
} else { } else {
// Check to see if groups are being used here. // Check to see if groups are being used here.
if ($groupmode = groups_get_activity_groupmode($cm)) { if ($groupmode = groups_get_activity_groupmode($cm)) {
// We don't need to validate a possible groupid = 0 since it would be handled by data_search_entries.
$groupid = groups_get_activity_group($cm); $groupid = groups_get_activity_group($cm);
// Determine is the group is visible to user (this is particullary for the group 0 -> all groups).
if (!groups_group_visible($groupid, $course, $cm)) {
throw new moodle_exception('notingroup');
}
} else { } else {
$groupid = 0; $groupid = 0;
} }
Expand Down Expand Up @@ -726,11 +719,8 @@ public static function search_entries($databaseid, $groupid = 0, $returncontents
} else { } else {
// Check to see if groups are being used here. // Check to see if groups are being used here.
if ($groupmode = groups_get_activity_groupmode($cm)) { if ($groupmode = groups_get_activity_groupmode($cm)) {
// We don't need to validate a possible groupid = 0 since it would be handled by data_search_entries.
$groupid = groups_get_activity_group($cm); $groupid = groups_get_activity_group($cm);
// Determine is the group is visible to user (this is particullary for the group 0 -> all groups).
if (!groups_group_visible($groupid, $course, $cm)) {
throw new moodle_exception('notingroup');
}
} else { } else {
$groupid = 0; $groupid = 0;
} }
Expand Down Expand Up @@ -985,26 +975,18 @@ public static function add_entry($databaseid, $groupid, $data) {
// Check database is open in time. // Check database is open in time.
data_require_time_available($database, null, $context); data_require_time_available($database, null, $context);


$groupmode = groups_get_activity_groupmode($cm); // Determine default group.
if (!empty($params['groupid'])) { if (empty($params['groupid'])) {
$groupid = $params['groupid'];
// Determine is the group is visible to user.
if (!groups_group_visible($groupid, $course, $cm)) {
throw new moodle_exception('notingroup');
}
} else {
// Check to see if groups are being used here. // Check to see if groups are being used here.
$groupmode = groups_get_activity_groupmode($cm);
if ($groupmode) { if ($groupmode) {
$groupid = groups_get_activity_group($cm); $groupid = groups_get_activity_group($cm);
// Determine is the group is visible to user (this is particullary for the group 0 -> all groups).
if (!groups_group_visible($groupid, $course, $cm)) {
throw new moodle_exception('notingroup');
}
} else { } else {
$groupid = 0; $groupid = 0;
} }
} }


// Group is validated inside the function.
if (!data_user_can_add_entry($database, $groupid, $groupmode, $context)) { if (!data_user_can_add_entry($database, $groupid, $groupmode, $context)) {
throw new moodle_exception('noaccess', 'data'); throw new moodle_exception('noaccess', 'data');
} }
Expand Down

0 comments on commit c957f2c

Please sign in to comment.