ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilECSEventQueueReader Class Reference

Reads ECS events and stores them in the database. More...

+ Collaboration diagram for ilECSEventQueueReader:

Public Member Functions

 __construct ($a_server_id)
 Constructor. More...
 
 getServer ()
 get server setting More...
 
 getEvents ()
 get all events More...
 
 deleteAll ()
 Delete all events. More...
 
 deleteAllEContentEvents (array $a_types)
 Delete all econtents. More...
 
 refresh ()
 Fetch events from fifo Using fifo public. More...
 
 shift ()
 get and delete the first event entry More...
 
 add ($a_type, $a_id, $a_op)
 add More...
 
 delete ($a_event_id)
 delete private More...
 
 read ()
 Read public. More...
 

Static Public Member Functions

static getAllEContentTypes ()
 All available content types. More...
 
static handleImportReset (ilECSSetting $server)
 Reread all imported econtent. More...
 
static handleExportReset (ilECSSetting $server)
 Handle export reset. More...
 
static deleteServer ($a_server_id)
 Delete by server id ilDB $ilDB. More...
 
static deleteByServerId ($a_server_id)
 

Data Fields

const TYPE_EXPORTED = 'exported'
 
const TYPE_DIRECTORY_TREES = 'directory_trees'
 
const TYPE_CMS_COURSES = 'courses'
 
const TYPE_CMS_COURSE_MEMBERS = 'course_members'
 
const TYPE_REMOTE_COURSE = 'rcrs'
 
const TYPE_REMOTE_CATEGORY = 'rcat'
 
const TYPE_REMOTE_FILE = 'rfil'
 
const TYPE_REMOTE_GLOSSARY = 'rglo'
 
const TYPE_REMOTE_GROUP = 'rgrp'
 
const TYPE_REMOTE_LEARNING_MODULE = 'rlm'
 
const TYPE_REMOTE_WIKI = 'rwik'
 
const TYPE_REMOTE_TEST = 'rtst'
 
const TYPE_COURSE_URLS = 'course_urls'
 
const TYPE_ENROLMENT_STATUS = 'member_status'
 

Protected Member Functions

 deleteAllExportedEvents ()
 Delete all exported events. More...
 

Static Protected Member Functions

static getEventTypeFromObjectType ($a_obj_type)
 Convert object type to event type. More...
 
static getAllResourceIds (ilECSSetting $server, array $a_types, $a_sender_only=false)
 Get all resource ids by resource type. More...
 

Protected Attributes

 $log
 
 $db
 
 $events = array()
 
 $econtent_ids = array()
 

Private Member Functions

 writeEventToDB (ilECSEvent $ev)
 Write event to db. More...
 
 update ($a_type, $a_id, $a_operation)
 update one entry More...
 

Detailed Description

Reads ECS events and stores them in the database.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 36 of file class.ilECSEventQueueReader.php.

Constructor & Destructor Documentation

◆ __construct()

ilECSEventQueueReader::__construct (   $a_server_id)

Constructor.

public

Definition at line 64 of file class.ilECSEventQueueReader.php.

References $DIC, $ilDB, $ilLog, ilECSSetting\getInstanceByServerId(), read(), and settings().

65  {
66  global $DIC;
67 
68  $ilLog = $DIC['ilLog'];
69  $ilDB = $DIC['ilDB'];
70 
71  include_once('Services/WebServices/ECS/classes/class.ilECSSetting.php');
72 
73  $this->settings = ilECSSetting::getInstanceByServerId($a_server_id);
74  $this->log = $ilLog;
75  $this->db = $ilDB;
76 
77  $this->read();
78  }
settings()
Definition: settings.php:2
static getInstanceByServerId($a_server_id)
Get singleton instance per server.
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the call graph for this function:

Member Function Documentation

◆ add()

ilECSEventQueueReader::add (   $a_type,
  $a_id,
  $a_op 
)

add

public

Definition at line 531 of file class.ilECSEventQueueReader.php.

References $a_type, $DIC, $ilDB, $query, $res, and getServer().

