$string['err_uniquename'] = 'Portfolio name must be unique (per plugin)';
$string['enabled'] = 'Enable portfolios';
$string['enableddesc'] = 'This will allow administrators to configure remote systems for users to export content to';
+$string['exportalreadyfinished']= 'Portfolio export complete!';
+$string['exportalreadyfinisheddesc'] = 'Portfolio export complete!';
$string['exporting'] = 'Exporting to portfolio';
$string['exportingcontentfrom'] = 'Exporting content from $a';
$string['exportcomplete'] = 'Portfolio export complete!';
*/
private $expirytime;
+ /**
+ * deleted - this is set during the cleanup routine
+ * so that subsequent save() calls can detect it
+ */
+ private $deleted = false;
+
/**
* construct a new exporter for use
*
$DB->delete_records('portfolio_tempdata', array('id' => $this->id));
$fs = get_file_storage();
$fs->delete_area_files(SYSCONTEXTID, 'portfolio_exporter', $this->id);
+ $this->deleted = true;
return true;
}
'caller_file' => $this->callerfile,
'caller_sha1' => $this->caller->get_sha1(),
'caller_class' => get_class($this->caller),
+ 'continueurl' => $this->instance->get_static_continue_url(),
+ 'returnurl' => $this->caller->get_return_url(),
+ 'tempdataid' => $this->id,
'time' => time(),
);
$DB->insert_record('portfolio_log', $l);
}
+ /**
+ * in some cases (mahara) we need to update this after the log has been done
+ * because of MDL-20872
+ */
+ public function update_log_url($url) {
+ global $DB;
+ $DB->set_field('portfolio_log', 'continueurl', $url, array('tempdataid' => $this->id));
+ }
+
/**
* processes the 'finish' stage of the export
*
public function process_stage_finished($queued=false) {
global $OUTPUT;
$returnurl = $this->caller->get_return_url();
- $continueurl = $this->instance->get_continue_url();
+ $continueurl = $this->instance->get_interactive_continue_url();
$extras = $this->instance->get_extra_finish_options();
$key = 'exportcomplete';
$this->save(); // call again so that id gets added to the save data.
} else {
if (!$r = $DB->get_record('portfolio_tempdata', array('id' => $this->id))) {
- debugging("tried to save current object, but failed - see MDL-20872");
+ if (!$this->deleted) {
+ debugging("tried to save current object, but failed - see MDL-20872");
+ }
return;
}
$r->data = base64_encode(serialize($this));
*
* @return array of stored_file objects keyed by name
*/
- public function get_tempfiles() {
+ public function get_tempfiles($skipfile='portfolio-export.zip') {
$fs = get_file_storage();
$files = $fs->get_area_files(SYSCONTEXTID, 'portfolio_exporter', $this->id, '', false);
if (empty($files)) {
}
$returnfiles = array();
foreach ($files as $f) {
+ if ($f->get_filename() == $skipfile) {
+ continue;
+ }
$returnfiles[$f->get_filepath() . '/' . $f->get_filename()] = $f;
}
return $returnfiles;
return $DB->get_records_sql_menu($sql, $values);
}
- public static function print_cleaned_export($log) {
+ public static function print_cleaned_export($log, $instance=null) {
global $CFG, $OUTPUT, $PAGE;
+ if (empty($instance) || !$instance instanceof portfolio_plugin) {
+ $instance = portfolio_instance($log->portfolio);
+ }
$title = get_string('exportalreadyfinished', 'portfolio');
$PAGE->navbar->add($title);
$PAGE->set_title($title);
$PAGE->set_heading($title);
echo $OUTPUT->header();
echo $OUTPUT->notification(get_string('exportalreadyfinished', 'portfolio'));
- self::print_finish_info($log->returnurl, $log->continueurl);
+ self::print_finish_info($log->returnurl, $instance->resolve_static_continue_url($log->continueurl));
echo $OUTPUT->continue_button($CFG->wwwroot);
echo $OUTPUT->footer();
exit;
/**
* the url for the user to continue to their portfolio
+ * during the lifecycle of the request
*
* @return string url or false.
*/
- public abstract function get_continue_url();
+ public abstract function get_interactive_continue_url();
+
+ /**
+ * the url to save in the log as the continue url
+ * this is passed through resolve_static_continue_url()
+ * at display time to the user.
+ */
+ public function get_static_continue_url() {
+ return $this->get_interactive_continue_url();
+ }
+
+ /**
+ * override this function if you need to add something on to the url
+ * for post-export continues (eg from the log page)
+ * mahara does this, for example, to start a jump session
+ */
+ public function resolve_static_continue_url($url) {
+ return $url;
+ }
/**
* mform to display to the user in their profile
return true;
}
- public function get_continue_url() {
+ public function get_interactive_continue_url() {
return '';
}
);
}
- public function get_continue_url() {
+ public function get_interactive_continue_url() {
return 'http://box.net/files#0:f:' . $this->get_export_config('folder');
}
return true;
}
- public function get_continue_url() {
+ public function get_interactive_continue_url() {
return false;
}
}
return false;
}
- public function get_continue_url() {
+ public function get_interactive_continue_url() {
// return $this->flickr->urls_getUserPhotos();
return "http://www.flickr.com/tools/uploader_edit.gne?ids="; // Add ids of uploaded files
}
return true;
}
- public function get_continue_url(){
+ public function get_interactive_continue_url(){
return 'http://docs.google.com/';
}
if (isset($response->querystring)) {
$this->continueurl = $response->querystring;
}
+ // if we're not queuing the logging might have already happened
+ $this->exporter->update_log_url($this->get_static_continue_url());
}
- public function get_continue_url() {
- $this->ensure_mnethost();
- $this->ensure_environment();
- $mnetauth = get_auth_plugin('mnet');
+ public function get_static_continue_url() {
$remoteurl = '/artefact/file/';// @todo penny this might change later when we change formats.
if (isset($this->continueurl)) {
$remoteurl .= $this->continueurl;
}
+ return $remoteurl;
+ }
+
+ public function resolve_static_continue_url($remoteurl) {
+ static $sessions = array();
+ // if this is called mutliple times for the same host, stuff breaks
+ // so we have to keep track and just replace the wantsurl bit
+ // in case things go to different plugins or whatever
+ if (array_key_exists($this->get_config('mnethostid'), $sessions)) {
+ return preg_replace('/wantsurl=[^&]*&/', 'wantsurl=' . urlencode($remoteurl) . '&', $sessions[$this->get_config('mnethostid')]);
+ }
+ $this->ensure_mnethost();
+ $this->ensure_environment();
+ $mnetauth = get_auth_plugin('mnet');
if (!$url = $mnetauth->start_jump_session($this->get_config('mnethostid'), $remoteurl)) {
return false;
}
+ $sessions[$this->get_config('mnethostid')] = $url;
return $url;
}
+ public function get_interactive_continue_url() {
+ return $this->resolve_static_continue_url($this->get_static_continue_url());
+ }
+
public function steal_control($stage) {
if ($stage != PORTFOLIO_STAGE_CONFIG) {
return false;
return true;
}
- public function get_continue_url(){
+ public function get_interactive_continue_url(){
return 'http://picasaweb.google.com/';
}
$pluginname = '';
try {
$plugin = portfolio_instance($log->portfolio);
- $pluginname = $plugin->get('name');
+ $url = $plugin->resolve_static_continue_url($log->continueurl);
+ if ($url) {
+ $pluginname = '<a href="' . $url . '">' . $plugin->get('name') . '</a>';
+ } else {
+ $pluginname = $plugin->get('name');
+ }
} catch (portfolio_exception $e) { // may have been deleted
$pluginname = get_string('unknownplugin', 'portfolio');
}
$table->data[] = array(
$pluginname,
- call_user_func(array($class, 'display_name')),
+ '<a href="' . $log->returnurl . '">' . call_user_func(array($class, 'display_name')) . '</a>',
userdate($log->time),
);
}