aboutsummaryrefslogtreecommitdiffstats
path: root/include/menu.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/menu.php')
-rw-r--r--include/menu.php37
1 files changed, 23 insertions, 14 deletions
diff --git a/include/menu.php b/include/menu.php
index be9831951..105e4216b 100644
--- a/include/menu.php
+++ b/include/menu.php
@@ -26,11 +26,12 @@ function menu_fetch($name,$uid,$observer_xchan) {
function menu_render($menu) {
if(! $menu)
return '';
+
for($x = 0; $x < count($menu['items']); $x ++)
- if($menu['items']['mitem_flags'] & MENU_ITEM_ZID)
- $menu['items']['mitem_link'] = zid($menu['items']['mitem_link']);
- if($menu['items']['mitem_flags'] & MENU_ITEM_NEWWIN)
- $menu['items']['newwin'] = '1';
+ if($menu['items'][$x]['mitem_flags'] & MENU_ITEM_ZID)
+ $menu['items'][$x]['mitem_link'] = zid($menu['items'][$x]['mitem_link']);
+ if($menu['items'][$x]['mitem_flags'] & MENU_ITEM_NEWWIN)
+ $menu['items'][$x]['newwin'] = '1';
return replace_macros(get_markup_template('usermenu.tpl'),array(
'$menu' => $menu['menu'],
@@ -74,8 +75,7 @@ function menu_create($arr) {
$r = q("select * from menu where menu_name = '%s' and menu_channel_id = %d limit 1",
dbesc($menu_name),
- intval($menu_channel_id),
- intval($menu_flags)
+ intval($menu_channel_id)
);
if($r)
@@ -101,9 +101,17 @@ function menu_create($arr) {
}
-function menu_list($channel_id, $flags = 0) {
+/**
+ * If $flags is present, check that all the bits in $flags are set
+ * so that MENU_SYSTEM|MENU_BOOKMARK will return entries with both
+ * bits set. We will use this to find system generated bookmarks.
+ */
+
+function menu_list($channel_id, $name = '', $flags = 0) {
- $sel_options = (($flags) ? " and ( menu_flags & " . intval($flags) . " ) " : '');
+ $sel_options = '';
+ $sel_options .= (($name) ? " and menu_name = '" . protect_sprintf(dbesc($name)) . "' " : '');
+ $sel_options .= (($flags) ? " and menu_flags = " . intval($flags) . " " : '');
$r = q("select * from menu where menu_channel_id = %d $sel_options order by menu_name",
intval($channel_id)
@@ -204,7 +212,8 @@ function menu_add_item($menu_id, $uid, $arr) {
$channel = get_app()->get_channel();
}
- if ((! $arr['contact_allow'])
+ if (($channel)
+ && (! $arr['contact_allow'])
&& (! $arr['group_allow'])
&& (! $arr['contact_deny'])
&& (! $arr['group_deny'])) {
@@ -223,11 +232,11 @@ function menu_add_item($menu_id, $uid, $arr) {
$str_contact_deny = perms2str($arr['contact_deny']);
}
-
- $allow_cid = perms2str($arr['allow_cid']);
- $allow_gid = perms2str($arr['allow_gid']);
- $deny_cid = perms2str($arr['deny_cid']);
- $deny_gid = perms2str($arr['deny_gid']);
+// unused
+// $allow_cid = perms2str($arr['allow_cid']);
+// $allow_gid = perms2str($arr['allow_gid']);
+// $deny_cid = perms2str($arr['deny_cid']);
+// $deny_gid = perms2str($arr['deny_gid']);
$r = q("insert into menu_item ( mitem_link, mitem_desc, mitem_flags, allow_cid, allow_gid, deny_cid, deny_gid, mitem_channel_id, mitem_menu_id, mitem_order ) values ( '%s', '%s', %d, '%s', '%s', '%s', '%s', %d, %d, %d ) ",
dbesc($mitem_link),