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
|
2 |
|
public function __construct($appName, |
40
|
|
|
IRequest $request, |
41
|
|
|
IURLGenerator $urlGenerator, |
42
|
|
|
Util $util, $userId) { |
43
|
2 |
|
parent::__construct($appName, $request); |
44
|
2 |
|
$this->userId = $userId; |
45
|
2 |
|
$this->urlGenerator = $urlGenerator; |
46
|
2 |
|
$this->util = $util; |
47
|
2 |
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @NoCSRFRequired |
51
|
|
|
* @NoAdminRequired |
52
|
|
|
* @return RedirectResponse |
53
|
|
|
*/ |
54
|
2 |
|
public function index() { |
55
|
2 |
|
$order = json_decode($this->util->getAppOrder()); |
56
|
2 |
|
if ($order !== null && sizeof($order) > 0) { |
57
|
1 |
|
$firstPage = $order[0]; |
58
|
1 |
|
} else { |
59
|
1 |
|
$appId = 'files'; |
60
|
1 |
|
if (getenv('front_controller_active') === 'true') { |
61
|
|
|
$firstPage = $this->urlGenerator->getAbsoluteURL('/apps/' . $appId . '/'); |
62
|
|
|
} else { |
63
|
1 |
|
$firstPage = $this->urlGenerator->getAbsoluteURL('/index.php/apps/' . $appId . '/'); |
|
|
|
|
64
|
|
|
} |
65
|
|
|
} |
66
|
2 |
|
return new RedirectResponse($firstPage); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
} |
70
|
|
|
|
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.