$calRecurrence->setWeekly(true);
         $calRecurrence->setWeekday($_POST['weekday']);
         $calRecurrence->setMonthly(false);
         $calRecurrence->setYearly(false);
         break;
     case "monthly":
         $calRecurrence->setWeekly(false);
         $calRecurrence->setMonthly(true);
         $calRecurrence->setDayOfMonth($_POST['dayOfMonth']);
         $calRecurrence->setYearly(false);
         break;
     case "yearly":
         $calRecurrence->setWeekly(false);
         $calRecurrence->setMonthly(false);
         $calRecurrence->setYearly(true);
         $calRecurrence->setDateOfYear(str_pad($_POST['dateOfYear_month'], 2, '0', STR_PAD_LEFT) . str_pad($_POST['dateOfYear_day'], 2, '0', STR_PAD_LEFT));
         break;
 }
 $calRecurrence->setStartPeriod($_POST['startPeriod']);
 if ($_POST['endType'] == "dt") {
     $calRecurrence->setEndPeriod($_POST['endPeriod']);
 } else {
     $calRecurrence->setNbRecurrences($_POST['nbRecurrences']);
 }
 $calRecurrence->setUser($save['user']);
 $calRecurrence->save($_POST['affect'] == 'all');
 // Save the ip at the log for the addition of new calendar items when done by anonymous users
 if (empty($user) && empty($save['calitemId']) && $caladd["{$newcalid}"]['tiki_p_add_events']) {
     $logslib->add_log('calendar', 'Recurrent calendar item starting on ' . $_POST['startPeriod'] . ' added to calendar ' . $save['calendarId']);
 }
 if (empty($user) && !empty($save['calitemId']) and $caladd["{$newcalid}"]['tiki_p_change_events']) {