GeneralSection.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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\App\Validators\PasswordsValidator;
  8. use ThurData\Servers\KerioEmail\App\Validators\RepeatPasswordValidator;
  9. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Hidden;
  10. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Password;
  11. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Select;
  12. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Text;
  13. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Sections\InputGroup;
  14. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\InputGroupElements;
  15. /**
  16. *
  17. * Created by PhpStorm.
  18. * User: ThurData
  19. * Date: 12.11.19
  20. * Time: 13:39
  21. * Class GeneralSection
  22. */
  23. class GeneralSection extends FreeFieldsSection
  24. {
  25. protected $id = 'generalSection';
  26. protected $name = 'generalSection';
  27. use FormExtendedTrait;
  28. public function initContent()
  29. {
  30. /**
  31. * hosting id
  32. */
  33. $hid = $this->getRequestValue('id');
  34. /**
  35. * product manager allow to check product settings
  36. */
  37. $productManager = new ProductManager();
  38. $productManager->loadByHostingId($hid);
  39. $this->generateDoubleSection([new Text('firstname'), new Text('lastname')]);
  40. $email = new InputGroup('usernameGroup');
  41. $email->addTextField('username', false, true);
  42. $email->addInputAddon('emailSign', false, '@');
  43. $email->addInputComponent((new InputGroupElements\Text('domain'))->addHtmlAttribute('readonly','true'));
  44. $this->addSection($email);
  45. $this->generateDoubleSection([new Text('display_name'), new Select('status')]);
  46. $this->generateDoubleSection([new Text('quota'), new Select('unit')]);
  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. }
  55. }