Commit 5c33bf75 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review

Merge "Bug 1829943: Release submitted portfolios when deleting an institution"

parents cf77fc8f 7ba35ae8
......@@ -92,24 +92,37 @@ if ($institution || $add) {
}
function delete_submit(Pieform $form, $values) {
global $SESSION;
global $SESSION, $USER;
$authinstanceids = get_column('auth_instance', 'id', 'institution', $values['i']);
$collectionids = get_column('collection', 'id', 'institution', $values['i']);
$viewids = get_column('view', 'id', 'institution', $values['i']);
$artefactids = get_column('artefact', 'id', 'institution', $values['i']);
$regdataids = get_column('institution_registration', 'id', 'institution', $values['i']);
$host = get_field('host', 'wwwroot', 'institution', $values['i']);
db_begin();
require_once(get_config('libroot') . 'collection.php');
if ($submittedcolids = get_column('collection', 'id', 'submittedhost', $host)) {
foreach ($submittedcolids as $id) {
$collection = new Collection($id);
$collection->release($USER);
}
}
if ($collectionids) {
require_once(get_config('libroot') . 'collection.php');
foreach ($collectionids as $collectionid) {
$collection = new Collection($collectionid);
$collection->delete();
}
}
require_once(get_config('libroot') . 'view.php');
if ($submittedviewids = get_column('view', 'id', 'submittedhost', $host)) {
foreach ($submittedviewids as $id) {
$view = new View($id);
$view->release($USER);
}
}
if ($viewids) {
require_once(get_config('libroot') . 'view.php');
foreach ($viewids as $viewid) {
$view = new View($viewid);
$view->delete();
......@@ -172,6 +185,7 @@ if ($institution || $add) {
execute_sql("UPDATE {group} SET institution = 'mahara' WHERE institution = ?", array($values['i']));
delete_records('auth_instance', 'institution', $values['i']);
delete_records('host', 'institution', $values['i']);
delete_records('institution_locked_profile_field', 'name', $values['i']);
delete_records('usr_institution_request', 'institution', $values['i']);
......
......@@ -1192,7 +1192,8 @@ class Collection {
handle_event('releasesubmission', array('releaseuser' => $releaseuser,
'id' => $this->get('id'),
'groupname' => get_field('group', 'name', 'id', $this->submittedgroup),
'hostname' => $this->submittedhost,
'groupname' => ($this->submittedgroup ? get_field('group', 'name', 'id', $this->submittedgroup) : ''),
'eventfor' => 'collection'));
// We don't send out notifications about the release of remote-submitted Views & Collections
......
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