532  {
533  global $DIC;
534 
535  $ilDB = $DIC['ilDB'];
536 
537  $next_id = $ilDB->nextId('ecs_events');
538  $query = "INSERT INTO ecs_events (event_id,type,id,op,server_id) " .
539  "VALUES (" .
540  $ilDB->quote($next_id, 'integer') . ", " .
541  $this->db->quote($a_type, 'text') . ", " .
542  $this->db->quote($a_id, 'integer') . ", " .
543  $this->db->quote($a_op, 'text') . ", " .
544  $ilDB->quote($this->getServer()->getServerId(), 'integer') . ' ' .
545  ")";
546  $res = $ilDB->manipulate($query);
547 
548  $new_event['event_id'] = $next_id;
549  $new_event['type'] = $a_type;
550  $new_event['id'] = $a_id;
551  $new_event['op'] = $a_op;
552 
553  $this->events[] = $new_event;
554  $this->econtent_ids[$a_id] = $a_id;
555  return true;
556  }
global $DIC
Definition: saml.php:7
$a_type
Definition: workflow.php:92
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:

◆ delete()

ilECSEventQueueReader::delete (   $a_event_id)

delete private

Parameters
intevent id

Definition at line 584 of file class.ilECSEventQueueReader.php.

References $DIC, $ilDB, $query, $res, and getServer().

