MDL-16535 - nicer messages about invalid exports

This commit is contained in:
mjollnir_
2008-09-16 17:50:55 +00:00
parent a7d9068300
commit c737eed82f
3 changed files with 26 additions and 3 deletions
+2
View 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';
+13
View 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;
}
}
?>
+11 -3
View 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) {