]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-15991 - made box.net client library support change to curl integration with files api
authormjollnir_ <mjollnir_>
Sat, 9 Aug 2008 13:43:01 +0000 (13:43 +0000)
committermjollnir_ <mjollnir_>
Sat, 9 Aug 2008 13:43:01 +0000 (13:43 +0000)
MDL-15992 - added renameFile function to box.net client library

repository/boxnet/boxlibphp5.php

index f4ed213ef6f654d02f69ed1c7800c0b6f6a46576..d5f962af79a943459a4e57c8b295a480d12ebaff 100755 (executable)
@@ -203,11 +203,15 @@ class boxclient {
         }
         return $ret_array;
     }
-    // Upload File
+
+    /** Upload a File
+    * @param array $params the file MUST be present in key 'file' and be a moodle stored_file object.
+    */
     function UploadFile ($params = array()) {
         $params['auth_token'] = $this->auth_token;
         // this param should be the full path of the file
-        $params['new_file1']  = '@'.$params['file'];
+        $params['new_file1']  = $params['file'];
+        unset($params['file']);
         $defaults = array(
             'folder_id' => 0, //Set to '0' by default. Change to create within sub-folder.
             'share'     => 1, //Set to '1' by default. Set to '0' to make folder private.
@@ -246,6 +250,30 @@ class boxclient {
         return $ret_array;
     }
 
+    function RenameFile($fileid, $newname) {
+        $params = array(
+            'api_key'    => $this->api_key,
+            'auth_token' => $this->auth_token,
+            'action'     => 'rename',
+            'target'     => 'file',
+            'target_id'  => $fileid,
+            'new_name'   => $newname,
+        );
+        $data = $this->makeRequest('action=rename', $params);
+        if ($this->_checkForError($data)) {
+            return false;
+        }
+        foreach ($data as $a) {
+            switch ($a['tag']) {
+                case 'STATUS':
+                    if ($a['value'] == 'e_rename_node') {
+                        return true;
+                    }
+            }
+        }
+        return false;
+    }
+
     // Register New User
     function RegisterUser($params = array()) {
         $params['api_key'] = $this->api_key;