public
nobgit
read
NobMail
Based on mailcow: dockerized
Languages
Repository composition by tracked source files.
PHP
49%
JavaScript
35%
HTML
9%
CSS
4%
Shell
2%
Python
1%
Lua
0%
Perl
0%
Ruby
0%
SCSS
0%
Create file
Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git
Trace
data/web/inc/functions.presets.inc.php
Trace helps you understand code history line by line. See who changed each line, when it changed, and which commit introduced it.
Author
Date
Commit
Line
Code
1
<?php
2
function presets($_action, $_kind) {
3
switch ($_action) {
4
case 'get':
5
if ($_SESSION['mailcow_cc_role'] != "admin" && $_SESSION['mailcow_cc_role'] != "domainadmin") {
6
return false;
7
}
8
$presets = array();
9
$kind = strtolower(trim($_kind));
10
$lang_base = 'admin';
11
$presets_path = __DIR__ . '/presets/' . $kind;
12
if (!in_array($kind, ['rspamd', 'sieve'], true)) {
13
return array();
14
}
15
if ($kind === 'sieve') {
16
$lang_base = 'mailbox';
17
}
18
foreach (glob($presets_path . '/*.yml') as $filename) {
19
$presets[] = getPresetFromFilePath($filename, $lang_base);
20
}
21
return $presets;
22
break;
23
}
24
return array();
25
}
26
function getPresetFromFilePath($filePath, $lang_base) {
27
global $lang;
28
$preset = Spyc::YAMLLoad($filePath);
29
$preset = ['name' => basename($filePath, '.yml')] + $preset;
30
/* get translated headlines */
31
if (isset($preset['headline']) && strpos($preset['headline'], 'lang.') === 0) {
32
$langTextName = trim(substr($preset['headline'], 5));
33
if (isset($lang[$lang_base][$langTextName])) {
34
$preset['headline'] = $lang[$lang_base][$langTextName];
35
}
36
}
37
return $preset;
38
}