/ExchangeWebServices.php

https://github.com/maiiku/EWSWrapper · PHP · 485 lines · 174 code · 46 blank · 265 comment · 0 complexity · 501af55153de9c4af5049be7bfe80842 MD5 · raw file

  1. <?php
  2. /**
  3. * Base class of the Exchange Web Services application.
  4. *
  5. * @author James I. Armes <http://www.jamesarmes.net>
  6. */
  7. /**
  8. * Base class of the Exchange Web Services application.
  9. *
  10. * @author James I. Armes <http://www.jamesarmes.net>
  11. */
  12. class ExchangeWebServices {
  13. /**
  14. * Location of the Exchange server.
  15. *
  16. * @var string
  17. */
  18. protected $server;
  19. /**
  20. * Username to use when connecting to the Exchange server.
  21. *
  22. * @var string
  23. */
  24. protected $username;
  25. /**
  26. * Password to use when connecting to the Exchange server.
  27. *
  28. * @var string
  29. */
  30. protected $password;
  31. /**
  32. * Constructor for the ExchangeWebServices class
  33. *
  34. * @param string $server
  35. * @param string $username
  36. * @param string $password
  37. */
  38. public function __construct($server = null, $username = null,
  39. $password = null) {
  40. //bootstrap
  41. include "bootstrap.php";
  42. // set the object properties
  43. $this->setServer($server);
  44. $this->setUsername($username);
  45. $this->setPassword($password);
  46. } // end function __construct()
  47. /**
  48. * Returns the SOAP Client that may be used to make calls against the server
  49. *
  50. * @return NTLMSoapClient_Exchange
  51. */
  52. public function getClient()
  53. {
  54. return $this->initializeSoapClient();
  55. } // end function getClient()
  56. /**
  57. * Sets the password property
  58. *
  59. * @param string $password
  60. */
  61. public function setPassword($password) {
  62. $this->password = $password;
  63. return true;
  64. } // end function setPassword()
  65. /**
  66. * Sets the server property
  67. *
  68. * @param string $server
  69. */
  70. public function setServer($server) {
  71. $this->server = $server;
  72. return true;
  73. } // end function setServer()
  74. /**
  75. * Sets the user name property
  76. *
  77. * @param string $username
  78. */
  79. public function setUsername($username) {
  80. $this->username = $username;
  81. return true;
  82. } // end function setUsername()
  83. /**
  84. * Function Description
  85. *
  86. * @param AddDelegateType $request
  87. * @return AddDelegateResponseMessageType
  88. */
  89. public function AddDelegate($request) {
  90. $request->getAsSOAP();
  91. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  92. } // end function AddDelegate()
  93. /**
  94. * Function Description
  95. *
  96. * @param ConvertIdType $request
  97. * @return ConvertIdResponseType
  98. */
  99. public function ConvertId($request) {
  100. $request->getAsSOAP();
  101. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  102. } // end function ConvertId()
  103. /**
  104. * Function Description
  105. *
  106. * @param CopyFolderType $request
  107. * @return CopyFolderResponseType
  108. */
  109. public function CopyFolder($request) {
  110. $request->getAsSOAP();
  111. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  112. } // end function CopyFolder()
  113. /**
  114. * Function Description
  115. *
  116. * @param CopyItemType $request
  117. * @return CopyItemResponseType
  118. */
  119. public function CopyItem($request) {
  120. $request->getAsSOAP();
  121. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  122. } // end function CopyItem()
  123. /**
  124. * Function Description
  125. *
  126. * @param CreateAttachmentType $request
  127. * @return CreateAttachmentResponseType
  128. */
  129. public function CreateAttachment($request) {
  130. $request->getAsSOAP();
  131. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  132. } // end function CreateAttachment()
  133. /**
  134. * Function Description
  135. *
  136. * @param CreateFolderType $request
  137. * @return CreateFolderResponseType
  138. */
  139. public function CreateFolder($request) {
  140. $request->getAsSOAP();
  141. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  142. } // end function CreateFolder()
  143. /**
  144. * Function Description
  145. *
  146. * @param CreateItemType $request
  147. * @return CreateItemResponseType
  148. */
  149. public function CreateItem($request) {
  150. $request->getAsSOAP();
  151. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  152. } // end function CreateItem()
  153. /**
  154. * Function Description
  155. *
  156. * @param CreateManagedFolderRequestType $request
  157. * @return CreateManagedFolderResponseType
  158. */
  159. public function CreateManagedFolder($request) {
  160. $request->getAsSOAP();
  161. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  162. } // end function CreateManagedFolder()
  163. /**
  164. * Function Description
  165. *
  166. * @param DeleteAttachmentType $request
  167. * @return DeleteAttachmentResponseType
  168. */
  169. public function DeleteAttachment($request) {
  170. $request->getAsSOAP();
  171. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  172. } // end function DeleteAttachment()
  173. /**
  174. * Function Description
  175. *
  176. * @param DeleteFolderType $request
  177. * @return DeleteFolderResponseType
  178. */
  179. public function DeleteFolder($request) {
  180. $request->getAsSOAP();
  181. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  182. } // end function DeleteFolder()
  183. /**
  184. * Function Description
  185. *
  186. * @param DeleteItemType $request
  187. * @return DeleteItemResponseType
  188. */
  189. public function DeleteItem($request) {
  190. $request->getAsSOAP();
  191. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  192. } // end function DeleteItem()
  193. /**
  194. * Function Description
  195. *
  196. * @param ExpandDLType $request
  197. * @return ExpandDLResponseType
  198. */
  199. public function ExpandDL($request) {
  200. $request->getAsSOAP();
  201. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  202. } // end function ExpandDL()
  203. /**
  204. * Function Description
  205. *
  206. * @param EWS_FindFolderType $request
  207. * @return EWS_FindFolderResponseType
  208. */
  209. public function FindFolder($request) {
  210. $request->getAsSOAP();
  211. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  212. } // end function FindFolder()
  213. /**
  214. * Function Description
  215. *
  216. * @param FindItemType $request
  217. * @return FindItemResponseType
  218. */
  219. public function FindItem($request) {
  220. $request->getAsSOAP();
  221. //print_r($request);
  222. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  223. } // end function FindItem()
  224. /**
  225. * Function Description
  226. *
  227. * @param GetAttachmentType $request
  228. * @return GetAttachmentResponseType
  229. */
  230. public function GetAttachment($request) {
  231. $request->getAsSOAP();
  232. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  233. } // end function GetAttachment()
  234. /**
  235. * Function Description
  236. *
  237. * @param GetDelegateType $request
  238. * @return GetDelegateResponseMessageType
  239. */
  240. public function GetDelegate($request) {
  241. $request->getAsSOAP();
  242. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  243. } // end function GetDelegate()
  244. /**
  245. * Function Description
  246. *
  247. * @param GetEventsType $request
  248. * @return GetEventsResponseType
  249. */
  250. public function GetEvents($request) {
  251. $request->getAsSOAP();
  252. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  253. } // end function GetEvents()
  254. /**
  255. * Function Description
  256. *
  257. * @param GetFolderType $request
  258. * @return GetFolderResponseType
  259. */
  260. public function GetFolder($request) {
  261. $request->getAsSOAP();
  262. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  263. } // end function GetFolder()
  264. /**
  265. * Function Description
  266. *
  267. * @param GetItemType $request
  268. * @return GetItemResponseType
  269. */
  270. public function GetItem($request) {
  271. $request->getAsSOAP();
  272. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  273. } // end function GetItem()
  274. /**
  275. * Function Description
  276. *
  277. * @param GetUserAvailabilityRequestType $GetUserAvailabilityRequest
  278. * @return GetUserAvailabilityResponseType
  279. */
  280. public function GetUserAvailability($GetUserAvailabilityRequest) {
  281. $request->getAsSOAP();
  282. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  283. } // end function GetUserAvailability()
  284. /**
  285. * Function Description
  286. *
  287. * @param GetUserOofSettingsRequest $GetUserOofSettingsRequest
  288. * @return GetUserOofSettingsResponse
  289. */
  290. public function GetUserOofSettings($GetUserOofSettingsRequest) {
  291. $request->getAsSOAP();
  292. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  293. } // end function GetUserOofSettings()
  294. /**
  295. * Function Description
  296. *
  297. * @param MoveFolderType $request
  298. * @return MoveFolderResponseType
  299. */
  300. public function MoveFolder($request) {
  301. $request->getAsSOAP();
  302. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  303. } // end function MoveFolder()
  304. /**
  305. * Function Description
  306. *
  307. * @param MoveItemType $request
  308. * @return MoveItemResponseType
  309. */
  310. public function MoveItem($request) {
  311. $request->getAsSOAP();
  312. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  313. } // end function MoveItem()
  314. /**
  315. * Function Description
  316. *
  317. * @param RemoveDelegateType $request
  318. * @return RemoveDelegateResponseMessageType
  319. */
  320. public function RemoveDelegate($request) {
  321. $request->getAsSOAP();
  322. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  323. } // end function RemoveDelegate()
  324. /**
  325. * Function Description
  326. *
  327. * @param ResolveNamesType $request
  328. * @return ResolveNamesResponseType
  329. */
  330. public function ResolveNames($request) {
  331. $request->getAsSOAP();
  332. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  333. } // end function ResolveNames()
  334. /**
  335. * Function Description
  336. *
  337. * @param SendItemType $request
  338. * @return SendItemResponseType
  339. */
  340. public function SendItem($request) {
  341. $request->getAsSOAP();
  342. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  343. } // end function SendItem()
  344. /**
  345. * Function Description
  346. *
  347. * @param SetUserOofSettingsRequest $SetUserOofSettingsRequest
  348. * @return SetUserOofSettingsResponse
  349. */
  350. public function SetUserOofSettings($SetUserOofSettingsRequest) {
  351. $request->getAsSOAP();
  352. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  353. } // end function SetUserOofSettings()
  354. /**
  355. * Function Description
  356. *
  357. * @param SubscribeType $request
  358. * @return SubscribeResponseType
  359. */
  360. public function Subscribe($request) {
  361. $request->getAsSOAP();
  362. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  363. } // end function Subscribe()
  364. /**
  365. * Function Description
  366. *
  367. * @param SyncFolderHierarchyType $request
  368. * @return SyncFolderHierarchyResponseType
  369. */
  370. public function SyncFolderHierarchy($request) {
  371. $request->getAsSOAP();
  372. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  373. } // end function SyncFolderHierarchy()
  374. /**
  375. * Function Description
  376. *
  377. * @param SyncFolderItemsType $request
  378. * @return SyncFolderItemsResponseType
  379. */
  380. public function SyncFolderItems($request) {
  381. $request->getAsSOAP();
  382. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  383. } // end function SyncFolderItems()
  384. /**
  385. * Function Description
  386. *
  387. * @param UnsubscribeType $request
  388. * @return UnsubscribeResponseType
  389. */
  390. public function Unsubscribe($request) {
  391. $request->getAsSOAP();
  392. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  393. } // end function Unsubscribe()
  394. /**
  395. * Function Description
  396. *
  397. * @param UpdateDelegateType $request
  398. * @return UpdateDelegateResponseMessageType
  399. */
  400. public function UpdateDelegate($request) {
  401. $request->getAsSOAP();
  402. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  403. } // end function UpdateDelegate()
  404. /**
  405. * Function Description
  406. *
  407. * @param UpdateFolderType $request
  408. * @return UpdateFolderResponseType
  409. */
  410. public function UpdateFolder($request) {
  411. $request->getAsSOAP();
  412. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  413. } // end function UpdateFolder()
  414. /**
  415. * Function Description
  416. *
  417. * @param UpdateItemType $request
  418. * @return UpdateItemResponseType
  419. */
  420. public function UpdateItem($request) {
  421. $request->getAsSOAP();
  422. //print_r($request);
  423. return $this->initializeSoapClient()->{__FUNCTION__}($request);
  424. } // end function UpdateItem()
  425. /**
  426. * Initializes the SoapClient object to make a request
  427. *
  428. * @return NTLMSoapClient_Exchange
  429. */
  430. protected function initializeSoapClient() {
  431. return new NTLMSoapClient_Exchange(
  432. dirname(__FILE__).'/wsdl/services.wsdl',
  433. array(
  434. 'user' => $this->username,
  435. 'password' => $this->password,
  436. 'location' => 'https://'.$this->server.'/EWS/Exchange.asmx',
  437. )); // end return
  438. } // end function initializeSoapClient()
  439. } // end class ExchangeWebService