[Web] Small adjustments to presets
parent
9f754c95b9
commit
8003f3b4b3
|
@ -0,0 +1 @@
|
||||||
|
/* Autogenerated by mailcow */
|
|
@ -1,56 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
function presets($_action, $_kind, $_object)
|
function presets($_action, $_kind) {
|
||||||
{
|
global $lang;
|
||||||
if ($_SESSION['mailcow_cc_role'] !== 'admin') {
|
switch ($_action) {
|
||||||
$_SESSION['return'][] = [
|
case 'get':
|
||||||
'type' => 'danger',
|
if ($_SESSION['mailcow_cc_role'] != "admin") {
|
||||||
'log' => [__FUNCTION__, $_action, $_data_log],
|
|
||||||
'msg' => 'access_denied',
|
|
||||||
];
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
$presets = array();
|
||||||
global $lang;
|
|
||||||
if ($_action === 'get') {
|
|
||||||
$kind = strtolower(trim($_kind));
|
$kind = strtolower(trim($_kind));
|
||||||
$langSection = 'admin';
|
$lang_base = 'admin';
|
||||||
$presetsPath = __DIR__ . '/presets/' . $kind;
|
$presets_path = __DIR__ . '/presets/' . $kind;
|
||||||
|
if (!in_array($kind, ['rspamd', 'sieve'], true)) {
|
||||||
if (!in_array($kind, ['admin-rspamd', 'mailbox-sieve'], true)) {
|
return array();
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
|
if ($kind === 'sieve') {
|
||||||
if ($kind === 'mailbox-sieve') {
|
$lang_base = 'mailbox';
|
||||||
$langSection = 'mailbox';
|
|
||||||
}
|
}
|
||||||
|
foreach (glob($presets_path . '/*.yml') as $filename) {
|
||||||
if ($_object !== 'all') {
|
$presets[] = getPresetFromFilePath($filename, $lang_base);
|
||||||
return getPresetFromFilePath($presetsPath . '/' . $_object . '.yml', $langSection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$presets = [];
|
|
||||||
foreach (glob($presetsPath . '/*.yml') as $filename) {
|
|
||||||
$presets[] = getPresetFromFilePath($filename, $langSection);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $presets;
|
return $presets;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
return array();
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
|
function getPresetFromFilePath($filePath, $lang_base) {
|
||||||
function getPresetFromFilePath($filePath, $langSection)
|
|
||||||
{
|
|
||||||
global $lang;
|
global $lang;
|
||||||
$preset = Spyc::YAMLLoad($filePath);
|
$preset = Spyc::YAMLLoad($filePath);
|
||||||
$preset = ['name' => basename($filePath, '.yml')] + $preset;
|
$preset = ['name' => basename($filePath, '.yml')] + $preset;
|
||||||
|
|
||||||
/* get translated headlines */
|
/* get translated headlines */
|
||||||
if (isset($preset['headline']) && strpos($preset['headline'], 'lang.') === 0) {
|
if (isset($preset['headline']) && strpos($preset['headline'], 'lang.') === 0) {
|
||||||
$langTextName = trim(substr($preset['headline'], 5));
|
$langTextName = trim(substr($preset['headline'], 5));
|
||||||
if (isset($lang[$langSection][$langTextName])) {
|
if (isset($lang[$lang_base][$langTextName])) {
|
||||||
$preset['headline'] = $lang[$langSection][$langTextName];
|
$preset['headline'] = $lang[$lang_base][$langTextName];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $preset;
|
return $preset;
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
headline: lang.rsettings_preset_1
|
|
||||||
content: |
|
|
||||||
priority = 10;
|
|
||||||
authenticated = yes;
|
|
||||||
apply "default" {
|
|
||||||
symbols_enabled = ["DKIM_SIGNED", "RATELIMITED", "RATELIMIT_UPDATE", "RATELIMIT_CHECK", "DYN_RL_CHECK", "HISTORY_SAVE", "MILTER_HEADERS", "ARC_SIGNED"];
|
|
||||||
}
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
headline: lang.rsettings_preset_1
|
||||||
|
content: |
|
||||||
|
priority = 10;
|
||||||
|
authenticated = yes;
|
||||||
|
apply "default" {
|
||||||
|
symbols_enabled = ["DKIM_SIGNED", "RATELIMITED", "RATELIMIT_UPDATE", "RATELIMIT_CHECK", "DYN_RL_CHECK", "HISTORY_SAVE", "MILTER_HEADERS", "ARC_SIGNED"];
|
||||||
|
}
|
|
@ -3,7 +3,7 @@ var rspamd_presetsElem = document.getElementById("rspamd_presets");
|
||||||
if (rspamd_presetsElem) {
|
if (rspamd_presetsElem) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
url: '/api/v1/get/presets-admin-rspamd/all',
|
url: '/api/v1/get/presets/rspamd',
|
||||||
jsonp: false,
|
jsonp: false,
|
||||||
complete: function (data) {
|
complete: function (data) {
|
||||||
if (data.responseText !== '{}') {
|
if (data.responseText !== '{}') {
|
||||||
|
|
|
@ -3,7 +3,7 @@ var sieve_presetsElem = document.getElementById("sieve_presets");
|
||||||
if (sieve_presetsElem) {
|
if (sieve_presetsElem) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
url: '/api/v1/get/presets-mailbox-sieve/all',
|
url: '/api/v1/get/presets/sieve',
|
||||||
jsonp: false,
|
jsonp: false,
|
||||||
complete: function (data) {
|
complete: function (data) {
|
||||||
if (data.responseText !== '{}') {
|
if (data.responseText !== '{}') {
|
||||||
|
|
|
@ -1071,11 +1071,15 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "presets-admin-rspamd":
|
case "presets":
|
||||||
process_get_return(presets('get', 'admin-rspamd', $object));
|
switch ($object) {
|
||||||
|
case "rspamd":
|
||||||
|
process_get_return(presets('get', 'rspamd'));
|
||||||
|
case "sieve":
|
||||||
break;
|
break;
|
||||||
case "presets-mailbox-sieve":
|
process_get_return(presets('get', 'sieve'));
|
||||||
process_get_return(presets('get', 'mailbox-sieve', $object));
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
break;
|
break;
|
||||||
// return no route found if no case is matched
|
// return no route found if no case is matched
|
||||||
|
|
Loading…
Reference in New Issue