ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilECSEnrolmentStatusConnector Class Reference

Connector for course member ressource. More...

+ Inheritance diagram for ilECSEnrolmentStatusConnector:
+ Collaboration diagram for ilECSEnrolmentStatusConnector:

Public Member Functions

 __construct (ilECSSetting $settings=null)
 Constructor. More...
 
 getEnrolmentStatus ($a_enrole_id=0, $a_details=false)
 Get single directory tree. More...
 
 addEnrolmentStatus (ilECSEnrolmentStatus $enrolment, $a_target_mid)
 Add new enrolment status. More...
 
- Public Member Functions inherited from ilECSConnector
 __construct (ilECSSetting $settings=null)
 Constructor. More...
 
 addHeader ($a_name, $a_value)
 Add Header. More...
 
 getHeader ()
 
 setHeader ($a_header_strings)
 
 getServer ()
 Get current server setting. More...
 
 addAuth ($a_post, $a_target_mid)
 Add auth resource. More...
 
 getAuth ($a_hash, $a_details_only=false)
 get auth resource More...
 
 getEventQueues ()
 get event queue More...
 
 readEventFifo ($a_delete=false)
 Read event fifo. More...
 
 getResourceList ($a_path)
 
 getResource ($a_path, $a_econtent_id, $a_details_only=false)
 Get resources from ECS server. More...
 
 addResource ($a_path, $a_post)
 Add resource. More...
 
 updateResource ($a_path, $a_econtent_id, $a_post_string)
 update resource More...
 
 deleteResource ($a_path, $a_econtent_id)
 Delete resource. More...
 
 getMemberships ($a_mid=0)
 public More...
 

Additional Inherited Members

- Data Fields inherited from ilECSConnector
const HTTP_CODE_CREATED = 201
 
const HTTP_CODE_OK = 200
 
const HTTP_CODE_NOT_FOUND = 404
 
const HEADER_MEMBERSHIPS = 'X-EcsReceiverMemberships'
 
const HEADER_COMMUNITIES = 'X-EcsReceiverCommunities'
 
- Protected Member Functions inherited from ilECSConnector
 prepareConnection ()
 prepare connection More...
 
 call ()
 call peer More...
 
- Static Protected Member Functions inherited from ilECSConnector
static _fetchEContentIdFromHeader ($a_header)
 fetch new econtent id from location header More...
 
- Protected Attributes inherited from ilECSConnector
 $path_postfix = ''
 
 $settings
 
 $header_strings = array()
 

Detailed Description

Connector for course member ressource.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e $Id$

Definition at line 14 of file class.ilECSEnrolmentStatusConnector.php.

Constructor & Destructor Documentation

◆ __construct()

ilECSEnrolmentStatusConnector::__construct ( ilECSSetting  $settings = null)

Constructor.

Parameters
ilECSSetting$settings

Definition at line 21 of file class.ilECSEnrolmentStatusConnector.php.

References ilECSConnector\$settings.

22  {
23  parent::__construct($settings);
24  }

Member Function Documentation

◆ addEnrolmentStatus()

ilECSEnrolmentStatusConnector::addEnrolmentStatus ( ilECSEnrolmentStatus  $enrolment,
  $a_target_mid 
)

Add new enrolment status.

Definition at line 80 of file class.ilECSEnrolmentStatusConnector.php.

References $ilLog, $info, $result, $ret, ilECSConnector\addHeader(), ilECSConnector\call(), ilECSConnector\getHeader(), ilECSConnector\HEADER_MEMBERSHIPS, and ilECSConnector\prepareConnection().

