From 033cf6138071c1707b3bb448524761f086b8a445 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 27 Apr 2017 22:37:51 -0700 Subject: profile_tabs is now channel_apps (except the original was left behind as the gitwiki addon still uses it). A couple of things were modernised but basic functionality is the same as the latest revisions to the original. --- include/nav.php | 173 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 171 insertions(+), 2 deletions(-) (limited to 'include/nav.php') diff --git a/include/nav.php b/include/nav.php index 2d12f2950..fecf28548 100644 --- a/include/nav.php +++ b/include/nav.php @@ -2,6 +2,10 @@ use \Zotlabs\Lib as Zlib; +require_once('include/security.php'); +require_once('include/menu.php'); + + function nav() { /** @@ -38,8 +42,8 @@ EOT; $observer = App::get_observer(); require_once('include/conversation.php'); - $is_owner = (((local_channel()) && (\App::$profile['profile_uid'] == local_channel())) ? true : false); - $navapps[] = profile_tabs($a, $is_owner, \App::$profile['channel_address']); + $is_owner = (((local_channel()) && (App::$profile['profile_uid'] == local_channel())) ? true : false); + $navapps[] = channel_apps($is_owner, App::$profile['channel_address']); $myident = (($channel) ? $channel['xchan_addr'] : ''); @@ -312,3 +316,168 @@ function nav_set_selected($item){ ); App::$nav_sel[$item] = 'active'; } + + + +function channel_apps($is_owner = false, $nickname = null) { + + // Don't provide any channel apps if we're running as the sys channel + + if(App::$is_sys) + return ''; + + if(! get_pconfig($uid, 'system', 'channelapps','1')) + return ''; + + $channel = App::get_channel(); + + if($channel && is_null($nickname)) + $nickname = $channel['channel_address']; + + $uid = ((App::$profile['profile_uid']) ? App::$profile['profile_uid'] : local_channel()); + $account_id = ((App::$profile['profile_uid']) ? App::$profile['channel_account_id'] : App::$channel['channel_account_id']); + + if($uid == local_channel()) { + return; + } + else { + $cal_link = '/cal/' . $nickname; + } + + $sql_options = item_permissions_sql($uid); + + $r = q("select item.* from item left join iconfig on item.id = iconfig.iid + where item.uid = %d and iconfig.cat = 'system' and iconfig.v = '%s' + and item.item_delayed = 0 and item.item_deleted = 0 + and ( iconfig.k = 'WEBPAGE' and item_type = %d ) + $sql_options limit 1", + intval($uid), + dbesc('home'), + intval(ITEM_TYPE_WEBPAGE) + ); + + $has_webpages = (($r) ? true : false); + + if(x($_GET, 'tab')) + $tab = notags(trim($_GET['tab'])); + + $url = z_root() . '/channel/' . $nickname; + $pr = z_root() . '/profile/' . $nickname; + + $tabs = [ + [ + 'label' => t('Channel'), + 'url' => $url, + 'sel' => ((argv(0) == 'channel') ? 'active' : ''), + 'title' => t('Status Messages and Posts'), + 'id' => 'status-tab', + 'icon' => 'home' + ], + ]; + + $p = get_all_perms($uid,get_observer_hash()); + + if ($p['view_profile']) { + $tabs[] = [ + 'label' => t('About'), + 'url' => $pr, + 'sel' => ((argv(0) == 'profile') ? 'active' : ''), + 'title' => t('Profile Details'), + 'id' => 'profile-tab', + 'icon' => 'user' + ]; + } + if ($p['view_storage']) { + $tabs[] = [ + 'label' => t('Photos'), + 'url' => z_root() . '/photos/' . $nickname, + 'sel' => ((argv(0) == 'photos') ? 'active' : ''), + 'title' => t('Photo Albums'), + 'id' => 'photo-tab', + 'icon' => 'photo' + ]; + $tabs[] = [ + 'label' => t('Files'), + 'url' => z_root() . '/cloud/' . $nickname, + 'sel' => ((argv(0) == 'cloud' || argv(0) == 'sharedwithme') ? 'active' : ''), + 'title' => t('Files and Storage'), + 'id' => 'files-tab', + 'icon' => 'folder-open' + ]; + } + + if($p['view_stream'] && $cal_link) { + $tabs[] = [ + 'label' => t('Events'), + 'url' => z_root() . $cal_link, + 'sel' => ((argv(0) == 'cal' || argv(0) == 'events') ? 'active' : ''), + 'title' => t('Events'), + 'id' => 'event-tab', + 'icon' => 'calendar' + ]; + } + + + if ($p['chat'] && feature_enabled($uid,'ajaxchat')) { + $has_chats = ZLib\Chatroom::list_count($uid); + if ($has_chats) { + $tabs[] = [ + 'label' => t('Chatrooms'), + 'url' => z_root() . '/chat/' . $nickname, + 'sel' => ((argv(0) == 'chat') ? 'active' : '' ), + 'title' => t('Chatrooms'), + 'id' => 'chat-tab', + 'icon' => 'comments-o' + ]; + } + } + + $has_bookmarks = menu_list_count(local_channel(),'',MENU_BOOKMARK) + menu_list_count(local_channel(),'',MENU_SYSTEM|MENU_BOOKMARK); + if ($is_owner && $has_bookmarks) { + $tabs[] = [ + 'label' => t('Bookmarks'), + 'url' => z_root() . '/bookmarks', + 'sel' => ((argv(0) == 'bookmarks') ? 'active' : ''), + 'title' => t('Saved Bookmarks'), + 'id' => 'bookmarks-tab', + 'icon' => 'bookmark' + ]; + } + + if($has_webpages && feature_enabled($uid,'webpages')) { + $tabs[] = [ + 'label' => t('Webpages'), + 'url' => z_root() . '/page/' . $nickname . '/home', + 'sel' => ((argv(0) == 'webpages') ? 'active' : ''), + 'title' => t('View Webpages'), + 'id' => 'webpages-tab', + 'icon' => 'newspaper-o' + ]; + } + + + if ($p['view_wiki']) { + if(feature_enabled($uid,'wiki') && (get_account_techlevel($account_id) > 3)) { + $tabs[] = [ + 'label' => t('Wikis'), + 'url' => z_root() . '/wiki/' . $nickname, + 'sel' => ((argv(0) == 'wiki') ? 'active' : ''), + 'title' => t('Wiki'), + 'id' => 'wiki-tab', + 'icon' => 'pencil-square-o' + ]; + } + } + + $arr = array('is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => (($tab) ? $tab : false), 'tabs' => $tabs); + call_hooks('profile_tabs', $arr); + call_hooks('channel_apps', $arr); + + return replace_macros(get_markup_template('profile_tabs.tpl'), + [ + '$tabs' => $arr['tabs'], + '$name' => App::$profile['channel_name'], + '$thumb' => App::$profile['thumb'] + ] + ); +} \ No newline at end of file -- cgit v1.2.3 From 21103f8bc4d4a54211ba4edaefc1bce694a8fa05 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 16 May 2017 22:57:34 -0700 Subject: provide mechanism to arbitrarily sort the nav tray apps, currently the preferred order list needs to be manually created --- include/nav.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/nav.php') diff --git a/include/nav.php b/include/nav.php index 849e19d9a..0fd555abf 100644 --- a/include/nav.php +++ b/include/nav.php @@ -257,6 +257,8 @@ EOT; usort($syslist,'Zotlabs\\Lib\\Apps::app_name_compare'); + $syslist = Zlib\Apps::app_order(local_channel(),$syslist); + foreach($syslist as $app) { $nav_apps[] = Zlib\Apps::app_render($app,'nav'); } -- cgit v1.2.3 From 7ae0317b6a2bed323492ef987ddbaaf4f2a1a9b9 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 22 May 2017 17:07:34 -0700 Subject: apporder style improvement and add to nav menu, also add language awareness to webpages --- include/nav.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include/nav.php') diff --git a/include/nav.php b/include/nav.php index 0fd555abf..91bade5a7 100644 --- a/include/nav.php +++ b/include/nav.php @@ -281,6 +281,7 @@ EOT; '$nav_apps' => $nav_apps, '$channel_apps' => $channel_apps, '$addapps' => t('Add Apps'), + '$orderapps' => t('Arrange Apps'), '$sysapps_toggle' => t('Toggle System Apps') )); -- cgit v1.2.3 From 4fcfcc81172ebdfa4a27d3bca94bffe97356f600 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 29 May 2017 13:50:02 -0700 Subject: start deprecation of server_role --- include/nav.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'include/nav.php') diff --git a/include/nav.php b/include/nav.php index 91bade5a7..4d6c479da 100644 --- a/include/nav.php +++ b/include/nav.php @@ -65,8 +65,6 @@ EOT; //we could additionally use this to display important system notifications e.g. for updates )); - $server_role = get_config('system','server_role'); - $basic = (($server_role === 'basic') ? true : false); $techlevel = get_account_techlevel(); // nav links: array of array('href', 'text', 'extra css classes', 'title') @@ -97,7 +95,7 @@ EOT; if(local_channel()) { - if($chans && count($chans) > 1 && feature_enabled(local_channel(),'nav_channel_select') && (! $basic)) + if($chans && count($chans) > 1 && feature_enabled(local_channel(),'nav_channel_select')) $nav['channels'] = $chans; $nav['logout'] = ['logout',t('Logout'), "", t('End this session'),'logout_nav_btn']; @@ -105,7 +103,7 @@ EOT; // user menu $nav['usermenu'][] = ['profile/' . $channel['channel_address'], t('View Profile'), "", t('Your profile page'),'profile_nav_btn']; - if(feature_enabled(local_channel(),'multi_profiles') && (! $basic)) + if(feature_enabled(local_channel(),'multi_profiles')) $nav['usermenu'][] = ['profiles', t('Edit Profiles'),"", t('Manage/Edit profiles'),'profiles_nav_btn']; else $nav['usermenu'][] = ['profiles/' . $prof[0]['id'], t('Edit Profile'),"", t('Edit your profile'),'profiles_nav_btn']; @@ -201,8 +199,7 @@ EOT; $nav['all_events']['all']=array('events', t('View events'), "", ""); $nav['all_events']['mark'] = array('', t('Mark all events seen'), '',''); - if(! $basic) - $nav['manage'] = array('manage', t('Channel Manager'), "", t('Manage Your Channels'),'manage_nav_btn'); + $nav['manage'] = array('manage', t('Channel Manager'), "", t('Manage Your Channels'),'manage_nav_btn'); $nav['settings'] = array('settings', t('Settings'),"", t('Account/Channel Settings'),'settings_nav_btn'); -- cgit v1.2.3