Commit a6e021a2 authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic Committed by Robert Lyon
Browse files

Bug 1788300: copy group collections from group homepage

Also stop showing the copy page button on the collection rows

behatnotneeded
Change-Id: I2cfb78609b37fc56fdbf1f12be2f29c08e63a411
(cherry picked from commit d4c1d00c)
parent 0fc61717
......@@ -59,7 +59,8 @@ $groupviews = (array)View::view_search(null, null, (object) array('group' => $gr
false, null, null, null, null, true);
foreach ($groupviews['data'] as &$view) {
if (isset($view['template']) && $view['template']) {
$view['form'] = pieform(create_view_form(null, null, $view['id']));
$collid = !empty($view['collid']) ? $view['collid'] : null;
$view['form'] = pieform(create_view_form(null, null, $view['id'], $collid, $collid));
}
}
if (!empty($configdata['showgroupviews']) && isset($groupviews)) {
......
......@@ -320,7 +320,8 @@ class PluginBlocktypeGroupViews extends MaharaCoreBlocktype {
null, null, true);
foreach ($data['groupviews']->data as &$view) {
if (!$editing && isset($view['template']) && $view['template']) {
$view['form'] = pieform(create_view_form(null, null, $view['id']));
$collid = !empty($view['collid']) ? $view['collid'] : null;
$view['form'] = pieform(create_view_form(null, null, $view['viewid'], $collid, $collid));
}
}
......
......@@ -35,7 +35,7 @@ if (!is_logged_in() && !$group->public) {
if ($usetemplate = param_integer('usetemplate', null)) {
// If a form has been submitted, build it now and pieforms will
// call the submit function straight away
pieform(create_view_form(null, null, $usetemplate));
pieform(create_view_form(null, null, $usetemplate, param_integer('copycollection', null)));
}
define('TITLE', $group->name);
......
......@@ -6737,7 +6737,18 @@ class ViewSubmissionException extends UserException {
}
}
function create_view_form($group=null, $institution=null, $template=null, $collection=null) {
/**
* Create the form buttons for copying a page and/or a collection
*
* @param string $group The ID of the group to copy to
* @param string $institution The ID of the institution to copy to
* @param string $template The ID of the page to copy
* @param string $collection The ID of the collection to copy
* @param string $collectiononly Only display the copy collection button
*
* @return form array
*/
function create_view_form($group=null, $institution=null, $template=null, $collection=null, $collectiononly=false) {
global $USER;
$form = array(
'name' => 'createview',
......@@ -6806,6 +6817,9 @@ function create_view_form($group=null, $institution=null, $template=null, $colle
}
$form['name'] .= $template;
}
if ($collectiononly) {
unset($form['elements']['submit']);
}
return $form;
}
......
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