ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilECSCmsCourseCommandQueueHandler.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 try {
55 include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseConnector.php';
56 $crs_reader = new ilECSCourseConnector($server);
57 $details = $crs_reader->getCourse($a_content_id, true);
58 $this->mid = $details->getMySender();
59
60 // Check if import is enabled
61 include_once './Services/WebServices/ECS/classes/class.ilECSParticipantSetting.php';
62 $part = ilECSParticipantSetting::getInstance($this->getServer()->getServerId(), $this->getMid());
63 if (!$part->isImportEnabled()) {
64 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': Import disabled for mid ' . $this->getMid());
65 return false;
66 }
67 // Check course allocation setting
68 include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingSettings.php';
70 $this->getServer()->getServerId(),
71 $this->getMid()
72 );
73 $enabled = $gl_settings->isCourseAllocationEnabled();
74 if (!$enabled) {
75 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': Course allocation disabled for ' . $this->getMid());
76 }
77 return $enabled;
78 } catch (ilECSConnectorException $e) {
79 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': Reading course details failed with message ' . $e->getMessage());
80 return false;
81 }
82 }
83
84
90 public function handleCreate(ilECSSetting $server, $a_content_id)
91 {
92 include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
93 include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsTree.php';
94 include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseConnector.php';
95
96 if (!$this->checkAllocationActivation($server, $a_content_id)) {
97 return true;
98 }
99 try {
100 $course = $this->readCourse($server, $a_content_id);
101 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': ' . print_r($course, true));
102 $this->doUpdate($a_content_id, $course);
103 return true;
104 } catch (ilECSConnectorException $e) {
105 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': Course creation failed with mesage ' . $e->getMessage());
106 return false;
107 }
108 return true;
109 }
110
116 public function handleDelete(ilECSSetting $server, $a_content_id)
117 {
118 // nothing todo
119 return true;
120 }
121
127 public function handleUpdate(ilECSSetting $server, $a_content_id)
128 {
129 if (!$this->checkAllocationActivation($server, $a_content_id)) {
130 return true;
131 }
132
133 try {
134 $course = $this->readCourse($server, $a_content_id);
135 $this->doUpdate($a_content_id, $course);
136 return true;
137 } catch (ilECSConnectorException $e) {
138 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': Course creation failed with mesage ' . $e->getMessage());
139 return false;
140 }
141 return true;
142 }
143
144
150 protected function doUpdate($a_content_id, $course)
151 {
152 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': Starting course creation/update');
153
154 include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseCreationHandler.php';
155 $creation_handler = new ilECSCourseCreationHandler($this->getServer(), $this->mid);
156 $creation_handler->handle($a_content_id, $course);
157 }
158
159
164 private function readCourse(ilECSSetting $server, $a_content_id, $a_details = false)
165 {
166 try {
167 include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseConnector.php';
168 $crs_reader = new ilECSCourseConnector($server);
169 return $crs_reader->getCourse($a_content_id, $a_details);
170 } catch (ilECSConnectorException $e) {
171 throw $e;
172 }
173 }
174}
An exception for terminatinating execution or to throw for unit testing.
checkAllocationActivation(ilECSSetting $server, $a_content_id)
Check if course allocation is activated for one recipient of the.
handleCreate(ilECSSetting $server, $a_content_id)
Handle create.
handleUpdate(ilECSSetting $server, $a_content_id)
Handle update.
handleDelete(ilECSSetting $server, $a_content_id)
Handle delete.
readCourse(ilECSSetting $server, $a_content_id, $a_details=false)
Read course from ecs.
static getInstanceByServerMid($a_server_id, $a_mid)
Get instance.
static getInstance($a_server_id, $mid)
Get instance by server id and mid.
Interface for all command queue handler classes.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.