Function Reference: geodir_imex_process_event_data
Summary
Validate the event data.
Package
GeoDirectory
Parameters
- $gd_post
- (array) (required) Post array.
- Default: None
Return Values
- (array)
- Event data array.
Change Log
Since: 1.5.1
Source File
geodir_imex_process_event_data() is located in geodirectory-admin/admin_functions.php [Line: 5965]
Source Code
function geodir_imex_process_event_data($gd_post) { $recurring_pkg = geodir_event_recurring_pkg( (object)$gd_post ); $is_recurring = isset( $gd_post['is_recurring_event'] ) && (int)$gd_post['is_recurring_event'] == 0 ? false : true; $event_date = isset($gd_post['event_date']) && $gd_post['event_date'] != '' ? geodir_date($gd_post['event_date'], 'Y-m-d') : ''; $event_enddate = isset($gd_post['event_enddate']) && $gd_post['event_enddate'] != '' ? geodir_date($gd_post['event_enddate'], 'Y-m-d') : $event_date; $all_day = isset($gd_post['is_whole_day_event']) && !empty($gd_post['is_whole_day_event']) ? true : false; $starttime = isset($gd_post['starttime']) && !$all_day ? $gd_post['starttime'] : ''; $endtime = isset($gd_post['endtime']) && !$all_day ? $gd_post['endtime'] : ''; $repeat_type = ''; $different_times = ''; $starttimes = ''; $endtimes = ''; $repeat_days = ''; $repeat_weeks = ''; $event_recurring_dates = ''; $repeat_x = ''; $duration_x = ''; $repeat_end_type = ''; $max_repeat = ''; $repeat_end = ''; if ($recurring_pkg && $is_recurring) { $repeat_type = $gd_post['recurring_type']; if ($repeat_type == 'custom') { $starttimes = !$all_day && !empty($gd_post['event_starttimes']) ? explode(",", $gd_post['event_starttimes']) : array(); $endtimes = !$all_day && !empty($gd_post['event_endtimes']) ? explode(",", $gd_post['event_endtimes']) : array(); if (!empty($starttimes) || !empty($endtimes)) { $different_times = true; } $recurring_dates = isset($gd_post['recurring_dates']) && $gd_post['recurring_dates'] != '' ? explode(",", $gd_post['recurring_dates']) : array(); if (!empty($recurring_dates)) { $event_recurring_dates = array(); foreach ($recurring_dates as $recurring_date) { $recurring_date = trim($recurring_date); if ($recurring_date != '') { $event_recurring_dates[] = geodir_date($recurring_date, 'Y-m-d'); } } $event_recurring_dates = array_unique($event_recurring_dates); $event_recurring_dates = implode(",", $event_recurring_dates); } } else { $duration_x = !empty( $gd_post['event_duration_days'] ) ? (int)$gd_post['event_duration_days'] : 1; $repeat_x = !empty( $gd_post['recurring_interval'] ) ? (int)$gd_post['recurring_interval'] : 1; $max_repeat = !empty( $gd_post['max_recurring_count'] ) ? (int)$gd_post['max_recurring_count'] : 1; $repeat_end = !empty( $gd_post['recurring_end_date'] ) ? geodir_date($gd_post['recurring_end_date'], 'Y-m-d') : ''; $repeat_end_type = $repeat_end != '' ? 1 : 0; $max_repeat = $repeat_end != '' ? '' : $max_repeat; $week_days = array_flip(array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat')); $a_repeat_days = isset($gd_post['recurring_week_days']) && trim($gd_post['recurring_week_days'])!='' ? explode(',', trim($gd_post['recurring_week_days'])) : array(); $repeat_days = array(); if (!empty($a_repeat_days)) { foreach ($a_repeat_days as $repeat_day) { $repeat_day = geodir_strtolower(trim($repeat_day)); if ($repeat_day != '' && isset($week_days[$repeat_day])) { $repeat_days[] = $week_days[$repeat_day]; } } $repeat_days = array_unique($repeat_days); } $a_repeat_weeks = isset($gd_post['recurring_week_nos']) && trim($gd_post['recurring_week_nos']) != '' ? explode(",", trim($gd_post['recurring_week_nos'])) : array(); $repeat_weeks = array(); if (!empty($a_repeat_weeks)) { foreach ($a_repeat_weeks as $repeat_week) { $repeat_weeks[] = (int)$repeat_week; } $repeat_weeks = array_unique($repeat_weeks); } } } if (isset($gd_post['recurring_dates'])) { unset($gd_post['recurring_dates']); } $gd_post['is_recurring'] = $is_recurring; $gd_post['event_date'] = $event_date; $gd_post['event_start'] = $event_date; $gd_post['event_end'] = $event_enddate; $gd_post['all_day'] = $all_day; $gd_post['starttime'] = $starttime; $gd_post['endtime'] = $endtime; $gd_post['repeat_type'] = $repeat_type; $gd_post['different_times'] = $different_times; $gd_post['starttimes'] = $starttimes; $gd_post['endtimes'] = $endtimes; $gd_post['repeat_days'] = $repeat_days; $gd_post['repeat_weeks'] = $repeat_weeks; $gd_post['event_recurring_dates'] = $event_recurring_dates; $gd_post['repeat_x'] = $repeat_x; $gd_post['duration_x'] = $duration_x; $gd_post['repeat_end_type'] = $repeat_end_type; $gd_post['max_repeat'] = $max_repeat; $gd_post['repeat_end'] = $repeat_end; return $gd_post; }