Commit 65c3fccd authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Modify release form to release entire collections (bug #786389)

When a submitted view is part of a submitted collection (and they're
both submitted to the same group), the release button is modified to
say "Release collection", and on submitting the form, the entire
collection is released.  There is no longer any way to release a
single page out of a submitted collection.

Change-Id: Ic6bcfab3865e5fb81f90c327598be6cb6e1195bf
parent add7195c
......@@ -143,6 +143,7 @@ $string['memberrequests'] = 'Membership requests';
$string['declinerequest'] = 'Decline request';
$string['submittedviews'] = 'Submitted pages';
$string['releaseview'] = 'Release page';
$string['releasecollection'] = 'Release collection';
$string['invite'] = 'Invite';
$string['remove'] = 'Remove';
$string['updatemembership'] = 'Update membership';
......@@ -153,6 +154,7 @@ $string['viewreleasedmessage'] = 'Your page "%s" has been released from %s by %s
$string['collectionreleasedsubject'] = 'Your collection "%s" has been released from %s by %s';
$string['collectionreleasedmessage'] = 'Your collection "%s" has been released from %s by %s';
$string['viewreleasedsuccess'] = 'Page was released successfully';
$string['collectionreleasedsuccess'] = 'Collection released successfully';
$string['leavegroup'] = 'Leave this group';
$string['joingroup'] = 'Join this group';
$string['requestjoingroup'] = 'Request to join this group';
......
......@@ -79,6 +79,8 @@ $string['View'] = 'Page';
$string['Views'] = 'Pages';
$string['viewsubmittedtogroup'] = 'This page has been submitted to <a href="%s">%s</a>';
$string['viewsubmittedtogroupon'] = 'This page was submitted to <a href="%s">%s</a> on %s';
$string['collectionsubmittedtogroup'] = 'This collection has been submitted to <a href="%s">%s</a>';
$string['collectionsubmittedtogroupon'] = 'This collection was submitted to <a href="%s">%s</a> on %s';
$string['nobodycanseethisview2'] = 'Only you can see this page';
$string['noviews'] = 'No pages.';
$string['nviews'] = array(
......
......@@ -106,12 +106,27 @@ if ($viewtype == 'profile' || $viewtype == 'dashboard' || $viewtype == 'grouphom
define('TITLE', $view->get('title'));
$collection = $view->get('collection');
$submittedgroup = (int)$view->get('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);
if ($view->get('submittedtime')) {
// If the view is part of a submitted collection, the whole
// collection must be released at once.
$releasecollection = !empty($collection) && $collection->get('submittedgroup') == $submittedgroup->id;
if ($releasecollection) {
if ($ctime = $collection->get('submittedtime')) {
$text = get_string(
'collectionsubmittedtogroupon', 'view', group_homepage_url($submittedgroup), hsc($submittedgroup->name),
format_date(strtotime($ctime))
);
}
else {
$text = get_string('collectionsubmittedtogroup', 'view', group_homepage_url($submittedgroup), hsc($submittedgroup->name));
}
}
else if ($view->get('submittedtime')) {
$text = get_string('viewsubmittedtogroupon', 'view', group_homepage_url($submittedgroup), hsc($submittedgroup->name), format_date(strtotime($view->get('submittedtime'))));
}
else {
......@@ -130,7 +145,7 @@ if ($USER->is_logged_in() && $submittedgroup && group_user_can_assess_submitted_
),
'submit' => array(
'type' => 'submit',
'value' => get_string('releaseview', 'group'),
'value' => $releasecollection ? get_string('releasecollection', 'group') : get_string('releaseview', 'group'),
),
),
));
......@@ -139,11 +154,16 @@ else {
$releaseform = '';
}
function releaseview_submit() {
global $USER, $SESSION, $view, $submittedgroup;
$view->release($USER);
$SESSION->add_ok_msg(get_string('viewreleasedsuccess', 'group'));
global $USER, $SESSION, $view, $collection, $submittedgroup, $releasecollection;
if ($releasecollection) {
$collection->release($USER);
$SESSION->add_ok_msg(get_string('collectionreleasedsuccess', 'group'));
}
else {
$view->release($USER);
$SESSION->add_ok_msg(get_string('viewreleasedsuccess', 'group'));
}
if ($submittedgroup) {
// The tutor might not have access to the view any more; send
// them back to the group page.
......@@ -218,7 +238,7 @@ addLoadEvent(function () {
EOF;
// collection top navigation
if ($collection = $view->get('collection')) {
if ($collection) {
$shownav = $collection->get('navigation');
if ($shownav) {
if ($views = $collection->get('views')) {
......
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