585  {
586  global $DIC;
587 
588  $ilDB = $DIC['ilDB'];
589 
590  $query = "DELETE FROM ecs_events " .
591  "WHERE event_id = " . $this->db->quote($a_event_id, 'integer') . " " .
592  'AND server_id = ' . $ilDB->quote($this->getServer()->getServerId(), 'integer');
593  $res = $ilDB->manipulate($query);
594  unset($this->econtent_ids[$a_event_id]);
595  return true;
596  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:

◆ deleteAll()

ilECSEventQueueReader::deleteAll ( )

Delete all events.

public

Definition at line 281 of file class.ilECSEventQueueReader.php.

References $DIC, $ilDB, $query, $res, and getServer().

282  {
283  global $DIC;
284 
285  $ilDB = $DIC['ilDB'];
286 
287  $query = "DELETE FROM ecs_events " .
288  'WHERE server_id = ' . $ilDB->quote($this->getServer()->getServerId(), 'integer');
289  $res = $ilDB->manipulate($query);
290  return true;
291  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:

◆ deleteAllEContentEvents()

ilECSEventQueueReader::deleteAllEContentEvents ( array  $a_types)

Delete all econtents.

public

Parameters
array$a_types

Definition at line 299 of file class.ilECSEventQueueReader.php.

References $DIC, $ilDB, $query, $res, and getServer().

Referenced by handleImportReset().

300  {
301  global $DIC;
302 
303  $ilDB = $DIC['ilDB'];
304 
305  $query = "DELETE FROM ecs_events " .
306  "WHERE " . $this->db->in("type", $a_types, "", "text") . ' ' .
307  'AND server_id = ' . $ilDB->quote($this->getServer()->getServerId(), 'integer');
308  $res = $ilDB->manipulate($query);
309  return true;
310  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteAllExportedEvents()

ilECSEventQueueReader::deleteAllExportedEvents ( )
protected

Delete all exported events.

public

Definition at line 317 of file class.ilECSEventQueueReader.php.

References $DIC, $ilDB, $query, $res, and getServer().

Referenced by handleExportReset().

318  {
319  global $DIC;
320 
321  $ilDB = $DIC['ilDB'];
322 
323  $query = "DELETE FROM ecs_events " .
324  "WHERE type = " . $this->db->quote(self::TYPE_EXPORTED, 'text') . ' ' .
325  'AND server_id = ' . $ilDB->quote($this->getServer()->getServerId(), 'integer');
326  $res = $ilDB->manipulate($query);
327  return true;
328  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteByServerId()

static ilECSEventQueueReader::deleteByServerId (   $a_server_id)
static

Definition at line 626 of file class.ilECSEventQueueReader.php.

References $DIC, $ilDB, and $query.

Referenced by ilECSSetting\delete().

627  {
628  global $DIC;
629 
630  $ilDB = $DIC['ilDB'];
631 
632  $query = 'DELETE FROM ecs_events' .
633  ' WHERE server_id = ' . $ilDB->quote($a_server_id, 'integer');
634  $ilDB->manipulate($query);
635  return true;
636  }
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ Here is the caller graph for this function:

◆ deleteServer()

static ilECSEventQueueReader::deleteServer (   $a_server_id)
static

Delete by server id ilDB $ilDB.

Parameters
int$a_server_id

Definition at line 374 of file class.ilECSEventQueueReader.php.

References $DIC, $ilDB, and $query.

Referenced by ilECSSettingsGUI\doDelete().

375  {
376  global $DIC;
377 
378  $ilDB = $DIC['ilDB'];
379 
380  $query = 'DELETE FROM ecs_events ' .
381  'WHERE server_id = ' . $ilDB->quote($a_server_id, 'integer');
382  $ilDB->manipulate($query);
383  }
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ Here is the caller graph for this function:

◆ getAllEContentTypes()

static ilECSEventQueueReader::getAllEContentTypes ( )
static

All available content types.

Returns
array

Definition at line 97 of file class.ilECSEventQueueReader.php.

98  {
99  return array(self::TYPE_REMOTE_COURSE, self::TYPE_REMOTE_CATEGORY,
100  self::TYPE_REMOTE_FILE, self::TYPE_REMOTE_GLOSSARY, self::TYPE_REMOTE_GROUP,
101  self::TYPE_REMOTE_LEARNING_MODULE, self::TYPE_REMOTE_WIKI, self::TYPE_REMOTE_TEST);
102  }

◆ getAllResourceIds()

static ilECSEventQueueReader::getAllResourceIds ( ilECSSetting  $server,
array  $a_types,
  $a_sender_only = false 
)
staticprotected

Get all resource ids by resource type.

Parameters
ilECSSetting$server
array$a_types
bool$a_sender_only
Returns
array type => ids

Definition at line 112 of file class.ilECSEventQueueReader.php.

References $list, $type, and ilRemoteObjectBase\getInstanceByEventType().

113  {
114  include_once 'Services/WebServices/ECS/classes/class.ilRemoteObjectBase.php';
115  $list = array();
116  foreach ($a_types as $type) {
118  if ($robj) {
119  $list[$type] = $robj->getAllResourceIds($server, $a_sender_only);
120  }
121  }
122 
123  return $list;
124  }
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
$type
static getInstanceByEventType($a_type)
Get instance by ilECSEvent(QueueReader) type.
+ Here is the call graph for this function:

◆ getEvents()

ilECSEventQueueReader::getEvents ( )

get all events

public

Definition at line 271 of file class.ilECSEventQueueReader.php.

272  {
273  return $this->events ? $this->events : array();
274  }

◆ getEventTypeFromObjectType()

static ilECSEventQueueReader::getEventTypeFromObjectType (   $a_obj_type)
staticprotected

Convert object type to event type.

Parameters
string$a_obj_type
Returns
string

Definition at line 86 of file class.ilECSEventQueueReader.php.

87  {
88  // currently they are the same for all resource types
89  return $a_obj_type;
90  }

◆ getServer()

ilECSEventQueueReader::getServer ( )

get server setting

Returns
ilECSSetting

Definition at line 259 of file class.ilECSEventQueueReader.php.

Referenced by add(), delete(), deleteAll(), deleteAllEContentEvents(), deleteAllExportedEvents(), read(), refresh(), update(), and writeEventToDB().

260  {
261  return $this->settings;
262  }
+ Here is the caller graph for this function:

◆ handleExportReset()

static ilECSEventQueueReader::handleExportReset ( ilECSSetting  $server)
static

Handle export reset.

Delete exported econtent and create it again

Returns
bool throws ilException, ilECSConnectorException

Definition at line 220 of file class.ilECSEventQueueReader.php.

References $GLOBALS, $list, ilECSExport\_deleteEContentIds(), ilECSExport\_getAllEContentIds(), deleteAllExportedEvents(), and ilECSSetting\getServerId().

Referenced by ilECSSettingsGUI\readAll().

221  {
222  include_once('./Services/WebServices/ECS/classes/class.ilECSExport.php');
223 
224  // Delete all export events
225  $queue = new ilECSEventQueueReader($server->getServerId());
226  $queue->deleteAllExportedEvents();
227 
228  // Read all local export info
229  $local_econtent_ids = ilECSExport::_getAllEContentIds($server->getServerId());
230 
231  $types = self::getAllEContentTypes();
232  $list = self::getAllResourceIds($server, $types, true);
233 
234 
235  // merge in one array
236  $all_remote_ids = array();
237  foreach ($list as $resource_type => $remote_ids) {
238  $all_remote_ids = array_merge($all_remote_ids, (array) $remote_ids);
239  }
240  $all_remote_ids = array_unique($all_remote_ids);
241 
242  $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': Resources = ' . print_r($all_remote_ids, true));
243  $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': Local = ' . print_r($local_econtent_ids, true));
244  foreach ($local_econtent_ids as $local_econtent_id => $local_obj_id) {
245  if (!in_array($local_econtent_id, $all_remote_ids)) {
246  // Delete this deprecated info
247  $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': Deleting deprecated econtent id ' . $local_econtent_id);
248  ilECSExport::_deleteEContentIds($server->getServerId(), array($local_econtent_id));
249  }
250  }
251  return true;
252  }
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
static _getAllEContentIds($a_server_id)
get all exported econtent ids per server
getServerId()
Get current server id.
static _deleteEContentIds($a_server_id, $a_ids)
Delete econtent ids for server.
deleteAllExportedEvents()
Delete all exported events.
Reads ECS events and stores them in the database.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleImportReset()

static ilECSEventQueueReader::handleImportReset ( ilECSSetting  $server)
static

Reread all imported econtent.

Returns
bool throws ilException, ilECSConnectorException

Definition at line 133 of file class.ilECSEventQueueReader.php.

References $DIC, $GLOBALS, $ilLog, $list, $type, ilObject\_lookupType(), ilECSEvent\CREATED, deleteAllEContentEvents(), ilECSEvent\DESTROYED, ilECSImport\getAllImportedRemoteObjects(), ilECSUtils\getPossibleRemoteTypes(), ilECSSetting\getServerId(), and ilECSEvent\UPDATED.

Referenced by ilECSSettingsGUI\readAll().

134  {
135  global $DIC;
136 
137  $ilLog = $DIC['ilLog'];
138 
139  include_once('Services/WebServices/ECS/classes/class.ilECSConnector.php');
140  include_once('Services/WebServices/ECS/classes/class.ilECSConnectorException.php');
141 
142  try {
143  include_once('./Services/WebServices/ECS/classes/class.ilECSEventQueueReader.php');
144  include_once('./Services/WebServices/ECS/classes/class.ilECSImport.php');
145  include_once('./Services/WebServices/ECS/classes/class.ilECSExport.php');
146 
147  $types = self::getAllEContentTypes();
148 
149  $event_queue = new ilECSEventQueueReader($server->getServerId());
150  $event_queue->deleteAllEContentEvents($types);
151 
152  $list = self::getAllResourceIds($server, $types);
154 
155  $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': Imported = ' . print_r($imported, true));
156  $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': List = ' . print_r($list, true));
157 
158  foreach ($list as $resource_type => $link_ids) {
159  if (!in_array($resource_type, ilECSUtils::getPossibleRemoteTypes())) {
160  $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': Ignoring resource type ' . $resource_type);
161  continue;
162  }
163 
164 
165  foreach ((array) $link_ids as $link_id) {
166  if (!isset($imported[$link_id])) {
167  // Add create event for not imported econtent
168  $event_queue->add(
169  $resource_type,
170  $link_id,
172  );
173  } else {
174  // Add update event for already existing events
175  $event_queue->add(
176  $resource_type,
177  $link_id,
179  );
180  }
181 
182  if (isset($imported[$link_id])) {
183  unset($imported[$link_id]);
184  }
185  }
186  }
187 
188  if (is_array($imported)) {
189  // Delete event for deprecated econtent
190  include_once 'Services/WebServices/ECS/classes/class.ilECSObjectSettings.php';
191  foreach ($imported as $econtent_id => $obj_id) {
192  $type = self::getEventTypeFromObjectType(ilObject::_lookupType($obj_id));
193  if ($type) {
194  $event_queue->add(
195  $type,
196  $econtent_id,
198  );
199  }
200  }
201  }
202  } catch (ilECSConnectorException $e1) {
203  $ilLog->write('Cannot connect to ECS server: ' . $e1->getMessage());
204  throw $e1;
205  } catch (ilException $e2) {
206  $ilLog->write('Update failed: ' . $e2->getMessage());
207  throw $e2;
208  }
209  return true;
210  }
static getAllImportedRemoteObjects($a_server_id)
get all imported links
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
static getPossibleRemoteTypes($a_with_captions=false)
Get all possible remote object types.
$type
getServerId()
Get current server id.
global $DIC
Definition: saml.php:7
deleteAllEContentEvents(array $a_types)
Delete all econtents.
Reads ECS events and stores them in the database.
static _lookupType($a_id, $a_reference=false)
lookup object type
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilECSEventQueueReader::read ( )

