From: mjollnir_ Date: Tue, 9 Sep 2008 21:03:37 +0000 (+0000) Subject: MDL-15760 improvements to create folder handling in box.net portfolio plugin X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=53aa4841c4c18a1effa9ca985d750ab262b4bfdd;p=moodle.git MDL-15760 improvements to create folder handling in box.net portfolio plugin --- diff --git a/lang/en_utf8/portfolio_boxnet.php b/lang/en_utf8/portfolio_boxnet.php index 077d54c927..af6ab8f0ba 100644 --- a/lang/en_utf8/portfolio_boxnet.php +++ b/lang/en_utf8/portfolio_boxnet.php @@ -15,6 +15,7 @@ $string['password'] = 'Your box.net password (will not be stored)'; $string['pluginname'] = 'Box.net internet storage'; $string['sharedfolder'] = 'Shared'; $string['targetfolder'] = 'Target folder'; +$string['tobecreated'] = 'To be created'; $string['username'] = 'Your box.net username (will not be stored)'; ?> diff --git a/portfolio/type/boxnet/lib.php b/portfolio/type/boxnet/lib.php index 5a18f9d66a..e84fa997fb 100644 --- a/portfolio/type/boxnet/lib.php +++ b/portfolio/type/boxnet/lib.php @@ -15,6 +15,14 @@ class portfolio_plugin_boxnet extends portfolio_plugin_push_base { } public function prepare_package() { + // if we need to create the folder, do it now + if ($newfolder = $this->get_export_config('newfolder')) { + if (!$created = $this->boxclient->createFolder($newfolder, array('share' => 0))) { + throw new portfolio_plugin_exception('foldercreatefailed', 'portfolio_boxnet'); + } + $this->folders[$created['folder_id']] = $created['folder_type']; + $this->set_export_config(array('folder' => $created['folder_id'])); + } return true; // don't do anything else for this plugin, we want to send all files as they are. } @@ -24,7 +32,8 @@ class portfolio_plugin_boxnet extends portfolio_plugin_push_base { $return = $this->boxclient->uploadFile( array( 'file' => $file, - 'folder_id' => $this->get_export_config('folder') + 'folder_id' => $this->get_export_config('folder'), + 'share' => 0, ) ); if (array_key_exists('status', $return) && $return['status'] == 'upload_ok' @@ -39,21 +48,15 @@ class portfolio_plugin_boxnet extends portfolio_plugin_push_base { return is_array($ret) && !empty($ret); } - public function set_export_config($config) { - parent::set_export_config($config); - if (array_key_exists('newfolder', $config) && !empty($config['newfolder'])) { - if (!$created = $this->boxclient->createFolder($config['newfolder'])) { - throw new portfolio_plugin_exception('foldercreatefailed', 'portfolio_boxnet'); - } - $this->folders[$created['folder_id']] = $created['folder_type']; - parent::set_export_config(array('folder' => $created['folder_id'])); - } - } - public function get_export_summary() { $allfolders = $this->get_folder_list(); + if ($newfolder = $this->get_export_config('newfolder')) { + $foldername = $newfolder . ' (' . get_string('tobecreated', 'portfolio_boxnet') . ')'; + } else { + $foldername = $allfolders[$this->get_export_config('folder')]; + } return array( - get_string('targetfolder', 'portfolio_boxnet') => $allfolders[$this->get_export_config('folder')] + get_string('targetfolder', 'portfolio_boxnet') => $foldername ); }