aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorredmatrix <redmatrix@redmatrix.me>2015-05-28 20:50:29 -0700
committerredmatrix <redmatrix@redmatrix.me>2015-05-28 20:50:29 -0700
commit3c82156d63d16c1d7c0226f2f58ae720b904d542 (patch)
tree1df7b229e3c924076cc9e08fff2328cdbe684681 /mod
parentdf5223fe9813a2f6bee053c1c3c6acbdbaf6d42f (diff)
downloadvolse-hubzilla-3c82156d63d16c1d7c0226f2f58ae720b904d542.tar.gz
volse-hubzilla-3c82156d63d16c1d7c0226f2f58ae720b904d542.tar.bz2
volse-hubzilla-3c82156d63d16c1d7c0226f2f58ae720b904d542.zip
untested menu element import, be aware that the menu api does not over-write on duplicate name - it just fails. We'll need to sort this out eventually. Also it was planned to offer a choice of whether to preserve links from the source site or change the baseurl to the local one. Currently we convert them all to local links.
Diffstat (limited to 'mod')
-rw-r--r--mod/impel.php53
1 files changed, 46 insertions, 7 deletions
diff --git a/mod/impel.php b/mod/impel.php
index dcc82c9ba..5bc850562 100644
--- a/mod/impel.php
+++ b/mod/impel.php
@@ -58,14 +58,53 @@ function impel_init(&$a) {
break;
}
if($is_menu) {
+ $m = array();
+ $m['menu_channel_id'] = local_channel();
+ $m['menu_name'] = $j['name'];
+ $m['menu_desc'] = $j['desc'];
+ if($j['created'])
+ $m['menu_created'] = datetime_convert($j['created']);
+ if($j['edited'])
+ $m['menu_edited'] = datetime_convert($j['edited']);
+
+ $m['menu_flags'] = 0;
+ if($j['flags']) {
+ if(in_array('bookmark',$j['flags']))
+ $m['menu_flags'] |= MENU_BOOKMARK;
+ if(in_array('system',$j['flags']))
+ $m['menu_flags'] |= MENU_SYSTEM;
-
-
-
-
-
-
-
+ }
+ $menu_id = $menu_create($m);
+ if($menu_id) {
+ if(is_array($j['items'])) {
+ foreach($j['items'] as $it) {
+ $mitem = array();
+ $mitem['mitem_link'] = str_replace('[baseurl]',z_root(),$it['link']);
+ $mitem['mitem_desc'] = escapetags($it['link']);
+ $mitem['mitem_order'] = intval($it['order']);
+ if(is_array($it['flags'])) {
+ $mitem['mitem_flags'] = 0;
+ if(in_array('zid',$it['flags']))
+ $mitem['mitem_flags'] |= MENU_ITEM_ZID;
+ if(in_array('new-window',$it['flags']))
+ $mitem['mitem_flags'] |= MENU_ITEM_NEWWIN;
+ if(in_array('chatroom',$it['flags']))
+ $mitem['mitem_flags'] |= MENU_ITEM_CHATROOM;
+ }
+ menu_add_item($menu_id,local_channel(),$mitem);
+ }
+ if($j['edited']) {
+ $x = q("update menu set menu_edited = '%s' where menu_id = %d and menu_channel_id = %d",
+ dbesc(datetime_convert('UTC','UTC',$j['edited'])),
+ intval($menu_id),
+ intval(channel_id())
+ );
+ }
+ }
+ $ret['success'] = true;
+ }
+ $x = $ret;
}
else {
$arr['uid'] = local_channel();