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');
145 $types = self::getAllEContentTypes();
150 $list = self::getAllResourceIds($server, $types);
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');
242 $types = self::getAllEContentTypes();
243 $list = self::getAllResourceIds($server, $types,
true);
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':
409 $type = self::TYPE_DIRECTORY_TREES;
412 case 'course_members':
413 $type = self::TYPE_CMS_COURSE_MEMBERS;
417 $type = self::TYPE_CMS_COURSES;
421 $type = self::TYPE_REMOTE_COURSE;
425 $type = self::TYPE_REMOTE_CATEGORY;
429 $type = self::TYPE_REMOTE_FILE;
433 $type = self::TYPE_REMOTE_GLOSSARY;
437 $type = self::TYPE_REMOTE_GROUP;
440 case 'learningmodules':
441 $type = self::TYPE_REMOTE_LEARNING_MODULE;
445 $type = self::TYPE_REMOTE_WIKI;
449 $type = self::TYPE_REMOTE_TEST;
453 $type = self::TYPE_COURSE_URLS;
456 case 'member_status':
457 $type = self::TYPE_ENROLMENT_STATUS;
466 $query =
"SELECT * FROM ecs_events ".
467 "WHERE type = ".$ilDB->quote($type,
'integer').
" ".
469 'AND server_id = '.$ilDB->quote($this->getServer()->getServerId(),
'integer');
475 $event_id =
$row->event_id;
481 $query =
"INSERT ecs_events (event_id,type,id,op,server_id) ".
483 $ilDB->quote($ilDB->nextId(
'ecs_events'),
'integer').
','.
484 $ilDB->quote($type,
'text').
', '.
486 $ilDB->quote($ev->
getStatus(),
'text').
', '.
487 $ilDB->quote($this->getServer()->getServerId(),
'integer').
' '.
489 $ilDB->manipulate(
$query);
514 $query =
"UPDATE ecs_events ".
515 "SET op = ".$ilDB->quote($ev->
getStatus(),
'text').
" ".
516 "WHERE event_id = ".$ilDB->quote($event_id,
'integer').
' '.
517 'AND type = '.$ilDB->quote($type).
' '.
518 'AND server_id = '.$ilDB->quote($this->
getServer()->getServerId(),
'integer');
519 $ilDB->manipulate(
$query);
531 $event = array_shift($this->events);
539 #$this->delete($event['event_id']); 554 $next_id = $ilDB->nextId(
'ecs_events');
555 $query =
"INSERT INTO ecs_events (event_id,type,id,op,server_id) ".
557 $ilDB->quote($next_id,
'integer').
", ".
558 $this->db->quote(
$a_type,
'text').
", ".
559 $this->db->quote($a_id,
'integer').
", ".
560 $this->db->quote($a_op,
'text').
", ".
561 $ilDB->quote($this->
getServer()->getServerId(),
'integer').
' '.
565 $new_event[
'event_id'] = $next_id;
567 $new_event[
'id'] = $a_id;
568 $new_event[
'op'] = $a_op;
570 $this->events[] = $new_event;
571 $this->econtent_ids[$a_id] = $a_id;
585 $query =
"UPDATE ecs_events ".
586 "SET op = ".$this->db->quote($a_operation,
'text').
" ".
587 "WHERE type = ".$this->db->quote(
$a_type,
'text').
" ".
588 "AND id = ".$this->db->quote($a_id,
'integer').
" ".
589 'AND server_id = '.$ilDB->quote($this->
getServer()->getServerId(),
'integer');
599 public function delete($a_event_id)
603 $query =
"DELETE FROM ecs_events ".
604 "WHERE event_id = ".$this->db->quote($a_event_id,
'integer').
" ".
605 'AND server_id = '.$ilDB->quote($this->
getServer()->getServerId(),
'integer');
607 unset($this->econtent_ids[$a_event_id]);
619 $query =
"SELECT * FROM ecs_events ".
620 'WHERE server_id = '.$ilDB->quote($this->
getServer()->getServerId(),
'integer').
' '.
632 $this->econtent_ids[
$row->event_id] =
$row->event_id;
642 $query =
'DELETE FROM ecs_events'.
643 ' WHERE server_id = '.$ilDB->quote($a_server_id,
'integer');
644 $ilDB->manipulate(
$query);
const TYPE_REMOTE_CATEGORY
static getAllImportedRemoteObjects($a_server_id)
get all imported links
static getEventTypeFromObjectType($a_obj_type)
Convert object type to event type.
static _getAllEContentIds($a_server_id)
get all exported econtent ids per server
static getPossibleRemoteTypes($a_with_captions=false)
Get all possible remote object types.
Base class for ILIAS Exception handling.
static getInstanceByServerId($a_server_id)
Get singleton instance per server.
static handleImportReset(ilECSSetting $server)
Reread all imported econtent.
update($a_type, $a_id, $a_operation)
update one entry
static deleteServer($a_server_id)
Delete by server id ilDB $ilDB.
getServerId()
Get current server id.
static _deleteEContentIds($a_server_id, $a_ids)
Delete econtent ids for server.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
getRessourceType()
Get ressource type.
deleteAllExportedEvents()
Delete all exported events.
static getInstanceByEventType($a_type)
Get instance by ilECSEvent(QueueReader) type.
static getAllEContentTypes()
All available content types.
deleteAllEContentEvents(array $a_types)
Delete all econtents.
deleteAll()
Delete all events.
getRessourceId()
Get ressource id.
const TYPE_DIRECTORY_TREES
writeEventToDB(ilECSEvent $ev)
Write event to db.
refresh()
Fetch events from fifo Using fifo public.
Reads ECS events and stores them in the database.
static deleteByServerId($a_server_id)
const TYPE_REMOTE_LEARNING_MODULE
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
shift()
get and delete the first event entry
const TYPE_CMS_COURSE_MEMBERS
const TYPE_REMOTE_GLOSSARY
__construct($a_server_id)
Constructor.
getServer()
get server setting
static handleExportReset(ilECSSetting $server)
Handle export reset.
getEvents()
get all events
const TYPE_ENROLMENT_STATUS
static getAllResourceIds(ilECSSetting $server, array $a_types, $a_sender_only=false)
Get all resource ids by resource type.
add($a_type, $a_id, $a_op)
add