]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-15760 improvements to create folder handling in box.net portfolio plugin
authormjollnir_ <mjollnir_>
Tue, 9 Sep 2008 21:03:37 +0000 (21:03 +0000)
committermjollnir_ <mjollnir_>
Tue, 9 Sep 2008 21:03:37 +0000 (21:03 +0000)
lang/en_utf8/portfolio_boxnet.php
portfolio/type/boxnet/lib.php

index 077d54c927bcc80af8b3ddd69e841b15ef72f24d..af6ab8f0ba8364c92d31a9c462bf32d204dcd09b 100644 (file)
@@ -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)';
 
 ?>
index 5a18f9d66a1707c1b3f891a5ce97fe4fbd8e9a14..e84fa997fbcc55ad678da37655e5b7ff24ab1974 100644 (file)
@@ -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
         );
     }