show bookmarks menu only if we have any bookmarks already

This commit is contained in:
marijus 2014-09-20 16:31:56 +02:00
parent 9feb619bea
commit bd54358aa6
3 changed files with 20 additions and 3 deletions

View File

@ -1556,7 +1556,9 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
); );
} }
if($is_owner) { require_once('include/menu.php');
$has_bookmarks = menu_list_count(local_user(),'',MENU_BOOKMARK) + menu_list_count(local_user(),'',MENU_SYSTEM|MENU_BOOKMARK);
if($is_owner && $has_bookmarks) {
$tabs[] = array( $tabs[] = array(
'label' => t('Bookmarks'), 'label' => t('Bookmarks'),
'url' => $a->get_baseurl() . '/bookmarks', 'url' => $a->get_baseurl() . '/bookmarks',

View File

@ -124,7 +124,17 @@ function menu_list($channel_id, $name = '', $flags = 0) {
return $r; return $r;
} }
function menu_list_count($channel_id, $name = '', $flags = 0) {
$sel_options = '';
$sel_options .= (($name) ? " and menu_name = '" . protect_sprintf(dbesc($name)) . "' " : '');
$sel_options .= (($flags) ? " and menu_flags = " . intval($flags) . " " : '');
$r = q("select count(*) as total from menu where menu_channel_id = %d $sel_options",
intval($channel_id)
);
return $r[0]['total'];
}
function menu_edit($arr) { function menu_edit($arr) {

View File

@ -110,9 +110,14 @@ EOT;
$nav['usermenu'][] = Array('chat/' . $channel['channel_address'],t('Chat'),"",t('Your chatrooms')); $nav['usermenu'][] = Array('chat/' . $channel['channel_address'],t('Chat'),"",t('Your chatrooms'));
} }
$nav['usermenu'][] = Array('bookmarks', t('Bookmarks'), "", t('Your bookmarks')); require_once('include/menu.php');
$has_bookmarks = menu_list_count(local_user(),'',MENU_BOOKMARK) + menu_list_count(local_user(),'',MENU_SYSTEM|MENU_BOOKMARK);
if($has_bookmarks) {
$nav['usermenu'][] = Array('bookmarks', t('Bookmarks'), "", t('Your bookmarks'));
}
if(feature_enabled($channel['channel_id'],'webpages')) if(feature_enabled($channel['channel_id'],'webpages'))
$nav['usermenu'][] = Array('webpages/' . $channel['channel_address'],t('Webpages'),"",t('Your webpages')); $nav['usermenu'][] = Array('webpages/' . $channel['channel_address'],t('Webpages'),"",t('Your webpages'));
} }
else { else {
if(! get_account_id()) if(! get_account_id())