本文整理汇总了PHP中EM_Event::save方法的典型用法代码示例。如果您正苦于以下问题:PHP EM_Event::save方法的具体用法?PHP EM_Event::save怎么用?PHP EM_Event::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EM_Event
的用法示例。
在下文中一共展示了EM_Event::save方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: em_admin_event_actions
function em_admin_event_actions()
{
if (current_user_can(EM_MIN_CAPABILITY) && !empty($_GET['page']) && $_GET['page'] == 'events-manager-event' && !empty($_REQUEST['action'])) {
global $wpdb;
global $EM_Event;
//if dealing with new event, we still want an event object
if (!is_object($EM_Event)) {
$EM_Event = new EM_Event();
}
// UPDATE or CREATE action
if ($_REQUEST['action'] == 'save') {
$validation = $EM_Event->get_post();
if ($validation) {
//EM_Event gets the event if submitted via POST and validates it (safer than to depend on JS)
//Save
if ($EM_Event->save()) {
$page = !empty($_REQUEST['pno']) ? $_REQUEST['pno'] : '';
$scope = !empty($_REQUEST['scope']) ? $_REQUEST['scope'] : '';
wp_redirect(get_bloginfo('wpurl') . '/wp-admin/admin.php?page=events-manager&p=' . $page . '&scope=' . $scope . '&message=' . urlencode($EM_Event->feedback_message));
}
}
//errors added automatically to event global object
}
//Copy the event
if ($_REQUEST['action'] == 'duplicate') {
global $EZSQL_ERROR;
$EM_Event = $EM_Event->duplicate();
if ($EM_Event === false) {
$redirect_url = em_add_get_params($_SERVER['HTTP_REFERER'], array('error' => __('There was an error duplicating the event. Try again maybe?', 'dbem'), 'message' => ''), false);
wp_redirect($redirect_url);
} else {
$page = !empty($_REQUEST['pno']) ? $_REQUEST['pno'] : '';
$scope = !empty($_REQUEST['scope']) ? $_REQUEST['scope'] : '';
wp_redirect(get_bloginfo('wpurl') . '/wp-admin/admin.php?page=events-manager-event&event_id=' . $EM_Event->id . '&p=' . $page . '&scope=' . $scope . '&message=' . urlencode($EM_Event->feedback_message));
}
}
}
}
示例2: em_init_actions
/**
* Performs actions on init. This works for both ajax and normal requests, the return results depends if an em_ajax flag is passed via POST or GET.
*/
function em_init_actions()
{
global $wpdb, $EM_Notices, $EM_Event;
if (defined('DOING_AJAX') && DOING_AJAX) {
$_REQUEST['em_ajax'] = true;
}
//NOTE - No EM objects are globalized at this point, as we're hitting early init mode.
//TODO Clean this up.... use a uniformed way of calling EM Ajax actions
if (!empty($_REQUEST['em_ajax']) || !empty($_REQUEST['em_ajax_action'])) {
if (isset($_REQUEST['em_ajax_action']) && $_REQUEST['em_ajax_action'] == 'get_location') {
if (isset($_REQUEST['id'])) {
$EM_Location = new EM_Location($_REQUEST['id'], 'location_id');
$location_array = $EM_Location->to_array();
$location_array['location_balloon'] = $EM_Location->output(get_option('dbem_location_baloon_format'));
echo EM_Object::json_encode($location_array);
}
die;
}
if (isset($_REQUEST['em_ajax_action']) && $_REQUEST['em_ajax_action'] == 'delete_ticket') {
if (isset($_REQUEST['id'])) {
$EM_Ticket = new EM_Ticket($_REQUEST['id']);
$result = $EM_Ticket->delete();
if ($result) {
$result = array('result' => true);
} else {
$result = array('result' => false, 'error' => $EM_Ticket->feedback_message);
}
} else {
$result = array('result' => false, 'error' => __('No ticket id provided', 'dbem'));
}
echo EM_Object::json_encode($result);
die;
}
if (isset($_REQUEST['query']) && $_REQUEST['query'] == 'GlobalMapData') {
$EM_Locations = EM_Locations::get($_REQUEST);
$json_locations = array();
foreach ($EM_Locations as $location_key => $EM_Location) {
$json_locations[$location_key] = $EM_Location->to_array();
$json_locations[$location_key]['location_balloon'] = $EM_Location->output(get_option('dbem_map_text_format'));
}
echo EM_Object::json_encode($json_locations);
die;
}
if (isset($_REQUEST['ajaxCalendar']) && $_REQUEST['ajaxCalendar']) {
//FIXME if long events enabled originally, this won't show up on ajax call
echo EM_Calendar::output($_REQUEST, false);
die;
}
}
//Event Actions
if (!empty($_REQUEST['action']) && substr($_REQUEST['action'], 0, 5) == 'event') {
//Load the event object, with saved event if requested
if (!empty($_REQUEST['event_id'])) {
$EM_Event = new EM_Event($_REQUEST['event_id']);
} else {
$EM_Event = new EM_Event();
}
//Save Event, only via BP or via [event_form]
if ($_REQUEST['action'] == 'event_save' && $EM_Event->can_manage('edit_events', 'edit_others_events')) {
//Check Nonces
if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'wpnonce_event_save')) {
exit('Trying to perform an illegal action.');
}
//Grab and validate submitted data
if ($EM_Event->get_post() && $EM_Event->save()) {
//EM_Event gets the event if submitted via POST and validates it (safer than to depend on JS)
$events_result = true;
//Success notice
if (is_user_logged_in()) {
$EM_Notices->add_confirm($EM_Event->output(get_option('dbem_events_form_result_success')), true);
} else {
$EM_Notices->add_confirm($EM_Event->output(get_option('dbem_events_anonymous_result_success')), true);
}
$redirect = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : wp_get_referer();
$redirect = em_add_get_params($redirect, array('success' => 1));
wp_redirect($redirect);
exit;
} else {
$EM_Notices->add_error($EM_Event->get_errors());
$events_result = false;
}
}
if ($_REQUEST['action'] == 'event_duplicate' && wp_verify_nonce($_REQUEST['_wpnonce'], 'event_duplicate_' . $EM_Event->event_id)) {
$EM_Event = $EM_Event->duplicate();
if ($EM_Event === false) {
$EM_Notices->add_error($EM_Event->errors, true);
} else {
$EM_Notices->add_confirm($EM_Event->feedback_message, true);
}
wp_redirect(wp_get_referer());
exit;
}
if ($_REQUEST['action'] == 'event_delete' && wp_verify_nonce($_REQUEST['_wpnonce'], 'event_delete_' . $EM_Event->event_id)) {
//DELETE action
$selectedEvents = !empty($_REQUEST['events']) ? $_REQUEST['events'] : '';
if (EM_Object::array_is_numeric($selectedEvents)) {
$events_result = EM_Events::delete($selectedEvents);
//.........这里部分代码省略.........
示例3: duplicate
/**
* Duplicates this event and returns the duplicated event. Will return false if there is a problem with duplication.
* @return EM_Event
*/
function duplicate()
{
global $wpdb, $EZSQL_ERROR;
//First, duplicate.
if ($this->can_manage('edit_events', 'edit_others_events')) {
$event_table_name = EM_EVENTS_TABLE;
$eventArray = $this->to_array();
unset($eventArray['event_id']);
$EM_Event = new EM_Event($eventArray);
if ($EM_Event->save()) {
$EM_Event->feedback_message = sprintf(__("%s successfully duplicated.", 'dbem'), __('Event', 'dbem'));
return apply_filters('em_event_duplicate', $EM_Event, $this);
}
} else {
$EM_Event->add_error(sprintf(__('You are not allowed to manage this %s.'), __('event', 'dbem')));
}
//TODO add error notifications for duplication failures.
return apply_filters('em_event_duplicate', false, $this);
}
示例4: em_init_actions
/**
* Performs actions on init. This works for both ajax and normal requests, the return results depends if an em_ajax flag is passed via POST or GET.
*/
function em_init_actions()
{
global $wpdb, $EM_Notices, $EM_Event;
if (defined('DOING_AJAX') && DOING_AJAX) {
$_REQUEST['em_ajax'] = true;
}
//NOTE - No EM objects are globalized at this point, as we're hitting early init mode.
//TODO Clean this up.... use a uniformed way of calling EM Ajax actions
if (!empty($_REQUEST['em_ajax']) || !empty($_REQUEST['em_ajax_action'])) {
if (isset($_REQUEST['em_ajax_action']) && $_REQUEST['em_ajax_action'] == 'get_location') {
if (isset($_REQUEST['id'])) {
$EM_Location = new EM_Location($_REQUEST['id'], 'location_id');
$location_array = $EM_Location->to_array();
$location_array['location_balloon'] = $EM_Location->output(get_option('dbem_location_baloon_format'));
echo EM_Object::json_encode($location_array);
}
die;
}
if (isset($_REQUEST['em_ajax_action']) && $_REQUEST['em_ajax_action'] == 'delete_ticket') {
if (isset($_REQUEST['id'])) {
$EM_Ticket = new EM_Ticket($_REQUEST['id']);
$result = $EM_Ticket->delete();
if ($result) {
$result = array('result' => true);
} else {
$result = array('result' => false, 'error' => $EM_Ticket->feedback_message);
}
} else {
$result = array('result' => false, 'error' => __('No ticket id provided', 'dbem'));
}
echo EM_Object::json_encode($result);
die;
}
if (isset($_REQUEST['query']) && $_REQUEST['query'] == 'GlobalMapData') {
$EM_Locations = EM_Locations::get($_REQUEST);
$json_locations = array();
foreach ($EM_Locations as $location_key => $EM_Location) {
$json_locations[$location_key] = $EM_Location->to_array();
$json_locations[$location_key]['location_balloon'] = $EM_Location->output(get_option('dbem_map_text_format'));
}
echo EM_Object::json_encode($json_locations);
die;
}
if (isset($_REQUEST['ajaxCalendar']) && $_REQUEST['ajaxCalendar']) {
//FIXME if long events enabled originally, this won't show up on ajax call
echo EM_Calendar::output($_REQUEST, false);
die;
}
}
//Event Actions
if (!empty($_REQUEST['action']) && substr($_REQUEST['action'], 0, 5) == 'event') {
//Load the event object, with saved event if requested
if (!empty($_REQUEST['event_id'])) {
$EM_Event = new EM_Event($_REQUEST['event_id']);
} else {
$EM_Event = new EM_Event();
}
//Save Event, only via BP or via [event_form]
if ($_REQUEST['action'] == 'event_save' && $EM_Event->can_manage('edit_events', 'edit_others_events')) {
//Check Nonces
if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'wpnonce_event_save')) {
exit('Trying to perform an illegal action.');
}
//Grab and validate submitted data
if ($EM_Event->get_post() && $EM_Event->save()) {
//EM_Event gets the event if submitted via POST and validates it (safer than to depend on JS)
$events_result = true;
//Success notice
if (is_user_logged_in()) {
if (empty($_REQUEST['event_id'])) {
$EM_Notices->add_confirm($EM_Event->output(get_option('dbem_events_form_result_success')), true);
} else {
$EM_Notices->add_confirm($EM_Event->output(get_option('dbem_events_form_result_success_updated')), true);
}
} else {
$EM_Notices->add_confirm($EM_Event->output(get_option('dbem_events_anonymous_result_success')), true);
}
$redirect = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : wp_get_referer();
$redirect = em_add_get_params($redirect, array('success' => 1), false, false);
wp_redirect($redirect);
exit;
} else {
$EM_Notices->add_error($EM_Event->get_errors());
$events_result = false;
}
}
if ($_REQUEST['action'] == 'event_duplicate' && wp_verify_nonce($_REQUEST['_wpnonce'], 'event_duplicate_' . $EM_Event->event_id)) {
$event = $EM_Event->duplicate();
if ($event === false) {
$EM_Notices->add_error($EM_Event->errors, true);
wp_redirect(wp_get_referer());
} else {
$EM_Notices->add_confirm($EM_Event->feedback_message, true);
wp_redirect($event->get_edit_url());
}
exit;
}
//.........这里部分代码省略.........
示例5: importEventsCSV
/**
* import events from CSV upload
* @param string $filepath
*/
protected function importEventsCSV($filepath)
{
global $wpdb;
$fp = fopen($filepath, 'r');
if ($fp === false) {
throw new EM_ImpExpImportException('error opening CSV file');
}
// read first line of CSV to make sure it's the correct format -- fgetscsv is fine for this simple task!
$header = fgetcsv($fp);
if ($header === false) {
throw new EM_ImpExpImportException('error reading import file or file is empty');
}
if (is_null($header)) {
throw new EM_ImpExpImportException('import file handle is null');
}
if (!is_array($header)) {
throw new EM_ImpExpImportException('import file did not scan as CSV');
}
if (!in_array('summary', $header)) {
throw new EM_ImpExpImportException('import file does not contain a field "summary"');
}
$wpdb->query('start transaction');
$records = 0;
$rows = 0;
$attrs = array();
$eventCategories = self::getEventCategories();
$eventCountries = self::getEventCountries();
$csv = new parseCSV();
$csv->fields = $header;
while ($line = fgets($fp)) {
$line = "\n{$line}\n";
// fix up line so that it can be parsed correctly
$cols = $csv->parse_string($line);
if ($cols) {
$rows++;
$cols = $cols[0];
// collect standard event properties
$data = array('uid' => isset($cols['uid']) ? trim($cols['uid']) : '', 'url' => isset($cols['url']) ? self::safeURL($cols['url']) : '', 'summary' => isset($cols['summary']) ? $cols['summary'] : '', 'dtstart' => isset($cols['dtstart']) ? $cols['dtstart'] : '', 'dtend' => isset($cols['dtend']) ? $cols['dtend'] : '', 'categories' => isset($cols['categories']) ? $cols['categories'] : '', 'freq' => isset($cols['freq']) ? $cols['freq'] : '', 'byday' => isset($cols['byday']) ? $cols['byday'] : '', 'interval' => isset($cols['interval']) ? $cols['interval'] : '', 'until' => isset($cols['until']) ? $cols['until'] : '', 'post_content' => isset($cols['post_content']) ? $cols['post_content'] : '', 'post_excerpt' => isset($cols['post_excerpt']) ? $cols['post_excerpt'] : '', 'event_spaces' => isset($cols['event_spaces']) ? $cols['event_spaces'] : '', 'location_name' => isset($cols['location_name']) ? $cols['location_name'] : '', 'location_address' => isset($cols['location_address']) ? $cols['location_address'] : '', 'location_town' => isset($cols['location_town']) ? $cols['location_town'] : '', 'location_state' => isset($cols['location_state']) ? $cols['location_state'] : '', 'location_postcode' => isset($cols['location_postcode']) ? $cols['location_postcode'] : '', 'location_country' => isset($cols['location_country']) ? $cols['location_country'] : '', 'location_region' => isset($cols['location_region']) ? $cols['location_region'] : '', 'location_latitude' => isset($cols['location_latitude']) ? $cols['location_latitude'] : '', 'location_longitude' => isset($cols['location_longitude']) ? $cols['location_longitude'] : '');
if (isset($eventCountries[strtolower($data['location_country'])])) {
$data['location_country'] = $eventCountries[strtolower($data['location_country'])];
}
// collect custom event attributes, being columns not found in standard event properties
$attrs = array();
foreach ($cols as $key => $value) {
if (strlen($value) > 0 && !isset($data[$key])) {
$attrs[$key] = $value;
}
}
// if we have location, try to either retrieve it by name, or create a new location object
$location = false;
if (self::hasLocation($data)) {
if ($data['location_name']) {
// try to find location by name
$location = $this->getLocationByName($data['location_name']);
}
if (!$location) {
// must create a new location object
$location = new EM_Location();
$location->location_name = empty($data['location_name']) ? self::fudgeLocationName($data) : $data['location_name'];
$location->location_address = empty($data['location_address']) ? $data['location_name'] : $data['location_address'];
$location->location_town = $data['location_town'];
$location->location_state = $data['location_state'];
$location->location_postcode = $data['location_postcode'];
$location->location_country = $data['location_country'];
$location->location_region = $data['location_region'];
$location->location_latitude = $data['location_latitude'];
$location->location_longitude = $data['location_longitude'];
self::maybeSetCoordinates($location);
$location->save();
}
}
// try to find existing event with matching unique ID first, so can update it
$event = false;
if ($data['uid']) {
add_filter('em_events_get_default_search', array(__CLASS__, 'filterEventArgs'), 10, 2);
add_filter('em_events_build_sql_conditions', array(__CLASS__, 'filterEventSQL'), 10, 2);
$event = EM_Events::get(array('em_impexp_uid' => $data['uid']));
$event = count($event) > 0 ? $event[0] : false;
remove_filter('em_events_get_default_search', array(__CLASS__, 'filterEventArgs'), 10, 2);
remove_filter('em_events_build_sql_conditions', array(__CLASS__, 'filterEventSQL'), 10, 2);
}
if (!$event) {
// must create a new event
$event = new EM_Event();
}
$event->location_id = $location ? $location->location_id : 0;
$event->event_attributes['em_impexp_uid'] = $data['uid'];
$event->event_attributes['em_impexp_url'] = $data['url'];
$event->event_name = $data['summary'];
$event->post_content = $data['post_content'];
$event->post_excerpt = $data['post_excerpt'];
if (preg_match('@^\\d\\d/\\d\\d/\\d\\d\\d\\d$@', $data['dtstart'])) {
$data['dtstart'] .= ' 00:00:00';
$event->start = date_create_from_format('d/m/Y H:i:s', $data['dtstart'])->getTimestamp();
$event->event_start_date = date('Y-m-d', $event->start);
$event->event_start_time = date('H:i:s', $event->start);
//.........这里部分代码省略.........
示例6: em_init_actions
/**
* Performs actions on init. This works for both ajax and normal requests, the return results depends if an em_ajax flag is passed via POST or GET.
*/
function em_init_actions()
{
global $wpdb, $EM_Notices, $EM_Event;
//NOTE - No EM objects are globalized at this point, as we're hitting early init mode.
//TODO Clean this up.... use a uniformed way of calling EM Ajax actions
if (!empty($_REQUEST['em_ajax']) || !empty($_REQUEST['em_ajax_action'])) {
if (isset($_REQUEST['em_ajax_action']) && $_REQUEST['em_ajax_action'] == 'get_location') {
if (isset($_REQUEST['id'])) {
$EM_Location = new EM_Location($_REQUEST['id']);
$location_array = $EM_Location->to_array();
$location_array['location_balloon'] = $EM_Location->output(get_option('dbem_location_baloon_format'));
echo EM_Object::json_encode($location_array);
}
die;
}
if (isset($_REQUEST['em_ajax_action']) && $_REQUEST['em_ajax_action'] == 'delete_ticket') {
if (isset($_REQUEST['id'])) {
$EM_Ticket = new EM_Ticket($_REQUEST['id']);
$result = $EM_Ticket->delete();
if ($result) {
$result = array('result' => true);
} else {
$result = array('result' => false, 'error' => $EM_Ticket->feedback_message);
}
} else {
$result = array('result' => false, 'error' => __('No ticket id provided', 'dbem'));
}
echo EM_Object::json_encode($result);
die;
}
if (isset($_REQUEST['query']) && $_REQUEST['query'] == 'GlobalMapData') {
$EM_Locations = EM_Locations::get($_REQUEST);
$json_locations = array();
foreach ($EM_Locations as $location_key => $EM_Location) {
$json_locations[$location_key] = $EM_Location->to_array();
$json_locations[$location_key]['location_balloon'] = $EM_Location->output(get_option('dbem_map_text_format'));
}
echo EM_Object::json_encode($json_locations);
die;
}
if (isset($_REQUEST['ajaxCalendar']) && $_REQUEST['ajaxCalendar']) {
//FIXME if long events enabled originally, this won't show up on ajax call
echo EM_Calendar::output($_REQUEST);
die;
}
}
//Event Actions
if (!empty($_REQUEST['action']) && substr($_REQUEST['action'], 0, 5) == 'event') {
//Load the event object, with saved event if requested
if (!empty($_REQUEST['event_id'])) {
$EM_Event = new EM_Event($_REQUEST['event_id']);
} else {
$EM_Event = new EM_Event();
}
if ($_REQUEST['action'] == 'event_save' && current_user_can('edit_events')) {
//Check Nonces
if (is_admin()) {
if (!wp_verify_nonce($_REQUEST['_wpnonce'] && 'event_save')) {
check_admin_referer('trigger_error');
}
} else {
if (!wp_verify_nonce($_REQUEST['_wpnonce'] && 'event_save')) {
exit('Trying to perform an illegal action.');
}
}
//Grab and validate submitted data
if ($EM_Event->get_post() && $EM_Event->save()) {
//EM_Event gets the event if submitted via POST and validates it (safer than to depend on JS)
$EM_Notices->add_confirm($EM_Event->feedback_message);
if (is_admin()) {
$page = !empty($_REQUEST['pno']) ? $_REQUEST['pno'] : '';
$scope = !empty($_REQUEST['scope']) ? $_REQUEST['scope'] : '';
//wp_redirect( get_bloginfo('wpurl').'/wp-admin/admin.php?page=events-manager&pno='.$page.'&scope='.$scope.'&message='.urlencode($EM_Event->feedback_message));
} else {
$redirect = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : wp_get_referer();
wp_redirect($redirect);
}
$events_result = true;
} else {
$EM_Notices->add_error($EM_Event->get_errors());
$events_result = false;
}
}
if ($_REQUEST['action'] == 'event_duplicate') {
global $EZSQL_ERROR;
$EM_Event = $EM_Event->duplicate();
if ($EM_Event === false) {
$EM_Notices->add_error($EM_Event->errors, true);
} else {
if ($EM_Event->id == $_REQUEST['event_id']) {
$EM_Notices->add_confirm($EM_Event->feedback_message . " " . sprintf(__('You are now viewing the duplicated %s.', 'dbem'), __('event', 'dbem')), true);
} else {
$EM_Notices->add_confirm($EM_Event->feedback_message, true);
}
}
}
if ($_REQUEST['action'] == 'event_delete') {
//.........这里部分代码省略.........
示例7: duplicate
/**
* Duplicates this event and returns the duplicated event. Will return false if there is a problem with duplication.
* @return EM_Event
*/
function duplicate()
{
global $wpdb, $EZSQL_ERROR;
//First, duplicate.
if ($this->can_manage(true)) {
$event_table_name = $wpdb->prefix . EM_EVENTS_TABLE;
$eventArray = $this->to_array(true);
unset($eventArray['event_id']);
$EM_Event = new EM_Event($eventArray);
if ($EM_Event->save()) {
$EM_Event->feedback_message = __("You are now viewing the duplicated event", 'dbem');
return apply_filters('em_event_duplicate', $EM_Event, $this);
}
}
//TODO add error notifications for duplication failures.
return apply_filters('em_event_duplicate', false, $this);
}
示例8: create_event_from_feed
public static function create_event_from_feed(array $FEED_ = NULL, $event_id = NULL)
{
global $ESS_Notices, $current_site;
$EM_Event = NULL;
if ($FEED_ != NULL) {
//dd( $FEED_ );
$EM_Event = new EM_Event(intval($event_id) > 0 ? $event_id : 0);
// set eventID for update
// -- Populate $_POST global var for EM functions
if (ESS_Import::set_post_from_feed($FEED_)) {
//dd($_POST);
if ($EM_Event->can_manage('edit_events', 'edit_recurring_events', 'edit_others_events') && $EM_Event->get_post()) {
// -- temporarily remove the save listener to prevent multi-pushing to search engines
ESS_IO::set_save_filter(FALSE);
$EM_Location = NULL;
$EM_Categories = NULL;
$EM_Tickets = NULL;
$blog_id = isset($current_site) ? $current_site->blog_id : NULL;
// used as global by some functions (Cf: EM_location::save())
if (empty($event_id)) {
$EM_Event->force_status = intval(get_option('ess_syndication_status')) >= 1 ? ESS_Database::EVENT_STATUS_PUBLISH : ESS_Database::EVENT_STATUS_DRAFT;
$EM_Event->event_status = 1;
$EM_Event->previous_status = 1;
} else {
$EM_Event->event_id = $event_id;
// -- Remove old images in case of event's update
if (get_option('ess_feed_import_images') && intval($EM_Event->post_id) > 0) {
ESS_Images::delete($EM_Event->post_id);
}
}
$EM_Event->post_status = strtolower($_POST['event_access']) == 'private' ? 'private' : ESS_Database::EVENT_STATUS_PUBLISH;
// == GENERAL
if (strlen($_POST['content']) > 0) {
if (get_option('ess_backlink_enabled')) {
$feed_uri = $FEED_['generals']['uri'];
$feed_uri_host = parse_url($feed_uri, PHP_URL_HOST);
$_POST['content'] .= "<h6>" . __("Source:", 'dbem') . " <a title=\"" . __("Source:", 'dbem') . " " . $feed_uri_host . "\" href=\"" . $feed_uri . "\">" . parse_url($feed_uri, PHP_URL_HOST) . "</a></h6>";
}
}
// == PLACE / LOCATION
//dd( $_POST['location_name'] );
if ($_POST['no_location'] === FALSE && strlen($_POST['location_name']) > 0 && get_option('dbem_locations_enabled')) {
$EM_Location = new EM_Location();
if ($EM_Location->can_manage('publish_locations') && $EM_Location->get_post(FALSE)) {
//d( $EM_Location );
// -- Search if this location already exists in the database
$similar_ = ESS_Import::load_similar_location(array('location_name' => $EM_Location->location_name, 'location_address' => $EM_Location->location_address, 'location_town' => $EM_Location->location_town, 'location_state' => $EM_Location->location_state, 'location_postcode' => $EM_Location->location_postcode, 'location_country' => $EM_Location->location_country));
//dd( $similar_ );
// if the location already exists use it instead.
if (@count($similar_) > 0 && $similar_ != NULL) {
foreach ($similar_ as $key => $val) {
$EM_Location->{$key} = $val;
}
} else {
$EM_Location->post_status = 'publish';
$EM_Location->location_status = 1;
$EM_Location->post_content = '';
}
// -- Search & defines latitude / longitude if not set
if (FeedValidator::isValidLatitude((string) $_POST['location_latitude']) == FALSE || FeedValidator::isValidLongitude((string) $_POST['location_longitude']) == FALSE) {
require_once EM_ESS_DIR . "/inc/libs/geocoder/GoogleGeocode.php";
$geocode_ = GoogleGeocode::getGeocodeFromAddress(trim($EM_Location->location_address . " " . $EM_Location->location_town . " " . $EM_Location->location_postcode . " " . $EM_Location->location_country));
$lat = (string) $geocode_['results'][0]['geometry']['location']['lat'];
$lng = (string) $geocode_['results'][0]['geometry']['location']['lng'];
//echo "latitude: " . $lat . " ==> ".((FeedValidator::isValidLatitude( $lat ))?'TRUE':'FALSE')."<br/>";
//echo "longitude: " . $lng . " ==> ".((FeedValidator::isValidLongitude( $lng ))?'TRUE':'FALSE')."<br/>";
if (FeedValidator::isValidLatitude($lat) && FeedValidator::isValidLongitude($lng)) {
$EM_Location->location_latitude = $lat;
$EM_Location->location_longitude = $lng;
}
}
if ($EM_Location->save() === FALSE) {
$ESS_Notices->add_error($EM_Location->get_errors());
}
$EM_Event->location_id = $EM_Location->location_id;
} else {
$ESS_Notices->add_error($EM_Location->get_errors());
}
}
// end add location
//dd( $EM_Location );
// == PRICE / TICKETS
//dd( $_POST['em_tickets'] );
if (@count($_POST['em_tickets']) > 0 && get_option('dbem_rsvp_enabled')) {
$EM_Tickets = new EM_Tickets($EM_Event);
$ticket_data = NULL;
// Create tickets only if they doesn't exists
if (@count($EM_Tickets->tickets) <= 0) {
foreach ($_POST['em_tickets'] as $ticket_data) {
$EM_Ticket = new EM_Ticket();
$EM_Ticket->get_post($ticket_data);
$EM_Tickets->tickets[] = $EM_Ticket;
}
}
if ($ticket_data != NULL) {
$EM_Event->event_rsvp = TRUE;
$EM_Event->event_rsvp_date = $ticket_data['event_rsvp_date'];
$EM_Event->event_rsvp_time = $ticket_data['event_rsvp_time'];
$EM_Event->event_spaces = $ticket_data['event_spaces'];
$EM_Event->rsvp_time = $ticket_data['event_rsvp_time'];
//.........这里部分代码省略.........
示例9: updateEvent
function updateEvent($data)
{
$em_event = em_get_event(getPostIdByMetaValue('_ss_id', $data['id']), 'post_id');
$check = true;
if (isset($data['command']) && $data['command'] == 'UPDATE') {
if (!$em_event->event_id) {
$em_event = new EM_Event();
}
$em_event->event_start_date = $data["starttag"];
$em_event->event_start_time = $data["startzeit"];
$em_event->event_end_date = $data["endtag"];
$em_event->event_end_time = $data["endzeit"];
$em_event->start = strtotime($em_event->event_start_date . " " . $em_event->event_start_time);
$em_event->end = strtotime($em_event->event_end_date . " " . $em_event->event_end_time);
$em_event->location_id = isset($data["venueid"]) ? $data["venueid"] : '';
$em_event->post_title = $data["titel"];
$em_event->event_name = $data["titel"];
//$em_event->body = (($data["kurzbeschreibung"]) ? $data["kurzbeschreibung"] : '');
$em_event->post_content = isset($data["kurzbeschreibung"]) ? $data["kurzbeschreibung"] : '';
$em_event->post_excerpt = isset($data["auszug"]) ? $data["auszug"] : '';
$em_event->post_tags = @$data["tags"];
// meta
$em_event->event_attributes = array('Status' => $data['status'], 'Line Up' => $data['lineup'], 'Stil' => isset($data["stil"]) ? $data["stil"] : '', 'Preis' => $data['preis'], 'Parent' => isset($data["parentid"]) ? $data["parentid"] : '', 'Team' => $data['team'], 'Recommended' => $data['recommended'], 'Promoted' => $data['promoted'], 'Gewinnspiel' => $data['gewinnspiel'], 'Kurzbeschreibung' => $data["kurzbeschreibung"]);
$em_event->group_id = 0;
$em_event->event_date_modified = date('Y-m-d H:i:s', time());
$em_event->event_all_day = $data['ganztägig'] ? 1 : 0;
$em_event->event_rsvp = 0;
$check = $em_event->save();
add_post_meta($em_event->post_id, '_ss_id', $data['id']);
// add category
$categories = array();
$type = new EM_Category(strtolower($data["veranstaltungstyp"]));
if (!$type->term_id) {
$type = new EM_Category("sonstiges");
}
array_push($categories, $type->term_id);
if ($data["recommended"]) {
array_push($categories, get_cat_ID('tipp'));
}
if ($data["promoted"]) {
array_push($categories, get_cat_ID('sponsored'));
}
if ($data["team"]) {
array_push($categories, get_cat_ID('team'));
}
if ($data["veranstaltungstyp"]) {
array_push($categories, get_cat_ID(strtolower($data["veranstaltungstyp"])));
}
if ($data["gewinnspiel"]) {
array_push($categories, get_cat_ID('gewinnspiel'));
}
if ($data["preis"] != '' && $data["preis"] == 0) {
array_push($categories, get_cat_ID('kostenlos'));
}
if (count($categories)) {
wp_set_post_terms($em_event->post_id, $categories, 'event-categories', false);
}
// add tags
$tags = array();
if ($data["tags"]) {
array_push($tags, $data["tags"]);
}
//if($data["ausverkauft"]) array_push($tags, "ausverkauft");
if ($data["openair"]) {
array_push($tags, "open air");
}
if ($data['lineup']) {
$tags = array_merge($tags, explode(',', $data['lineup']));
}
if ($data['tags']) {
$tags = array_merge($tags, explode(',', $data['tags']));
}
if (count($tags)) {
wp_set_post_terms($em_event->post_id, $tags, 'event-tags', false);
}
} elseif (isset($data['command']) && $data['command'] == 'DELETE') {
if ($em_event->event_id) {
$check = $em_event->delete(true);
}
}
return $check;
}