Move OCS methods to lib/ocs/.php

This commit is contained in:
Tom Needham 2012-07-30 12:42:18 +00:00
parent f09ecee63a
commit 9072106048
6 changed files with 184 additions and 1 deletions

View File

@ -62,7 +62,7 @@ class OC_API {
}
}
// include core routes
require_once(OC::$SERVERROOT.'core/routes.php');
require_once(OC::$SERVERROOT.'ocs/routes.php');
$name = $parameters['_name'];
$response = array();

11
lib/ocs/activity.php Normal file
View File

@ -0,0 +1,11 @@
<?php
class OC_OCS_Activity {
public static function activityGet($parameters){
// TODO
}
}
?>

97
lib/ocs/cloud.php Normal file
View File

@ -0,0 +1,97 @@
<?php
class OC_OCS_Cloud {
public static function systemwebapps($parameters){
$login = OC_OCS::checkpassword();
$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 $values;
}
public static function getQuota($parameters){
$login=OC_OCS::checkpassword();
if(OC_Group::inGroup($login, 'admin') or ($login==$parameters['user'])) {
if(OC_User::userExists($parameters['user'])){
// calculate the disc space
$user_dir = '/'.$parameters['user'].'/files';
OC_Filesystem::init($user_dir);
$rootInfo=OC_FileCache::get('');
$sharedInfo=OC_FileCache::get('/Shared');
$used=$rootInfo['size']-$sharedInfo['size'];
$free=OC_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 $xml;
}else{
return 300;
}
}else{
return 300;
}
}
public static function setQuota($parameters){
$login=OC_OCS::checkpassword();
if(OC_Group::inGroup($login, 'admin')) {
// todo
// not yet implemented
// add logic here
error_log('OCS call: user:'.$parameters['user'].' quota:'.$parameters['quota']);
$xml=array();
return $xml;
}else{
return 300;
}
}
public static function getPublickey($parameters){
$login=OC_OCS::checkpassword();
if(OC_User::userExists($parameters['user'])){
// calculate the disc space
// TODO
return array();
}else{
return 300;
}
}
public static function getPrivatekey($parameters){
$login=OC_OCS::checkpassword();
if(OC_Group::inGroup($login, 'admin') or ($login==$parameters['user'])) {
if(OC_User::userExists($user)){
// calculate the disc space
$txt='this is the private key of '.$parameters['user'];
echo($txt);
}else{
echo self::generateXml('', 'fail', 300, 'User does not exist');
}
}else{
echo self::generateXml('', 'fail', 300, 'You don´t have permission to access this ressource.');
}
}
}
?>

16
lib/ocs/config.php Normal file
View File

@ -0,0 +1,16 @@
<?php
class OC_OCS_Config {
public static function apiConfig($parameters){
$xml['version'] = '1.7';
$xml['website'] = 'ownCloud';
$xml['host'] = OCP\Util::getServerHost();
$xml['contact'] = '';
$xml['ssl'] = 'false';
return $xml;
}
}
?>

22
lib/ocs/person.php Normal file
View File

@ -0,0 +1,22 @@
<?php
class OC_OCS_Person {
public static function check($parameters){
if($parameters['login']<>''){
if(OC_User::login($parameters['login'],$parameters['password'])){
$xml['person']['personid'] = $parameters['login'];
return $xml;
}else{
return 102;
}
}else{
return 101;
}
}
}
?>

37
lib/ocs/privatedata.php Normal file
View File

@ -0,0 +1,37 @@
<?php
class OC_OCS_Privatedata {
public static function privatedataGet($parameters){
$user = OC_OCS::checkpassword();
$result = OC_OCS::getData($user,$app,$key);
$xml= array();
foreach($result as $i=>$log) {
$xml[$i]['key']=$log['key'];
$xml[$i]['app']=$log['app'];
$xml[$i]['value']=$log['value'];
}
return $xml;
//TODO: replace 'privatedata' with 'attribute' once a new libattice has been released that works with it
}
public static function privatedataSet($parameters){
$user = OC_OCS::checkpassword();
if(OC_OCS::setData($user,$app,$key,$value)){
return 100;
}
}
public static function privatedataDelete($parameteres){
$user = OC_OCS::checkpassword();
if($key=="" or $app==""){
return; //key and app are NOT optional here
}
if(OC_OCS::deleteData($user,$app,$key)){
return 100;
}
}
}
?>