Read public.

Definition at line 602 of file class.ilECSEventQueueReader.php.

References $DIC, $ilDB, $query, $res, $row, ilDBConstants\FETCHMODE_OBJECT, and getServer().

Referenced by __construct().

603  {
604  global $DIC;
605 
606  $ilDB = $DIC['ilDB'];
607 
608  $query = "SELECT * FROM ecs_events " .
609  'WHERE server_id = ' . $ilDB->quote($this->getServer()->getServerId(), 'integer') . ' ' .
610  'ORDER BY event_id';
611 
612  $res = $this->db->query($query);
613  $counter = 0;
614  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
615  $this->events[$counter]['event_id'] = $row->event_id;
616  $this->events[$counter]['type'] = $row->type;
617  $this->events[$counter]['id'] = $row->id;
618  $this->events[$counter]['op'] = $row->op;
619 
620  $this->econtent_ids[$row->event_id] = $row->event_id;
621  ++$counter;
622  }
623  return true;
624  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ refresh()

ilECSEventQueueReader::refresh ( )

Fetch events from fifo Using fifo public.

Exceptions
ilECSConnectorException

Definition at line 336 of file class.ilECSEventQueueReader.php.

References $GLOBALS, $res, $result, getServer(), and writeEventToDB().

337  {
338  try {
339  include_once('Services/WebServices/ECS/classes/class.ilECSConnector.php');
340  include_once('Services/WebServices/ECS/classes/class.ilECSConnectorException.php');
341 
342  $connector = new ilECSConnector($this->getServer());
343  while (true) {
344  $res = $connector->readEventFifo(false);
345 
346  if (!count($res->getResult())) {
347  return true;
348  }
349 
350  foreach ($res->getResult() as $result) {
351  include_once './Services/WebServices/ECS/classes/class.ilECSEvent.php';
352  $event = new ilECSEvent($result);
353 
354  $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ' ---------------------------- Handling new event ');
355  $GLOBALS['DIC']['ilLog']->write(__METHOD__ . print_r($event, true));
356  $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ' ---------------------------- Done! ');
357 
358  // Fill command queue
359  $this->writeEventToDB($event);
360  }
361  // Delete from fifo
362  $connector->readEventFifo(true);
363  }
364  } catch (ilECSConnectorException $e) {
365  $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': Cannot read event fifo. Aborting');
366  }
367  }
$result
foreach($_POST as $key=> $value) $res
writeEventToDB(ilECSEvent $ev)
Write event to db.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ Here is the call graph for this function:

