24 include_once
'./Services/WebServices/ECS/classes/class.ilECSEvent.php';
59 include_once(
'Services/WebServices/ECS/classes/class.ilECSSetting.php');
60 include_once(
'Services/WebServices/ECS/classes/class.ilECSReaderException.php');
80 include_once(
'Services/WebServices/ECS/classes/class.ilECSConnector.php');
81 include_once(
'Services/WebServices/ECS/classes/class.ilECSConnectorException.php');
85 include_once(
'./Services/WebServices/ECS/classes/class.ilECSEContentReader.php');
86 include_once(
'./Services/WebServices/ECS/classes/class.ilECSEventQueueReader.php');
87 include_once(
'./Services/WebServices/ECS/classes/class.ilECSImport.php');
88 include_once(
'./Services/WebServices/ECS/classes/class.ilECSExport.php');
94 $list =
$reader->readResourceList();
101 foreach($list->getLinkIds() as $link_id)
103 if(!isset($imported[$link_id]))
122 if(isset($imported[$link_id]))
124 unset($imported[$link_id]);
128 if(is_array($imported))
131 foreach($imported as $econtent_id => $null)
142 $ilLog->write(
'Cannot connect to ECS server: '.$e1->getMessage());
147 $ilLog->write(
'Update failed: '.$e2->getMessage());
163 include_once(
'./Services/WebServices/ECS/classes/class.ilECSExport.php');
175 include_once
'./Services/WebServices/ECS/classes/class.ilECSEContentReader.php';
181 $GLOBALS[
'ilLog']->write(__METHOD__.
': Connect failed '.$e->getMessage());
186 $GLOBALS[
'ilLog']->write(__METHOD__.
': Connect failed '.$e->getMessage());
190 $remote_econtent_ids = array();
193 $remote_econtent_ids = $list->getLinkIds();
197 foreach($local_econtent_ids as $econtent_id => $obj_id)
199 if(!in_array($econtent_id, $remote_econtent_ids))
206 foreach($remote_econtent_ids as $econtent_id)
208 if(!isset($local_econtent_ids[$econtent_id]))
223 return $this->settings;
235 return $this->events ? $this->events : array();
247 $query =
"DELETE FROM ecs_events ".
248 'WHERE server_id = '.$ilDB->quote($this->
getServer()->getServerId(),
'integer');
262 $query =
"DELETE FROM ecs_events ".
263 "WHERE type = ".$this->db->quote(self::TYPE_ECONTENT,
'text').
' '.
264 'AND server_id = '.$ilDB->quote($this->
getServer()->getServerId(),
'integer');
278 $query =
"DELETE FROM ecs_events ".
279 "WHERE type = ".$this->db->quote(self::TYPE_EXPORTED,
'text').
' '.
280 'AND server_id = '.$ilDB->quote($this->
getServer()->getServerId(),
'integer');
294 include_once(
'Services/WebServices/ECS/classes/class.ilECSConnector.php');
295 include_once(
'Services/WebServices/ECS/classes/class.ilECSConnectorException.php');
300 $res = $connector->readEventFifo(
false);
302 if(!count(
$res->getResult()))
309 include_once
'./Services/WebServices/ECS/classes/class.ilECSEvent.php';
312 $GLOBALS[
'ilLog']->write(__METHOD__.
' ---------------------------- Handling new event ');
313 $GLOBALS[
'ilLog']->write(__METHOD__.print_r($event,
true));
314 $GLOBALS[
'ilLog']->write(__METHOD__.
' ---------------------------- Done! ');
320 $connector->readEventFifo(
true);
325 $GLOBALS[
'ilLog']->write(__METHOD__.
': Cannot read event fifo. Aborting');
338 $query =
'DELETE FROM ecs_events '.
339 'WHERE server_id = '.$ilDB->quote($a_server_id,
'integer');
340 $ilDB->manipulate(
$query);
350 $query =
"SELECT * FROM ecs_events ".
351 "WHERE type = ".$ilDB->quote(self::TYPE_ECONTENT,
'integer').
" ".
353 'AND server_id = '.$ilDB->quote($this->getServer()->getServerId(),
'integer');
359 $event_id =
$row->event_id;
367 $query =
"INSERT ecs_events (event_id,type,id,op,server_id) ".
369 $ilDB->quote($ilDB->nextId(
'ecs_events'),
'integer').
','.
370 $ilDB->quote(self::TYPE_ECONTENT,
'text').
', '.
372 $ilDB->quote($ev->
getStatus(),
'text').
', '.
373 $ilDB->quote($this->getServer()->getServerId(),
'integer').
' '.
375 $ilDB->manipulate(
$query);
400 $query =
"UPDATE ecs_events ".
401 "SET op = ".$ilDB->quote($ev->
getStatus(),
'text').
" ".
402 "WHERE event_id = ".$ilDB->quote($event_id,
'integer').
' '.
403 'AND server_id = '.$ilDB->quote($this->
getServer()->getServerId(),
'integer');
404 $ilDB->manipulate(
$query);
416 $event = array_shift($this->events);
423 $this->
delete($event[
'event_id']);
434 public function add($a_type,$a_id,$a_op)
438 $next_id = $ilDB->nextId(
'ecs_events');
439 $query =
"INSERT INTO ecs_events (event_id,type,id,op,server_id) ".
441 $ilDB->quote($next_id,
'integer').
", ".
442 $this->db->quote($a_type,
'text').
", ".
443 $this->db->quote($a_id,
'integer').
", ".
444 $this->db->quote($a_op,
'text').
", ".
445 $ilDB->quote($this->
getServer()->getServerId(),
'integer').
' '.
449 $new_event[
'event_id'] = $next_id;
450 $new_event[
'type'] = $a_type;
451 $new_event[
'id'] = $a_id;
452 $new_event[
'op'] = $a_op;
454 $this->events[] = $new_event;
455 $this->econtent_ids[$a_id] = $a_id;
465 private function update($a_type,$a_id,$a_operation)
469 $query =
"UPDATE ecs_events ".
470 "SET op = ".$this->db->quote($a_operation,
'text').
" ".
471 "WHERE type = ".$this->db->quote($a_type,
'text').
" ".
472 "AND id = ".$this->db->quote($a_id,
'integer').
" ".
473 'AND server_id = '.$ilDB->quote($this->
getServer()->getServerId(),
'integer');
483 private function delete($a_event_id)
487 $query =
"DELETE FROM ecs_events ".
488 "WHERE event_id = ".$this->db->quote($a_event_id,
'integer').
" ".
489 'AND server_id = '.$ilDB->quote($this->
getServer()->getServerId(),
'integer');
491 unset($this->econtent_ids[$a_event_id]);
503 $query =
"SELECT * FROM ecs_events ORDER BY event_id ".
504 'AND server_id = '.$ilDB->quote($this->
getServer()->getServerId(),
'integer');
509 $this->events[$counter][
'event_id'] =
$row->event_id;
510 $this->events[$counter][
'type'] =
$row->type;
511 $this->events[$counter][
'id'] =
$row->id;
512 $this->events[$counter][
'op'] =
$row->op;
514 $this->econtent_ids[
$row->event_id] =
$row->event_id;