ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCalendarAppointmentGUI Class Reference

Administrate calendar appointments. More...

+ Collaboration diagram for ilCalendarAppointmentGUI:

Public Member Functions

 __construct (ilDate $seed, $a_appointment_id=0)
 Constructor.
 executeCommand ()
 Execute command.

Protected Member Functions

 cancel ()
 cancel editing
 initForm ($a_mode)
 init form
 add ()
 add new appointment
 save ()
 save appointment
 edit ()
 edit appointment
 showInfoScreen ()
 show info screen
 update ()
 update
 askDelete ()
 ask delete
 delete ()
 delete
 initTimeZone ()
 init timezone
 initSeed (ilDate $seed)
 init seed
 initAppointment ($a_app_id=0)
 init appointment
 load ()
 load post
 loadRecurrenceSettings ()
 load recurrence settings
 saveRecurrenceSettings ()
 save recurrence settings
 createDefaultCalendar ()
 Create a default calendar.

Protected Attributes

 $seed = null
 $default_fulltime = true
 $app = null
 $rec = null
 $timezone = null
 $tpl
 $lng
 $ctrl

Detailed Description

Administrate calendar appointments.

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

Definition at line 36 of file class.ilCalendarAppointmentGUI.php.

Constructor & Destructor Documentation

ilCalendarAppointmentGUI::__construct ( ilDate  $seed,
  $a_appointment_id = 0 
)

Constructor.

public

Parameters
ilDateseed
Returns

Definition at line 56 of file class.ilCalendarAppointmentGUI.php.

References $ilCtrl, $lng, initAppointment(), initSeed(), and initTimeZone().

{
global $ilCtrl,$lng;
$this->lng = $lng;
$lng->loadLanguageModule('dateplaner');
$this->ctrl = $ilCtrl;
$this->initTimeZone();
$this->initSeed($seed);
$this->initAppointment($a_appointment_id);
}

+ Here is the call graph for this function:

Member Function Documentation

ilCalendarAppointmentGUI::add ( )
protected

add new appointment

protected

Returns

Definition at line 222 of file class.ilCalendarAppointmentGUI.php.

References $tpl, and initForm().

Referenced by save().

