24 include_once
'./Services/WebServices/ECS/classes/class.ilECSEvent.php';
68 include_once(
'Services/WebServices/ECS/classes/class.ilECSSetting.php');
96 return array(self::TYPE_REMOTE_COURSE, self::TYPE_REMOTE_CATEGORY,
97 self::TYPE_REMOTE_FILE, self::TYPE_REMOTE_GLOSSARY, self::TYPE_REMOTE_GROUP,
98 self::TYPE_REMOTE_LEARNING_MODULE, self::TYPE_REMOTE_WIKI, self::TYPE_REMOTE_TEST);
111 include_once
'Services/WebServices/ECS/classes/class.ilRemoteObjectBase.php';
113 foreach($a_types as $type)
118 $list[$type] = $robj->getAllResourceIds($server, $a_sender_only);
136 include_once(
'Services/WebServices/ECS/classes/class.ilECSConnector.php');
137 include_once(
'Services/WebServices/ECS/classes/class.ilECSConnectorException.php');
141 include_once(
'./Services/WebServices/ECS/classes/class.ilECSEventQueueReader.php');
142 include_once(
'./Services/WebServices/ECS/classes/class.ilECSImport.php');
143 include_once(
'./Services/WebServices/ECS/classes/class.ilECSExport.php');
153 $GLOBALS[
'ilLog']->write(__METHOD__.
': Imported = '.print_r($imported,
true));
154 $GLOBALS[
'ilLog']->write(__METHOD__.
': List = '.print_r($list,
true));
156 foreach($list as $resource_type => $link_ids)
160 $GLOBALS[
'ilLog']->write(__METHOD__.
': Ignoring resource type '. $resource_type);
165 foreach((array) $link_ids as $link_id)
167 if(!isset($imported[$link_id]))
186 if(isset($imported[$link_id]))
188 unset($imported[$link_id]);
193 if(is_array($imported))
196 include_once
'Services/WebServices/ECS/classes/class.ilECSObjectSettings.php';
197 foreach($imported as $econtent_id => $obj_id)
202 $event_queue->add($type,
212 $ilLog->write(
'Cannot connect to ECS server: '.$e1->getMessage());
217 $ilLog->write(
'Update failed: '.$e2->getMessage());
233 include_once(
'./Services/WebServices/ECS/classes/class.ilECSExport.php');
247 $all_remote_ids = array();
248 foreach($list as $resource_type => $remote_ids)
250 $all_remote_ids = array_merge($all_remote_ids,(array) $remote_ids);
252 $all_remote_ids = array_unique($all_remote_ids);
254 $GLOBALS[
'ilLog']->write(__METHOD__.
': Resources = ' . print_r($all_remote_ids,
true));
255 $GLOBALS[
'ilLog']->write(__METHOD__.
': Local = ' . print_r($local_econtent_ids,
true));
256 foreach($local_econtent_ids as $local_econtent_id => $local_obj_id)
258 if(!in_array($local_econtent_id, $all_remote_ids))
261 $GLOBALS[
'ilLog']->write(__METHOD__.
': Deleting deprecated econtent id '. $local_econtent_id);
276 return $this->settings;
288 return $this->events ? $this->events : array();
300 $query =
"DELETE FROM ecs_events ".
301 'WHERE server_id = '.$ilDB->quote($this->
getServer()->getServerId(),
'integer');
316 $query =
"DELETE FROM ecs_events ".
317 "WHERE ".$this->db->in(
"type", $a_types,
"",
"text").
' '.
318 'AND server_id = '.$ilDB->quote($this->
getServer()->getServerId(),
'integer');
332 $query =
"DELETE FROM ecs_events ".
333 "WHERE type = ".$this->db->quote(self::TYPE_EXPORTED,
'text').
' '.
334 'AND server_id = '.$ilDB->quote($this->
getServer()->getServerId(),
'integer');
348 include_once(
'Services/WebServices/ECS/classes/class.ilECSConnector.php');
349 include_once(
'Services/WebServices/ECS/classes/class.ilECSConnectorException.php');
354 $res = $connector->readEventFifo(
false);
356 if(!count(
$res->getResult()))
363 include_once
'./Services/WebServices/ECS/classes/class.ilECSEvent.php';
366 $GLOBALS[
'ilLog']->write(__METHOD__.
' ---------------------------- Handling new event ');
367 $GLOBALS[
'ilLog']->write(__METHOD__.print_r($event,
true));
368 $GLOBALS[
'ilLog']->write(__METHOD__.
' ---------------------------- Done! ');
374 $connector->readEventFifo(
true);
380 $GLOBALS[
'ilLog']->write(__METHOD__.
': Cannot read event fifo. Aborting');
393 $query =
'DELETE FROM ecs_events '.
394 'WHERE server_id = '.$ilDB->quote($a_server_id,
'integer');
395 $ilDB->manipulate(
$query);
408 case 'directory_trees':
412 case 'course_members':
440 case 'learningmodules':
456 case 'member_status':
461 $query =
"SELECT * FROM ecs_events ".
462 "WHERE type = ".$ilDB->quote($type,
'integer').
" ".
464 'AND server_id = '.$ilDB->quote($this->getServer()->getServerId(),
'integer');
470 $event_id =
$row->event_id;
476 $query =
"INSERT ecs_events (event_id,type,id,op,server_id) ".
478 $ilDB->quote($ilDB->nextId(
'ecs_events'),
'integer').
','.
479 $ilDB->quote($type,
'text').
', '.
481 $ilDB->quote($ev->
getStatus(),
'text').
', '.
482 $ilDB->quote($this->getServer()->getServerId(),
'integer').
' '.
484 $ilDB->manipulate(
$query);
509 $query =
"UPDATE ecs_events ".
510 "SET op = ".$ilDB->quote($ev->
getStatus(),
'text').
" ".
511 "WHERE event_id = ".$ilDB->quote($event_id,
'integer').
' '.
512 'AND type = '.$ilDB->quote($type).
' '.
513 'AND server_id = '.$ilDB->quote($this->
getServer()->getServerId(),
'integer');
514 $ilDB->manipulate(
$query);
526 $event = array_shift($this->events);
534 #$this->delete($event['event_id']);
545 public function add($a_type,$a_id,$a_op)
549 $next_id = $ilDB->nextId(
'ecs_events');
550 $query =
"INSERT INTO ecs_events (event_id,type,id,op,server_id) ".
552 $ilDB->quote($next_id,
'integer').
", ".
553 $this->db->quote($a_type,
'text').
", ".
554 $this->db->quote($a_id,
'integer').
", ".
555 $this->db->quote($a_op,
'text').
", ".
556 $ilDB->quote($this->
getServer()->getServerId(),
'integer').
' '.
560 $new_event[
'event_id'] = $next_id;
561 $new_event[
'type'] = $a_type;
562 $new_event[
'id'] = $a_id;
563 $new_event[
'op'] = $a_op;
565 $this->events[] = $new_event;
566 $this->econtent_ids[$a_id] = $a_id;
576 private function update($a_type,$a_id,$a_operation)
580 $query =
"UPDATE ecs_events ".
581 "SET op = ".$this->db->quote($a_operation,
'text').
" ".
582 "WHERE type = ".$this->db->quote($a_type,
'text').
" ".
583 "AND id = ".$this->db->quote($a_id,
'integer').
" ".
584 'AND server_id = '.$ilDB->quote($this->
getServer()->getServerId(),
'integer');
594 public function delete($a_event_id)
598 $query =
"DELETE FROM ecs_events ".
599 "WHERE event_id = ".$this->db->quote($a_event_id,
'integer').
" ".
600 'AND server_id = '.$ilDB->quote($this->
getServer()->getServerId(),
'integer');
602 unset($this->econtent_ids[$a_event_id]);
614 $query =
"SELECT * FROM ecs_events ".
615 'WHERE server_id = '.$ilDB->quote($this->
getServer()->getServerId(),
'integer').
' '.
622 $this->events[$counter][
'event_id'] =
$row->event_id;
623 $this->events[$counter][
'type'] =
$row->type;
624 $this->events[$counter][
'id'] =
$row->id;
625 $this->events[$counter][
'op'] =
$row->op;
627 $this->econtent_ids[
$row->event_id] =
$row->event_id;
637 $query =
'DELETE FROM ecs_events'.
638 ' WHERE server_id = '.$ilDB->quote($a_server_id,
'integer');
639 $ilDB->manipulate(
$query);