Skip to content

Commit

Permalink
MDL-16535 - nicer messages about invalid exports
Browse files Browse the repository at this point in the history
  • Loading branch information
mjollnir_ committed Sep 16, 2008
1 parent a7d9068 commit c737eed
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lang/en_utf8/portfolio.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
$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';
Expand Down
13 changes: 13 additions & 0 deletions lib/portfolio/exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,19 @@ public function get_base_filearea() {
);
}

/** 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;
}

}

?>
14 changes: 11 additions & 3 deletions portfolio/add.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
unset($SESSION->portfolioexport);
redirect($CFG->wwwroot);
} else {
throw $e;
portfolio_exporter::print_expired_export();
}
}
if ($cancel) {
Expand All @@ -53,6 +53,10 @@
}
}
} 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
Expand All @@ -66,8 +70,12 @@
$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) {
Expand Down

0 comments on commit c737eed

Please sign in to comment.