Exemplo n.º 1
0
 private function getDateTimeFromPost()
 {
     // If user have checked the box for associating the foodle with a time.
     if (FoodleUtils::checkbox('eventtimeopt')) {
         //error_log('DateTime: Checkbox [eventtimeopt] set');
         $date = array();
         // The datefrom should always be present
         if (!empty($_REQUEST['eventdatefrom']) && preg_match('/([0-9]{4}-[0-9]{2}-[0-9]{2})/', $_REQUEST['eventdatefrom'], $matches)) {
             $date['datefrom'] = $matches[1];
         } else {
             return NULL;
         }
         //error_log('DateTime: Found [eventdatefrom]');
         // If [all day] is checked, pick the time from.
         if (!FoodleUtils::checkbox('eventallday')) {
             //error_log('DateTime: Checkbox [eventallday] not set');
             if (!empty($_REQUEST['eventtimefrom']) && preg_match('/([0-9]{2}:[0-9]{2})/', $_REQUEST['eventtimefrom'], $matches)) {
                 $date['timefrom'] = $matches[1];
             } else {
                 return NULL;
             }
             //error_log('DateTime: Found [eventtimefrom]');
             if (!empty($_REQUEST['eventtimeto']) && preg_match('/([0-9]{2}:[0-9]{2})/', $_REQUEST['eventtimeto'], $matches)) {
                 $date['timeto'] = $matches[1];
             } else {
                 return NULL;
             }
             //error_log('DateTime: Found [eventtimeto]');
         }
         // If [multiple days] is checked, pick the date and time to.
         if (FoodleUtils::checkbox('eventmultipledays')) {
             //error_log('DateTime: Checkbox [eventmultipledays] set');
             if (!empty($_REQUEST['eventdateto']) && preg_match('/([0-9]{4}-[0-9]{2}-[0-9]{2})/', $_REQUEST['eventdateto'], $matches)) {
                 $date['dateto'] = $matches[1];
             } else {
                 return NULL;
             }
             //error_log('DateTime: Found [eventdateto]');
         }
         return $date;
     }
     //error_log('DateTime: Checkbox [eventtimeopt] not set');
     return NULL;
 }