blob: 52950833d2b629ebf70d1248d3522baa1e0cc041 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
<?php
/**
* @copyright Copyright (c) 2016 Julius Härtl <jus@bitgrid.net>
*
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\AppOrder;
use OCA\AppOrder\Service\ConfigService;
class Util {
private $userId;
private $appConfig;
public function __construct(ConfigService $appConfig, $userId) {
$this->userId = $userId;
$this->appConfig = $appConfig;
}
public function getAppOrder() {
$order_user = $this->appConfig->getUserValue('order', $this->userId);
$order_default = $this->appConfig->getAppValue('order');
$forced_order = json_decode($this->appConfig->getAppValue('force')) ?? false;
if ($order_user !== null && $order_user !== "" && !($forced_order)) {
$order = $order_user;
} else {
$order = $order_default;
}
return $order;
}
public function matchOrder($nav, $order) {
$nav_tmp = array();
$result = array();
foreach ($nav as $app) {
$nav_tmp[$app['href']] = $app;
}
if(is_array($order)) {
foreach ($order as $app) {
if (array_key_exists($app, $nav_tmp)) {
$result[$app] = $nav_tmp[$app];
}
}
}
foreach ($nav as $app) {
if (!array_key_exists($app['href'], $result)) {
$result[$app['href']] = $app;
}
}
return $result;
}
public function getAppHidden() {
$hidden_user = $this->appConfig->getUserValue('hidden', $this->userId);
$hidden_default = $this->appConfig->getAppValue('hidden');
$forced_order = json_decode($this->appConfig->getAppValue('force')) ?? false;
if ($hidden_user !== null && $hidden_user !== "" && !($forced_order)) {
$hidden = $hidden_user;
} else {
$hidden = $hidden_default;
}
return $hidden;
}
}
|