Completed
Push — public-sharing ( 074741...f74216 )
by Thomas
19:39
created

PublicController::index()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 20
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 2
eloc 12
c 3
b 0
f 0
nc 2
nop 1
dl 0
loc 20
rs 9.4285
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\IConfig;
32
use OCP\IRequest;
33
use OCP\IUserSession;
34
35
class PublicController extends Controller {
36
37
	/**
38
	 * @var IConfig
39
	 */
40
	private $config;
41
42
	/**
43
	 * @var IUserSession
44
	 */
45
	private $userSession;
46
47
	/**
48
	 * @param string $appName
49
	 * @param IRequest $request an instance of the request
50
	 * @param IConfig $config
51
	 * @param IUserSession $userSession
52
	 */
53
	public function __construct($appName, IRequest $request,
54
								IUserSession $userSession, IConfig $config) {
55
		parent::__construct($appName, $request);
56
		$this->config = $config;
57
		$this->userSession = $userSession;
58
	}
59
60
	/**
61
	 * @PublicPage
62
	 * @NoCSRFRequired
63
	 *
64
	 * @return TemplateResponse
65
	 */
66
	public function index($calendar) {
67
		
68
		$runningOn = $this->config->getSystemValue('version');
69
70
		$isAssetPipelineEnabled = $this->config->getSystemValue('asset-pipeline.enabled', false);
71
		if ($isAssetPipelineEnabled) {
72
			return new TemplateResponse('calendar', 'main-asset-pipeline-unsupported');
73
		}
74
75
		$appVersion = $this->config->getAppValue($this->appName, 'installed_version');
76
		$defaultView = $this->config->getUserValue(1, $this->appName, 'currentView', 'month');
77
78
		$supportsClass = version_compare($runningOn, '9.1', '>=');
79
80
		return new TemplateResponse('calendar', 'public', [
81
			'appVersion' => $appVersion,
82
			'defaultView' => $defaultView,
83
			'supportsClass' => $supportsClass
84
		]);
85
	}
86
}
87