aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-09-20 16:22:21 -0700
committerfriendica <info@friendica.com>2014-09-20 16:22:21 -0700
commit44cb423f21b6a34a138e7ffd2814fdd08788cfbe (patch)
treebbd84e79b59b3e6ccd848758a65aeae9033d37fa /include
parent8d23a8da8dd7326d6ce9c3a64f96e5325a09d4a1 (diff)
parenta1773fea2529e6e3b1dcc816e948dacb4a250705 (diff)
downloadvolse-hubzilla-44cb423f21b6a34a138e7ffd2814fdd08788cfbe.tar.gz
volse-hubzilla-44cb423f21b6a34a138e7ffd2814fdd08788cfbe.tar.bz2
volse-hubzilla-44cb423f21b6a34a138e7ffd2814fdd08788cfbe.zip
Merge https://github.com/friendica/red into pending_merge
Diffstat (limited to 'include')
-rw-r--r--include/chat.php11
-rw-r--r--include/conversation.php8
-rw-r--r--include/menu.php10
-rw-r--r--include/nav.php13
4 files changed, 35 insertions, 7 deletions
diff --git a/include/chat.php b/include/chat.php
index b8fb185df..5c3d0c9d9 100644
--- a/include/chat.php
+++ b/include/chat.php
@@ -189,6 +189,17 @@ function chatroom_list($uid) {
return $r;
}
+function chatroom_list_count($uid) {
+ require_once('include/security.php');
+ $sql_extra = permissions_sql($uid);
+
+ $r = q("select count(*) as total from chatroom where cr_uid = %d $sql_extra",
+ intval($uid)
+ );
+
+ return $r[0]['total'];
+}
+
/**
* create a chat message via API.
* It is the caller's responsibility to enter the room.
diff --git a/include/conversation.php b/include/conversation.php
index a4d94f946..4c030662c 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -1552,8 +1552,8 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
}
require_once('include/chat.php');
- $chats = chatroom_list($uid);
- if (count($chats)) {
+ $has_chats = chatroom_list_count($uid);
+ if ($has_chats) {
$tabs[] = array(
'label' => t('Chatrooms'),
'url' => $a->get_baseurl() . '/chat/' . $nickname,
@@ -1563,7 +1563,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(
'label' => t('Bookmarks'),
'url' => $a->get_baseurl() . '/bookmarks',
diff --git a/include/menu.php b/include/menu.php
index 4b0a11f10..8997d2e39 100644
--- a/include/menu.php
+++ b/include/menu.php
@@ -124,7 +124,17 @@ function menu_list($channel_id, $name = '', $flags = 0) {
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) {
diff --git a/include/nav.php b/include/nav.php
index 799faf5ce..714f4b63d 100644
--- a/include/nav.php
+++ b/include/nav.php
@@ -105,14 +105,19 @@ EOT;
$nav['usermenu'][] = Array('cloud/' . $channel['channel_address'],t('Files'),"",t('Your files'));
require_once('include/chat.php');
- $chats = chatroom_list(local_user());
- if (count($chats)) {
+ $has_chats = chatroom_list_count(local_user());
+ if($has_chats) {
$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'))
- $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 {
if(! get_account_id())