{
global $tpl;
$this->initForm('create');
$tpl->setContent($this->form->getHTML());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCalendarAppointmentGUI::askDelete ( )
protected

ask delete

protected

Returns

Definition at line 407 of file class.ilCalendarAppointmentGUI.php.

References $tpl.

{
global $tpl;
include_once('./Services/Utilities/classes/class.ilConfirmationGUI.php');
$this->ctrl->saveParameter($this,array('seed','app_id'));
$confirm = new ilConfirmationGUI();
$confirm->setFormAction($this->ctrl->getFormAction($this));
$confirm->setHeaderText($this->lng->txt('cal_delete_app_sure'));
$confirm->setCancel($this->lng->txt('cancel'),'edit');
$confirm->setConfirm($this->lng->txt('delete'),'delete');
$confirm->addItem('appointments[]',$this->app->getEntryId(),$this->app->getTitle());
$tpl->setContent($confirm->getHTML());
}
ilCalendarAppointmentGUI::cancel ( )
protected

cancel editing

protected

Parameters
@return

Definition at line 99 of file class.ilCalendarAppointmentGUI.php.

{
$this->ctrl->returnToParent($this);
}
ilCalendarAppointmentGUI::createDefaultCalendar ( )
protected

Create a default calendar.

protected

Returns

Definition at line 710 of file class.ilCalendarAppointmentGUI.php.

References $lng, ilCalendarCategory\DEFAULT_COLOR, and ilCalendarCategory\TYPE_USR.

Referenced by save(), and update().

{
global $ilUser,$lng;
$cat = new ilCalendarCategory();
$cat->setTitle($this->lng->txt('cal_default_calendar'));
$cat->setObjId($ilUser->getId());
return $cat->add();
}

+ Here is the caller graph for this function:

ilCalendarAppointmentGUI::delete ( )
protected

delete

protected

Parameters
@return

Definition at line 432 of file class.ilCalendarAppointmentGUI.php.

References $app, ilCalendarCategoryAssignments\_deleteByAppointmentId(), and ilUtil\sendInfo().

{
foreach($_POST['appointments'] as $app_id)
{
$app = new ilCalendarEntry($app_id);
$app->delete();
include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
}
ilUtil::sendInfo($this->lng->txt('cal_deleted_app'),true);
$this->ctrl->returnToParent($this);
}

+ Here is the call graph for this function:

ilCalendarAppointmentGUI::edit ( )
protected

edit appointment

protected

Parameters
@return

Definition at line 277 of file class.ilCalendarAppointmentGUI.php.

References $ilErr, $tpl, ilCalendarCategories\_getInstance(), ilCalendarCategoryAssignments\_lookupCategory(), initForm(), and showInfoScreen().

Referenced by update().

{
global $tpl,$ilUser,$ilErr;
include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
$cat_id = ilCalendarCategoryAssignments::_lookupCategory($this->app->getEntryId());
$cats = ilCalendarCategories::_getInstance($ilUser->getId());
if(!$cats->isVisible($cat_id))
{
$ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
return false;
}
if(!$cats->isEditable($cat_id) or $this->app->isAutoGenerated())
{
$this->showInfoScreen();
return true;
}
$this->initForm('edit');
$tpl->setContent($this->form->getHTML());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCalendarAppointmentGUI::executeCommand ( )

Execute command.

public

Parameters

Definition at line 76 of file class.ilCalendarAppointmentGUI.php.

References $cmd, $ilSetting, and $tpl.

{
global $ilUser, $ilSetting,$tpl;
$next_class = $this->ctrl->getNextClass($this);
switch($next_class)
{
default:
$cmd = $this->ctrl->getCmd("add");
$this->$cmd();
break;
}
return true;
}
ilCalendarAppointmentGUI::initAppointment (   $a_app_id = 0)
protected

init appointment

protected

Parameters
intappointment id
Returns

Definition at line 497 of file class.ilCalendarAppointmentGUI.php.

References $seed, ilCalendarRecurrences\_getFirstRecurrence(), and IL_CAL_HOUR.

Referenced by __construct().

{
include_once('./Services/Calendar/classes/class.ilCalendarEntry.php');
include_once('./Services/Calendar/classes/class.ilCalendarRecurrences.php');
$this->app = new ilCalendarEntry($a_app_id);
if(!$a_app_id)
{
$start = clone $this->seed;
$this->app->setStart($start);
$seed_end = clone $this->seed;
if($this->default_fulltime)
{
#$seed_end->increment(IL_CAL_DAY,1);
}
else
{
$seed_end->increment(IL_CAL_HOUR,2);
}
$this->app->setEnd($seed_end);
$this->app->setFullday($this->default_fulltime);
$this->rec = new ilCalendarRecurrence();
}
else
{
$this->rec = ilCalendarRecurrences::_getFirstRecurrence($this->app->getEntryId());
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCalendarAppointmentGUI::initForm (   $a_mode)
protected

init form

protected

Parameters
stringmode ('edit' | 'create')
Returns

Definition at line 111 of file class.ilCalendarAppointmentGUI.php.

References $_GET, $rec, $title, $tpl, ilCalendarCategories\_getInstance(), ilCalendarCategories\_lookupCategoryIdByObjId(), ilObject\_lookupObjId(), ilCalendarCategoryAssignments\getFirstAssignment(), ilYuiUtil\initDomEvent(), ilCheckboxInputGUI\setChecked(), ilDateTimeInputGUI\setDate(), ilTextInputGUI\setValue(), ilSelectInputGUI\setValue(), and ilTextAreaInputGUI\setValue().

Referenced by add(), and edit().

{
global $ilUser,$tpl;
include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
include_once('./Services/Calendar/classes/class.ilCalendarRecurrenceGUI.php');
include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
$this->form = new ilPropertyFormGUI();
include_once('./Services/YUI/classes/class.ilYuiUtil.php');
switch($a_mode)
{
case 'create':
$this->form->setTitle($this->lng->txt('cal_new_app'));
$this->ctrl->saveParameter($this,array('seed'));
$this->form->setFormAction($this->ctrl->getFormAction($this));
$this->form->addCommandButton('save',$this->lng->txt('cal_add_appointment'));
$this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
break;
case 'edit':
$this->form->setTitle($this->lng->txt('cal_edit_appointment'));
$this->ctrl->saveParameter($this,array('seed','app_id'));
$this->form->setFormAction($this->ctrl->getFormAction($this));
$this->form->addCommandButton('update',$this->lng->txt('save'));
$this->form->addCommandButton('askDelete',$this->lng->txt('delete'));
$this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
break;
}
// title
$title = new ilTextInputGUI($this->lng->txt('title'),'title');
$title->setValue($this->app->getTitle());
$title->setRequired(true);
$title->setMaxLength(128);
$title->setSize(32);
$this->form->addItem($title);
// calendar selection
$calendar = new ilSelectInputGUI($this->lng->txt('cal_category_selection'),'calendar');
if($_POST['category'])
{
$calendar->setValue((int) $_POST['calendar']);
}
elseif($a_mode == 'edit')
{
$ass = new ilCalendarCategoryAssignments($this->app->getEntryId());
$cat = $ass->getFirstAssignment();
$calendar->setValue($cat);
}
elseif(isset($_GET['ref_id']))
{
include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
$obj_cal = ilObject::_lookupObjId($_GET['ref_id']);
$calendar->setValue(ilCalendarCategories::_lookupCategoryIdByObjId($obj_cal));
}
$calendar->setRequired(true);
$cats = ilCalendarCategories::_getInstance($ilUser->getId());
$calendar->setOptions($cats->prepareCategoriesOfUserForSelection());
$this->form->addItem($calendar);
$tpl->addJavaScript('./Services/Calendar/js/toggle_appointment_time.js');
$fullday = new ilCheckboxInputGUI($this->lng->txt('cal_fullday'),'fullday');
$fullday->setChecked($this->app->isFullday() ? true : false);
$fullday->setOptionTitle($this->lng->txt('cal_fullday_title'));
$fullday->setAdditionalAttributes('onchange="ilToggleAppointmentTime(this);"');
$this->form->addItem($fullday);
$start = new ilDateTimeInputGUI($this->lng->txt('cal_start'),'start');
$start->setDate($this->app->getStart());
$start->setShowTime(true);
$start->setMinuteStepSize(5);
$fullday->addSubItem($start);
$end = new ilDateTimeInputGUI($this->lng->txt('cal_end'),'end');
$end->setDate($this->app->getEnd());
$end->setShowTime(true);
$end->setMinuteStepSize(5);
$fullday->addSubItem($end);
// Recurrence
include_once('./Services/Calendar/classes/Form/class.ilRecurrenceInputGUI.php');
$rec = new ilRecurrenceInputGUI($this->lng->txt('cal_recurrences'),'frequence');
$rec->setRecurrence($this->rec);
$this->form->addItem($rec);
$where = new ilTextInputGUI($this->lng->txt('cal_where'),'location');
$where->setValue($this->app->getLocation());
$where->setMaxLength(128);
$where->setSize(32);
$this->form->addItem($where);
$desc = new ilTextAreaInputGUI($this->lng->txt('description'),'description');
$desc->setValue($this->app->getDescription());
$desc->setCols(3);
$this->form->addItem($desc);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCalendarAppointmentGUI::initSeed ( ilDate  $seed)
protected

init seed

protected

Parameters
@return

Definition at line 467 of file class.ilCalendarAppointmentGUI.php.

References $_GET, $seed, $timezone, ilDate\get(), IL_CAL_DATE, and IL_CAL_DATETIME.

Referenced by __construct().

{
if(!isset($_GET['hour']))
{
$this->seed = clone $seed;
$this->default_fulltime = true;
}
else
{
if((int) $_GET['hour'] < 10)
{
$time = '0'.(int) $_GET['hour'].':00:00';
}
else
{
$time = (int) $_GET['hour'].':00:00';
}
$this->seed = new ilDateTime($seed->get(IL_CAL_DATE).' '.$time,IL_CAL_DATETIME,$this->timezone);
$this->default_fulltime = false;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCalendarAppointmentGUI::initTimeZone ( )
protected

init timezone

protected

Parameters
@return

Definition at line 453 of file class.ilCalendarAppointmentGUI.php.

Referenced by __construct().

{
global $ilUser;
$this->timezone = $ilUser->getTimeZone();
}

+ Here is the caller graph for this function:

ilCalendarAppointmentGUI::load ( )
protected

load post

protected

Parameters
@return

Definition at line 536 of file class.ilCalendarAppointmentGUI.php.

References IL_CAL_DATE, IL_CAL_FKT_GETDATE, loadRecurrenceSettings(), and ilUtil\stripSlashes().

Referenced by save(), and update().

{
$this->app->setTitle(ilUtil::stripSlashes($_POST['title']));
$this->app->setLocation(ilUtil::stripSlashes($_POST['location']));
$this->app->setDescription(ilUtil::stripSlashes($_POST['description']));
$this->app->setTitle(ilUtil::stripSlashes($_POST['title']));
$this->app->setFullday(isset($_POST['fullday']) ? true : false);
if($this->app->isFullday())
{
$start = new ilDate($_POST['start']['date']['y'].'-'.$_POST['start']['date']['m'].'-'.$_POST['start']['date']['d'],
$this->app->setStart($start);
$end = new ilDate($_POST['end']['date']['y'].'-'.$_POST['end']['date']['m'].'-'.$_POST['end']['date']['d'],
$this->app->setEnd($end);
}
else
{
$start_dt['year'] = (int) $_POST['start']['date']['y'];
$start_dt['mon'] = (int) $_POST['start']['date']['m'];
$start_dt['mday'] = (int) $_POST['start']['date']['d'];
$start_dt['hours'] = (int) $_POST['start']['time']['h'];
$start_dt['minutes'] = (int) $_POST['start']['time']['m'];
$start = new ilDateTime($start_dt,IL_CAL_FKT_GETDATE,$this->timezone);
$this->app->setStart($start);
$end_dt['year'] = (int) $_POST['end']['date']['y'];
$end_dt['mon'] = (int) $_POST['end']['date']['m'];
$end_dt['mday'] = (int) $_POST['end']['date']['d'];
$end_dt['hours'] = (int) $_POST['end']['time']['h'];
$end_dt['minutes'] = (int) $_POST['end']['time']['m'];
$end = new ilDateTime($end_dt,IL_CAL_FKT_GETDATE,$this->timezone);
$this->app->setEnd($end);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCalendarAppointmentGUI::loadRecurrenceSettings ( )
protected

load recurrence settings

protected

Returns

Definition at line 581 of file class.ilCalendarAppointmentGUI.php.

References IL_CAL_FREQ_DAILY, IL_CAL_FREQ_MONTHLY, IL_CAL_FREQ_WEEKLY, IL_CAL_FREQ_YEARLY, and ilUtil\stripSlashes().

Referenced by load().

{
$this->rec->reset();
switch($_POST['frequence'])
{
$this->rec->setFrequenceType($_POST['frequence']);
$this->rec->setInterval((int) $_POST['count_DAILY']);
break;
$this->rec->setFrequenceType($_POST['frequence']);
$this->rec->setInterval((int) $_POST['count_WEEKLY']);
if(is_array($_POST['byday_WEEKLY']))
{
$this->rec->setBYDAY(ilUtil::stripSlashes(implode(',',$_POST['byday_WEEKLY'])));
}
break;
$this->rec->setFrequenceType($_POST['frequence']);
$this->rec->setInterval((int) $_POST['count_MONTHLY']);
switch((int) $_POST['subtype_MONTHLY'])
{
case 0:
// nothing to do;
break;
case 1:
switch((int) $_POST['monthly_byday_day'])
{
case 8:
// Weekday
$this->rec->setBYSETPOS((int) $_POST['monthly_byday_num']);
$this->rec->setBYDAY('MO,TU,WE,TH,FR');
break;
case 9:
// Day of month
$this->rec->setBYMONTHDAY((int) $_POST['monthly_byday_num']);
break;
default:
$this->rec->setBYDAY((int) $_POST['monthly_byday_num'].$_POST['monthly_byday_day']);
break;
}
break;
case 2:
$this->rec->setBYMONTHDAY((int) $_POST['monthly_bymonthday']);
break;
}
break;
$this->rec->setFrequenceType($_POST['frequence']);
$this->rec->setInterval((int) $_POST['count_YEARLY']);
switch((int) $_POST['subtype_YEARLY'])
{
case 0:
// nothing to do;
break;
case 1:
$this->rec->setBYMONTH((int) $_POST['yearly_bymonth_byday']);
$this->rec->setBYDAY((int) $_POST['yearly_byday_num'].$_POST['yearly_byday']);
break;
case 2:
$this->rec->setBYMONTH((int) $_POST['yearly_bymonth_by_monthday']);
$this->rec->setBYMONTHDAY((int) $_POST['yearly_bymonthday']);
break;
}
break;
}
// UNTIL
switch((int) $_POST['until_type'])
{
case 1:
// nothing to do
break;
case 2:
$this->rec->setFrequenceUntilCount((int) $_POST['count']);
break;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCalendarAppointmentGUI::save ( )
protected

save appointment

protected

Definition at line 235 of file class.ilCalendarAppointmentGUI.php.

References $ilErr, add(), ilCalendarCategoryAssignments\addAssignment(), createDefaultCalendar(), load(), saveRecurrenceSettings(), and ilUtil\sendInfo().

{
global $ilErr;
$this->load();
if($this->app->validate())
{
if(!(int) $_POST['calendar'])
{
$cat_id = $this->createDefaultCalendar();
}
else
{
$cat_id = (int) $_POST['calendar'];
}
$this->app->save();
$this->rec->setEntryId($this->app->getEntryId());
include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
$ass = new ilCalendarCategoryAssignments($this->app->getEntryId());
$ass->addAssignment($cat_id);
ilUtil::sendInfo($this->lng->txt('cal_created_appointment'));
$this->ctrl->returnToParent($this);
}
else
{
ilUtil::sendInfo($ilErr->getMessage());
}
$this->add();
}

+ Here is the call graph for this function:

ilCalendarAppointmentGUI::saveRecurrenceSettings ( )
protected

save recurrence settings

protected

Parameters
@return

Definition at line 679 of file class.ilCalendarAppointmentGUI.php.

Referenced by save(), and update().

{
switch($_POST['frequence'])
{
case 'NONE':
// No recurrence => delete if there is an recurrence rule
if($this->rec->getRecurrenceId())
{
$this->rec->delete();
}
break;
default:
if($this->rec->getRecurrenceId())
{
$this->rec->update();
}
else
{
$this->rec->save();
}
break;
}
}

+ Here is the caller graph for this function:

ilCalendarAppointmentGUI::showInfoScreen ( )
protected

show info screen

protected

Returns

Definition at line 309 of file class.ilCalendarAppointmentGUI.php.

References $tpl, ilObject\_getAllReferences(), ilCalendarCategories\_getInstance(), ilLink\_getStaticLink(), ilCalendarCategoryAssignments\_lookupCategory(), ilObject\_lookupType(), ilDatePresentation\formatPeriod(), and ilCalendarCategory\TYPE_OBJ.

Referenced by edit().

{
global $tpl,$ilUser;
include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
$info = new ilInfoScreenGUI($this);
$info->setFormAction($this->ctrl->getFormAction($this));
$info->addSection($this->lng->txt('cal_details'));
// Appointment
$info->addProperty($this->lng->txt('appointment'),
$this->app->getStart(),
$this->app->getEnd()));
$info->addProperty($this->lng->txt('title'),$this->app->getPresentationTitle());
// Description
if(strlen($desc = $this->app->getDescription()))
{
$info->addProperty($this->lng->txt('description'),$desc);
}
// Location
if(strlen($loc = $this->app->getLocation()))
{
$info->addProperty($this->lng->txt('cal_where'),$loc);
}
include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
$cat_id = ilCalendarCategoryAssignments::_lookupCategory($this->app->getEntryId());
$category = new ilCalendarCategory($cat_id);
if($category->getType() == ilCalendarCategory::TYPE_OBJ)
{
$info->addSection($this->lng->txt('additional_info'));
$cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
$refs = ilObject::_getAllReferences($cat_info['obj_id']);
include_once('classes/class.ilLink.php');
$href = ilLink::_getStaticLink(current($refs),ilObject::_lookupType($cat_info['obj_id']),true);
$info->addProperty($this->lng->txt('perma_link'),'<a class="small" href="'.$href.'" target="_top">'.$href.'</a>');
}
$tpl->setContent($info->getHTML());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCalendarAppointmentGUI::update ( )
protected

update

protected

Returns

Definition at line 363 of file class.ilCalendarAppointmentGUI.php.

References $ilErr, createDefaultCalendar(), ilCalendarCategoryAssignments\deleteAssignments(), edit(), load(), saveRecurrenceSettings(), and ilUtil\sendInfo().

{
global $ilErr;
$this->load();
if($this->app->validate())
{
if(!(int) $_POST['calendar'])
{
$cat_id = $this->createDefaultCalendar();
}
else
{
$cat_id = (int) $_POST['calendar'];
}
$this->app->update();
include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
$ass = new ilCalendarCategoryAssignments($this->app->getEntryId());
$ass->addAssignment($cat_id);
ilUtil::sendInfo($this->lng->txt('settings_saved'));
$this->ctrl->returnToParent($this);
}
else
{
ilUtil::sendInfo($ilErr->getMessage());
}
$this->edit();
}

+ Here is the call graph for this function:

Field Documentation

ilCalendarAppointmentGUI::$app = null
protected

Definition at line 41 of file class.ilCalendarAppointmentGUI.php.

Referenced by delete().

ilCalendarAppointmentGUI::$ctrl
protected

Definition at line 47 of file class.ilCalendarAppointmentGUI.php.

ilCalendarAppointmentGUI::$default_fulltime = true
protected

Definition at line 39 of file class.ilCalendarAppointmentGUI.php.

ilCalendarAppointmentGUI::$lng
protected

Definition at line 46 of file class.ilCalendarAppointmentGUI.php.

Referenced by __construct(), and createDefaultCalendar().

ilCalendarAppointmentGUI::$rec = null
protected

Definition at line 42 of file class.ilCalendarAppointmentGUI.php.

Referenced by initForm().

ilCalendarAppointmentGUI::$seed = null
protected

Definition at line 38 of file class.ilCalendarAppointmentGUI.php.

Referenced by initAppointment(), and initSeed().

ilCalendarAppointmentGUI::$timezone = null
protected

Definition at line 43 of file class.ilCalendarAppointmentGUI.php.

Referenced by initSeed().

ilCalendarAppointmentGUI::$tpl
protected

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