1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @copyright Copyright (c) 2016 Julius Härtl <[email protected]> |
4
|
|
|
* |
5
|
|
|
* @author Julius Härtl <[email protected]> |
6
|
|
|
* |
7
|
|
|
* @license GNU AGPL version 3 or any later version |
8
|
|
|
* |
9
|
|
|
* This program is free software: you can redistribute it and/or modify |
10
|
|
|
* it under the terms of the GNU Affero General Public License as |
11
|
|
|
* published by the Free Software Foundation, either version 3 of the |
12
|
|
|
* License, or (at your option) any later version. |
13
|
|
|
* |
14
|
|
|
* This program is distributed in the hope that it will be useful, |
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17
|
|
|
* GNU Affero General Public License for more details. |
18
|
|
|
* |
19
|
|
|
* You should have received a copy of the GNU Affero General Public License |
20
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
21
|
|
|
* |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
namespace OCA\AppOrder\Controller; |
25
|
|
|
|
26
|
|
|
use \OCP\AppFramework\Controller; |
27
|
|
|
use OCP\AppFramework\Http\RedirectResponse; |
28
|
|
|
use \OCP\IRequest; |
29
|
|
|
use \OCA\AppOrder\Service\ConfigService; |
30
|
|
|
use OCA\AppOrder\Util; |
31
|
|
|
use OCP\IURLGenerator; |
32
|
|
|
|
33
|
|
|
class AppController extends Controller { |
34
|
|
|
|
35
|
|
|
private $userId; |
36
|
|
|
private $urlGenerator; |
37
|
|
|
private $util; |
38
|
|
|
|
39
|
3 |
|
public function __construct($appName, |
40
|
|
|
IRequest $request, |
41
|
|
|
IURLGenerator $urlGenerator, |
42
|
|
|
Util $util, $userId) { |
43
|
3 |
|
parent::__construct($appName, $request); |
44
|
3 |
|
$this->userId = $userId; |
45
|
3 |
|
$this->urlGenerator = $urlGenerator; |
46
|
3 |
|
$this->util = $util; |
47
|
3 |
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @NoCSRFRequired |
51
|
|
|
* @NoAdminRequired |
52
|
|
|
* @return RedirectResponse |
53
|
|
|
*/ |
54
|
3 |
|
public function index() { |
55
|
3 |
|
$order = json_decode($this->util->getAppOrder()); |
56
|
3 |
|
$hidden = json_decode($this->util->getAppHidden()); |
57
|
|
|
|
58
|
3 |
|
$firstPage = null; |
59
|
|
|
|
60
|
3 |
|
if ($order !== null && sizeof($order) > 0) { |
61
|
2 |
|
if($hidden !== null && sizeof($hidden) > 0){ |
62
|
1 |
|
foreach($order as $app){ |
63
|
1 |
|
if(!in_array($app,$hidden)){ |
64
|
1 |
|
$firstPage = $app; |
65
|
1 |
|
break; |
66
|
|
|
} |
67
|
1 |
|
} |
68
|
1 |
|
} |
69
|
|
|
else{ |
70
|
1 |
|
$firstPage = $order[0]; |
71
|
|
|
} |
72
|
2 |
|
} |
73
|
3 |
|
if($firstPage===null) { |
74
|
|
|
|
75
|
1 |
|
$appId = 'files'; |
76
|
|
|
|
77
|
1 |
|
if (getenv('front_controller_active') === 'true') { |
78
|
|
|
$firstPage = $this->urlGenerator->getAbsoluteURL('/apps/' . $appId . '/'); |
79
|
|
|
} else { |
80
|
1 |
|
$firstPage = $this->urlGenerator->getAbsoluteURL('/index.php/apps/' . $appId . '/'); |
|
|
|
|
81
|
|
|
} |
82
|
1 |
|
} |
83
|
3 |
|
return new RedirectResponse($firstPage); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
} |
87
|
|
|
|
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.