Commit ea8b4809 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Create hidden tutor access records for views submitted to groups, so that the...


Create hidden tutor access records for views submitted to groups, so that the normal view access system can be used
Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 8cc9d739
......@@ -761,14 +761,21 @@ class View {
throw new ParameterException("View with id " . $this->get('id') . " has not been submitted");
}
$releaseuser = optional_userobj($releaseuser);
db_begin();
if ($submitinfo['type'] == 'group') {
$group = $this->get('submittedgroup');
$this->set('submittedgroup', null);
if ($group) {
// Remove hidden tutor view access records
delete_records('view_access', 'view', $this->id, 'group', $group, 'visible', 0);
}
}
else if ($submitinfo['type'] == 'host') {
$this->set('submittedhost', null);
}
$this->set('submittedtime', null);
$this->commit();
db_commit();
$ownerlang = get_user_language($this->get('owner'));
$url = get_config('wwwroot') . 'view/view.php?id=' . $this->get('id');
require_once('activity.php');
......
......@@ -77,13 +77,25 @@ function submitview_submit(Pieform $form, $values) {
global $SESSION, $USER, $viewid, $groupid, $group;
db_begin();
update_record('view', array('submittedgroup' => $groupid, 'submittedtime' => db_format_timestamp(time())), array('id' => $viewid));
$roles = get_column('grouptype_roles', 'role', 'grouptype', $group->grouptype, 'see_submitted_views', 1);
foreach ($roles as $role) {
$accessrecord = (object) array(
'view' => $viewid,
'group' => $groupid,
'role' => $role,
'visible' => 0,
'allowcomments' => 1,
'approvecomments' => 0,
);
ensure_record_exists('view_access', $accessrecord, $accessrecord);
}
activity_occurred('groupmessage', array(
'subject' => get_string('viewsubmitted', 'view'), // will be overwritten
'message' => get_string('viewsubmitted', 'view'), // will be overwritten
'submittedview' => $viewid,
'viewowner' => $USER->get('id'),
'group' => $groupid,
'roles' => get_column('grouptype_roles', 'role', 'grouptype', $group->grouptype, 'see_submitted_views', 1),
'roles' => $roles,
'strings' => (object) array(
'urltext' => (object) array('key' => 'view'),
),
......
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