25 include_once(
'./Services/Calendar/classes/class.ilCalendarUserSettings.php');
 
   26 include_once 
'./Services/Calendar/classes/class.ilCalendarRecurrence.php';
 
   67                 $this->lng->loadLanguageModule(
'dateplaner');
 
   70                 $tpl->addJavascript(
"./Services/Calendar/js/recurrence_input.js");
 
   90                 if(
$_POST[
'frequence'] == 
'NONE')
 
   99                                 $this->
setAlert($lng->txt(
"cal_rec_err_limit"));
 
  121                 switch(
$_POST[
'frequence'])
 
  129                                 $this->
getRecurrence()->setFrequenceType($_POST[
'frequence']);
 
  130                                 $this->
getRecurrence()->setInterval((
int) $_POST[
'count_WEEKLY']);
 
  131                                 if(is_array($_POST[
'byday_WEEKLY']))
 
  138                                 $this->
getRecurrence()->setFrequenceType($_POST[
'frequence']);
 
  139                                 $this->
getRecurrence()->setInterval((
int) $_POST[
'count_MONTHLY']);
 
  140                                 switch((
int) $_POST[
'subtype_MONTHLY'])
 
  147                                                 switch((
int) $_POST[
'monthly_byday_day'])
 
  151                                                                 $this->
getRecurrence()->setBYSETPOS((
int) $_POST[
'monthly_byday_num']);
 
  157                                                                 $this->
getRecurrence()->setBYMONTHDAY((
int) $_POST[
'monthly_byday_num']);
 
  161                                                                 $this->
getRecurrence()->setBYDAY((
int) $_POST[
'monthly_byday_num'].$_POST[
'monthly_byday_day']);
 
  167                                                 $this->
getRecurrence()->setBYMONTHDAY((
int) $_POST[
'monthly_bymonthday']);
 
  173                                 $this->
getRecurrence()->setFrequenceType($_POST[
'frequence']);
 
  174                                 $this->
getRecurrence()->setInterval((
int) $_POST[
'count_YEARLY']);
 
  175                                 switch((
int) $_POST[
'subtype_YEARLY'])
 
  182                                                 $this->
getRecurrence()->setBYMONTH((
int) $_POST[
'yearly_bymonth_byday']);
 
  183                                                 $this->
getRecurrence()->setBYDAY((
int) $_POST[
'yearly_byday_num'].$_POST[
'yearly_byday']);
 
  187                                                 $this->
getRecurrence()->setBYMONTH((
int) $_POST[
'yearly_bymonth_by_monthday']);
 
  188                                                 $this->
getRecurrence()->setBYMONTHDAY((
int) $_POST[
'yearly_bymonthday']);
 
  195                 switch((
int) 
$_POST[
'until_type'])
 
  204                                 $this->
getRecurrence()->setFrequenceUntilCount((
int) $_POST[
'count']);
 
  208                                 $end_dt[
'year'] = (int) $_POST[
'until_end'][
'date'][
'y'];
 
  209                                 $end_dt[
'mon'] = (int) $_POST[
'until_end'][
'date'][
'm'];
 
  210                                 $end_dt[
'mday'] = (int) $_POST[
'until_end'][
'date'][
'd'];
 
  230                 $this->recurrence = $a_rec;
 
  249                 $this->allow_unlimited_recurrences = $a_status;
 
  270                 $this->enabled_subforms = $a_sub_forms;
 
  293                 $tpl = 
