diff options
Diffstat (limited to 'lib/ocs')
-rw-r--r-- | lib/ocs/cloud.php | 60 | ||||
-rw-r--r-- | lib/ocs/result.php | 50 |
2 files changed, 53 insertions, 57 deletions
diff --git a/lib/ocs/cloud.php b/lib/ocs/cloud.php index 5553ae38215..132d923d960 100644 --- a/lib/ocs/cloud.php +++ b/lib/ocs/cloud.php @@ -24,49 +24,23 @@ class OC_OCS_Cloud { - public static function getSystemWebApps() { - OC_Util::checkLoggedIn(); - $apps = OC_App::getEnabledApps(); - $values = array(); - foreach($apps as $app) { - $info = OC_App::getAppInfo($app); - if(isset($info['standalone'])) { - $newValue = array('name'=>$info['name'], 'url'=>OC_Helper::linkToAbsolute($app, ''), 'icon'=>''); - $values[] = $newValue; - } - } - return new OC_OCS_Result($values); - } - - public static function getUserQuota($parameters) { - $user = OC_User::getUser(); - if(OC_User::isAdminUser($user) or ($user==$parameters['user'])) { - - if(OC_User::userExists($parameters['user'])) { - // calculate the disc space - $userDir = '/'.$parameters['user'].'/files'; - \OC\Files\Filesystem::init($parameters['user'], $userDir); - $rootInfo = \OC\Files\Filesystem::getFileInfo(''); - $sharedInfo = \OC\Files\Filesystem::getFileInfo('/Shared'); - $used = $rootInfo['size'] - $sharedInfo['size']; - $free = \OC\Files\Filesystem::free_space(); - $total = $free + $used; - if($total===0) $total = 1; // prevent division by zero - $relative = round(($used/$total)*10000)/100; - - $xml = array(); - $xml['quota'] = $total; - $xml['free'] = $free; - $xml['used'] = $used; - $xml['relative'] = $relative; - - return new OC_OCS_Result($xml); - } else { - return new OC_OCS_Result(null, 300); - } - } else { - return new OC_OCS_Result(null, 300); - } + public static function getCapabilities($parameters) { + $result = array(); + list($major, $minor, $micro) = OC_Util::getVersion(); + $result['version'] = array( + 'major' => $major, + 'minor' => $minor, + 'micro' => $micro, + 'string' => OC_Util::getVersionString(), + 'edition' => OC_Util::getEditionString(), + ); + + $result['capabilities'] = array( + 'core' => array( + 'pollinterval' => OC_Config::getValue('pollinterval', 60), + ), + ); + return new OC_OCS_Result($result); } public static function getUserPublickey($parameters) { diff --git a/lib/ocs/result.php b/lib/ocs/result.php index 65b2067fc3f..729c39056d9 100644 --- a/lib/ocs/result.php +++ b/lib/ocs/result.php @@ -22,7 +22,7 @@ class OC_OCS_Result{ - private $data, $message, $statusCode, $items, $perPage; + protected $data, $message, $statusCode, $items, $perPage; /** * create the OCS_Result object @@ -49,26 +49,48 @@ class OC_OCS_Result{ public function setItemsPerPage(int $items) { $this->perPage = $items; } - + + /** + * get the status code + * @return int + */ + public function getStatusCode() { + return $this->statusCode; + } + /** - * returns the data associated with the api result + * get the meta data for the result * @return array */ - public function getResult() { - $return = array(); - $return['meta'] = array(); - $return['meta']['status'] = ($this->statusCode === 100) ? 'ok' : 'failure'; - $return['meta']['statuscode'] = $this->statusCode; - $return['meta']['message'] = $this->message; + public function getMeta() { + $meta = array(); + $meta['status'] = ($this->statusCode === 100) ? 'ok' : 'failure'; + $meta['statuscode'] = $this->statusCode; + $meta['message'] = $this->message; if(isset($this->items)) { - $return['meta']['totalitems'] = $this->items; + $meta['totalitems'] = $this->items; } if(isset($this->perPage)) { - $return['meta']['itemsperpage'] = $this->perPage; + $meta['itemsperpage'] = $this->perPage; } - $return['data'] = $this->data; - // Return the result data. - return $return; + return $meta; + + } + + /** + * get the result data + * @return array|string|int + */ + public function getData() { + return $this->data; + } + + /** + * return bool if the method succedded + * @return bool + */ + public function succeeded() { + return (substr($this->statusCode, 0, 1) === '1'); } |