source: pro-bachkim-filespace/sourcecode/application/libraries/vservices.php @ 66

Last change on this file since 66 was 66, checked in by dungnv, 11 years ago
File size: 2.0 KB
Line 
1<?php
2
3Class VServices {
4       
5        private $_apiUrl;
6        private $_curlObj;
7        private $_userId;
8        private $_password;
9       
10        public function __construct() {
11               
12        }
13       
14        public function setApiUrl($url) {
15                $this->_apiUrl = $url;
16        }
17       
18        public function setConnection($curl) {
19                $this->_curlObj = $curl;
20        }
21       
22        public function setUserId ($userId) {
23                $this->_userId = $userId;
24        }
25       
26        public function setPassword ($password) {
27                $this->_password = $password;
28        }
29       
30        public function getPrivateTree () {
31                $this->_curlObj->create($this->_apiUrl. 'space/dir/isgetall/1');
32                $this->_curlObj->option(CURLOPT_BUFFERSIZE, 10);
33                $this->_curlObj->options(array(CURLOPT_BUFFERSIZE => 10));
34               
35                $post = array('userid' => $this->_userId);
36                $this->_curlObj->post($post);
37                return $this->_curlObj->execute();
38        }
39       
40        /**
41         * $aryParams
42         *
43         * @param unknown $action
44         * @param unknown $aryParams
45         */
46        public function actionExecute ($action, $aryParams = array()) {
47                $this->_curlObj->create($this->_apiUrl. 'space/'.$action);
48                $this->_curlObj->option(CURLOPT_BUFFERSIZE, 10);
49                $this->_curlObj->options(array(CURLOPT_BUFFERSIZE => 10));
50               
51                $aryParams['userid'] = $this->_userId;
52                $this->_curlObj->post($aryParams);
53                return $this->_curlObj->execute();
54        }
55       
56        public function createDir ($dirName, $parentId) {
57                $this->_curlObj->create($this->_apiUrl. 'space/mkdir');
58                $this->_curlObj->option(CURLOPT_BUFFERSIZE, 10);
59                $this->_curlObj->options(array(CURLOPT_BUFFERSIZE => 10));
60               
61                $post = array('userid' => $this->_userId, 'parent_id' => $parentId, 'name' => $dirName);
62                $this->_curlObj->post($post);
63                return $this->_curlObj->execute();
64        }
65       
66        public function deleteDir ($dirId) {
67                $this->_curlObj->create($this->_apiUrl. 'space/delete');
68                $this->_curlObj->option(CURLOPT_BUFFERSIZE, 10);
69                $this->_curlObj->options(array(CURLOPT_BUFFERSIZE => 10));
70               
71                $post = array('userid' => $this->_userId, 'type' => 'folder', 'id' => $dirId);
72                $this->_curlObj->post($post);
73                return $this->_curlObj->execute();
74        }
75               
76        public function __destruct() {
77               
78        }
79}
Note: See TracBrowser for help on using the repository browser.