UpdateAccountCosQuota.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. namespace ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Update;
  3. use ThurData\Servers\KerioEmail\App\Enums\Size;
  4. use ThurData\Servers\KerioEmail\App\Enums\Kerio;
  5. use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Interfaces\ApiService;
  6. use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Models\Account;
  7. use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Models\ClassOfService;
  8. use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Create\CreateAccountCosQuota;
  9. /**
  10. *
  11. * Created by PhpStorm.
  12. * User: ThurData
  13. * Date: 09.10.19
  14. * Time: 08:25
  15. * Class UpdateAccountCosQuota
  16. */
  17. class UpdateAccountCosQuota extends CreateAccountCosQuota
  18. {
  19. /**
  20. * @return bool|mixed|Account|void
  21. */
  22. protected function process()
  23. {
  24. /**
  25. *
  26. */
  27. $model = $this->getModel();
  28. /**
  29. * update account in KERIO
  30. */
  31. $result = $this->api->account->update($model);
  32. /**
  33. * problem with create account
  34. */
  35. if(!$result)
  36. {
  37. $this->setError($this->api->account->getLastResult()->getLastErrorCode());
  38. return false;
  39. }
  40. return $result;
  41. }
  42. /**
  43. * @return Account
  44. */
  45. public function getModel()
  46. {
  47. $account = new Account();
  48. /**
  49. * set account attributes
  50. */
  51. $account->setId($this->formData['id']);
  52. $account->setAttr(Account::ATTR_FIRSTNAME, $this->formData['firstname']);
  53. $account->setAttr(Account::ATTR_LASTNAME, $this->formData['lastname']);
  54. $account->setAttr(Account::ATTR_PHONE, $this->formData['phone']);
  55. $account->setAttr(Account::ATTR_MOBILE_PHONE, $this->formData['mobile_phone']);
  56. $account->setAttr(Account::ATTR_FAX, $this->formData['fax']);
  57. $account->setAttr(Account::ATTR_PAGER, $this->formData['pager']);
  58. $account->setAttr(Account::ATTR_HOME_PHONE, $this->formData['home_phone']);
  59. $account->setAttr(Account::ATTR_COUNTRY, $this->formData['country']);
  60. $account->setAttr(Account::ATTR_STATE, $this->formData['state']);
  61. $account->setAttr(Account::ATTR_PROF_TITLE, $this->formData['title']);
  62. $account->setAttr(Account::ATTR_POSTAL_CODE, $this->formData['post_code']);
  63. $account->setAttr(Account::ATTR_CITY, $this->formData['city']);
  64. $account->setAttr(Account::ATTR_STREET, $this->formData['street']);
  65. $account->setAttr(Account::ATTR_COMPANY, $this->formData['company']);
  66. $account->setAttr(Account::ATTR_ACCOUNT_STATUS, $this->formData['status']);
  67. $account->setAttr(Account::ATTR_DISPLAY_NAME, $this->formData['display_name']);
  68. /* @var $cos ClassOfService*/
  69. $cos = $this->cosModels[$this->formData['cosId']];
  70. /**
  71. * set quota by class of service
  72. */
  73. $account->setAttr(Account::ATTR_MAIL_QUOTA, $cos->getDataResourceA(Account::ATTR_MAIL_QUOTA));
  74. /**
  75. * define class of services attribute for account
  76. */
  77. $cosAttrs = $cos->getAllDataResourcesAAttributes();
  78. foreach(Kerio::BASE_ACCOUNT_CONFIG as $key)
  79. {
  80. $value = $cosAttrs[$key] ? $cosAttrs[$key] : Kerio::ATTR_DISABLED;
  81. $account->setAttr($key, $value);
  82. }
  83. /**
  84. *
  85. * set class of service id as account attribute
  86. */
  87. $account->setAttr(Account::ATTR_CLASS_OF_SERVICE_ID, $cos->getId());
  88. return $account;
  89. }
  90. }