1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Nextcloud - Tasks |
4
|
|
|
* |
5
|
|
|
* @author Raimund Schlüßler |
6
|
|
|
* @copyright 2019 Raimund Schlüßler <[email protected]> |
7
|
|
|
* |
8
|
|
|
* This library is free software; you can redistribute it and/or |
9
|
|
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
10
|
|
|
* License as published by the Free Software Foundation; either |
11
|
|
|
* version 3 of the License, or any later version. |
12
|
|
|
* |
13
|
|
|
* This library is distributed in the hope that it will be useful, |
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
17
|
|
|
* |
18
|
|
|
* You should have received a copy of the GNU Affero General Public |
19
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
20
|
|
|
* |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
namespace OCA\Tasks\Controller; |
24
|
|
|
|
25
|
|
|
use \OCP\AppFramework\Controller; |
26
|
|
|
use \OCP\AppFramework\Http\TemplateResponse; |
27
|
|
|
use \OCP\IRequest; |
28
|
|
|
use \OCP\IUserSession; |
29
|
|
|
use \OCP\IConfig; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Controller class for main page. |
33
|
|
|
*/ |
34
|
|
|
class PageController extends Controller { |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var IUserSession |
38
|
|
|
*/ |
39
|
|
|
private $userSession; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var IConfig |
43
|
|
|
*/ |
44
|
|
|
private $config; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @param string $appName |
48
|
|
|
* @param IRequest $request an instance of the request |
49
|
|
|
* @param IUserSession $userSession |
50
|
|
|
* @param IConfig $config |
51
|
|
|
*/ |
52
|
|
|
public function __construct(string $appName, IRequest $request, IUserSession $userSession, IConfig $config) { |
53
|
|
|
parent::__construct($appName, $request); |
54
|
|
|
$this->userSession = $userSession; |
55
|
|
|
$this->config = $config; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @NoAdminRequired |
61
|
|
|
* @NoCSRFRequired |
62
|
|
|
* |
63
|
|
|
* @return TemplateResponse |
64
|
|
|
*/ |
65
|
|
|
public function index():TemplateResponse { |
66
|
|
|
\OCP\Util::connectHook('\OCP\Config', 'js', $this, 'addJavaScriptVariablesForIndex'); |
67
|
|
|
return new TemplateResponse('tasks', 'main'); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Add parameters to javascript for user sites |
72
|
|
|
* |
73
|
|
|
* @param array $array |
74
|
|
|
*/ |
75
|
|
|
public function addJavaScriptVariablesForIndex(array $array) { |
76
|
|
|
$user = $this->userSession->getUser(); |
77
|
|
|
if ($user === null) { |
78
|
|
|
return; |
79
|
|
|
} |
80
|
|
|
$appversion = $this->config->getAppValue($this->appName, 'installed_version'); |
81
|
|
|
$array['array']['oca_tasks'] = \json_encode([ |
82
|
|
|
'versionstring' => $appversion, |
83
|
|
|
]); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|