Fixup OCS modules

This commit is contained in:
Bart Visscher 2012-07-31 22:19:11 +02:00
parent c2bdb5c716
commit 28537037ae
6 changed files with 47 additions and 54 deletions

View File

@ -5,7 +5,4 @@ class OC_OCS_Activity {
public static function activityGet($parameters){
// TODO
}
}
?>

View File

@ -2,8 +2,8 @@
class OC_OCS_Cloud {
public static function systemwebapps($parameters){
$login = OC_OCS::checkpassword();
public static function getSystemWebApps($parameters){
OC_Util::checkLoggedIn();
$apps = OC_App::getEnabledApps();
$values = array();
foreach($apps as $app) {
@ -16,9 +16,10 @@ class OC_OCS_Cloud {
return $values;
}
public static function getQuota($parameters){
$login=OC_OCS::checkpassword();
if(OC_Group::inGroup($login, 'admin') or ($login==$parameters['user'])) {
public static function getUserQuota($parameters){
OC_Util::checkLoggedIn();
$user = OC_User::getUser();
if(OC_Group::inGroup($user, 'admin') or ($user==$parameters['user'])) {
if(OC_User::userExists($parameters['user'])){
// calculate the disc space
@ -47,9 +48,10 @@ class OC_OCS_Cloud {
}
}
public static function setQuota($parameters){
$login=OC_OCS::checkpassword();
if(OC_Group::inGroup($login, 'admin')) {
public static function setUserQuota($parameters){
OC_Util::checkLoggedIn();
$user = OC_User::getUser();
if(OC_Group::inGroup($user, 'admin')) {
// todo
// not yet implemented
@ -63,8 +65,8 @@ class OC_OCS_Cloud {
}
}
public static function getPublickey($parameters){
$login=OC_OCS::checkpassword();
public static function getUserPublickey($parameters){
OC_Util::checkLoggedIn();
if(OC_User::userExists($parameters['user'])){
// calculate the disc space
@ -75,23 +77,20 @@ class OC_OCS_Cloud {
}
}
public static function getPrivatekey($parameters){
$login=OC_OCS::checkpassword();
if(OC_Group::inGroup($login, 'admin') or ($login==$parameters['user'])) {
public static function getUserPrivatekey($parameters){
OC_Util::checkLoggedIn();
$user = OC_User::getUser();
if(OC_Group::inGroup($user, 'admin') or ($user==$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.');
}
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.');
}
}
}
?>

View File

@ -10,7 +10,4 @@ class OC_OCS_Config {
$xml['ssl'] = 'false';
return $xml;
}
}
?>

View File

@ -14,9 +14,5 @@ class OC_OCS_Person {
}else{
return 101;
}
}
}
?>

View File

@ -2,8 +2,8 @@
class OC_OCS_Privatedata {
public static function privatedataGet($parameters){
// TODO check user auth
public static function get($parameters){
OC_Util::checkLoggedIn();
$user = OC_User::getUser();
$app = addslashes(strip_tags($parameters['app']));
$key = addslashes(strip_tags($parameters['key']));
@ -18,15 +18,22 @@ class OC_OCS_Privatedata {
//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();
public static function set($parameters){
OC_Util::checkLoggedIn();
$user = OC_User::getUser();
$app = addslashes(strip_tags($parameters['app']));
$key = addslashes(strip_tags($parameters['key']));
$value = OC_OCS::readData('post', 'value', 'text');
if(OC_OCS::setData($user,$app,$key,$value)){
return 100;
}
}
public static function privatedataDelete($parameteres){
$user = OC_OCS::checkpassword();
public static function delete($parameters){
OC_Util::checkLoggedIn();
$user = OC_User::getUser();
$app = addslashes(strip_tags($parameters['app']));
$key = addslashes(strip_tags($parameters['key']));
if($key=="" or $app==""){
return; //key and app are NOT optional here
}
@ -34,7 +41,4 @@ class OC_OCS_Privatedata {
return 100;
}
}
}
?>

View File

@ -12,14 +12,14 @@ OC_API::register('post', '/person/check', array('OC_OCS_Person', 'check'), 'ocs'
// Activity
OC_API::register('get', '/activity', array('OC_OCS_Activity', 'activityGet'), 'ocs');
// Privatedata
OC_API::register('get', '/privatedata/getattribute/{app}/{key}', array('OC_OCS_Privatedata', 'privatedataGet'), 'ocs');
OC_API::register('post', '/privatedata/setattribute/{app}/{key}', array('OC_OCS_Privatedata', 'privatedataPut'), 'ocs');
OC_API::register('post', '/privatedata/deleteattribute/{app}/{key}', array('OC_OCS_Privatedata', 'privatedataDelete'), 'ocs');
OC_API::register('get', '/privatedata/getattribute/{app}/{key}', array('OC_OCS_Privatedata', 'get'), 'ocs');
OC_API::register('post', '/privatedata/setattribute/{app}/{key}', array('OC_OCS_Privatedata', 'set'), 'ocs');
OC_API::register('post', '/privatedata/deleteattribute/{app}/{key}', array('OC_OCS_Privatedata', 'delete'), 'ocs');
// Cloud
OC_API::register('get', '/cloud/system/webapps', array('OC_OCS_Cloud', 'systemwebapps'), 'ocs');
OC_API::register('get', '/cloud/user/{user}', array('OC_OCS_Cloud', 'getQuota'), 'ocs');
OC_API::register('post', '/cloud/user/{user}', array('OC_OCS_Cloud', 'setQuota'), 'ocs');
OC_API::register('get', '/cloud/user/{user}/publickey', array('OC_OCS_Cloud', 'getPublicKey'), 'ocs');
OC_API::register('get', '/cloud/user/{user}/privatekey', array('OC_OCS_Cloud', 'getPrivateKey'), 'ocs');
OC_API::register('get', '/cloud/system/webapps', array('OC_OCS_Cloud', 'getSystemWebApps'), 'ocs');
OC_API::register('get', '/cloud/user/{user}', array('OC_OCS_Cloud', 'getUserQuota'), 'ocs');
OC_API::register('post', '/cloud/user/{user}', array('OC_OCS_Cloud', 'setUserQuota'), 'ocs');
OC_API::register('get', '/cloud/user/{user}/publickey', array('OC_OCS_Cloud', 'getUserPublicKey'), 'ocs');
OC_API::register('get', '/cloud/user/{user}/privatekey', array('OC_OCS_Cloud', 'getUserPrivateKey'), 'ocs');
?>