/** * Find a location with same name, address and town as supplied array * @param $location * @return array */ function dbem_get_identical_location($location) { $EM_Location = new EM_Location($location); return $EM_Location->load_similar(); }
/** * Retrieve event, location and recurring information via POST * @return boolean */ function get_post() { //Build Event Array do_action('em_event_get_post_pre', $this); $this->name = !empty($_POST['event_name']) ? stripslashes($_POST['event_name']) : ''; $this->start_date = !empty($_POST['event_start_date']) ? $_POST['event_start_date'] : ''; $this->end_date = !empty($_POST['event_end_date']) ? $_POST['event_end_date'] : $this->start_date; $this->rsvp = !empty($_POST['event_rsvp']) ? 1 : 0; $this->seats = !empty($_POST['event_seats']) && is_numeric($_POST['event_seats']) ? $_POST['event_seats'] : 0; $this->notes = !empty($_POST['content']) ? stripslashes($_POST['content']) : ''; //WP TinyMCE field //Sort out time //TODO make time handling less painful $match = array(); if (!empty($_POST['event_start_time']) && preg_match('/^([01]\\d|2[0-3]):([0-5]\\d)(AM|PM)?$/', $_POST['event_start_time'], $match)) { if ($match[3] == 'PM' && $match[1] != 12) { $match[1] = 12 + $match[1]; } elseif ($match[3] == 'AM' && $match[1] == 12) { $match[1] = '00'; } $this->start_time = $match[1] . ":" . $match[2] . ":00"; } else { $this->start_time = "00:00:00"; } if (!empty($_POST['event_end_time']) && preg_match('/^([01]\\d|2[0-3]):([0-5]\\d)(AM|PM)?$/', $_POST['event_end_time'], $match)) { if ($match[3] == 'PM' && $match[1] != 12) { $match[1] = 12 + $match[1]; } elseif ($match[3] == 'AM' && $match[1] == 12) { $match[1] = '00'; } $this->end_time = $match[1] . ":" . $match[2] . ":00"; } else { $this->end_time = $this->start_time; } //Start/End times should be available as timestamp $this->start = strtotime($this->start_date . " " . $this->start_time); $this->end = strtotime($this->end_date . " " . $this->end_time); //Contact Person if (!empty($_POST['event_contactperson_id']) && is_numeric($_POST['event_contactperson_id'])) { //TODO contactperson choices needs limiting depending on role $this->contactperson_id = $_POST['event_contactperson_id']; } //category if (!empty($_POST['event_category_id']) && is_numeric($_POST['event_category_id'])) { $this->category_id = $_POST['event_category_id']; } //Attributes $event_attributes = array(); for ($i = 1; !empty($_POST["mtm_{$i}_ref"]) && trim($_POST["mtm_{$i}_ref"]) != ''; $i++) { if (!empty($_POST["mtm_{$i}_name"]) && trim($_POST["mtm_{$i}_name"]) != '') { $event_attributes[$_POST["mtm_{$i}_ref"]] = stripslashes($_POST["mtm_{$i}_name"]); } } $this->attributes = $event_attributes; //Recurrence data $this->recurrence_id = !empty($_POST['recurrence_id']) && is_numeric($_POST['recurrence_id']) ? $_POST['recurrence_id'] : 0; if (!empty($_POST['repeated_event'])) { $this->recurrence = 1; $this->freq = !empty($_POST['recurrence_freq']) && in_array($_POST['recurrence_freq'], array('daily', 'weekly', 'monthly')) ? $_POST['recurrence_freq'] : 'daily'; if (!empty($_POST['recurrence_bydays']) && $this->freq == 'weekly' && self::array_is_numeric($_POST['recurrence_bydays'])) { $this->byday = implode(",", $_POST['recurrence_bydays']); } elseif (!empty($_POST['recurrence_byday']) && $this->freq == 'monthly') { $this->byday = $_POST['recurrence_byday']; } $this->interval = !empty($_POST['recurrence_interval']) ? $_POST['recurrence_interval'] : 1; $this->byweekno = !empty($_POST['recurrence_byweekno']) ? $_POST['recurrence_byweekno'] : ''; } //Add location information, or just link to previous location, this is a requirement... if (!empty($_POST['location-select-id'])) { $this->location = new EM_Location($_POST['location-select-id']); } else { $this->location = new EM_Location($_POST); $this->location->load_similar($_POST); } return apply_filters('em_event_get_post', $this->validate(), $this); }