streams/Code/Widget/Settings_menu.php

135 lines
3.8 KiB
PHP
Raw Normal View History

2017-03-16 03:56:12 +00:00
<?php
2022-02-16 04:08:28 +00:00
namespace Code\Widget;
2017-03-16 03:56:12 +00:00
2019-10-10 05:51:48 +00:00
use App;
2022-02-16 04:08:28 +00:00
use Code\Lib\Apps;
use Code\Render\Theme;
2022-02-12 20:43:29 +00:00
2019-10-10 05:51:48 +00:00
2022-10-23 21:18:44 +00:00
class Settings_menu implements WidgetInterface
2021-12-02 23:02:31 +00:00
{
2017-03-16 03:56:12 +00:00
2022-10-24 03:39:49 +00:00
public function widget(array $arguments): string
2021-12-02 23:02:31 +00:00
{
2017-03-16 03:56:12 +00:00
2021-12-03 03:01:39 +00:00
if (!local_channel()) {
2022-10-03 09:54:13 +00:00
return '';
2021-12-03 03:01:39 +00:00
}
2017-03-16 03:56:12 +00:00
2021-12-02 23:02:31 +00:00
$channel = App::get_channel();
2017-03-16 03:56:12 +00:00
2021-12-03 03:01:39 +00:00
$x = q(
"select count(*) as total from hubloc where hubloc_hash = '%s' and hubloc_deleted = 0 ",
2021-12-02 23:02:31 +00:00
dbesc($channel['channel_hash'])
);
2017-03-16 03:56:12 +00:00
2022-11-20 05:28:50 +00:00
$hublocs = $x && $x[0]['total'] > 1;
2017-03-16 03:56:12 +00:00
2022-10-03 09:54:13 +00:00
$tabs = [
[
2021-12-02 23:02:31 +00:00
'label' => t('Account settings'),
'url' => z_root() . '/settings/account',
'selected' => ((argv(1) === 'account') ? 'active' : ''),
2022-10-03 09:54:13 +00:00
],
2017-03-16 03:56:12 +00:00
2022-10-03 09:54:13 +00:00
[
2021-12-02 23:02:31 +00:00
'label' => t('Channel settings'),
'url' => z_root() . '/settings/channel',
'selected' => ((argv(1) === 'channel') ? 'active' : ''),
2022-10-03 09:54:13 +00:00
],
2017-03-16 03:56:12 +00:00
2022-10-03 09:54:13 +00:00
];
$tabs[] = [
'label' => t('Edit profile'),
'url' => z_root() . '/settings/profile_edit',
'selected' => ((argv(1) === 'profile_edit') ? 'active' : ''),
];
2017-03-16 03:56:12 +00:00
2022-10-03 09:54:13 +00:00
$tabs[] = [
2021-12-02 23:02:31 +00:00
'label' => t('Display settings'),
'url' => z_root() . '/settings/display',
'selected' => ((argv(1) === 'display') ? 'active' : ''),
2022-10-03 09:54:13 +00:00
];
2017-03-16 03:56:12 +00:00
2022-10-03 09:54:13 +00:00
$tabs[] = [
2021-12-02 23:02:31 +00:00
'label' => t('Manage Blocks'),
'url' => z_root() . '/superblock',
'selected' => ((argv(0) === 'superblock') ? 'active' : ''),
2022-10-03 09:54:13 +00:00
];
2021-12-02 23:02:31 +00:00
if ($hublocs) {
2022-10-03 09:54:13 +00:00
$tabs[] = [
2021-12-02 23:02:31 +00:00
'label' => t('Manage locations'),
'url' => z_root() . '/locs',
'selected' => ((argv(1) === 'locs') ? 'active' : ''),
2022-10-03 09:54:13 +00:00
];
2021-12-02 23:02:31 +00:00
}
2017-03-16 03:56:12 +00:00
2022-10-03 09:54:13 +00:00
$tabs[] = [
2021-12-02 23:02:31 +00:00
'label' => t('Export channel'),
'url' => z_root() . '/uexport',
'selected' => ''
2022-10-03 09:54:13 +00:00
];
2017-03-16 03:56:12 +00:00
2022-01-25 23:20:02 +00:00
// if(Features::enabled(local_channel(),'oauth_clients')) {
2021-12-03 03:01:39 +00:00
// $tabs[] = array(
// 'label' => t('OAuth1 apps'),
// 'url' => z_root() . '/settings/oauth',
// 'selected' => ((argv(1) === 'oauth') ? 'active' : ''),
// );
// }
2017-03-16 03:56:12 +00:00
2021-12-02 23:02:31 +00:00
if (Apps::system_app_installed(local_channel(), 'Clients')) {
2022-10-03 09:54:13 +00:00
$tabs[] = [
2021-12-02 23:02:31 +00:00
'label' => t('Client apps'),
'url' => z_root() . '/settings/oauth2',
'selected' => ((argv(1) === 'oauth2') ? 'active' : ''),
2022-10-03 09:54:13 +00:00
];
2021-12-02 23:02:31 +00:00
}
2018-04-06 04:01:36 +00:00
2022-01-25 23:20:02 +00:00
// if(Features::enabled(local_channel(),'access_tokens')) {
2021-12-03 03:01:39 +00:00
// $tabs[] = array(
// 'label' => t('Guest Access Tokens'),
// 'url' => z_root() . '/settings/tokens',
// 'selected' => ((argv(1) === 'tokens') ? 'active' : ''),
// );
// }
2022-01-22 10:04:36 +00:00
if(Apps::system_app_installed(local_channel(),'Roles')) {
2022-10-03 09:54:13 +00:00
$tabs[] = [
2022-01-22 10:04:36 +00:00
'label' => t('Permission Roles'),
'url' => z_root() . '/settings/permcats',
'selected' => ((argv(1) === 'permcats') ? 'active' : ''),
2022-10-03 09:54:13 +00:00
];
2022-01-22 10:04:36 +00:00
}
2021-12-03 03:01:39 +00:00
// if($role === false || $role === 'custom') {
// $tabs[] = array(
// 'label' => t('Connection Default Permissions'),
// 'url' => z_root() . '/defperms',
// 'selected' => ''
// );
// }
2022-01-25 23:20:02 +00:00
// if(Features::enabled(local_channel(),'channel_sources')) {
2021-12-03 03:01:39 +00:00
// $tabs[] = array(
// 'label' => t('Channel Sources'),
// 'url' => z_root() . '/sources',
// 'selected' => ''
// );
// }
2017-03-16 03:56:12 +00:00
2022-02-12 20:43:29 +00:00
$tabtpl = Theme::get_template("generic_links_widget.tpl");
2022-10-03 09:54:13 +00:00
return replace_macros($tabtpl, [
2021-12-02 23:02:31 +00:00
'$title' => t('Settings'),
'$class' => 'settings-widget',
'$items' => $tabs,
2022-10-03 09:54:13 +00:00
]);
2021-12-02 23:02:31 +00:00
}
2021-12-03 03:01:39 +00:00
}