Commit 8f0e0737 authored by Robert Lyon's avatar Robert Lyon
Browse files

Upload groups via csv throws errors (Bug #1376503)



When the role 'course' is used - see notes in bug for testing

Also fixing the problem when updating groups via csv one could set
allowarchives = 1 even if allow submitpages = 0 which shouldn't be
allowed.

Change-Id: I9a2205835b09f73c9c881e8f707845e9032939ed
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent d02d83b3
...@@ -34,6 +34,7 @@ $ALLOWEDKEYS = array( ...@@ -34,6 +34,7 @@ $ALLOWEDKEYS = array(
'roles', 'roles',
'public', 'public',
'submitpages', 'submitpages',
'allowarchives',
'editroles', 'editroles',
'hidden', 'hidden',
'hidemembers', 'hidemembers',
......
...@@ -434,7 +434,7 @@ function group_create($data) { ...@@ -434,7 +434,7 @@ function group_create($data) {
'shortname' => $data['shortname'], 'shortname' => $data['shortname'],
'request' => isset($data['request']) ? intval($data['request']) : 0, 'request' => isset($data['request']) ? intval($data['request']) : 0,
'submittableto' => intval($data['submittableto']), 'submittableto' => intval($data['submittableto']),
'allowarchives' => !empty($data['submittableto']) ? intval($data['allowarchives']) : 0, 'allowarchives' => (!empty($data['submittableto']) && !empty($data['allowarchives'])) ? intval($data['allowarchives']) : 0,
'editroles' => $data['editroles'], 'editroles' => $data['editroles'],
'hidden' => $data['hidden'], 'hidden' => $data['hidden'],
'hidemembers' => $data['hidemembers'], 'hidemembers' => $data['hidemembers'],
...@@ -563,6 +563,12 @@ function group_update($new, $create=false) { ...@@ -563,6 +563,12 @@ function group_update($new, $create=false) {
throw new AccessDeniedException("group_update: cannot update a group in this institution"); throw new AccessDeniedException("group_update: cannot update a group in this institution");
} }
} }
if (
(isset($new->submittableto) && empty($new->submittableto)) ||
(!isset($new->submittableto) && empty($old->submittableto))
) {
$new->allowarchives = 0;
}
// Institution and shortname cannot be updated (yet) // Institution and shortname cannot be updated (yet)
unset($new->institution); unset($new->institution);
......
Supports Markdown
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