/**
  * Init Form 
  *
  * @access protected
  */
 protected function initForm($a_mode)
 {
     global $ilUser;
     if (is_object($this->form)) {
         return true;
     }
     $this->lng->loadLanguageModule('dateplaner');
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     include_once './Services/YUI/classes/class.ilYuiUtil.php';
     ilYuiUtil::initDomEvent();
     $this->form = new ilPropertyFormGUI();
     $this->form->setMultipart(true);
     $this->form->setTableWidth('600px');
     $this->form->setFormAction($this->ctrl->getFormAction($this));
     $this->form->setMultipart(true);
     /*
     $full = new ilCheckboxInputGUI('','fulltime');
     $full->setChecked($this->object->getFirstAppointment()->enabledFulltime() ? true : false);
     $full->setOptionTitle($this->lng->txt('event_fulltime_info'));
     $full->setAdditionalAttributes('onchange="ilToggleSessionTime(this);"');
     #$this->form->addItem($full);
     */
     $this->lng->loadLanguageModule('dateplaner');
     include_once './Services/Form/classes/class.ilDateDurationInputGUI.php';
     #$this->tpl->addJavaScript('./Modules/Session/js/toggle_session_time.js');
     $this->tpl->addJavaScript('./Services/Form/js/date_duration.js');
     $dur = new ilDateDurationInputGUI($this->lng->txt('cal_fullday'), 'event');
     $dur->setStartText($this->lng->txt('event_start_date'));
     $dur->setEndText($this->lng->txt('event_end_date'));
     $dur->enableToggleFullTime($this->lng->txt('event_fulltime_info'), $this->object->getFirstAppointment()->enabledFulltime() ? true : false);
     $dur->setMinuteStepSize(5);
     $dur->setShowTime(true);
     $dur->setShowDate(true);
     $dur->setStart($this->object->getFirstAppointment()->getStart());
     $dur->setEnd($this->object->getFirstAppointment()->getEnd());
     $this->form->addItem($dur);
     /*
     // start
     $start = new ilDateTimeInputGUI($this->lng->txt('event_start_date'),'start');
     $start->setMinuteStepSize(5);
     $start->setDate($this->object->getFirstAppointment()->getStart());
     $start->setShowTime(true);
     #$this->form->addItem($start);
     
     // end
     $end = new ilDateTimeInputGUI($this->lng->txt('event_end_date'),'end');
     $end->setMinuteStepSize(5);
     $end->setDate($this->object->getFirstAppointment()->getEnd());
     $end->setShowTime(true);
     #$this->form->addItem($end);
     */
     // Recurrence
     if ($a_mode == 'create') {
         if (!is_object($this->rec)) {
             include_once './Modules/Session/classes/class.ilEventRecurrence.php';
             $this->rec = new ilEventRecurrence();
         }
         include_once './Services/Calendar/classes/Form/class.ilRecurrenceInputGUI.php';
         $rec = new ilRecurrenceInputGUI($this->lng->txt('cal_recurrences'), 'frequence');
         $rec->allowUnlimitedRecurrences(false);
         $rec->setRecurrence($this->rec);
         $this->form->addItem($rec);
     }
     $section = new ilFormSectionHeaderGUI();
     $section->setTitle($this->lng->txt('event_section_information'));
     $this->form->addItem($section);
     // title
     $title = new ilTextInputGUI($this->lng->txt('event_title'), 'title');
     $title->setValue($this->object->getTitle());
     $title->setSize(50);
     $title->setMaxLength(70);
     $this->form->addItem($title);
     // desc
     $desc = new ilTextAreaInputGUI($this->lng->txt('event_desc'), 'desc');
     $desc->setValue($this->object->getLongDescription());
     $desc->setRows(4);
     $desc->setCols(50);
     $this->form->addItem($desc);
     // location
     $desc = new ilTextAreaInputGUI($this->lng->txt('event_location'), 'location');
     $desc->setValue($this->object->getLocation());
     $desc->setRows(4);
     $desc->setCols(50);
     $this->form->addItem($desc);
     // workflow
     $details = new ilTextAreaInputGUI($this->lng->txt('event_details_workflow'), 'details');
     $details->setValue($this->object->getDetails());
     $details->setCols(50);
     $details->setRows(4);
     $this->form->addItem($details);
     // section
     $section = new ilFormSectionHeaderGUI();
     $section->setTitle($this->lng->txt('event_tutor_data'));
     $this->form->addItem($section);
     // name
     $tutor_name = new ilTextInputGUI($this->lng->txt('tutor_name'), 'tutor_name');
     $tutor_name->setValue($this->object->getName());
     $tutor_name->setSize(20);
     $tutor_name->setMaxLength(70);
     $this->form->addItem($tutor_name);
     // email
     $tutor_email = new ilTextInputGUI($this->lng->txt('tutor_email'), 'tutor_email');
     $tutor_email->setValue($this->object->getEmail());
     $tutor_email->setSize(20);
     $tutor_email->setMaxLength(70);
     $this->form->addItem($tutor_email);
     // phone
     $tutor_phone = new ilTextInputGUI($this->lng->txt('tutor_phone'), 'tutor_phone');
     $tutor_phone->setValue($this->object->getPhone());
     $tutor_phone->setSize(20);
     $tutor_phone->setMaxLength(70);
     $this->form->addItem($tutor_phone);
     $section = new ilFormSectionHeaderGUI();
     $section->setTitle($this->lng->txt('crs_further_settings'));
     $this->form->addItem($section);
     // registration
     $reg = new ilCheckboxInputGUI($this->lng->txt('event_registration'), 'registration');
     $reg->setChecked($this->object->enabledRegistration() ? true : false);
     $reg->setOptionTitle($this->lng->txt('event_registration_info'));
     $this->form->addItem($reg);
     $section = new ilFormSectionHeaderGUI();
     $section->setTitle($this->lng->txt('event_assign_files'));
     $this->form->addItem($section);
     $files = new ilFileWizardInputGUI($this->lng->txt('objs_file'), 'files');
     $files->setFilenames(array(0 => ''));
     $this->form->addItem($files);
     switch ($a_mode) {
         case 'create':
             $this->form->setTitle($this->lng->txt('event_table_create'));
             $this->form->setTitleIcon(ilUtil::getImagePath('icon_event.png'));
             $this->form->addCommandButton('save', $this->lng->txt('event_btn_add'));
             $this->form->addCommandButton('saveAndAssignMaterials', $this->lng->txt('event_btn_add_edit'));
             $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
             return true;
         case 'edit':
             $this->form->setTitle($this->lng->txt('event_table_update'));
             $this->form->setTitleIcon(ilUtil::getImagePath('icon_event.png'));
             $this->form->addCommandButton('update', $this->lng->txt('save'));
             $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
             return true;
     }
     return true;
 }
 /**
  * init create/edit form
  *
  * @access protected
  * @param string edit or create
  * @return
  */
 protected function initForm($a_mode = 'edit')
 {
     global $ilUser, $tpl, $tree;
     if (is_object($this->form)) {
         return true;
     }
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $this->form = new ilPropertyFormGUI();
     switch ($a_mode) {
         case 'edit':
             $this->form->setFormAction($this->ctrl->getFormAction($this, 'update'));
             break;
         default:
             $this->form->setTableWidth('600px');
             $this->form->setFormAction($this->ctrl->getFormAction($this, 'save'));
             break;
     }
     // title
     $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
     $title->setSubmitFormOnEnter(true);
     $title->setValue($this->object->getTitle());
     $title->setSize(40);
     $title->setMaxLength(128);
     $title->setRequired(true);
     $this->form->addItem($title);
     // desc
     $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'desc');
     $desc->setValue($this->object->getLongDescription());
     $desc->setRows(2);
     $desc->setCols(40);
     $this->form->addItem($desc);
     // Group type
     $grp_type = new ilRadioGroupInputGUI($this->lng->txt('grp_typ'), 'grp_type');
     if ($a_mode == 'edit') {
         $type = $this->object->getGroupType() ? $this->object->getGroupType() : $this->object->readGroupStatus();
     } else {
         $type = $this->object->getGroupType() ? $this->object->getGroupType() : GRP_TYPE_PUBLIC;
     }
     $grp_type->setValue($type);
     $grp_type->setRequired(true);
     // PUBLIC GROUP
     $opt_public = new ilRadioOption($this->lng->txt('grp_public'), GRP_TYPE_PUBLIC, $this->lng->txt('grp_public_info'));
     $grp_type->addOption($opt_public);
     // CLOSED GROUP
     $opt_closed = new ilRadioOption($this->lng->txt('grp_closed'), GRP_TYPE_CLOSED, $this->lng->txt('grp_closed_info'));
     $grp_type->addOption($opt_closed);
     if ($a_mode == 'update_group_type') {
         $grp_type->setAlert($this->lng->txt('grp_type_changed_info'));
     }
     $this->form->addItem($grp_type);
     if ($a_mode == 'edit') {
         // Group registration ############################################################
         $pres = new ilFormSectionHeaderGUI();
         $pres->setTitle($this->lng->txt('grp_setting_header_registration'));
         $this->form->addItem($pres);
         // Registration type
         $reg_type = new ilRadioGroupInputGUI($this->lng->txt('group_registration_mode'), 'registration_type');
         $reg_type->setValue($this->object->getRegistrationType());
         $opt_dir = new ilRadioOption($this->lng->txt('grp_reg_direct'), GRP_REGISTRATION_DIRECT);
         #$this->lng->txt('grp_reg_direct_info'));
         $reg_type->addOption($opt_dir);
         $opt_pass = new ilRadioOption($this->lng->txt('grp_pass_request'), GRP_REGISTRATION_PASSWORD);
         $pass = new ilTextInputGUI('', 'password');
         $pass->setInfo($this->lng->txt('grp_reg_password_info'));
         $pass->setValue($this->object->getPassword());
         $pass->setSize(10);
         $pass->setMaxLength(32);
         $opt_pass->addSubItem($pass);
         $reg_type->addOption($opt_pass);
         $opt_req = new ilRadioOption($this->lng->txt('grp_reg_request'), GRP_REGISTRATION_REQUEST, $this->lng->txt('grp_reg_request_info'));
         $reg_type->addOption($opt_req);
         $opt_deact = new ilRadioOption($this->lng->txt('grp_reg_disabled'), GRP_REGISTRATION_DEACTIVATED, $this->lng->txt('grp_reg_disabled_info'));
         $reg_type->addOption($opt_deact);
         // Registration codes
         $reg_code = new ilCheckboxInputGUI($this->lng->txt('grp_reg_code'), 'reg_code_enabled');
         $reg_code->setChecked($this->object->isRegistrationAccessCodeEnabled());
         $reg_code->setValue(1);
         $reg_code->setInfo($this->lng->txt('grp_reg_code_enabled_info'));
         $this->form->addItem($reg_type);
         // time limit
         $time_limit = new ilCheckboxInputGUI($this->lng->txt('grp_reg_limited'), 'reg_limit_time');
         $time_limit->setOptionTitle($this->lng->txt('grp_reg_limit_time'));
         $time_limit->setChecked($this->object->isRegistrationUnlimited() ? false : true);
         $this->lng->loadLanguageModule('dateplaner');
         include_once './Services/Form/classes/class.ilDateDurationInputGUI.php';
         $tpl->addJavaScript('./Services/Form/js/date_duration.js');
         $dur = new ilDateDurationInputGUI($this->lng->txt('grp_reg_period'), 'reg');
         $dur->setStartText($this->lng->txt('cal_start'));
         $dur->setEndText($this->lng->txt('cal_end'));
         $dur->setMinuteStepSize(5);
         $dur->setShowDate(true);
         $dur->setShowTime(true);
         $dur->setStart($this->object->getRegistrationStart());
         $dur->setEnd($this->object->getRegistrationEnd());
         $time_limit->addSubItem($dur);
         $this->form->addItem($time_limit);
         // max member
         $lim = new ilCheckboxInputGUI($this->lng->txt('reg_grp_max_members_short'), 'registration_membership_limited');
         $lim->setValue(1);
         $lim->setOptionTitle($this->lng->txt('reg_grp_max_members'));
         $lim->setChecked($this->object->isMembershipLimited());
         $max = new ilTextInputGUI('', 'registration_max_members');
         $max->setValue($this->object->getMaxMembers() ? $this->object->getMaxMembers() : '');
         $max->setTitle($this->lng->txt('members') . ':');
         $max->setSize(3);
         $max->setMaxLength(4);
         $max->setInfo($this->lng->txt('grp_reg_max_members_info'));
         $lim->addSubItem($max);
         $wait = new ilCheckboxInputGUI('', 'waiting_list');
         $wait->setValue(1);
         $wait->setOptionTitle($this->lng->txt('grp_waiting_list'));
         $wait->setInfo($this->lng->txt('grp_waiting_list_info'));
         $wait->setChecked($this->object->isWaitingListEnabled() ? true : false);
         $lim->addSubItem($wait);
         $this->form->addItem($lim);
         // Registration codes
         if (!$this->object->getRegistrationAccessCode()) {
             include_once './Services/Membership/classes/class.ilMembershipRegistrationCodeUtils.php';
             $this->object->setRegistrationAccessCode(ilMembershipRegistrationCodeUtils::generateCode());
         }
         $reg_link = new ilHiddenInputGUI('reg_code');
         $reg_link->setValue($this->object->getRegistrationAccessCode());
         $this->form->addItem($reg_link);
         $link = new ilCustomInputGUI($this->lng->txt('grp_reg_code_link'));
         include_once './Services/Link/classes/class.ilLink.php';
         $val = ilLink::_getLink($this->object->getRefId(), $this->object->getType(), array(), '_rcode' . $this->object->getRegistrationAccessCode());
         $link->setHTML('<font class="small">' . $val . '</font>');
         $reg_code->addSubItem($link);
         $this->form->addItem($reg_code);
         // Group presentation
         $hasParentCourse = $tree->checkForParentType($this->object->getRefId(), 'crs');
         $pres = new ilFormSectionHeaderGUI();
         $pres->setTitle($this->lng->txt('grp_setting_header_presentation'));
         $this->form->addItem($pres);
         // presentation type
         $view_type = new ilRadioGroupInputGUI($this->lng->txt('grp_presentation_type'), 'view_mode');
         if ($hasParentCourse) {
             switch ($this->object->getViewMode()) {
                 case ilContainer::VIEW_SESSIONS:
                     $course_view_mode = ' (' . $this->lng->txt('cntr_view_sessions') . ')';
                     break;
                 case ilContainer::VIEW_SIMPLE:
                     $course_view_mode = ' (' . $this->lng->txt('cntr_view_simple') . ')';
                     break;
                 case ilContainer::VIEW_BY_TYPE:
                     $course_view_mode = ' (' . $this->lng->txt('cntr_view_by_type') . ')';
                     break;
             }
             $opt = new ilRadioOption($this->lng->txt('grp_view_inherit') . $course_view_mode, ilContainer::VIEW_INHERIT);
             $opt->setInfo($this->lng->txt('grp_view_inherit_info'));
             $view_type->addOption($opt);
         }
         if ($hasParentCourse && $this->object->getViewMode(false) == ilContainer::VIEW_INHERIT) {
             $view_type->setValue(ilContainer::VIEW_INHERIT);
         } else {
             $view_type->setValue($this->object->getViewMode(true));
         }
         $opt = new ilRadioOption($this->lng->txt('cntr_view_simple'), ilContainer::VIEW_SIMPLE);
         $opt->setInfo($this->lng->txt('grp_view_info_simple'));
         $view_type->addOption($opt);
         $opt = new ilRadioOption($this->lng->txt('cntr_view_by_type'), ilContainer::VIEW_BY_TYPE);
         $opt->setInfo($this->lng->txt('grp_view_info_by_type'));
         $view_type->addOption($opt);
         $this->form->addItem($view_type);
         $sog = new ilRadioGroupInputGUI($this->lng->txt('sorting_header'), 'sor');
         $sog->setRequired(true);
         if ($a_mode == 'edit') {
             $sog->setValue(ilContainerSortingSettings::_readSortMode(ilObject::_lookupObjId($this->object->getRefId())));
         } elseif ($hasParentCourse) {
             $sog->setValue(ilContainer::SORT_INHERIT);
         } else {
             $sog->setValue(ilContainer::SORT_TITLE);
         }
         if ($hasParentCourse) {
             $sde = new ilRadioOption();
             $sde->setValue(ilContainer::SORT_INHERIT);
             $title = $this->lng->txt('sort_inherit_prefix');
             $title .= ' (' . ilContainerSortingSettings::sortModeToString(ilContainerSortingSettings::lookupSortModeFromParentContainer(ilObject::_lookupObjectId($ref_id))) . ') ';
             $sde->setTitle($title);
             $sde->setInfo($this->lng->txt('sorting_info_inherit'));
             $sog->addOption($sde);
         }
         $sma = new ilRadioOption();
         $sma->setValue(ilContainer::SORT_TITLE);
         $sma->setTitle($this->lng->txt('sorting_title_header'));
         $sma->setInfo($this->lng->txt('sorting_info_title'));
         $sog->addOption($sma);
         $sti = new ilRadioOption();
         $sti->setValue(ilContainer::SORT_MANUAL);
         $sti->setTitle($this->lng->txt('sorting_manual_header'));
         $sti->setInfo($this->lng->txt('sorting_info_manual'));
         $sog->addOption($sti);
         $this->form->addItem($sog);
         include_once './Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
         ilObjectServiceSettingsGUI::initServiceSettingsForm($this->object->getId(), $this->form, array(ilObjectServiceSettingsGUI::CALENDAR_VISIBILITY, ilObjectServiceSettingsGUI::NEWS_VISIBILITY));
     }
     switch ($a_mode) {
         case 'create':
             $this->form->setTitle($this->lng->txt('grp_new'));
             $this->form->setTitleIcon(ilUtil::getImagePath('icon_grp.png'));
             $this->form->addCommandButton('save', $this->lng->txt('grp_new'));
             $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
             return true;
         case 'edit':
             $this->form->setTitle($this->lng->txt('grp_edit'));
             $this->form->setTitleIcon(ilUtil::getImagePath('icon_grp.png'));
             // Edit ecs export settings
             include_once 'Modules/Group/classes/class.ilECSGroupSettings.php';
             $ecs = new ilECSGroupSettings($this->object);
             $ecs->addSettingsToForm($this->form, 'grp');
             $this->form->addCommandButton('update', $this->lng->txt('save'));
             $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
             return true;
         case 'update_group_type':
             $grp_type->setValue($type == GRP_TYPE_PUBLIC ? GRP_TYPE_CLOSED : GRP_TYPE_PUBLIC);
             $this->form->setTitle($this->lng->txt('grp_edit'));
             $this->form->setTitleIcon(ilUtil::getImagePath('icon_grp.png'));
             return true;
     }
     return true;
 }
 /**
  * init form
  *
  * @access protected
  * @param string mode ('edit' | 'create')
  * @return
  */
 protected function initForm($a_mode, $a_as_milestone = false, $a_edit_single_app = false)
 {
     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';
     ilYuiUtil::initDomEvent();
     $resp_info = false;
     switch ($a_mode) {
         case 'create':
             $this->ctrl->saveParameter($this, array('seed', 'idate'));
             $this->form->setFormAction($this->ctrl->getFormAction($this));
             if ($a_as_milestone) {
                 $this->form->setTitle($this->lng->txt('cal_new_ms'));
                 $this->form->addCommandButton('saveMilestone', $this->lng->txt('cal_add_milestone'));
                 $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
             } else {
                 $this->form->setTitle($this->lng->txt('cal_new_app'));
                 $this->form->addCommandButton('save', $this->lng->txt('cal_add_appointment'));
                 $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
             }
             break;
         case 'edit':
             if ($a_as_milestone) {
                 $this->form->setTitle($this->lng->txt('cal_edit_milestone'));
             } else {
                 $this->form->setTitle($this->lng->txt('cal_edit_appointment'));
             }
             $this->ctrl->saveParameter($this, array('seed', 'app_id', 'idate'));
             $this->form->setFormAction($this->ctrl->getFormAction($this));
             $ass = new ilCalendarCategoryAssignments($this->app->getEntryId());
             $cat = $ass->getFirstAssignment();
             include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
             $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat);
             $type = ilObject::_lookupType($cat_info['obj_id']);
             if ($a_as_milestone && $cat_info['type'] == ilCalendarCategory::TYPE_OBJ && ($type == "grp" || $type == "crs")) {
                 $resp_info = true;
                 $this->form->addCommandButton('editResponsibleUsers', $this->lng->txt('cal_change_responsible_users'));
             }
             $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']);
         $selected_calendar = (int) $_POST['calendar'];
     } else {
         if ($_GET['category_id']) {
             $calendar->setValue((int) $_GET['category_id']);
             $selected_calendar = (int) $_GET['category_id'];
         } elseif ($a_mode == 'edit') {
             $ass = new ilCalendarCategoryAssignments($this->app->getEntryId());
             $cat = $ass->getFirstAssignment();
             $calendar->setValue($cat);
             $selected_calendar = $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));
             $selected_calendar = ilCalendarCategories::_lookupCategoryIdByObjId($obj_cal);
         }
     }
     $calendar->setRequired(true);
     $cats = ilCalendarCategories::_getInstance($ilUser->getId());
     $calendar->setOptions($cats->prepareCategoriesOfUserForSelection());
     include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
     if (ilCalendarSettings::_getInstance()->isNotificationEnabled()) {
         $notification_cals = $cats->getNotificationCalendars();
         $notification_cals = count($notification_cals) ? implode(',', $notification_cals) : '';
         $calendar->addCustomAttribute("onchange=\"ilToggleNotification(new Array(" . $notification_cals . "));\"");
     }
     $this->form->addItem($calendar);
     if (!$a_as_milestone) {
         include_once './Services/Form/classes/class.ilDateDurationInputGUI.php';
         $tpl->addJavaScript('./Services/Form/js/date_duration.js');
         $dur = new ilDateDurationInputGUI($this->lng->txt('cal_fullday'), 'event');
         $dur->setStartText($this->lng->txt('cal_start'));
         $dur->setEndText($this->lng->txt('cal_end'));
         $dur->enableToggleFullTime($this->lng->txt('cal_fullday_title'), $this->app->isFullday() ? true : false);
         $dur->setMinuteStepSize(5);
         $dur->setShowDate(true);
         $dur->setShowTime(true);
         $dur->setStart($this->app->getStart());
         $dur->setEnd($this->app->getEnd());
         $this->form->addItem($dur);
         // 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);
         // location
         $where = new ilTextInputGUI($this->lng->txt('cal_where'), 'location');
         $where->setValue($this->app->getLocation());
         $where->setMaxLength(128);
         $where->setSize(32);
         $this->form->addItem($where);
     } else {
         $deadline = new ilDateTimeInputGUI($this->lng->txt('cal_deadline'), 'event[start]');
         $deadline->setDate($this->app->getStart());
         $deadline->setShowTime(false);
         $deadline->setMinuteStepSize(5);
         $this->form->addItem($deadline);
         // completion
         $completion_vals = array();
         for ($i = 0; $i <= 100; $i += 5) {
             $completion_vals[$i] = $i . " %";
         }
         $compl = new ilSelectInputGUI($this->lng->txt('cal_task_completion'), 'completion');
         $compl->setOptions($completion_vals);
         $compl->setValue($this->app->getCompletion());
         $this->form->addItem($compl);
     }
     $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
     $desc->setValue($this->app->getDescription());
     $desc->setRows(5);
     $this->form->addItem($desc);
     if ($a_as_milestone && $a_mode == "edit" && $resp_info) {
         // users responsible
         $users = $this->app->readResponsibleUsers();
         $resp = new ilNonEditableValueGUI($this->lng->txt('cal_responsible'), $users);
         $delim = "";
         foreach ($users as $r) {
             $value .= $delim . $r["lastname"] . ", " . $r["firstname"] . " [" . $r["login"] . "]";
             $delim = "<br />";
         }
         if (count($users) > 0) {
             $resp->setValue($value);
         } else {
             $resp->setValue("-");
         }
         $this->form->addItem($resp);
     }
     if (ilCalendarSettings::_getInstance()->isUserNotificationEnabled()) {
         $notu = new ilTextWizardInputGUI($this->lng->txt('cal_user_notification'), 'notu');
         $notu->setInfo($this->lng->txt('cal_user_notification_info'));
         $notu->setSize(20);
         $notu->setMaxLength(64);
         $values = array();
         foreach ($this->notification->getRecipients() as $rcp) {
             switch ($rcp['type']) {
                 case ilCalendarUserNotification::TYPE_USER:
                     $values[] = ilObjUser::_lookupLogin($rcp['usr_id']);
                     break;
                 case ilCalendarUserNotification::TYPE_EMAIL:
                     $values[] = $rcp['email'];
                     break;
             }
         }
         if (count($values)) {
             $notu->setValues($values);
         } else {
             $notu->setValues(array(''));
         }
         $this->form->addItem($notu);
     }
     // Notifications
     include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
     if (ilCalendarSettings::_getInstance()->isNotificationEnabled() and count($cats->getNotificationCalendars())) {
         $selected_cal = new ilCalendarCategory($selected_calendar);
         $disabled = true;
         if ($selected_cal->getType() == ilCalendarCategory::TYPE_OBJ) {
             if (ilObject::_lookupType($selected_cal->getObjId()) == 'crs' or ilObject::_lookupType($selected_cal->getObjId()) == 'grp') {
                 $disabled = false;
             }
         }
         $tpl->addJavaScript('./Services/Calendar/js/toggle_notification.js');
         $not = new ilCheckboxInputGUI($this->lng->txt('cal_cg_notification'), 'not');
         $not->setInfo($this->lng->txt('cal_notification_info'));
         $not->setValue(1);
         $not->setChecked($this->app->isNotificationEnabled());
         $not->setDisabled($disabled);
         $this->form->addItem($not);
     }
 }
 /**
  * 
  */
 public function initFilter()
 {
     /**
      * @var $tpl ilTemplate
      */
     global $tpl;
     include_once 'Services/Form/classes/class.ilTextInputGUI.php';
     $ul = new ilTextInputGUI($this->lng->txt('login') . '/' . $this->lng->txt('email') . '/' . $this->lng->txt('name'), 'query');
     $ul->setDataSource($this->ctrl->getLinkTarget($this->getParentObject(), 'addUserAutoComplete', '', true));
     $ul->setSize(20);
     $ul->setSubmitFormOnEnter(true);
     $this->addFilterItem($ul);
     $ul->readFromSession();
     $this->filter['query'] = $ul->getValue();
     include_once 'Services/Form/classes/class.ilSelectInputGUI.php';
     $options = array();
     $languages = ilObject::_getObjectsByType('lng');
     foreach ($languages as $lng) {
         $options[$lng['title']] = $this->lng->txt('meta_l_' . $lng['title']);
     }
     asort($options);
     $options = array('' => $this->lng->txt('any_language')) + $options;
     $si = new ilSelectInputGUI($this->lng->txt('language'), 'lng');
     $si->setOptions($options);
     $this->addFilterItem($si);
     $si->readFromSession();
     $this->filter['lng'] = $si->getValue();
     include_once 'Services/Form/classes/class.ilDateDurationInputGUI.php';
     $tpl->addJavaScript('./Services/Form/js/date_duration.js');
     $duration = new ilDateDurationInputGUI($this->lng->txt('tos_period'), 'period');
     $duration->setStartText($this->lng->txt('tos_period_from'));
     $duration->setEndText($this->lng->txt('tos_period_until'));
     $duration->setStart(new ilDateTime(strtotime('-1 year', time()), IL_CAL_UNIX));
     $duration->setEnd(new ilDateTime(time(), IL_CAL_UNIX));
     $duration->setMinuteStepSize(5);
     $duration->setShowTime(true);
     $duration->setShowDate(true);
     $this->addFilterItem($duration, true);
     $duration->readFromSession();
     $this->optional_filter['period'] = $duration->getValue();
 }