24 include_once
'./Services/WebServices/ECS/classes/class.ilECSEvent.php';
67 include_once(
'Services/WebServices/ECS/classes/class.ilECSSetting.php');
95 return array(self::TYPE_REMOTE_COURSE, self::TYPE_REMOTE_CATEGORY,
96 self::TYPE_REMOTE_FILE, self::TYPE_REMOTE_GLOSSARY, self::TYPE_REMOTE_GROUP,
97 self::TYPE_REMOTE_LEARNING_MODULE, self::TYPE_REMOTE_WIKI, self::TYPE_REMOTE_TEST);
110 include_once
'Services/WebServices/ECS/classes/class.ilRemoteObjectBase.php';
112 foreach($a_types as $type)
117 $list[$type] = $robj->getAllResourceIds($server, $a_sender_only);
135 include_once(
'Services/WebServices/ECS/classes/class.ilECSConnector.php');
136 include_once(
'Services/WebServices/ECS/classes/class.ilECSConnectorException.php');
140 include_once(
'./Services/WebServices/ECS/classes/class.ilECSEventQueueReader.php');
141 include_once(
'./Services/WebServices/ECS/classes/class.ilECSImport.php');
142 include_once(
'./Services/WebServices/ECS/classes/class.ilECSExport.php');
152 $GLOBALS[
'ilLog']->write(__METHOD__.
': Imported = '.print_r($imported,
true));
153 $GLOBALS[
'ilLog']->write(__METHOD__.
': List = '.print_r($list,
true));
155 foreach($list as $resource_type => $link_ids)
159 $GLOBALS[
'ilLog']->write(__METHOD__.
': Ignoring resource type '. $resource_type);
164 foreach((array) $link_ids as $link_id)
166 if(!isset($imported[$link_id]))
185 if(isset($imported[$link_id]))
187 unset($imported[$link_id]);
192 if(is_array($imported))
195 include_once
'Services/WebServices/ECS/classes/class.ilECSObjectSettings.php';
196 foreach($imported as $econtent_id => $obj_id)
201 $event_queue->add($type,
211 $ilLog->write(
'Cannot connect to ECS server: '.$e1->getMessage());
216 $ilLog->write(
'Update failed: '.$e2->getMessage());
232 include_once(
'./Services/WebServices/ECS/classes/class.ilECSExport.php');
246 $all_remote_ids = array();
247 foreach($list as $resource_type => $remote_ids)
249 $all_remote_ids = array_merge($all_remote_ids,(array) $remote_ids);
251 $all_remote_ids = array_unique($all_remote_ids);
253 $GLOBALS[
'ilLog']->write(__METHOD__.
': Resources = ' . print_r($all_remote_ids,
true));
254 $GLOBALS[
'ilLog']->write(__METHOD__.
': Local = ' . print_r($local_econtent_ids,
true));
255 foreach($local_econtent_ids as $local_econtent_id => $local_obj_id)
257 if(!in_array($local_econtent_id, $all_remote_ids))
260 $GLOBALS[
'ilLog']->write(__METHOD__.
': Deleting deprecated econtent id '. $local_econtent_id);
275 return $this->settings;
287 return $this->events ? $this->events : array();
299 $query =
"DELETE FROM ecs_events ".
300 'WHERE server_id = '.$ilDB->quote($this->
getServer()->getServerId(),
'integer');
315 $query =
"DELETE FROM ecs_events ".
316 "WHERE ".$this->db->in(
"type", $a_types,
"",
"text").
' '.
317 'AND server_id = '.$ilDB->quote($this->
getServer()->getServerId(),
'integer');
331 $query =
"DELETE FROM ecs_events ".
332 "WHERE type = ".$this->db->quote(self::TYPE_EXPORTED,
'text').
' '.
333 'AND server_id = '.$ilDB->quote($this->
getServer()->getServerId(),
'integer');
347 include_once(
'Services/WebServices/ECS/classes/class.ilECSConnector.php');
348 include_once(
'Services/WebServices/ECS/classes/class.ilECSConnectorException.php');
353 $res = $connector->readEventFifo(
false);
355 if(!count(
$res->getResult()))
362 include_once
'./Services/WebServices/ECS/classes/class.ilECSEvent.php';
365 $GLOBALS[
'ilLog']->write(__METHOD__.
' ---------------------------- Handling new event ');
366 $GLOBALS[
'ilLog']->write(__METHOD__.print_r($event,
true));
367 $GLOBALS[
'ilLog']->write(__METHOD__.
' ---------------------------- Done! ');
373 $connector->readEventFifo(
true);
379 $GLOBALS[
'ilLog']->write(__METHOD__.
': Cannot read event fifo. Aborting');
392 $query =
'DELETE FROM ecs_events '.
393 'WHERE server_id = '.$ilDB->quote($a_server_id,
'integer');
394 $ilDB->manipulate(
$query);
409 case 'directory_trees':
413 case 'course_members':
441 case 'learningmodules':
458 $query =
"SELECT * FROM ecs_events ".
459 "WHERE type = ".$ilDB->quote($type,
'integer').
" ".
461 'AND server_id = '.$ilDB->quote($this->getServer()->getServerId(),
'integer');
467 $event_id =
$row->event_id;
473 $query =
"INSERT ecs_events (event_id,type,id,op,server_id) ".
475 $ilDB->quote($ilDB->nextId(
'ecs_events'),
'integer').
','.
476 $ilDB->quote($type,
'text').
', '.
478 $ilDB->quote($ev->
getStatus(),
'text').
', '.
479 $ilDB->quote($this->getServer()->getServerId(),
'integer').
' '.
481 $ilDB->manipulate(
$query);
506 $query =
"UPDATE ecs_events ".
507 "SET op = ".$ilDB->quote($ev->
getStatus(),
'text').
" ".
508 "WHERE event_id = ".$ilDB->quote($event_id,
'integer').
' '.
509 'AND type = '.$ilDB->quote($type).
' '.
510 'AND server_id = '.$ilDB->quote($this->
getServer()->getServerId(),
'integer');
511 $ilDB->manipulate(
$query);
523 $event = array_shift($this->events);
531 #$this->delete($event['event_id']);
542 public function add($a_type,$a_id,$a_op)
546 $next_id = $ilDB->nextId(
'ecs_events');
547 $query =
"INSERT INTO ecs_events (event_id,type,id,op,server_id) ".
549 $ilDB->quote($next_id,
'integer').
", ".
550 $this->db->quote($a_type,
'text').
", ".
551 $this->db->quote($a_id,
'integer').
", ".
552 $this->db->quote($a_op,
'text').
", ".
553 $ilDB->quote($this->
getServer()->getServerId(),
'integer').
' '.
557 $new_event[
'event_id'] = $next_id;
558 $new_event[
'type'] = $a_type;
559 $new_event[
'id'] = $a_id;
560 $new_event[
'op'] = $a_op;
562 $this->events[] = $new_event;
563 $this->econtent_ids[$a_id] = $a_id;
573 private function update($a_type,$a_id,$a_operation)
577 $query =
"UPDATE ecs_events ".
578 "SET op = ".$this->db->quote($a_operation,
'text').
" ".
579 "WHERE type = ".$this->db->quote($a_type,
'text').
" ".
580 "AND id = ".$this->db->quote($a_id,
'integer').
" ".
581 'AND server_id = '.$ilDB->quote($this->
getServer()->getServerId(),
'integer');
591 public function delete($a_event_id)
595 $query =
"DELETE FROM ecs_events ".
596 "WHERE event_id = ".$this->db->quote($a_event_id,
'integer').
" ".
597 'AND server_id = '.$ilDB->quote($this->
getServer()->getServerId(),
'integer');
599 unset($this->econtent_ids[$a_event_id]);
611 $query =
"SELECT * FROM ecs_events ".
612 'WHERE server_id = '.$ilDB->quote($this->
getServer()->getServerId(),
'integer').
' '.
619 $this->events[$counter][
'event_id'] =
$row->event_id;
620 $this->events[$counter][
'type'] =
$row->type;
621 $this->events[$counter][
'id'] =
$row->id;
622 $this->events[$counter][
'op'] =
$row->op;
624 $this->econtent_ids[
$row->event_id] =
$row->event_id;
634 $query =
'DELETE FROM ecs_events'.
635 ' WHERE server_id = '.$ilDB->quote($a_server_id,
'integer');
636 $ilDB->manipulate(
$query);