An attempt to obtain a functional version with the various fixes implemented so far.
This commit is contained in:
@@ -11,9 +11,12 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class Aria2Command extends Base
|
||||
{
|
||||
// public function __construct()
|
||||
private $dbconn;
|
||||
public function __construct(\OCP\IDBConnection $connection)
|
||||
{
|
||||
// $this->dbconn = new DbHelper();
|
||||
|
||||
$this->dbconn = new DbHelper($connection);
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ use OCP\AppFramework\Http\JSONResponse;
|
||||
use OCP\Files\IRootFolder;
|
||||
use OCP\IL10N;
|
||||
use OCP\IRequest;
|
||||
use OC_Util;
|
||||
use \OC\Files\Filesystem;
|
||||
|
||||
class Aria2Controller extends Controller
|
||||
@@ -33,9 +34,9 @@ class Aria2Controller extends Controller
|
||||
$this->uid = $UserId;
|
||||
$this->l10n = $IL10N;
|
||||
$this->rootFolder = $rootFolder;
|
||||
$this->urlGenerator = \OC::$server->get(\OCP\IURLGenerator::class);
|
||||
$this->urlGenerator = \OC::$server->getURLGenerator();
|
||||
$this->downloadDir = Helper::getDownloadDir();
|
||||
\OC_Util::setupFS();
|
||||
OC_Util::setupFS();
|
||||
//$this->config = \OC::$server->getAppConfig();
|
||||
$this->aria2 = $aria2;
|
||||
$this->aria2->init();
|
||||
|
||||
@@ -15,6 +15,7 @@ use OCP\AppFramework\Http\TemplateResponse;
|
||||
//use OCP\Files\IRootFolder;
|
||||
use OCP\IL10N;
|
||||
use OCP\IRequest;
|
||||
use OC_Util;
|
||||
use OCP\Util;
|
||||
|
||||
class MainController extends Controller
|
||||
@@ -46,7 +47,7 @@ class MainController extends Controller
|
||||
//$this->rootFolder = $rootFolder;
|
||||
$this->aria2 = $aria2;
|
||||
$this->aria2->init();
|
||||
$this->urlGenerator = \OC::$server->get(\OCP\IURLGenerator::class);
|
||||
$this->urlGenerator = \OC::$server->getURLGenerator();
|
||||
$this->dbconn = new DbHelper();
|
||||
$this->counters = new Counters($aria2, $this->dbconn, $UserId);
|
||||
$this->ytdl = $ytdl;
|
||||
@@ -63,8 +64,8 @@ class MainController extends Controller
|
||||
{
|
||||
// $str = \OC::$server->getDatabaseConnection()->getInner()->getPrefix();
|
||||
//$config = \OC::$server->getAppConfig();
|
||||
Util::addScript($this->appName, 'app');
|
||||
Util::addStyle($this->appName, 'app');
|
||||
Util::addInitScript($this->appName, 'app');
|
||||
OC_Util::addStyle($this->appName, 'app');
|
||||
|
||||
$params = $this->buildParams();
|
||||
$response = new TemplateResponse($this->appName, 'Index', $params);
|
||||
|
||||
@@ -23,7 +23,7 @@ class SearchController extends Controller
|
||||
parent::__construct($appName, $request);
|
||||
$this->appName = $appName;
|
||||
$this->uid = $UserId;
|
||||
$this->urlGenerator = \OC::$server->get(\OCP\IURLGenerator::class);
|
||||
$this->urlGenerator = \OC::$server->getURLGenerator();
|
||||
$this->search = new siteSearch();
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -32,7 +32,7 @@ class YtdlController extends Controller
|
||||
parent::__construct($appName, $request);
|
||||
$this->appName = $appName;
|
||||
$this->uid = $UserId;
|
||||
$this->urlGenerator = \OC::$server->get(\OCP\IURLGenerator::class);
|
||||
$this->urlGenerator = \OC::$server->getURLGenerator();
|
||||
$this->l10n = $IL10N;
|
||||
$this->downloadDir = Helper::getDownloadDir();
|
||||
$this->dbconn = new DbHelper();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class siteSearch
|
||||
private $defaultSite = __NAMESPACE__ . '\Sites\TPB';
|
||||
public function __construct()
|
||||
{
|
||||
$this->container = \OC::$server->get(IServerContainer::class);
|
||||
$this->container = \OC::$server->query(IServerContainer::class);
|
||||
$this->site = __NAMESPACE__ . '\Sites\TPB';
|
||||
}
|
||||
public function go($keyword): array
|
||||
|
||||
@@ -10,8 +10,6 @@ use OCP\Settings\ISettings;
|
||||
use OCA\NCDownloader\Db\Settings;
|
||||
use OCA\NCDownloader\Tools\Helper;
|
||||
|
||||
use OCP\IUserManager;
|
||||
|
||||
class Personal implements ISettings
|
||||
{
|
||||
|
||||
@@ -21,22 +19,18 @@ 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,
|
||||
IUserManager $userManager
|
||||
IConfig $config
|
||||
) {
|
||||
$this->connection = $connection;
|
||||
$this->timeFactory = $timeFactory;
|
||||
$this->config = $config;
|
||||
$this->userManager = $userManager;
|
||||
$this->uid = \OC::$server->get(\OCP\IUserSession::class)->getUser()->getUID();
|
||||
$this->uid = \OC::$server->getUserSession()->getUser()->getUID();
|
||||
$this->settings = new Settings($this->uid);
|
||||
}
|
||||
|
||||
@@ -46,10 +40,7 @@ class Personal implements ISettings
|
||||
public function getForm()
|
||||
{
|
||||
$path = '/apps/ncdownloader/personal/save';
|
||||
$user = $this->userManager->get($this->uid);
|
||||
$groupManager = \OC::$server->get(\OCP\IGroupManager::class);
|
||||
$isAdmin = ($user !== null) ? $groupManager->isInGroup($user->getUID(), 'admin') : false;
|
||||
$parameters = [
|
||||
$parameters = [
|
||||
"settings" => [
|
||||
"ncd_downloader_dir" => Helper::getDownloadDir(),
|
||||
"ncd_torrents_dir" => $this->settings->get("ncd_torrents_dir"),
|
||||
@@ -58,7 +49,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" => $isAdmin,
|
||||
"is_admin" => \OC_User::isAdminUser($this->uid),
|
||||
],
|
||||
"options" => [
|
||||
[
|
||||
|
||||
@@ -8,6 +8,7 @@ use OCA\NCDownloader\Aria2\Options as aria2Options;
|
||||
use OCA\NCDownloader\Db\Settings;
|
||||
use OCP\IUser;
|
||||
use OC\Files\Filesystem;
|
||||
use OC_Util;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use OCA\NCDownloader\Aria2\Aria2;
|
||||
use OCA\NCDownloader\Ytdl\Ytdl;
|
||||
@@ -147,6 +148,8 @@ class Helper
|
||||
if (is_array($msg)) {
|
||||
$msg = implode(",", $msg);
|
||||
}
|
||||
$logger = \OC::$server->get(LoggerInterface::class);
|
||||
// $logger = \OC::$server->getLogger();
|
||||
$logger = self::getLogger();
|
||||
$logger->error($msg, ['app' => 'ncdownloader']);
|
||||
}
|
||||
@@ -159,19 +162,7 @@ class Helper
|
||||
{
|
||||
if (!isset($filter)) {
|
||||
$filter = array(
|
||||
'status',
|
||||
'followedBy',
|
||||
'totalLength',
|
||||
'errorMessage',
|
||||
'dir',
|
||||
'uploadLength',
|
||||
'completedLength',
|
||||
'downloadSpeed',
|
||||
'files',
|
||||
'numSeeders',
|
||||
'connections',
|
||||
'gid',
|
||||
'following',
|
||||
'status', 'followedBy', 'totalLength', 'errorMessage', 'dir', 'uploadLength', 'completedLength', 'downloadSpeed', 'files', 'numSeeders', 'connections', 'gid', 'following',
|
||||
);
|
||||
}
|
||||
$value = array_filter($data, function ($k) use ($filter) {
|
||||
@@ -236,7 +227,8 @@ class Helper
|
||||
if ($memcache->hasKey($program)) {
|
||||
return $memcache->get($program);
|
||||
}
|
||||
$dataPath = \OC::$server->get(\OCP\IConfig::class)->getSystemValue('datadirectory');
|
||||
|
||||
$dataPath = \OC::$server->getSystemConfig()->getValue('datadirectory');
|
||||
$paths = ['/usr/local/sbin', '/usr/local/bin', '/usr/sbin', '/usr/bin', '/sbin', '/bin', '/opt/bin', $dataPath . "/bin"];
|
||||
$result = $default;
|
||||
$exeSniffer = new ExecutableFinder();
|
||||
@@ -403,13 +395,13 @@ class Helper
|
||||
|
||||
public static function getDataDir(): string
|
||||
{
|
||||
return \OC::$server->get(\OCP\IConfig::class)->getSystemValue('datadirectory');
|
||||
return \OC::$server->getSystemConfig()->getValue('datadirectory');
|
||||
}
|
||||
|
||||
public static function getLocalFolder(string $path): string
|
||||
{
|
||||
if (self::getUID()) {
|
||||
\OC_Util::setupFS();
|
||||
OC_Util::setupFS();
|
||||
//get the real path of the file in the filesystem
|
||||
return \OC\Files\Filesystem::getLocalFile($path);
|
||||
}
|
||||
@@ -429,6 +421,7 @@ class Helper
|
||||
|
||||
public static function getUser(): ?IUser
|
||||
{
|
||||
// return \OC::$server->getUserSession()->getUser();
|
||||
return \OC::$server->get(\OCP\IUserSession::class)->getUser();
|
||||
}
|
||||
|
||||
@@ -498,7 +491,7 @@ class Helper
|
||||
|
||||
public static function getAppPath(): string
|
||||
{
|
||||
return \OC::$server->get(\OCP\App\IAppManager::class)->getAppPath('ncdownloader');
|
||||
return \OC::$server->getAppManager()->getAppPath('ncdownloader');
|
||||
}
|
||||
public static function folderUpdated(string $dir): bool
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@ class Helper
|
||||
{
|
||||
$this->dbconn = new DbHelper();
|
||||
$this->tablename = $this->dbconn->queryBuilder->getTableName("ncdownloader_info");
|
||||
$this->user = \OC::$server->get(\OCP\IUserSession::class)->getUser()->getUID();
|
||||
$this->user = \OC::$server->getUserSession()->getUser()->getUID();
|
||||
}
|
||||
|
||||
public static function create()
|
||||
|
||||
Reference in New Issue
Block a user