Fixed deprecation warnings and improved compatibility with newer versions.

This commit is contained in:
benson
2025-10-09 16:46:28 +08:00
parent b97c6e9c7a
commit 2be9ec0512
10 changed files with 57 additions and 44 deletions

View File

@@ -10,6 +10,8 @@ use OCP\Settings\ISettings;
use OCA\NCDownloader\Db\Settings;
use OCA\NCDownloader\Tools\Helper;
use OCP\IUserManager;
class Personal implements ISettings
{
@@ -19,18 +21,22 @@ class Personal implements ISettings
private $timeFactory;
/** @var IConfig */
private $config;
/** @var IUserManager */
private $userManager;
private $uid;
private $settings;
public function __construct(
IDBConnection $connection,
ITimeFactory $timeFactory,
IConfig $config
IConfig $config,
IUserManager $userManager
) {
$this->connection = $connection;
$this->timeFactory = $timeFactory;
$this->config = $config;
$this->uid = \OC::$server->getUserSession()->getUser()->getUID();
$this->userManager = $userManager;
$this->uid = \OC::$server->get(\OCP\IUserSession::class)->getUser()->getUID();
$this->settings = new Settings($this->uid);
}
@@ -40,7 +46,10 @@ class Personal implements ISettings
public function getForm()
{
$path = '/apps/ncdownloader/personal/save';
$parameters = [
$user = $this->userManager->get($this->uid);
$groupManager = \OC::$server->get(\OCP\IGroupManager::class);
$isAdmin = ($user !== null) ? $groupManager->isInGroup($user->getUID(), 'admin') : false;
$parameters = [
"settings" => [
"ncd_downloader_dir" => Helper::getDownloadDir(),
"ncd_torrents_dir" => $this->settings->get("ncd_torrents_dir"),
@@ -49,7 +58,7 @@ class Personal implements ISettings
'ncd_seed_time' => $this->settings->get("ncd_seed_time"),
"path" => $path,
"disallow_aria2_settings" => Helper::getAdminSettings("disallow_aria2_settings"),
"is_admin" => \OC_User::isAdminUser($this->uid),
"is_admin" => $isAdmin,
],
"options" => [
[