Beispiel #1
0
 public static function translateFromRequest()
 {
     $dt = Loader::helper('form/date_time');
     $dateStart = $dt->translate('pdStartDate');
     $dateEnd = $dt->translate('pdEndDate');
     if ($dateStart || $dateEnd) {
         // create a PermissionDuration object
         if ($_REQUEST['pdID']) {
             $pd = PermissionDuration::getByID($_REQUEST['pdID']);
         } else {
             $pd = new PermissionDuration();
         }
         if ($_REQUEST['pdStartDateAllDayActivate']) {
             $pd->setStartDateAllDay(1);
             $dateStart = date('Y-m-d 00:00:00', strtotime($dateStart));
         } else {
             $pd->setStartDateAllDay(0);
         }
         if ($_REQUEST['pdEndDateAllDayActivate']) {
             $pd->setEndDateAllDay(1);
             $dateEnd = date('Y-m-d 23:59:59', strtotime($dateEnd));
         } else {
             $pd->setEndDateAllDay(0);
         }
         $pd->setStartDate($dateStart);
         $pd->setEndDate($dateEnd);
         if ($_POST['pdRepeatPeriod'] && $_POST['pdRepeat']) {
             $pd->setRepeatPeriod($_POST['pdRepeatPeriod']);
             if ($_POST['pdRepeatPeriod'] == 'daily') {
                 $pd->setRepeatEveryNum($_POST['pdRepeatPeriodDaysEvery']);
             } else {
                 if ($_POST['pdRepeatPeriod'] == 'weekly') {
                     $pd->setRepeatEveryNum($_POST['pdRepeatPeriodWeeksEvery']);
                     $pd->setRepeatPeriodWeekDays($_POST['pdRepeatPeriodWeeksDays']);
                 } else {
                     if ($_POST['pdRepeatPeriod'] == 'monthly') {
                         $pd->setRepeatMonthBy($_POST['pdRepeatPeriodMonthsRepeatBy']);
                         $pd->setRepeatEveryNum($_POST['pdRepeatPeriodMonthsEvery']);
                     }
                 }
             }
             $pd->setRepeatPeriodEnd($dt->translate('pdEndRepeatDateSpecific'));
         } else {
             $pd->setRepeatPeriod(false);
         }
         $pd->save();
     } else {
         unset($pd);
     }
     return $pd;
 }