ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 ($a_component, $a_event, $a_parameter)
 Handle events like create, update, delete. More...
 
static createCategory ($a_obj, $a_check_existing=false)
 Create a category for a new object (crs,grp, ...) More...
 
static updateCategory ($a_obj)
 Create a category for a new object (crs,grp, ...) More...
 
static createAppointments ($a_obj, $a_appointments)
 Create appointments. More...
 
static deleteAppointments ($a_obj_id, array $a_context_ids=null)
 Delete automatic generated appointments. More...
 
static deleteCategory ($a_obj_id)
 delete category More...
 
static handleEvent ($a_component, $a_event, $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
Version
$Id$

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

Member Function Documentation

◆ createAppointments()

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

Create appointments.

@access public

Parameters

return

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

186 {
187 global $ilLog;
188
189 include_once('./Services/Calendar/classes/class.ilCalendarEntry.php');
190 include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
191 include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
192
193 if (!$cat_id = ilCalendarCategories::_lookupCategoryIdByObjId($a_obj->getId())) {
194 $ilLog->write(__METHOD__ . ': Cannot find calendar category for obj_id ' . $a_obj->getId());
195 $cat_id = self::createCategory($a_obj);
196 }
197
198 foreach ($a_appointments as $app_templ) {
199 $app = new ilCalendarEntry();
200 $app->setContextId($app_templ->getContextId());
201 $app->setTitle($app_templ->getTitle());
202 $app->setSubtitle($app_templ->getSubtitle());
203 $app->setDescription($app_templ->getDescription());
204 $app->setFurtherInformations($app_templ->getInformation());
205 $app->setLocation($app_templ->getLocation());
206 $app->setStart($app_templ->getStart());
207 $app->setEnd($app_templ->getEnd());
208 $app->setFullday($app_templ->isFullday());
209 $app->setAutoGenerated(true);
210 $app->setTranslationType($app_templ->getTranslationType());
211 $app->save();
212
213 $ass = new ilCalendarCategoryAssignments($app->getEntryId());
214 $ass->addAssignment($cat_id);
215 }
216 }
static createCategory($a_obj, $a_check_existing=false)
Create a category for a new object (crs,grp, ...)
static _lookupCategoryIdByObjId($a_obj_id)
lookup category by obj_id
Model for a calendar entry.

References $ilLog, ilCalendarCategories\_lookupCategoryIdByObjId(), and createCategory().

Referenced by handleEvent().

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

◆ createCategory()

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

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

@access public

Parameters
objectilias object ('crs','grp',...)

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

138 {
139 global $lng;
140
141 include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
142 include_once('./Services/Calendar/classes/class.ilCalendarAppointmentColors.php');
143
144 // already existing? do update instead
145 if ($a_check_existing &&
147 return self::updateCategory($a_obj);
148 }
149
150 $cat = new ilCalendarCategory();
151 $cat->setTitle($a_obj->getTitle() ? $a_obj->getTitle() : $lng->txt('obj_' . $a_obj->getType()));
152 $cat->setType(ilCalendarCategory::TYPE_OBJ);
153 $cat->setColor(ilCalendarAppointmentColors::_getRandomColorByType($a_obj->getType()));
154 $cat->setObjId($a_obj->getId());
155 return $cat->add();
156 }
static updateCategory($a_obj)
Create a category for a new object (crs,grp, ...)
static _getRandomColorByType($a_type)
get random color entry for type
Stores calendar categories.
static _getInstanceByObjId($a_obj_id)
get instance by obj_id
global $lng
Definition: privfeed.php:17

References $lng, ilCalendarCategory\_getInstanceByObjId(), ilCalendarAppointmentColors\_getRandomColorByType(), 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 (   $a_obj_id,
array  $a_context_ids = null 
)
static

Delete automatic generated appointments.

@access public

Parameters
intobj_id
arraycontext ids

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

227 {
228 include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
229 include_once('./Services/Calendar/classes/class.ilCalendarEntry.php');
230
232 // delete only selected entries
233 if (is_array($a_context_ids)) {
234 $entry = new ilCalendarEntry($app_id);
235 if (!in_array($entry->getContextId(), $a_context_ids)) {
236 continue;
237 }
238 }
239
242 }
243 }
static _deleteByAppointmentId($a_app_id)
Delete appointment assignment.
static _getAutoGeneratedAppointmentsByObjId($a_obj_id)
get automatic generated appointments of category
static _delete($a_entry_id)
delete entry

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 (   $a_obj_id)
static

