frontend implementation of Domains.duplicate()
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -636,6 +636,23 @@ if ($page == 'domains' || $page == 'overview') {
|
||||
'alert_msg' => lng('domains.import_description')
|
||||
]);
|
||||
}
|
||||
} elseif ($action == 'duplicate') {
|
||||
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
||||
try {
|
||||
Domains::getLocal($userinfo, $_POST)->duplicate();
|
||||
} catch (Exception $e) {
|
||||
Response::dynamicError($e->getMessage());
|
||||
}
|
||||
Response::redirectTo($filename, [
|
||||
'page' => $page,
|
||||
'searchfield' => 'd.domain_ace',
|
||||
'searchtext' => $_POST['domain'] ?? ""
|
||||
]);
|
||||
} else {
|
||||
Response::redirectTo($filename, [
|
||||
'page' => 'overview'
|
||||
]);
|
||||
}
|
||||
}
|
||||
} elseif ($page == 'domainssleditor') {
|
||||
require_once __DIR__ . '/ssl_editor.php';
|
||||
|
||||
@@ -25,10 +25,13 @@
|
||||
|
||||
namespace Froxlor\UI\Callbacks;
|
||||
|
||||
use Froxlor\CurrentUser;
|
||||
use Froxlor\Database\Database;
|
||||
use Froxlor\Froxlor;
|
||||
use Froxlor\PhpHelper;
|
||||
use Froxlor\UI\Panel\UI;
|
||||
use Froxlor\User;
|
||||
use PDO;
|
||||
|
||||
class Text
|
||||
{
|
||||
@@ -105,4 +108,44 @@ class Text
|
||||
'body' => $body
|
||||
];
|
||||
}
|
||||
|
||||
public static function domainDuplicateModal(array $attributes): array
|
||||
{
|
||||
$linker = UI::getLinker();
|
||||
$result = $attributes['fields'];
|
||||
|
||||
$customers = [
|
||||
0 => lng('panel.please_choose')
|
||||
];
|
||||
$result_customers_stmt = Database::prepare("
|
||||
SELECT `customerid`, `loginname`, `name`, `firstname`, `company`
|
||||
FROM `" . TABLE_PANEL_CUSTOMERS . "` " . (CurrentUser::getField('customers_see_all') ? '' : " WHERE `adminid` = :adminid ") . "
|
||||
ORDER BY COALESCE(NULLIF(`name`,''), `company`) ASC
|
||||
");
|
||||
$params = [];
|
||||
if (CurrentUser::getField('customers_see_all') == '0') {
|
||||
$params['adminid'] = CurrentUser::getField('adminid');
|
||||
}
|
||||
Database::pexecute($result_customers_stmt, $params);
|
||||
|
||||
while ($row_customer = $result_customers_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$customers[$row_customer['customerid']] = User::getCorrectFullUserDetails($row_customer) . ' (' . $row_customer['loginname'] . ')';
|
||||
}
|
||||
|
||||
$domdup_data = include Froxlor::getInstallDir() . '/lib/formfields/admin/domains/formfield.domains_duplicate.php';
|
||||
|
||||
$body = UI::twig()->render(UI::validateThemeTemplate('/user/inline-form.html.twig'), [
|
||||
'formaction' => $linker->getLink(['section' => 'domains', 'page' => 'domains', 'action' => 'duplicate']),
|
||||
'formdata' => $domdup_data['domain_duplicate'],
|
||||
'editid' => $attributes['fields']['id'],
|
||||
'nosubmit' => 0
|
||||
]);
|
||||
return [
|
||||
'entry' => $attributes['fields']['id'],
|
||||
'id' => 'ddModal' . $attributes['fields']['id'],
|
||||
'title' => lng('admin.domain_duplicate_named', [$attributes['fields']['domain']]),
|
||||
'action' => 'duplicate',
|
||||
'body' => $body
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,6 +161,11 @@ return [
|
||||
'id' => ':id'
|
||||
],
|
||||
],
|
||||
'duplicate' => [
|
||||
'icon' => 'fa-solid fa-clone',
|
||||
'title' => lng('admin.domain_duplicate'),
|
||||
'modal' => [Text::class, 'domainDuplicateModal'],
|
||||
],
|
||||
'logfiles' => [
|
||||
'icon' => 'fa-solid fa-file',
|
||||
'title' => lng('panel.viewlogs'),
|
||||
|
||||
@@ -489,6 +489,8 @@ return [
|
||||
'adminguide' => 'Admin Guide',
|
||||
'userguide' => 'User Guide',
|
||||
'apiguide' => 'API Guide',
|
||||
'domain_duplicate' => 'Domain duplizieren',
|
||||
'domain_duplicate_named' => '%s duplizieren',
|
||||
],
|
||||
'apikeys' => [
|
||||
'no_api_keys' => 'Keine API Keys gefunden',
|
||||
|
||||
@@ -500,6 +500,8 @@ return [
|
||||
'adminguide' => 'Admin guide',
|
||||
'userguide' => 'User guide',
|
||||
'apiguide' => 'API guide',
|
||||
'domain_duplicate' => 'Duplicate domain',
|
||||
'domain_duplicate_named' => 'Duplicate %s',
|
||||
],
|
||||
'apcuinfo' => [
|
||||
'clearcache' => 'Clear APCu cache',
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
{% import "Froxlor/form/form.html.twig" as form %}
|
||||
{{ form.form(formdata, formaction|default('#'), formdata.title, editid|default(''), true, idprefix|default('')) }}
|
||||
{{ form.form(formdata, formaction|default('#'), formdata.title, editid|default(''), nosubmit|default(true), idprefix|default('')) }}
|
||||
|
||||
Reference in New Issue
Block a user