diff --git a/classes/processor.php b/classes/processor.php index 5ad4212..95242c9 100644 --- a/classes/processor.php +++ b/classes/processor.php @@ -1453,16 +1453,21 @@ public static function select_deselect_javascript() { require(["jquery"], function($) { $(".coursearchiver_selectall #id_toggle").click(function() { var text = $(this).val().length > 0 ? $(this).val() : $(this).text().trim(); - if("'.get_string('selectall', 'tool_coursearchiver').'" === text) { - $("input:checkbox").prop("checked", true); + if ("'.get_string('selectall', 'tool_coursearchiver').'" === text) { + $("input[type=checkbox]", "#region-main").prop("checked", true); $(".coursearchiver_selectall #id_toggle").val("'.get_string('deselectall', 'tool_coursearchiver').'"); $(".coursearchiver_selectall #id_toggle").text("'.get_string('deselectall', 'tool_coursearchiver').'"); - } - else if("'.get_string('deselectall', 'tool_coursearchiver').'" === text) { - $("input:checkbox").prop("checked", false); + } else if ("'.get_string('deselectall', 'tool_coursearchiver').'" === text) { + $("input[type=checkbox]", "#region-main").prop("checked", false); $(".coursearchiver_selectall #id_toggle").val("'.get_string('selectall', 'tool_coursearchiver').'"); $(".coursearchiver_selectall #id_toggle").text("'.get_string('selectall', 'tool_coursearchiver').'"); } + + if ($("input[type=checkbox]:checked", "#region-main").length) { + $(".camultibuttons").show(); + } else { + $(".camultibuttons").hide(); + } }); }); '); @@ -1627,17 +1632,6 @@ public static function get_archivelist($search, $recover = false) { '', $config->coursearchiverpath), "/\\"); - // Form start. - $rowcolor = "#FFF"; - $data = [ - "formstart" => true, - "isadmin" => $isadmin, - "recover" => $recover, - "searchterm" => $search, - "rowcolor" => $rowcolor, - "limiter" => $config->archivelimit, - ]; - $courses = $OUTPUT->render_from_template('tool_coursearchiver/archive_view', $data); $params = []; @@ -1662,6 +1656,19 @@ public static function get_archivelist($search, $recover = false) { $config->archivelimit ); + // Form start. + $rowcolor = "#FFF"; + $data = [ + "formstart" => true, + "results" => ($archives), + "isadmin" => $isadmin, + "recover" => $recover, + "searchterm" => $search, + "rowcolor" => $rowcolor, + "limiter" => $config->archivelimit, + ]; + $courses = $OUTPUT->render_from_template('tool_coursearchiver/archive_view', $data); + if ($archives) { foreach ($archives as $archive) { $pathinfo = pathinfo($archive->filename); @@ -1684,30 +1691,33 @@ public static function get_archivelist($search, $recover = false) { $rowcolor = $rowcolor == "#FFF" ? "#EEE" : "#FFF"; // Form content. - $data = ["formcontent" => true, - "isadmin" => $isadmin, - "recover" => $recover, - "rowcolor" => $rowcolor, - "file" => $file, - "path" => $path, - "downloadurl" => $downloadurl, - "restoreurl" => $restoreurl, - ]; + $data = [ + "formcontent" => true, + "results" => ($archives), + "isadmin" => $isadmin, + "recover" => $recover, + "rowcolor" => $rowcolor, + "file" => $file, + "path" => $path, + "downloadurl" => $downloadurl, + "restoreurl" => $restoreurl, + ]; $courses .= $OUTPUT->render_from_template('tool_coursearchiver/archive_view', $data); } } else { $rowcolor = $rowcolor == "#FFF" ? "#EEE" : "#FFF"; // Form content. - $data = ["nocontent" => true, - "isadmin" => $isadmin, - "recover" => $recover, - "rowcolor" => $rowcolor, - ]; + $data = [ + "nocontent" => true, + "isadmin" => $isadmin, + "recover" => $recover, + "rowcolor" => $rowcolor, + ]; $courses .= $OUTPUT->render_from_template('tool_coursearchiver/archive_view', $data); } // Form end. - $data = ["formend" => true, "recover" => $recover, "isadmin" => $isadmin]; + $data = ["formend" => true, "recover" => $recover, "isadmin" => $isadmin, "results" => ($archives)]; $courses .= $OUTPUT->render_from_template('tool_coursearchiver/archive_view', $data); return $courses; diff --git a/lang/en/tool_coursearchiver.php b/lang/en/tool_coursearchiver.php index 3c4e0fe..cf3ed14 100644 --- a/lang/en/tool_coursearchiver.php +++ b/lang/en/tool_coursearchiver.php @@ -61,7 +61,8 @@ $string['cli_question_hide'] = 'Hide these {$a} courses?'; $string['cli_question_hideemail'] = 'Send these {$a} users a "Course to be hidden" email?'; $string['confirm'] = 'Continue'; -$string['confirmdelete'] = 'Are you sure you want to delete?'; +$string['confirmdelete'] = 'Are you sure you want to delete these archived files?'; +$string['confirmdownload'] = 'Are you sure you want to download these archived files?'; $string['confirmmessage'] = 'Are you sure you want to {$a}'; $string['confirmmessagearchive'] = 'archive and remove these {$a} courses?'; $string['confirmmessagearchiveemail'] = 'send an email notification of pending course archival to these {$a} course owners?'; @@ -118,6 +119,7 @@ '; $string['deletewarningsubject'] = 'Notice: Courses will be deleted soon.'; $string['deselectall'] = 'Deselect All'; +$string['downloadselected'] = 'Download Selected'; $string['email'] = 'Send Email'; $string['emailselector'] = 'Users selected to receive emails.'; $string['empty'] = 'empty'; diff --git a/templates/archive_view.mustache b/templates/archive_view.mustache index 16e1176..72cc696 100644 --- a/templates/archive_view.mustache +++ b/templates/archive_view.mustache @@ -76,11 +76,13 @@ {{/limiter}} {{#isadmin}} -
- -
+ {{#results}} +
+ +
+ {{/results}}
{{/isadmin}} @@ -103,7 +105,32 @@
{{#isadmin}} - + {{/isadmin}} @@ -113,7 +140,7 @@ {{path}} - + {{# str }} download, moodle {{/ str }} {{#isadmin}} @@ -136,25 +163,33 @@ {{#formend}}
- {{#isadmin}} - {{#recover}} - - {{/recover}} - {{^recover}} - - {{/recover}} - -
-
- -
- {{/isadmin}} + {{#results}} + {{#isadmin}} + {{#recover}} + + {{/recover}} + {{^recover}} + + + {{/recover}} + + +
+ +
+ {{/isadmin}} + {{/results}} {{/formend}} \ No newline at end of file