2013-02-26 01:09:40 +00:00
< ? php /** @file */
2010-07-20 12:21:19 +00:00
2018-10-08 02:54:25 +00:00
use Zotlabs\Lib\Apps ;
use Zotlabs\Lib\Chatroom ;
use Zotlabs\Lib\System ;
2017-01-22 12:45:34 +00:00
2017-04-28 05:37:51 +00:00
require_once ( 'include/security.php' );
require_once ( 'include/menu.php' );
2017-10-11 01:50:01 +00:00
function nav ( $template = 'default' ) {
2011-02-22 04:19:33 +00:00
2011-01-11 22:20:01 +00:00
/**
*
* Build page header and site navigation bars
*
*/
2016-03-31 23:06:03 +00:00
if ( ! ( x ( App :: $page , 'nav' )))
App :: $page [ 'nav' ] = '' ;
2010-12-17 00:35:45 +00:00
2018-05-18 23:57:45 +00:00
App :: $page [ 'htmlhead' ] .= '<script>$(document).ready(function() { $("#nav-search-text").search_autocomplete(\'' . z_root () . '/acl' . '\');});</script>' ;
2012-10-25 02:13:29 +00:00
2017-11-07 09:43:13 +00:00
$is_owner = ((( local_channel ()) && (( App :: $profile_uid == local_channel ()) || ( App :: $profile_uid == 0 ))) ? true : false );
2015-01-29 04:56:04 +00:00
if ( local_channel ()) {
2016-03-31 23:06:03 +00:00
$channel = App :: get_channel ();
$observer = App :: get_observer ();
2014-07-25 04:29:07 +00:00
$prof = q ( " select id from profile where uid = %d and is_default = 1 " ,
intval ( $channel [ 'channel_id' ])
);
2017-08-10 09:41:00 +00:00
if ( ! $_SESSION [ 'delegate' ]) {
2019-10-05 08:07:02 +00:00
$chans = q ( " select channel_name, channel_id from channel left join pconfig on channel_id = pconfig.uid where channel_account_id = %d and channel_removed = 0 and pconfig.cat = 'system' and pconfig.k = 'include_in_menu' and pconfig.v = '1' order by channel_name " ,
intval ( get_account_id ())
2017-08-10 09:41:00 +00:00
);
}
2019-10-03 23:44:52 +00:00
2017-11-07 09:43:13 +00:00
$sitelocation = (( $is_owner ) ? '' : App :: $profile [ 'reddress' ]);
2012-11-09 02:44:33 +00:00
}
2017-11-07 09:43:13 +00:00
elseif ( remote_channel ()) {
2016-03-31 23:06:03 +00:00
$observer = App :: get_observer ();
2017-11-07 09:43:13 +00:00
$sitelocation = (( App :: $profile [ 'reddress' ]) ? App :: $profile [ 'reddress' ] : '@' . App :: get_hostname ());
}
2017-03-20 16:24:48 +00:00
require_once ( 'include/conversation.php' );
2017-11-07 09:43:13 +00:00
2017-05-05 14:32:20 +00:00
$channel_apps [] = channel_apps ( $is_owner , App :: $profile [ 'channel_address' ]);
2012-09-26 00:57:20 +00:00
2018-10-14 00:53:17 +00:00
$project_icon = System :: get_project_icon ();
2018-10-08 02:54:25 +00:00
$banner = System :: get_banner ();
2014-03-03 00:46:34 +00:00
2017-10-10 14:51:35 +00:00
App :: $page [ 'header' ] .= replace_macros ( get_markup_template ( 'hdr.tpl' ), array (
//we could additionally use this to display important system notifications e.g. for updates
));
2014-03-03 00:46:34 +00:00
2011-07-14 10:05:54 +00:00
// nav links: array of array('href', 'text', 'extra css classes', 'title')
2017-03-14 17:31:19 +00:00
$nav = [];
2011-04-14 07:22:38 +00:00
2018-02-14 23:32:33 +00:00
if ( can_view_public_stream ())
2017-12-03 11:31:41 +00:00
$nav [ 'pubs' ] = true ;
2011-01-11 22:20:01 +00:00
/**
* Display login or logout
2016-08-08 00:29:35 +00:00
*/
2011-01-11 22:20:01 +00:00
2017-03-14 17:31:19 +00:00
$nav [ 'usermenu' ] = [];
2011-07-29 14:23:47 +00:00
$userinfo = null ;
2017-03-14 17:31:19 +00:00
$nav [ 'loginmenu' ] = [];
2011-07-29 14:23:47 +00:00
2017-02-03 23:31:01 +00:00
if ( $observer ) {
2017-03-14 17:31:19 +00:00
$userinfo = [
2019-10-14 19:26:12 +00:00
'icon' => $observer [ 'xchan_photo_m' ] . '?rev=' . strtotime ( $observer [ 'xchan_photo_date' ]),
2017-02-03 23:31:01 +00:00
'name' => $observer [ 'xchan_addr' ],
2017-03-14 17:31:19 +00:00
];
2017-02-03 23:31:01 +00:00
}
elseif ( ! $_SESSION [ 'authenticated' ]) {
$nav [ 'remote_login' ] = remote_login ();
$nav [ 'loginmenu' ][] = Array ( 'rmagic' , t ( 'Remote authentication' ), '' , t ( 'Click to authenticate to your home hub' ), 'rmagic_nav_btn' );
}
2015-01-29 04:56:04 +00:00
if ( local_channel ()) {
2017-10-11 08:21:00 +00:00
if ( ! $_SESSION [ 'delegate' ]) {
2019-04-05 07:54:35 +00:00
$nav [ 'manage' ] = array ( 'manage' , t ( 'Channels' ), " " , t ( 'Manage your channels' ), 'manage_nav_btn' );
2017-10-11 08:21:00 +00:00
}
2018-09-14 03:32:44 +00:00
2019-10-02 00:44:58 +00:00
$nav [ 'group' ] = array ( 'lists' , t ( 'Lists' ), " " , t ( 'Manage your access lists' ), 'group_nav_btn' );
2018-06-01 19:52:54 +00:00
2017-10-11 08:21:00 +00:00
$nav [ 'settings' ] = array ( 'settings' , t ( 'Settings' ), " " , t ( 'Account/Channel Settings' ), 'settings_nav_btn' );
2019-10-03 20:22:59 +00:00
$nav [ 'safe' ] = array ( 'safe' , t ( 'Safe Mode' ), (( get_safemode ()) ? t ( '(is on)' ) : t ( '(is off)' )) , t ( 'Content filtering' ), 'safe_nav_btn' );
2019-07-31 05:37:55 +00:00
2017-10-11 08:21:00 +00:00
2019-10-03 23:44:52 +00:00
if ( $chans && count ( $chans ) > 0 ) {
2014-08-19 03:03:48 +00:00
$nav [ 'channels' ] = $chans ;
2019-10-03 23:44:52 +00:00
}
2014-08-19 03:03:48 +00:00
2017-03-14 17:31:19 +00:00
$nav [ 'logout' ] = [ 'logout' , t ( 'Logout' ), " " , t ( 'End this session' ), 'logout_nav_btn' ];
2011-07-29 14:23:47 +00:00
// user menu
2018-07-27 09:50:04 +00:00
$nav [ 'usermenu' ][] = [ 'profile/' . $channel [ 'channel_address' ], t ( 'View Profile' ), (( \App :: $nav_sel [ 'raw_name' ] == 'Profile' ) ? 'active' : '' ), t ( 'Your profile page' ), 'profile_nav_btn' ];
2017-03-14 17:31:19 +00:00
2017-05-29 20:50:02 +00:00
if ( feature_enabled ( local_channel (), 'multi_profiles' ))
2018-07-27 09:50:04 +00:00
$nav [ 'usermenu' ][] = [ 'profiles' , t ( 'Edit Profiles' ), (( \App :: $nav_sel [ 'raw_name' ] == 'Profiles' ) ? 'active' : '' ) , t ( 'Manage/Edit profiles' ), 'profiles_nav_btn' ];
2014-07-25 04:29:07 +00:00
else
2018-07-27 09:50:04 +00:00
$nav [ 'usermenu' ][] = [ 'profiles/' . $prof [ 0 ][ 'id' ], t ( 'Edit Profile' ), (( \App :: $nav_sel [ 'raw_name' ] == 'Profiles' ) ? 'active' : '' ), t ( 'Edit your profile' ), 'profiles_nav_btn' ];
2014-06-14 13:31:36 +00:00
2010-11-09 01:30:00 +00:00
}
else {
2014-10-16 15:21:37 +00:00
if ( ! get_account_id ()) {
2017-10-14 08:17:47 +00:00
if ( App :: $module === 'channel' ) {
$nav [ 'login' ] = login ( true , 'main-login' , false , false );
$nav [ 'loginmenu' ][] = [ 'login' , t ( 'Login' ), '' , t ( 'Sign in' ), '' ];
}
else {
$nav [ 'login' ] = login ( true , 'main-login' , false , false );
$nav [ 'loginmenu' ][] = [ 'login' , t ( 'Login' ), '' , t ( 'Sign in' ), 'login_nav_btn' ];
App :: $page [ 'content' ] .= replace_macros ( get_markup_template ( 'nav_login.tpl' ),
[
'$nav' => $nav ,
'userinfo' => $userinfo
]
);
}
2014-10-16 15:21:37 +00:00
}
2013-01-27 09:19:24 +00:00
else
2017-03-14 17:31:19 +00:00
$nav [ 'alogout' ] = [ 'logout' , t ( 'Logout' ), " " , t ( 'End this session' ), 'logout_nav_btn' ];
2013-01-27 09:19:24 +00:00
2010-11-09 01:30:00 +00:00
}
2010-07-20 12:21:19 +00:00
2017-12-14 20:48:30 +00:00
$my_url = get_my_url ();
if ( ! $my_url ) {
2016-03-31 23:06:03 +00:00
$observer = App :: get_observer ();
2017-12-14 20:48:30 +00:00
$my_url = (( $observer ) ? $observer [ 'xchan_url' ] : '' );
2013-07-18 18:01:03 +00:00
}
2011-01-05 09:53:34 +00:00
2017-12-14 20:48:30 +00:00
$homelink_arr = parse_url ( $my_url );
$homelink = $homelink_arr [ 'scheme' ] . '://' . $homelink_arr [ 'host' ];
2017-07-25 18:06:01 +00:00
if ( ! $is_owner ) {
2016-11-20 14:38:36 +00:00
$nav [ 'rusermenu' ] = array (
$homelink ,
2017-03-10 01:43:16 +00:00
t ( 'Take me home' ),
2016-11-20 14:38:36 +00:00
'logout' ,
2017-07-25 18:06:01 +00:00
(( local_channel ()) ? t ( 'Logout' ) : t ( 'Log me out of this site' ))
2016-11-20 14:38:36 +00:00
);
}
2011-01-11 22:20:01 +00:00
2016-09-04 23:38:35 +00:00
if ((( get_config ( 'system' , 'register_policy' ) == REGISTER_OPEN ) || ( get_config ( 'system' , 'register_policy' ) == REGISTER_APPROVE )) && ( ! $_SESSION [ 'authenticated' ]))
2017-03-14 17:31:19 +00:00
$nav [ 'register' ] = [ 'register' , t ( 'Register' ), " " , t ( 'Create an account' ), 'register_nav_btn' ];
2010-07-29 01:24:07 +00:00
2018-08-01 00:27:50 +00:00
if ( ! get_config ( 'system' , 'hide_help' , true )) {
2016-04-23 14:39:56 +00:00
$help_url = z_root () . '/help?f=&cmd=' . App :: $cmd ;
2016-04-21 21:03:09 +00:00
$context_help = '' ;
$enable_context_help = (( intval ( get_config ( 'system' , 'enable_context_help' )) === 1 || get_config ( 'system' , 'enable_context_help' ) === false ) ? true : false );
if ( $enable_context_help === true ) {
require_once ( 'include/help.php' );
$context_help = load_context_help ();
2016-04-23 14:39:56 +00:00
//point directly to /help if $context_help is empty - this can be removed once we have context help for all modules
2016-04-21 21:03:09 +00:00
$enable_context_help = (( $context_help ) ? true : false );
}
2017-03-14 17:31:19 +00:00
$nav [ 'help' ] = [ $help_url , t ( 'Help' ), " " , t ( 'Help and documentation' ), 'help_nav_btn' , $context_help , $enable_context_help ];
2016-03-21 10:33:02 +00:00
}
2014-05-22 00:23:34 +00:00
2018-05-30 20:40:22 +00:00
2019-07-26 01:48:35 +00:00
$search_form_action = 'search' ;
2018-05-30 20:40:22 +00:00
2019-07-26 01:48:35 +00:00
$nav [ 'search' ] = [ 'search' , t ( 'Search' ), " " , t ( 'Search site @name, #tag, content' ), $search_form_action ];
2013-01-19 09:07:35 +00:00
2011-06-13 10:52:52 +00:00
/**
* Admin page
*/
2017-07-28 20:42:02 +00:00
if ( is_site_admin ()) {
2014-12-12 15:27:45 +00:00
$nav [ 'admin' ] = array ( 'admin/' , t ( 'Admin' ), " " , t ( 'Site Setup and Configuration' ), 'admin_nav_btn' );
2011-06-13 10:52:52 +00:00
}
2013-11-29 04:17:07 +00:00
$x = array ( 'nav' => $nav , 'usermenu' => $userinfo );
2017-03-14 17:31:19 +00:00
2013-11-29 04:17:07 +00:00
call_hooks ( 'nav' , $x );
2017-01-22 09:20:39 +00:00
// Not sure the best place to put this on the page. So I'm implementing it but leaving it
// turned off until somebody discovers this and figures out a good location for it.
$powered_by = '' ;
2014-09-30 04:58:35 +00:00
2017-10-10 14:51:35 +00:00
if ( App :: $profile_uid && App :: $nav_sel [ 'raw_name' ]) {
$active_app = q ( " SELECT app_url FROM app WHERE app_channel = %d AND app_name = '%s' LIMIT 1 " ,
intval ( App :: $profile_uid ),
dbesc ( App :: $nav_sel [ 'raw_name' ])
);
if ( $active_app ) {
$url = $active_app [ 0 ][ 'app_url' ];
}
2017-10-09 19:22:57 +00:00
}
2018-12-13 03:04:14 +00:00
$pinned_list = [];
$syslist = [];
2017-01-22 12:45:34 +00:00
//app bin
2017-07-25 18:06:01 +00:00
if ( $is_owner ) {
2018-07-06 05:27:44 +00:00
if ( get_pconfig ( local_channel (), 'system' , 'import_system_apps' ) !== datetime_convert ( 'UTC' , 'UTC' , 'now' , 'Y-m-d' )) {
2018-09-12 18:52:55 +00:00
Apps :: import_system_apps ();
2018-07-06 05:27:44 +00:00
set_pconfig ( local_channel (), 'system' , 'import_system_apps' , datetime_convert ( 'UTC' , 'UTC' , 'now' , 'Y-m-d' ));
2017-02-06 12:45:46 +00:00
}
2018-12-13 03:04:14 +00:00
$list = Apps :: app_list ( local_channel (), false , [ 'nav_pinned_app' ]);
if ( $list ) {
foreach ( $list as $li ) {
$pinned_list [] = Apps :: app_encode ( $li );
}
}
Apps :: translate_system_apps ( $pinned_list );
usort ( $pinned_list , 'Zotlabs\\Lib\\Apps::app_name_compare' );
$pinned_list = Apps :: app_order ( local_channel (), $pinned_list , 'nav_pinned_app' );
$syslist = [];
$list = Apps :: app_list ( local_channel (), false , [ 'nav_featured_app' ]);
2018-09-19 03:51:38 +00:00
2017-02-01 11:59:56 +00:00
if ( $list ) {
foreach ( $list as $li ) {
2018-09-12 18:52:55 +00:00
$syslist [] = Apps :: app_encode ( $li );
2017-01-22 12:45:34 +00:00
}
}
2018-09-12 18:52:55 +00:00
Apps :: translate_system_apps ( $syslist );
2018-12-13 03:04:14 +00:00
2017-02-01 11:59:56 +00:00
}
else {
2018-09-12 18:52:55 +00:00
$syslist = Apps :: get_system_apps ( true );
2017-01-22 12:45:34 +00:00
}
2017-02-07 21:32:25 +00:00
usort ( $syslist , 'Zotlabs\\Lib\\Apps::app_name_compare' );
2018-12-13 03:04:14 +00:00
$syslist = Apps :: app_order ( local_channel (), $syslist , 'nav_featured_app' );
2017-05-17 05:57:34 +00:00
2018-12-13 03:04:14 +00:00
if ( $pinned_list ) {
foreach ( $pinned_list as $app ) {
if ( \App :: $nav_sel [ 'name' ] == $app [ 'name' ])
$app [ 'active' ] = true ;
2017-07-26 19:42:07 +00:00
2018-12-13 03:04:14 +00:00
if ( $is_owner ) {
2018-09-12 18:52:55 +00:00
$navbar_apps [] = Apps :: app_render ( $app , 'navbar' );
2017-10-09 02:43:03 +00:00
}
2018-12-13 03:04:14 +00:00
elseif ( ! $is_owner && strpos ( $app [ 'requires' ], 'local_channel' ) === false ) {
$navbar_apps [] = Apps :: app_render ( $app , 'navbar' );
2017-11-16 10:11:06 +00:00
}
2017-10-09 02:43:03 +00:00
}
2018-12-13 03:04:14 +00:00
}
if ( $syslist ) {
foreach ( $syslist as $app ) {
if ( \App :: $nav_sel [ 'name' ] == $app [ 'name' ])
$app [ 'active' ] = true ;
if ( $is_owner ) {
2019-10-03 04:38:32 +00:00
$nav_apps [] = Apps :: app_render ( $app , 'nav' );
2017-10-09 02:43:03 +00:00
}
2018-12-13 03:04:14 +00:00
elseif ( ! $is_owner && strpos ( $app [ 'requires' ], 'local_channel' ) === false ) {
2019-10-03 04:38:32 +00:00
$nav_apps [] = Apps :: app_render ( $app , 'nav' );
2017-11-16 10:11:06 +00:00
}
2017-10-09 02:43:03 +00:00
}
2017-02-06 19:10:10 +00:00
}
2017-02-01 11:59:56 +00:00
2017-10-09 22:13:25 +00:00
$c = theme_include ( 'navbar_' . purify_filename ( $template ) . '.css' );
$tpl = get_markup_template ( 'navbar_' . purify_filename ( $template ) . '.tpl' );
2017-10-08 23:48:24 +00:00
if ( $c && $tpl ) {
head_add_css ( 'navbar_' . $template . '.css' );
}
if ( ! $tpl ) {
2017-10-11 01:50:01 +00:00
$tpl = get_markup_template ( 'navbar_default.tpl' );
2017-10-08 23:48:24 +00:00
}
2011-04-14 07:22:38 +00:00
2016-03-31 23:06:03 +00:00
App :: $page [ 'nav' ] .= replace_macros ( $tpl , array (
2016-04-23 14:39:56 +00:00
'$baseurl' => z_root (),
2018-10-14 00:53:17 +00:00
'$project_icon' => $project_icon ,
'$project_title' => t ( 'Powered by $Projectname' ),
2017-02-17 14:07:20 +00:00
'$fulldocs' => t ( 'Help' ),
2011-04-14 07:22:38 +00:00
'$sitelocation' => $sitelocation ,
2013-11-29 04:17:07 +00:00
'$nav' => $x [ 'nav' ],
2011-04-14 07:22:38 +00:00
'$banner' => $banner ,
2017-12-11 15:50:25 +00:00
'$emptynotifications' => t ( 'Loading' ),
2013-11-29 04:17:07 +00:00
'$userinfo' => $x [ 'usermenu' ],
2015-01-29 04:56:04 +00:00
'$localuser' => local_channel (),
2017-07-25 18:06:01 +00:00
'$is_owner' => $is_owner ,
2017-10-09 19:22:57 +00:00
'$sel' => App :: $nav_sel ,
2014-09-30 04:58:35 +00:00
'$powered_by' => $powered_by ,
2019-07-26 01:48:35 +00:00
'$help' => t ( '@name, #tag, content' ),
2017-01-22 12:45:34 +00:00
'$pleasewait' => t ( 'Please wait...' ),
2017-05-05 14:32:20 +00:00
'$nav_apps' => $nav_apps ,
2017-10-09 02:43:03 +00:00
'$navbar_apps' => $navbar_apps ,
2017-10-31 03:43:24 +00:00
'$channel_menu' => get_pconfig ( App :: $profile_uid , 'system' , 'channel_menu' , get_config ( 'system' , 'channel_menu' )),
2017-10-05 23:59:33 +00:00
'$channel_thumb' => (( App :: $profile ) ? App :: $profile [ 'thumb' ] : '' ),
2017-05-05 14:32:20 +00:00
'$channel_apps' => $channel_apps ,
2018-07-20 03:44:34 +00:00
'$addapps' => t ( 'Add/Manage Apps' ),
2017-05-23 00:07:34 +00:00
'$orderapps' => t ( 'Arrange Apps' ),
2017-10-08 15:19:29 +00:00
'$sysapps_toggle' => t ( 'Toggle System Apps' ),
2017-10-10 14:51:35 +00:00
'$url' => (( $url ) ? $url : App :: $cmd )
2016-04-23 14:39:56 +00:00
));
2010-12-30 22:36:35 +00:00
2016-07-03 12:21:48 +00:00
if ( x ( $_SESSION , 'reload_avatar' ) && $observer ) {
// The avatar has been changed on the server but the browser doesn't know that,
// force the browser to reload the image from the server instead of its cache.
$tpl = get_markup_template ( 'force_image_reload.tpl' );
App :: $page [ 'nav' ] .= replace_macros ( $tpl , array (
'$imgUrl' => $observer [ 'xchan_photo_m' ]
));
unset ( $_SESSION [ 'reload_avatar' ]);
}
2016-03-31 23:06:03 +00:00
call_hooks ( 'page_header' , App :: $page [ 'nav' ]);
2011-08-17 16:36:24 +00:00
}
2011-02-22 04:19:33 +00:00
2011-08-17 16:36:24 +00:00
/*
* Set a menu item in navbar as selected
*
*/
function nav_set_selected ( $item ){
2017-10-09 19:22:57 +00:00
App :: $nav_sel [ 'raw_name' ] = $item ;
$item = [ 'name' => $item ];
2018-09-12 18:52:55 +00:00
Apps :: translate_system_apps ( $item );
2017-10-09 19:22:57 +00:00
App :: $nav_sel [ 'name' ] = $item [ 'name' ];
2011-02-22 04:19:33 +00:00
}
2017-04-28 05:37:51 +00:00
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 [] = [
2017-11-07 10:22:11 +00:00
'label' => t ( 'Calendar' ),
2017-04-28 05:37:51 +00:00
'url' => z_root () . $cal_link ,
2017-11-07 10:22:11 +00:00
'sel' => (( argv ( 0 ) == 'cal' ) ? 'active' : '' ),
'title' => t ( 'Calendar' ),
2017-04-28 05:37:51 +00:00
'id' => 'event-tab' ,
'icon' => 'calendar'
];
}
2018-09-13 09:32:43 +00:00
if ( $p [ 'chat' ] && Apps :: system_app_installed ( $uid , 'Chatrooms' )) {
2018-09-12 18:52:55 +00:00
$has_chats = Chatroom :: list_count ( $uid );
2017-04-28 05:37:51 +00:00
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'
];
}
2018-09-12 18:52:55 +00:00
if ( $p [ 'view_pages' ] && Apps :: system_app_installed ( $uid , 'Cards' )) {
2017-08-23 07:01:02 +00:00
$tabs [] = [
'label' => t ( 'Cards' ),
'url' => z_root () . '/cards/' . $nickname ,
'sel' => (( argv ( 0 ) == 'cards' ) ? 'active' : '' ),
'title' => t ( 'View Cards' ),
'id' => 'cards-tab' ,
'icon' => 'list'
];
}
2018-09-12 18:52:55 +00:00
if ( $p [ 'view_pages' ] && Apps :: system_app_installed ( $uid , 'Articles' )) {
2017-11-22 23:39:06 +00:00
$tabs [] = [
'label' => t ( 'Articles' ),
'url' => z_root () . '/articles/' . $nickname ,
'sel' => (( argv ( 0 ) == 'articles' ) ? 'active' : '' ),
'title' => t ( 'View Articles' ),
'id' => 'articles-tab' ,
'icon' => 'file-text-o'
];
}
2017-08-23 07:01:02 +00:00
2018-09-12 18:52:55 +00:00
if ( $has_webpages && Apps :: system_app_installed ( $uid , 'Webpages' )) {
2017-04-28 05:37:51 +00:00
$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'
];
}
2018-09-12 18:52:55 +00:00
if ( $p [ 'view_wiki' ] && Apps :: system_app_installed ( $uid , 'Wiki' )) {
$tabs [] = [
'label' => t ( 'Wikis' ),
'url' => z_root () . '/wiki/' . $nickname ,
'sel' => (( argv ( 0 ) == 'wiki' ) ? 'active' : '' ),
'title' => t ( 'Wiki' ),
'id' => 'wiki-tab' ,
'icon' => 'pencil-square-o'
];
2018-09-19 03:51:38 +00:00
2017-04-28 05:37:51 +00:00
}
$arr = array ( 'is_owner' => $is_owner , 'nickname' => $nickname , 'tab' => (( $tab ) ? $tab : false ), 'tabs' => $tabs );
2018-09-13 08:59:37 +00:00
2017-04-28 05:37:51 +00:00
call_hooks ( 'channel_apps' , $arr );
return replace_macros ( get_markup_template ( 'profile_tabs.tpl' ),
[
'$tabs' => $arr [ 'tabs' ],
'$name' => App :: $profile [ 'channel_name' ],
2017-10-05 23:59:33 +00:00
'$thumb' => App :: $profile [ 'thumb' ],
2017-04-28 05:37:51 +00:00
]
);
2017-05-05 14:32:20 +00:00
}