diff options
author | Raimund Schlüßler <raimund.schluessler@mailbox.org> | 2019-01-26 22:21:23 +0300 |
---|---|---|
committer | Raimund Schlüßler <raimund.schluessler@mailbox.org> | 2019-01-26 22:21:23 +0300 |
commit | 8689319840c7f486bf5a2a92bb17b9b64d5de9a6 (patch) | |
tree | 0e11fbc39fba2c9a23c0661c6a252a0c79f31795 /lib | |
parent | 8e98e3fb0e5d101213692af298ca947d40264dc1 (diff) |
Fix creating new tasks
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Controller/PageController.php | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 241d690f..cf5de5e0 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -26,6 +26,7 @@ use \OCP\AppFramework\Controller; use \OCP\AppFramework\Http\TemplateResponse; use \OCP\AppFramework\Http\NotFoundResponse; use \OCP\IRequest; +use \OCP\IUserSession; use \OCP\IConfig; /** @@ -35,12 +36,14 @@ class PageController extends Controller { /** * @param string $appName + * @param IUserSession $userSession * @param IConfig $config */ - public function __construct($appName, IRequest $request, + public function __construct($appName, IRequest $request, IUserSession $userSession, $userId, IConfig $config) { parent::__construct($appName, $request); $this->config = $config; + $this->userSession = $userSession; $this->userId = $userId; } @@ -50,18 +53,8 @@ class PageController extends Controller { * @NoCSRFRequired */ public function index() { - - $day = new \DateTime('today'); - $day = $day->format('d'); - - $appVersion = $this->config->getAppValue($this->appName, 'installed_version'); - $response = new TemplateResponse('tasks', 'main'); - $response->setParams(array( - 'appVersion' => $appVersion, - 'DOM' => $day - )); - - return $response; + \OCP\Util::connectHook('\OCP\Config', 'js', $this, 'addJavaScriptVariablesForIndex'); + return new TemplateResponse('tasks', 'main'); } @@ -78,4 +71,20 @@ class PageController extends Controller { } return $response; } + + /** + * Add parameters to javascript for user sites + * + * @param array $array + */ + public function addJavaScriptVariablesForIndex(array $array) { + $user = $this->userSession->getUser(); + if ($user === null) { + return; + } + $appversion = $this->config->getAppValue($this->appName, 'installed_version'); + $array['array']['oca_tasks'] = \json_encode([ + 'versionstring' => $appversion, + ]); + } } |