ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
5include_once './Services/WebServices/ECS/interfaces/interface.ilECSCommandQueueHandler.php';
6include_once './Services/WebServices/ECS/classes/class.ilECSSetting.php';
7include_once './Services/WebServices/ECS/classes/class.ilECSParticipantSetting.php';
8
9
16{
17 private $server = null;
18 private $mid = 0;
19
20
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
62 public function handleCreate(ilECSSetting $server, $a_content_id)
63 {
64 try {
65 include_once './Services/WebServices/ECS/classes/Connectors/class.ilECSEnrolmentStatus.php';
66 include_once './Services/WebServices/ECS/classes/Connectors/class.ilECSEnrolmentStatusConnector.php';
67 $enrolment_con = new ilECSEnrolmentStatusConnector($server);
68 $status = $enrolment_con->getEnrolmentStatus($a_content_id);
69 $GLOBALS['ilLog']->write(__METHOD__ . ': ' . print_r($status, true));
70 $GLOBALS['ilLog']->write(__METHOD__ . ': ' . $status->getPersonIdType());
71 $GLOBALS['ilLog']->write(__METHOD__ . ': ' . $status->getPersonId());
72 switch ($status->getPersonIdType()) {
74 $id_arr = ilUtil::parseImportId($status->getPersonId());
75 $GLOBALS['ilLog']->write(__METHOD__ . ': Handling status change to ' . $status->getStatus() . ' for user ' . $id_arr['id']);
76 $this->doUpdate($id_arr['id'], $status);
77 break;
78
79
80
81 default:
82 $GLOBALS['ilLog']->write(__METHOD__ . ': not implemented yes: person id type: ' . $status->getPersonIdType());
83 break;
84 }
85 } catch (ilECSConnectorException $e) {
86 $GLOBALS['ilLog']->write(__METHOD__ . ': Enrolment status change failed with messsage: ' . $e->getMessage());
87 }
88 return true;
89 }
90
96 public function handleDelete(ilECSSetting $server, $a_content_id)
97 {
98 // nothing todo
99 return true;
100 }
101
107 public function handleUpdate(ilECSSetting $server, $a_content_id)
108 {
109 // Shouldn't happen
110 return true;
111 }
112
113
119 protected function doUpdate($a_usr_id, ilECSEnrolmentStatus $status)
120 {
121 include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
122 $obj_ids = ilECSImport::lookupObjIdsByContentId($status->getId());
123 $obj_id = end($obj_ids);
124 $ref_ids = ilObject::_getAllReferences($obj_id);
125 $ref_id = end($ref_ids);
126
127
128 if (!$ref_id) {
129 // Remote object not found
130 return true;
131 }
132
133 switch ($status->getStatus()) {
135 // nothing todo in the moment: maybe send mail
136 break;
137
139 $GLOBALS['ilLog']->write(__METHOD__ . ': Add desktop item: ' . $a_usr_id . ' ' . $ref_id . ' ' . $obj_id);
140 ilObjUser::_addDesktopItem($a_usr_id, $ref_id, ilObject::_lookupType($obj_id));
141 break;
142
147 $GLOBALS['ilLog']->write(__METHOD__ . ': Remove desktop item: ' . $a_usr_id . ' ' . $ref_id . ' ' . $obj_id);
148 ilObjUser::_dropDesktopItem($a_usr_id, $ref_id, ilObject::_lookupType($obj_id));
149 break;
150 }
151 return true;
152 }
153}
An exception for terminatinating execution or to throw for unit testing.
handleUpdate(ilECSSetting $server, $a_content_id)
Handle update.
doUpdate($a_usr_id, ilECSEnrolmentStatus $status)
Perform update.
handleDelete(ilECSSetting $server, $a_content_id)
Handle delete.
handleCreate(ilECSSetting $server, $a_content_id)
Handle create.
checkAllocationActivation(ilECSSetting $server, $a_content_id)
Check if course allocation is activated for one recipient of the.
Connector for course member ressource.
static lookupObjIdsByContentId($a_content_id)
static _dropDesktopItem($a_usr_id, $a_item_id, $a_type)
drop an item from user's personal desktop
static _addDesktopItem($a_usr_id, $a_item_id, $a_type, $a_par="")
add an item to user's personal desktop
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
static parseImportId($a_import_id)
Parse an ilias import id Typically of type il_[IL_INST_ID]_[OBJ_TYPE]_[OBJ_ID] returns array( 'orig' ...
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Interface for all command queue handler classes.