diff --git a/config/ACL.php b/config/ACL.php index daf8ce0..ed22807 100644 --- a/config/ACL.php +++ b/config/ACL.php @@ -54,6 +54,7 @@ class ACL extends \Zend\Permissions\Acl\Acl '/channels/{sid}', '/channels/{sid}/{cid}', + '/channels/edit/{sid}/{cid}', '/channels/delete/{sid}/{cid}', '/channels/send/{sid}/{cid}', diff --git a/config/routes.php b/config/routes.php index dd7704c..6caa253 100644 --- a/config/routes.php +++ b/config/routes.php @@ -239,6 +239,11 @@ $container[ChannelInfoAction::class] = function ($container) { }; $app->get('/channels/{sid}/{cid}', ChannelInfoAction::class); +$container[ChannelEditAction::class] = function ($container) { + return new ChannelEditAction($container); +}; +$app->post('/channels/edit/{sid}/{cid}', ChannelEditAction::class); + $container[ChannelDeleteAction::class] = function ($container) { return new ChannelDeleteAction($container); }; diff --git a/src/Control/Actions/ChannelEditAction.php b/src/Control/Actions/ChannelEditAction.php new file mode 100644 index 0000000..da7b32d --- /dev/null +++ b/src/Control/Actions/ChannelEditAction.php @@ -0,0 +1,24 @@ +getParsedBody(); + + $this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']); + $selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId'); + + $channelResult = $this->ts->getInstance()->channelEdit($cid, $body); + + $this->flash->addMessage('success', $this->translator->trans('done')); + + return $response->withRedirect('/channels/' . $sid . '/' . $cid); + } +} \ No newline at end of file diff --git a/src/Control/Actions/ChannelInfoAction.php b/src/Control/Actions/ChannelInfoAction.php index 95ce667..f8c1d05 100644 --- a/src/Control/Actions/ChannelInfoAction.php +++ b/src/Control/Actions/ChannelInfoAction.php @@ -26,6 +26,8 @@ final class ChannelInfoAction extends AbstractAction 'files' => $this->ts->getInstance()->getElement('data', $files), 'channel' => $this->ts->getInstance()->getElement('data', $channelResult), 'clients' => $this->ts->getInstance()->getElement('data', $clientsResult), + 'codecs' => TSInstance::getCodecs(), + 'codecsquality' => TSInstance::getCodecsQuality(), 'sid' => $sid, 'cid' => $cid ]); diff --git a/src/Control/Actions/ServerInfoAction.php b/src/Control/Actions/ServerInfoAction.php index a347439..a4a9e14 100644 --- a/src/Control/Actions/ServerInfoAction.php +++ b/src/Control/Actions/ServerInfoAction.php @@ -21,6 +21,10 @@ final class ServerInfoAction extends AbstractAction 'title' => $this->translator->trans('server_info.title') . ' ' . $sid, 'info' => $this->ts->getInstance()->getElement('data', $infoResult), 'uploads' => $this->ts->getInstance()->getElement('data', $uploadsResult), + 'messagemodes' => TSInstance::getHostMessageModes(), + 'bannermodes' => TSInstance::getHostBannerModes(), + 'encryptionmodes' => TSInstance::getCodecEncryptionModes(), + 'loglevels' => TSInstance::getLogLevels(), 'sid' => $sid ]); } diff --git a/src/Util/TSInstance.php b/src/Util/TSInstance.php index 808f0b9..014cc20 100644 --- a/src/Util/TSInstance.php +++ b/src/Util/TSInstance.php @@ -87,4 +87,95 @@ class TSInstance { return $this->ts; } + + /** + * @return array + */ + public static function getCodecs() + { + $arr = []; + $arr['CODEC_SPEEX_NARROWBAND'] = ts3admin::CODEC_SPEEX_NARROWBAND; + $arr['CODEC_SPEEX_WIDEBAND'] = ts3admin::CODEC_SPEEX_WIDEBAND; + $arr['CODEC_SPEEX_ULTRAWIDEBAND'] = ts3admin::CODEC_SPEEX_ULTRAWIDEBAND; + $arr['CODEC_CELT_MONO'] = ts3admin::CODEC_CELT_MONO; + $arr['CODEC_OPUS_VOICE'] = ts3admin::CODEC_OPUS_VOICE; + $arr['CODEC_OPUS_MUSIC'] = ts3admin::CODEC_OPUS_MUSIC; + + return $arr; + } + + /** + * @return array + */ + public static function getCodecsQuality() + { + $arr = []; + $arr[1] = 1; + $arr[2] = 2; + $arr[3] = 3; + $arr[4] = 4; + $arr[5] = 5; + $arr[6] = 6; + $arr[7] = 7; + $arr[8] = 8; + $arr[9] = 19; + $arr[10] = 10; + + return $arr; + } + + /** + * @return array + */ + public static function getHostMessageModes() + { + $arr = []; + $arr['HostMessageMode_NONE'] = ts3admin::HostMessageMode_NONE; + $arr['HostMessageMode_LOG'] = ts3admin::HostMessageMode_LOG; + $arr['HostMessageMode_MODAL'] = ts3admin::HostMessageMode_MODAL; + $arr['HostMessageMode_MODALQUIT'] = ts3admin::HostMessageMode_MODALQUIT; + + return $arr; + } + + /** + * @return array + */ + public static function getHostBannerModes() + { + $arr = []; + $arr['HostBannerMode_NOADJUST'] = ts3admin::HostBannerMode_NOADJUST; + $arr['HostBannerMode_IGNOREASPECT'] = ts3admin::HostBannerMode_IGNOREASPECT; + $arr['HostBannerMode_KEEPASPECT'] = ts3admin::HostBannerMode_KEEPASPECT; + + return $arr; + } + + /** + * @return array + */ + public static function getCodecEncryptionModes() + { + $arr = []; + $arr['CODEC_CRYPT_INDIVIDUAL'] = ts3admin::CODEC_CRYPT_INDIVIDUAL; + $arr['CODEC_CRYPT_DISABLED'] = ts3admin::CODEC_CRYPT_DISABLED; + $arr['CODEC_CRYPT_ENABLED'] = ts3admin::CODEC_CRYPT_ENABLED; + + return $arr; + } + + /** + * @return array + */ + public static function getLogLevels() + { + $arr = []; + $arr['LogLevel_NONE'] = 0; + $arr['LogLevel_ERROR'] = ts3admin::LogLevel_ERROR; + $arr['LogLevel_WARNING'] = ts3admin::LogLevel_WARNING; + $arr['LogLevel_DEBUG'] = ts3admin::LogLevel_DEBUG; + $arr['LogLevel_INFO'] = ts3admin::LogLevel_INFO; + + return $arr; + } } \ No newline at end of file diff --git a/src/View/material/channel_info.twig b/src/View/material/channel_info.twig index eafddaf..d36b293 100644 --- a/src/View/material/channel_info.twig +++ b/src/View/material/channel_info.twig @@ -33,5 +33,27 @@ {% endif %}