delete category

@access public

Parameters

return

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

254 {
255 global $ilLog;
256
257 include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
258
259 if (!$cat_id = ilCalendarCategories::_lookupCategoryIdByObjId($a_obj_id)) {
260 $ilLog->write(__METHOD__ . ': Cannot find calendar category for obj_id ' . $a_obj_id);
261 return false;
262 }
263
264 $category = new ilCalendarCategory($cat_id);
265 $category->delete();
266 }

References $ilLog, 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 (   $a_component,
  $a_event,
  $a_parameter 
)
static

Handle events like create, update, delete.

@access public

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

47 {
48 global $ilLog,$ilUser;
49
50 $delete_cache = false;
51
52 switch ($a_component) {
53 case 'Modules/Session':
54 case 'Modules/Group':
55 case 'Modules/Course':
56 switch ($a_event) {
57 case 'create':
58 $ilLog->write(__METHOD__ . ': Handling create event');
59 self::createCategory($a_parameter['object']);
60 self::createAppointments($a_parameter['object'], $a_parameter['appointments']);
61 $delete_cache = true;
62 break;
63
64 case 'update':
65 $ilLog->write(__METHOD__ . ': Handling update event');
66 self::updateCategory($a_parameter['object']);
67 self::deleteAppointments($a_parameter['obj_id']);
68 self::createAppointments($a_parameter['object'], $a_parameter['appointments']);
69 $delete_cache = true;
70 break;
71
72 case 'delete':
73 $ilLog->write(__METHOD__ . ': Handling delete event');
74 self::deleteCategory($a_parameter['obj_id']);
75 $delete_cache = true;
76 break;
77 }
78 break;
79
80 case 'Services/Booking':
81 switch ($a_event) {
82 case 'create':
83 break;
84 case 'update':
85 break;
86 case 'delete':
87 break;
88 }
89 break;
90
91 case 'Modules/Exercise':
92 switch ($a_event) {
93 case 'createAssignment':
94 $ilLog->write(__METHOD__ . ': Handling create event (exercise assignment)');
95 self::createCategory($a_parameter['object'], true); // exercise category could already exist
96 self::createAppointments($a_parameter['object'], $a_parameter['appointments']);
97 $delete_cache = true;
98 break;
99
100 case 'updateAssignment':
101 $ilLog->write(__METHOD__ . ': Handling update event (exercise assignment)');
102 self::createCategory($a_parameter['object'], true); // different life-cycle than ilObject
103 self::deleteAppointments($a_parameter['obj_id'], $a_parameter['context_ids']);
104 self::createAppointments($a_parameter['object'], $a_parameter['appointments']);
105 $delete_cache = true;
106 break;
107
108 case 'deleteAssignment':
109 $ilLog->write(__METHOD__ . ': Handling delete event (exercise assignment)');
110 self::deleteAppointments($a_parameter['obj_id'], $a_parameter['context_ids']);
111 $delete_cache = true;
112 break;
113
114 case 'delete':
115 $ilLog->write(__METHOD__ . ': Handling delete event');
116 self::deleteCategory($a_parameter['obj_id']);
117 $delete_cache = true;
118 break;
119 }
120 break;
121 }
122
123 if ($delete_cache) {
124 include_once './Services/Calendar/classes/class.ilCalendarCategories.php';
127 }
128 }
static deleteCategory($a_obj_id)
delete category
static deleteAppointments($a_obj_id, array $a_context_ids=null)
Delete automatic generated appointments.
static createAppointments($a_obj, $a_appointments)
Create appointments.
static deletePDItemsCache($a_usr_id)
Delete cache (add remove desktop item)
static deleteRepositoryCache($a_usr_id)
Delete cache.
$ilUser
Definition: imgupload.php:18

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

+ Here is the call graph for this function:

◆ updateCategory()

static ilCalendarAppEventListener::updateCategory (   $a_obj)
static

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

@access public

Parameters
objectilias object ('crs','grp',...)

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

166 {
167 include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
168 include_once('./Services/Calendar/classes/class.ilCalendarAppointmentColors.php');
169
170 if ($cat = ilCalendarCategory::_getInstanceByObjId($a_obj->getId())) {
171 $cat->setTitle($a_obj->getTitle());
172 $cat->update();
173 }
174 return true;
175 }

References ilCalendarCategory\_getInstanceByObjId().

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: