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

Handle events. More...

+ Collaboration diagram for ilLSEventHandler:

Public Member Functions

 __construct (ilTree $tree)
 
 handleObjectDeletion (array $parameter)
 Find out, if a subobject is about to be deleted. More...
 
 handleObjectToTrash (array $parameter)
 
 handleParticipantDeletion (int $obj_id, int $usr_id)
 

Protected Member Functions

 isExistingObject (int $ref_id)
 
 deleteLSOItem (int $obj_ref_id, int $parent_lso_ref_id)
 
 getParentLSOInfo (int $child_ref_id)
 get the LSO up from $child_ref_if More...
 
 getRefIdsOfObjId (int $triggerer_obj_id)
 
 getInstanceByRefId (int $ref_id)
 
 getInstanceByObjId (int $obj_id)
 

Protected Attributes

 $tree
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilLSEventHandler::__construct ( ilTree  $tree)

Definition at line 17 of file class.ilLSEventHandler.php.

References $tree.

18  {
19  $this->tree = $tree;
20  }

Member Function Documentation

◆ deleteLSOItem()

ilLSEventHandler::deleteLSOItem ( int  $obj_ref_id,
int  $parent_lso_ref_id 
)
protected

Definition at line 67 of file class.ilLSEventHandler.php.

References getInstanceByRefId().

Referenced by handleObjectDeletion(), and handleObjectToTrash().

68  {
69  $lso = $this->getInstanceByRefId($parent_lso_ref_id);
70  $lso->getStateDB()->deleteForItem(
71  $parent_lso_ref_id,
72  $obj_ref_id
73  );
74  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstanceByObjId()

ilLSEventHandler::getInstanceByObjId ( int  $obj_id)
protected

Definition at line 107 of file class.ilLSEventHandler.php.

References ilObject\_getAllReferences(), and getInstanceByRefId().

Referenced by handleParticipantDeletion().

108  {
109  $refs = \ilObject::_getAllReferences($obj_id);
110  $ref_id = array_shift(array_keys($refs));
111  return $this->getInstanceByRefId($ref_id);
112  }
Class ilObjLearningSequence.
static _getAllReferences($a_id)
get all reference ids of object
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstanceByRefId()

ilLSEventHandler::getInstanceByRefId ( int  $ref_id)
protected

Definition at line 102 of file class.ilLSEventHandler.php.

References ilObjectFactory\getInstanceByRefId().

Referenced by deleteLSOItem(), and getInstanceByObjId().

102  : ilObject
103  {
104  return ilObjectFactory::getInstanceByRefId($ref_id);
105  }
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getParentLSOInfo()

ilLSEventHandler::getParentLSOInfo ( int  $child_ref_id)
protected

get the LSO up from $child_ref_if

Returns
int | false;

Definition at line 87 of file class.ilLSEventHandler.php.

Referenced by handleObjectDeletion(), and handleObjectToTrash().

88  {
89  foreach ($this->tree->getPathFull($child_ref_id) as $hop) {
90  if ($hop['type'] === 'lso') {
91  return $hop;
92  }
93  }
94  return false;
95  }
+ Here is the caller graph for this function:

◆ getRefIdsOfObjId()

ilLSEventHandler::getRefIdsOfObjId ( int  $triggerer_obj_id)
protected

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

References ilObject\_getAllReferences().

97  : array
98  {
99  return ilObject::_getAllReferences($triggerer_obj_id);
100  }
static _getAllReferences($a_id)
get all reference ids of object
+ Here is the call graph for this function:

◆ handleObjectDeletion()

ilLSEventHandler::handleObjectDeletion ( array  $parameter)

Find out, if a subobject is about to be deleted.

cleanup states.

Definition at line 26 of file class.ilLSEventHandler.php.

References deleteLSOItem(), getParentLSOInfo(), and isExistingObject().

27  {
28  $obj_deleted = $parameter['object'];
29  $obj_ref_id = (int) $obj_deleted->getRefId();
30 
31  if (!$this->isExistingObject($obj_ref_id)) {
32  return;
33  }
34 
35  $parent_lso = $this->getParentLSOInfo($obj_ref_id);
36  if ($parent_lso) {
37  $this->deleteLSOItem($obj_ref_id, (int) $parent_lso['ref_id']);
38  }
39  }
getParentLSOInfo(int $child_ref_id)
get the LSO up from $child_ref_if
deleteLSOItem(int $obj_ref_id, int $parent_lso_ref_id)
+ Here is the call graph for this function:

◆ handleObjectToTrash()

ilLSEventHandler::handleObjectToTrash ( array  $parameter)
Parameters
array$parameter[obj_id, ref_id, old_parent_ref_id]

Definition at line 44 of file class.ilLSEventHandler.php.

References deleteLSOItem(), getParentLSOInfo(), and isExistingObject().

45  {
46  $obj_ref_id = (int) $parameter['ref_id'];
47  $old_parent_ref_id = (int) $parameter['old_parent_ref_id'];
48  $parent_lso = $this->getParentLSOInfo($obj_ref_id);
49 
50  if (!$this->isExistingObject($obj_ref_id) || !$parent_lso) {
51  return;
52  }
53 
54  if ($old_parent_ref_id) {
55  $this->deleteLSOItem($obj_ref_id, $old_parent_ref_id);
56  }
57  }
getParentLSOInfo(int $child_ref_id)
get the LSO up from $child_ref_if
deleteLSOItem(int $obj_ref_id, int $parent_lso_ref_id)
+ Here is the call graph for this function:

◆ handleParticipantDeletion()

ilLSEventHandler::handleParticipantDeletion ( int  $obj_id,
int  $usr_id 
)

Definition at line 76 of file class.ilLSEventHandler.php.

References getInstanceByObjId().

77  {
78  $lso = $this->getInstanceByObjId($obj_id);
79  $db = $lso->getStateDB();
80  $db->deleteFor($lso->getRefId(), [$usr_id]);
81  }
+ Here is the call graph for this function:

◆ isExistingObject()

ilLSEventHandler::isExistingObject ( int  $ref_id)
protected

Definition at line 59 of file class.ilLSEventHandler.php.

Referenced by handleObjectDeletion(), and handleObjectToTrash().

59  : bool
60  {
61  if (empty($ref_id) || !$this->tree->isInTree($ref_id)) {
62  return false;
63  }
64  return true;
65  }
+ Here is the caller graph for this function:

Field Documentation

◆ $tree

ilLSEventHandler::$tree
protected

Definition at line 15 of file class.ilLSEventHandler.php.

Referenced by __construct().


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