ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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)
 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)
 Delete automatic generated appointments. More...
 
static deleteCategory ($a_obj_id)
 delete category 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.

public

Parameters

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

References $ilLog, ilCalendarCategories\_lookupCategoryIdByObjId(), and ilCalendarCategoryAssignments\addAssignment().

144  {
145  global $ilLog;
146 
147  include_once('./Services/Calendar/classes/class.ilCalendarEntry.php');
148  include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
149  include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
150 
151  if(!$cat_id = ilCalendarCategories::_lookupCategoryIdByObjId($a_obj->getId()))
152  {
153  $ilLog->write(__METHOD__.': Cannot find calendar category for obj_id '.$a_obj->getId());
154  $cat_id = self::createCategory($a_obj);
155  }
156 
157  foreach($a_appointments as $app_templ)
158  {
159  $app = new ilCalendarEntry();
160  $app->setContextId($app_templ->getContextId());
161  $app->setTitle($app_templ->getTitle());
162  $app->setSubtitle($app_templ->getSubtitle());
163  $app->setDescription($app_templ->getDescription());
164  $app->setFurtherInformations($app_templ->getInformation());
165  $app->setLocation($app_templ->getLocation());
166  $app->setStart($app_templ->getStart());
167  $app->setEnd($app_templ->getEnd());
168  $app->setFullday($app_templ->isFullday());
169  $app->setAutoGenerated(true);
170  $app->setTranslationType($app_templ->getTranslationType());
171  $app->save();
172 
173  $ass = new ilCalendarCategoryAssignments($app->getEntryId());
174  $ass->addAssignment($cat_id);
175  }
176  }
Model for a calendar entry.
static _lookupCategoryIdByObjId($a_obj_id)
lookup category by obj_id
+ Here is the call graph for this function:

◆ createCategory()

static ilCalendarAppEventListener::createCategory (   $a_obj)
static

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

public

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

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

References $lng, ilCalendarAppointmentColors\_getRandomColorByType(), and ilCalendarCategory\TYPE_OBJ.

101  {
102  global $lng;
103 
104  include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
105  include_once('./Services/Calendar/classes/class.ilCalendarAppointmentColors.php');
106 
107  $cat = new ilCalendarCategory();
108  $cat->setTitle($a_obj->getTitle() ? $a_obj->getTitle() : $lng->txt('obj_'.$a_obj->getType()));
109  $cat->setType(ilCalendarCategory::TYPE_OBJ);
110  $cat->setColor(ilCalendarAppointmentColors::_getRandomColorByType($a_obj->getType()));
111  $cat->setObjId($a_obj->getId());
112  return $cat->add();
113  }
Stores calendar categories.
global $lng
Definition: privfeed.php:40
static _getRandomColorByType($a_type)
get random color entry for type
+ Here is the call graph for this function:

◆ deleteAppointments()

static ilCalendarAppEventListener::deleteAppointments (   $a_obj_id)
static

Delete automatic generated appointments.

public

Parameters
intobj_id

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

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

186  {
187  include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
188  include_once('./Services/Calendar/classes/class.ilCalendarEntry.php');
189 
191  {
193  ilCalendarEntry::_delete($app_id);
194  }
195  }
static _delete($a_entry_id)
delete entry
static _getAutoGeneratedAppointmentsByObjId($a_obj_id)
get automatic generated appointments of category
static _deleteByAppointmentId($a_app_id)
Delete appointment assignment.
+ Here is the call graph for this function:

◆ deleteCategory()

static ilCalendarAppEventListener::deleteCategory (   $a_obj_id)
static

delete category

public

Parameters

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

References $ilLog, and ilCalendarCategories\_lookupCategoryIdByObjId().

206  {
207  global $ilLog;
208 
209  include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
210 
211  if(!$cat_id = ilCalendarCategories::_lookupCategoryIdByObjId($a_obj_id))
212  {
213  $ilLog->write(__METHOD__.': Cannot find calendar category for obj_id '.$a_obj_id);
214  return false;
215  }
216 
217  $category = new ilCalendarCategory($cat_id);
218  $category->delete();
219 
220  }
static _lookupCategoryIdByObjId($a_obj_id)
lookup category by obj_id
Stores calendar categories.
+ Here is the call graph for this function:

◆ handleEvent()

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

Handle events like create, update, delete.

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.

References $ilLog, $ilUser, ilCalendarCategories\deletePDItemsCache(), and ilCalendarCategories\deleteRepositoryCache().

47  {
48  global $ilLog,$ilUser;
49 
50  switch($a_component)
51  {
52  case 'Modules/Session':
53  case 'Modules/Group':
54  case 'Modules/Course':
55  switch($a_event)
56  {
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  break;
62  case 'update':
63  $ilLog->write(__METHOD__.': Handling update event');
64  self::updateCategory($a_parameter['object']);
65  self::deleteAppointments($a_parameter['obj_id']);
66  self::createAppointments($a_parameter['object'],$a_parameter['appointments']);
67  break;
68  case 'delete':
69  $ilLog->write(__METHOD__.': Handling delete event');
70  self::deleteCategory($a_parameter['obj_id']);
71  break;
72  }
73  include_once './Services/Calendar/classes/class.ilCalendarCategories.php';
76 
77  break;
78 
79  case 'Services/Booking':
80  switch($a_event)
81  {
82  case 'create':
83  break;
84  case 'update':
85  break;
86  case 'delete':
87  break;
88  }
89 
90  }
91  }
static deletePDItemsCache($a_usr_id)
Delete cache (add remove desktop item)
static deleteRepositoryCache($a_usr_id)
Delete cache.
global $ilUser
Definition: imgupload.php:15
+ Here is the call graph for this function:

◆ updateCategory()

static ilCalendarAppEventListener::updateCategory (   $a_obj)
static

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

public

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

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

References ilCalendarCategory\_getInstanceByObjId().

123  {
124  include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
125  include_once('./Services/Calendar/classes/class.ilCalendarAppointmentColors.php');
126 
127  if($cat = ilCalendarCategory::_getInstanceByObjId($a_obj->getId()))
128  {
129  $cat->setTitle($a_obj->getTitle());
130  $cat->update();
131  }
132  return true;
133  }
static _getInstanceByObjId($a_obj_id)
get instance by obj_id
+ Here is the call graph for this function:

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