streams/Zotlabs/Widget/Settings_menu.php

128 lines
3 KiB
PHP
Raw Normal View History

2017-03-16 03:56:12 +00:00
<?php
namespace Zotlabs\Widget;
2019-10-10 05:51:48 +00:00
use App;
use Zotlabs\Lib\Apps;
2017-03-16 03:56:12 +00:00
class Settings_menu {
function widget($arr) {
if(! local_channel())
return;
2019-10-10 05:51:48 +00:00
$channel = App::get_channel();
2017-03-16 03:56:12 +00:00
$abook_self_id = 0;
// Retrieve the 'self' address book entry for use in the auto-permissions link
$role = get_pconfig(local_channel(),'system','permissions_role');
$abk = q("select abook_id from abook where abook_channel = %d and abook_self = 1 limit 1",
intval(local_channel())
);
if($abk)
$abook_self_id = $abk[0]['abook_id'];
$x = q("select count(*) as total from hubloc where hubloc_hash = '%s' and hubloc_deleted = 0 ",
dbesc($channel['channel_hash'])
);
$hublocs = (($x && $x[0]['total'] > 1) ? true : false);
$tabs = array(
array(
'label' => t('Account settings'),
'url' => z_root().'/settings/account',
'selected' => ((argv(1) === 'account') ? 'active' : ''),
),
array(
'label' => t('Channel settings'),
'url' => z_root().'/settings/channel',
'selected' => ((argv(1) === 'channel') ? 'active' : ''),
),
);
$tabs[] = array(
'label' => t('Display settings'),
'url' => z_root().'/settings/display',
'selected' => ((argv(1) === 'display') ? 'active' : ''),
);
if($hublocs) {
$tabs[] = array(
'label' => t('Manage locations'),
'url' => z_root() . '/locs',
'selected' => ((argv(1) === 'locs') ? 'active' : ''),
);
}
$tabs[] = array(
'label' => t('Export channel'),
'url' => z_root() . '/uexport',
'selected' => ''
);
if(feature_enabled(local_channel(),'oauth_clients')) {
$tabs[] = array(
2018-04-06 04:01:36 +00:00
'label' => t('OAuth1 apps'),
'url' => z_root() . '/settings/oauth',
'selected' => ((argv(1) === 'oauth') ? 'active' : ''),
);
}
2017-03-16 03:56:12 +00:00
2019-10-10 05:51:48 +00:00
if(Apps::system_app_installed(local_channel(),'Clients')) {
2018-04-06 04:01:36 +00:00
$tabs[] = array(
2019-10-10 05:51:48 +00:00
'label' => t('Client apps'),
2018-04-06 04:01:36 +00:00
'url' => z_root() . '/settings/oauth2',
'selected' => ((argv(1) === 'oauth2') ? 'active' : ''),
);
}
if(feature_enabled(local_channel(),'access_tokens')) {
2017-03-16 03:56:12 +00:00
$tabs[] = array(
'label' => t('Guest Access Tokens'),
'url' => z_root() . '/settings/tokens',
'selected' => ((argv(1) === 'tokens') ? 'active' : ''),
);
}
if(feature_enabled(local_channel(),'permcats')) {
$tabs[] = array(
'label' => t('Permission Categories'),
2017-03-16 03:56:12 +00:00
'url' => z_root() . '/settings/permcats',
'selected' => ((argv(1) === 'permcats') ? 'active' : ''),
);
}
if($role === false || $role === 'custom') {
$tabs[] = array(
'label' => t('Connection Default Permissions'),
'url' => z_root() . '/defperms',
2017-03-16 03:56:12 +00:00
'selected' => ''
);
}
if(feature_enabled(local_channel(),'channel_sources')) {
$tabs[] = array(
'label' => t('Channel Sources'),
'url' => z_root() . '/sources',
'selected' => ''
);
}
$tabtpl = get_markup_template("generic_links_widget.tpl");
return replace_macros($tabtpl, array(
'$title' => t('Settings'),
'$class' => 'settings-widget',
'$items' => $tabs,
));
}
}