◆ shift()

ilECSEventQueueReader::shift ( )

get and delete the first event entry

public

Returns
array event data or an empty array if the queue is empty

Definition at line 513 of file class.ilECSEventQueueReader.php.

514  {
515  $event = array_shift($this->events);
516  if ($event == null) {
517  return array();
518  } else {
519 
520  #$this->delete($event['event_id']);
521  return $event;
522  }
523  }

◆ update()

ilECSEventQueueReader::update (   $a_type,
  $a_id,
  $a_operation 
)
private

update one entry

private

Definition at line 564 of file class.ilECSEventQueueReader.php.

References $a_type, $DIC, $ilDB, $query, $res, and getServer().

565  {
566  global $DIC;
567 
568  $ilDB = $DIC['ilDB'];
569 
570  $query = "UPDATE ecs_events " .
571  "SET op = " . $this->db->quote($a_operation, 'text') . " " .
572  "WHERE type = " . $this->db->quote($a_type, 'text') . " " .
573  "AND id = " . $this->db->quote($a_id, 'integer') . " " .
574  'AND server_id = ' . $ilDB->quote($this->getServer()->getServerId(), 'integer');
575  $res = $ilDB->manipulate($query);
576  }
global $DIC
Definition: saml.php:7
$a_type
Definition: workflow.php:92
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:

