Commit fd3b307d authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic
Browse files

Bug 1642389: Release collection when deleting group

When a collection is submitted to a group and then
the group is deleted, then the collections are
released.

behatnotneeded

Change-Id: I7e242e5992d8abdafd5aa7b989fba65aa3928b37
parent 1fac3c09
......@@ -1079,7 +1079,8 @@ class Collection {
// We don't send out notifications about the release of remote-submitted Views & Collections
// (though I'm not sure why)
if ($this->submittedgroup) {
// if the method is called in an upgrade and we dont have a release user
if (!defined('INSTALLER') && $this->submittedgroup) {
$releaseuser = optional_userobj($releaseuser);
$releaseuserdisplay = display_name($releaseuser, $this->owner);
$submitinfo = $this->submitted_to();
......
......@@ -4816,7 +4816,21 @@ function xmldb_core_upgrade($oldversion=0) {
$index = new XMLDBIndex('shortnameuk');
$index->setAttributes(XMLDB_KEY_UNIQUE, array('shortname'));
add_index($table, $index);
}
if ($oldversion < 2016112400) {
log_debug('Realease all collections that are still submitted but to a deleted group');
require_once(get_config('libroot') . 'collection.php');
if ($collections = get_records_sql_array("
SELECT c.id
FROM {collection} c JOIN {group} g ON c.submittedgroup=g.id
WHERE c.submittedstatus = ".Collection::SUBMITTED." AND g.deleted = 1 "
)) {
foreach ($collections as $collectionid) {
$collection = new Collection($collectionid->id);
$collection->release();
}
}
}
return $status;
......
......@@ -790,6 +790,13 @@ function group_delete($groupid, $shortname=null, $institution=null, $notifymembe
$view->delete();
}
// Release collections submitted to the group
require_once(get_config('libroot') . 'collection.php');
foreach (get_column('collection', 'id', 'submittedgroup', $group->id) as $collectionid) {
$collection = new Collection($collectionid);
$collection->release();
}
// Release views submitted to the group
foreach (get_column('view', 'id', 'submittedgroup', $group->id) as $viewid) {
$view = new View($viewid);
......
......@@ -16,7 +16,7 @@ $config = new stdClass();
// See https://wiki.mahara.org/wiki/Developer_Area/Version_Numbering_Policy
// For upgrades on stable branches, increment the version by one. On master, use the date.
$config->version = 2016112301;
$config->version = 2016112400;
$config->series = '17.04';
$config->release = '17.04dev';
$config->minupgradefrom = 2012080604;
......
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