diff options
author | marijus <mario@localhost.localdomain> | 2014-02-05 14:48:42 +0100 |
---|---|---|
committer | marijus <mario@localhost.localdomain> | 2014-02-05 14:48:42 +0100 |
commit | 419e3b5024efec40c98e48c3bf213c4e60d39fae (patch) | |
tree | d3754aa1d251308eb6178fe4ab138463ceaaf135 /include/bookmarks.php | |
parent | d7d2fff24b05bcb3ff3acc215e99f8f7d33d058d (diff) | |
parent | 0844110f7b154a0fb5102362fe732c2b091222d7 (diff) | |
download | volse-hubzilla-419e3b5024efec40c98e48c3bf213c4e60d39fae.tar.gz volse-hubzilla-419e3b5024efec40c98e48c3bf213c4e60d39fae.tar.bz2 volse-hubzilla-419e3b5024efec40c98e48c3bf213c4e60d39fae.zip |
Merge branch 'master' of https://github.com/friendica/red into upstream
Diffstat (limited to 'include/bookmarks.php')
-rw-r--r-- | include/bookmarks.php | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/include/bookmarks.php b/include/bookmarks.php new file mode 100644 index 000000000..99cb60e64 --- /dev/null +++ b/include/bookmarks.php @@ -0,0 +1,55 @@ +<?php /** @file */ + +require_once('include/menu.php'); + +function bookmark_add($channel,$sender,$taxonomy,$private) { + + $iarr = array(); + $channel_id = $channel['channel_id']; + + if($private) + $iarr['contact_allow'] = array($channel['channel_hash']); + $iarr['mitem_link'] = $taxonomy['url']; + $iarr['mitem_desc'] = $taxonomy['term']; + $iarr['mitem_flags'] = 0; + + $m = @parse_url($taxonomy['url']); + $zrl = false; + if($m['host']) { + $r = q("select hubloc_url from hubloc where hubloc_host = '%s' limit 1", + dbesc($m['host']) + ); + if($r) + $zrl = true; + } + + if($zrl) + $iarr['mitem_flags'] |= MENU_ITEM_ZID; + + $arr = array(); + $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) { + logger('bookmark_add: unable to create menu ' . $arr['menu_name']); + return; + } + logger('add_bookmark: menu_id ' . $menu_id); + $r = q("select * from menu_item where mitem_link = '%s' and mitem_menu_id = %d and mitem_channel_id = %d limit 1", + dbesc($iarr['mitem_link']), + intval($menu_id), + intval($channel_id) + ); + if($r) + 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 |