◆ writeEventToDB()

ilECSEventQueueReader::writeEventToDB ( ilECSEvent  $ev)
private

Write event to db.

Definition at line 388 of file class.ilECSEventQueueReader.php.

References $DIC, $ilDB, $query, $res, $row, $type, ilECSEvent\CREATED, ilECSEvent\DESTROYED, ilDBConstants\FETCHMODE_OBJECT, ilECSEvent\getRessourceId(), ilECSEvent\getRessourceType(), getServer(), ilECSEvent\getStatus(), and ilECSEvent\UPDATED.

Referenced by refresh().

389  {
390  global $DIC;
391 
392  $ilDB = $DIC['ilDB'];
393 
394  // this should probably be moved elsewhere
395  switch ($ev->getRessourceType()) {
396  case 'directory_trees':
397  $type = self::TYPE_DIRECTORY_TREES;
398  break;
399 
400  case 'course_members':
401  $type = self::TYPE_CMS_COURSE_MEMBERS;
402  break;
403 
404  case 'courses':
405  $type = self::TYPE_CMS_COURSES;
406  break;
407 
408  case 'courselinks':
409  $type = self::TYPE_REMOTE_COURSE;
410  break;
411 
412  case 'categories':
413  $type = self::TYPE_REMOTE_CATEGORY;
414  break;
415 
416  case 'files':
417  $type = self::TYPE_REMOTE_FILE;
418  break;
419 
420  case 'glossaries':
421  $type = self::TYPE_REMOTE_GLOSSARY;
422  break;
423 
424  case 'groups':
425  $type = self::TYPE_REMOTE_GROUP;
426  break;
427 
428  case 'learningmodules':
429  $type = self::TYPE_REMOTE_LEARNING_MODULE;
430  break;
431 
432  case 'wikis':
433  $type = self::TYPE_REMOTE_WIKI;
434  break;
435 
436  case 'tests':
437  $type = self::TYPE_REMOTE_TEST;
438  break;
439 
440  case 'course_urls':
441  $type = self::TYPE_COURSE_URLS;
442  break;
443 
444  case 'member_status':
445  $type = self::TYPE_ENROLMENT_STATUS;
446  break;
447 
448  default:
449  // write custom event type
450  $type = $ev->getRessourceType();
451  break;
452  }
453 
454  $query = "SELECT * FROM ecs_events " .
455  "WHERE type = " . $ilDB->quote($type, 'integer') . " " .
456  "AND id = " . $ilDB->quote($ev->getRessourceId(), 'integer') . " " .
457  'AND server_id = ' . $ilDB->quote($this->getServer()->getServerId(), 'integer');
458  $res = $ilDB->query($query);
459 
460  $event_id = 0;
461  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
462  $event_id = $row->event_id;
463  }
464 
465  if (!$event_id) {
466  // No previous entry exists => perform insert
467  $query = "INSERT ecs_events (event_id,type,id,op,server_id) " .
468  "VALUES( " .
469  $ilDB->quote($ilDB->nextId('ecs_events'), 'integer') . ',' .
470  $ilDB->quote($type, 'text') . ', ' .
471  $ilDB->quote($ev->getRessourceId(), 'integer') . ', ' .
472  $ilDB->quote($ev->getStatus(), 'text') . ', ' .
473  $ilDB->quote($this->getServer()->getServerId(), 'integer') . ' ' .
474  ')';
475  $ilDB->manipulate($query);
476  return true;
477  }
478  // Do update
479  $do_update = false;
480  switch ($ev->getStatus()) {
481  case ilECSEvent::CREATED:
482  // Do update, although impossible
483  $do_update = true;
484  break;
485 
487  $do_update = true;
488  break;
489 
490  case ilECSEvent::UPDATED:
491  // Do nothing. Old status is ok.
492  break;
493  }
494 
495  if (!$do_update) {
496  return true;
497  }
498  $query = "UPDATE ecs_events " .
499  "SET op = " . $ilDB->quote($ev->getStatus(), 'text') . " " .
500  "WHERE event_id = " . $ilDB->quote($event_id, 'integer') . ' ' .
501  'AND type = ' . $ilDB->quote($type) . ' ' .
502  'AND server_id = ' . $ilDB->quote($this->getServer()->getServerId(), 'integer');
503  $ilDB->manipulate($query);
504  return true;
505  }
getStatus()
get title
$type
global $DIC
Definition: saml.php:7
getRessourceType()
Get ressource type.
getRessourceId()
Get ressource id.
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilECSEventQueueReader::$db
protected

