GeneralSection.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace ModulesGarden\Servers\KerioEmail\App\UI\Client\Ressource\Sections;
  3. use ModulesGarden\Servers\KerioEmail\App\Libs\Product\ProductManager;
  4. use ModulesGarden\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Repository\ClassOfServices;
  5. use ModulesGarden\Servers\KerioEmail\App\Traits\FormExtendedTrait;
  6. use ModulesGarden\Servers\KerioEmail\App\UI\Admin\Custom\Sections\FreeFieldsSection;
  7. use ModulesGarden\Servers\KerioEmail\App\Validators\PasswordsValidator;
  8. use ModulesGarden\Servers\KerioEmail\App\Validators\RepeatPasswordValidator;
  9. use ModulesGarden\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Hidden;
  10. use ModulesGarden\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Password;
  11. use ModulesGarden\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Select;
  12. use ModulesGarden\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Text;
  13. use ModulesGarden\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Switcher;
  14. use ModulesGarden\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Number;
  15. use ModulesGarden\Servers\KerioEmail\Core\UI\Widget\Forms\Sections\InputGroup;
  16. use ModulesGarden\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\InputGroupElements;
  17. /**
  18. *
  19. * Created by PhpStorm.
  20. * User: Tomasz Bielecki ( tomasz.bi@modulesgarden.com )
  21. * Date: 12.11.19
  22. * Time: 13:39
  23. * Class GeneralSection
  24. */
  25. class GeneralSection extends FreeFieldsSection
  26. {
  27. protected $id = 'generalSection';
  28. protected $name = 'generalSection';
  29. use FormExtendedTrait;
  30. public function initContent()
  31. {
  32. /**
  33. * hosting id
  34. */
  35. $hid = $this->getRequestValue('id');
  36. /**
  37. * product manager allow to check product settings
  38. */
  39. $productManager = new ProductManager();
  40. $productManager->loadByHostingId($hid);
  41. $email = new InputGroup('usernameGroup');
  42. $email->addTextField('username', false, true);
  43. $email->addInputAddon('emailSign', false, '@');
  44. $email->addInputComponent((new InputGroupElements\Text('domain'))->addHtmlAttribute('readonly','true'));
  45. $this->addSection($email);
  46. $this->generateDoubleSection([new Text('display_name'), new Select('status')]);
  47. $passwd = new Password('password');
  48. $passwd->setDescription('description');
  49. $passwd->addValidator(new PasswordsValidator());
  50. $passwd->notEmpty();
  51. $repPasswd = (new Password('repeat_password'))->addValidator(new RepeatPasswordValidator());
  52. $repPasswd->notEmpty();
  53. $this->generateDoubleSection([$passwd, $repPasswd]);
  54. $type = new Select('type');
  55. $capacity = new Text('capacity');
  56. $this->generateDoubleSection([$type, $capacity]);
  57. $field = new Text('description');
  58. $this->addField($field);
  59. $field = new Text('notes');
  60. $this->addField($field);
  61. $autoAcceptDecline = (new Switcher('auto_accept'))->setDefaultValue('on');
  62. $autoDeclineBusy = (new Switcher('auto_busy'))->setDefaultValue('on');
  63. $this->generateDoubleSection([$autoAcceptDecline, $autoDeclineBusy]);
  64. }
  65. }