Add copy action to OpenVPN pages. Implements #5851

Added to Server, Client, and Client-Specific Override pages
This commit is contained in:
jim-p 2019-11-21 12:08:39 -05:00
parent 1d9fbb7165
commit d86c28bc83
3 changed files with 28 additions and 7 deletions

View File

@ -102,7 +102,7 @@ if ($act == "new") {
global $simplefields;
$simplefields = array('auth_user', 'auth_pass');
if ($act == "edit") {
if (($act == "edit") || ($act == "dup")) {
if (isset($id) && $a_client[$id]) {
foreach ($simplefields as $stat) {
$pconfig[$stat] = $a_client[$id][$stat];
@ -194,6 +194,12 @@ if ($act == "edit") {
}
}
if ($act == "dup") {
$act = "new";
$vpnid = 0;
unset($id);
}
if ($_POST['save']) {
unset($input_errors);
@ -1133,8 +1139,9 @@ else:
<?=htmlspecialchars($client['description'])?>
</td>
<td>
<a class="fa fa-pencil" title="<?=gettext('Edit client')?>" href="vpn_openvpn_client.php?act=edit&amp;id=<?=$i?>"></a>
<a class="fa fa-trash" title="<?=gettext('Delete client')?>" href="vpn_openvpn_client.php?act=del&amp;id=<?=$i?>" usepost></a>
<a class="fa fa-pencil" title="<?=gettext('Edit Client')?>" href="vpn_openvpn_client.php?act=edit&amp;id=<?=$i?>"></a>
<a class="fa fa-clone" title="<?=gettext("Copy Client")?>" href="vpn_openvpn_client.php?act=dup&amp;id=<?=$i?>" usepost></a>
<a class="fa fa-trash" title="<?=gettext('Delete Client')?>" href="vpn_openvpn_client.php?act=del&amp;id=<?=$i?>" usepost></a>
</td>
</tr>
<?php

View File

@ -67,7 +67,7 @@ if ($_POST['act'] == "del") {
}
}
if ($act == "edit") {
if (($act == "edit") || ($act == "dup")) {
if (isset($id) && $a_csc[$id]) {
$pconfig['server_list'] = explode(",", $a_csc[$id]['server_list']);
$pconfig['custom_options'] = $a_csc[$id]['custom_options'];
@ -130,6 +130,11 @@ if ($act == "edit") {
}
}
if ($act == "dup") {
$act = "new";
unset($id);
}
if ($_POST['save']) {
unset($input_errors);
@ -701,6 +706,7 @@ else : // Not an 'add' or an 'edit'. Just the table of Override CSCs
</td>
<td>
<a class="fa fa-pencil" title="<?=gettext('Edit CSC Override')?>" href="vpn_openvpn_csc.php?act=edit&amp;id=<?=$i?>"></a>
<a class="fa fa-clone" title="<?=gettext("Copy CSC Override")?>" href="vpn_openvpn_csc.php?act=dup&amp;id=<?=$i?>" usepost></a>
<a class="fa fa-trash" title="<?=gettext('Delete CSC Override')?>" href="vpn_openvpn_csc.php?act=del&amp;id=<?=$i?>" usepost></a>
</td>
</tr>

View File

@ -111,7 +111,7 @@ if ($act == "new") {
$pconfig['compression'] = "none";
}
if ($act == "edit") {
if (($act == "edit") || ($act == "dup")) {
if (isset($id) && $a_server[$id]) {
$pconfig['disable'] = isset($a_server[$id]['disable']);
@ -268,6 +268,13 @@ if ($act == "edit") {
}
}
if ($act == "dup") {
$act = "new";
$pconfig['local_port'] = openvpn_port_next('UDP');
$vpnid = 0;
unset($id);
}
if ($_POST['save']) {
unset($input_errors);
$pconfig = $_POST;
@ -1568,8 +1575,9 @@ else:
<?=htmlspecialchars(sprintf('%1$s (%2$s)', $server['description'], $server['dev_mode']))?>
</td>
<td>
<a class="fa fa-pencil" title="<?=gettext('Edit server')?>" href="vpn_openvpn_server.php?act=edit&amp;id=<?=$i?>"></a>
<a class="fa fa-trash" title="<?=gettext('Delete server')?>" href="vpn_openvpn_server.php?act=del&amp;id=<?=$i?>" usepost></a>
<a class="fa fa-pencil" title="<?=gettext('Edit Server')?>" href="vpn_openvpn_server.php?act=edit&amp;id=<?=$i?>"></a>
<a class="fa fa-clone" title="<?=gettext("Copy Server")?>" href="vpn_openvpn_server.php?act=dup&amp;id=<?=$i?>" usepost></a>
<a class="fa fa-trash" title="<?=gettext('Delete Server')?>" href="vpn_openvpn_server.php?act=del&amp;id=<?=$i?>" usepost></a>
</td>
</tr>
<?php