ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilCourseReferenceAppEventListener Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilCourseReferenceAppEventListener:
+ Collaboration diagram for ilCourseReferenceAppEventListener:

Static Public Member Functions

static handleEvent (string $a_component, string $a_event, array $a_parameter)
 Handle an event in a listener. More...
 
static handleEvent (string $a_component, string $a_event, array $a_parameter)
 Handle an event in a listener. More...
 

Protected Member Functions

 handleUserAssignments ($a_event, $a_parameter)
 
 handleReferences ($a_course_obj_id, $a_usr_id, $a_role_id)
 

Private Member Functions

 __construct ()
 ilCourseReferenceAppEventHandler constructor. More...
 

Private Attributes

 $logger = null
 
 $tree = null
 

Static Private Attributes

static $instance = null
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilCourseReferencePathInfo

Definition at line 22 of file class.ilCourseReferenceAppEventListener.php.

Constructor & Destructor Documentation

◆ __construct()

ilCourseReferenceAppEventListener::__construct ( )
private

ilCourseReferenceAppEventHandler constructor.

Definition at line 37 of file class.ilCourseReferenceAppEventListener.php.

38 {
39 global $DIC;
40
41 $this->logger = $DIC->logger()->crsr();
42 $this->tree = $DIC->repositoryTree();
43 }
global $DIC
Definition: shib_login.php:26

References $DIC, and ILIAS\Repository\logger().

+ Here is the call graph for this function:

Member Function Documentation

◆ handleEvent()

static ilCourseReferenceAppEventListener::handleEvent ( string  $a_component,
string  $a_event,
array  $a_parameter 
)
static

Handle an event in a listener.

Parameters
string$a_componentcomponent, e.g. "components/ILIAS/Forum" or "components/ILIAS/User"
string$a_eventevent e.g. "createUser", "updateUser", "deleteUser", ...
array$a_parameterparameter array (assoc), array("name" => ..., "phone_office" => ...)

Implements ilAppEventListener.

Definition at line 120 of file class.ilCourseReferenceAppEventListener.php.

120 : void
121 {
122 ilLoggerFactory::getLogger('crs')->warning($a_component);
123 switch ($a_component) {
124 case 'components/ILIAS/AccessControl':
125 $self = new self();
126 $self->handleUserAssignments($a_event, $a_parameter);
127 break;
128 }
129 }
static getLogger(string $a_component_id)
Get component logger.

References ilLoggerFactory\getLogger().

+ Here is the call graph for this function:

◆ handleReferences()

ilCourseReferenceAppEventListener::handleReferences (   $a_course_obj_id,
  $a_usr_id,
  $a_role_id 
)
protected
Parameters
$a_course_obj_id
$a_usr_id
$a_role_id

Definition at line 72 of file class.ilCourseReferenceAppEventListener.php.

73 {
74 $role_title = ilObject::_lookupTitle($a_role_id);
75 if (substr($role_title, 0, 10) !== 'il_crs_mem') {
76 $this->logger->debug('Ignoring non member role: ' . $role_title);
77 return;
78 }
79
80
81 // find all crs references for course
82 $course_ref_ids = ilObject::_getAllReferences($a_course_obj_id);
83 $course_ref_id = end($course_ref_ids);
84
85 $childs = $this->tree->getChildsByType($course_ref_id, 'crsr');
86 $this->logger->dump($childs, ilLogLevel::DEBUG);
87
88 foreach ($childs as $tree_node) {
89 $this->logger->debug('Handling course reference: ' . $tree_node['title']);
90 $path_info = ilCourseReferencePathInfo::getInstanceByRefId($tree_node['child']);
91
92 // this also checks for structure crs -> grp -> crsr, which return false
93 if (!$path_info->hasParentCourse()) {
94 $this->logger->debug('No reference member update: no direct parent course');
95 continue;
96 }
97
98 if (!$path_info->isMemberUpdateEnabled()) {
99 $this->logger->debug('No reference member update: update disabled.');
100 continue;
101 }
102
103 $this->logger->debug('Reference member update: adding user to course.');
104 $target_course_ref_id = $path_info->getTargetId();
105 $part = ilCourseParticipants::getInstance($target_course_ref_id);
106 $part->add($a_usr_id, ilParticipants::IL_CRS_MEMBER);
107 }
108 }
static getInstanceByRefId(int $ref_id, int $target_ref_id=0)
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupTitle(int $obj_id)
static getInstance(int $a_ref_id)

References ilObject\_getAllReferences(), ilObject\_lookupTitle(), ilLogLevel\DEBUG, ilParticipants\getInstance(), ilCourseReferencePathInfo\getInstanceByRefId(), ilParticipants\IL_CRS_MEMBER, and ILIAS\Repository\logger().

Referenced by handleUserAssignments().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleUserAssignments()

ilCourseReferenceAppEventListener::handleUserAssignments (   $a_event,
  $a_parameter 
)
protected
Parameters
$a_event
$a_parameter

Definition at line 49 of file class.ilCourseReferenceAppEventListener.php.

50 {
51 if ($a_parameter['type'] != 'crs') {
52 $this->logger->debug('Ignoring event for type ' . $a_parameter['type']);
53 return true;
54 }
55
56 $this->logger->info('Current event is: ' . $a_event);
57 if ($a_event == 'assignUser') {
58 $this->logger->debug('Handling assign user event for type crs.');
59 $this->handleReferences($a_parameter['obj_id'], $a_parameter['usr_id'], $a_parameter['role_id']);
60 } else {
61 $this->logger->debug('Ignoring event: ' . $a_event);
62 }
63 }
handleReferences($a_course_obj_id, $a_usr_id, $a_role_id)

References handleReferences(), and ILIAS\Repository\logger().

+ Here is the call graph for this function:

Field Documentation

◆ $instance

ilCourseReferenceAppEventListener::$instance = null
staticprivate

Definition at line 24 of file class.ilCourseReferenceAppEventListener.php.

◆ $logger

ilCourseReferenceAppEventListener::$logger = null
private

Definition at line 29 of file class.ilCourseReferenceAppEventListener.php.

◆ $tree

ilCourseReferenceAppEventListener::$tree = null
private

Definition at line 32 of file class.ilCourseReferenceAppEventListener.php.


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