Commit d477fb68 authored by Lisa Seeto's avatar Lisa Seeto Committed by Gerrit Code Review
Browse files

Merge "Bug 1424419: Allow all pages to be deleted when deleting a collection"

parents 172b375a 5b46c5b7
......@@ -81,13 +81,13 @@ $form = pieform(array(
$smarty = smarty();
setpageicon($smarty, 'icon-folder-open');
$smarty->assign('subheading', get_string('deletespecifiedcollection', 'collection', $collection->get('name')));
$smarty->assign('message', get_string('collectionconfirmdelete', 'collection'));
$smarty->assign('message', get_string('collectionconfirmdelete1', 'collection', get_config('wwwroot'), $id));
$smarty->assign('form', $form);
function deletecollection_submit(Pieform $form, $values) {
global $SESSION, $collection, $baseurl;
$SESSION->add_ok_msg(get_string('collectiondeleted', 'collection'));
......@@ -99,6 +99,19 @@ if ($viewids = get_column_sql('SELECT id FROM {view} WHERE owner = ? AND type =
// Select one by default if needed
if ($collid = param_integer('collection', null)) {
$elements['what']['defaultvalue'] = 'collections';
if (isset($elements['collection_' . $collid])) {
$elements['collection_' . $collid]['defaultvalue'] = true;
else if ($viewid = param_integer('view', null)) {
$elements['what']['defaultvalue'] = 'views';
if (isset($elements['view_' . $viewid])) {
$elements['view_' . $viewid]['defaultvalue'] = true;
else {
$elements['what']['disabled'] = true;
......@@ -44,7 +44,9 @@ $string['collectionaccess'] = 'Collection access';
$string['collectionaccessrules'] = 'Collection access rules';
$string['collectionaccesseditedsuccessfully'] = 'Collection access saved successfully';
$string['collectioneditaccess'] = 'You are editing access for %d pages in this collection.';
$string['collectionconfirmdelete'] = 'Pages in this collection will not be deleted. Are you sure you wish to delete this collection?';
$string['collectionconfirmdelete1'] = '<p>Do you really want to delete this collection? It will also delete all pages within this collection. If you only want to delete individual pages, abort this action and delete the pages in question themselves.</p>
<p>Please consider creating a backup by <a href="%sexport/index.php?collection=%s">exporting</a> your portfolio before you delete anything.</p>
<p><strong>Note:</strong> If you decide to delete this collection, all your files and journal entries that you linked in the pages will still be available. However, any text blocks and comments placed on the pages will be deleted along with the pages.</p>';
$string['collectioncreatedsuccessfully'] = 'Collection created successfully.';
$string['collectioncreatedsuccessfullyshare'] = 'Your collection has been created successfully. Share your collection with others using the access links below.';
$string['collectiondeleted'] = 'Collection deleted successfully.';
......@@ -228,7 +228,7 @@ $string['cantsubmittogroup'] = 'You cannot submit to this group.';
$string['cantdeleteview'] = 'You cannot delete this page.';
$string['deletespecifiedview'] = 'Delete page "%s"';
$string['deleteviewconfirm1'] = 'Do you really want to delete this page? It cannot be undone.';
$string['deleteviewconfirmbackup'] = 'Please consider creating a backup of this page by <a href="%sexport/">exporting</a> it.';
$string['deleteviewconfirmbackup1'] = 'Please consider creating a backup of this page by <a href="%sexport/index.php?view=%s">exporting</a> it.';
$string['deleteviewconfirmnote3'] = '<strong>Note:</strong> All your files and journal entries that you linked in this page will still be available.<br/>However, any comments placed on this page will be deleted.';
$string['deleteviewconfirmnote2'] = 'This page is a part of the collection <a href="%s">"%s"</a>.';
......@@ -132,7 +132,7 @@ class Collection {
* Deletes a Collection
public function delete() {
public function delete($deleteviews = false) {
$viewids = get_column('collection_view', 'view', 'collection', $this->id);
......@@ -171,6 +171,14 @@ class Collection {
if ($viewids) {
delete_records_select('view_access', 'view IN (' . join(',', $viewids) . ') AND token IS NOT NULL');
// Delete the views that were in the collection if required
if ($deleteviews) {
foreach ($viewids as $viewid) {
$view = new View($viewid);
$data = array('id' => $this->id,
'name' => $this->name,
'eventfor' => 'collection',
......@@ -2,7 +2,7 @@
<div class="card bg-danger view-container">
<h2 class="card-header">{$subheading}</h2>
<div class="card-body">
......@@ -8,7 +8,7 @@
{if $collectionnote}<p class="lead">{$collectionnote|clean_html|safe}</p>{/if}
{if $landingpagenote}<p class="lead">{$landingpagenote}</p>{/if}
<p>{if $view->get('owner')}
{str tag="deleteviewconfirmbackup" section="view" arg1=$WWWROOT}
{str tag="deleteviewconfirmbackup1" section="view" arg1=$WWWROOT arg2=$view->get('id')}
<p>{str tag="deleteviewconfirmnote3" section="view"}</p>
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