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) {
116 $list[
$type] = $robj->getAllResourceIds($server, $a_sender_only);
134 include_once(
'Services/WebServices/ECS/classes/class.ilECSConnector.php');
135 include_once(
'Services/WebServices/ECS/classes/class.ilECSConnectorException.php');
138 include_once(
'./Services/WebServices/ECS/classes/class.ilECSEventQueueReader.php');
139 include_once(
'./Services/WebServices/ECS/classes/class.ilECSImport.php');
140 include_once(
'./Services/WebServices/ECS/classes/class.ilECSExport.php');
142 $types = self::getAllEContentTypes();
147 $list = self::getAllResourceIds($server, $types);
150 $GLOBALS[
'ilLog']->write(__METHOD__ .
': Imported = ' . print_r($imported,
true));
151 $GLOBALS[
'ilLog']->write(__METHOD__ .
': List = ' . print_r(
$list,
true));
153 foreach (
$list as $resource_type => $link_ids) {
155 $GLOBALS[
'ilLog']->write(__METHOD__ .
': Ignoring resource type ' . $resource_type);
160 foreach ((
array) $link_ids as $link_id) {
161 if (!isset($imported[$link_id])) {
177 if (isset($imported[$link_id])) {
178 unset($imported[$link_id]);
183 if (is_array($imported)) {
185 include_once
'Services/WebServices/ECS/classes/class.ilECSObjectSettings.php';
186 foreach ($imported as $econtent_id => $obj_id) {
198 $ilLog->write(
'Cannot connect to ECS server: ' . $e1->getMessage());
201 $ilLog->write(
'Update failed: ' . $e2->getMessage());
217 include_once(
'./Services/WebServices/ECS/classes/class.ilECSExport.php');
226 $types = self::getAllEContentTypes();
227 $list = self::getAllResourceIds($server, $types,
true);
231 $all_remote_ids =
array();
232 foreach (
$list as $resource_type => $remote_ids) {
233 $all_remote_ids = array_merge($all_remote_ids, (
array) $remote_ids);
235 $all_remote_ids = array_unique($all_remote_ids);
237 $GLOBALS[
'ilLog']->write(__METHOD__ .
': Resources = ' . print_r($all_remote_ids,
true));
238 $GLOBALS[
'ilLog']->write(__METHOD__ .
': Local = ' . print_r($local_econtent_ids,
true));
239 foreach ($local_econtent_ids as $local_econtent_id => $local_obj_id) {
240 if (!in_array($local_econtent_id, $all_remote_ids)) {
242 $GLOBALS[
'ilLog']->write(__METHOD__ .
': Deleting deprecated econtent id ' . $local_econtent_id);
256 return $this->settings;
268 return $this->events ? $this->events :
array();
280 $query =
"DELETE FROM ecs_events " .
281 'WHERE server_id = ' . $ilDB->quote($this->
getServer()->getServerId(),
'integer');
296 $query =
"DELETE FROM ecs_events " .
297 "WHERE " . $this->db->in(
"type", $a_types,
"",
"text") .
' ' .
298 'AND server_id = ' . $ilDB->quote($this->
getServer()->getServerId(),
'integer');
312 $query =
"DELETE FROM ecs_events " .
313 "WHERE type = " . $this->db->quote(self::TYPE_EXPORTED,
'text') .
' ' .
314 'AND server_id = ' . $ilDB->quote($this->
getServer()->getServerId(),
'integer');
328 include_once(
'Services/WebServices/ECS/classes/class.ilECSConnector.php');
329 include_once(
'Services/WebServices/ECS/classes/class.ilECSConnectorException.php');
333 $res = $connector->readEventFifo(
false);
335 if (!count(
$res->getResult())) {
340 include_once
'./Services/WebServices/ECS/classes/class.ilECSEvent.php';
343 $GLOBALS[
'ilLog']->write(__METHOD__ .
' ---------------------------- Handling new event ');
344 $GLOBALS[
'ilLog']->write(__METHOD__ . print_r($event,
true));
345 $GLOBALS[
'ilLog']->write(__METHOD__ .
' ---------------------------- Done! ');
351 $connector->readEventFifo(
true);
354 $GLOBALS[
'ilLog']->write(__METHOD__ .
': Cannot read event fifo. Aborting');
367 $query =
'DELETE FROM ecs_events ' .
368 'WHERE server_id = ' . $ilDB->quote($a_server_id,
'integer');
369 $ilDB->manipulate(
$query);
381 case 'directory_trees':
382 $type = self::TYPE_DIRECTORY_TREES;
385 case 'course_members':
386 $type = self::TYPE_CMS_COURSE_MEMBERS;
390 $type = self::TYPE_CMS_COURSES;
394 $type = self::TYPE_REMOTE_COURSE;
398 $type = self::TYPE_REMOTE_CATEGORY;
402 $type = self::TYPE_REMOTE_FILE;
406 $type = self::TYPE_REMOTE_GLOSSARY;
410 $type = self::TYPE_REMOTE_GROUP;
413 case 'learningmodules':
414 $type = self::TYPE_REMOTE_LEARNING_MODULE;
418 $type = self::TYPE_REMOTE_WIKI;
422 $type = self::TYPE_REMOTE_TEST;
426 $type = self::TYPE_COURSE_URLS;
429 case 'member_status':
430 $type = self::TYPE_ENROLMENT_STATUS;
439 $query =
"SELECT * FROM ecs_events " .
440 "WHERE type = " . $ilDB->quote(
$type,
'integer') .
" " .
441 "AND id = " . $ilDB->quote($ev->
getRessourceId(),
'integer') .
" " .
442 'AND server_id = ' . $ilDB->quote($this->getServer()->getServerId(),
'integer');
447 $event_id =
$row->event_id;
452 $query =
"INSERT ecs_events (event_id,type,id,op,server_id) " .
454 $ilDB->quote($ilDB->nextId(
'ecs_events'),
'integer') .
',' .
455 $ilDB->quote(
$type,
'text') .
', ' .
457 $ilDB->quote($ev->
getStatus(),
'text') .
', ' .
458 $ilDB->quote($this->getServer()->getServerId(),
'integer') .
' ' .
460 $ilDB->manipulate(
$query);
483 $query =
"UPDATE ecs_events " .
484 "SET op = " . $ilDB->quote($ev->
getStatus(),
'text') .
" " .
485 "WHERE event_id = " . $ilDB->quote($event_id,
'integer') .
' ' .
486 'AND type = ' . $ilDB->quote(
$type) .
' ' .
487 'AND server_id = ' . $ilDB->quote($this->
getServer()->getServerId(),
'integer');
488 $ilDB->manipulate(
$query);
500 $event = array_shift($this->events);
501 if ($event == null) {
505 #$this->delete($event['event_id']); 520 $next_id = $ilDB->nextId(
'ecs_events');
521 $query =
"INSERT INTO ecs_events (event_id,type,id,op,server_id) " .
523 $ilDB->quote($next_id,
'integer') .
", " .
524 $this->db->quote(
$a_type,
'text') .
", " .
525 $this->db->quote($a_id,
'integer') .
", " .
526 $this->db->quote($a_op,
'text') .
", " .
527 $ilDB->quote($this->
getServer()->getServerId(),
'integer') .
' ' .
531 $new_event[
'event_id'] = $next_id;
533 $new_event[
'id'] = $a_id;
534 $new_event[
'op'] = $a_op;
536 $this->events[] = $new_event;
537 $this->econtent_ids[$a_id] = $a_id;
551 $query =
"UPDATE ecs_events " .
552 "SET op = " . $this->db->quote($a_operation,
'text') .
" " .
553 "WHERE type = " . $this->db->quote(
$a_type,
'text') .
" " .
554 "AND id = " . $this->db->quote($a_id,
'integer') .
" " .
555 'AND server_id = ' . $ilDB->quote($this->
getServer()->getServerId(),
'integer');
565 public function delete($a_event_id)
569 $query =
"DELETE FROM ecs_events " .
570 "WHERE event_id = " . $this->db->quote($a_event_id,
'integer') .
" " .
571 'AND server_id = ' . $ilDB->quote($this->
getServer()->getServerId(),
'integer');
573 unset($this->econtent_ids[$a_event_id]);
585 $query =
"SELECT * FROM ecs_events " .
586 'WHERE server_id = ' . $ilDB->quote($this->
getServer()->getServerId(),
'integer') .
' ' .
597 $this->econtent_ids[
$row->event_id] =
$row->event_id;
607 $query =
'DELETE FROM ecs_events' .
608 ' WHERE server_id = ' . $ilDB->quote($a_server_id,
'integer');
609 $ilDB->manipulate(
$query);
const TYPE_REMOTE_CATEGORY
static getAllImportedRemoteObjects($a_server_id)
get all imported links
if(isset($_REQUEST['delete'])) $list
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.
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
foreach($_POST as $key=> $value) $res
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