-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoptions.php
100 lines (87 loc) · 3 KB
/
options.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
use Bitrix\Main\Application;
use Bitrix\Main\Config\Option;
use Bitrix\Main\Loader;
use Bitrix\Main\Localization\Loc;
Loc::loadMessages($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/options.php');
Loc::loadMessages(__FILE__);
$module_id = 'bsi.queue';
Loader::includeModule($module_id);
if (!$USER->IsAdmin()) {
$APPLICATION->AuthForm(Loc::getMessage('ACCESS_DENIED'));
}
$request = Application::getInstance()->getContext()->getRequest();
$tabs = [
[
'DIV' => 'edit1',
'TAB' => Loc::getMessage('MAIN_TAB_SET'),
'TITLE' => Loc::getMessage('MAIN_TAB_TITLE_SET'),
'ICON' => '',
],
];
$tabControl = new CAdminTabControl('tabControl', $tabs);
$allOptions = [
[
'id' => 'stats_lifetime',
'name' => Loc::getMessage('BSI_QUEUE_OPTION_STATS_LIFETIME'),
'type' => 'integer',
],
];
foreach ($allOptions as &$option) {
$option['value'] = Option::get($module_id, $option['id'], null);
}
unset($option);
$errorMessage = '';
if ($request->isPost() && $request['Update'] !== '' && check_bitrix_sessid()) {
foreach ($allOptions as $option) {
$value = $request[$option['id']] ?? null;
if ($option['type'] === 'integer') {
$value = (int) $value;
} elseif (!is_string($value)) {
$value = trim($value);
}
Option::set($mid, $option['id'], $value);
}
if ($e = $APPLICATION->getException()) {
CAdminMessage::ShowMessage([
'DETAILS' => $e->getString(),
'TYPE' => 'ERROR',
'HTML' => true,
]);
} elseif ($request['back_url_settings'] !== '') {
LocalRedirect($request['back_url_settings']);
} else {
LocalRedirect($APPLICATION->GetCurPage() . '?' . http_build_query([
'mid' => $mid,
'lang' => LANGUAGE_ID,
'back_url_settings' => $request['back_url_settings'],
]) . '&' . $tabControl->ActiveTabParam());
}
}
?>
<form method="post"
action="<?= $APPLICATION->GetCurPage() ?>?mid=<?= htmlspecialcharsbx($mid) ?>&lang=<?= LANGUAGE_ID ?>">
<?php
echo bitrix_sessid_post();
$tabControl->Begin();
$tabControl->BeginNextTab();
if ($errorMessage) : ?>
<tr>
<td colspan="2" style="text-align: center;"><b style="color: red;"><?= $errorMessage ?></b></td>
</tr>
<?php endif ?>
<?php foreach ($allOptions as $option) : ?>
<tr>
<td style="width: 40%;"><?= $option['name'] ?>:</td>
<td style="width: 60%;">
<input type="text" name="<?= $option['id'] ?>" value="<?= htmlspecialchars($option['value']) ?>">
</td>
</tr>
<?php endforeach ?>
<?php
$tabControl->Buttons() ?>
<input type="submit" name="Update" value="<?= Loc::getMessage('MAIN_SAVE') ?>" class="adm-btn-save">
<input type="reset" name="reset" value="<?= Loc::getMessage('MAIN_RESET') ?>">
<?php $tabControl->End() ?>
</form>