From db79c1b96006fbb5d6fb1ce0d9e9a53db0071155 Mon Sep 17 00:00:00 2001 From: mjollnir_ Date: Sat, 9 Aug 2008 13:43:01 +0000 Subject: [PATCH] MDL-15991 - made box.net client library support change to curl integration with files api MDL-15992 - added renameFile function to box.net client library --- repository/boxnet/boxlibphp5.php | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/repository/boxnet/boxlibphp5.php b/repository/boxnet/boxlibphp5.php index f4ed213ef6..d5f962af79 100755 --- a/repository/boxnet/boxlibphp5.php +++ b/repository/boxnet/boxlibphp5.php @@ -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; -- 2.39.5