ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCourseReferenceAppEventListener Class Reference

Class ilCourseReferencePathInfo. More...

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

Static Public Member Functions

static handleEvent ($a_component, $a_event, $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

Constructor & Destructor Documentation

◆ __construct()

ilCourseReferenceAppEventListener::__construct ( )
private

ilCourseReferenceAppEventHandler constructor.

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

References $DIC.

24  {
25  global $DIC;
26 
27  $this->logger = $DIC->logger()->crsr();
28  $this->tree = $DIC->repositoryTree();
29  }
$DIC
Definition: xapitoken.php:46

Member Function Documentation

◆ handleEvent()

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

Handle an event in a listener.

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

Implements ilAppEventListener.

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

References ilLoggerFactory\getLogger().

108  {
109  ilLoggerFactory::getLogger('crs')->warning($a_component);
110  switch ($a_component) {
111 
112  case 'Services/AccessControl':
113  $self = new self();
114  $self->handleUserAssignments($a_event, $a_parameter);
115  break;
116  }
117  }
static getLogger($a_component_id)
Get component logger.
+ 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 58 of file class.ilCourseReferenceAppEventListener.php.

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

Referenced by handleUserAssignments().

59  {
60  $role_title = ilObject::_lookupTitle($a_role_id);
61  if (substr($role_title, 0, 10) !== 'il_crs_mem') {
62  $this->logger->debug('Ignoring non member role: ' . $role_title);
63  return;
64  }
65 
66 
67  // find all crs references for course
68  $course_ref_ids = ilObject::_getAllReferences($a_course_obj_id);
69  $course_ref_id = end($course_ref_ids);
70 
71  $childs = $this->tree->getChildsByType($course_ref_id, 'crsr');
72  $this->logger->dump($childs, ilLogLevel::DEBUG);
73 
74  foreach ($childs as $tree_node) {
75  $this->logger->debug('Handling course reference: ' . $tree_node['title']);
76  $path_info = ilCourseReferencePathInfo::getInstanceByRefId($tree_node['child']);
77 
78  // this also checks for structure crs -> grp -> crsr, which return false
79  if (!$path_info->hasParentCourse()) {
80  $this->logger->debug('No reference member update: no direct parent course');
81  continue;
82  }
83 
84  if (!$path_info->isMemberUpdateEnabled()) {
85  $this->logger->debug('No reference member update: update disabled.');
86  continue;
87  }
88 
89  $this->logger->debug('Reference member update: adding user to course.');
90  $target_course_ref_id = $path_info->getTargetId();
91  $part = ilCourseParticipants::getInstance($target_course_ref_id);
92  $part->add($a_usr_id, IL_CRS_MEMBER);
93  }
94  }
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
const IL_CRS_MEMBER
static getInstance($a_ref_id)
Get instance by ref_id.
static getInstanceByRefId(int $ref_id, int $target_ref_id=0)
+ 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 35 of file class.ilCourseReferenceAppEventListener.php.

References handleReferences().

36  {
37  if ($a_parameter['type'] != 'crs') {
38  $this->logger->debug('Ignoring event for type ' . $a_parameter['type']);
39  return true;
40  }
41 
42  $this->logger->info('Current event is: ' . $a_event);
43  if ($a_event == 'assignUser') {
44  $this->logger->debug('Handling assign user event for type crs.');
45  $this->handleReferences($a_parameter['obj_id'], $a_parameter['usr_id'], $a_parameter['role_id']);
46  } else {
47  $this->logger->debug('Ignoring event: ' . $a_event);
48  }
49  }
handleReferences($a_course_obj_id, $a_usr_id, $a_role_id)
+ Here is the call graph for this function:

Field Documentation

◆ $instance

ilCourseReferenceAppEventListener::$instance = null
staticprivate

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

◆ $logger

ilCourseReferenceAppEventListener::$logger = null
private

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

◆ $tree

ilCourseReferenceAppEventListener::$tree = null
private

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


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