aboutsummaryrefslogtreecommitdiffstats
path: root/include/menu.php
diff options
context:
space:
mode:
authorPaolo T <tuscanhobbit@users.noreply.github.com>2014-02-25 16:33:40 +0100
committerPaolo T <tuscanhobbit@users.noreply.github.com>2014-02-25 16:33:40 +0100
commit0a98f6b878ec89be7282621192d9daf80f125e6c (patch)
tree718a4771ce1fb86931531226898b0b5d00e4a337 /include/menu.php
parent34d30e4d7eb48bd801482531a0d775328bd43ab4 (diff)
parentb1021df485fb6129acda5bba616bac10aea75a45 (diff)
downloadvolse-hubzilla-0a98f6b878ec89be7282621192d9daf80f125e6c.tar.gz
volse-hubzilla-0a98f6b878ec89be7282621192d9daf80f125e6c.tar.bz2
volse-hubzilla-0a98f6b878ec89be7282621192d9daf80f125e6c.zip
Merge pull request #1 from friendica/master
Update this fork
Diffstat (limited to 'include/menu.php')
-rw-r--r--include/menu.php74
1 files changed, 45 insertions, 29 deletions
diff --git a/include/menu.php b/include/menu.php
index c10a669b3..2f1719d0b 100644
--- a/include/menu.php
+++ b/include/menu.php
@@ -1,6 +1,7 @@
<?php /** @file */
require_once('include/security.php');
+require_once('include/bbcode.php');
function menu_fetch($name,$uid,$observer_xchan) {
@@ -23,18 +24,21 @@ function menu_fetch($name,$uid,$observer_xchan) {
return null;
}
-
-function menu_render($menu) {
+function menu_render($menu, $edit = false) {
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';
+
+ for($x = 0; $x < count($menu['items']); $x ++) {
+ 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';
+ $menu['items'][$x]['mitem_desc'] = bbcode($menu['items'][$x]['mitem_desc']);
+ }
return replace_macros(get_markup_template('usermenu.tpl'),array(
'$menu' => $menu['menu'],
+ '$edit' => (($edit) ? t("Edit") : ''),
'$items' => $menu['items']
));
}
@@ -58,6 +62,8 @@ function menu_create($arr) {
$menu_name = trim(escape_tags($arr['menu_name']));
$menu_desc = trim(escape_tags($arr['menu_desc']));
+ $menu_flags = intval($arr['menu_flags']);
+
if(! $menu_desc)
$menu_desc = $menu_name;
@@ -65,6 +71,9 @@ function menu_create($arr) {
if(! $menu_name)
return false;
+ if(! $menu_flags)
+ $menu_flags = 0;
+
$menu_channel_id = intval($arr['menu_channel_id']);
@@ -76,10 +85,11 @@ function menu_create($arr) {
if($r)
return false;
- $r = q("insert into menu ( menu_name, menu_desc, menu_channel_id )
- values( '%s', '%s', %d )",
+ $r = q("insert into menu ( menu_name, menu_desc, menu_flags, menu_channel_id )
+ values( '%s', '%s', %d, %d )",
dbesc($menu_name),
dbesc($menu_desc),
+ intval($menu_flags),
intval($menu_channel_id)
);
if(! $r)
@@ -95,8 +105,19 @@ function menu_create($arr) {
}
-function menu_list($channel_id) {
- $r = q("select * from menu where menu_channel_id = %d order by menu_name",
+/**
+ * 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 = '';
+ $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_desc",
intval($channel_id)
);
return $r;
@@ -110,6 +131,7 @@ function menu_edit($arr) {
$menu_name = trim(escape_tags($arr['menu_name']));
$menu_desc = trim(escape_tags($arr['menu_desc']));
+ $menu_flags = intval($arr['menu_flags']);
if(! $menu_desc)
$menu_desc = $menu_name;
@@ -117,6 +139,9 @@ function menu_edit($arr) {
if(! $menu_name)
return false;
+ if(! $menu_flags)
+ $menu_flags = 0;
+
$menu_channel_id = intval($arr['menu_channel_id']);
@@ -139,21 +164,11 @@ function menu_edit($arr) {
return false;
}
-
- $r = q("select * from menu where menu_name = '%s' and menu_channel_id = %d and menu_desc = '%s' limit 1",
- dbesc($menu_name),
- intval($menu_channel_id),
- dbesc($menu_desc)
- );
-
- if($r)
- return false;
-
-
- return q("update menu set menu_name = '%s', menu_desc = '%s'
+ return q("update menu set menu_name = '%s', menu_desc = '%s', menu_flags = %d
where menu_id = %d and menu_channel_id = %d limit 1",
dbesc($menu_name),
dbesc($menu_desc),
+ intval($menu_flags),
intval($menu_id),
intval($menu_channel_id)
);
@@ -201,7 +216,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'])) {
@@ -220,11 +236,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),