-
Notifications
You must be signed in to change notification settings - Fork 71
/
app_menu.php
82 lines (69 loc) · 2.26 KB
/
app_menu.php
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
<?php
global $mysqli,$session,$user,$settings;
if ($session["read"] || $session["public_userid"]) {
if (!isset($settings['app'])) {
$settings['app'] = array();
}
require_once "Modules/app/app_model.php";
$appconfig = new AppConfig($mysqli, $settings['app']);
// enable apikey read access
$userid = false;
if ($session['read']) {
$userid = $session['userid'];
$apikey = $user->get_apikey_read($session['userid']);
} else if ($session["public_userid"]) {
$userid = $session["public_userid"];
$apikey = "";
}
//} else if (isset($_GET['readkey'])) {
// $apikey = $_GET['readkey'];
// $userid = $user->get_id_from_apikey($apikey);
$l2 = array();
if ($userid)
{
$apikey_str = "";
if ($apikey) $apikey_str = '&readkey='.$apikey;
$applist = $appconfig->get_list($userid);
$_i = 0;
foreach ($applist as $appitem) {
$item = array(
"name"=>$appitem->name,
"href"=>"app/view?name=".urlencode($appitem->name).$apikey_str,
"icon"=>"star_border",
"order"=>$_i
);
if ($session['public_userid']) {
$item['href'] = $session['public_username']."/".$item["href"];
// Only show app if public
if (isset($appitem->public) && $appitem->public) {
$l2["$_i"] = $item;
$_i++;
}
} else {
$l2["$_i"] = $item;
$_i++;
}
}
}
if ($session["write"]) {
if (!$appconfig->app_table_exists) {
$l2['notice'] = array(
"name"=>_('Please update database'),
"href"=>"admin/db",
"icon"=>"",
"order"=>$_i
);
} else {
$l2['new'] = array(
"name"=>_('New'),
"href"=>"app/new",
"icon"=>"plus",
"order"=>$_i
);
}
}
// Level 1 top bar
if (count($l2)) {
$menu["app"] = array("name"=>"Apps", "order"=>2, "icon"=>"apps", "default"=>"app/view", "l2"=>$l2);
}
}