Completed
Push — public-sharing ( 2a5627...af1464 )
by Thomas
18:09
created

PublicController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 59
rs 10
wmc 3
lcom 1
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
B index() 0 27 2
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
		\OC_User::setIncognitoMode(true);
69
70
		$runningOn = $this->config->getSystemValue('version');
71
72
		$isAssetPipelineEnabled = $this->config->getSystemValue('asset-pipeline.enabled', false);
73
		if ($isAssetPipelineEnabled) {
74
			return new TemplateResponse('calendar', 'main-asset-pipeline-unsupported');
75
		}
76
77
		// $user = $this->userSession->getUser();
78
		// $userId = $user->getUID();
79
		// $emailAddress = $user->getEMailAddress();
80
81
		$appVersion = $this->config->getAppValue($this->appName, 'installed_version');
82
		$defaultView = $this->config->getUserValue(1, $this->appName, 'currentView', 'month');
83
84
		$supportsClass = version_compare($runningOn, '9.1', '>=');
85
86
		return new TemplateResponse('calendar', 'public', [
87
			'appVersion' => $appVersion,
88
			'defaultView' => $defaultView,
89
			'emailAddress' => '',
90
			'supportsClass' => $supportsClass
91
		]);
92
	}
93
}