From a7803a8eafa19664e08587596dcebeef7c63b84d Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 12 Aug 2013 03:10:34 -0700 Subject: menu module --- mod/menu.php | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 mod/menu.php (limited to 'mod') diff --git a/mod/menu.php b/mod/menu.php new file mode 100644 index 000000000..aeb885f7d --- /dev/null +++ b/mod/menu.php @@ -0,0 +1,96 @@ +get_channel(); + $menu_id = ((argc() > 1) ? intval(argv(1)) : 0); + + + + $menu_name = (($_REQUEST['menu_name']) ? $_REQUEST['menu_name'] : ''); + $menu_desc = (($_REQUEST['menu_desc']) ? $_REQUEST['menu_desc'] : ''); + + + $mitem_link = (($_REQUEST['mitem_link']) ? $_REQUEST['menu_link'] : ''); + $mitem_desc = (($_REQUEST['mitem_desc']) ? $_REQUEST['mitem_desc'] : ''); + $mitem_order = (($_REQUEST['mitem_order']) ? intval($_REQUEST['mitem_order']) : 0); + $mitem_id = (($_REQUEST['mitem_id']) ? intval($_REQUEST['mitem_id']) : 0); + + $mitem_flags = (($_REQUEST['mitem_zid']) ? MENU_ITEM_ZID : 0); + + + if ((! $_REQUEST['contact_allow']) + && (! $_REQUEST['group_allow']) + && (! $_REQUEST['contact_deny']) + && (! $_REQUEST['group_deny'])) { + $str_group_allow = $channel['channel_allow_gid']; + $str_contact_allow = $channel['channel_allow_cid']; + $str_group_deny = $channel['channel_deny_gid']; + $str_contact_deny = $channel['channel_deny_cid']; + } + else { + + // use the posted permissions + + $str_group_allow = perms2str($_REQUEST['group_allow']); + $str_contact_allow = perms2str($_REQUEST['contact_allow']); + $str_group_deny = perms2str($_REQUEST['group_deny']); + $str_contact_deny = perms2str($_REQUEST['contact_deny']); + } + + + +} + + +function menu_content(&$a) { + + if(! local_user()) { + notice( t('Permission denied.') . EOL); + return ''; + } + + + if(argc() == 1) { + // list menus + + } + + + if(argc() > 1) { + if(argv(1) === 'new') { + // new menu + + + + } + + elseif(intval(argv(1))) { + if(argc() == 3 && argv(2) == 'drop') { + $r = menu_delete_id(intval(argv(1)),local_user()); + if($r) + info( t('Menu deleted.') . EOL); + else + notice( t('Menu could not be deleted.'). EOL); + + goaway(z_root() . '/menu'); + } + else { + // edit menu + + + } + } + + } + +} -- cgit v1.2.3 From 28a8b821b0586ec430a554c520bc079f9d4dc63f Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 12 Aug 2013 03:25:37 -0700 Subject: add mod_mitem to manage menu items --- mod/menu.php | 35 ---------------------- mod/mitem.php | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 35 deletions(-) create mode 100644 mod/mitem.php (limited to 'mod') diff --git a/mod/menu.php b/mod/menu.php index aeb885f7d..3198027f4 100644 --- a/mod/menu.php +++ b/mod/menu.php @@ -2,10 +2,6 @@ require_once('include/menu.php'); -// probably should split this into two modules - with this being the CRUD module for menu -// and mod_mitem to do the same for menu_items -// Currently this file has pieces of both - function menu_post(&$a) { if(! local_user()) @@ -14,41 +10,10 @@ function menu_post(&$a) { $channel = $a->get_channel(); $menu_id = ((argc() > 1) ? intval(argv(1)) : 0); - - $menu_name = (($_REQUEST['menu_name']) ? $_REQUEST['menu_name'] : ''); $menu_desc = (($_REQUEST['menu_desc']) ? $_REQUEST['menu_desc'] : ''); - $mitem_link = (($_REQUEST['mitem_link']) ? $_REQUEST['menu_link'] : ''); - $mitem_desc = (($_REQUEST['mitem_desc']) ? $_REQUEST['mitem_desc'] : ''); - $mitem_order = (($_REQUEST['mitem_order']) ? intval($_REQUEST['mitem_order']) : 0); - $mitem_id = (($_REQUEST['mitem_id']) ? intval($_REQUEST['mitem_id']) : 0); - - $mitem_flags = (($_REQUEST['mitem_zid']) ? MENU_ITEM_ZID : 0); - - - if ((! $_REQUEST['contact_allow']) - && (! $_REQUEST['group_allow']) - && (! $_REQUEST['contact_deny']) - && (! $_REQUEST['group_deny'])) { - $str_group_allow = $channel['channel_allow_gid']; - $str_contact_allow = $channel['channel_allow_cid']; - $str_group_deny = $channel['channel_deny_gid']; - $str_contact_deny = $channel['channel_deny_cid']; - } - else { - - // use the posted permissions - - $str_group_allow = perms2str($_REQUEST['group_allow']); - $str_contact_allow = perms2str($_REQUEST['contact_allow']); - $str_group_deny = perms2str($_REQUEST['group_deny']); - $str_contact_deny = perms2str($_REQUEST['contact_deny']); - } - - - } diff --git a/mod/mitem.php b/mod/mitem.php new file mode 100644 index 000000000..b2ccaa341 --- /dev/null +++ b/mod/mitem.php @@ -0,0 +1,95 @@ +get_channel(); + $mitem_id = ((argc() > 1) ? intval(argv(1)) : 0); + + $mitem_link = (($_REQUEST['mitem_link']) ? $_REQUEST['menu_link'] : ''); + $mitem_desc = (($_REQUEST['mitem_desc']) ? $_REQUEST['mitem_desc'] : ''); + $mitem_order = (($_REQUEST['mitem_order']) ? intval($_REQUEST['mitem_order']) : 0); + $mitem_id = (($_REQUEST['mitem_id']) ? intval($_REQUEST['mitem_id']) : 0); + + $mitem_flags = (($_REQUEST['mitem_zid']) ? MENU_ITEM_ZID : 0); + + + if ((! $_REQUEST['contact_allow']) + && (! $_REQUEST['group_allow']) + && (! $_REQUEST['contact_deny']) + && (! $_REQUEST['group_deny'])) { + $str_group_allow = $channel['channel_allow_gid']; + $str_contact_allow = $channel['channel_allow_cid']; + $str_group_deny = $channel['channel_deny_gid']; + $str_contact_deny = $channel['channel_deny_cid']; + } + else { + + // use the posted permissions + + $str_group_allow = perms2str($_REQUEST['group_allow']); + $str_contact_allow = perms2str($_REQUEST['contact_allow']); + $str_group_deny = perms2str($_REQUEST['group_deny']); + $str_contact_deny = perms2str($_REQUEST['contact_deny']); + } + +} + + +function mitem_content(&$a) { + + if(! local_user()) { + notice( t('Permission denied.') . EOL); + return ''; + } + + + if(argc() == 1) { + // list menus + + } + + + if(argc() > 1) { + if(argv(1) === 'new') { + // new menu + + + + } + + elseif(intval(argv(1))) { + $m = q("select * from menu_item where mitem_id = %d and mitem_channel_id = %d limit 1", + intval(argv(1)), + intval(local_user()) + ); + if(! $m) { + notice( t('Menu item not found.') . EOL); + goaway(z_root() . '/menu'); + } + + $mitem = $m[0]; + if(argc() == 3 && argv(2) == 'drop') { + $r = menu_del_item($mitem['mitem_menu_id'], local_user(),intval(argv(1))); + if($r) + info( t('Menu item deleted.') . EOL); + else + notice( t('Menu item could not be deleted.'). EOL); + + goaway(z_root() . '/menu'); + } + else { + // edit menu item + + + } + } + + } + + + + +} -- cgit v1.2.3 From 04f8de184e8c925e38335eb18c102985ce421f95 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 12 Aug 2013 17:42:52 -0700 Subject: block content-type (called ITEM_BUILDBLOCK to avoid confusion with content that is blocked) --- mod/item.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'mod') diff --git a/mod/item.php b/mod/item.php index dc8ee5015..1893a6ef4 100644 --- a/mod/item.php +++ b/mod/item.php @@ -70,6 +70,7 @@ function item_post(&$a) { $categories = ((x($_REQUEST,'category')) ? escape_tags($_REQUEST['category']) : ''); $webpage = ((x($_REQUEST,'webpage')) ? intval($_REQUEST['webpage']) : 0); $pagetitle = ((x($_REQUEST,'pagetitle')) ? escape_tags($_REQUEST['pagetitle']): ''); + $buildblock = ((x($_REQUEST,'buildblock')) ? intval($_REQUEST['buildblock']) : 0); if($pagetitle) { require_once('library/urlify/URLify.php'); @@ -492,6 +493,8 @@ function item_post(&$a) { if($webpage) $item_restrict = $item_restrict | ITEM_WEBPAGE; + if($buildblock) + $item_restrict = $item_restrict | ITEM_BUILDBLOCK; if(! strlen($verb)) -- cgit v1.2.3 From 55cb32248953c6e63a2da478f0eb3895875f93d8 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 13 Aug 2013 01:24:02 -0700 Subject: a bit more work on menus --- mod/menu.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'mod') diff --git a/mod/menu.php b/mod/menu.php index 3198027f4..a624b4727 100644 --- a/mod/menu.php +++ b/mod/menu.php @@ -27,6 +27,24 @@ function menu_content(&$a) { if(argc() == 1) { // list menus + $x = menu_list(local_user()); + if($x) { + $o = replace_macros(get_markup_template('menulist.tpl'),array( + '$title' => t('Manage Menus'), + '$menus' => $x, + '$edit' => t('Edit'), + '$drop' => t('Drop'), + '$new' => t('New'), + '$hintnew' => t('Create a new menu'), + '$hintdrop' => t('Delete this menu'), + '$hintedit' => t('Edit this menu') + )); + } + return $o; + + + + } -- cgit v1.2.3 From 680baff73d70769714d806c00cc84c6e65faba0f Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 13 Aug 2013 18:10:03 -0700 Subject: menu management complete (as opposed to menu *content* management, which is not). As usual, this means functionally complete - as theming and presentation have been left for those more suited to the task. --- mod/menu.php | 62 +++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 13 deletions(-) (limited to 'mod') diff --git a/mod/menu.php b/mod/menu.php index a624b4727..f00bf7a78 100644 --- a/mod/menu.php +++ b/mod/menu.php @@ -7,12 +7,29 @@ function menu_post(&$a) { if(! local_user()) return; - $channel = $a->get_channel(); - $menu_id = ((argc() > 1) ? intval(argv(1)) : 0); + $_REQUEST['menu_channel_id'] = local_user(); - $menu_name = (($_REQUEST['menu_name']) ? $_REQUEST['menu_name'] : ''); - $menu_desc = (($_REQUEST['menu_desc']) ? $_REQUEST['menu_desc'] : ''); + $menu_id = ((argc() > 1) ? intval(argv(1)) : 0); + if($menu_id) { + $_REQUEST['menu_id'] = intval(argv(1)); + $r = menu_edit($_REQUEST); + if($r) { + info( t('Menu updated.') . EOL); + goaway(z_root() . '/mitem/' . $menu_id); + } + else + notice( t('Unable to update menu.'). EOL); + } + else { + $r = menu_create($_REQUEST); + if($r) { + info( t('Menu created.') . EOL); + goaway(z_root() . '/mitem/' . $r); + } + else + notice( t('Unable to create menu.'). EOL); + } } @@ -37,6 +54,7 @@ function menu_content(&$a) { '$new' => t('New'), '$hintnew' => t('Create a new menu'), '$hintdrop' => t('Delete this menu'), + '$hintcontent' => t('Edit menu contents'), '$hintedit' => t('Edit this menu') )); } @@ -50,14 +68,22 @@ function menu_content(&$a) { if(argc() > 1) { - if(argv(1) === 'new') { - // new menu - - - + if(argv(1) === 'new') { + $o = replace_macros(get_markup_template('menuedit.tpl'), array( + '$header' => t('New Menu'), + '$menu_name' => array('menu_name', t('Menu name'), '', t('Must be unique, only seen by you'), '*'), + '$menu_desc' => array('menu_desc', t('Menu title'), '', t('Menu title as seen by others'), ''), + '$submit' => t('Create') + )); + return $o; } elseif(intval(argv(1))) { + $m = menu_fetch_id(intval(argv(1)),local_user()); + if(! $m) { + notice( t('Menu not found.') . EOL); + return ''; + } if(argc() == 3 && argv(2) == 'drop') { $r = menu_delete_id(intval(argv(1)),local_user()); if($r) @@ -68,12 +94,22 @@ function menu_content(&$a) { goaway(z_root() . '/menu'); } else { - // edit menu - - + $o = replace_macros(get_markup_template('menuedit.tpl'), array( + '$header' => t('Edit Menu'), + '$menu_id' => intval(argv(1)), + '$hintedit' => t('Add or remove entries to this menu'), + '$editcontents' => t('Edit menu contents'), + '$menu_name' => array('menu_name', t('Menu name'), $m['menu_name'], t('Must be unique, only seen by you'), '*'), + '$menu_desc' => array('menu_desc', t('Menu title'), $m['menu_desc'], t('Menu title as seen by others'), ''), + '$submit' => t('Modify') + )); + return $o; } } - + else { + notice( t('Not found.') . EOL); + return; + } } } -- cgit v1.2.3 From 9508967c7350e69bf3321aaa63f5527a3e8096f4 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 13 Aug 2013 20:57:03 -0700 Subject: menu management is now functional with the exception of acl's (and of course a way to display the menus you create, and probably a bit more input sanity checking) --- mod/menu.php | 2 +- mod/mitem.php | 145 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 126 insertions(+), 21 deletions(-) (limited to 'mod') diff --git a/mod/menu.php b/mod/menu.php index f00bf7a78..910fc389b 100644 --- a/mod/menu.php +++ b/mod/menu.php @@ -22,7 +22,7 @@ function menu_post(&$a) { } else { $r = menu_create($_REQUEST); - if($r) { + if($r) { info( t('Menu created.') . EOL); goaway(z_root() . '/mitem/' . $r); } diff --git a/mod/mitem.php b/mod/mitem.php index b2ccaa341..2b890d5a1 100644 --- a/mod/mitem.php +++ b/mod/mitem.php @@ -1,20 +1,40 @@ data['menu'] = $m; + +} + function mitem_post(&$a) { if(! local_user()) return; - $channel = $a->get_channel(); - $mitem_id = ((argc() > 1) ? intval(argv(1)) : 0); + if(! $a->data['menu']) + return; - $mitem_link = (($_REQUEST['mitem_link']) ? $_REQUEST['menu_link'] : ''); - $mitem_desc = (($_REQUEST['mitem_desc']) ? $_REQUEST['mitem_desc'] : ''); - $mitem_order = (($_REQUEST['mitem_order']) ? intval($_REQUEST['mitem_order']) : 0); - $mitem_id = (($_REQUEST['mitem_id']) ? intval($_REQUEST['mitem_id']) : 0); + $_REQUEST['mitem_channel_id'] = local_user(); + $_REQUEST['menu_id'] = $a->data['menu']['menu_id']; - $mitem_flags = (($_REQUEST['mitem_zid']) ? MENU_ITEM_ZID : 0); + $_REQUEST['mitem_flags'] = 0; + if($_REQUEST['usezid']) + $_REQUEST['mitem_flags'] |= MENU_ITEM_ZID; + if($_REQUEST['newwin']) + $_REQUEST['mitem_flags'] |= MENU_ITEM_NEWWIN; +// FIXME!!!! if ((! $_REQUEST['contact_allow']) && (! $_REQUEST['group_allow']) @@ -35,6 +55,34 @@ function mitem_post(&$a) { $str_contact_deny = perms2str($_REQUEST['contact_deny']); } + + + + $mitem_id = ((argc() > 2) ? intval(argv(2)) : 0); + if($mitem_id) { + $_REQUEST['mitem_id'] = $mitem_id; + $r = menu_edit_item($_REQUEST['menu_id'],local_user(),$_REQUEST); + if($r) { + info( t('Menu element updated.') . EOL); + goaway(z_root() . '/mitem/' . $_REQUEST['menu_id']); + } + else + notice( t('Unable to update menu element.') . EOL); + + } + else { + $r = menu_add_item($_REQUEST['menu_id'],local_user(),$_REQUEST); + if($r) { + info( t('Menu element added.') . EOL); + goaway(z_root() . '/mitem/' . $_REQUEST['menu_id']); + } + else + notice( t('Unable to add menu element.') . EOL); + + } + + + } @@ -45,24 +93,67 @@ function mitem_content(&$a) { return ''; } - - if(argc() == 1) { - // list menus - + if(argc() < 2 || (! $a->data['menu'])) { + notice( t('Not found.') . EOL); + return ''; } - if(argc() > 1) { - if(argv(1) === 'new') { - // new menu + $m = menu_fetch($a->data['menu']['menu_name'],local_user(), get_observer_hash()); + $a->set_widget('menu_preview',menu_render($m)); + + + if(argc() == 2) { + $r = q("select * from menu_item where mitem_menu_id = %d and mitem_channel_id = %d order by mitem_order asc, mitem_desc asc", + intval($a->data['menu']['menu_id']), + local_user() + ); + + if($r) { + $o = replace_macros(get_markup_template('mitemlist.tpl'),array( + '$title' => t('Manage Menu Elements'), + '$menuname' => $a->data['menu']['menu_name'], + '$menudesc' => $a->data['menu']['menu_desc'], + '$edmenu' => t('Edit menu'), + '$menu_id' => $a->data['menu']['menu_id'], + '$mlist' => $r, + '$edit' => t('Edit element'), + '$drop' => t('Drop element'), + '$new' => t('New element'), + '$hintmenu' => t('Edit this menu container'), + '$hintnew' => t('Add menu element'), + '$hintdrop' => t('Delete this menu item'), + '$hintedit' => t('Edit this menu item') + )); + } + + return $o; + + } + if(argc() > 2) { + if(argv(2) === 'new') { + + $o = replace_macros(get_markup_template('mitemedit.tpl'), array( + '$header' => t('New Menu Element'), + '$menu_id' => $a->data['menu']['menu_id'], + '$mitem_desc' => array('mitem_desc', t('Link text'), '', '','*'), + '$mitem_link' => array('mitem_link', t('URL of link'), '', '', '*'), + '$usezid' => array('usezid', t('Use Red magic-auth if available'), true, ''), + '$newwin' => array('newwin', t('Open link in new window'), false,''), +// permissions go here + '$mitem_order' => array('mitem_order', t('Order in list'),'0',t('Higher numbers will sink to bottom of listing')), + '$submit' => t('Create') + )); + return $o; } - elseif(intval(argv(1))) { + + elseif(intval(argv(2))) { $m = q("select * from menu_item where mitem_id = %d and mitem_channel_id = %d limit 1", - intval(argv(1)), + intval(argv(2)), intval(local_user()) ); if(! $m) { @@ -71,19 +162,33 @@ function mitem_content(&$a) { } $mitem = $m[0]; - if(argc() == 3 && argv(2) == 'drop') { - $r = menu_del_item($mitem['mitem_menu_id'], local_user(),intval(argv(1))); + + if(argc() == 4 && argv(3) == 'drop') { + $r = menu_del_item($mitem['mitem_menu_id'], local_user(),intval(argv(2))); if($r) info( t('Menu item deleted.') . EOL); else notice( t('Menu item could not be deleted.'). EOL); - goaway(z_root() . '/menu'); + goaway(z_root() . '/mitem/' . $mitem['mitem_menu_id']); } else { - // edit menu item + // edit menu item + $o = replace_macros(get_markup_template('mitemedit.tpl'), array( + '$header' => t('Edit Menu Element'), + '$menu_id' => $a->data['menu']['menu_id'], + '$mitem_id' => intval(argv(2)), + '$mitem_desc' => array('mitem_desc', t('Link text'), $mitem['mitem_desc'], '','*'), + '$mitem_link' => array('mitem_link', t('URL of link'), $mitem['mitem_link'], '', '*'), + '$usezid' => array('usezid', t('Use Red magic-auth if available'), (($mitem['mitem_flags'] & MENU_ITEM_ZID) ? 1 : 0), ''), + '$newwin' => array('newwin', t('Open link in new window'), (($mitem['mitem_flags'] & MENU_ITEM_NEWWIN) ? 1 : 0),''), +// permissions go here + '$mitem_order' => array('mitem_order', t('Order in list'),$mitem['mitem_order'],t('Higher numbers will sink to bottom of listing')), + '$submit' => t('Modify') + )); + return $o; } } -- cgit v1.2.3 From f287ff596cf8562cdb9290fc0a5b31b45d9100c1 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 14 Aug 2013 05:26:17 -0700 Subject: fix expire so it actually should expire stuff; and mostly the correct stuff - though it DOESN'T currently send out notifications to connections --- mod/settings.php | 1 - 1 file changed, 1 deletion(-) (limited to 'mod') diff --git a/mod/settings.php b/mod/settings.php index 0cca41810..c39286ebc 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -330,7 +330,6 @@ function settings_post(&$a) { $expire_items = ((x($_POST,'expire_items')) ? intval($_POST['expire_items']) : 0); - $expire_notes = ((x($_POST,'expire_notes')) ? intval($_POST['expire_notes']) : 0); $expire_starred = ((x($_POST,'expire_starred')) ? intval($_POST['expire_starred']) : 0); $expire_photos = ((x($_POST,'expire_photos'))? intval($_POST['expire_photos']) : 0); $expire_network_only = ((x($_POST,'expire_network_only'))? intval($_POST['expire_network_only']) : 0); -- cgit v1.2.3