]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-16535 - nicer messages about invalid exports
authormjollnir_ <mjollnir_>
Tue, 16 Sep 2008 17:50:55 +0000 (17:50 +0000)
committermjollnir_ <mjollnir_>
Tue, 16 Sep 2008 17:50:55 +0000 (17:50 +0000)
lang/en_utf8/portfolio.php
lib/portfolio/exporter.php
portfolio/add.php

index ef830e3c8f3947717beaba6ffd8f59aac21aab0b..8054b5ce49323fc5ac93744c05fdbbfd34d969a7 100644 (file)
@@ -33,6 +33,8 @@ $string['exportqueued'] = 'Portfolio export has been successfully queued for tra
 $string['exportqueuedforced'] = 'Portfolio export has been successfully queued for transfer (the remote system has enforced queued transfers)';
 $string['exportedpreviously'] = 'Previous exports';
 $string['exportexceptionnoexporter'] = 'A portfolio_export_exception was thrown with an active session but no exporter object';
+$string['exportexpired'] = 'Portfolio export expired';
+$string['exportexpireddesc'] = 'You tried to repeat the export of some information, or start an empty export.  To do that properly you should go back to the original location and start again.  This sometimes happens if you use the back button after an export has completed, or by bookmarking an invalid url.';
 $string['failedtosendpackage'] = 'Failed to send your data to the selected portfolio system: original error was $a';
 $string['failedtopackage'] = 'Could not find files to package';
 $string['filedenied'] = 'Access denied to this file';
index 56ef62290f272f224e6feb9fd52611c0e0508d54..d7663874c9ff567b2d680e12e3335f90f3465b1b 100644 (file)
@@ -760,6 +760,19 @@ class portfolio_exporter {
         );
     }
 
+    /** wrapper function to print a friendly error to users
+    *
+    * this is generally caused by them hitting an expired transfer
+    * through the usage of the backbutton
+    */
+    public static function print_expired_export() {
+        $title = get_string('exportexpired', 'portfolio');
+        print_header($title, $title);
+        notify(get_string('exportexpireddesc', 'portfolio'));
+        print_footer();
+        exit;
+    }
+
 }
 
 ?>
index 32116e84cc42cb878b16e088653f119fef21273a..65769de693c72dbef45bf244fe573a5260be3b81 100644 (file)
@@ -29,7 +29,7 @@ if ($dataid) {
             unset($SESSION->portfolioexport);
             redirect($CFG->wwwroot);
         } else {
-            throw $e;
+            portfolio_exporter::print_expired_export();
         }
     }
     if ($cancel) {
@@ -53,6 +53,10 @@ if ($dataid) {
         }
     }
 } else {
+
+    if (empty($_GET) && empty($_POST)) {
+        portfolio_exporter::print_expired_export();
+    }
     // we'e just posted here for the first time and have might the instance already
     if ($instance = optional_param('instance', 0, PARAM_INT)) {
         // this can throw exceptions but there's no point catching and rethrowing here
@@ -66,8 +70,12 @@ if ($dataid) {
         $instance = null;
     }
 
-    $callbackfile = required_param('callbackfile', PARAM_PATH);
-    $callbackclass = required_param('callbackclass', PARAM_ALPHAEXT);
+    $callbackfile = optional_param('callbackfile', null, PARAM_PATH);
+    $callbackclass = optional_param('callbackclass', null, PARAM_ALPHAEXT);
+
+    if (empty($callbackfile) || empty($callbackclass)) {
+        portfolio_exporter::print_expired_export();
+    }
 
     $callbackargs = array();
     foreach (array_keys(array_merge($_GET, $_POST)) as $key) {