|
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 \OCP\INavigationManager; |
|
30
|
|
|
use \OCA\AppOrder\Service\ConfigService; |
|
31
|
|
|
use OCA\AppOrder\Util; |
|
32
|
|
|
use OCP\IURLGenerator; |
|
33
|
|
|
|
|
34
|
|
|
class AppController extends Controller { |
|
35
|
|
|
|
|
36
|
|
|
private $userId; |
|
37
|
|
|
private $appConfig; |
|
38
|
|
|
private $urlGenerator; |
|
39
|
|
|
private $util; |
|
40
|
|
|
|
|
41
|
|
|
public function __construct($appName, IRequest $request, ConfigService $appConfig, IURLGenerator $urlGenerator, Util $util, $userId) { |
|
|
|
|
|
|
42
|
|
|
parent::__construct($appName, $request); |
|
43
|
|
|
$this->userId = $userId; |
|
44
|
|
|
$this->appConfig = $appConfig; |
|
45
|
|
|
$this->urlGenerator = $urlGenerator; |
|
46
|
|
|
$this->util = $util; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @NoCSRFRequired |
|
51
|
|
|
* @return RedirectResponse |
|
52
|
|
|
*/ |
|
53
|
|
|
public function index() { |
|
54
|
|
|
$order = json_decode($this->util->getAppOrder()); |
|
55
|
|
|
if($order !== null && sizeof($order)>0) { |
|
56
|
|
|
$firstPage = $order[0]; |
|
57
|
|
|
} else { |
|
58
|
|
|
$appId = 'files'; |
|
59
|
|
|
if(getenv('front_controller_active') === 'true') { |
|
60
|
|
|
$firstPage = $this->urlGenerator->getAbsoluteURL('/apps/' . $appId . '/'); |
|
61
|
|
|
} else { |
|
62
|
|
|
$firstPage = $this->urlGenerator->getAbsoluteURL('/index.php/apps/' . $appId . '/'); |
|
|
|
|
|
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
return new RedirectResponse($firstPage); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
} |
|
69
|
|
|
|
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.