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

Handles events (create,update,delete) for autmatic generated calendar events from course, groups, ... More...

+ Inheritance diagram for ilCalendarAppEventListener:
+ Collaboration diagram for ilCalendarAppEventListener:

Static Public Member Functions

static handleEvent (string $a_component, string $a_event, array $a_parameter)
 Handle events like create, update, delete @access public. More...
 
static createCategory (ilObject $a_obj, bool $a_check_existing=false)
 Create a category for a new object (crs,grp, ...) More...
 
static updateCategory (ilObject $a_obj)
 Update category for a object (crs,grp, ...) More...
 
static createAppointments (ilObject $a_obj, array $a_appointments)
 Create appointments. More...
 
static deleteAppointments (int $a_obj_id, ?array $a_context_ids=null)
 Delete automatic generated appointments. More...
 
static deleteCategory (int $a_obj_id)
 delete category More...
 
static handleEvent (string $a_component, string $a_event, array $a_parameter)
 Handle an event in a listener. More...
 

Detailed Description

Handles events (create,update,delete) for autmatic generated calendar events from course, groups, ...

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 27 of file class.ilCalendarAppEventListener.php.

Member Function Documentation

◆ createAppointments()

static ilCalendarAppEventListener::createAppointments ( ilObject  $a_obj,
array  $a_appointments 
)
static

Create appointments.

Parameters
ilObject
ilCalendarAppointmentTemplate[]
Returns
void

Definition at line 162 of file class.ilCalendarAppEventListener.php.

162 : void
163 {
164 global $DIC;
165
166 $logger = $DIC->logger()->cal();
167
168 if (!$cat_id = ilCalendarCategories::_lookupCategoryIdByObjId($a_obj->getId())) {
169 $logger->warning('Cannot find calendar category for obj_id ' . $a_obj->getId());
170 $cat_id = self::createCategory($a_obj);
171 }
172
173 foreach ($a_appointments as $app_templ) {
174 $app = new ilCalendarEntry();
175 $app->setContextId($app_templ->getContextId());
176 $app->setContextInfo($app_templ->getContextInfo());
177 $app->setTitle($app_templ->getTitle());
178 $app->setSubtitle($app_templ->getSubtitle());
179 $app->setDescription($app_templ->getDescription());
180 $app->setFurtherInformations($app_templ->getInformation());
181 $app->setLocation($app_templ->getLocation());
182 $app->setStart($app_templ->getStart());
183 $app->setEnd($app_templ->getEnd());
184 $app->setFullday($app_templ->isFullday());
185 $app->setAutoGenerated(true);
186 $app->setTranslationType($app_templ->getTranslationType());
187 $app->save();
188
189 $ass = new ilCalendarCategoryAssignments($app->getEntryId());
190 $ass->addAssignment($cat_id);
191 }
192 }
static createCategory(ilObject $a_obj, bool $a_check_existing=false)
Create a category for a new object (crs,grp, ...)
static _lookupCategoryIdByObjId(int $a_obj_id)
lookup category by obj_id
Model for a calendar entry.
global $DIC
Definition: shib_login.php:26

References $DIC, ilCalendarCategories\_lookupCategoryIdByObjId(), createCategory(), and ilObject\getId().

Referenced by handleEvent().

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

◆ createCategory()

static ilCalendarAppEventListener::createCategory ( ilObject  $a_obj,
bool  $a_check_existing = false 
)
static

Create a category for a new object (crs,grp, ...)

Definition at line 124 of file class.ilCalendarAppEventListener.php.

124 : int
125 {
126 global $DIC;
127
128 $lng = $DIC->language();
129
130 // already existing? do update instead
131 if ($a_check_existing &&
133 return self::updateCategory($a_obj);
134 }
135 $cat = new ilCalendarCategory();
136 $cat->setTitle($a_obj->getTitle() ? $a_obj->getTitle() : $lng->txt('obj_' . $a_obj->getType()));
137 $cat->setType(ilCalendarCategory::TYPE_OBJ);
139 $cat->setObjId($a_obj->getId());
140 return $cat->add();
141 }
static updateCategory(ilObject $a_obj)
Update category for a object (crs,grp, ...)
Stores calendar categories.
static _getInstanceByObjId(int $a_obj_id)
get instance by obj_id
global $lng
Definition: privfeed.php:31

References $DIC, $lng, ilCalendarCategory\_getInstanceByObjId(), ilCalendarAppointmentColors\_getRandomColorByType(), ilObject\getId(), ilObject\getTitle(), ilObject\getType(), ilCalendarCategory\TYPE_OBJ, and updateCategory().

Referenced by createAppointments(), and handleEvent().

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

◆ deleteAppointments()

static ilCalendarAppEventListener::deleteAppointments ( int  $a_obj_id,
?array  $a_context_ids = null 
)
static

Delete automatic generated appointments.

Definition at line 197 of file class.ilCalendarAppEventListener.php.

198 {
200 // delete only selected entries
201 if (is_array($a_context_ids)) {
202 $entry = new ilCalendarEntry($app_id);
203 if (!in_array($entry->getContextId(), $a_context_ids)) {
204 continue;
205 }
206 }
209 }
210 }
static _getAutoGeneratedAppointmentsByObjId(int $a_obj_id)
get automatic generated appointments of category
static _deleteByAppointmentId(int $a_app_id)
Delete appointment assignment.
static _delete(int $a_entry_id)

