Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/tasks.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--appinfo/app.php18
-rw-r--r--appinfo/application.php108
-rw-r--r--lib/AppInfo/Application.php58
-rw-r--r--lib/Controller/CollectionsController.php10
-rw-r--r--lib/Controller/PageController.php39
-rw-r--r--lib/Controller/SettingsController.php14
-rw-r--r--lib/Service/CollectionsService.php33
-rw-r--r--lib/Service/SettingsService.php27
8 files changed, 145 insertions, 162 deletions
diff --git a/appinfo/app.php b/appinfo/app.php
index c8cb7ef4..ab609f9c 100644
--- a/appinfo/app.php
+++ b/appinfo/app.php
@@ -20,19 +20,5 @@
*
*/
-namespace OCA\Tasks\AppInfo;
-
-\OC::$server->getNavigationManager()->add(function () {
- $urlGenerator = \OC::$server->getURLGenerator();
- return [
- 'id' => 'tasks',
-
- 'order' => 100,
-
- 'href' => $urlGenerator->linkToRoute('tasks.page.index'),
-
- 'icon' => $urlGenerator->imagePath('tasks', 'tasks.svg'),
-
- 'name' => \OC::$server->getL10N('tasks')->t('Tasks'),
- ];
-});
+$app = new \OCA\Tasks\AppInfo\Application();
+$app->registerNavigation();
diff --git a/appinfo/application.php b/appinfo/application.php
deleted file mode 100644
index b15e8042..00000000
--- a/appinfo/application.php
+++ /dev/null
@@ -1,108 +0,0 @@
-<?php
-/**
-* Nextcloud - Tasks
-*
-* @author Raimund Schlüßler
-* @copyright 2018 Raimund Schlüßler <raimund.schluessler@mailbox.org>
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
-* License as published by the Free Software Foundation; either
-* version 3 of the License, or any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
-*
-* You should have received a copy of the GNU Affero General Public
-* License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*
-*/
-
-namespace OCA\Tasks\AppInfo;
-
-use \OCP\AppFramework\App;
-use \OCP\AppFramework\IAppContainer;
-use \OCA\Tasks\Controller\PageController;
-use \OCA\Tasks\Controller\CollectionsController;
-use \OCA\Tasks\Controller\SettingsController;
-use \OCA\Tasks\Service\CollectionsService;
-use \OCA\Tasks\Service\SettingsService;
-
-class Application extends App {
-
-
- public function __construct (array $urlParams=array()) {
- parent::__construct('tasks', $urlParams);
-
- $container = $this->getContainer();
-
- /**
- * Controllers
- */
- $container->registerService('PageController', function(IAppContainer $c) {
- return new PageController(
- $c->query('AppName'),
- $c->query('Request'),
- $c->query('UserSession'),
- $c->query('UserId'),
- $c->query('ServerContainer')->getConfig()
- );
- });
-
- $container->registerService('CollectionsController', function(IAppContainer $c) {
- return new CollectionsController(
- $c->query('AppName'),
- $c->query('Request'),
- $c->query('CollectionsService')
- );
- });
-
- $container->registerService('SettingsController', function(IAppContainer $c) {
- return new SettingsController(
- $c->query('AppName'),
- $c->query('Request'),
- $c->query('SettingsService')
- );
- });
-
- /**
- * Services
- */
-
- $container->registerService('CollectionsService', function(IAppContainer $c) {
- return new CollectionsService(
- $c->query('UserId'),
- $c->query('L10N'),
- $c->query('Settings'),
- $c->query('AppName')
- );
- });
-
- $container->registerService('SettingsService', function(IAppContainer $c) {
- return new SettingsService(
- $c->query('UserId'),
- $c->query('Settings'),
- $c->query('AppName')
- );
- });
-
- /**
- * Core
- */
- $container->registerService('UserId', function(IAppContainer $c) {
- $user = $c->query('ServerContainer')->getUserSession()->getUser();
-
- return ($user) ? $user->getUID() : '';
- });
-
- $container->registerService('L10N', function(IAppContainer $c) {
- return $c->query('ServerContainer')->getL10N($c->query('AppName'));
- });
-
- $container->registerService('Settings', function(IAppContainer $c) {
- return $c->query('ServerContainer')->getConfig();
- });
- }
-}
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
new file mode 100644
index 00000000..03588a05
--- /dev/null
+++ b/lib/AppInfo/Application.php
@@ -0,0 +1,58 @@
+<?php
+/**
+ * Nextcloud - Tasks
+ *
+ * @author Raimund Schlüßler
+ * @copyright 2019 Raimund Schlüßler <raimund.schluessler@mailbox.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Tasks\AppInfo;
+
+use OCP\AppFramework\App;
+
+class Application extends App {
+
+ /**
+ * @param array $params
+ */
+ public function __construct(array $params=[]) {
+ parent::__construct('tasks', $params);
+ }
+
+ /**
+ * Register navigation
+ */
+ public function registerNavigation() {
+ $appName = $this->getContainer()->getAppName();
+ $server = $this->getContainer()->getServer();
+ $urlGenerator = $server->getURLGenerator();
+
+ $server->getNavigationManager()->add(function() use ($appName, $server, $urlGenerator) {
+ return [
+ 'id' => $appName,
+
+ 'order' => 100,
+
+ 'href' => $urlGenerator->linkToRoute('tasks.page.index'),
+
+ 'icon' => $urlGenerator->imagePath($appName, 'tasks.svg'),
+
+ 'name' => $server->getL10N($appName)->t('Tasks'),
+ ];
+ });
+ }
+}
diff --git a/lib/Controller/CollectionsController.php b/lib/Controller/CollectionsController.php
index 3eff4f51..98250d84 100644
--- a/lib/Controller/CollectionsController.php
+++ b/lib/Controller/CollectionsController.php
@@ -28,11 +28,19 @@ use \OCP\AppFramework\Controller;
class CollectionsController extends Controller {
+ /**
+ * @var CollectionsService
+ */
private $collectionsService;
use Response;
- public function __construct($appName, IRequest $request, CollectionsService $collectionsService){
+ /**
+ * @param string $appName
+ * @param IRequest $request an instance of the request
+ * @param CollectionsService $collectionsService
+ */
+ public function __construct(string $appName, IRequest $request, CollectionsService $collectionsService){
parent::__construct($appName, $request);
$this->collectionsService = $collectionsService;
}
diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php
index cf5de5e0..bb182be3 100644
--- a/lib/Controller/PageController.php
+++ b/lib/Controller/PageController.php
@@ -3,7 +3,7 @@
* Nextcloud - Tasks
*
* @author Raimund Schlüßler
- * @copyright 2018 Raimund Schlüßler <raimund.schluessler@mailbox.org>
+ * @copyright 2019 Raimund Schlüßler <raimund.schluessler@mailbox.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
@@ -24,7 +24,6 @@ namespace OCA\Tasks\Controller;
use \OCP\AppFramework\Controller;
use \OCP\AppFramework\Http\TemplateResponse;
-use \OCP\AppFramework\Http\NotFoundResponse;
use \OCP\IRequest;
use \OCP\IUserSession;
use \OCP\IConfig;
@@ -35,43 +34,39 @@ use \OCP\IConfig;
class PageController extends Controller {
/**
+ * @var IUserSession
+ */
+ private $userSession;
+
+ /**
+ * @var IConfig
+ */
+ private $config;
+
+ /**
* @param string $appName
+ * @param IRequest $request an instance of the request
* @param IUserSession $userSession
* @param IConfig $config
*/
- public function __construct($appName, IRequest $request, IUserSession $userSession,
- $userId, IConfig $config) {
+ public function __construct(string $appName, IRequest $request, IUserSession $userSession, IConfig $config) {
parent::__construct($appName, $request);
- $this->config = $config;
$this->userSession = $userSession;
- $this->userId = $userId;
+ $this->config = $config;
}
/**
* @NoAdminRequired
* @NoCSRFRequired
+ *
+ * @return TemplateResponse
*/
- public function index() {
+ public function index():TemplateResponse {
\OCP\Util::connectHook('\OCP\Config', 'js', $this, 'addJavaScriptVariablesForIndex');
return new TemplateResponse('tasks', 'main');
}
-
- /**
- * @NoAdminRequired
- * @NoCSRFRequired
- */
- public function templates($template) {
- $templates = array( 'confirmation');
- if (in_array($template, $templates)) {
- $response = new TemplateResponse('tasks', $template, [], 'blank');
- } else {
- $response = new NotFoundResponse();
- }
- return $response;
- }
-
/**
* Add parameters to javascript for user sites
*
diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php
index 7ff8a228..28934031 100644
--- a/lib/Controller/SettingsController.php
+++ b/lib/Controller/SettingsController.php
@@ -27,12 +27,20 @@ use \OCP\AppFramework\Controller;
use \OCP\IRequest;
class SettingsController extends Controller {
-
+
+ /**
+ * @var SettingsService
+ */
private $settingsService;
use Response;
- public function __construct($appName, IRequest $request, SettingsService $settingsService){
+ /**
+ * @param string $appName
+ * @param IRequest $request an instance of the request
+ * @param SettingsService $settingsService
+ */
+ public function __construct(string $appName, IRequest $request, SettingsService $settingsService){
parent::__construct($appName, $request);
$this->settingsService = $settingsService;
}
@@ -49,7 +57,7 @@ class SettingsController extends Controller {
/**
* @NoAdminRequired
*/
- public function set($setting, $value){
+ public function set($setting, $value) {
return $this->generateResponse(function () use ($setting, $value) {
return $this->settingsService->set($setting, $value);
});
diff --git a/lib/Service/CollectionsService.php b/lib/Service/CollectionsService.php
index 6f7ffa80..8a3c33ad 100644
--- a/lib/Service/CollectionsService.php
+++ b/lib/Service/CollectionsService.php
@@ -27,12 +27,33 @@ use OCP\IL10N;
class CollectionsService {
+ /**
+ * @var string
+ */
private $userId;
+
+ /**
+ * @var IL10N
+ */
private $l10n;
+
+ /**
+ * @var IConfig
+ */
private $settings;
+
+ /**
+ * @var string
+ */
private $appName;
- public function __construct($userId, IL10N $l10n, IConfig $settings, $appName) {
+ /**
+ * @param string $userId
+ * @param IL10N $l10n
+ * @param IConfig $settings
+ * @param string $appName
+ */
+ public function __construct(string $userId, IL10N $l10n, IConfig $settings, string $appName) {
$this->userId = $userId;
$this->l10n = $l10n;
$this->settings = $settings;
@@ -40,11 +61,11 @@ class CollectionsService {
}
/**
- * get all collections
+ * Get all collections
*
* @return array
*/
- public function getAll() {
+ public function getAll():array {
$collections = array(
array(
'id' => "starred",
@@ -89,13 +110,13 @@ class CollectionsService {
}
/**
- * set the visibility of a collection by collectionID
+ * Set the visibility of a collection by collectionID
*
- * @param int $collectionID
+ * @param string $collectionID
* @param int $visibility
* @return bool
*/
- public function setVisibility($collectionID, $visibility){
+ public function setVisibility(string $collectionID, int $visibility):bool {
if (in_array($visibility, array(0,1,2))){
$this->settings->setUserValue($this->userId, $this->appName,'show_'.$collectionID,$visibility);
}
diff --git a/lib/Service/SettingsService.php b/lib/Service/SettingsService.php
index cc27ce26..3201ca59 100644
--- a/lib/Service/SettingsService.php
+++ b/lib/Service/SettingsService.php
@@ -26,22 +26,38 @@ use OCP\IConfig;
class SettingsService {
+ /**
+ * @var string
+ */
private $userId;
+
+ /**
+ * @var IConfig
+ */
private $settings;
+
+ /**
+ * @var string
+ */
private $appName;
- public function __construct($userId, IConfig $settings, $appName) {
+ /**
+ * @param string $userId
+ * @param IConfig $settings
+ * @param string $appName
+ */
+ public function __construct(string $userId, IConfig $settings, string $appName) {
$this->userId = $userId;
$this->settings = $settings;
$this->appName = $appName;
}
/**
- * get the current settings
+ * Get the current settings
*
* @return array
*/
- public function get() {
+ public function get():array {
$settings = array(
'defaultCalendarId' => (string)$this->settings->getUserValue($this->userId, $this->appName,'various_defaultCalendarId'),
'showHidden' => (int)$this->settings->getUserValue($this->userId, $this->appName,'various_showHidden'),
@@ -53,14 +69,13 @@ class SettingsService {
}
/**
- * set setting of type to new value
+ * Set setting of type to new value
*
* @param $setting
- * @param $type
* @param $value
* @return bool
*/
- public function set($setting, $value) {
+ public function set($setting, $value):bool {
$this->settings->setUserValue($this->userId, $this->appName, 'various_'.$setting, $value);
return true;
}