Definition at line 54 of file class.ilECSEventQueueReader.php.

◆ $econtent_ids

ilECSEventQueueReader::$econtent_ids = array()
protected

Definition at line 57 of file class.ilECSEventQueueReader.php.

◆ $events

ilECSEventQueueReader::$events = array()
protected

Definition at line 56 of file class.ilECSEventQueueReader.php.

◆ $log

ilECSEventQueueReader::$log
protected

Definition at line 53 of file class.ilECSEventQueueReader.php.

◆ TYPE_CMS_COURSE_MEMBERS

const ilECSEventQueueReader::TYPE_CMS_COURSE_MEMBERS = 'course_members'

Definition at line 41 of file class.ilECSEventQueueReader.php.

Referenced by ilECSTaskScheduler\handleEvents().

◆ TYPE_CMS_COURSES

const ilECSEventQueueReader::TYPE_CMS_COURSES = 'courses'

Definition at line 40 of file class.ilECSEventQueueReader.php.

Referenced by ilECSTaskScheduler\handleEvents().

◆ TYPE_COURSE_URLS

const ilECSEventQueueReader::TYPE_COURSE_URLS = 'course_urls'

Definition at line 50 of file class.ilECSEventQueueReader.php.

Referenced by ilECSTaskScheduler\handleEvents().

◆ TYPE_DIRECTORY_TREES

const ilECSEventQueueReader::TYPE_DIRECTORY_TREES = 'directory_trees'

◆ TYPE_ENROLMENT_STATUS

const ilECSEventQueueReader::TYPE_ENROLMENT_STATUS = 'member_status'

Definition at line 51 of file class.ilECSEventQueueReader.php.

Referenced by ilECSTaskScheduler\handleEvents().

◆ TYPE_EXPORTED

const ilECSEventQueueReader::TYPE_EXPORTED = 'exported'

Definition at line 38 of file class.ilECSEventQueueReader.php.

◆ TYPE_REMOTE_CATEGORY

const ilECSEventQueueReader::TYPE_REMOTE_CATEGORY = 'rcat'

◆ TYPE_REMOTE_COURSE

const ilECSEventQueueReader::TYPE_REMOTE_COURSE = 'rcrs'

◆ TYPE_REMOTE_FILE

const ilECSEventQueueReader::TYPE_REMOTE_FILE = 'rfil'

◆ TYPE_REMOTE_GLOSSARY

const ilECSEventQueueReader::TYPE_REMOTE_GLOSSARY = 'rglo'

◆ TYPE_REMOTE_GROUP

const ilECSEventQueueReader::TYPE_REMOTE_GROUP = 'rgrp'

◆ TYPE_REMOTE_LEARNING_MODULE

const ilECSEventQueueReader::TYPE_REMOTE_LEARNING_MODULE = 'rlm'

◆ TYPE_REMOTE_TEST

const ilECSEventQueueReader::TYPE_REMOTE_TEST = 'rtst'

◆ TYPE_REMOTE_WIKI

const ilECSEventQueueReader::TYPE_REMOTE_WIKI = 'rwik'

The documentation for this class was generated from the following file: