|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* ownCloud - Calendar App |
|
4
|
|
|
* |
|
5
|
|
|
* @author Georg Ehrke |
|
6
|
|
|
* @copyright 2016 Georg Ehrke <[email protected]> |
|
7
|
|
|
* @author Raghu Nayyar |
|
8
|
|
|
* @copyright 2016 Raghu Nayyar <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
* This library is free software; you can redistribute it and/or |
|
11
|
|
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
12
|
|
|
* License as published by the Free Software Foundation; either |
|
13
|
|
|
* version 3 of the License, or any later version. |
|
14
|
|
|
* |
|
15
|
|
|
* This library is distributed in the hope that it will be useful, |
|
16
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18
|
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
|
19
|
|
|
* |
|
20
|
|
|
* You should have received a copy of the GNU Affero General Public |
|
21
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
|
22
|
|
|
* |
|
23
|
|
|
*/ |
|
24
|
|
|
namespace OCA\Calendar\Controller; |
|
25
|
|
|
|
|
26
|
|
|
use OC\AppFramework\Http; |
|
27
|
|
|
use OCP\AppFramework\Controller; |
|
28
|
|
|
use OCP\AppFramework\Http\DataDisplayResponse; |
|
29
|
|
|
use OCP\AppFramework\Http\NotFoundResponse; |
|
30
|
|
|
use OCP\AppFramework\Http\TemplateResponse; |
|
31
|
|
|
use OCP\AppFramework\Http\ContentSecurityPolicy; |
|
32
|
|
|
use OCP\IConfig; |
|
33
|
|
|
use OCP\IRequest; |
|
34
|
|
|
use OCP\IUserSession; |
|
35
|
|
|
|
|
36
|
|
|
class PublicController extends Controller { |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @var IConfig |
|
40
|
|
|
*/ |
|
41
|
|
|
private $config; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @var IUserSession |
|
45
|
|
|
*/ |
|
46
|
|
|
private $userSession; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @param string $appName |
|
50
|
|
|
* @param IRequest $request an instance of the request |
|
51
|
|
|
* @param IConfig $config |
|
52
|
|
|
* @param IUserSession $userSession |
|
53
|
|
|
*/ |
|
54
|
|
|
public function __construct($appName, IRequest $request, |
|
55
|
|
|
IUserSession $userSession, IConfig $config) { |
|
56
|
|
|
parent::__construct($appName, $request); |
|
57
|
|
|
$this->config = $config; |
|
58
|
|
|
$this->userSession = $userSession; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @PublicPage |
|
63
|
|
|
* @NoCSRFRequired |
|
64
|
|
|
* |
|
65
|
|
|
* @return TemplateResponse |
|
66
|
|
|
*/ |
|
67
|
|
|
public function index($calendar) { |
|
68
|
|
|
|
|
69
|
|
|
$runningOn = $this->config->getSystemValue('version'); |
|
70
|
|
|
|
|
71
|
|
|
$isAssetPipelineEnabled = $this->config->getSystemValue('asset-pipeline.enabled', false); |
|
72
|
|
|
if ($isAssetPipelineEnabled) { |
|
73
|
|
|
return new TemplateResponse('calendar', 'main-asset-pipeline-unsupported'); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
$appVersion = $this->config->getAppValue($this->appName, 'installed_version'); |
|
77
|
|
|
$defaultView = $this->config->getUserValue(1, $this->appName, 'currentView', 'month'); |
|
78
|
|
|
|
|
79
|
|
|
$supportsClass = version_compare($runningOn, '9.1', '>='); |
|
80
|
|
|
|
|
81
|
|
|
$response = new TemplateResponse('calendar', 'public', [ |
|
82
|
|
|
'appVersion' => $appVersion, |
|
83
|
|
|
'defaultView' => $defaultView, |
|
84
|
|
|
'emailAddress' => '', |
|
85
|
|
|
'supportsClass' => $supportsClass |
|
86
|
|
|
]); |
|
87
|
|
|
$response->addHeader('X-Frame-Options', 'ALLOW'); |
|
88
|
|
|
$csp = new ContentSecurityPolicy(); |
|
89
|
|
|
$csp->addAllowedScriptDomain('*'); |
|
90
|
|
|
$response->setContentSecurityPolicy($csp); |
|
91
|
|
|
|
|
92
|
|
|
return $response; |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|