Archived
1
0
Fork 0

allow editing more attributes

This commit is contained in:
Varakh 2018-04-05 11:31:28 +02:00
parent dbe38967a5
commit 3eb5cfcc1e
10 changed files with 202 additions and 2 deletions

View file

@ -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}',

View file

@ -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);
};

View file

@ -0,0 +1,24 @@
<?php
use Slim\Http\Request;
use Slim\Http\Response;
final class ChannelEditAction extends AbstractAction
{
public function __invoke(Request $request, Response $response, $args)
{
$sid = $args['sid'];
$cid = $args['cid'];
$body = $request->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);
}
}

View file

@ -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
]);

View file

@ -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
]);
}

View file

@ -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;
}
}

View file

@ -33,5 +33,27 @@
{% endif %}
<h2 class="header">{% trans %}channel_info.h.details{% endtrans %}</h2>
{% 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': '<i class="material-icons">check_circle</i>'},
{'key': 'channel_topic', 'type': 'text', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'channel_description', 'type': 'text', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'channel_password', 'type': 'text', 'blank': true,'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'channel_maxclients', 'type': 'number', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'channel_flag_maxclients_unlimited', 'type': 'checkbox', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'channel_maxfamilyclients', 'type': 'number', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'channel_flag_maxfamilyclients_unlimited', 'type': 'checkbox', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'channel_flag_maxfamilyclients_inherited', 'type': 'checkbox', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'channel_flag_permanent', 'type': 'checkbox', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'channel_flag_semi_permanent', 'type': 'checkbox', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'channel_flag_default', 'type': 'checkbox', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'channel_order', 'type': 'number', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'channel_needed_talk_power', 'type': 'number', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'channel_name_phonetic', 'type': 'text', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'channel_codec', 'type': 'select', 'options': codecs, 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'channel_codec_quality', 'type': 'select', 'options': codecsquality, 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'channel_codec_is_unencrypted', 'type': 'checkbox', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'channel_icon_id', 'type': 'number', 'uri': '/channels/edit/' ~ sid ~ '/' ~ cid , 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
]
} %}
{% endblock %}

View file

@ -22,6 +22,7 @@
{'key': 'serverinstance_template_serverdefault_group', 'type': 'number', 'uri': '/instance/edit', 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'serverinstance_template_channeldefault_group', 'type': 'number', 'uri': '/instance/edit', 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'serverinstance_template_channeladmin_group', 'type': 'number', 'uri': '/instance/edit', 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'serverinstance_serverquery_ban_time', 'type': 'number', 'uri': '/instance/edit', 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'serverinstance_serverquery_flood_commands', 'type': 'number', 'uri': '/instance/edit', 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'serverinstance_serverquery_flood_time', 'type': 'number', 'uri': '/instance/edit', 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'serverinstance_serverquery_flood_ban_time', 'type': 'number', 'uri': '/instance/edit', 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},

View file

@ -48,8 +48,24 @@
<input type="checkbox" name="{{ editable.key }}"
id="{{ editable.key }}" value="1" />
{% endif %}
{% elseif editable.type == 'select' %}
<select class="form-control" name="{{ editable.key }}" id="{{ editable.key }}">
{% for k,v in editable.options %}
{% if v == item %}
<option class="form-control" value="{{ v }}" selected>{{ k }}</option>
{% else %}
<option class="form-control" value="{{ v }}">{{ k }}</option>
{% endif %}
{% endfor %}
</select>
{% else %}
<input class="form-control" name="{{ editable.key }}" id="{{ editable.key }}" type="{{ editable.type }}" value="{{ item }}" />
<input class="form-control" name="{{ editable.key }}" id="{{ editable.key }}" type="{{ editable.type }}"
{% if editable.blank is defined and editable.blank == true %}
{% else %}
value="{{ item }}"
{% endif %}
/>
{% endif %}
<button class="btn btn-primary" id="{{ 'form_' ~ editable.key }}" type="submit">{{ editable.submit_label|raw }}</button>

View file

@ -44,6 +44,13 @@
],
'attributesEditable': [
{'key': 'virtualserver_name', 'type': 'text', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_name_phonetic', 'type': 'text', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_icon_id', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_reserved_slots', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_default_server_group', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_default_channel_group', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_default_channel_admin_group', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_needed_identity_security_level', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_maxclients', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_min_client_version', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_port', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
@ -51,6 +58,33 @@
{'key': 'virtualserver_autostart', 'type': 'checkbox', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_min_android_version', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_min_ios_version', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_complain_autoban_count', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_complain_autoban_time', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_complain_remove_time', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_min_clients_in_channel_before_forced_silence', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_priority_speaker_dimm_modificator', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_antiflood_points_tick_reduce', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_antiflood_points_needed_command_block', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_antiflood_points_needed_ip_block', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_hostbanner_url', 'type': 'text', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_hostbutton_url', 'type': 'text', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_hostbutton_tooltip', 'type': 'text', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_password', 'type': 'text', 'blank': true, 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_hostbanner_gfx_interval', 'type': 'number', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_hostbanner_gfx_url', 'type': 'text', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_hostbutton_gfx_url', 'type': 'text', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_hostmessage', 'type': 'text', 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_hostmessage_mode', 'type': 'select', 'options': messagemodes,'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_hostbanner_mode', 'type': 'select', 'options': bannermodes,'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_flag_password', 'type': 'checkbox','uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_welcomemessage', 'type': 'text','uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_codec_encryption_mode', 'type': 'select', 'options': encryptionmodes, 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_log_client', 'type': 'select', 'options': loglevels, 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_log_query', 'type': 'select', 'options': loglevels, 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_log_channel', 'type': 'select', 'options': loglevels, 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_log_permissions', 'type': 'select', 'options': loglevels, 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_log_server', 'type': 'select', 'options': loglevels, 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
{'key': 'virtualserver_log_filetransfer', 'type': 'select', 'options': loglevels, 'uri': '/servers/edit/' ~ sid, 'uri_method': 'post', 'submit_label': '<i class="material-icons">check_circle</i>'},
]
} %}