new helper function to retrieve settings

This commit is contained in:
huangjx
2022-04-22 18:29:21 +08:00
parent 49477881a9
commit 5ae1685044
7 changed files with 29 additions and 24 deletions

View File

@@ -32,8 +32,7 @@ class Aria2Controller extends Controller
$this->l10n = $IL10N;
$this->rootFolder = $rootFolder;
$this->urlGenerator = \OC::$server->getURLGenerator();
$this->settings = new Settings($UserId);
$this->downloadDir = $this->settings->get('ncd_downloader_dir') ?? "/Downloads";
$this->downloadDir = Helper::getDownloadDir();
OC_Util::setupFS();
//$this->config = \OC::$server->getAppConfig();
$this->aria2 = $aria2;

View File

@@ -38,10 +38,9 @@ class MainController extends Controller
$this->dbconn = new DbHelper();
$this->counters = new Counters($aria2, $this->dbconn, $UserId);
$this->youtube = $youtube;
$this->settings = new Settings($this->uid);
$this->isAdmin = \OC_User::isAdminUser($this->uid);
$this->hideError = $this->settings->get("ncd_hide_errors", false);
$this->disable_bt_nonadmin = $this->settings->setType($this->settings::TYPE['SYSTEM'])->get("ncd_disable_bt", false);
$this->hideError = Helper::getSettings("ncd_hide_errors", false);
$this->disable_bt_nonadmin = Helper::getSettings("ncd_disable_bt", false, Settings::TYPE["SYSTEM"]);
$this->accessDenied = $this->l10n->t("Sorry,only admin users can download files via BT!");
}
/**

View File

@@ -111,7 +111,7 @@ class SettingsController extends Controller
{
$saved = json_decode($this->settings->get("custom_youtube_dl_settings"), 1);
$params = $this->request->getParams();
foreach ($data as $key => $value) {
foreach ($params as $key => $value) {
unset($saved[$key]);
}
$resp = $this->settings->save("custom_youtube_dl_settings", json_encode($saved));

View File

@@ -5,7 +5,6 @@ use OCA\NCDownloader\Tools\Aria2;
use OCA\NCDownloader\Tools\DbHelper;
use OCA\NCDownloader\Tools\folderScan;
use OCA\NCDownloader\Tools\Helper;
use OCA\NCDownloader\Tools\Settings;
use OCA\NCDownloader\Tools\Youtube;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse;
@@ -26,8 +25,7 @@ class YoutubeController extends Controller
$this->uid = $UserId;
$this->urlGenerator = \OC::$server->getURLGenerator();
$this->l10n = $IL10N;
$this->settings = new Settings($UserId);
$this->downloadDir = $this->settings->get('ncd_downloader_dir') ?? "/Downloads";
$this->downloadDir = Helper::getDownloadDir();
$this->dbconn = new DbHelper();
$this->youtube = $youtube;
$this->aria2 = $aria2;