ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilECSDirectoryTreeConnector.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once './Services/WebServices/ECS/classes/class.ilECSConnector.php';
5 include_once './Services/WebServices/ECS/classes/class.ilECSConnectorException.php';
6 
14 {
15 
20  public function __construct(ilECSSetting $settings = null)
21  {
22  parent::__construct($settings);
23  }
24 
31  public function getDirectoryTrees($a_mid = 0)
32  {
33  global $DIC;
34 
35  $ilLog = $DIC['ilLog'];
36 
37  $this->path_postfix = '/campusconnect/directory_trees';
38 
39  try {
40  $this->prepareConnection();
41  $this->setHeader(array());
42  $this->addHeader('Accept', 'text/uri-list');
43  $this->addHeader('X-EcsQueryStrings', 'all=true');
44  if ($a_mid) {
45  $this->addHeader('X-EcsReceiverMemberships', $a_mid);
46  }
47 
48  $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->getHeader());
49  $res = $this->call();
50 
51  $ecsResult = new ilECSResult($res, false, ilECSResult::RESULT_TYPE_URL_LIST);
52  return $ecsResult->getResult();
53  } catch (ilCurlConnectionException $exc) {
54  throw new ilECSConnectorException('Error calling ECS service: ' . $exc->getMessage());
55  }
56  }
57 
62  public function getDirectoryTree($tree_id)
63  {
64  $this->path_postfix = '/campusconnect/directory_trees/' . (int) $tree_id;
65 
66  try {
67  $this->prepareConnection();
68  $this->setHeader(array());
69  $this->addHeader('Accept', 'text/uri-list');
70  $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->getHeader());
71  $res = $this->call();
72 
73  if (substr($res, 0, 4) == 'http') {
74  $json = file_get_contents($res);
75  $ecs_result = new ilECSResult($json);
76  } else {
77  $ecs_result = new ilECSResult($res);
78  }
79  return $ecs_result;
80  } catch (ilCurlConnectionException $e) {
81  throw new ilECSConnectorException('Error calling ECS service: ' . $e->getMessage());
82  }
83  }
84 }
const RESULT_TYPE_URL_LIST
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
getDirectoryTree($tree_id)
Get single directory tree.
setHeader($a_header_strings)
addHeader($a_name, $a_value)
Add Header.
__construct(ilECSSetting $settings=null)
Constructor.
prepareConnection()
prepare connection
getDirectoryTrees($a_mid=0)
Get directory tree ilLog $ilLog.