UpdateAccount.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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\Libs\Kerio\Components\Api\Soap\Interfaces\ApiService;
  5. use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Models\Account;
  6. use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Create\CreateAccount;
  7. /**
  8. *
  9. * Created by PhpStorm.
  10. * User: ThurData
  11. * Date: 18.09.19
  12. * Time: 11:09
  13. * Class UpdateAccount
  14. */
  15. class UpdateAccount extends CreateAccount
  16. {
  17. /**
  18. * @return bool|mixed|Account|void
  19. */
  20. protected function process()
  21. {
  22. /**
  23. *
  24. */
  25. $model = $this->getModel();
  26. /**
  27. * update account in ZIMBRA
  28. */
  29. $result = $this->api->account->update($model);
  30. /**
  31. * problem with create account
  32. */
  33. if(!$result)
  34. {
  35. $this->setError($this->api->account->getLastResult()->getLastErrorCode());
  36. return false;
  37. }
  38. return $result;
  39. }
  40. /**
  41. * @return Account
  42. */
  43. public function getModel()
  44. {
  45. $account = new Account();
  46. /**
  47. * set account attributes
  48. */
  49. $account->setId($this->formData['id']);
  50. $account->setAttr(Account::ATTR_FIRSTNAME, $this->formData['firstname']);
  51. $account->setAttr(Account::ATTR_LASTNAME, $this->formData['lastname']);
  52. $account->setAttr(Account::ATTR_PHONE, $this->formData['phone']);
  53. $account->setAttr(Account::ATTR_MOBILE_PHONE, $this->formData['mobile_phone']);
  54. $account->setAttr(Account::ATTR_FAX, $this->formData['fax']);
  55. $account->setAttr(Account::ATTR_PAGER, $this->formData['pager']);
  56. $account->setAttr(Account::ATTR_HOME_PHONE, $this->formData['home_phone']);
  57. $account->setAttr(Account::ATTR_COUNTRY, $this->formData['country']);
  58. $account->setAttr(Account::ATTR_STATE, $this->formData['state']);
  59. $account->setAttr(Account::ATTR_PROF_TITLE, $this->formData['title']);
  60. $account->setAttr(Account::ATTR_POSTAL_CODE, $this->formData['post_code']);
  61. $account->setAttr(Account::ATTR_CITY, $this->formData['city']);
  62. $account->setAttr(Account::ATTR_STREET, $this->formData['street']);
  63. $account->setAttr(Account::ATTR_COMPANY, $this->formData['company']);
  64. $account->setAttr(Account::ATTR_ACCOUNT_STATUS, $this->formData['status']);
  65. $account->setAttr(Account::ATTR_DISPLAY_NAME, $this->formData['display_name']);
  66. return $account;
  67. }
  68. }