ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $DIC, $ilLog, $info, $result, $ret, ilECSConnector\addHeader(), ilECSConnector\call(), ilECSConnector\getHeader(), ilECSConnector\HEADER_MEMBERSHIPS, and ilECSConnector\prepareConnection().

81  {
82  global $DIC;
83 
84  $ilLog = $DIC['ilLog'];
85 
86  $ilLog->write(__METHOD__ . ': Add new enrolment status');
87 
88  $this->path_postfix = '/campusconnect/member_status';
89 
90  try {
91  $this->prepareConnection();
92 
93  $this->addHeader('Content-Type', 'application/json');
94  $this->addHeader('Accept', 'application/json');
95  $this->addHeader(ilECSConnector::HEADER_MEMBERSHIPS, $a_target_mid);
96  #$this->addHeader(ilECSConnector::HEADER_MEMBERSHIPS, 1);
97 
98  $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->getHeader());
99  $this->curl->setOpt(CURLOPT_POST, true);
100  $this->curl->setOpt(CURLOPT_POSTFIELDS, json_encode($enrolment));
101  $ret = $this->call();
102 
103  $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
104 
105  $ilLog->write(__METHOD__ . ': Checking HTTP status...');
106  if ($info != self::HTTP_CODE_CREATED) {
107  $ilLog->write(__METHOD__ . ': Cannot create auth resource, did not receive HTTP 201. ');
108  $ilLog->write(__METHOD__ . ': POST was: ' . print_r($enrolment, true));
109  $ilLog->write(__METHOD__ . ': HTTP code: ' . $info);
110  throw new ilECSConnectorException('Received HTTP status code: ' . $info);
111  }
112  $ilLog->write(__METHOD__ . ': ... got HTTP 201 (created)');
113 
114  $result = new ilECSResult($ret);
115  $enrolment_res = $result->getResult();
116 
117  $ilLog->write(__METHOD__ . ': ... Received result: ' . print_r($enrolment_res, true));
118 
119  return $enrolment_res;
120  } catch (ilCurlConnectionException $exc) {
121  throw new ilECSConnectorException('Error calling ECS service: ' . $exc->getMessage());
122  }
123  }
$result
global $DIC
Definition: saml.php:7
$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(), 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['DIC']['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  }
Presentation of ecs content details (http://...campusconnect/courselinks/id/details) ...
foreach($_POST as $key=> $value) $res
setHeader($a_header_strings)
addHeader($a_name, $a_value)
Add Header.
prepareConnection()
prepare connection
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ Here is the call graph for this function:

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