References ilCalendarEntry\_delete(), ilCalendarCategoryAssignments\_deleteByAppointmentId(), and ilCalendarCategoryAssignments\_getAutoGeneratedAppointmentsByObjId().

Referenced by handleEvent().

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

◆ deleteCategory()

static ilCalendarAppEventListener::deleteCategory ( int  $a_obj_id)
static

delete category

Definition at line 215 of file class.ilCalendarAppEventListener.php.

215 : void
216 {
217 global $DIC;
218
219 $logger = $DIC->logger()->cal();
220
221 if (!$cat_id = ilCalendarCategories::_lookupCategoryIdByObjId($a_obj_id)) {
222 $logger->warning('Cannot find calendar category for obj_id ' . $a_obj_id);
223 return;
224 }
225
226 $category = new ilCalendarCategory($cat_id);
227 $category->delete();
228 }

References $DIC, and ilCalendarCategories\_lookupCategoryIdByObjId().

Referenced by handleEvent().

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

◆ handleEvent()

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

Handle events like create, update, delete @access public.

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 37 of file class.ilCalendarAppEventListener.php.

37 : void
38 {
39 global $DIC;
40
41 $logger = $DIC->logger()->cal();
42 $ilUser = $DIC->user();
43
44 $delete_cache = false;
45 switch ($a_component) {
46 case 'components/ILIAS/Session':
47 case 'components/ILIAS/Group':
48 case 'components/ILIAS/Course':
49 case 'components/ILIAS/EmployeeTalk':
50 switch ($a_event) {
51 case 'create':
52 $logger->debug('Handling create event');
53 self::createCategory($a_parameter['object']);
54 self::createAppointments($a_parameter['object'], $a_parameter['appointments']);
55 $delete_cache = true;
56 break;
57
58 case 'update':
59 $logger->debug('Handling update event');
60 self::updateCategory($a_parameter['object']);
61 self::deleteAppointments($a_parameter['obj_id']);
62 self::createAppointments($a_parameter['object'], $a_parameter['appointments']);
63 $delete_cache = true;
64 break;
65
66 case 'delete':
67 $logger->debug('Handling delete event');
68 self::deleteCategory($a_parameter['obj_id']);
69 $delete_cache = true;
70 break;
71 }
72 break;
73
74 case 'components/ILIAS/Booking':
75 switch ($a_event) {
76 case 'create':
77 case 'delete':
78 case 'update':
79 break;
80 }
81 break;
82
83 case 'components/ILIAS/Exercise':
84 switch ($a_event) {
85 case 'createAssignment':
86 $logger->debug('Handling create event (exercise assignment)');
87 self::createCategory($a_parameter['object'], true); // exercise category could already exist
88 self::createAppointments($a_parameter['object'], $a_parameter['appointments']);
89 $delete_cache = true;
90 break;
91
92 case 'updateAssignment':
93 $logger->debug('Handling update event (exercise assignment)');
94 self::createCategory($a_parameter['object'], true); // different life-cycle than ilObject
95 self::deleteAppointments($a_parameter['obj_id'], $a_parameter['context_ids']);
96 self::createAppointments($a_parameter['object'], $a_parameter['appointments']);
97 $delete_cache = true;
98 break;
99
100 case 'deleteAssignment':
101 $logger->debug('Handling delete event (exercise assignment)');
102 self::deleteAppointments($a_parameter['obj_id'], $a_parameter['context_ids']);
103 $delete_cache = true;
104 break;
105
106 case 'delete':
107 $logger->debug(':Handling delete event');
108 self::deleteCategory($a_parameter['obj_id']);
109 $delete_cache = true;
110 break;
111 }
112 break;
113 }
114
115 if ($delete_cache) {
118 }
119 }
static deleteCategory(int $a_obj_id)
delete category
static createAppointments(ilObject $a_obj, array $a_appointments)
Create appointments.
static deleteAppointments(int $a_obj_id, ?array $a_context_ids=null)
Delete automatic generated appointments.
static deleteRepositoryCache(int $a_usr_id)
Delete cache.
static deletePDItemsCache(int $a_usr_id)
Delete cache (add remove desktop item)

References $DIC, createAppointments(), createCategory(), deleteAppointments(), deleteCategory(), ilCalendarCategories\deletePDItemsCache(), ilCalendarCategories\deleteRepositoryCache(), and updateCategory().

+ Here is the call graph for this function:

◆ updateCategory()

static ilCalendarAppEventListener::updateCategory ( ilObject  $a_obj)
static

Update category for a object (crs,grp, ...)

Definition at line 146 of file class.ilCalendarAppEventListener.php.

146 : int
147 {
148 if ($cat = ilCalendarCategory::_getInstanceByObjId($a_obj->getId())) {
149 $cat->setTitle($a_obj->getTitle());
150 $cat->update();
151 return $cat->getCategoryID();
152 }
153 return 0;
154 }

References ilCalendarCategory\_getInstanceByObjId(), ilObject\getId(), and ilObject\getTitle().

Referenced by createCategory(), and handleEvent().

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

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