ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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.

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

References $tree.

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.

68 {
69 $lso = $this->getInstanceByRefId($parent_lso_ref_id);
70 $lso->getStateDB()->deleteForItem(
71 $parent_lso_ref_id,
72 $obj_ref_id
73 );
74 }

References getInstanceByRefId().

Referenced by handleObjectDeletion(), and handleObjectToTrash().

+ 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.

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

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

Referenced by handleParticipantDeletion().

+ 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.

102 : ilObject
103 {
105 }
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
Class ilObject Basic functions for all objects.

References ilObjectFactory\getInstanceByRefId().

Referenced by deleteLSOItem(), and getInstanceByObjId().

+ 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.

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 }

Referenced by handleObjectDeletion(), and handleObjectToTrash().

+ 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.

97 : array
98 {
99 return ilObject::_getAllReferences($triggerer_obj_id);
100 }

References ilObject\_getAllReferences().

+ 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.

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)

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

+ 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.

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 }

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

+ 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.

77 {
78 $lso = $this->getInstanceByObjId($obj_id);
79 $db = $lso->getStateDB();
80 $db->deleteFor($lso->getRefId(), [$usr_id]);
81 }

References getInstanceByObjId().

+ Here is the call graph for this function:

◆ isExistingObject()

ilLSEventHandler::isExistingObject ( int  $ref_id)
protected

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

59 : bool
60 {
61 if (empty($ref_id) || !$this->tree->isInTree($ref_id)) {
62 return false;
63 }
64 return true;
65 }

Referenced by handleObjectDeletion(), and handleObjectToTrash().

+ 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: