richdocuments/lib/AppConfig.php

76 строки
1.6 KiB
PHP
Исходник Обычный вид История

2015-09-18 22:10:27 +03:00
<?php
/**
2015-12-16 17:57:44 +03:00
* ownCloud - Richdocuments App
2015-09-18 22:10:27 +03:00
*
* @author Victor Dubiniuk
* @copyright 2015 Victor Dubiniuk victor.dubiniuk@gmail.com
*
* This file is licensed under the Affero General Public License version 3 or
* later.
*/
2016-03-06 00:40:47 +03:00
2015-12-16 17:57:44 +03:00
namespace OCA\Richdocuments;
2015-09-18 22:10:27 +03:00
use \OCP\IConfig;
2016-09-14 09:16:15 +03:00
class AppConfig{
private $appName = 'richdocuments';
2015-09-18 22:10:27 +03:00
private $defaults = [
2016-03-24 00:03:39 +03:00
'wopi_url' => 'https://localhost:9980'
2015-09-18 22:10:27 +03:00
];
2016-03-06 00:40:47 +03:00
2015-09-18 22:10:27 +03:00
private $config;
2016-03-06 00:40:47 +03:00
2015-09-18 22:10:27 +03:00
public function __construct(IConfig $config) {
$this->config = $config;
}
2016-03-06 00:40:47 +03:00
2015-09-18 22:10:27 +03:00
/**
* Get a value by key
* @param string $key
* @return string
*/
public function getAppValue($key) {
$defaultValue = null;
if (array_key_exists($key, $this->defaults)){
$defaultValue = $this->defaults[$key];
}
return $this->config->getAppValue($this->appName, $key, $defaultValue);
}
/**
* Set a value by key
* @param string $key
* @param string $value
* @return string
*/
public function setAppValue($key, $value) {
return $this->config->setAppValue($this->appName, $key, $value);
}
2016-03-06 00:40:47 +03:00
2015-09-18 22:10:27 +03:00
/**
* Get a value by key for a user
* @param string $userId
* @param string $key
* @return string
*/
public function getUserValue($userId, $key) {
$defaultValue = null;
if (array_key_exists($key, $this->defaults)){
$defaultValue = $this->defaults[$key];
}
return $this->config->getUserValue($userId, $this->appName, $key, $defaultValue);
}
/**
* Set a value by key for a user
* @param string $userId
* @param string $key
* @param string $value
* @return string
*/
public function setUserValue($userId, $key, $value) {
return $this->config->setAppValue($userId, $this->appName, $key, $value);
}
}