| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php
- namespace ModulesGarden\Servers\ZimbraEmail\App\Libs\Zimbra\Components\Api\Soap\Services\Update;
- use ModulesGarden\Servers\ZimbraEmail\App\Enums\Size;
- use ModulesGarden\Servers\ZimbraEmail\App\Enums\Zimbra;
- use ModulesGarden\Servers\ZimbraEmail\App\Libs\Zimbra\Components\Api\Soap\Interfaces\ApiService;
- use ModulesGarden\Servers\ZimbraEmail\App\Libs\Zimbra\Components\Api\Soap\Models\Account;
- use ModulesGarden\Servers\ZimbraEmail\App\Libs\Zimbra\Components\Api\Soap\Models\ClassOfService;
- use ModulesGarden\Servers\ZimbraEmail\App\Libs\Zimbra\Components\Api\Soap\Services\Create\CreateAccountCosQuota;
- /**
- *
- * Created by PhpStorm.
- * User: Tomasz Bielecki ( tomasz.bi@modulesgarden.com )
- * Date: 09.10.19
- * Time: 08:25
- * Class UpdateAccountCosQuota
- */
- class UpdateAccountCosQuota extends CreateAccountCosQuota
- {
- /**
- * @return bool|mixed|Account|void
- */
- protected function process()
- {
- /**
- *
- */
- $model = $this->getModel();
- /**
- * update account in ZIMBRA
- */
- $result = $this->api->account->update($model);
- /**
- * problem with create account
- */
- if(!$result)
- {
- $this->setError($this->api->account->getLastResult()->getLastErrorCode());
- return false;
- }
- return $result;
- }
- /**
- * @return Account
- */
- public function getModel()
- {
- $account = new Account();
- /**
- * set account attributes
- */
- $account->setId($this->formData['id']);
- $account->setAttr(Account::ATTR_FIRSTNAME, $this->formData['firstname']);
- $account->setAttr(Account::ATTR_LASTNAME, $this->formData['lastname']);
- $account->setAttr(Account::ATTR_PHONE, $this->formData['phone']);
- $account->setAttr(Account::ATTR_MOBILE_PHONE, $this->formData['mobile_phone']);
- $account->setAttr(Account::ATTR_FAX, $this->formData['fax']);
- $account->setAttr(Account::ATTR_PAGER, $this->formData['pager']);
- $account->setAttr(Account::ATTR_HOME_PHONE, $this->formData['home_phone']);
- $account->setAttr(Account::ATTR_COUNTRY, $this->formData['country']);
- $account->setAttr(Account::ATTR_STATE, $this->formData['state']);
- $account->setAttr(Account::ATTR_PROF_TITLE, $this->formData['title']);
- $account->setAttr(Account::ATTR_POSTAL_CODE, $this->formData['post_code']);
- $account->setAttr(Account::ATTR_CITY, $this->formData['city']);
- $account->setAttr(Account::ATTR_STREET, $this->formData['street']);
- $account->setAttr(Account::ATTR_COMPANY, $this->formData['company']);
- $account->setAttr(Account::ATTR_ACCOUNT_STATUS, $this->formData['status']);
- $account->setAttr(Account::ATTR_DISPLAY_NAME, $this->formData['display_name']);
- if ($this->formData['forward'] == 'on') {
- $account->setAttr(Account::ATTR_MAIL_FORWARD, $this->formData['zimbraPrefMailForwardingAddress']);
- $account->setAttr(Account::ATTR_DISABLE_LOCAL, 'TRUE');
- $account->setAttr(Account::ATTR_ENABLE_FORWARD, 'TRUE');
- } else {
- $account->setAttr(Account::ATTR_MAIL_FORWARD, NULL);
- $account->setAttr(Account::ATTR_DISABLE_LOCAL, 'FALSE');
- $account->setAttr(Account::ATTR_ENABLE_FORWARD, 'FALSE');
- }
- /* @var $cos ClassOfService*/
- $cos = $this->cosModels[$this->formData['cosId']];
- /**
- * set quota by class of service
- */
- $account->setAttr(Account::ATTR_MAIL_QUOTA, $cos->getDataResourceA(Account::ATTR_MAIL_QUOTA));
- /**
- * define class of services attribute for account
- */
- $cosAttrs = $cos->getAllDataResourcesAAttributes();
- foreach(Zimbra::BASE_ACCOUNT_CONFIG as $key)
- {
- $value = $cosAttrs[$key] ? $cosAttrs[$key] : Zimbra::ATTR_DISABLED;
- $account->setAttr($key, $value);
- }
- /**
- *
- * set class of service id as account attribute
- */
- $account->setAttr(Account::ATTR_CLASS_OF_SERVICE_ID, $cos->getId());
- return $account;
- }
- }
|