aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/bookmarks.php33
1 files changed, 24 insertions, 9 deletions
diff --git a/include/bookmarks.php b/include/bookmarks.php
index 99cb60e64..895dedaff 100644
--- a/include/bookmarks.php
+++ b/include/bookmarks.php
@@ -2,7 +2,17 @@
require_once('include/menu.php');
-function bookmark_add($channel,$sender,$taxonomy,$private) {
+function bookmark_add($channel,$sender,$taxonomy,$private,$opts = null) {
+
+ $menu_id = 0;
+ $menu_name = '';
+ $ischat = false;
+
+ if(is_array($opts)) {
+ $menu_id = ((x($opts,'menu_id')) ? intval($opt['menu_id']) : 0);
+ $menu_name = ((x($opts,'menu_name')) ? escape_tags($opts['menu_name']) : '');
+ $ischat = ((x($opts,'ischat')) ? intval($opts['ischat']) : 0);
+ }
$iarr = array();
$channel_id = $channel['channel_id'];
@@ -11,7 +21,7 @@ function bookmark_add($channel,$sender,$taxonomy,$private) {
$iarr['contact_allow'] = array($channel['channel_hash']);
$iarr['mitem_link'] = $taxonomy['url'];
$iarr['mitem_desc'] = $taxonomy['term'];
- $iarr['mitem_flags'] = 0;
+ $iarr['mitem_flags'] = (($ischat) ? MENU_ITEM_CHATROOM : 0);
$m = @parse_url($taxonomy['url']);
$zrl = false;
@@ -27,16 +37,20 @@ function bookmark_add($channel,$sender,$taxonomy,$private) {
$iarr['mitem_flags'] |= MENU_ITEM_ZID;
$arr = array();
- $arr['menu_name'] = substr($sender['xchan_hash'],0,16) . ' ' . $sender['xchan_name'];
+ if(! $menu_name)
+ $arr['menu_name'] = substr($sender['xchan_hash'],0,16) . ' ' . $sender['xchan_name'];
$arr['menu_desc'] = sprintf( t('%1$s\'s bookmarks'), $sender['xchan_name']);
$arr['menu_flags'] = (($sender['xchan_hash'] === $channel['channel_hash']) ? MENU_BOOKMARK : MENU_SYSTEM|MENU_BOOKMARK);
$arr['menu_channel_id'] = $channel_id;
- $x = menu_list($arr['menu_channel_id'],$arr['menu_name'],$arr['menu_flags']);
- if($x)
- $menu_id = $x[0]['menu_id'];
- else
- $menu_id = menu_create($arr);
+ if(! $menu_id) {
+ $x = menu_list($arr['menu_channel_id'],$arr['menu_name'],$arr['menu_flags']);
+ if($x)
+ $menu_id = $x[0]['menu_id'];
+ else
+ $menu_id = menu_create($arr);
+ }
+
if(! $menu_id) {
logger('bookmark_add: unable to create menu ' . $arr['menu_name']);
return;
@@ -51,5 +65,6 @@ function bookmark_add($channel,$sender,$taxonomy,$private) {
logger('add_bookmark: duplicate menu entry', LOGGER_DEBUG);
if(! $r)
$r = menu_add_item($menu_id,$channel_id,$iarr);
+
return $r;
-} \ No newline at end of file
+}