ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups 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.
static createCategory ($a_obj)
 Create a category for a new object (crs,grp, ...)
static updateCategory ($a_obj)
 Create a category for a new object (crs,grp, ...)
static createAppointments ($a_obj, $a_appointments)
 Create appointments.
static deleteAppointments ($a_obj_id)
 Delete automatic generated appointments.
static deleteCategory ($a_obj_id)
 delete category

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

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

Create appointments.

public

Parameters
@return

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

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

Referenced by handleEvent().

{
global $ilLog;
include_once('./Services/Calendar/classes/class.ilCalendarEntry.php');
include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
if(!$cat_id = ilCalendarCategories::_lookupCategoryIdByObjId($a_obj->getId()))
{
$ilLog->write(__METHOD__.': Cannot find calendar category for obj_id '.$a_obj->getId());
$cat_id = self::createCategory($a_obj);
}
foreach($a_appointments as $app_templ)
{
$app = new ilCalendarEntry();
$app->setContextId($app_templ->getContextId());
$app->setTitle($app_templ->getTitle());
$app->setSubtitle($app_templ->getSubtitle());
$app->setDescription($app_templ->getDescription());
$app->setFurtherInformations($app_templ->getInformation());
$app->setLocation($app_templ->getLocation());
$app->setStart($app_templ->getStart());
$app->setEnd($app_templ->getEnd());
$app->setFullday($app_templ->isFullday());
$app->setAutoGenerated(true);
$app->setTranslationType($app_templ->getTranslationType());
$app->save();
$ass = new ilCalendarCategoryAssignments($app->getEntryId());
$ass->addAssignment($cat_id);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Referenced by createAppointments(), and handleEvent().

{
global $lng;
include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
include_once('./Services/Calendar/classes/class.ilCalendarAppointmentColors.php');
$cat = new ilCalendarCategory();
$cat->setTitle($a_obj->getTitle() ? $a_obj->getTitle() : $lng->txt('obj_'.$a_obj->getType()));
$cat->setColor(ilCalendarAppointmentColors::_getRandomColorByType($a_obj->getType()));
$cat->setObjId($a_obj->getId());
return $cat->add();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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().

Referenced by handleEvent().

{
include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
include_once('./Services/Calendar/classes/class.ilCalendarEntry.php');
{
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilCalendarAppEventListener::deleteCategory (   $a_obj_id)
static

delete category

public

Parameters
@return

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

References $ilLog, and ilCalendarCategories\_lookupCategoryIdByObjId().

Referenced by handleEvent().

{
global $ilLog;
include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
{
$ilLog->write(__METHOD__.': Cannot find calendar category for obj_id '.$a_obj_id);
return false;
}
$category = new ilCalendarCategory($cat_id);
$category->delete();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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, createAppointments(), createCategory(), deleteAppointments(), deleteCategory(), ilCalendarCategories\deletePDItemsCache(), ilCalendarCategories\deleteRepositoryCache(), and updateCategory().

{
global $ilLog,$ilUser;
switch($a_component)
{
case 'Modules/Session':
case 'Modules/Group':
case 'Modules/Course':
switch($a_event)
{
case 'create':
$ilLog->write(__METHOD__.': Handling create event');
self::createCategory($a_parameter['object']);
self::createAppointments($a_parameter['object'],$a_parameter['appointments']);
break;
case 'update':
$ilLog->write(__METHOD__.': Handling update event');
self::updateCategory($a_parameter['object']);
self::deleteAppointments($a_parameter['obj_id']);
self::createAppointments($a_parameter['object'],$a_parameter['appointments']);
break;
case 'delete':
$ilLog->write(__METHOD__.': Handling delete event');
self::deleteCategory($a_parameter['obj_id']);
break;
}
include_once './Services/Calendar/classes/class.ilCalendarCategories.php';
break;
case 'Services/Booking':
switch($a_event)
{
case 'create':
break;
case 'update':
break;
case 'delete':
break;
}
}
}

+ Here is the call graph for this function:

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().

Referenced by handleEvent().

{
include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
include_once('./Services/Calendar/classes/class.ilCalendarAppointmentColors.php');
if($cat = ilCalendarCategory::_getInstanceByObjId($a_obj->getId()))
{
$cat->setTitle($a_obj->getTitle());
$cat->update();
}
return true;
}

+ 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: