MDL-15777 - updated most of the portfolio code to use files api.

Not done:

- forum (the rest of the module isn't using files api yet)
- database mod (touches other parts of the code (ods and excel libs)
- portfolio download plugin (needs discussion with petr about userfiles)

all of these have been disabled in the meantime.
This commit is contained in:
mjollnir_ 2008-08-09 14:24:58 +00:00
parent db79c1b960
commit d67bfc32a1
13 changed files with 178 additions and 126 deletions

View file

@ -35,6 +35,7 @@ if ($dataid) {
}
$instance->set('user', $USER);
$exporter->set('instance', $instance);
$exporter->save();
}
}
} else {
@ -94,18 +95,8 @@ if ($dataid) {
$SESSION->portfolioexport = $exporter->get('id');
}
$stage = optional_param('stage', PORTFOLIO_STAGE_CONFIG);
$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;
}
if (!$exporter->get('instance')) {
print_object($exporter);
// we've just arrived but have no instance
// so retrieve everything from the request,
// add them as hidden fields in a new form
@ -135,6 +126,15 @@ if (!$exporter->get('instance')) {
}
}
$stage = optional_param('stage', PORTFOLIO_STAGE_CONFIG);
$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);
?>

View file

@ -7,24 +7,26 @@ class portfolio_plugin_boxnet extends portfolio_plugin_base {
private $boxclient;
private $ticket;
private $authtoken;
private $workdir;
private $folders;
public function prepare_package($tempdir) {
$this->workdir = $tempdir;
public function prepare_package() {
return true; // don't do anything else for this plugin, we want to send all files as they are.
}
public function send_package() {
$ret = array();
foreach (get_directory_list($this->workdir) as $file) {
$file = $this->workdir . '/' . $file;
$ret[] = $this->boxclient->uploadFile(
foreach ($this->exporter->get_tempfiles() as $file) {
$return = $this->boxclient->uploadFile(
array(
'file' => $file,
'folder_id' => $this->get_export_config('folder')
)
);
if (array_key_exists('status', $return) && $return['status'] == 'upload_ok'
&& array_key_exists('id', $return) && count($return['id']) == 1) {
$return['rename'] = $this->boxclient->renameFile($return['id'][array_pop(array_keys($return['id']))], $file->get_filename());
$ret[] = $return;
}
}
if ($this->boxclient->isError()) {
return false;

View file

@ -15,7 +15,7 @@ class portfolio_plugin_download extends portfolio_plugin_base {
return PORTFOLIO_TIME_LOW;
}
public function prepare_package($tempdir) {
public function prepare_package() {
// just zip up whatever files the caller has created for us
// and move them to the user's temporary area.
$userdir = temp_portfolio_usertemp_directory($this->get('user')->id);
@ -47,6 +47,10 @@ class portfolio_plugin_download extends portfolio_plugin_base {
public function get_continue_url() {
return false;
}
public static function plugin_sanity_check() {
return 'notupgradedtousefilesapi';
}
}
?>