An attempt to obtain a functional version with the various fixes implemented so far.
This commit is contained in:
@@ -12,7 +12,7 @@ class Helper
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->conn = \OC::$server->get(\OCP\IDBConnection::class);
|
||||
$this->conn = \OC::$server->getDatabaseConnection();
|
||||
$this->queryBuilder = $this->conn->getQueryBuilder();
|
||||
$this->prefixedTable = $this->queryBuilder->getTableName($this->table);
|
||||
//$container = \OC::$server->query(\OCP\IServerContainer::class);
|
||||
@@ -130,7 +130,7 @@ class Helper
|
||||
|
||||
public function getDBType(): string
|
||||
{
|
||||
return \OC::$server->get(\OCP\IConfig::class)->getSystemValue('dbtype', "mysql");
|
||||
return \OC::$server->getConfig()->getSystemValue('dbtype', "mysql");
|
||||
}
|
||||
|
||||
public function getExtra($data)
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace OCA\NCDownloader\Db;
|
||||
|
||||
class Settings
|
||||
use OC\AllConfig;
|
||||
|
||||
class Settings extends AllConfig
|
||||
{
|
||||
//@config OC\AppConfig
|
||||
private $appConfig;
|
||||
@@ -10,6 +12,8 @@ class Settings
|
||||
//@OC\SystemConfig
|
||||
private $sysConfig;
|
||||
|
||||
//@OC\AllConfig
|
||||
private $allConfig;
|
||||
private $user;
|
||||
private $appName;
|
||||
//type of settings (system = 1 or app =2)
|
||||
@@ -18,11 +22,13 @@ class Settings
|
||||
public const TYPE = ['SYSTEM' => 1, 'USER' => 2, 'APP' => 3];
|
||||
public function __construct($user = null)
|
||||
{
|
||||
$this->appConfig = \OC::$server->get(\OCP\IConfig::class);
|
||||
$this->sysConfig = \OC::$server->get(\OCP\IConfig::class);
|
||||
//$this->appConfig = \OC::$server->getAppConfig();
|
||||
//$this->appConfig = \OC::$server->getAppConfig();
|
||||
$this->sysConfig = \OC::$server->getSystemConfig();
|
||||
$this->appName = 'ncdownloader';
|
||||
$this->type = self::TYPE['USER'];
|
||||
$this->user = $user;
|
||||
$this->allConfig = new AllConfig($this->sysConfig);
|
||||
//$this->connAdapter = \OC::$server->getDatabaseConnection();
|
||||
//$this->conn = $this->connAdapter->getInner();
|
||||
}
|
||||
@@ -42,16 +48,16 @@ class Settings
|
||||
public function get($key, $default = null)
|
||||
{
|
||||
if ($this->type == self::TYPE['USER'] && isset($this->user)) {
|
||||
return $this->appConfig->getUserValue($this->user, $this->appName, $key, $default);
|
||||
return $this->allConfig->getUserValue($this->user, $this->appName, $key, $default);
|
||||
} else if ($this->type == self::TYPE['SYSTEM']) {
|
||||
return $this->appConfig->getSystemValue($key, $default);
|
||||
return $this->allConfig->getSystemValue($key, $default);
|
||||
} else {
|
||||
return $this->appConfig->getAppValue($this->appName, $key, $default);
|
||||
return $this->allConfig->getAppValue($this->appName, $key, $default);
|
||||
}
|
||||
}
|
||||
public function getAria2()
|
||||
{
|
||||
$settings = $this->appConfig->getUserValue($this->user, $this->appName, "custom_aria2_settings", '');
|
||||
$settings = $this->allConfig->getUserValue($this->user, $this->appName, "custom_aria2_settings", '');
|
||||
return json_decode($settings, 1);
|
||||
}
|
||||
|
||||
@@ -74,11 +80,11 @@ class Settings
|
||||
{
|
||||
try {
|
||||
if ($this->type == self::TYPE['USER'] && isset($this->user)) {
|
||||
$this->appConfig->setUserValue($this->user, $this->appName, $key, $value);
|
||||
$this->allConfig->setUserValue($this->user, $this->appName, $key, $value);
|
||||
} else if ($this->type == self::TYPE['SYSTEM']) {
|
||||
$this->appConfig->setSystemValue($key, $value);
|
||||
$this->allConfig->setSystemValue($key, $value);
|
||||
} else {
|
||||
$this->appConfig->setAppValue($this->appName, $key, $value);
|
||||
$this->allConfig->setAppValue($this->appName, $key, $value);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return ['error' => $e->getMessage()];
|
||||
@@ -91,22 +97,22 @@ class Settings
|
||||
$keys = $this->getAllKeys();
|
||||
$value = [];
|
||||
foreach ($keys as $key) {
|
||||
$value[$key] = $this->appConfig->getAppValue($this->appName, $key);
|
||||
$value[$key] = $this->allConfig->getAppValue($this->appName, $key);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
public function getAllKeys()
|
||||
{
|
||||
return $this->appConfig->getAppKeys($this->appName);
|
||||
return $this->allConfig->getAppKeys($this->appName);
|
||||
}
|
||||
|
||||
public function getAllUserSettings()
|
||||
{
|
||||
$keys = $this->appConfig->getUserKeys($this->user, $this->appName);
|
||||
$keys = $this->allConfig->getUserKeys($this->user, $this->appName);
|
||||
$value = [];
|
||||
foreach ($keys as $key) {
|
||||
$value[$key] = $this->appConfig->getUserValue($this->user, $this->appName, $key);
|
||||
$value[$key] = $this->allConfig->getUserValue($this->user, $this->appName, $key);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user