<?php
$string['activeportfolios'] = 'Active portfolios';
+$string['alreadyalt'] = 'Already exporting - please click here to resolve this transfer';
+$string['alreadytext'] = 'Add to portfolio - needs attention';
$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 <a href=\"$a->finish\">complete that first</a>, or <a href=\"$a->cancel\">click here</a> to cancel it.';
+$string['activeexport'] = 'Resolve active export';
+$string['alreadyexporting'] = 'You already have an active portfolio export in this session. Before continuing, you must either complete this export, or cancel it. Would you like to continue it? (No will cancel it)';
$string['availableformats'] = 'Available export formats';
$string['callercouldnotpackage'] = 'Failed to package up your data for export: original error was $a';
$string['cannotsetvisible'] = 'Cannot set this to visible - the plugin has been completely disabled because of a misconfiguration';
*/
class portfolio_add_button {
+ private $alreadyexporting;
private $callbackclass;
private $callbackargs;
private $callbackfile;
public function __construct($options=null) {
global $SESSION, $CFG;
if (isset($SESSION->portfolioexport)) {
- $a = new StdClass;
- $a->cancel = $CFG->wwwroot . '/portfolio/add.php?cancel=1';
- $a->finish = $CFG->wwwroot . '/portfolio/add.php?id=' . $SESSION->portfolioexport;
- throw new portfolio_button_exception('alreadyexporting', 'portfolio', null, $a);
+ $this->alreadyexporting = true;
+ return;
}
$this->instances = portfolio_instances();
if (empty($options)) {
* this path should be relative (ie, not include) dirroot, eg '/mod/forum/lib.php'
*/
public function set_callback_options($class, array $argarray, $file=null) {
+ if ($this->alreadyexporting) {
+ return;
+ }
global $CFG;
if (empty($file)) {
$backtrace = debug_backtrace();
* {@see portfolio_format_from_file} for how to get the appropriate formats to pass here for uploaded files.
*/
public function set_formats($formats=null) {
+ if ($this->alreadyexporting) {
+ return;
+ }
if (is_string($formats)) {
$formats = array($formats);
}
* this is whole string, not key. optional, defaults to 'Add to portfolio';
*/
public function to_html($format=null, $addstr=null) {
+ if ($this->alreadyexporting) {
+ return $this->already_exporting($format);
+ }
global $CFG, $COURSE;
if (!$this->is_renderable()) {
return;
public function get_callbackclass() {
return $this->callbackclass;
}
+
+ private function already_exporting($format) {
+ global $CFG;
+ $url = $CFG->wwwroot . '/portfolio/already.php';
+ $icon = $CFG->pixpath . '/t/portfoliono.gif';
+ $alt = get_string('alreadyalt', 'portfolio');
+ $text = get_string('alreadytext', 'portfolio');
+ if (empty($format)) {
+ $format = PORTFOLIO_ADD_FULL_FORM;
+ }
+ switch ($format) {
+ case PORTFOLIO_ADD_FULL_FORM:
+ return '<form action="' . $url . '">' . "\n"
+ . '<input type="submit" value="' . $text . '" />' . "\n"
+ . ' </form>';
+ case PORTFOLIO_ADD_ICON_FORM:
+ case PORTFOLIO_ADD_ICON_LINK:
+ return '<a href="' . $url . '"><img src="' . $icon . '" alt="' . $alt . '" /></a>';
+ case PORTFOLIO_ADD_TEXT_LINK:
+ return '<a href="' . $url . '">' . $text . '</a>';
+ default:
+ debugging(get_string('invalidaddformat', 'portfolio', $format));
+ }
+ }
}
/**
--- /dev/null
+<?php
+require_once(dirname(dirname(__FILE__)) . '/config.php');
+
+if (empty($CFG->enableportfolios)) {
+ print_error('disabled', 'portfolio');
+}
+
+$strheading = get_string('activeexport', 'portfolio');
+print_header($strheading, $strheading);
+
+notice_yesno(get_string('alreadyexporting', 'portfolio'), $CFG->wwwroot . '/portfolio/add.php', $CFG->wwwroot . '/portfolio/add.php?cancel=1');
+
+print_footer();
+
+?>