From d8f16442a1ca7d0be18dedd52c0f4eb339ba19b6 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 4 Feb 2014 00:52:34 -0800 Subject: bookmark permissions --- boot.php | 3 ++- include/permissions.php | 1 + install/database.sql | 2 ++ install/update.php | 10 +++++++++- mod/settings.php | 6 +++++- version.inc | 2 +- view/js/mod_connedit.js | 1 + view/js/mod_settings.js | 4 ++++ 8 files changed, 25 insertions(+), 4 deletions(-) diff --git a/boot.php b/boot.php index 18a4ff888..faae00273 100755 --- a/boot.php +++ b/boot.php @@ -46,7 +46,7 @@ define ( 'RED_PLATFORM', 'Red Matrix' ); define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R'); define ( 'ZOT_REVISION', 1 ); -define ( 'DB_UPDATE_VERSION', 1095 ); +define ( 'DB_UPDATE_VERSION', 1096 ); define ( 'EOL', '
' . "\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); @@ -270,6 +270,7 @@ define ( 'PERMS_W_STORAGE', 0x02000); define ( 'PERMS_R_PAGES', 0x04000); define ( 'PERMS_W_PAGES', 0x08000); define ( 'PERMS_A_REPUBLISH', 0x10000); +define ( 'PERMS_A_BOOMARK', 0x20000); // General channel permissions diff --git a/include/permissions.php b/include/permissions.php index 1b11dfb87..060ed841c 100644 --- a/include/permissions.php +++ b/include/permissions.php @@ -29,6 +29,7 @@ function get_perms() { 'write_pages' => array('channel_w_pages', intval(PERMS_W_PAGES), false, t('Can edit my "public" pages'), ''), 'republish' => array('channel_a_republish', intval(PERMS_A_REPUBLISH), false, t('Can source my "public" posts in derived channels'), t('Somewhat advanced - very useful in open communities')), + 'bookmark' => array('channel_a_bookmark', intval(PERMS_A_BOOKMARK), false, t('Can send me bookmarks'), ''), 'delegate' => array('channel_a_delegate', intval(PERMS_A_DELEGATE), false, t('Can administer my channel resources'), t('Extremely advanced. Leave this alone unless you know what you are doing')), ); $ret = array('global_permissions' => $global_perms); diff --git a/install/database.sql b/install/database.sql index c89e4cef2..86531a415 100644 --- a/install/database.sql +++ b/install/database.sql @@ -177,6 +177,7 @@ CREATE TABLE IF NOT EXISTS `channel` ( `channel_r_pages` int(10) unsigned NOT NULL DEFAULT '128', `channel_w_pages` int(10) unsigned NOT NULL DEFAULT '128', `channel_a_republish` int(10) unsigned NOT NULL DEFAULT '128', + `channel_a_bookmark` int(10) unsigned NOT NULL DEFAULT '128', PRIMARY KEY (`channel_id`), UNIQUE KEY `channel_address_unique` (`channel_address`), KEY `channel_account_id` (`channel_account_id`), @@ -211,6 +212,7 @@ CREATE TABLE IF NOT EXISTS `channel` ( KEY `channel_w_pages` (`channel_w_pages`), KEY `channel_deleted` (`channel_deleted`), KEY `channel_a_republish` (`channel_a_republish`), + KEY `channel_a_bookmark` (`channel_a_bookmark`), KEY `channel_dirdate` (`channel_dirdate`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; diff --git a/install/update.php b/install/update.php index e8b6d37f6..93442a81f 100644 --- a/install/update.php +++ b/install/update.php @@ -1,6 +1,6 @@ Date: Tue, 4 Feb 2014 01:42:43 -0800 Subject: fix the search for system bookmarks --- include/menu.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/include/menu.php b/include/menu.php index be9831951..7522f69a3 100644 --- a/include/menu.php +++ b/include/menu.php @@ -75,7 +75,6 @@ function menu_create($arr) { $r = q("select * from menu where menu_name = '%s' and menu_channel_id = %d limit 1", dbesc($menu_name), intval($menu_channel_id), - intval($menu_flags) ); if($r) @@ -101,9 +100,15 @@ function menu_create($arr) { } +/** + * 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, $flags = 0) { - $sel_options = (($flags) ? " and ( menu_flags & " . intval($flags) . " ) " : ''); + $sel_options = (($flags) ? " and ( menu_flags & " . intval($flags) . " ) = " . intval($flags) . " " : ''); $r = q("select * from menu where menu_channel_id = %d $sel_options order by menu_name", intval($channel_id) @@ -204,7 +209,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'])) { -- cgit v1.2.3 From 3665bc38ef15137c7d36a12aa13a44c4d0304547 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 4 Feb 2014 16:06:56 -0800 Subject: bookmarking --- boot.php | 2 +- include/bookmarks.php | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ include/items.php | 15 ++++++++++++++ include/menu.php | 27 ++++++++++++++----------- include/permissions.php | 2 +- mod/bookmarks.php | 40 +++++++++++++++++++++++++++++++++++++ mod/parse_url.php | 2 +- 7 files changed, 126 insertions(+), 15 deletions(-) create mode 100644 include/bookmarks.php create mode 100644 mod/bookmarks.php diff --git a/boot.php b/boot.php index faae00273..1d462eff8 100755 --- a/boot.php +++ b/boot.php @@ -270,7 +270,7 @@ define ( 'PERMS_W_STORAGE', 0x02000); define ( 'PERMS_R_PAGES', 0x04000); define ( 'PERMS_W_PAGES', 0x08000); define ( 'PERMS_A_REPUBLISH', 0x10000); -define ( 'PERMS_A_BOOMARK', 0x20000); +define ( 'PERMS_A_BOOKMARK', 0x20000); // General channel permissions diff --git a/include/bookmarks.php b/include/bookmarks.php new file mode 100644 index 000000000..62ec9fcab --- /dev/null +++ b/include/bookmarks.php @@ -0,0 +1,53 @@ + $menu['menu'], @@ -74,7 +75,7 @@ function menu_create($arr) { $r = q("select * from menu where menu_name = '%s' and menu_channel_id = %d limit 1", dbesc($menu_name), - intval($menu_channel_id), + intval($menu_channel_id) ); if($r) @@ -106,9 +107,11 @@ function menu_create($arr) { * bits set. We will use this to find system generated bookmarks. */ -function menu_list($channel_id, $flags = 0) { +function menu_list($channel_id, $name = '', $flags = 0) { - $sel_options = (($flags) ? " and ( menu_flags & " . intval($flags) . " ) = " . intval($flags) . " " : ''); + $sel_options = ''; + $sel_options .= (($name) ? " and 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_name", intval($channel_id) @@ -229,11 +232,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), diff --git a/include/permissions.php b/include/permissions.php index 060ed841c..420591c54 100644 --- a/include/permissions.php +++ b/include/permissions.php @@ -29,7 +29,7 @@ function get_perms() { 'write_pages' => array('channel_w_pages', intval(PERMS_W_PAGES), false, t('Can edit my "public" pages'), ''), 'republish' => array('channel_a_republish', intval(PERMS_A_REPUBLISH), false, t('Can source my "public" posts in derived channels'), t('Somewhat advanced - very useful in open communities')), - 'bookmark' => array('channel_a_bookmark', intval(PERMS_A_BOOKMARK), false, t('Can send me bookmarks'), ''), + 'bookmark' => array('channel_a_bookmark', intval(PERMS_A_BOOKMARK), false, t('Can send me bookmarks'), 'Bookmarks from this person will automatically be saved'), 'delegate' => array('channel_a_delegate', intval(PERMS_A_DELEGATE), false, t('Can administer my channel resources'), t('Extremely advanced. Leave this alone unless you know what you are doing')), ); $ret = array('global_permissions' => $global_perms); diff --git a/mod/bookmarks.php b/mod/bookmarks.php new file mode 100644 index 000000000..25bf39a7a --- /dev/null +++ b/mod/bookmarks.php @@ -0,0 +1,40 @@ +' . t('My Bookmarks') . ''; + + $x = menu_list(local_user(),'',MENU_BOOKMARK); + + if($x) { + foreach($x as $xx) { + $y = menu_fetch($xx['menu_name'],local_user(),get_observer_hash()); + $o .= menu_render($y); + } + } + + $o .= '

' . t('My Connections Bookmarks') . '

'; + + + $x = menu_list(local_user(),'',MENU_SYSTEM|MENU_BOOKMARK); + + if($x) { + foreach($x as $xx) { + $y = menu_fetch($xx['menu_name'],local_user(),get_observer_hash()); + $o .= menu_render($y); + } + } + + + + return $o; + +} + diff --git a/mod/parse_url.php b/mod/parse_url.php index c206c24ec..340e1a67e 100644 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -252,7 +252,7 @@ function parse_url_content(&$a) { logger('parse_url: ' . $url); - $template = $br . '[url=%s]%s[/url]%s' . $br; + $template = $br . '#^[url=%s]%s[/url]%s' . $br; $arr = array('url' => $url, 'text' => ''); -- cgit v1.2.3 From aede006970fb9124161b4732b9f44002a35d17ef Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 4 Feb 2014 17:12:13 -0800 Subject: bookmarks - mop up and go home --- include/ItemObject.php | 10 ++++++++++ include/bookmarks.php | 2 +- include/conversation.php | 8 ++++++++ include/menu.php | 2 +- mod/bookmarks.php | 34 ++++++++++++++++++++++++++++++++++ view/js/mod_connedit.js | 2 +- view/js/mod_settings.js | 2 +- view/tpl/conv_item.tpl | 3 +++ view/tpl/jot-header.tpl | 8 +++++++- 9 files changed, 66 insertions(+), 5 deletions(-) diff --git a/include/ItemObject.php b/include/ItemObject.php index e9a0b65c0..9b1a6fbcd 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -171,6 +171,15 @@ class Item extends BaseObject { ); } + $has_bookmarks = false; + if(is_array($item['term'])) { + foreach($item['term'] as $t) { + if($t['type'] == TERM_BOOKMARK) + $has_bookmarks = true; + } + } + + if($this->is_commentable()) { $like = array( t("I like this \x28toggle\x29"), t("like")); $dislike = array( t("I don't like this \x28toggle\x29"), t("dislike")); @@ -237,6 +246,7 @@ class Item extends BaseObject { 'star' => ((feature_enabled($conv->get_profile_owner(),'star_posts')) ? $star : ''), 'tagger' => ((feature_enabled($conv->get_profile_owner(),'commtag')) ? $tagger : ''), 'filer' => ((feature_enabled($conv->get_profile_owner(),'filing')) ? $filer : ''), + 'bookmark' => (($conv->get_profile_owner() == local_user() && $has_bookmarks) ? t('Bookmark Links') : ''), 'drop' => $drop, 'multidrop' => ((feature_enabled($conv->get_profile_owner(),'multi_delete')) ? $multidrop : ''), // end toolbar buttons diff --git a/include/bookmarks.php b/include/bookmarks.php index 62ec9fcab..3ca8ee1c1 100644 --- a/include/bookmarks.php +++ b/include/bookmarks.php @@ -29,7 +29,7 @@ function bookmark_add($channel,$sender,$taxonomy,$private) { $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'] = MENU_SYSTEM|MENU_BOOKMARK; + $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']); diff --git a/include/conversation.php b/include/conversation.php index 316bc1612..633435871 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1496,6 +1496,14 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){ 'title' => t('Events and Calendar'), 'id' => 'events-tab', ); + + $tabs[] = array( + 'label' => t('Bookmarks'), + 'url' => $a->get_baseurl() . '/bookmarks', + 'sel' => ((argv(0) == 'bookmarks') ? 'active' : ''), + 'title' => t('Saved Bookmarks'), + 'id' => 'bookmarks-tab', + ); } if($is_owner && feature_enabled($a->profile['profile_uid'],'webpages')) { diff --git a/include/menu.php b/include/menu.php index e5bd4a680..105e4216b 100644 --- a/include/menu.php +++ b/include/menu.php @@ -110,7 +110,7 @@ function menu_create($arr) { function menu_list($channel_id, $name = '', $flags = 0) { $sel_options = ''; - $sel_options .= (($name) ? " and name = '" . protect_sprintf(dbesc($name)) . "' " : ''); + $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_name", diff --git a/mod/bookmarks.php b/mod/bookmarks.php index 25bf39a7a..fe5ec1e19 100644 --- a/mod/bookmarks.php +++ b/mod/bookmarks.php @@ -1,5 +1,39 @@ get_channel(); + + $i = q("select * from item where id = %d and uid = %d limit 1", + intval($item_id), + intval(local_user()) + ); + if(! $i) + return; + + $i = fetch_post_tags($i); + + $item = $i[0]; + + $terms = get_terms_oftype($item['term'],TERM_BOOKMARK); + + if($terms && (! $i[0]['item_restrict'])) { + require_once('include/bookmarks.php'); + require_once('include/Contact.php'); + $s = channelx_by_hash($i[0]['author_xchan']); + foreach($terms as $t) { + bookmark_add($u,$s[0],$t,$i[0]['item_private']); + notice( t('Bookmark(s) added') . EOL); + } + } + killme(); +} + function bookmarks_content(&$a) { if(! local_user()) { notice( t('Permission denied.') . EOL); diff --git a/view/js/mod_connedit.js b/view/js/mod_connedit.js index 6bb39fb7a..7a33952dc 100644 --- a/view/js/mod_connedit.js +++ b/view/js/mod_connedit.js @@ -17,7 +17,7 @@ function connectFullShare() { $('#me_id_perms_chat').attr('checked','checked'); $('#me_id_perms_view_storage').attr('checked','checked'); $('#me_id_perms_republish').attr('checked','checked'); - $('#me_id_perms_bookmark').attr('checked','checked'); + } function connectCautiousShare() { diff --git a/view/js/mod_settings.js b/view/js/mod_settings.js index 7ede7fb73..16101db57 100644 --- a/view/js/mod_settings.js +++ b/view/js/mod_settings.js @@ -66,7 +66,7 @@ function channel_privacy_macro(n) { $('#id_write_pages option').eq(1).attr('selected','selected'); $('#id_delegate option').eq(0).attr('selected','selected'); $('#id_republish option').eq(0).attr('selected','selected'); - $('#id_bookmark option').eq(0).attr('selected','selected'); + $('#id_bookmark option').eq(1).attr('selected','selected'); $('#id_profile_in_directory_onoff .off').removeClass('hidden'); $('#id_profile_in_directory_onoff .on').addClass('hidden'); $('#id_profile_in_directory').val(0); diff --git a/view/tpl/conv_item.tpl b/view/tpl/conv_item.tpl index 50a243ff4..869692bfa 100755 --- a/view/tpl/conv_item.tpl +++ b/view/tpl/conv_item.tpl @@ -85,6 +85,9 @@ {{/if}} {{if $item.filer}} + {{/if}} + {{if $item.bookmark}} + {{/if}} diff --git a/view/tpl/jot-header.tpl b/view/tpl/jot-header.tpl index 878e1e7da..80421d552 100755 --- a/view/tpl/jot-header.tpl +++ b/view/tpl/jot-header.tpl @@ -185,7 +185,6 @@ function enableOnUser(){ } } - function jotGetLocation() { reply = prompt("{{$whereareu}}", $('#jot-location').val()); if(reply && reply.length) { @@ -295,6 +294,13 @@ function enableOnUser(){ } + function itemBookmark(id) { + $.get('{{$baseurl}}/bookmarks?f=&item=' + id); + if(timer) clearTimeout(timer); + timer = setTimeout(NavUpdate,1000); + } + + function jotClearLocation() { $('#jot-coord').val(''); $('#profile-nolocation-wrapper').hide(); -- cgit v1.2.3 From 9f439c3248c0464298e0b486a85ad74ec2df8270 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 4 Feb 2014 17:14:22 -0800 Subject: add icon translation for new icon --- view/js/icon_translate.js | 1 + 1 file changed, 1 insertion(+) diff --git a/view/js/icon_translate.js b/view/js/icon_translate.js index 838ff899f..737164cb8 100644 --- a/view/js/icon_translate.js +++ b/view/js/icon_translate.js @@ -51,4 +51,5 @@ $(document).ready(function() { $('.icon-globe').addClass(''); $('.icon-circle-blank').addClass(''); $('.icon-circle').addClass(''); + $('.icon-bookmark').addClass(''); }); \ No newline at end of file -- cgit v1.2.3 From 8a11c2941395bdd325ac076bd22ad011fe41f3c7 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 4 Feb 2014 19:39:56 -0800 Subject: make links in comments bookmark-able --- include/bookmarks.php | 4 ++++ include/text.php | 2 +- mod/item.php | 4 ++-- view/js/main.js | 6 ++++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/bookmarks.php b/include/bookmarks.php index 3ca8ee1c1..3a4c5c5d6 100644 --- a/include/bookmarks.php +++ b/include/bookmarks.php @@ -7,6 +7,10 @@ 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']; diff --git a/include/text.php b/include/text.php index dc7d94b6d..266d8952b 100755 --- a/include/text.php +++ b/include/text.php @@ -604,7 +604,7 @@ function get_tags($s) { // bookmarks - if(preg_match_all('/#\^\[(url|zrl)=(.*?)\](.*?)\[\/(url|zrl)\]/',$s,$match,PREG_SET_ORDER)) { + if(preg_match_all('/#\^\[(url|zrl)(.*?)\](.*?)\[\/(url|zrl)\]/',$s,$match,PREG_SET_ORDER)) { foreach($match as $mtch) { $ret[] = $mtch[0]; } diff --git a/mod/item.php b/mod/item.php index 68bb75897..c8c0e3762 100644 --- a/mod/item.php +++ b/mod/item.php @@ -896,9 +896,9 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag) { //is it a hash tag? if(strpos($tag,'#') === 0) { if(strpos($tag,'#^[') === 0) { - if(preg_match('/#\^\[(url|zrl)=(.*?)\](.*?)\[\/(url|zrl)\]/',$tag,$match)) { + if(preg_match('/#\^\[(url|zrl)(.*?)\](.*?)\[\/(url|zrl)\]/',$tag,$match)) { $basetag = $match[3]; - $url = $match[2]; + $url = ((substr($match[2],0,1) === '=') ? substr($match[2],1) : $match[3]); $replaced = true; } diff --git a/view/js/main.js b/view/js/main.js index c8e9fc9a2..44cb79949 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -55,6 +55,8 @@ if(typeof(insertFormatting) != 'undefined') return(insertFormatting(comment,BBcode,id)); + var urlprefix = ((BBcode == 'url') ? '#^' : ''); + var tmpStr = $("#comment-edit-text-" + id).val(); if(tmpStr == comment) { tmpStr = ""; @@ -68,11 +70,11 @@ if (document.selection) { textarea.focus(); selected = document.selection.createRange(); - selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]"; + selected.text = urlprefix+"["+BBcode+"]" + selected.text + "[/"+BBcode+"]"; } else if (textarea.selectionStart || textarea.selectionStart == "0") { var start = textarea.selectionStart; var end = textarea.selectionEnd; - textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length); + textarea.value = textarea.value.substring(0, start) + urlprefix+"["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length); } return true; } -- cgit v1.2.3 From f30a39f9df5dc0cc70a9cb9befe87a8723c75721 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 5 Feb 2014 03:15:10 -0800 Subject: bookmark debug logging --- include/bookmarks.php | 8 +++----- mod/bookmarks.php | 6 +++++- version.inc | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/bookmarks.php b/include/bookmarks.php index 3a4c5c5d6..7a9f40697 100644 --- a/include/bookmarks.php +++ b/include/bookmarks.php @@ -7,10 +7,6 @@ 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']; @@ -45,12 +41,14 @@ function bookmark_add($channel,$sender,$taxonomy,$private) { 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('duplicate menu entry'); if(! $r) $r = menu_add_item($menu_id,$channel_id,$iarr); return $r; diff --git a/mod/bookmarks.php b/mod/bookmarks.php index fe5ec1e19..73958ff2f 100644 --- a/mod/bookmarks.php +++ b/mod/bookmarks.php @@ -26,9 +26,13 @@ function bookmarks_init(&$a) { require_once('include/bookmarks.php'); require_once('include/Contact.php'); $s = channelx_by_hash($i[0]['author_xchan']); + if(! $s) { + notice( t('Author lookup failed') . EOL); + killme(); + } foreach($terms as $t) { bookmark_add($u,$s[0],$t,$i[0]['item_private']); - notice( t('Bookmark(s) added') . EOL); + notice( t('Bookmark added') . EOL); } } killme(); diff --git a/version.inc b/version.inc index 6140d2174..c26fe7d69 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2014-02-04.578 +2014-02-05.579 -- cgit v1.2.3 From 24f32e55c88311867218c1d93c808cd842453078 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 5 Feb 2014 03:29:02 -0800 Subject: bookmarking bugfix --- include/bookmarks.php | 2 +- mod/bookmarks.php | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/include/bookmarks.php b/include/bookmarks.php index 7a9f40697..99cb60e64 100644 --- a/include/bookmarks.php +++ b/include/bookmarks.php @@ -48,7 +48,7 @@ function bookmark_add($channel,$sender,$taxonomy,$private) { intval($channel_id) ); if($r) - logger('duplicate menu entry'); + logger('add_bookmark: duplicate menu entry', LOGGER_DEBUG); if(! $r) $r = menu_add_item($menu_id,$channel_id,$iarr); return $r; diff --git a/mod/bookmarks.php b/mod/bookmarks.php index 73958ff2f..de30d9bb6 100644 --- a/mod/bookmarks.php +++ b/mod/bookmarks.php @@ -8,11 +8,12 @@ function bookmarks_init(&$a) { return; $u = $a->get_channel(); - + $i = q("select * from item where id = %d and uid = %d limit 1", intval($item_id), intval(local_user()) ); + if(! $i) return; @@ -22,16 +23,18 @@ function bookmarks_init(&$a) { $terms = get_terms_oftype($item['term'],TERM_BOOKMARK); - if($terms && (! $i[0]['item_restrict'])) { + if($terms && (! $item['item_restrict'])) { require_once('include/bookmarks.php'); - require_once('include/Contact.php'); - $s = channelx_by_hash($i[0]['author_xchan']); + + $s = q("select * from xchan where xchan_hash = '%s' limit 1", + dbesc($item['author_xchan']) + ); if(! $s) { - notice( t('Author lookup failed') . EOL); + logger('mod_bookmarks: author lookup failed.'); killme(); } foreach($terms as $t) { - bookmark_add($u,$s[0],$t,$i[0]['item_private']); + bookmark_add($u,$s[0],$t,$item['item_private']); notice( t('Bookmark added') . EOL); } } -- cgit v1.2.3 From 0844110f7b154a0fb5102362fe732c2b091222d7 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 5 Feb 2014 03:44:46 -0800 Subject: preserve system bit when editing menus --- mod/menu.php | 5 ++++- view/tpl/menuedit.tpl | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/mod/menu.php b/mod/menu.php index dd8fe8300..a2d0c2385 100644 --- a/mod/menu.php +++ b/mod/menu.php @@ -9,7 +9,9 @@ function menu_post(&$a) { $_REQUEST['menu_channel_id'] = local_user(); if($_REQUEST['menu_bookmark']) - $_REQUEST['menu_flags'] = MENU_BOOKMARK; + $_REQUEST['menu_flags'] |= MENU_BOOKMARK; + if($_REQUEST['menu_system']) + $_REQUEST['menu_flags'] |= MENU_SYSTEM; $menu_id = ((argc() > 1) ? intval(argv(1)) : 0); if($menu_id) { @@ -108,6 +110,7 @@ function menu_content(&$a) { '$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'), ''), '$menu_bookmark' => array('menu_bookmark', t('Allow bookmarks'), (($m['menu_flags'] & MENU_BOOKMARK) ? 1 : 0), t('Menu may be used to store saved bookmarks'), ''), + '$menu_system' => (($m['menu_flags'] & MENU_SYSTEM) ? 1 : 0), '$submit' => t('Modify') )); return $o; diff --git a/view/tpl/menuedit.tpl b/view/tpl/menuedit.tpl index 324dbe426..1ccfb3d68 100644 --- a/view/tpl/menuedit.tpl +++ b/view/tpl/menuedit.tpl @@ -10,6 +10,10 @@ {{if $menu_id}} {{/if}} +{{if $menu_system}} + +{{/if}} + {{include file="field_input.tpl" field=$menu_name}} {{include file="field_input.tpl" field=$menu_desc}} -- cgit v1.2.3