Completed
Push — DAVclient ( 891165...d70979 )
by Raimund
03:00
created

PageController::index()   B

Complexity

Conditions 3
Paths 2

Size

Total Lines 36
Code Lines 30

Duplication

Lines 0
Ratio 0 %

Importance

Changes 6
Bugs 0 Features 1
Metric Value
c 6
b 0
f 1
dl 0
loc 36
rs 8.8571
cc 3
eloc 30
nc 2
nop 0
1
<?php
2
/**
3
 * ownCloud - Tasks
4
 *
5
 * @author Raimund Schlüßler
6
 * @copyright 2015 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
28
/**
29
 * Controller class for main page.
30
 */
31
class PageController extends Controller {
32
33
	/**
34
	 * @param string $appName
35
	 * @param IConfig $config
36
	 */
37
	public function __construct($appName, IRequest $request,
38
								$userId, IConfig $config) {
39
		parent::__construct($appName, $request);
40
		$this->config = $config;
41
		$this->userId = $userId;
42
		$this->userSession = $userSession;
0 ignored issues
show
Bug introduced by
The variable $userSession does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
43
	}
44
45
46
	/**
47
	 * @NoAdminRequired
48
	 * @NoCSRFRequired
49
	 */
50
	public function index() {
51
		if (defined('DEBUG') && DEBUG) {
52
			script('tasks', 'vendor/angular/angular');
53
			script('tasks', 'vendor/angular-route/angular-route');
54
			script('tasks', 'vendor/angular-animate/angular-animate');
55
			script('tasks', 'vendor/angular-sanitize/angular-sanitize');
56
			script('tasks', 'vendor/angular-draganddrop/angular-drag-and-drop-lists');
57
			script('tasks', 'vendor/angular-ui-select/dist/select');
58
			script('tasks', 'vendor/jstzdetect/jstz');
59
		} else {
60
			script('tasks', 'vendor/angular/angular.min');
61
			script('tasks', 'vendor/angular-route/angular-route.min');
62
			script('tasks', 'vendor/angular-animate/angular-animate.min');
63
			script('tasks', 'vendor/angular-sanitize/angular-sanitize.min');
64
			script('tasks', 'vendor/angular-draganddrop/angular-drag-and-drop-lists.min');
65
			script('tasks', 'vendor/angular-ui-select/dist/select.min');
66
			script('tasks', 'vendor/jstzdetect/jstz.min');
67
		}
68
		script('tasks', 'public/app');
69
		script('tasks', 'vendor/jquery-timepicker/jquery.ui.timepicker');
70
		script('tasks', 'vendor/davclient.js/lib/client');
71
		script('tasks', 'vendor/ical.js/build/ical');
72
		style('tasks', 'style');	
73
		style('tasks', 'vendor/angularui/ui-select/select2');
74
75
		$day = new \DateTime('today');
76
		$day = $day->format('d');
0 ignored issues
show
Unused Code introduced by
$day is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
77
78
		$appVersion = $this->config->getAppValue($this->appName, 'installed_version');
79
		$response = new TemplateResponse('tasks', 'main');
80
		$response->setParams(array(
81
			'appVersion' => $appVersion
82
		));
83
84
		return $response;
85
	}
86
}
87