declared class properties

This commit is contained in:
benson
2023-04-29 21:15:52 +08:00
parent 13fd802180
commit a197f66d6d
16 changed files with 65 additions and 14 deletions

View File

@@ -16,7 +16,7 @@ class Aria2
//optional token for authenticating with Aria2
private $token = null;
//the aria2 method being invoked
private $method = null;
public $methodName = null;
//the aria2c binary path
private $bin = null;
// return the following items when getting downloads info by default
@@ -35,6 +35,13 @@ class Aria2
private $rpcUrl;
//php binary path;
private $php;
//curl handle
private $ch;
//aria2 global options
private $onDownloadStart;
private $content;
private $torrentsDir;
public function __construct($options = array())
{
$options += [

View File

@@ -25,6 +25,16 @@ class MainController extends Controller
private $config;
private $aria2Opts;
private $l10n;
private $urlGenerator;
private $uid;
private $isAdmin;
private $hideError;
private $disable_bt_nonadmin;
private $aria2;
private $dbconn;
private $counters;
private $ytdl;
private $accessDenied;
public function __construct($appName, IRequest $request, $UserId, IL10N $IL10N, Aria2 $aria2, Ytdl $ytdl)
{
@@ -55,7 +65,7 @@ class MainController extends Controller
//$config = \OC::$server->getAppConfig();
OC_Util::addScript($this->appName, 'app');
OC_Util::addStyle($this->appName, 'app');
$params = $this->buildParams();
$response = new TemplateResponse($this->appName, 'Index', $params);

View File

@@ -10,10 +10,13 @@ use OCA\NCDownloader\Tools\Helper;
class SearchController extends Controller
{
private $userId;
private $uid;
private $settings = null;
//@config OC\AppConfig
private $l10n;
private $urlGenerator;
private $search;
public function __construct($appName, IRequest $request, $UserId)
{

View File

@@ -15,13 +15,15 @@ class SettingsController extends Controller
//@config OC\AppConfig
private $config;
public function __construct($AppName, IRequest $Request, $UserId) //, IL10N $L10N)
private $uid;
private $settings;
public function __construct($AppName, IRequest $Request, $uid) //, IL10N $L10N)
{
parent::__construct($AppName, $Request);
$this->UserId = $UserId;
$this->uid = $uid;
//$this->L10N = $L10N;
$this->settings = new Settings($UserId);
$this->settings = new Settings($uid);
//$this->config = \OC::$server->getAppConfig();
}
@@ -94,7 +96,7 @@ class SettingsController extends Controller
public function saveCustomAria2()
{
$noAria2Settings = (bool) Helper::getAdminSettings("disallow_aria2_settings");
if ($noAria2Settings && !\OC_User::isAdminUser($this->UserId)) {
if ($noAria2Settings && !\OC_User::isAdminUser($this->uid)) {
$resp = ["error" => "forbidden", "status" => false];
return new JSONResponse($resp);
}

View File

@@ -17,6 +17,15 @@ class YtdlController extends Controller
//@config OC\AppConfig
private $l10n;
private $audio_extensions = array("mp3", "m4a", "vorbis");
private $video_extensions = array("mp4", "webm", "mkv");
private $uid;
private $downloadDir;
private $dbconn;
private $ytdl;
private $aria2;
private $urlGenerator;
private $tablename;
private $dataDir;
public function __construct($appName, IRequest $request, $UserId, IL10N $IL10N, Aria2 $aria2, Ytdl $ytdl)
{

View File

@@ -7,6 +7,8 @@ class Helper
//@var OC\DB\ConnectionAdapter
private $conn;
private $table = "ncdownloader_info";
private $prefixedTable;
public $queryBuilder;
public function __construct()
{

View File

@@ -86,7 +86,7 @@ class Settings extends AllConfig
$this->allConfig->setAppValue($this->appName, $key, $value);
}
} catch (\Exception $e) {
return ['error' => $e->getMessage];
return ['error' => $e->getMessage()];
}
return ['message' => "Saved!"];

View File

@@ -7,6 +7,7 @@ use Symfony\Component\HttpClient\HttpClient;
final class Client
{
private $client;
public function __construct(?array $options = null)
{
$this->client = HttpClient::create($this->configure($options));

View File

@@ -8,6 +8,9 @@ abstract class searchBase
protected $tableTitles = [];
protected $rows = [];
protected $errors = [];
protected $searchUrl;
protected $crawler;
protected $client;
protected $actionLinks = [["name" => 'download', 'path' => '/index.php/apps/ncdownloader/new'], ['name' => 'clipboard']];
public function getTableTitles(): array

View File

@@ -29,8 +29,6 @@ class Admin implements ISettings
$this->connection = $connection;
$this->timeFactory = $timeFactory;
$this->config = $config;
$this->UserId = \OC::$server->getUserSession()->getUser()->getUID();
$this->settings = new Settings($this->UserId);
}
/**

View File

@@ -19,6 +19,8 @@ class Personal implements ISettings
private $timeFactory;
/** @var IConfig */
private $config;
private $uid;
private $settings;
public function __construct(
IDBConnection $connection,
@@ -28,8 +30,8 @@ class Personal implements ISettings
$this->connection = $connection;
$this->timeFactory = $timeFactory;
$this->config = $config;
$this->UserId = \OC::$server->getUserSession()->getUser()->getUID();
$this->settings = new Settings($this->UserId);
$this->uid = \OC::$server->getUserSession()->getUser()->getUID();
$this->settings = new Settings($this->uid);
}
/**
@@ -46,7 +48,7 @@ class Personal implements ISettings
'ncd_seed_time' => $this->settings->get("ncd_seed_time"),
"path" => '/apps/ncdownloader/personal/save',
"disallow_aria2_settings" => Helper::getAdminSettings("disallow_aria2_settings"),
"is_admin" => \OC_User::isAdminUser($this->UserId),
"is_admin" => \OC_User::isAdminUser($this->uid),
]
];

View File

@@ -8,6 +8,9 @@ use OCA\NCDownloader\Db\Helper as DbHelper;
class Counters
{
private $minmax = [0, 999];
private $aria2;
private $dbconn;
private $uid;
public function __construct(Aria2 $aria2, DbHelper $dbconn, $uid)
{

View File

@@ -11,6 +11,8 @@ class folderScan
private $user;
private $path;
private $realDir;
private $logger;
private $scanner;
public function __construct($path = null, $user = null)
{
$this->user = $user ?? Helper::getUID();

View File

@@ -8,6 +8,13 @@ class Helper
{
public $file = null;
protected $pid = 0;
protected $dbconn;
protected $tablename;
protected $user;
protected $tools;
protected $gid;
protected $ytdl;
protected $status;
public function __construct()
{
$this->dbconn = new DbHelper();

View File

@@ -20,6 +20,8 @@ class Ytdl
private $defaultDir = "/tmp/downloads";
private $env = [];
private $bin;
private $cmd;
public $helper;
public function __construct(array $options)
{