2012-07-30 16:42:18 +04:00
|
|
|
<?php
|
2012-12-31 19:47:15 +04:00
|
|
|
/**
|
|
|
|
* ownCloud
|
|
|
|
*
|
|
|
|
* @author Frank Karlitschek
|
|
|
|
* @author Tom Needham
|
|
|
|
* @copyright 2012 Frank Karlitschek frank@owncloud.org
|
|
|
|
* @copyright 2012 Tom Needham tom@owncloud.com
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 3 of the License, or any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
2012-07-30 16:42:18 +04:00
|
|
|
|
|
|
|
class OC_OCS_Privatedata {
|
|
|
|
|
2012-12-31 19:47:15 +04:00
|
|
|
public static function get($parameters) {
|
2012-08-01 00:19:11 +04:00
|
|
|
OC_Util::checkLoggedIn();
|
2012-07-30 23:13:29 +04:00
|
|
|
$user = OC_User::getUser();
|
|
|
|
$app = addslashes(strip_tags($parameters['app']));
|
|
|
|
$key = addslashes(strip_tags($parameters['key']));
|
2013-02-09 20:35:47 +04:00
|
|
|
$result = OC_OCS::getData($user, $app, $key);
|
2012-12-12 22:06:07 +04:00
|
|
|
$xml = array();
|
2012-07-30 16:42:18 +04:00
|
|
|
foreach($result as $i=>$log) {
|
|
|
|
$xml[$i]['key']=$log['key'];
|
|
|
|
$xml[$i]['app']=$log['app'];
|
|
|
|
$xml[$i]['value']=$log['value'];
|
|
|
|
}
|
2012-12-12 21:35:58 +04:00
|
|
|
return new OC_OCS_Result($xml);
|
2012-07-30 16:42:18 +04:00
|
|
|
//TODO: replace 'privatedata' with 'attribute' once a new libattice has been released that works with it
|
|
|
|
}
|
2013-01-14 23:30:39 +04:00
|
|
|
|
2012-12-31 19:47:15 +04:00
|
|
|
public static function set($parameters) {
|
2012-08-01 00:19:11 +04:00
|
|
|
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');
|
2013-02-09 19:46:55 +04:00
|
|
|
if(OC_Preferences::setValue($user, $app, $key, $value)) {
|
2012-12-12 21:35:58 +04:00
|
|
|
return new OC_OCS_Result(null, 100);
|
2012-07-30 16:42:18 +04:00
|
|
|
}
|
|
|
|
}
|
2013-01-14 23:30:39 +04:00
|
|
|
|
2012-12-31 19:47:15 +04:00
|
|
|
public static function delete($parameters) {
|
2012-08-01 00:19:11 +04:00
|
|
|
OC_Util::checkLoggedIn();
|
|
|
|
$user = OC_User::getUser();
|
|
|
|
$app = addslashes(strip_tags($parameters['app']));
|
|
|
|
$key = addslashes(strip_tags($parameters['key']));
|
2012-12-31 19:47:15 +04:00
|
|
|
if($key==="" or $app==="") {
|
2012-12-12 21:35:58 +04:00
|
|
|
return new OC_OCS_Result(null, 101); //key and app are NOT optional here
|
2012-07-30 16:42:18 +04:00
|
|
|
}
|
2012-12-31 19:47:15 +04:00
|
|
|
if(OC_Preferences::deleteKey($user, $app, $key)) {
|
2012-12-12 21:35:58 +04:00
|
|
|
return new OC_OCS_Result(null, 100);
|
2012-07-30 16:42:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|