DistributionList.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <?php
  2. namespace ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Models;
  3. use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Interfaces\AbstractModel;
  4. /**
  5. *
  6. * Created by PhpStorm.
  7. * User: Tomasz Bielecki ( tomasz.bi@thurdata.com )
  8. * Date: 10.09.19
  9. * Time: 08:43
  10. * Class DistributionList
  11. */
  12. class DistributionList extends AbstractModel
  13. {
  14. const ATTR_DISPLAY_NAME = 'displayName';
  15. const ATTR_DESCRIPTION = 'description';
  16. const ATTR_SUBSCRIPTION_REQUEST = 'kerioDistributionListSubscriptionPolicy';
  17. const ATTR_UNSUBSCRIPTION_REQUEST = 'kerioDistributionListUnsubscriptionPolicy';
  18. const ATTR_NOTIFY_SHARES = 'kerioDistributionListSendShareMessageToNewMembers';
  19. const ATTR_HIDE_IN_GAL = 'kerioHideInGal';
  20. const ATTR_MAIL_STATUS = 'kerioMailStatus';
  21. const REPLY_TO_ENABLED = 'kerioPrefReplyToEnabled';
  22. const REPLY_TO_DISPLAY = 'kerioPrefReplyToDisplay';
  23. const REPLY_TO_ADDRESS = 'kerioPrefReplyToAddress';
  24. protected $name;
  25. protected $id;
  26. protected $attrs;
  27. protected $dynamic = false;
  28. protected $members = [];
  29. protected $owners = [];
  30. protected $alias = null;
  31. /**
  32. * @return mixed
  33. */
  34. public function getId()
  35. {
  36. return $this->id;
  37. }
  38. /**
  39. * @param $id
  40. * @return $this
  41. */
  42. public function setId($id)
  43. {
  44. $this->id = $id;
  45. return $this;
  46. }
  47. /**
  48. * @return mixed
  49. */
  50. public function getName()
  51. {
  52. return $this->name;
  53. }
  54. /**
  55. * @param $name
  56. * @return $this
  57. */
  58. public function setName($name)
  59. {
  60. $this->name = $name;
  61. return $this;
  62. }
  63. /**
  64. * @return bool
  65. */
  66. public function isDynamic()
  67. {
  68. return $this->dynamic;
  69. }
  70. /**
  71. * @param bool $dynamic
  72. */
  73. public function setDynamic($dynamic)
  74. {
  75. $this->dynamic = $dynamic;
  76. }
  77. /**
  78. * @return mixed
  79. */
  80. public function getAttrs()
  81. {
  82. return $this->attrs;
  83. }
  84. /**
  85. * @param mixed $attrs
  86. */
  87. public function setAttrs($attrs)
  88. {
  89. $this->attrs = $attrs;
  90. }
  91. /**
  92. * @param $key
  93. * @param null $value
  94. */
  95. public function setAttr($key, $value = null)
  96. {
  97. $this->attrs[$key] = $value;
  98. }
  99. /**
  100. * @param $member
  101. * @return $this
  102. */
  103. public function addMember($member)
  104. {
  105. $this->members[$member] = $member;
  106. return $this;
  107. }
  108. /**
  109. * @param array $members
  110. * @return $this
  111. */
  112. public function setMembers($members = [])
  113. {
  114. $this->members = $members;
  115. return $this;
  116. }
  117. /**
  118. * @return array
  119. */
  120. public function getMembers()
  121. {
  122. return $this->members;
  123. }
  124. /**
  125. * @param array $owners
  126. * @return $this
  127. */
  128. public function setOwners($owners = [])
  129. {
  130. $this->owners = $owners;
  131. return $this;
  132. }
  133. /**
  134. * @param $owner
  135. * @return $this
  136. */
  137. public function addOwner($owner)
  138. {
  139. $this->owners[$owner] = $owner;
  140. return $this;
  141. }
  142. /**
  143. * @return array
  144. */
  145. public function getOwners()
  146. {
  147. return $this->owners;
  148. }
  149. /**
  150. * @param $owner
  151. * @return $this
  152. */
  153. public function setAlias($alias)
  154. {
  155. $this->alias = $alias;
  156. return $this;
  157. }
  158. /**
  159. * @return array
  160. */
  161. public function getAlias()
  162. {
  163. return $this->alias;
  164. }
  165. /**
  166. * @return mixed
  167. */
  168. public function getResourceMembers()
  169. {
  170. if($this->resources['dlm']['DATA'])
  171. {
  172. $tmp[$this->resources['dlm']['DATA']] = $this->resources['dlm']['DATA'];
  173. return $tmp;
  174. }
  175. foreach($this->resources['dlm'] as $owner)
  176. {
  177. $tmp[$owner['DATA']] = $owner['DATA'];
  178. }
  179. return $tmp;
  180. }
  181. /**
  182. * @return mixed
  183. */
  184. public function getResourceOwners()
  185. {
  186. $owners = $this->resources['owners'] ? $this->resources['owners'] : $this->owners;
  187. /**
  188. *
  189. */
  190. if($owners['OWNER']['NAME'])
  191. {
  192. $tmp[$owners['OWNER']['NAME']] = $owners['OWNER']['NAME'];
  193. return $tmp;
  194. }
  195. /**
  196. *
  197. */
  198. foreach($owners['OWNER'] as $owner)
  199. {
  200. $tmp[$owner['NAME']] = $owner['NAME'];
  201. }
  202. return $tmp;
  203. }
  204. /**
  205. * @return mixed
  206. */
  207. public function getResourceAliases()
  208. {
  209. foreach($this->getDataResourceACollection('kerioMailAlias') as $alias)
  210. {
  211. if(isset($alias['DATA']) && $this->getName() !== $alias['DATA'])
  212. {
  213. $tmp[$alias['DATA']] = $alias['DATA'];
  214. }elseif($this->getName() !== $alias){
  215. $tmp[$alias] =$alias;
  216. }
  217. }
  218. return $tmp;
  219. }
  220. }