{% trans %}channel_info.h.details{% endtrans %}

- {% include 'keyvalue.twig' with {'data': channel} %} + {% include 'keyvalue.twig' with {'data': channel, + 'attributesEditable': [ + {'key': 'channel_name', 'type': 'text', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'channel_topic', 'type': 'text', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'channel_description', 'type': 'text', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'channel_password', 'type': 'text', 'blank': true,'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'channel_maxclients', 'type': 'number', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'channel_flag_maxclients_unlimited', 'type': 'checkbox', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'channel_maxfamilyclients', 'type': 'number', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'channel_flag_maxfamilyclients_unlimited', 'type': 'checkbox', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'channel_flag_maxfamilyclients_inherited', 'type': 'checkbox', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'channel_flag_permanent', 'type': 'checkbox', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'channel_flag_semi_permanent', 'type': 'checkbox', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'channel_flag_default', 'type': 'checkbox', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'channel_order', 'type': 'number', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'channel_needed_talk_power', 'type': 'number', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'channel_name_phonetic', 'type': 'text', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'channel_codec', 'type': 'select', 'options': codecs, 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'channel_codec_quality', 'type': 'select', 'options': codecsquality, 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'channel_codec_is_unencrypted', 'type': 'checkbox', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'channel_icon_id', 'type': 'number', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': 'check_circle'}, + ] + } %} {% endblock %} \ No newline at end of file diff --git a/src/View/material/instance.twig b/src/View/material/instance.twig index 21bbb68..412ef1f 100644 --- a/src/View/material/instance.twig +++ b/src/View/material/instance.twig @@ -22,6 +22,7 @@ {'key': 'serverinstance_template_serverdefault_group', 'type': 'number', 'uri': '/instance/edit', 'uri_method': 'post', 'submit_label': 'check_circle'}, {'key': 'serverinstance_template_channeldefault_group', 'type': 'number', 'uri': '/instance/edit', 'uri_method': 'post', 'submit_label': 'check_circle'}, {'key': 'serverinstance_template_channeladmin_group', 'type': 'number', 'uri': '/instance/edit', 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'serverinstance_serverquery_ban_time', 'type': 'number', 'uri': '/instance/edit', 'uri_method': 'post', 'submit_label': 'check_circle'}, {'key': 'serverinstance_serverquery_flood_commands', 'type': 'number', 'uri': '/instance/edit', 'uri_method': 'post', 'submit_label': 'check_circle'}, {'key': 'serverinstance_serverquery_flood_time', 'type': 'number', 'uri': '/instance/edit', 'uri_method': 'post', 'submit_label': 'check_circle'}, {'key': 'serverinstance_serverquery_flood_ban_time', 'type': 'number', 'uri': '/instance/edit', 'uri_method': 'post', 'submit_label': 'check_circle'}, diff --git a/src/View/material/keyvalue.twig b/src/View/material/keyvalue.twig index 7254bf9..96358e5 100644 --- a/src/View/material/keyvalue.twig +++ b/src/View/material/keyvalue.twig @@ -48,8 +48,24 @@ {% endif %} + {% elseif editable.type == 'select' %} + {% else %} - + {% endif %} diff --git a/src/View/material/server_info.twig b/src/View/material/server_info.twig index 04fa199..8ba1e6d 100644 --- a/src/View/material/server_info.twig +++ b/src/View/material/server_info.twig @@ -44,6 +44,13 @@ ], 'attributesEditable': [ {'key': 'virtualserver_name', 'type': 'text', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_name_phonetic', 'type': 'text', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_icon_id', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_reserved_slots', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_default_server_group', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_default_channel_group', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_default_channel_admin_group', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_needed_identity_security_level', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, {'key': 'virtualserver_maxclients', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, {'key': 'virtualserver_min_client_version', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, {'key': 'virtualserver_port', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, @@ -51,6 +58,33 @@ {'key': 'virtualserver_autostart', 'type': 'checkbox', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, {'key': 'virtualserver_min_android_version', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, {'key': 'virtualserver_min_ios_version', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_complain_autoban_count', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_complain_autoban_time', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_complain_remove_time', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_min_clients_in_channel_before_forced_silence', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_priority_speaker_dimm_modificator', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_antiflood_points_tick_reduce', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_antiflood_points_needed_command_block', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_antiflood_points_needed_ip_block', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_hostbanner_url', 'type': 'text', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_hostbutton_url', 'type': 'text', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_hostbutton_tooltip', 'type': 'text', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_password', 'type': 'text', 'blank': true, 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_hostbanner_gfx_interval', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_hostbanner_gfx_url', 'type': 'text', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_hostbutton_gfx_url', 'type': 'text', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_hostmessage', 'type': 'text', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_hostmessage_mode', 'type': 'select', 'options': messagemodes,'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_hostbanner_mode', 'type': 'select', 'options': bannermodes,'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_flag_password', 'type': 'checkbox','uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_welcomemessage', 'type': 'text','uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_codec_encryption_mode', 'type': 'select', 'options': encryptionmodes, 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_log_client', 'type': 'select', 'options': loglevels, 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_log_query', 'type': 'select', 'options': loglevels, 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_log_channel', 'type': 'select', 'options': loglevels, 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_log_permissions', 'type': 'select', 'options': loglevels, 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_log_server', 'type': 'select', 'options': loglevels, 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, + {'key': 'virtualserver_log_filetransfer', 'type': 'select', 'options': loglevels, 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': 'check_circle'}, ] } %}