]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-16047 - nicer handling of interupted exports
authormjollnir_ <mjollnir_>
Tue, 19 Aug 2008 10:17:39 +0000 (10:17 +0000)
committermjollnir_ <mjollnir_>
Tue, 19 Aug 2008 10:17:39 +0000 (10:17 +0000)
lang/en_utf8/portfolio.php
lib/portfoliolib.php
portfolio/add.php

index 6f303f83981ebe52b5f0b41adf689dcd387ca104..a7049b0cc8fbd368a62f772f7aec61e2f8455a53 100644 (file)
@@ -3,7 +3,7 @@
 $string['addnewportfolio'] = 'Add a new portfolio';
 $string['addtoportfolio'] = 'Add to portfolio';
 $string['addalltoportfolio'] = 'Add all to portfolio';
-$string['alreadyexporting'] = 'You already have an active portfolio export in this session. Please complete that first, or <a href=\"$a\">click here</a> to cancel it.';
+$string['alreadyexporting'] = 'You already have an active portfolio export in this session. Please <a href=\"$a->finish\">complete that first</a>, or <a href=\"$a->cancel\">click here</a> to cancel it.';
 $string['availableformats'] = 'Available export formats';
 $string['callercouldnotpackage'] = 'Failed to package up your data for export';
 $string['cannotsetvisible'] = 'Cannot set this to visible - the plugin has been completely disabled because of a misconfiguration';
index b0fe301fb846578f4b86f46a8c066ffa2c20b31d..3da55544da9b9d866ba30f387f8e187170f7f8f9 100644 (file)
@@ -185,7 +185,10 @@ function portfolio_add_button($callbackclass, $callbackargs, $callbackfile=null,
     }
 
     if (isset($SESSION->portfolioexport)) {
-        print_error('alreadyexporting', 'portfolio', null, $CFG->wwwroot . '/portfolio/add.php?cancel=1');
+        $a = new StdClass;
+        $a->cancel = $CFG->wwwroot . '/portfolio/add.php?cancel=1';
+        $a->finish = $CFG->wwwroot . '/portfolio/add.php?id=' . $SESSION->portfolioexport;
+        print_error('alreadyexporting', 'portfolio', null, $a);
     }
 
     if (empty($callbackfile)) {
@@ -1715,6 +1718,8 @@ final class portfolio_exporter {
     public $instancefile;
     public $callerfile;
 
+    private $stage;
+
     /**
     * id of this export
     * matches record in portfolio_tempdata table
@@ -1787,9 +1792,9 @@ final class portfolio_exporter {
     * @return boolean whether or not to process the next stage. this is important as the function is called recursively.
     */
     public function process_stage($stage, $alreadystolen=false) {
+        $this->set('stage', $stage);
+        $this->save();
         if (!$alreadystolen && $url = $this->instance->steal_control($stage)) {
-            $this->set('stage', $stage);
-            $this->save();
             redirect($url);
             break;
         }
index fb6607436b3304e641b1f18223ab2913a87041fc..80438ea3058a330ccbc38ce65fbff8a1e657e6e4 100644 (file)
@@ -114,15 +114,18 @@ if (!$exporter->get('instance')) {
     }
 }
 
-$stage = optional_param('stage', PORTFOLIO_STAGE_CONFIG);
+if (!$stage = optional_param('stage', PORTFOLIO_STAGE_CONFIG)) {
+    $stage = $exporter->get('stage');
+}
+
 $alreadystolen = false;
 // for places returning control to pass (rather than PORTFOLIO_STAGE_PACKAGE
 // which is unstable if they can't get to the constant (eg external system)
 if ($postcontrol = optional_param('postcontrol', 0, PARAM_INT)) {
-    $stage = $exporter->get('stage');
     $exporter->instance()->post_control($stage, array_merge($_GET, $_POST));
     $alreadystolen = true;
 }
+
 $exporter->process_stage($stage, $alreadystolen);
 
 ?>