new ilTemplate(
'tpl.recurrence_input.html',
true,
true,
'Services/Calendar');
 
  295                 $options = array(
'NONE' => $this->lng->txt(
'cal_no_recurrence'));
 
  314                         $this->recurrence->getFrequenceType(),
 
  321                         array(
'onchange' => 
'ilHideFrequencies();',
'id' => 
'il_recurrence_1')));
 
  323                 $tpl->setVariable(
'TXT_EVERY',$this->lng->txt(
'cal_every'));
 
  328                         $tpl->setVariable(
'TXT_DAILY_FREQ_UNIT',$this->lng->txt(
'cal_day_s'));
 
  329                         $tpl->setVariable(
'COUNT_DAILY_VAL',$this->recurrence->getInterval());
 
  335                         $tpl->setVariable(
'TXT_WEEKLY_FREQ_UNIT',$this->lng->txt(
'cal_week_s'));
 
  336                         $tpl->setVariable(
'COUNT_WEEKLY_VAL',$this->recurrence->getInterval());
 
  343                         $tpl->setVariable(
'TXT_MONTHLY_FREQ_UNIT',$this->lng->txt(
'cal_month_s'));
 
  344                         $tpl->setVariable(
'COUNT_MONTHLY_VAL',$this->recurrence->getInterval());
 
  345                         $tpl->setVariable(
'TXT_ON_THE',$this->lng->txt(
'cal_on_the'));
 
  346                         $tpl->setVariable(
'TXT_BYMONTHDAY',$this->lng->txt(
'cal_on_the'));
 
  347                         $tpl->setVariable(
'TXT_OF_THE_MONTH',$this->lng->txt(
'cal_of_the_month'));
 
  355                         $tpl->setVariable(
'TXT_YEARLY_FREQ_UNIT',$this->lng->txt(
'cal_year_s'));
 
  356                         $tpl->setVariable(
'COUNT_YEARLY_VAL',$this->recurrence->getInterval());
 
  357                         $tpl->setVariable(
'TXT_ON_THE',$this->lng->txt(
'cal_on_the'));
 
  365                 $a_tpl->setCurrentBlock(
"prop_custom");
 
  366                 $a_tpl->setVariable(
"CUSTOM_CONTENT", 
$tpl->get());
 
  367                 $a_tpl->parseCurrentBlock();
 
  379                 $days = array(0 => 
'SU',1 => 
'MO',2 => 
'TU',3 => 
'WE',4 => 
'TH',5 => 
'FR',6 => 
'SA',7 => 
'SU');
 
  381                 $checked_days = array();
 
  382                 foreach($this->recurrence->getBYDAYList() as $byday)
 
  384                         if(in_array($byday,$days))
 
  386                                 $checked_days[] = $byday;
 
  390                 for($i = (
int) $this->user_settings->getWeekStart();$i < 7 + (int) $this->user_settings->getWeekStart();$i++)
 
  392                         $tpl->setCurrentBlock(
'byday_simple');
 
  394                         if(in_array($days[$i],$checked_days))
 
  396                                 $tpl->setVariable(
'BYDAY_WEEKLY_CHECKED',
'checked="checked"');
 
  398                         $tpl->setVariable(
'TXT_ON',$this->lng->txt(
'cal_on'));
 
  399                         $tpl->setVariable(
'BYDAY_WEEKLY_VAL',$days[$i]);
 
  401                         $tpl->parseCurrentBlock();
 
  415                 $byday_list = $this->recurrence->getBYDAYList();
 
  419                 foreach($byday_list as $byday)
 
  421                         if(preg_match(
'/^(-?\d)([A-Z][A-Z])/',$byday,$parsed) === 1)
 
  424                                 $chosen_num_day = $parsed[1];
 
  425                                 $chosen_day = $parsed[2];
 
  429                 if(count($this->recurrence->getBYMONTHDAYList()) == 1)
 
  431                         $bymonthday = $this->recurrence->getBYMONTHDAY();
 
  432                         if(in_array($bymonthday,array(1,2,3,4,5,-1)))
 
  435                                 $chosen_num_day = $bymonthday;
 
  440                 if(count($this->recurrence->getBYSETPOSList()) == 1)
 
  442                         $bysetpos = $this->recurrence->getBYSETPOS();
 
  443                         if(in_array($bysetpos,array(1,2,3,4,5,-1)))
 
  445                                 if($this->recurrence->getBYDAYList() == array(
'MO',
'TU',
'WE',
'TH',
'FR'))
 
  448                                         $chosen_num_day = $bysetpos;
 
  458                         $tpl->setVariable(
'M_BYDAY_CHECKED',
'checked="checked"');
 
  461                 $num_options = array(
 
  462                         1 => $this->lng->txt(
'cal_first'),
 
  463                         2 => $this->lng->txt(
'cal_second'),
 
  464                         3 => $this->lng->txt(
'cal_third'),
 
  465                         4 => $this->lng->txt(
'cal_fourth'),
 
  466                         5 => $this->lng->txt(
'cal_fifth'),
 
  467                    -1 => $this->lng->txt(
'cal_last'));
 
  477                         array(
'onchange' => 
"ilUpdateSubTypeSelection('sub_monthly_radio_1');")));
 
  479                 $days = array(0 => 
'SU',1 => 
'MO',2 => 
'TU',3 => 
'WE',4 => 
'TH',5 => 
'FR',6 => 
'SA',7 => 
'SU');
 
  481                 for($i = (
int) $this->user_settings->getWeekStart();$i < 7 + (int) $this->user_settings->getWeekStart();$i++)
 
  485                 $days_select[8] = $this->lng->txt(
'cal_weekday');
 
  486                 $days_select[9] = $this->lng->txt(
'cal_day_of_month');
 
  495                         array(
'onchange' => 
"ilUpdateSubTypeSelection('sub_monthly_radio_1');")));
 
  507                 $tpl->setVariable(
'TXT_IN',$this->lng->txt(
'cal_in'));
 
  511                 if(count($bymonthday = $this->recurrence->getBYMONTHDAYList()) == 1)
 
  513                         foreach($bymonthday as $mday)
 
  515                                 if($mday > 0 and $mday < 32)
 
  525                         $tpl->setVariable(
'M_BYMONTHDAY_CHECKED',
'checked="checked"');
 
  528                 for($i = 1; $i < 32;$i++)
 
  534                         'monthly_bymonthday',
 
  540                         array(
'onchange' => 
"ilUpdateSubTypeSelection('sub_monthly_radio_2');")));
 
  552                 $tpl->setVariable(
'TXT_Y_EVERY',$this->lng->txt(
'cal_every'));
 
  558                 foreach($this->recurrence->getBYMONTHList() as $month)
 
  560                         if($this->recurrence->getBYMONTHDAYList())
 
  562                                 $chosen_month = $month;
 
  567                 foreach($this->recurrence->getBYMONTHDAYList() as $day)
 
  572                 for($i = 1; $i < 32;$i++)
 
  585                         array(
'onchange' => 
"ilUpdateSubTypeSelection('sub_yearly_radio_2');")));
 
  588                 for($m = 1;$m < 13;$m++)
 
  594                         'yearly_bymonth_by_monthday',
 
  600                         array(
'onchange' => 
"ilUpdateSubTypeSelection('sub_yearly_radio_2');")));
 
  605                         $tpl->setVariable(
'Y_BYMONTHDAY_CHECKED',
'checked="checked"');
 
  619                 $tpl->setVariable(
'TXT_ON_THE',$this->lng->txt(
'cal_on_the'));
 
  624                 foreach($this->recurrence->getBYDAYList() as $byday)
 
  626                         if(preg_match(
'/^(-?\d)([A-Z][A-Z])/',$byday,$parsed) === 1)
 
  629                                 $chosen_num_day = $parsed[1];
 
  630                                 $chosen_day = $parsed[2];
 
  635                 $num_options = array(
 
  636                         1 => $this->lng->txt(
'cal_first'),
 
  637                         2 => $this->lng->txt(
'cal_second'),
 
  638                         3 => $this->lng->txt(
'cal_third'),
 
  639                         4 => $this->lng->txt(
'cal_fourth'),
 
  640                         5 => $this->lng->txt(
'cal_fifth'),
 
  641                    -1 => $this->lng->txt(
'cal_last'));
 
  651                         array(
'onchange' => 
"ilUpdateSubTypeSelection('sub_yearly_radio_1');")));
 
  654                 $days = array(0 => 
'SU',1 => 
'MO',2 => 
'TU',3 => 
'WE',4 => 
'TH',5 => 
'FR',6 => 
'SA',7 => 
'SU');
 
  655                 for($i = (
int) $this->user_settings->getWeekStart();$i < 7 + (int) $this->user_settings->getWeekStart();$i++)
 
  667                         array(
'onchange' => 
"ilUpdateSubTypeSelection('sub_yearly_radio_1');")));
 
  672                 foreach($this->recurrence->getBYMONTHList() as $month)
 
  674                         if($this->recurrence->getBYMONTHDAYList())
 
  676                                 $chosen_month = $month;
 
  682                 for($m = 1;$m < 13;$m++)
 
  688                         'yearly_bymonth_byday',
 
  694                         array(
'onchange' => 
"ilUpdateSubTypeSelection('sub_yearly_radio_1');")));
 
  710                         $tpl->setVariable(
'TXT_NO_ENDING',$this->lng->txt(
'cal_no_ending'));
 
  713                 $tpl->setVariable(
'TXT_UNTIL_CREATE',$this->lng->txt(
'cal_create'));
 
  714                 $tpl->setVariable(
'TXT_APPOINTMENTS',$this->lng->txt(
'cal_appointments'));
 
  716                 $tpl->setVariable(
'VAL_COUNT',$this->recurrence->getFrequenceUntilCount() ? 
 
  717                         $this->recurrence->getFrequenceUntilCount() : 
 
  720                 if($this->recurrence->getFrequenceUntilDate())
 
  722                         $tpl->setVariable(
'UNTIL_END_CHECKED',
'checked="checked"');
 
  726                         $tpl->setVariable(
'UNTIL_COUNT_CHECKED',
'checked="checked"');
 
  730                         $tpl->setVariable(
'UNTIL_NO_CHECKED',
'checked="checked"');
 
  733                 $tpl->setVariable(
'TXT_UNTIL_END',$this->lng->txt(
'cal_repeat_until'));
 
  736                         $this->recurrence->getFrequenceUntilDate() ? $this->recurrence->getFrequenceUntilDate() : 
new ilDate(time(),
IL_CAL_UNIX));
 
  737                 $tpl->setVariable(
'UNTIL_END_DATE',$dt->getTableFilterHTML());