81  {
82  global $ilLog;
83 
84  $ilLog->write(__METHOD__ . ': Add new enrolment status');
85 
86  $this->path_postfix = '/campusconnect/member_status';
87 
88  try {
89  $this->prepareConnection();
90 
91  $this->addHeader('Content-Type', 'application/json');
92  $this->addHeader('Accept', 'application/json');
93  $this->addHeader(ilECSConnector::HEADER_MEMBERSHIPS, $a_target_mid);
94  #$this->addHeader(ilECSConnector::HEADER_MEMBERSHIPS, 1);
95 
96  $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->getHeader());
97  $this->curl->setOpt(CURLOPT_POST, true);
98  $this->curl->setOpt(CURLOPT_POSTFIELDS, json_encode($enrolment));
99  $ret = $this->call();
100 
101  $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
102 
103  $ilLog->write(__METHOD__ . ': Checking HTTP status...');
104  if ($info != self::HTTP_CODE_CREATED) {
105  $ilLog->write(__METHOD__ . ': Cannot create auth resource, did not receive HTTP 201. ');
106  $ilLog->write(__METHOD__ . ': POST was: ' . print_r($enrolment, true));
107  $ilLog->write(__METHOD__ . ': HTTP code: ' . $info);
108  throw new ilECSConnectorException('Received HTTP status code: ' . $info);
109  }
110  $ilLog->write(__METHOD__ . ': ... got HTTP 201 (created)');
111 
112  $result = new ilECSResult($ret);
113  $enrolment_res = $result->getResult();
114 
115  $ilLog->write(__METHOD__ . ': ... Received result: ' . print_r($enrolment_res, true));
116 
117  return $enrolment_res;
118  } catch (ilCurlConnectionException $exc) {
119  throw new ilECSConnectorException('Error calling ECS service: ' . $exc->getMessage());
120  }
121  }
$result
$ret
Definition: parser.php:6
addHeader($a_name, $a_value)
Add Header.
prepareConnection()
prepare connection
$info
Definition: index.php:5
+ Here is the call graph for this function:

◆ getEnrolmentStatus()

ilECSEnrolmentStatusConnector::getEnrolmentStatus (   $a_enrole_id = 0,
  $a_details = false 
)

Get single directory tree.

Returns
mixed object of EContentDetails or object of ECSEnrolmentStatus

Definition at line 31 of file class.ilECSEnrolmentStatusConnector.php.

References $GLOBALS, $res, ilECSConnector\addHeader(), array, ilECSConnector\call(), ilECSConnector\getHeader(), ilECSConnector\prepareConnection(), and ilECSConnector\setHeader().

32  {
33  if ($a_enrole_id) {
34  $this->path_postfix = '/campusconnect/member_status/' . (int) $a_enrole_id;
35  }
36  if ($a_details and $a_enrole_id) {
37  $this->path_postfix .= '/details';
38  }
39 
40  try {
41  $this->prepareConnection();
42  $this->setHeader(array());
43  if ($a_details) {
44  $this->addHeader('Accept', 'application/json');
45  } else {
46  #$this->addHeader('Accept', 'text/uri-list');
47  }
48  $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->getHeader());
49  $res = $this->call();
50 
51  if (substr($res, 0, 4) == 'http') {
52  $json = file_get_contents($res);
53  $ecs_result = new ilECSResult($json);
54  } else {
55  $ecs_result = new ilECSResult($res);
56  }
57 
58  // Return ECSEContentDetails for details switch
59  if ($a_details) {
60  include_once './Services/WebServices/ECS/classes/class.ilECSEContentDetails.php';
61  $details = new ilECSEContentDetails();
62  $GLOBALS['ilLog']->write(print_r($res, true));
63  $details->loadFromJson($ecs_result->getResult());
64  return $details;
65  } else {
66  include_once './Services/WebServices/ECS/classes/Connectors/class.ilECSEnrolmentStatus.php';
67  $enrolment = new ilECSEnrolmentStatus();
68  $enrolment->loadFromJson($ecs_result->getResult());
69  return $enrolment;
70  }
71  } catch (ilCurlConnectionException $e) {
72  throw new ilECSConnectorException('Error calling ECS service: ' . $e->getMessage());
73  }
74  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Presentation of ecs content details (http://...campusconnect/courselinks/id/details) ...
foreach($_POST as $key=> $value) $res
setHeader($a_header_strings)
Create styles array
The data for the language used.
addHeader($a_name, $a_value)
Add Header.
prepareConnection()
prepare connection
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: