GeneralSection.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace ThurData\Servers\KerioEmail\App\UI\Client\EmailAccount\Sections;
  3. use ThurData\Servers\KerioEmail\App\Libs\Product\ProductManager;
  4. use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Repository\ClassOfServices;
  5. use ThurData\Servers\KerioEmail\App\Traits\FormExtendedTrait;
  6. use ThurData\Servers\KerioEmail\App\UI\Admin\Custom\Sections\FreeFieldsSection;
  7. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Validators\Decimal;
  8. use ThurData\Servers\KerioEmail\App\Validators\PasswordsValidator;
  9. use ThurData\Servers\KerioEmail\App\Validators\RepeatPasswordValidator;
  10. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Hidden;
  11. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Password;
  12. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Select;
  13. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Text;
  14. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Number;
  15. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Sections\InputGroup;
  16. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\InputGroupElements;
  17. /**
  18. *
  19. * Created by PhpStorm.
  20. * User: ThurData
  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. $this->generateDoubleSection([new Text('firstname'), new Text('lastname')]);
  42. $email = new InputGroup('usernameGroup');
  43. $email->addTextField('username', false, true);
  44. $email->addInputAddon('emailSign', false, '@');
  45. $email->addInputComponent((new InputGroupElements\Text('domain'))->addHtmlAttribute('readonly','true'));
  46. $this->addSection($email);
  47. $this->generateDoubleSection([new Text('display_name'), new Select('status')]);
  48. $quota = new Text('quota');
  49. $quota->setDescription('description');
  50. $quota->addValidator(new Decimal(0));
  51. $this->generateDoubleSection([$quota, new Select('unit')]);
  52. $passwd = new Password('password');
  53. $passwd->setDescription('description');
  54. $passwd->addValidator(new PasswordsValidator());
  55. $passwd->notEmpty();
  56. $repPasswd = (new Password('repeat_password'))->addValidator(new RepeatPasswordValidator());
  57. $repPasswd->notEmpty();
  58. $this->generateDoubleSection([$passwd, $repPasswd]);
  59. }
  60. }