function eme_locations_page() { $current_userid = get_current_user_id(); if (isset($_GET['eme_admin_action']) && $_GET['eme_admin_action'] == "edit_location") { $location_id = intval($_GET['location_id']); $location = eme_get_location($location_id); if (current_user_can(get_option('eme_cap_edit_locations')) || current_user_can(get_option('eme_cap_author_locations')) && $location['location_author'] == $current_userid) { // edit location eme_locations_edit_layout($location); } else { $message = __('You have no right to edit this location!', 'eme'); eme_locations_table_layout($message); } } elseif (isset($_GET['eme_admin_action']) && $_GET['eme_admin_action'] == "copy_location") { $location_id = intval($_GET['location_id']); $location = eme_get_location($location_id); // make it look like a new location unset($location['location_id']); $location['location_name'] .= __(" (Copy)", "eme"); if (current_user_can(get_option('eme_cap_add_locations'))) { eme_locations_edit_layout($location); } else { $message = __('You have no right to copy this location!', 'eme'); eme_locations_table_layout($message); } } elseif (isset($_POST['eme_admin_action']) && $_POST['eme_admin_action'] == "add_location") { if (current_user_can(get_option('eme_cap_add_locations'))) { $location = eme_new_location(); eme_locations_edit_layout($location); } else { $message = __('You have no right to add a location!', 'eme'); eme_locations_table_layout($message); } } elseif (isset($_POST['eme_admin_action']) && $_POST['eme_admin_action'] == "delete_location" && isset($_POST['locations'])) { $locations = $_POST['locations']; foreach ($locations as $location_id) { $location = eme_get_location(intval($location_id)); if (current_user_can(get_option('eme_cap_edit_locations')) || current_user_can(get_option('eme_cap_author_locations')) && $location['location_author'] == $current_userid) { eme_delete_location(intval($location_id)); } } $message = __('Successfully deleted the selected locations.', 'eme'); eme_locations_table_layout($message); } elseif (isset($_POST['eme_admin_action']) && ($_POST['eme_admin_action'] == "do_editlocation" || $_POST['eme_admin_action'] == "do_addlocation")) { $action = $_POST['eme_admin_action']; if ($action == "do_editlocation") { $orig_location = eme_get_location(intval($_POST['location_id'])); } if ($action == "do_addlocation" && !current_user_can(get_option('eme_cap_add_locations'))) { $message = __('You have no right to add a location!', 'eme'); eme_locations_table_layout($message); } elseif ($action == "do_editlocation" && !(current_user_can(get_option('eme_cap_edit_locations')) || current_user_can(get_option('eme_cap_author_locations')) && $orig_location['location_author'] == $current_userid)) { $message = __('You have no right to edit this location!', 'eme'); eme_locations_table_layout($message); } else { $location = eme_new_location(); $location['location_name'] = trim(stripslashes($_POST['location_name'])); $location['location_address'] = stripslashes($_POST['location_address']); $location['location_town'] = stripslashes($_POST['location_town']); $location['location_description'] = stripslashes($_POST['content']); $location['location_url'] = isset($_POST['location_url']) ? eme_strip_tags($_POST['location_url']) : ''; $location['location_image_url'] = isset($_POST['location_image_url']) ? eme_strip_tags($_POST['location_image_url']) : ''; $location['location_image_id'] = isset($_POST['location_image_id']) ? intval($_POST['location_image_id']) : 0; $location['location_slug'] = isset($_POST['location_slug']) ? eme_permalink_convert(eme_strip_tags($_POST['location_slug'])) : eme_permalink_convert($location['location_name']); // we don't change the author //$location['location_author'] = $current_userid; if (isset($_POST['location_category_ids'])) { // the category id's need to begin and end with a comma // this is needed so we can later search for a specific // cat using LIKE '%,$cat,%' $location['location_category_ids'] = ""; foreach ($_POST['location_category_ids'] as $cat) { if (is_numeric($cat)) { if (empty($location['location_category_ids'])) { $location['location_category_ids'] = "{$cat}"; } else { $location['location_category_ids'] .= ",{$cat}"; } } } } else { $location['location_category_ids'] = ""; } $location['location_latitude'] = $_POST['location_latitude']; $location['location_longitude'] = $_POST['location_longitude']; if (empty($location['location_latitude'])) { $location['location_latitude'] = 0; $location['location_longitude'] = 0; } $location_attributes = array(); for ($i = 1; isset($_POST["mtm_{$i}_ref"]) && trim($_POST["mtm_{$i}_ref"]) != ''; $i++) { if (trim($_POST["mtm_{$i}_name"]) != '') { $location_attributes[$_POST["mtm_{$i}_ref"]] = stripslashes($_POST["mtm_{$i}_name"]); } } $location['location_attributes'] = serialize($location_attributes); $location_properties = array(); $location_properties = eme_init_location_props($location_properties); foreach ($_POST as $key => $value) { if (preg_match('/eme_loc_prop_(.+)/', $key, $matches)) { $location_properties[$matches[1]] = stripslashes($value); } } $location['location_properties'] = serialize($location_properties); $validation_result = eme_validate_location($location); if ($validation_result == "OK") { if ($action == "do_addlocation") { $new_location = eme_insert_location($location); if ($new_location) { $message = __('The location has been added.', 'eme'); } else { $message = __('There has been a problem adding the location.', 'eme'); } } elseif ($action == "do_editlocation") { $location['location_id'] = intval($_POST['location_id']); if (eme_update_location($location)) { $message = __('The location has been updated.', 'eme'); } else { $message = __('The location update failed.', 'eme'); } } eme_locations_table_layout($message); } else { $message = $validation_result; eme_locations_edit_layout($location, $message); } } } else { // no action, just a locations list eme_locations_table_layout(); } }
/** * Function that processes the data for a new location * */ function processLocation($event_data) { global $wpdb; if (isset($event_data['location_name']) && '' != $event_data['location_name']) { $event_data['location_name'] = esc_attr($event_data['location_name']); } if (isset($event_data['location_address']) && '' != $event_data['location_address']) { $event_data['location_address'] = esc_attr($event_data['location_address']); } if (isset($event_data['location_town']) && '' != $event_data['location_town']) { $event_data['location_town'] = esc_attr($event_data['location_town']); } if (!empty($event_data['location_name']) && !empty($event_data['location_address']) && !empty($event_data['location_town'])) { $locations_table = $wpdb->prefix . 'dbem_locations'; $sql = sprintf("SELECT * FROM %s WHERE location_town = '%s' AND location_address = '%s'", $locations_table, $event_data['location_town'], $event_data['location_address']); $location = $wpdb->get_row($sql, ARRAY_A); if (!$location['location_id']) { $location = array('location_name' => $event_data['location_name'], 'location_address' => $event_data['location_address'], 'location_town' => $event_data['location_town'], 'location_latitude' => $event_data['location_latitude'], 'location_longitude' => $event_data['location_longitude']); $location = eme_insert_location($location); } $event_data['location_id'] = $location['location_id']; } return $event_data; }
function eme_events_page() { global $wpdb, $eme_timezone; $extra_conditions = array(); $action = isset($_GET['eme_admin_action']) ? $_GET['eme_admin_action'] : ''; $event_ID = isset($_GET['event_id']) ? intval($_GET['event_id']) : ''; $recurrence_ID = isset($_GET['recurrence_id']) ? intval($_GET['recurrence_id']) : ''; $selectedEvents = isset($_GET['events']) ? $_GET['events'] : ''; $current_userid = get_current_user_id(); // if the delete event button is pushed while editing an event, set the action if (isset($_POST['event_delete_button'])) { $selectedEvents = array($event_ID); $action = "deleteEvents"; } // if the delete recurrence button is pushed while editing a recurrence, set the action if (isset($_POST['event_deleteRecurrence_button'])) { $recurrence = eme_get_recurrence($recurrence_ID); $selectedEvents = array($recurrence['event_id']); $action = "deleteRecurrence"; } // in case some generic actions were taken (like disable hello or disable donate), ignore all other actions if (isset($_GET['disable_hello_to_user']) || isset($_GET['disable_donate_message']) || isset($_GET['dbupdate']) || isset($_GET['disable_legacy_warning'])) { $action = ""; } if ($action == 'publicEvents') { if (current_user_can(get_option('eme_cap_edit_events'))) { eme_change_event_state($selectedEvents, STATUS_PUBLIC); $feedback_message = __('Event(s) published!', 'eme'); } else { $feedback_message = __('You have no right to edit events!', 'eme'); } eme_events_table($feedback_message); return; } if ($action == 'privateEvents') { if (current_user_can(get_option('eme_cap_edit_events'))) { eme_change_event_state($selectedEvents, STATUS_PRIVATE); $feedback_message = __('Event(s) made private!', 'eme'); } else { $feedback_message = __('You have no right to edit events!', 'eme'); } eme_events_table($feedback_message); return; } if ($action == 'draftEvents') { if (current_user_can(get_option('eme_cap_edit_events'))) { eme_change_event_state($selectedEvents, STATUS_DRAFT); $feedback_message = __('Event(s) changed to draft!', 'eme'); } else { $feedback_message = __('You have no right to edit events!', 'eme'); } eme_events_table($feedback_message); return; } // DELETE action (either from the event list, or when the delete button is pushed while editing an event) if ($action == 'deleteEvents') { if (current_user_can(get_option('eme_cap_edit_events'))) { foreach ($selectedEvents as $event_ID) { $tmp_event = array(); $tmp_event = eme_get_event($event_ID); if ($tmp_event['recurrence_id'] > 0) { # if the event is part of a recurrence and it is the last event of the recurrence, delete the recurrence # else just delete the singe event if (eme_recurrence_count($tmp_event['recurrence_id']) == 1) { $tmp_recurrence = eme_get_recurrence($tmp_event['recurrence_id']); eme_db_delete_recurrence($tmp_event, $tmp_recurrence); } else { eme_db_delete_event($tmp_event); } } else { eme_db_delete_event($tmp_event); } } $feedback_message = __('Event(s) deleted!', 'eme'); } else { $feedback_message = __('You have no right to delete events!', 'eme'); } eme_events_table($feedback_message); return; } // DELETE action (either from the event list, or when the delete button is pushed while editing a recurrence) if ($action == 'deleteRecurrence') { if (current_user_can(get_option('eme_cap_edit_events'))) { foreach ($selectedEvents as $event_ID) { $tmp_event = array(); $tmp_event = eme_get_event($event_ID); if ($tmp_event['recurrence_id'] > 0) { $tmp_recurrence = eme_get_recurrence($tmp_event['recurrence_id']); eme_db_delete_recurrence($tmp_event, $tmp_recurrence); } } $feedback_message = __('Event(s) deleted!', 'eme'); } else { $feedback_message = __('You have no right to delete events!', 'eme'); } eme_events_table($feedback_message); return; } // UPDATE or CREATE action if ($action == 'insert_event' || $action == 'update_event' || $action == 'update_recurrence') { if (!(current_user_can(get_option('eme_cap_add_event')) || current_user_can(get_option('eme_cap_edit_events')))) { $feedback_message = __('You have no right to insert or update events', 'eme'); eme_events_table($feedback_message); return; } $event = array(); $location = eme_new_location(); $event['event_name'] = isset($_POST['event_name']) ? trim(stripslashes($_POST['event_name'])) : ''; if (!current_user_can(get_option('eme_cap_publish_event'))) { $event['event_status'] = STATUS_DRAFT; } else { $event['event_status'] = isset($_POST['event_status']) ? stripslashes($_POST['event_status']) : get_option('eme_event_initial_state'); } $event['event_start_date'] = isset($_POST['event_start_date']) ? $_POST['event_start_date'] : ''; // for compatibility: check also the POST variable event_date $event['event_start_date'] = isset($_POST['event_date']) ? $_POST['event_date'] : $event['event_start_date']; $event['event_end_date'] = isset($_POST['event_end_date']) ? $_POST['event_end_date'] : ''; if (!_eme_is_date_valid($event['event_start_date'])) { $event['event_start_date'] = ""; } if (!_eme_is_date_valid($event['event_end_date'])) { $event['event_end_date'] = ""; } $eme_date_obj = new ExpressiveDate(null, $eme_timezone); if (isset($_POST['event_start_time']) && !empty($_POST['event_start_time'])) { $event['event_start_time'] = $eme_date_obj->setTimestampFromString($_POST['event_start_time'] . " " . $eme_timezone)->format("H:i:00"); } else { $event['event_start_time'] = "00:00:00"; } if (isset($_POST['event_end_time']) && !empty($_POST['event_end_time'])) { $event['event_end_time'] = $eme_date_obj->setTimestampFromString($_POST['event_end_time'] . " " . $eme_timezone)->format("H:i:00"); } else { $event['event_end_time'] = "00:00:00"; } $recurrence['recurrence_freq'] = isset($_POST['recurrence_freq']) ? $_POST['recurrence_freq'] : ''; if ($recurrence['recurrence_freq'] == 'specific') { $recurrence['recurrence_specific_days'] = isset($_POST['recurrence_start_date']) ? $_POST['recurrence_start_date'] : $event['event_start_date']; $recurrence['recurrence_start_date'] = ""; $recurrence['recurrence_end_date'] = ""; } else { $recurrence['recurrence_specific_days'] = ""; $recurrence['recurrence_start_date'] = isset($_POST['recurrence_start_date']) ? $_POST['recurrence_start_date'] : $event['event_start_date']; $recurrence['recurrence_end_date'] = isset($_POST['recurrence_end_date']) ? $_POST['recurrence_end_date'] : $event['event_end_date']; } if (!_eme_is_date_valid($recurrence['recurrence_start_date'])) { $recurrence['recurrence_start_date'] = ""; } if (!_eme_is_date_valid($recurrence['recurrence_end_date'])) { $recurrence['recurrence_end_date'] = $recurrence['recurrence_start_date']; } if (!_eme_are_dates_valid($recurrence['recurrence_specific_days'])) { $recurrence['recurrence_specific_days'] = ""; } if ($recurrence['recurrence_freq'] == 'weekly') { if (isset($_POST['recurrence_bydays'])) { $recurrence['recurrence_byday'] = implode(",", $_POST['recurrence_bydays']); } else { $recurrence['recurrence_byday'] = ''; } } else { if (isset($_POST['recurrence_byday'])) { $recurrence['recurrence_byday'] = $_POST['recurrence_byday']; } else { $recurrence['recurrence_byday'] = ''; } } $recurrence['recurrence_interval'] = isset($_POST['recurrence_interval']) ? $_POST['recurrence_interval'] : 1; if ($recurrence['recurrence_interval'] == 0) { $recurrence['recurrence_interval'] = 1; } $recurrence['recurrence_byweekno'] = isset($_POST['recurrence_byweekno']) ? $_POST['recurrence_byweekno'] : ''; $event['event_rsvp'] = isset($_POST['event_rsvp']) && is_numeric($_POST['event_rsvp']) ? $_POST['event_rsvp'] : 0; $event['rsvp_number_days'] = isset($_POST['rsvp_number_days']) && is_numeric($_POST['rsvp_number_days']) ? $_POST['rsvp_number_days'] : 0; $event['rsvp_number_hours'] = isset($_POST['rsvp_number_hours']) && is_numeric($_POST['rsvp_number_hours']) ? $_POST['rsvp_number_hours'] : 0; $event['registration_requires_approval'] = isset($_POST['registration_requires_approval']) && is_numeric($_POST['registration_requires_approval']) ? $_POST['registration_requires_approval'] : 0; $event['registration_wp_users_only'] = isset($_POST['registration_wp_users_only']) && is_numeric($_POST['registration_wp_users_only']) ? $_POST['registration_wp_users_only'] : 0; $event['event_seats'] = isset($_POST['event_seats']) ? $_POST['event_seats'] : 0; if (preg_match("/\\|\\|/", $event['event_seats'])) { $multiseat = preg_split("/\\|\\|/", $event['event_seats']); foreach ($multiseat as $key => $value) { if (!is_numeric($value)) { $multiseat[$key] = 0; } } $event['event_seats'] = eme_convert_array2multi($multiseat); } else { if (!is_numeric($event['event_seats'])) { $event['event_seats'] = 0; } } $event['use_paypal'] = isset($_POST['use_paypal']) && is_numeric($_POST['use_paypal']) ? $_POST['use_paypal'] : 0; $event['use_2co'] = isset($_POST['use_2co']) && is_numeric($_POST['use_2co']) ? $_POST['use_2co'] : 0; $event['use_webmoney'] = isset($_POST['use_webmoney']) && is_numeric($_POST['use_webmoney']) ? $_POST['use_webmoney'] : 0; $event['use_fdgg'] = isset($_POST['use_fdgg']) && is_numeric($_POST['use_fdgg']) ? $_POST['use_fdgg'] : 0; $event['use_mollie'] = isset($_POST['use_mollie']) && is_numeric($_POST['use_mollie']) ? $_POST['use_mollie'] : 0; $event['use_sagepay'] = isset($_POST['use_sagepay']) && is_numeric($_POST['use_sagepay']) ? $_POST['use_sagepay'] : 0; $event['price'] = isset($_POST['price']) ? $_POST['price'] : 0; if (preg_match("/\\|\\|/", $event['price'])) { $multiprice = preg_split("/\\|\\|/", $event['price']); foreach ($multiprice as $key => $value) { if (!is_numeric($value)) { $multiprice[$key] = 0; } } $event['price'] = eme_convert_array2multi($multiprice); } else { if (!is_numeric($event['price'])) { $event['price'] = 0; } } $event['currency'] = isset($_POST['currency']) ? $_POST['currency'] : ""; if (isset($_POST['event_contactperson_id']) && $_POST['event_contactperson_id'] != '') { $event['event_contactperson_id'] = $_POST['event_contactperson_id']; } else { $event['event_contactperson_id'] = 0; } //if (! _eme_is_time_valid ( $event_end_time )) // $event_end_time = $event_start_time; $location['location_name'] = isset($_POST['location_name']) ? trim(stripslashes($_POST['location_name'])) : ''; $location['location_address'] = isset($_POST['location_address']) ? stripslashes($_POST['location_address']) : ''; $location['location_town'] = isset($_POST['location_town']) ? stripslashes($_POST['location_town']) : ''; $location['location_latitude'] = isset($_POST['location_latitude']) ? $_POST['location_latitude'] : ''; $location['location_longitude'] = isset($_POST['location_longitude']) ? $_POST['location_longitude'] : ''; $location['location_author'] = $current_userid; $location['location_description'] = ""; //switched to WP TinyMCE field //$event['event_notes'] = stripslashes ( $_POST['event_notes'] ); $event['event_notes'] = isset($_POST['content']) ? stripslashes($_POST['content']) : ''; $event['event_page_title_format'] = isset($_POST['event_page_title_format']) ? stripslashes($_POST['event_page_title_format']) : ''; $event['event_single_event_format'] = isset($_POST['event_single_event_format']) ? stripslashes($_POST['event_single_event_format']) : ''; $event['event_contactperson_email_body'] = isset($_POST['event_contactperson_email_body']) ? stripslashes($_POST['event_contactperson_email_body']) : ''; $event['event_registration_recorded_ok_html'] = isset($_POST['event_registration_recorded_ok_html']) ? stripslashes($_POST['event_registration_recorded_ok_html']) : ''; $event['event_respondent_email_body'] = isset($_POST['event_respondent_email_body']) ? stripslashes($_POST['event_respondent_email_body']) : ''; $event['event_registration_pending_email_body'] = isset($_POST['event_registration_pending_email_body']) ? stripslashes($_POST['event_registration_pending_email_body']) : ''; $event['event_registration_updated_email_body'] = isset($_POST['event_registration_updated_email_body']) ? stripslashes($_POST['event_registration_updated_email_body']) : ''; $event['event_registration_cancelled_email_body'] = isset($_POST['event_registration_cancelled_email_body']) ? stripslashes($_POST['event_registration_cancelled_email_body']) : ''; $event['event_registration_denied_email_body'] = isset($_POST['event_registration_denied_email_body']) ? stripslashes($_POST['event_registration_denied_email_body']) : ''; $event['event_registration_form_format'] = isset($_POST['event_registration_form_format']) ? stripslashes($_POST['event_registration_form_format']) : ''; $event['event_cancel_form_format'] = isset($_POST['event_cancel_form_format']) ? stripslashes($_POST['event_cancel_form_format']) : ''; $event['event_url'] = isset($_POST['event_url']) ? eme_strip_tags($_POST['event_url']) : ''; $event['event_image_url'] = isset($_POST['event_image_url']) ? eme_strip_tags($_POST['event_image_url']) : ''; $event['event_image_id'] = isset($_POST['event_image_id']) ? intval($_POST['event_image_id']) : 0; $event['event_slug'] = isset($_POST['event_slug']) ? eme_permalink_convert(eme_strip_tags($_POST['event_slug'])) : eme_permalink_convert($event['event_name']); if (isset($_POST['event_category_ids'])) { // the category id's need to begin and end with a comma // this is needed so we can later search for a specific // cat using LIKE '%,$cat,%' $event['event_category_ids'] = ""; foreach ($_POST['event_category_ids'] as $cat) { if (is_numeric($cat)) { if (empty($event['event_category_ids'])) { $event['event_category_ids'] = "{$cat}"; } else { $event['event_category_ids'] .= ",{$cat}"; } } } } else { $event['event_category_ids'] = ""; } $event_attributes = array(); for ($i = 1; isset($_POST["mtm_{$i}_ref"]) && trim($_POST["mtm_{$i}_ref"]) != ''; $i++) { if (trim($_POST["mtm_{$i}_name"]) != '') { $event_attributes[$_POST["mtm_{$i}_ref"]] = stripslashes($_POST["mtm_{$i}_name"]); } } $event['event_attributes'] = serialize($event_attributes); $event_properties = array(); $event_properties = eme_init_event_props($event_properties); foreach ($_POST as $key => $value) { if (preg_match('/eme_prop_(.+)/', $key, $matches)) { $event_properties[$matches[1]] = stripslashes($value); } } $event['event_properties'] = serialize($event_properties); $validation_result = eme_validate_event($event); if ($validation_result != "OK") { // validation unsuccessful echo "<div id='message' class='error '>\n <p>" . __("Ach, there's a problem here:", "eme") . " {$validation_result}</p>\n </div>"; eme_event_form($event, "Edit event {$event_ID}", $event_ID); return; } // validation successful if (isset($_POST['location-select-id']) && $_POST['location-select-id'] != "") { $event['location_id'] = $_POST['location-select-id']; } else { if (empty($location['location_name']) && empty($location['location_address']) && empty($location['location_town'])) { $event['location_id'] = 0; } else { $related_location_id = eme_get_identical_location_id($location['location_name'], $location['location_address'], $location['location_town']); // print_r($related_location); if ($related_location_id) { $event['location_id'] = $related_location_id; } else { $new_location = eme_insert_location($location); if (!$new_location) { echo "<div id='message' class='error '>\n <p>" . __("Could not create the new location for this event: either you don't have the right to insert locations or there's a DB problem.", "eme") . "</p>\n </div>"; return; } $event['location_id'] = $new_location['location_id']; } } } if (!$event_ID && !$recurrence_ID) { $event['event_author'] = $current_userid; // new event or new recurrence if (isset($_POST['repeated_event']) && $_POST['repeated_event']) { //insert new recurrence if (!eme_db_insert_recurrence($event, $recurrence)) { $feedback_message = __('Database insert failed!', 'eme'); } else { $feedback_message = __('New recurrent event inserted!', 'eme'); //if (has_action('eme_insert_event_action')) do_action('eme_insert_event_action',$event); } } else { // INSERT new event if (!eme_db_insert_event($event)) { $feedback_message = __('Database insert failed!', 'eme'); } else { $feedback_message = __('New event successfully inserted!', 'eme'); } } } else { // something exists if ($recurrence_ID) { $tmp_recurrence = eme_get_recurrence($recurrence_ID); if (current_user_can(get_option('eme_cap_edit_events')) || current_user_can(get_option('eme_cap_author_event')) && ($tmp_recurrence['event_author'] == $current_userid || $tmp_recurrence['event_contactperson_id'] == $current_userid)) { // UPDATE old recurrence $recurrence['recurrence_id'] = $recurrence_ID; if (eme_db_update_recurrence($event, $recurrence)) { $feedback_message = __('Recurrence updated!', 'eme'); //if (has_action('eme_update_event_action')) do_action('eme_update_event_action',$event); } else { $feedback_message = __('Something went wrong with the recurrence update...', 'eme'); } } else { $feedback_message = sprintf(__("You have no right to update '%s'", 'eme'), $tmp_event['event_name']); } } else { $tmp_event = eme_get_event($event_ID); if (current_user_can(get_option('eme_cap_edit_events')) || current_user_can(get_option('eme_cap_author_event')) && ($tmp_event['event_author'] == $current_userid || $tmp_event['event_contactperson_id'] == $current_userid)) { if (isset($_POST['repeated_event']) && $_POST['repeated_event']) { // we go from single event to recurrence: create the recurrence and delete the single event eme_db_insert_recurrence($event, $recurrence); eme_db_delete_event($tmp_event); $feedback_message = __('New recurrent event inserted!', 'eme'); //if (has_action('eme_insert_event_action')) do_action('eme_insert_event_action',$event); } else { // UPDATE old event // unlink from recurrence in case it was generated by one $event['recurrence_id'] = 0; if (eme_db_update_event($event, $event_ID)) { $feedback_message = sprintf(__("Updated '%s'", 'eme'), $event['event_name']); } else { $feedback_message = sprintf(__("Failed to update '%s'", 'eme'), $event['event_name']); } //if (has_action('eme_update_event_action')) do_action('eme_update_event_action',$event); } } else { $feedback_message = sprintf(__("You have no right to update '%s'", 'eme'), $tmp_event['event_name']); } } } //$wpdb->query($sql); eme_events_table($feedback_message); return; } if ($action == 'edit_event') { if (!$event_ID) { if (current_user_can(get_option('eme_cap_add_event'))) { $title = __("Insert New Event", 'eme'); eme_event_form($event, $title, $event_ID); } else { $feedback_message = __('You have no right to add events!', 'eme'); eme_events_table($feedback_message); } } else { $event = eme_get_event($event_ID); if (current_user_can(get_option('eme_cap_edit_events')) || current_user_can(get_option('eme_cap_author_event')) && ($event['event_author'] == $current_userid || $event['event_contactperson_id'] == $current_userid)) { // UPDATE event $title = sprintf(__("Edit Event '%s'", 'eme'), $event['event_name']); eme_event_form($event, $title, $event_ID); } else { $feedback_message = sprintf(__("You have no right to update '%s'", 'eme'), $event['event_name']); eme_events_table($feedback_message); } } return; } //Add duplicate event if requested if ($action == 'duplicate_event') { $event = eme_get_event($event_ID); // make it look like a new event unset($event['event_id']); unset($event['recurrence_id']); $event['event_name'] .= __(" (Copy)", "eme"); if (current_user_can(get_option('eme_cap_edit_events')) || current_user_can(get_option('eme_cap_author_event')) && ($event['event_author'] == $current_userid || $event['event_contactperson_id'] == $current_userid)) { $title = sprintf(__("Edit event copy '%s'", 'eme'), $event['event_name']); eme_event_form($event, $title, 0); } else { $feedback_message = sprintf(__("You have no right to copy '%s'", 'eme'), $event['event_name']); eme_events_table($feedback_message); } return; } if ($action == 'edit_recurrence') { $recurrence = eme_get_recurrence($recurrence_ID); if (current_user_can(get_option('eme_cap_edit_events')) || current_user_can(get_option('eme_cap_author_event')) && ($recurrence['event_author'] == $current_userid || $recurrence['event_contactperson_id'] == $current_userid)) { $title = __("Edit Recurrence", 'eme') . " '" . $recurrence['event_name'] . "'"; eme_event_form($recurrence, $title, $recurrence_ID); } else { $feedback_message = __('You have no right to update', 'eme') . " '" . $recurrence['event_name'] . "' !"; eme_events_table($feedback_message); } return; } if ($action == "-1" || $action == "") { // No action, only showing the events list $scope = isset($_GET['scope']) ? $_GET['scope'] : ''; switch ($scope) { case "past": $title = __('Past Events', 'eme'); break; case "all": $title = __('All Events', 'eme'); break; default: $title = __('Future Events', 'eme'); $scope = "future"; } eme_events_table("", $scope); return; } }