mirror of
https://github.com/Froxlor/Froxlor.git
synced 2024-09-21 10:27:29 +00:00
exchange toggler-links with checkboxes in email edit form to be able to adjust all parameters at once, fixes #1277
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
parent
c69b38bc42
commit
40aa48a6d4
@ -247,11 +247,7 @@ if ($page == 'email_domain') {
|
|||||||
if (isset($result['email']) && $result['email'] != '') {
|
if (isset($result['email']) && $result['email'] != '') {
|
||||||
if (Request::post('send') == 'send') {
|
if (Request::post('send') == 'send') {
|
||||||
try {
|
try {
|
||||||
Emails::getLocal($userinfo, [
|
Emails::getLocal($userinfo, Request::postAll())->update();
|
||||||
'id' => $id,
|
|
||||||
'spam_tag_level' => Request::post('spam_tag_level', Rspamd::DEFAULT_MARK_LVL),
|
|
||||||
'spam_kill_level' => Request::post('spam_kill_level', Rspamd::DEFAULT_REJECT_LVL)
|
|
||||||
])->update();
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Response::dynamicError($e->getMessage());
|
Response::dynamicError($e->getMessage());
|
||||||
}
|
}
|
||||||
@ -291,88 +287,12 @@ if ($page == 'email_domain') {
|
|||||||
|
|
||||||
$email_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_edit.php';
|
$email_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_edit.php';
|
||||||
|
|
||||||
if (Settings::Get('catchall.catchall_enabled') != '1') {
|
|
||||||
unset($email_edit_data['emails_edit']['sections']['section_a']['fields']['mail_catchall']);
|
|
||||||
}
|
|
||||||
|
|
||||||
UI::view('user/form.html.twig', [
|
UI::view('user/form.html.twig', [
|
||||||
'formaction' => $linker->getLink(['section' => 'email']),
|
'formaction' => $linker->getLink(['section' => 'email']),
|
||||||
'formdata' => $email_edit_data['emails_edit'],
|
'formdata' => $email_edit_data['emails_edit'],
|
||||||
'editid' => $id
|
'editid' => $id
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
} elseif ($action == 'togglebypass' && $id != 0) {
|
|
||||||
try {
|
|
||||||
$json_result = Emails::getLocal($userinfo, [
|
|
||||||
'id' => $id
|
|
||||||
])->get();
|
|
||||||
} catch (Exception $e) {
|
|
||||||
Response::dynamicError($e->getMessage());
|
|
||||||
}
|
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
|
|
||||||
try {
|
|
||||||
Emails::getLocal($userinfo, [
|
|
||||||
'id' => $id,
|
|
||||||
'bypass_spam' => ($result['bypass_spam'] == '1' ? 0 : 1)
|
|
||||||
])->update();
|
|
||||||
} catch (Exception $e) {
|
|
||||||
Response::dynamicError($e->getMessage());
|
|
||||||
}
|
|
||||||
Response::redirectTo($filename, [
|
|
||||||
'page' => $page,
|
|
||||||
'domainid' => $email_domainid,
|
|
||||||
'action' => 'edit',
|
|
||||||
'id' => $id,
|
|
||||||
]);
|
|
||||||
} elseif ($action == 'togglegreylist' && $id != 0) {
|
|
||||||
try {
|
|
||||||
$json_result = Emails::getLocal($userinfo, [
|
|
||||||
'id' => $id
|
|
||||||
])->get();
|
|
||||||
} catch (Exception $e) {
|
|
||||||
Response::dynamicError($e->getMessage());
|
|
||||||
}
|
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
|
|
||||||
try {
|
|
||||||
Emails::getLocal($userinfo, [
|
|
||||||
'id' => $id,
|
|
||||||
'policy_greylist' => ($result['policy_greylist'] == '1' ? 0 : 1)
|
|
||||||
])->update();
|
|
||||||
} catch (Exception $e) {
|
|
||||||
Response::dynamicError($e->getMessage());
|
|
||||||
}
|
|
||||||
Response::redirectTo($filename, [
|
|
||||||
'page' => $page,
|
|
||||||
'domainid' => $email_domainid,
|
|
||||||
'action' => 'edit',
|
|
||||||
'id' => $id,
|
|
||||||
]);
|
|
||||||
} elseif ($action == 'togglecatchall' && $id != 0) {
|
|
||||||
try {
|
|
||||||
$json_result = Emails::getLocal($userinfo, [
|
|
||||||
'id' => $id
|
|
||||||
])->get();
|
|
||||||
} catch (Exception $e) {
|
|
||||||
Response::dynamicError($e->getMessage());
|
|
||||||
}
|
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
|
|
||||||
try {
|
|
||||||
Emails::getLocal($userinfo, [
|
|
||||||
'id' => $id,
|
|
||||||
'iscatchall' => ($result['iscatchall'] == '1' ? 0 : 1)
|
|
||||||
])->update();
|
|
||||||
} catch (Exception $e) {
|
|
||||||
Response::dynamicError($e->getMessage());
|
|
||||||
}
|
|
||||||
Response::redirectTo($filename, [
|
|
||||||
'page' => $page,
|
|
||||||
'domainid' => $email_domainid,
|
|
||||||
'action' => 'edit',
|
|
||||||
'id' => $id,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
} elseif ($page == 'accounts') {
|
} elseif ($page == 'accounts') {
|
||||||
$email_domainid = Request::any('domainid', 0);
|
$email_domainid = Request::any('domainid', 0);
|
||||||
|
@ -738,11 +738,12 @@ class Customers extends ApiCommand implements ResourceEntity
|
|||||||
'adminid' => $this->getUserDetail('adminid'),
|
'adminid' => $this->getUserDetail('adminid'),
|
||||||
'docroot' => $documentroot,
|
'docroot' => $documentroot,
|
||||||
'phpenabled' => $phpenabled,
|
'phpenabled' => $phpenabled,
|
||||||
'openbasedir' => '1'
|
'openbasedir' => '1',
|
||||||
|
'is_stdsubdomain' => 1
|
||||||
];
|
];
|
||||||
$domainid = -1;
|
$domainid = -1;
|
||||||
try {
|
try {
|
||||||
$std_domain = $this->apiCall('Domains.add', $ins_data);
|
$std_domain = $this->apiCall('Domains.add', $ins_data, true);
|
||||||
$domainid = $std_domain['id'];
|
$domainid = $std_domain['id'];
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->logger()->logAction(FroxlorLogger::ADM_ACTION, LOG_ERR, "[API] Unable to add standard-subdomain: " . $e->getMessage());
|
$this->logger()->logAction(FroxlorLogger::ADM_ACTION, LOG_ERR, "[API] Unable to add standard-subdomain: " . $e->getMessage());
|
||||||
|
@ -274,7 +274,8 @@ class Domains extends ApiCommand implements ResourceEntity
|
|||||||
* $override_tls is true
|
* $override_tls is true
|
||||||
* @param string $description
|
* @param string $description
|
||||||
* optional custom description (currently not used/shown in the frontend), default empty
|
* optional custom description (currently not used/shown in the frontend), default empty
|
||||||
*
|
* @param bool $is_stdsubdomain (internally)
|
||||||
|
* optional whether this is a standard subdomain for a customer which is being added so no usage is decreased
|
||||||
* @access admin
|
* @access admin
|
||||||
* @return string json-encoded array
|
* @return string json-encoded array
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
@ -282,7 +283,8 @@ class Domains extends ApiCommand implements ResourceEntity
|
|||||||
public function add()
|
public function add()
|
||||||
{
|
{
|
||||||
if ($this->isAdmin()) {
|
if ($this->isAdmin()) {
|
||||||
if ($this->getUserDetail('domains_used') < $this->getUserDetail('domains') || $this->getUserDetail('domains') == '-1') {
|
$is_stdsubdomain = $this->isInternal() ? $this->getBoolParam('is_stdsubdomain', true, 0) : false;
|
||||||
|
if ($is_stdsubdomain || $this->getUserDetail('domains_used') < $this->getUserDetail('domains') || $this->getUserDetail('domains') == '-1') {
|
||||||
// parameters
|
// parameters
|
||||||
$p_domain = $this->getParam('domain');
|
$p_domain = $this->getParam('domain');
|
||||||
|
|
||||||
@ -795,12 +797,15 @@ class Domains extends ApiCommand implements ResourceEntity
|
|||||||
$ins_data['id'] = $domainid;
|
$ins_data['id'] = $domainid;
|
||||||
unset($ins_data);
|
unset($ins_data);
|
||||||
|
|
||||||
|
if (!$is_stdsubdomain) {
|
||||||
$upd_stmt = Database::prepare("
|
$upd_stmt = Database::prepare("
|
||||||
UPDATE `" . TABLE_PANEL_ADMINS . "` SET `domains_used` = `domains_used` + 1
|
UPDATE `" . TABLE_PANEL_ADMINS . "` SET `domains_used` = `domains_used` + 1
|
||||||
WHERE `adminid` = :adminid");
|
WHERE `adminid` = :adminid
|
||||||
|
");
|
||||||
Database::pexecute($upd_stmt, [
|
Database::pexecute($upd_stmt, [
|
||||||
'adminid' => $adminid
|
'adminid' => $adminid
|
||||||
], true, true);
|
], true, true);
|
||||||
|
}
|
||||||
|
|
||||||
$ins_stmt = Database::prepare("
|
$ins_stmt = Database::prepare("
|
||||||
INSERT INTO `" . TABLE_DOMAINTOIP . "` SET
|
INSERT INTO `" . TABLE_DOMAINTOIP . "` SET
|
||||||
|
@ -90,17 +90,11 @@ return [
|
|||||||
]
|
]
|
||||||
],
|
],
|
||||||
'mail_catchall' => [
|
'mail_catchall' => [
|
||||||
|
'visible' => Settings::Get('catchall.catchall_enabled') == '1',
|
||||||
'label' => lng('emails.catchall'),
|
'label' => lng('emails.catchall'),
|
||||||
'type' => 'label',
|
'type' => 'checkbox',
|
||||||
'value' => ((int)$result['iscatchall'] == 0 ? lng('panel.no') : lng('panel.yes')),
|
'value' => '1',
|
||||||
'next_to' => [
|
'checked' => (int)$result['iscatchall'],
|
||||||
'add_link' => [
|
|
||||||
'type' => 'link',
|
|
||||||
'href' => $filename . '?page=' . $page . '&domainid=' . $result['domainid'] . '&action=togglecatchall&id=' . $result['id'],
|
|
||||||
'label' => '<i class="fa-solid fa-arrow-right-arrow-left"></i> ' . lng('panel.toggle'),
|
|
||||||
'classes' => 'btn btn-sm btn-secondary'
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
],
|
||||||
'spam_tag_level' => [
|
'spam_tag_level' => [
|
||||||
'visible' => Settings::Get('antispam.activated') == '1',
|
'visible' => Settings::Get('antispam.activated') == '1',
|
||||||
@ -119,30 +113,16 @@ return [
|
|||||||
'bypass_spam' => [
|
'bypass_spam' => [
|
||||||
'visible' => Settings::Get('antispam.activated') == '1',
|
'visible' => Settings::Get('antispam.activated') == '1',
|
||||||
'label' => lng('antispam.bypass_spam'),
|
'label' => lng('antispam.bypass_spam'),
|
||||||
'type' => 'label',
|
'type' => 'checkbox',
|
||||||
'value' => ((int)$result['bypass_spam'] == 0 ? lng('panel.no') : lng('panel.yes')),
|
'value' => '1',
|
||||||
'next_to' => [
|
'checked' => (int)$result['bypass_spam'],
|
||||||
'add_link' => [
|
|
||||||
'type' => 'link',
|
|
||||||
'href' => $filename . '?page=' . $page . '&domainid=' . $result['domainid'] . '&action=togglebypass&id=' . $result['id'],
|
|
||||||
'label' => '<i class="fa-solid fa-arrow-right-arrow-left"></i> ' . lng('panel.toggle'),
|
|
||||||
'classes' => 'btn btn-sm btn-secondary'
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
],
|
||||||
'policy_greylist' => [
|
'policy_greylist' => [
|
||||||
'visible' => Settings::Get('antispam.activated') == '1',
|
'visible' => Settings::Get('antispam.activated') == '1',
|
||||||
'label' => lng('antispam.policy_greylist'),
|
'label' => lng('antispam.policy_greylist'),
|
||||||
'type' => 'label',
|
'type' => 'checkbox',
|
||||||
'value' => ((int)$result['policy_greylist'] == 0 ? lng('panel.no') : lng('panel.yes')),
|
'value' => '1',
|
||||||
'next_to' => [
|
'checked' => (int)$result['policy_greylist'],
|
||||||
'add_link' => [
|
|
||||||
'type' => 'link',
|
|
||||||
'href' => $filename . '?page=' . $page . '&domainid=' . $result['domainid'] . '&action=togglegreylist&id=' . $result['id'],
|
|
||||||
'label' => '<i class="fa-solid fa-arrow-right-arrow-left"></i> ' . lng('panel.toggle'),
|
|
||||||
'classes' => 'btn btn-sm btn-secondary'
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
],
|
||||||
'mail_fwds' => [
|
'mail_fwds' => [
|
||||||
'label' => lng('emails.forwarders') . ' (' . $forwarders_count . ')',
|
'label' => lng('emails.forwarders') . ' (' . $forwarders_count . ')',
|
||||||
|
Loading…
Reference in New Issue
Block a user