Account.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866
  1. <?php
  2. /**
  3. * Zm_Account
  4. *
  5. * @author Yannick Lorenz <ylorenz@1g6.biz>
  6. * @author Fabrizio La Rosa <fabrizio.larosa@unime.it>
  7. * @version 2.2
  8. * @copyright Copyright (c) 2009, Yannick Lorenz
  9. * @copyright Copyright (c) 2012, Fabrizio La Rosa
  10. * @example ../test.php
  11. */
  12. /**
  13. * Zm_Account class documentation
  14. */
  15. // utils.php contains a small collection of useful functions
  16. require_once ("utils.php");
  17. /**
  18. * Zm_Account is a class which allows to manage Zimbra accounts via SOAP
  19. *
  20. * You may create, modify, rename, delete and get the attributes of a Zimbra account using this class
  21. *
  22. * For the usage examples of all class methods check the source code of test.php
  23. */
  24. class Zm_Account
  25. {
  26. /**
  27. * $auth
  28. * @var Zm_Auth $auth soap authentication
  29. */
  30. private $auth;
  31. /**
  32. * Constructor
  33. * @param Zm_Auth $auth soap authentication
  34. */
  35. function __construct($auth)
  36. {
  37. $this->auth = $auth;
  38. }
  39. /**
  40. * getAllAccounts
  41. * @deprecated it may take a long time to complete and fail on servers with lots of accounts
  42. *
  43. * use fetchAccounts instead
  44. * @param string $idOrNameDomain domain id or domain name
  45. * @param string $type value of the domain (auto, name, id)
  46. * @return array informations for all accounts
  47. */
  48. function getAllAccounts($idOrNameDomain, $type="auto")
  49. {
  50. if($type == "auto")
  51. $realType = getDomainType($idOrNameDomain);
  52. else
  53. $realType = $type;
  54. $result = null;
  55. $params = array(
  56. new SoapVar('<ns1:domain by="' . $realType . '">' . $idOrNameDomain . '</ns1:domain>', XSD_ANYXML),
  57. );
  58. try
  59. {
  60. $result = $this->auth->execSoapCall(
  61. "GetAllAccountsRequest",
  62. $params
  63. );
  64. $result = $result['SOAP:ENVELOPE']['SOAP:BODY']['GETALLACCOUNTSRESPONSE']['ACCOUNT'];
  65. }
  66. catch (SoapFault $exception)
  67. {
  68. $result = $exception;
  69. }
  70. return $result;
  71. }
  72. /**
  73. * fetchAccounts
  74. * @param string $ldapQuery LDAP-style filter string (RFC 2254)
  75. * @param array $attrList names of requested attributes
  76. * @param string $nameDomain domain name to restrict search request
  77. * @return array informations for accounts as specified in $ldapQuery
  78. * @author Marc Lamouche <marc.lamouche@ined.fr>
  79. */
  80. function fetchAccounts($ldapQuery, $attrList, $nameDomain = null)
  81. {
  82. $result = null;
  83. $params = array(
  84. new SoapVar('<ns1:query>'.$ldapQuery.'</ns1:query>', XSD_ANYXML),
  85. new SoapParam("accounts", "types"),
  86. new SoapParam(implode(',', $attrList), "attrs"),
  87. new SoapParam("0", "limit"),
  88. );
  89. if ( is_string($nameDomain) ) $params[] = new SoapParam($nameDomain, "domain");
  90. try
  91. {
  92. $response = $this->auth->execSoapCall(
  93. "SearchDirectoryRequest",
  94. $params
  95. );
  96. $result = array();
  97. $resultCount = intval($response['SOAP:ENVELOPE']['SOAP:BODY']['SEARCHDIRECTORYRESPONSE']['SEARCHTOTAL']);
  98. if ( !$resultCount ) return $result;
  99. if ( $resultCount > 1 )
  100. $accountList = &$response['SOAP:ENVELOPE']['SOAP:BODY']['SEARCHDIRECTORYRESPONSE']['ACCOUNT'];
  101. else
  102. $accountList = array(&$response['SOAP:ENVELOPE']['SOAP:BODY']['SEARCHDIRECTORYRESPONSE']['ACCOUNT']);
  103. foreach($accountList as $account)
  104. {
  105. $data = array();
  106. foreach($attrList as $attrName)
  107. $data[$attrName] = getSoapAttribute($account['A'], $attrName, ATTR_MULTIVALUE);
  108. $result[] = $data;
  109. unset($data);
  110. }
  111. }
  112. catch (SoapFault $exception)
  113. {
  114. $result = $exception;
  115. }
  116. return $result;
  117. }
  118. /**
  119. * getAccount
  120. * @param string $name account name
  121. * @return string account informations
  122. */
  123. function getAccount($name)
  124. {
  125. $result = null;
  126. $params = array(
  127. new SoapVar('<ns1:account by="name">' . $name . '</ns1:account>', XSD_ANYXML),
  128. );
  129. try
  130. {
  131. $result = $this->auth->execSoapCall(
  132. "GetAccountRequest",
  133. $params
  134. );
  135. $result = $result['SOAP:ENVELOPE']['SOAP:BODY']['GETACCOUNTRESPONSE']['ACCOUNT'];
  136. }
  137. catch (SoapFault $exception)
  138. {
  139. $result = $exception;
  140. }
  141. return $result;
  142. }
  143. /**
  144. * getQuota
  145. * @param string $name account name
  146. * @return string account informations
  147. */
  148. function getQuota($name)
  149. {
  150. $result = null;
  151. $params = array(
  152. new SoapVar('<ns1:account by="name">' . $name . '</ns1:account>', XSD_ANYXML),
  153. );
  154. try
  155. {
  156. $result = $this->auth->execSoapCall(
  157. "GetAccountRequest",
  158. $params
  159. );
  160. $result = getSoapAttribute($result['SOAP:ENVELOPE']['SOAP:BODY']['GETACCOUNTRESPONSE']['ACCOUNT']['A'], "zimbraMailQuota");
  161. }
  162. catch (SoapFault $exception)
  163. {
  164. $result = $exception;
  165. }
  166. return $result;
  167. }
  168. /**
  169. * getAccountId
  170. * @param string $name account name
  171. * @return string account id
  172. */
  173. function getAccountId($name)
  174. {
  175. $result = null;
  176. $params = array(
  177. new SoapVar('<ns1:account by="name">' . $name . '</ns1:account>', XSD_ANYXML),
  178. );
  179. try
  180. {
  181. $result = $this->auth->execSoapCall(
  182. "GetAccountInfoRequest",
  183. $params
  184. );
  185. $result = getSoapAttribute($result['SOAP:ENVELOPE']['SOAP:BODY']['GETACCOUNTINFORESPONSE']['A'], "zimbraId");
  186. }
  187. catch (SoapFault $exception)
  188. {
  189. $result = $exception;
  190. }
  191. return $result;
  192. }
  193. /**
  194. * accountExists
  195. * @param string $idOrNameAccount account id or account name
  196. * @param string $type value of the account (auto, name, id)
  197. * @return bool exists
  198. */
  199. function accountExists($idOrNameAccount, $type="auto")
  200. {
  201. if($type == "auto")
  202. $realType = getAccountType($idOrNameAccount);
  203. else
  204. $realType = $type;
  205. $result = null;
  206. $params = array(
  207. new SoapVar('<ns1:account by="' . $realType . '">' . $idOrNameAccount . '</ns1:account>', XSD_ANYXML),
  208. );
  209. $options = array(
  210. 'retry' => false,
  211. );
  212. try
  213. {
  214. $result = $this->auth->execSoapCall(
  215. "GetAccountInfoRequest",
  216. $params,
  217. $options
  218. );
  219. }
  220. catch (SoapFault $exception)
  221. {
  222. $result = $exception;
  223. }
  224. return (!is_a($result, "Exception"));
  225. }
  226. /**
  227. * getAccountInfo
  228. * @param string $idOrNameAccount account id or account name
  229. * @param string $type value of the account (auto, name, id)
  230. * @return array informations
  231. */
  232. function getAccountInfo($idOrNameAccount, $type="auto")
  233. {
  234. if($type == "auto")
  235. $realType = getAccountType($idOrNameAccount);
  236. else
  237. $realType = $type;
  238. $result = null;
  239. $params = array(
  240. new SoapVar('<ns1:account by="' . $realType . '">' . $idOrNameAccount . '</ns1:account>', XSD_ANYXML),
  241. );
  242. try
  243. {
  244. $result = $this->auth->execSoapCall(
  245. "GetAccountInfoRequest",
  246. $params
  247. );
  248. }
  249. catch (SoapFault $exception)
  250. {
  251. $result = $exception;
  252. }
  253. return $result;
  254. }
  255. /**
  256. * getMailbox
  257. * @param string $name account name
  258. * @return string account informations
  259. */
  260. function getMailbox($name)
  261. {
  262. $result = null;
  263. $id = getAccountId($name);
  264. $params = array(
  265. new SoapVar('<ns1:mbox id=' . $id . '</ns1:mbox>', XSD_ANYXML),
  266. );
  267. try
  268. {
  269. $result = $this->auth->execSoapCall(
  270. "GetMailboxRequest",
  271. $params
  272. );
  273. $result = $result['SOAP:ENVELOPE']['SOAP:BODY'];
  274. }
  275. catch (SoapFault $exception)
  276. {
  277. $result = $exception;
  278. }
  279. return $result;
  280. }
  281. /**
  282. * getAccountOption
  283. * @param string $idOrNameAccount account id or account name
  284. * @param string $optName name of the option to get
  285. * @param int $multisingle (ATTR_SINGLEVALUE, ATTR_MULTIVALUE)
  286. * @param string $type value of the account (auto, name, id)
  287. * @return string option
  288. */
  289. function getAccountOption($idOrNameAccount, $optName, $multisingle=ATTR_SINGLEVALUE, $type="auto")
  290. {
  291. if($type == "auto")
  292. $realType = getAccountType($idOrNameAccount);
  293. else
  294. $realType = $type;
  295. $result = null;
  296. $params = array(
  297. new SoapVar('<ns1:account by="' . $realType . '">' . $idOrNameAccount . '</ns1:account>', XSD_ANYXML),
  298. );
  299. try
  300. {
  301. $result = $this->auth->execSoapCall(
  302. "GetAccountRequest",
  303. $params
  304. );
  305. $result = getSoapAttribute($result['SOAP:ENVELOPE']['SOAP:BODY']['GETACCOUNTRESPONSE']['ACCOUNT']['A'], $optName, $multisingle);
  306. }
  307. catch (SoapFault $exception)
  308. {
  309. $result = $exception;
  310. }
  311. return $result;
  312. }
  313. /**
  314. * getAccountOptions
  315. * @param string $idOrNameAccount account id or account name
  316. * @param string $type value of the account (auto, name, id)
  317. * @return array options
  318. */
  319. function getAccountOptions($idOrNameAccount, $type="auto")
  320. {
  321. if($type == "auto")
  322. $realType = getAccountType($idOrNameAccount);
  323. else
  324. $realType = $type;
  325. $result = null;
  326. $params = array(
  327. new SoapVar('<ns1:account by="' . $realType . '">' . $idOrNameAccount . '</ns1:account>', XSD_ANYXML),
  328. );
  329. try
  330. {
  331. $result = $this->auth->execSoapCall(
  332. "GetAccountRequest",
  333. $params
  334. );
  335. $attrs = array();
  336. foreach ($result['SOAP:ENVELOPE']['SOAP:BODY']['GETACCOUNTRESPONSE']['ACCOUNT']['A'] as $a) {
  337. $attrs[$a['N']] = $a['DATA'];
  338. }
  339. $result = $attrs;
  340. }
  341. catch (SoapFault $exception)
  342. {
  343. $result = $exception;
  344. }
  345. return $result;
  346. }
  347. /**
  348. * createAccount
  349. * @param string $name account name
  350. * @param string $password password
  351. * @param array $attrs an optional array containing the account attributes to be set
  352. * @return string the new account's id
  353. */
  354. function createAccount($name, $password, $attrs = array())
  355. {
  356. $result = null;
  357. $params = array(
  358. new SoapParam($name, "name"),
  359. new SoapParam($password, "password"),
  360. );
  361. foreach ($attrs as $key=>$value)
  362. $params[] = new SoapVar('<ns1:a n="' . $key . '">' . $value . '</ns1:a>', XSD_ANYXML);
  363. try
  364. {
  365. $result = $this->auth->execSoapCall(
  366. "CreateAccountRequest",
  367. $params
  368. );
  369. $result = $result['SOAP:ENVELOPE']['SOAP:BODY']['CREATEACCOUNTRESPONSE']['ACCOUNT']['ID'];
  370. usleep(250000); // introduce a small delay, otherwise some troubles may arise if we modify the new account right after its creation
  371. }
  372. catch (SoapFault $exception)
  373. {
  374. $result = $exception;
  375. }
  376. return $result;
  377. }
  378. /**
  379. * setAccountPassword
  380. * @param string $idOrNameAccount account id or account name
  381. * @param string $password password
  382. * @param string $type value of the account (auto, name, id)
  383. * @return array informations
  384. */
  385. function setAccountPassword($idOrNameAccount, $password, $type="auto")
  386. {
  387. if($type == "auto")
  388. $realType = getAccountType($idOrNameAccount);
  389. else
  390. $realType = $type;
  391. if($realType == "name")
  392. $accountId = $this->getAccountId($idOrNameAccount);
  393. else
  394. $accountId = $idOrNameAccount;
  395. $result = null;
  396. $params = array(
  397. new SoapParam($accountId, "id"),
  398. new SoapParam($password, "newPassword"),
  399. );
  400. try
  401. {
  402. $result = $this->auth->execSoapCall(
  403. "SetPasswordRequest",
  404. $params
  405. );
  406. $result = $result['SOAP:ENVELOPE']['SOAP:BODY']['SETPASSWORDRESPONSE'];
  407. }
  408. catch (SoapFault $exception)
  409. {
  410. $result = $exception;
  411. }
  412. return $result;
  413. }
  414. /**
  415. * modifyAccount
  416. * @param string $idOrNameAccount account id or account name
  417. * @param array $attrs an array containing the account attributes to be set
  418. * @param string $type value of the account (auto, name, id)
  419. * @return array informations
  420. */
  421. function modifyAccount($idOrNameAccount, $attrs = array(), $type="auto")
  422. {
  423. if($type == "auto")
  424. $realType = getAccountType($idOrNameAccount);
  425. else
  426. $realType = $type;
  427. if($realType == "name")
  428. $accountId = $this->getAccountId($idOrNameAccount);
  429. else
  430. $accountId = $idOrNameAccount;
  431. $result = null;
  432. $params = array(
  433. new SoapParam($accountId, "id"),
  434. );
  435. foreach ($attrs as $key=>$value)
  436. $params[] = new SoapVar('<ns1:a n="' . $key . '">' . $value . '</ns1:a>', XSD_ANYXML);
  437. try
  438. {
  439. $result = $this->auth->execSoapCall(
  440. "ModifyAccountRequest",
  441. $params
  442. );
  443. }
  444. catch (SoapFault $exception)
  445. {
  446. $result = $exception;
  447. }
  448. return $result;
  449. }
  450. /**
  451. * renameAccount
  452. * @param string $idOrNameAccount account id or account name
  453. * @param string $newName new account name
  454. * @param string $type value of the account (auto, name, id)
  455. * @return array informations
  456. */
  457. function renameAccount($idOrNameAccount, $newName, $type="auto")
  458. {
  459. if($type == "auto")
  460. $realType = getAccountType($idOrNameAccount);
  461. else
  462. $realType = $type;
  463. if($realType == "name")
  464. $accountId = $this->getAccountId($idOrNameAccount);
  465. else
  466. $accountId = $idOrNameAccount;
  467. $result = null;
  468. $params = array(
  469. new SoapParam($accountId, "id"),
  470. new SoapParam($newName, "newName"),
  471. );
  472. try
  473. {
  474. $result = $this->auth->execSoapCall(
  475. "RenameAccountRequest",
  476. $params
  477. );
  478. }
  479. catch (SoapFault $exception)
  480. {
  481. $result = $exception;
  482. }
  483. return $result;
  484. }
  485. /**
  486. * deleteAccount
  487. * @param string $idOrNameAccount account id or account name
  488. * @param string $type value of the account (auto, name, id)
  489. * @return array informations
  490. */
  491. function deleteAccount($idOrNameAccount, $type="auto")
  492. {
  493. if($type == "auto")
  494. $realType = getAccountType($idOrNameAccount);
  495. else
  496. $realType = $type;
  497. if($realType == "name")
  498. $accountId = $this->getAccountId($idOrNameAccount);
  499. else
  500. $accountId = $idOrNameAccount;
  501. $result = null;
  502. $params = array(
  503. new SoapParam($accountId, "id"),
  504. );
  505. try
  506. {
  507. $result = $this->auth->execSoapCall(
  508. "DeleteAccountRequest",
  509. $params
  510. );
  511. }
  512. catch (SoapFault $exception)
  513. {
  514. $result = $exception;
  515. }
  516. return $result;
  517. }
  518. /**
  519. * getAccountAliases
  520. * @param string $idOrNameAccount account id or account name
  521. * @param string $type value of the account (auto, name, id)
  522. * @return array aliases
  523. */
  524. function getAccountAliases($idOrNameAccount, $type="auto")
  525. {
  526. return $this->getAccountOption($idOrNameAccount, "zimbraMailAlias", ATTR_MULTIVALUE, $type);
  527. }
  528. /**
  529. * addAccountAlias
  530. * @param string $idOrNameAccount account id or account name
  531. * @param string $alias account alias
  532. * @param string $type value of the account (auto, name, id)
  533. * @return array informations
  534. */
  535. function addAccountAlias($idOrNameAccount, $alias, $type="auto")
  536. {
  537. if($type == "auto")
  538. $realType = getAccountType($idOrNameAccount);
  539. else
  540. $realType = $type;
  541. if($realType == "name")
  542. $accountId = $this->getAccountId($idOrNameAccount);
  543. else
  544. $accountId = $idOrNameAccount;
  545. $result = null;
  546. $params = array(
  547. new SoapParam($accountId, "id"),
  548. new SoapParam($alias, "alias"),
  549. );
  550. try
  551. {
  552. $result = $this->auth->execSoapCall(
  553. "AddAccountAliasRequest",
  554. $params
  555. );
  556. }
  557. catch (SoapFault $exception)
  558. {
  559. $result = $exception;
  560. }
  561. return $result;
  562. }
  563. /**
  564. * removeAccountAlias
  565. * @param string $idOrNameAccount account id or account name
  566. * @param string $alias account alias
  567. * @param string $type value of the account (auto, name, id)
  568. * @return array informations
  569. */
  570. function removeAccountAlias($idOrNameAccount, $alias, $type="auto")
  571. {
  572. if($type == "auto")
  573. $realType = getAccountType($idOrNameAccount);
  574. else
  575. $realType = $type;
  576. if($realType == "name")
  577. $accountId = $this->getAccountId($idOrNameAccount);
  578. else
  579. $accountId = $idOrNameAccount;
  580. $result = null;
  581. $params = array(
  582. new SoapParam($accountId, "id"),
  583. new SoapParam($alias, "alias"),
  584. );
  585. try
  586. {
  587. $result = $this->auth->execSoapCall(
  588. "RemoveAccountAliasRequest",
  589. $params
  590. );
  591. }
  592. catch (SoapFault $exception)
  593. {
  594. $result = $exception;
  595. }
  596. return $result;
  597. }
  598. /**
  599. * getAccountStatus
  600. * @param string $idOrNameAccount account id or account name
  601. * @param string $type value of the account (auto, name, id)
  602. * @return string status
  603. */
  604. function getAccountStatus($idOrNameAccount, $type="auto")
  605. {
  606. return $this->getAccountOption($idOrNameAccount, "zimbraAccountStatus", ATTR_SINGLEVALUE, $type);
  607. }
  608. /**
  609. * setAccountStatus
  610. * @param string $idOrNameAccount account id or account name
  611. * @param string $status the status (active, maintenance, pending, locked, closed)
  612. * @param string $type value of the account (auto, name, id)
  613. * @return array informations
  614. */
  615. function setAccountStatus($idOrNameAccount, $status, $type = "auto")
  616. {
  617. $hideInGAL = ($status == "active") ? "FALSE" : "TRUE";
  618. $attrs = array(
  619. "zimbraAccountStatus"=>$status,
  620. "zimbraHideInGal"=>$hideInGAL,
  621. );
  622. $result = $this->modifyAccount($idOrNameAccount, $attrs, $type);
  623. return $result;
  624. }
  625. /**
  626. * expireAccountSessions
  627. * @param string $idOrNameAccount account id or account name
  628. * @param string $type value of the account (auto, name, id)
  629. * @return array informations
  630. */
  631. function expireAccountSessions($idOrNameAccount, $type = "auto")
  632. {
  633. $attrName = "zimbraAuthTokenValidityValue";
  634. $oldValue = $this->getAccountOption($idOrNameAccount, $attrName);
  635. $newValue = rand($oldValue+1, 1024);
  636. $attrs = array($attrName=>$newValue);
  637. $result = $this->modifyAccount($idOrNameAccount, $attrs, $type);
  638. return $result;
  639. }
  640. /**
  641. * getAccountCos
  642. * @param string $idOrNameAccount account id or account name
  643. * @param string $returnType get the COS ID or NAME
  644. * @param string $type value of the account (auto, name, id)
  645. * @return string COS id or name
  646. */
  647. function getAccountCos($idOrNameAccount, $returnType = "NAME", $type = "auto")
  648. {
  649. if($type == "auto")
  650. $realType = getAccountType($idOrNameAccount);
  651. else
  652. $realType = $type;
  653. if($realType == "name")
  654. $accountId = $this->getAccountId($idOrNameAccount);
  655. else
  656. $accountId = $idOrNameAccount;
  657. $result = null;
  658. $params = array(
  659. new SoapVar('<ns1:account by="' . $realType . '">' . $idOrNameAccount . '</ns1:account>', XSD_ANYXML),
  660. );
  661. try
  662. {
  663. $result = $this->auth->execSoapCall(
  664. "GetAccountInfoRequest",
  665. $params
  666. );
  667. $result = $result['SOAP:ENVELOPE']['SOAP:BODY']['GETACCOUNTINFORESPONSE']['COS'][$returnType];
  668. }
  669. catch (SoapFault $exception)
  670. {
  671. $result = $exception;
  672. }
  673. return $result;
  674. }
  675. /**
  676. * setAccountCos
  677. * @param string $idOrNameAccount account id or account name
  678. * @param string $cosName the COS name
  679. * @param string $type value of the account (auto, name, id)
  680. * @return array informations
  681. */
  682. function setAccountCos($idOrNameAccount, $cosName, $type = "auto")
  683. {
  684. $cosId = $this->getCosId($cosName);
  685. $attrs = array("zimbraCOSId"=>$cosId);
  686. $result = $this->modifyAccount($idOrNameAccount, $attrs, $type);
  687. return $result;
  688. }
  689. /**
  690. * getCosId
  691. * @param string $name the COS name
  692. * @return string COS id
  693. */
  694. function getCosId($name)
  695. {
  696. $result = null;
  697. $params = array(
  698. new SoapVar('<ns1:cos by="name">' . $name . '</ns1:cos>', XSD_ANYXML),
  699. );
  700. try
  701. {
  702. $result = $this->auth->execSoapCall(
  703. "GetCosRequest",
  704. $params
  705. );
  706. $result = $result['SOAP:ENVELOPE']['SOAP:BODY']['GETCOSRESPONSE']['COS']['ID'];
  707. }
  708. catch (SoapFault $exception)
  709. {
  710. $result = $exception;
  711. }
  712. return $result;
  713. }
  714. /**
  715. * getAllCos
  716. * @return array informations
  717. */
  718. function getAllCos()
  719. {
  720. $result = null;
  721. try
  722. {
  723. $result = $this->auth->execSoapCall(
  724. "GetAllCosRequest"
  725. );
  726. $result = $result['SOAP:ENVELOPE']['SOAP:BODY']['GETALLCOSRESPONSE'];
  727. }
  728. catch (SoapFault $exception)
  729. {
  730. $result = $exception;
  731. }
  732. return $result;
  733. }
  734. }
  735. ?>