| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- namespace ThurData\Servers\KerioEmail\App\UI\Client\EmailAccount\Sections;
- use ThurData\Servers\KerioEmail\App\Libs\Product\ProductManager;
- use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Repository\ClassOfServices;
- use ThurData\Servers\KerioEmail\App\Traits\FormExtendedTrait;
- use ThurData\Servers\KerioEmail\App\UI\Admin\Custom\Sections\FreeFieldsSection;
- use ThurData\Servers\KerioEmail\App\Validators\PasswordsValidator;
- use ThurData\Servers\KerioEmail\App\Validators\RepeatPasswordValidator;
- use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Hidden;
- use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Password;
- use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Select;
- use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Text;
- use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Sections\InputGroup;
- use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\InputGroupElements;
- /**
- *
- * Created by PhpStorm.
- * User: ThurData
- * Date: 12.11.19
- * Time: 13:39
- * Class GeneralSection
- */
- class GeneralSection extends FreeFieldsSection
- {
- protected $id = 'generalSection';
- protected $name = 'generalSection';
- use FormExtendedTrait;
- public function initContent()
- {
- /**
- * hosting id
- */
- $hid = $this->getRequestValue('id');
- /**
- * product manager allow to check product settings
- */
- $productManager = new ProductManager();
- $productManager->loadByHostingId($hid);
- $this->generateDoubleSection([new Text('firstname'), new Text('lastname')]);
- $email = new InputGroup('usernameGroup');
- $email->addTextField('username', false, true);
- $email->addInputAddon('emailSign', false, '@');
- $email->addInputComponent((new InputGroupElements\Text('domain'))->addHtmlAttribute('readonly','true'));
- $this->addSection($email);
- $this->generateDoubleSection([new Text('display_name'), new Select('status')]);
- /***
- *
- * set cosId dependent od cos_name
- */
- if($productManager->get('cos_name') === ClassOfServices::CLASS_OF_SERVICE_QUOTA)
- {
- $field = new Select('cosId');
- $this->addField($field);
- }elseif($productManager->get('cos_name') === ClassOfServices::KERIO_CONFIG_OPTIONS)
- {
- $field = new Hidden('cosId');
- $this->addField($field);
- }elseif($productManager->get('cos_name') !== ClassOfServices::CUSTOM_KERIO)
- {
- $field = new Hidden('cosId');
- $this->addField($field);
- }
- $passwd = new Password('password');
- $passwd->setDescription('description');
- $passwd->addValidator(new PasswordsValidator());
- $passwd->notEmpty();
- $repPasswd = (new Password('repeat_password'))->addValidator(new RepeatPasswordValidator());
- $repPasswd->notEmpty();
- $this->generateDoubleSection([$passwd, $repPasswd]);
- }
- }
|