ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilECSEnrolmentStatusCommandQueueHandler.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once './Services/WebServices/ECS/interfaces/interface.ilECSCommandQueueHandler.php';
6 include_once './Services/WebServices/ECS/classes/class.ilECSSetting.php';
7 include_once './Services/WebServices/ECS/classes/class.ilECSParticipantSetting.php';
8 
9 
16 {
17  private $server = null;
18  private $mid = 0;
19 
20 
24  public function __construct(ilECSSetting $server)
25  {
26  $this->server = $server;
27  }
28 
33  public function getServer()
34  {
35  return $this->server;
36  }
37 
42  public function getMid()
43  {
44  return $this->mid;
45  }
46 
52  public function checkAllocationActivation(ilECSSetting $server, $a_content_id)
53  {
54 
55  }
56 
57 
63  public function handleCreate(ilECSSetting $server, $a_content_id)
64  {
65  try
66  {
67  include_once './Services/WebServices/ECS/classes/Connectors/class.ilECSEnrolmentStatus.php';
68  include_once './Services/WebServices/ECS/classes/Connectors/class.ilECSEnrolmentStatusConnector.php';
69  $enrolment_con = new ilECSEnrolmentStatusConnector($server);
70  $status = $enrolment_con->getEnrolmentStatus($a_content_id);
71  $GLOBALS['ilLog']->write(__METHOD__.': '.print_r($status,TRUE));
72  $GLOBALS['ilLog']->write(__METHOD__.': '.$status->getPersonIdType());
73  $GLOBALS['ilLog']->write(__METHOD__.': '.$status->getPersonId());
74  switch($status->getPersonIdType())
75  {
77  $id_arr = ilUtil::parseImportId($status->getPersonId());
78  $GLOBALS['ilLog']->write(__METHOD__.': Handling status change to '.$status->getStatus().' for user '.$id_arr['id']);
79  $this->doUpdate($id_arr['id'],$status);
80  break;
81 
82 
83 
84  default:
85  $GLOBALS['ilLog']->write(__METHOD__.': not implemented yes: person id type: '.$status->getPersonIdType());
86  break;
87  }
88 
89  }
90  catch (ilECSConnectorException $e)
91  {
92  $GLOBALS['ilLog']->write(__METHOD__.': Enrolment status change failed with messsage: '.$e->getMessage());
93  }
94  return TRUE;
95  }
96 
102  public function handleDelete(ilECSSetting $server, $a_content_id)
103  {
104  // nothing todo
105  return true;
106  }
107 
113  public function handleUpdate(ilECSSetting $server, $a_content_id)
114  {
115  // Shouldn't happen
116  return true;
117  }
118 
119 
125  protected function doUpdate($a_usr_id, ilECSEnrolmentStatus $status)
126  {
127  include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
128  $obj_ids = ilECSImport::lookupObjIdsByContentId($status->getId());
129  $obj_id = end($obj_ids);
130  $ref_ids = ilObject::_getAllReferences($obj_id);
131  $ref_id = end($ref_ids);
132 
133 
134  if(!$ref_id)
135  {
136  // Remote object not found
137  return TRUE;
138  }
139 
140  switch($status->getStatus())
141  {
143  // nothing todo in the moment: maybe send mail
144  break;
145 
147  $GLOBALS['ilLog']->write(__METHOD__.': Add desktop item: '.$a_usr_id.' '.$ref_id.' '.$obj_id);
149  break;
150 
155  $GLOBALS['ilLog']->write(__METHOD__.': Remove desktop item: '.$a_usr_id.' '.$ref_id.' '.$obj_id);
157  break;
158  }
159  return TRUE;
160  }
161 
162 
163 }
164 ?>