GeneralSection.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. /***
  47. *
  48. * set cosId dependent od cos_name
  49. */
  50. if($productManager->get('cos_name') === ClassOfServices::CLASS_OF_SERVICE_QUOTA)
  51. {
  52. $field = new Select('cosId');
  53. $this->addField($field);
  54. }elseif($productManager->get('cos_name') === ClassOfServices::ZIMBRA_CONFIG_OPTIONS)
  55. {
  56. $field = new Hidden('cosId');
  57. $this->addField($field);
  58. }elseif($productManager->get('cos_name') !== ClassOfServices::CUSTOM_ZIMBRA)
  59. {
  60. $field = new Hidden('cosId');
  61. $this->addField($field);
  62. }
  63. $passwd = new Password('password');
  64. $passwd->setDescription('description');
  65. $passwd->addValidator(new PasswordsValidator());
  66. $passwd->notEmpty();
  67. $repPasswd = (new Password('repeat_password'))->addValidator(new RepeatPasswordValidator());
  68. $repPasswd->notEmpty();
  69. $this->generateDoubleSection([$passwd, $repPasswd]);
  70. }
  71. }