Options.php 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  1. <?php
  2. /**
  3. * This file is part of the ForkBB <https://github.com/forkbb>.
  4. *
  5. * @copyright (c) Visman <mio.visman@yandex.ru, https://github.com/MioVisman>
  6. * @license The MIT License (MIT)
  7. */
  8. declare(strict_types=1);
  9. namespace ForkBB\Models\Pages\Admin;
  10. use ForkBB\Core\Validator;
  11. use ForkBB\Models\Page;
  12. use ForkBB\Models\Pages\Admin;
  13. use ForkBB\Models\Config\Config;
  14. use function \ForkBB\__;
  15. class Options extends Admin
  16. {
  17. /**
  18. * Редактирование натроек форума
  19. */
  20. public function edit(array $args, string $method): Page
  21. {
  22. $this->c->Lang->load('validator');
  23. $this->c->Lang->load('admin_options');
  24. $this->c->Lang->load('profile_other');
  25. $config = clone $this->c->config;
  26. if ('POST' === $method) {
  27. $v = $this->c->Validator->reset()
  28. ->addValidators([
  29. 'check_timeout' => [$this, 'vCheckTimeout'],
  30. 'check_dir' => [$this, 'vCheckDir'],
  31. 'check_empty' => [$this, 'vCheckEmpty'],
  32. ])->addRules([
  33. 'token' => 'token:AdminOptions',
  34. 'o_board_title' => 'required|string:trim|max:255',
  35. 'o_board_desc' => 'exist|string:trim,empty|max:65000 bytes|html',
  36. 'o_default_timezone' => 'required|string:trim|in:-12,-11,-10,-9.5,-9,-8.5,-8,-7,-6,-5,-4,-3.5,-3,-2,-1,0,1,2,3,3.5,4,4.5,5,5.5,5.75,6,6.5,7,8,8.75,9,9.5,10,10.5,11,11.5,12,12.75,13,14',
  37. 'b_default_dst' => 'required|integer|in:0,1',
  38. 'o_default_lang' => 'required|string:trim|in:' . \implode(',', $this->c->Func->getLangs()),
  39. 'o_default_style' => 'required|string:trim|in:' . \implode(',', $this->c->Func->getStyles()),
  40. 'i_timeout_visit' => 'required|integer|min:0|max:99999',
  41. 'i_timeout_online' => 'required|integer|min:0|max:99999|check_timeout',
  42. 'i_redirect_delay' => 'required|integer|min:0|max:99999',
  43. 'b_show_user_info' => 'required|integer|in:0,1',
  44. 'b_show_post_count' => 'required|integer|in:0,1',
  45. 'i_topic_review' => 'required|integer|min:0|max:50',
  46. 'i_disp_topics_default' => 'required|integer|min:10|max:50',
  47. 'i_disp_posts_default' => 'required|integer|min:10|max:50',
  48. 'i_disp_users' => 'required|integer|min:10|max:50',
  49. 'b_quickpost' => 'required|integer|in:0,1',
  50. 'b_users_online' => 'required|integer|in:0,1',
  51. 'b_show_dot' => 'required|integer|in:0,1',
  52. 'b_topic_views' => 'required|integer|in:0,1',
  53. 'o_additional_navlinks' => 'exist|string:trim|max:65000 bytes',
  54. 'i_feed_type' => 'required|integer|in:0,1,2',
  55. 'i_feed_ttl' => 'required|integer|in:0,5,15,30,60',
  56. 'i_report_method' => 'required|integer|in:0,1,2',
  57. 'o_mailing_list' => 'exist|string:trim|max:65000 bytes', // ???? проверка списка email
  58. 'b_avatars' => 'required|integer|in:0,1',
  59. 'o_avatars_dir' => 'required|string:trim|max:255|check_dir',
  60. 'i_avatars_width' => 'required|integer|min:50|max:999',
  61. 'i_avatars_height' => 'required|integer|min:50|max:999',
  62. 'i_avatars_size' => 'required|integer|min:0|max:9999999',
  63. 'o_admin_email' => 'required|string:trim|email',
  64. 'o_webmaster_email' => 'required|string:trim|email',
  65. 'b_forum_subscriptions' => 'required|integer|in:0,1',
  66. 'b_topic_subscriptions' => 'required|integer|in:0,1',
  67. 'i_email_max_recipients' => 'required|integer|min:1|max:99999',
  68. 'o_smtp_host' => 'exist|string:trim|max:255',
  69. 'o_smtp_user' => 'exist|string:trim|max:255',
  70. 'o_smtp_pass' => 'exist|string:trim|max:255',
  71. 'changeSmtpPassword' => 'checkbox',
  72. 'b_smtp_ssl' => 'required|integer|in:0,1',
  73. 'b_regs_allow' => 'required|integer|in:0,1',
  74. 'b_regs_verify' => 'required|integer|in:0,1',
  75. 'b_regs_report' => 'required|integer|in:0,1',
  76. 'b_rules' => 'required|integer|in:0,1|check_empty:o_rules_message',
  77. 'o_rules_message' => 'exist|string:trim|max:65000 bytes|html',
  78. 'i_default_email_setting' => 'required|integer|in:0,1,2',
  79. 'b_announcement' => 'required|integer|in:0,1|check_empty:o_announcement_message',
  80. 'o_announcement_message' => 'exist|string:trim|max:65000 bytes|html',
  81. 'b_message_all_caps' => 'required|integer|in:0,1',
  82. 'b_subject_all_caps' => 'required|integer|in:0,1',
  83. 'b_force_guest_email' => 'required|integer|in:0,1',
  84. 'b_sig_all_caps' => 'required|integer|in:0,1',
  85. 'b_poll_enabled' => 'required|integer|in:0,1',
  86. 'i_poll_max_questions' => 'required|integer|min:1|max:99',
  87. 'i_poll_max_fields' => 'required|integer|min:2|max:99',
  88. 'i_poll_time' => 'required|integer|min:0|max:999999',
  89. 'i_poll_term' => 'required|integer|min:0|max:99',
  90. 'b_poll_guest' => 'required|integer|in:0,1',
  91. 'b_pm' => 'required|integer|in:0,1',
  92. ])->addAliases([
  93. ])->addArguments([
  94. ])->addMessages([
  95. 'o_board_title' => 'Must enter title message',
  96. 'o_admin_email' => 'Invalid e-mail message',
  97. 'o_webmaster_email' => 'Invalid webmaster e-mail message',
  98. ]);
  99. $valid = $v->validation($_POST);
  100. $data = $v->getData();
  101. if (empty($data['changeSmtpPassword'])) {
  102. unset($data['o_smtp_pass']);
  103. }
  104. unset($data['changeSmtpPassword'], $data['token']);
  105. foreach ($data as $attr => $value) {
  106. $config->$attr = $value;
  107. }
  108. if ($valid) {
  109. $config->save();
  110. return $this->c->Redirect->page('AdminOptions')->message('Options updated redirect');
  111. }
  112. $this->fIswev = $v->getErrors();
  113. }
  114. $this->aIndex = 'options';
  115. $this->nameTpl = 'admin/form';
  116. $this->form = $this->formEdit($config);
  117. $this->titleForm = 'Options head';
  118. $this->classForm = ['editoptions'];
  119. return $this;
  120. }
  121. /**
  122. * Дополнительная проверка времени online
  123. */
  124. public function vCheckTimeout(Validator $v, int $timeout): int
  125. {
  126. if ($timeout >= $v->i_timeout_visit) {
  127. $v->addError('Timeout error message');
  128. }
  129. return $timeout;
  130. }
  131. /**
  132. * Дополнительная проверка каталога аватарок
  133. */
  134. public function vCheckDir(Validator $v, string $dir): string
  135. {
  136. $dir = '/' . \trim(\str_replace(['\\', '.', '//', ':'], ['/', '', '', ''], $dir), '/');
  137. if (! \is_dir($this->c->DIR_PUBLIC . $dir)) {
  138. $v->addError('The folder for uploading avatars is incorrectly');
  139. } elseif (! \is_writable($this->c->DIR_PUBLIC . $dir)) {
  140. $v->addError('For PHP, it is forbidden to write in the folder for uploading avatars');
  141. }
  142. return $dir;
  143. }
  144. /**
  145. * Дополнительная проверка на пустоту другого поля
  146. */
  147. public function vCheckEmpty(Validator $v, int $value, string $attr): int
  148. {
  149. if (
  150. 0 !== $value
  151. && 0 === \strlen($v->$attr)
  152. ) {
  153. $value = 0;
  154. }
  155. return $value;
  156. }
  157. /**
  158. * Формирует данные для формы
  159. */
  160. protected function formEdit(Config $config): array
  161. {
  162. $form = [
  163. 'action' => $this->c->Router->link('AdminOptions'),
  164. 'hidden' => [
  165. 'token' => $this->c->Csrf->create('AdminOptions'),
  166. ],
  167. 'sets' => [],
  168. 'btns' => [
  169. 'save' => [
  170. 'type' => 'submit',
  171. 'value' => __('Save changes'),
  172. ],
  173. ],
  174. ];
  175. $yn = [1 => __('Yes'), 0 => __('No')];
  176. $langs = $this->c->Func->getNameLangs();
  177. $styles = $this->c->Func->getStyles();
  178. $form['sets']['essentials'] = [
  179. 'legend' => 'Essentials subhead',
  180. 'fields' => [
  181. 'o_board_title' => [
  182. 'type' => 'text',
  183. 'maxlength' => '255',
  184. 'value' => $config->o_board_title,
  185. 'caption' => 'Board title label',
  186. 'help' => 'Board title help',
  187. 'required' => true,
  188. # 'autofocus' => true,
  189. ],
  190. 'o_board_desc' => [
  191. 'type' => 'textarea',
  192. 'value' => $config->o_board_desc,
  193. 'caption' => 'Board desc label',
  194. 'help' => 'Board desc help',
  195. ],
  196. 'o_default_timezone' => [
  197. 'type' => 'select',
  198. 'options' => [
  199. '-12' => __('UTC-12:00'),
  200. '-11' => __('UTC-11:00'),
  201. '-10' => __('UTC-10:00'),
  202. '-9.5' => __('UTC-09:30'),
  203. '-9' => __('UTC-09:00'),
  204. '-8.5' => __('UTC-08:30'),
  205. '-8' => __('UTC-08:00'),
  206. '-7' => __('UTC-07:00'),
  207. '-6' => __('UTC-06:00'),
  208. '-5' => __('UTC-05:00'),
  209. '-4' => __('UTC-04:00'),
  210. '-3.5' => __('UTC-03:30'),
  211. '-3' => __('UTC-03:00'),
  212. '-2' => __('UTC-02:00'),
  213. '-1' => __('UTC-01:00'),
  214. '0' => __('UTC'),
  215. '1' => __('UTC+01:00'),
  216. '2' => __('UTC+02:00'),
  217. '3' => __('UTC+03:00'),
  218. '3.5' => __('UTC+03:30'),
  219. '4' => __('UTC+04:00'),
  220. '4.5' => __('UTC+04:30'),
  221. '5' => __('UTC+05:00'),
  222. '5.5' => __('UTC+05:30'),
  223. '5.75' => __('UTC+05:45'),
  224. '6' => __('UTC+06:00'),
  225. '6.5' => __('UTC+06:30'),
  226. '7' => __('UTC+07:00'),
  227. '8' => __('UTC+08:00'),
  228. '8.75' => __('UTC+08:45'),
  229. '9' => __('UTC+09:00'),
  230. '9.5' => __('UTC+09:30'),
  231. '10' => __('UTC+10:00'),
  232. '10.5' => __('UTC+10:30'),
  233. '11' => __('UTC+11:00'),
  234. '11.5' => __('UTC+11:30'),
  235. '12' => __('UTC+12:00'),
  236. '12.75' => __('UTC+12:45'),
  237. '13' => __('UTC+13:00'),
  238. '14' => __('UTC+14:00'),
  239. ],
  240. 'value' => $config->o_default_timezone,
  241. 'caption' => 'Timezone label',
  242. 'help' => 'Timezone help',
  243. ],
  244. 'b_default_dst' => [
  245. 'type' => 'radio',
  246. 'value' => $config->b_default_dst,
  247. 'values' => $yn,
  248. 'caption' => 'DST label',
  249. 'help' => 'DST help',
  250. ],
  251. 'o_default_lang' => [
  252. 'type' => 'select',
  253. 'options' => $langs,
  254. 'value' => $config->o_default_lang,
  255. 'caption' => 'Language label',
  256. 'help' => 'Language help',
  257. ],
  258. 'o_default_style' => [
  259. 'type' => 'select',
  260. 'options' => $styles,
  261. 'value' => $config->o_default_style,
  262. 'caption' => 'Default style label',
  263. 'help' => 'Default style help',
  264. ],
  265. ],
  266. ];
  267. $timestamp = \time() + ($this->user->timezone + $this->user->dst) * 3600;
  268. $form['sets']['timeouts'] = [
  269. 'legend' => 'Timeouts subhead',
  270. 'fields' => [
  271. 'i_timeout_visit' => [
  272. 'type' => 'number',
  273. 'min' => '0',
  274. 'max' => '99999',
  275. 'value' => $config->i_timeout_visit,
  276. 'caption' => 'Visit timeout label',
  277. 'help' => 'Visit timeout help',
  278. ],
  279. 'i_timeout_online' => [
  280. 'type' => 'number',
  281. 'min' => '0',
  282. 'max' => '99999',
  283. 'value' => $config->i_timeout_online,
  284. 'caption' => 'Online timeout label',
  285. 'help' => 'Online timeout help',
  286. ],
  287. 'i_redirect_delay' => [
  288. 'type' => 'number',
  289. 'min' => '0',
  290. 'max' => '99999',
  291. 'value' => $config->i_redirect_delay,
  292. 'caption' => 'Redirect time label',
  293. 'help' => 'Redirect time help',
  294. ],
  295. ],
  296. ];
  297. $form['sets']['display'] = [
  298. 'legend' => 'Display subhead',
  299. 'fields' => [
  300. 'b_show_user_info' => [
  301. 'type' => 'radio',
  302. 'value' => $config->b_show_user_info,
  303. 'values' => $yn,
  304. 'caption' => 'Info in posts label',
  305. 'help' => 'Info in posts help',
  306. ],
  307. 'b_show_post_count' => [
  308. 'type' => 'radio',
  309. 'value' => $config->b_show_post_count,
  310. 'values' => $yn,
  311. 'caption' => 'Post count label',
  312. 'help' => 'Post count help',
  313. ],
  314. 'i_disp_topics_default' => [
  315. 'type' => 'number',
  316. 'min' => '10',
  317. 'max' => '50',
  318. 'value' => $config->i_disp_topics_default,
  319. 'caption' => 'Topics per page label',
  320. 'help' => 'Topics per page help',
  321. ],
  322. 'i_disp_posts_default' => [
  323. 'type' => 'number',
  324. 'min' => '10',
  325. 'max' => '50',
  326. 'value' => $config->i_disp_posts_default,
  327. 'caption' => 'Posts per page label',
  328. 'help' => 'Posts per page help',
  329. ],
  330. 'i_disp_users' => [
  331. 'type' => 'number',
  332. 'min' => '10',
  333. 'max' => '50',
  334. 'value' => $config->i_disp_users,
  335. 'caption' => 'Users per page label',
  336. 'help' => 'Users per page help',
  337. ],
  338. 'i_topic_review' => [
  339. 'type' => 'number',
  340. 'min' => '0',
  341. 'max' => '50',
  342. 'value' => $config->i_topic_review,
  343. 'caption' => 'Topic review label',
  344. 'help' => 'Topic review help',
  345. ],
  346. 'b_message_all_caps' => [
  347. 'type' => 'radio',
  348. 'value' => $config->b_message_all_caps,
  349. 'values' => $yn,
  350. 'caption' => 'All caps message label',
  351. 'help' => 'All caps message help',
  352. ],
  353. 'b_subject_all_caps' => [
  354. 'type' => 'radio',
  355. 'value' => $config->b_subject_all_caps,
  356. 'values' => $yn,
  357. 'caption' => 'All caps subject label',
  358. 'help' => 'All caps subject help',
  359. ],
  360. 'b_sig_all_caps' => [
  361. 'type' => 'radio',
  362. 'value' => $config->b_sig_all_caps,
  363. 'values' => $yn,
  364. 'caption' => 'All caps sigs label',
  365. 'help' => 'All caps sigs help',
  366. ],
  367. 'b_force_guest_email' => [
  368. 'type' => 'radio',
  369. 'value' => $config->b_force_guest_email,
  370. 'values' => $yn,
  371. 'caption' => 'Require e-mail label',
  372. 'help' => 'Require e-mail help',
  373. ],
  374. ],
  375. ];
  376. $form['sets']['features'] = [
  377. 'legend' => 'Features subhead',
  378. 'fields' => [
  379. 'b_quickpost' => [
  380. 'type' => 'radio',
  381. 'value' => $config->b_quickpost,
  382. 'values' => $yn,
  383. 'caption' => 'Quick post label',
  384. 'help' => 'Quick post help',
  385. ],
  386. 'b_users_online' => [
  387. 'type' => 'radio',
  388. 'value' => $config->b_users_online,
  389. 'values' => $yn,
  390. 'caption' => 'Users online label',
  391. 'help' => 'Users online help',
  392. ],
  393. 'b_show_dot' => [
  394. 'type' => 'radio',
  395. 'value' => $config->b_show_dot,
  396. 'values' => $yn,
  397. 'caption' => 'User has posted label',
  398. 'help' => 'User has posted help',
  399. ],
  400. 'b_topic_views' => [
  401. 'type' => 'radio',
  402. 'value' => $config->b_topic_views,
  403. 'values' => $yn,
  404. 'caption' => 'Topic views label',
  405. 'help' => 'Topic views help',
  406. ],
  407. 'o_additional_navlinks' => [
  408. 'type' => 'textarea',
  409. 'value' => $config->o_additional_navlinks,
  410. 'caption' => 'Menu items label',
  411. 'help' => 'Menu items help',
  412. ],
  413. ],
  414. ];
  415. $form['sets']['feed'] = [
  416. 'legend' => 'Feed subhead',
  417. 'fields' => [
  418. 'i_feed_type' => [
  419. 'type' => 'radio',
  420. 'value' => $config->i_feed_type,
  421. 'values' => [
  422. 0 => __('No feeds'),
  423. 1 => __('RSS'),
  424. 2 => __('Atom'),
  425. ],
  426. 'caption' => 'Default feed label',
  427. 'help' => 'Default feed help',
  428. ],
  429. 'i_feed_ttl' => [
  430. 'type' => 'select',
  431. 'options' => [
  432. 0 => __('No cache'),
  433. 5 => __(['%d Minutes', 5]),
  434. 15 => __(['%d Minutes', 15]),
  435. 30 => __(['%d Minutes', 30]),
  436. 60 => __(['%d Minutes', 60]),
  437. ],
  438. 'value' => $config->i_feed_ttl,
  439. 'caption' => 'Feed TTL label',
  440. 'help' => 'Feed TTL help',
  441. ],
  442. ],
  443. ];
  444. $form['sets']['reports'] = [
  445. 'legend' => 'Reports subhead',
  446. 'fields' => [
  447. 'i_report_method' => [
  448. 'type' => 'radio',
  449. 'value' => $config->i_report_method,
  450. 'values' => [
  451. 0 => __('Internal'),
  452. 1 => __('By e-mail'),
  453. 2 => __('Both'),
  454. ],
  455. 'caption' => 'Reporting method label',
  456. 'help' => 'Reporting method help',
  457. ],
  458. 'o_mailing_list' => [
  459. 'type' => 'textarea',
  460. 'value' => $config->o_mailing_list,
  461. 'caption' => 'Mailing list label',
  462. 'help' => 'Mailing list help',
  463. ],
  464. ],
  465. ];
  466. $form['sets']['avatars'] = [
  467. 'legend' => 'Avatars subhead',
  468. 'fields' => [
  469. 'b_avatars' => [
  470. 'type' => 'radio',
  471. 'value' => $config->b_avatars,
  472. 'values' => $yn,
  473. 'caption' => 'Use avatars label',
  474. 'help' => 'Use avatars help',
  475. ],
  476. 'o_avatars_dir' => [
  477. 'type' => 'text',
  478. 'maxlength' => '255',
  479. 'value' => $config->o_avatars_dir,
  480. 'caption' => 'Upload directory label',
  481. 'help' => ['Upload directory help', $this->c->PUBLIC_URL],
  482. 'required' => true,
  483. ],
  484. 'i_avatars_width' => [
  485. 'type' => 'number',
  486. 'min' => '50',
  487. 'max' => '999',
  488. 'value' => $config->i_avatars_width,
  489. 'caption' => 'Max width label',
  490. 'help' => 'Max width help',
  491. ],
  492. 'i_avatars_height' => [
  493. 'type' => 'number',
  494. 'min' => '50',
  495. 'max' => '999',
  496. 'value' => $config->i_avatars_height,
  497. 'caption' => 'Max height label',
  498. 'help' => 'Max height help',
  499. ],
  500. 'i_avatars_size' => [
  501. 'type' => 'number',
  502. 'min' => '0',
  503. 'max' => '9999999',
  504. 'value' => $config->i_avatars_size,
  505. 'caption' => 'Max size label',
  506. 'help' => 'Max size help',
  507. ],
  508. ],
  509. ];
  510. $form['sets']['email'] = [
  511. 'legend' => 'E-mail subhead',
  512. 'fields' => [
  513. 'o_admin_email' => [
  514. 'type' => 'text',
  515. 'maxlength' => '80',
  516. 'value' => $config->o_admin_email,
  517. 'caption' => 'Admin e-mail label',
  518. 'help' => 'Admin e-mail help',
  519. 'required' => true,
  520. 'pattern' => '.+@.+',
  521. ],
  522. 'o_webmaster_email' => [
  523. 'type' => 'text',
  524. 'maxlength' => '80',
  525. 'value' => $config->o_webmaster_email,
  526. 'caption' => 'Webmaster e-mail label',
  527. 'help' => 'Webmaster e-mail help',
  528. 'required' => true,
  529. 'pattern' => '.+@.+',
  530. ],
  531. 'b_forum_subscriptions' => [
  532. 'type' => 'radio',
  533. 'value' => $config->b_forum_subscriptions,
  534. 'values' => $yn,
  535. 'caption' => 'Forum subscriptions label',
  536. 'help' => 'Forum subscriptions help',
  537. ],
  538. 'b_topic_subscriptions' => [
  539. 'type' => 'radio',
  540. 'value' => $config->b_topic_subscriptions,
  541. 'values' => $yn,
  542. 'caption' => 'Topic subscriptions label',
  543. 'help' => 'Topic subscriptions help',
  544. ],
  545. 'i_email_max_recipients' => [
  546. 'type' => 'number',
  547. 'min' => '1',
  548. 'max' => '99999',
  549. 'value' => $config->i_email_max_recipients,
  550. 'caption' => 'Email max recipients label',
  551. 'help' => 'Email max recipients help',
  552. ],
  553. 'o_smtp_host' => [
  554. 'type' => 'text',
  555. 'maxlength' => '255',
  556. 'value' => $config->o_smtp_host,
  557. 'caption' => 'SMTP address label',
  558. 'help' => 'SMTP address help',
  559. ],
  560. 'o_smtp_user' => [
  561. 'type' => 'text',
  562. 'maxlength' => '255',
  563. 'value' => $config->o_smtp_user,
  564. 'caption' => 'SMTP username label',
  565. 'help' => 'SMTP username help',
  566. ],
  567. 'o_smtp_pass' => [
  568. 'type' => 'password',
  569. 'maxlength' => '255',
  570. 'value' => $config->o_smtp_pass ? ' ' : null,
  571. 'caption' => 'SMTP password label',
  572. 'help' => 'SMTP password help',
  573. ],
  574. 'changeSmtpPassword' => [
  575. 'type' => 'checkbox',
  576. 'caption' => '',
  577. 'label' => 'SMTP change password help',
  578. ],
  579. 'b_smtp_ssl' => [
  580. 'type' => 'radio',
  581. 'value' => $config->b_smtp_ssl,
  582. 'values' => $yn,
  583. 'caption' => 'SMTP SSL label',
  584. 'help' => 'SMTP SSL help',
  585. ],
  586. ],
  587. ];
  588. $form['sets']['registration'] = [
  589. 'legend' => 'Registration subhead',
  590. 'fields' => [
  591. 'b_regs_allow' => [
  592. 'type' => 'radio',
  593. 'value' => $config->b_regs_allow,
  594. 'values' => $yn,
  595. 'caption' => 'Allow new label',
  596. 'help' => 'Allow new help',
  597. ],
  598. 'b_regs_verify' => [
  599. 'type' => 'radio',
  600. 'value' => $config->b_regs_verify,
  601. 'values' => $yn,
  602. 'caption' => 'Verify label',
  603. 'help' => 'Verify help',
  604. ],
  605. 'b_regs_report' => [
  606. 'type' => 'radio',
  607. 'value' => $config->b_regs_report,
  608. 'values' => $yn,
  609. 'caption' => 'Report new label',
  610. 'help' => 'Report new help',
  611. ],
  612. 'b_rules' => [
  613. 'type' => 'radio',
  614. 'value' => $config->b_rules,
  615. 'values' => $yn,
  616. 'caption' => 'Use rules label',
  617. 'help' => 'Use rules help',
  618. ],
  619. 'o_rules_message' => [
  620. 'type' => 'textarea',
  621. 'value' => $config->o_rules_message,
  622. 'caption' => 'Rules label',
  623. 'help' => 'Rules help',
  624. ],
  625. 'i_default_email_setting' => [
  626. 'class' => ['block'],
  627. 'type' => 'radio',
  628. 'value' => $config->i_default_email_setting,
  629. 'values' => [
  630. 0 => __('Display e-mail label'),
  631. 1 => __('Hide allow form label'),
  632. 2 => __('Hide both label'),
  633. ],
  634. 'caption' => 'E-mail default label',
  635. 'help' => 'E-mail default help',
  636. ],
  637. ],
  638. ];
  639. $form['sets']['announcement'] = [
  640. 'legend' => 'Announcement subhead',
  641. 'fields' => [
  642. 'b_announcement' => [
  643. 'type' => 'radio',
  644. 'value' => $config->b_announcement,
  645. 'values' => $yn,
  646. 'caption' => 'Display announcement label',
  647. 'help' => 'Display announcement help',
  648. ],
  649. 'o_announcement_message' => [
  650. 'type' => 'textarea',
  651. 'value' => $config->o_announcement_message,
  652. 'caption' => 'Announcement message label',
  653. 'help' => 'Announcement message help',
  654. ],
  655. ],
  656. ];
  657. $form['sets']['polls'] = [
  658. 'legend' => 'Polls subhead',
  659. 'fields' => [
  660. 'b_poll_enabled' => [
  661. 'type' => 'radio',
  662. 'value' => $config->b_poll_enabled,
  663. 'values' => $yn,
  664. 'caption' => 'Allow polls label',
  665. ],
  666. 'i_poll_max_questions' => [
  667. 'type' => 'number',
  668. 'min' => '1',
  669. 'max' => '99',
  670. 'value' => $config->i_poll_max_questions,
  671. 'caption' => 'Max questions label',
  672. 'help' => 'Max questions help',
  673. ],
  674. 'i_poll_max_fields' => [
  675. 'type' => 'number',
  676. 'min' => '2',
  677. 'max' => '99',
  678. 'value' => $config->i_poll_max_fields,
  679. 'caption' => 'Max options label',
  680. 'help' => 'Max options help',
  681. ],
  682. 'i_poll_time' => [
  683. 'type' => 'number',
  684. 'min' => '0',
  685. 'max' => '999999',
  686. 'value' => $config->i_poll_time,
  687. 'caption' => 'Poll edit time label',
  688. 'help' => 'Poll edit time help',
  689. ],
  690. 'i_poll_term' => [
  691. 'type' => 'number',
  692. 'min' => '0',
  693. 'max' => '99',
  694. 'value' => $config->i_poll_term,
  695. 'caption' => 'Hidden voices label',
  696. 'help' => 'Hidden voices help',
  697. ],
  698. 'b_poll_guest' => [
  699. 'type' => 'radio',
  700. 'value' => $config->b_poll_guest,
  701. 'values' => $yn,
  702. 'caption' => 'Result for guest label',
  703. 'help' => 'Result for guest help',
  704. ],
  705. ],
  706. ];
  707. $form['sets']['pm'] = [
  708. 'legend' => 'PM subhead',
  709. 'fields' => [
  710. 'b_pm' => [
  711. 'type' => 'radio',
  712. 'value' => $config->b_pm,
  713. 'values' => $yn,
  714. 'caption' => 'Allow PM label',
  715. 'help' => ['Allow PM help', __('User groups'), $this->c->Router->link('AdminGroups')],
  716. ],
  717. ],
  718. ];
  719. return $form;
  720. }
  721. }