Beispiel #1
0
 /**
  * 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')) {
         $EM_Event = clone $this;
         $EM_Event->get_categories();
         //before we remove event/post ids
         $EM_Event->get_bookings()->get_tickets();
         //in case this wasn't loaded and before we reset ids
         $EM_Event->event_id = null;
         $EM_Event->post_id = null;
         $EM_Event->ID = null;
         $EM_Event->post_name = '';
         $EM_Event->location_id = empty($EM_Event->location_id) && !get_option('dbem_require_location') ? 0 : $EM_Event->location_id;
         $EM_Event->get_bookings()->event_id = null;
         $EM_Event->get_bookings()->get_tickets()->event_id = null;
         //if bookings reset ticket ids and duplicate tickets
         foreach ($EM_Event->get_bookings()->get_tickets()->tickets as $EM_Ticket) {
             $EM_Ticket->ticket_id = null;
             $EM_Ticket->event_id = null;
         }
         do_action('em_event_duplicate_pre', $EM_Event);
         $EM_Event->duplicated = true;
         $EM_Event->force_status = 'draft';
         if ($EM_Event->save()) {
             $EM_Event->feedback_message = sprintf(__("%s successfully duplicated.", 'dbem'), __('Event', 'dbem'));
             //save tags here - eventually will be moved into part of $this->save();
             if (get_option('dbem_tags_enabled')) {
                 $EM_Tags = new EM_Tags($this);
                 $EM_Tags->event_id = $EM_Event->event_id;
                 $EM_Tags->post_id = $EM_Event->post_id;
                 $EM_Tags->save();
             }
             //other non-EM post meta inc. featured image
             $event_meta = $this->get_event_meta($this->blog_id);
             $new_event_meta = $EM_Event->get_event_meta($EM_Event->blog_id);
             $event_meta_inserts = array();
             //Get custom fields and post meta - adapted from $this->load_post_meta()
             foreach ($event_meta as $event_meta_key => $event_meta_vals) {
                 if ($event_meta_key[0] == '_' && is_array($event_meta_vals)) {
                     $field_name = substr($event_meta_key, 1);
                     if ($field_name != 'event_attributes' && !array_key_exists($event_meta_key, $new_event_meta) && !in_array($field_name, array('edit_last', 'edit_lock', 'event_owner_name', 'event_owner_anonymous', 'event_owner_email'))) {
                         foreach ($event_meta_vals as $event_meta_val) {
                             $event_meta_inserts[] = "({$EM_Event->post_id}, '{$event_meta_key}', '{$event_meta_val}')";
                         }
                     }
                 }
             }
             //save in one SQL statement
             if (!empty($event_meta_inserts)) {
                 $wpdb->query('INSERT INTO ' . $wpdb->postmeta . " (post_id, meta_key, meta_value) VALUES " . implode(', ', $event_meta_inserts));
             }
             if (array_key_exists('_event_approvals_count', $event_meta)) {
                 update_post_meta($EM_Event->post_id, '_event_approvals_count', 0);
             }
             //copy anything from the em_meta table too
             $wpdb->query('INSERT INTO ' . EM_META_TABLE . " (object_id, meta_key, meta_value) SELECT '{$EM_Event->event_id}', meta_key, meta_value FROM " . EM_META_TABLE . " WHERE object_id='{$this->event_id}'");
             //set event to draft status
             return apply_filters('em_event_duplicate', $EM_Event, $this);
         }
     }
     //TODO add error notifications for duplication failures.
     return apply_filters('em_event_duplicate', false, $this);
 }
Beispiel #2
0
/**
 * Handles AJAX Searching and Pagination for events, locations, tags and categories
 */
function em_ajax_search_and_pagination()
{
    $args = array('owner' => false, 'pagination' => 1, 'ajax' => true);
    if (empty($args['scope'])) {
        $args['scope'] = get_option('dbem_events_page_scope');
    }
    echo '<div class="em-search-ajax">';
    ob_start();
    if ($_REQUEST['action'] == 'search_events') {
        $args = EM_Events::get_post_search($args);
        $args['limit'] = !empty($args['limit']) ? $args['limit'] : get_option('dbem_events_default_limit');
        em_locate_template('templates/events-list.php', true, array('args' => $args));
        //if successful, this template overrides the settings and defaults, including search
    } elseif ($_REQUEST['action'] == 'search_events_grouped' && defined('DOING_AJAX')) {
        $args = EM_Events::get_post_search($args);
        $args['limit'] = !empty($args['limit']) ? $args['limit'] : get_option('dbem_events_default_limit');
        em_locate_template('templates/events-list-grouped.php', true, array('args' => $args));
        //if successful, this template overrides the settings and defaults, including search
    } elseif ($_REQUEST['action'] == 'search_locations' && defined('DOING_AJAX')) {
        $args = EM_Locations::get_post_search($args);
        $args['limit'] = !empty($args['limit']) ? $args['limit'] : get_option('dbem_locations_default_limit');
        em_locate_template('templates/locations-list.php', true, array('args' => $args));
        //if successful, this template overrides the settings and defaults, including search
    } elseif ($_REQUEST['action'] == 'search_tags' && defined('DOING_AJAX')) {
        $args = EM_Tags::get_post_search($args);
        $args['limit'] = !empty($args['limit']) ? $args['limit'] : get_option('dbem_tags_default_limit');
        em_locate_template('templates/tags-list.php', true, array('args' => $args));
        //if successful, this template overrides the settings and defaults, including search
    } elseif ($_REQUEST['action'] == 'search_cats' && defined('DOING_AJAX')) {
        $args = EM_Categories::get_post_search($args);
        $args['limit'] = !empty($args['limit']) ? $args['limit'] : get_option('dbem_categories_default_limit');
        em_locate_template('templates/categories-list.php', true, array('args' => $args));
        //if successful, this template overrides the settings and defaults, including search
    }
    echo '</div>';
    echo apply_filters('em_ajax_' . $_REQUEST['action'], ob_get_clean(), $args);
    exit;
}
<?php

/*
 * Default tags List Template
 * This page displays a list of locations, called during the em_content() if this is an events list page.
 * You can override the default display settings pages by copying this file to yourthemefolder/plugins/events-manager/templates/ and modifying it however you need.
 * You can display locations (or whatever) however you wish, there are a few variables made available to you:
 * 
 * $args - the args passed onto EM_Locations::output()
 * 
 */
$args = apply_filters('em_content_tags_args', $args);
$tags = EM_Tags::get($args);
$args['limit'] = get_option('dbem_tags_default_limit');
$args['page'] = !empty($_REQUEST['pno']) && is_numeric($_REQUEST['pno']) ? $_REQUEST['pno'] : 1;
if (count($tags) > 0) {
    echo EM_Tags::output($tags, $args);
} else {
    echo get_option('dbem_no_tags_message');
}
Beispiel #4
0
<?php

/*
 * Default tags List Template
 * This page displays a list of locations, called during the em_content() if this is an events list page.
 * You can override the default display settings pages by copying this file to yourthemefolder/plugins/events-manager/templates/ and modifying it however you need.
 * You can display locations (or whatever) however you wish, there are a few variables made available to you:
 * 
 * $args - the args passed onto EM_Locations::output()
 * 
 */
$args = apply_filters('em_content_tags_args', $args);
if (get_option('dbem_css_taglist')) {
    echo "<div class='css-tags-list'>";
}
echo EM_Tags::output($args);
if (get_option('dbem_css_taglist')) {
    echo "</div>";
}
 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'];
                     }
                 }
                 // end add tickets
                 //dd( $EM_Tickets );
                 // == CATEGORIES
                 //dd( $_POST['event_categories'] );
                 if (@count($_POST['event_categories']) > 0 && get_option('dbem_categories_enabled')) {
                     $EM_Categories = new EM_Categories();
                     if ($EM_Categories->can_manage('edit_event_categories')) {
                         $caregory_ids_ = array();
                         foreach ($_POST['event_categories'] as $category_name) {
                             $category_term = get_term_by('name', $category_name, EM_TAXONOMY_CATEGORY);
                             // DEBUG: 2014-01-30
                             // Fix a internationalization bug report: http://wordpress.org/support/topic/finding-event-category-by-slug-is-not-always-a-good-idea
                             //$category_slug = sanitize_title_with_dashes( $category_name );
                             //$category_term = get_term_by( 'slug', $category_slug, EM_TAXONOMY_CATEGORY );
                             if ($category_term === FALSE) {
                                 // Term (with category taxonomy) not created yet, let's create it
                                 //$term_array = wp_insert_term( $category_name, EM_TAXONOMY_CATEGORY, array( 'slug' => $category_slug ) );
                                 $term_array = wp_insert_term($category_name, EM_TAXONOMY_CATEGORY, array('name' => $category_name));
                                 if (intval($term_array['term_id']) > 0) {
                                     array_push($caregory_ids_, intval($term_array['term_id']));
                                 }
                             } else {
                                 if (intval($category_term->term_id) > 0) {
                                     array_push($caregory_ids_, intval($category_term->term_id));
                                 }
                             }
                         }
                         $_POST['event_categories'] = $caregory_ids_;
                         if ($EM_Categories->get_post() === FALSE) {
                             $ESS_Notices->add_error($EM_Categories->get_errors());
                         }
                     } else {
                         $ESS_Notices->add_error($EM_Categories->get_errors());
                     }
                 }
                 // end add categories
                 $EM_Event->categories = $EM_Categories;
                 //dd( $EM_Categories );
                 // == TAGS
                 //dd( $_POST['event_tags'] );
                 if (@count($_POST['event_tags']) > 0 && get_option('dbem_tags_enabled')) {
                     $EM_Tags = new EM_Tags();
                     $tag_ids_ = array();
                     foreach ($_POST['event_tags'] as $tag_name) {
                         $tag_slug = sanitize_title_with_dashes($tag_name);
                         $tag_term = get_term_by('slug', $tag_slug, EM_TAXONOMY_TAG);
                         if ($tag_term === FALSE) {
                             // -- Term (with tag taxonomy) not created yet, let's create it
                             $term_array = wp_insert_term($tag_name, EM_TAXONOMY_TAG, array('slug' => $tag_slug));
                             if (intval($term_array['term_id']) > 0) {
                                 array_push($tag_ids_, intval($term_array['term_id']));
                             }
                         } else {
                             if (intval($tag_term->term_id) > 0) {
                                 array_push($tag_ids_, intval($tag_term->term_id));
                             }
                         }
                     }
                     $_POST['event_tags'] = $tag_ids_;
                     if ($EM_Tags->get_post() === FALSE) {
                         $ESS_Notices->add_error($EM_Categories->get_errors());
                     }
                 }
                 // end add tags
                 //dd( $EM_Tags );
                 // == DATE (force date values)
                 if (strlen($_POST['event_start_date']) > 0) {
                     $EM_Event->event_start_date = $_POST['event_start_date'];
                     $EM_Event->start_date = $_POST['event_start_date'];
                     $EM_Event->event_start_time = $_POST['event_start_time'];
                     $EM_Event->start_time = $_POST['event_start_time'];
                     $EM_Event->event_end_date = $_POST['event_end_date'];
                     $EM_Event->end_date = $_POST['event_end_date'];
                     $EM_Event->event_end_time = $_POST['event_end_time'];
                     $EM_Event->end_time = $_POST['event_end_time'];
                     $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);
                     if ($EM_Event->end < date('U')) {
                         $ESS_Notices->add_info(__("An event imported is already finished: " . ESS_Elements::get_ahref($FEED_['generals']['uri']), 'dbem'));
                     }
                 }
                 // end add date
                 // == PEOPLE
                 $EM_Event->post_excerpt = strlen($_POST['event_excerpt']) > 0 ? $_POST['event_excerpt'] : '';
                 // -- update the information already set line 187
                 //dd( get_option( 'ess_syndication_status' ) );
                 $EM_Event->force_status = intval(get_option('ess_syndication_status')) >= 1 ? ESS_Database::EVENT_STATUS_PUBLISH : ESS_Database::EVENT_STATUS_DRAFT;
                 //dd( $EM_Event );
                 // == SAVE EVENT ======
                 $res = $EM_Event->save();
                 //dd( $res ); // return FALSE if two of some functions are not updated in EM_Events()
                 //echo "event post id: ". $EM_Event->post_id ."<br/>";
                 //echo "event event id: ". $EM_Event->event_id."<br/>";
                 if (intval($EM_Event->post_id) > 0) {
                     // == MEDIA ==========
                     if (@count($_POST['event_media'])) {
                         //var_dump( $_POST['event_media'] );
                         $media_attachement_ = array();
                         foreach ($_POST['event_media'] as $media_) {
                             if (ESS_IO::is_file_exists($media_['uri'])) {
                                 // Use the same 'manage' value to control the importation of 'images', 'sounds' or 'videos'.
                                 if ($EM_Event->can_manage('upload_event_images')) {
                                     // == IMAGES
                                     if (FeedValidator::getMediaType($media_['uri']) == 'image' && get_option('ess_feed_import_images')) {
                                         $attachment_id = ESS_Images::add(array('uri' => $media_['uri'], 'name' => $media_['name'], 'post_id' => $EM_Event->post_id));
                                         if ($attachment_id !== FALSE && intval($attachment_id) > 0) {
                                             array_push($media_attachement_, array('attachement_id' => $attachment_id, 'uri' => $media_['uri']));
                                         } else {
                                             $ESS_Notices->add_error(__("Impossible to upload the event's image: ", 'dbem') . ESS_Elements::get_ahref($media_['uri']));
                                         }
                                     }
                                     // end add images
                                     // == VIDEOS (TODO...)
                                     if (FeedValidator::getMediaType($media_['uri']) == 'video' && get_option('ess_feed_import_videos')) {
                                         if (ESS_Videos::add(array('uri' => $media_['uri'], 'name' => $media_['name'], 'post_id' => $EM_Event->post_id)) === FALSE) {
                                             $ESS_Notices->add_error(__("Impossible to upload the event's video: ", 'dbem') . ESS_Elements::get_ahref($media_['uri']));
                                         }
                                     }
                                     // end add videos
                                     // == SOUNDS (TODO...)
                                     if (FeedValidator::getMediaType($media_['uri']) == 'sound' && get_option('ess_feed_import_sounds')) {
                                         if (ESS_Sounds::add(array('uri' => $media_['uri'], 'name' => $media_['name'], 'post_id' => $EM_Event->post_id)) === FALSE) {
                                             $ESS_Notices->add_error(__("Impossible to upload the event's audio file: ", 'dbem') . ESS_Elements::get_ahref($media_['uri']));
                                         }
                                     }
                                     // end add sounds
                                 } else {
                                     $ESS_Notices->add_error($EM_Event->get_errors());
                                 }
                             } else {
                                 $ESS_Notices->add_info(sprintf(__("A media file defined in the ESS feed is not reachable: <a href='%s' target='_blank'>%s</a>", 'dbem'), $media_['uri'], $media_['uri']));
                             }
                         }
                         // -- Define image with the highest 'priority' as first attachement
                         $priority_test = 1;
                         foreach ($_POST['event_media'] as $media_) {
                             if (get_option('ess_feed_import_images') == FALSE) {
                                 break;
                             }
                             if (@$media_['priority'] == $priority_test) {
                                 if (FeedValidator::getMediaType($media_['uri']) == 'image') {
                                     foreach ($media_attachement_ as $ma_) {
                                         if ($ma_['uri'] == $media_['uri'] && $ma_['attachement_id'] > 0) {
                                             ESS_Images::delete($EM_Event->post_id, $ma_['attachement_id']);
                                             $err = ESS_Images::add(array('uri' => $media_['uri'], 'name' => $media_['name'], 'post_id' => $EM_Event->post_id));
                                         }
                                     }
                                 } else {
                                     $priority_test++;
                                 }
                             }
                         }
                         // -- Display all the media files thumbnail at the bottom of the event's description
                         $imgs_ = ESS_Images::get_thumbnails($EM_Event->post_id);
                         //var_dump( $imgs_ );die;
                         if (@count($imgs_) > 0) {
                             $EM_Event->post_content .= "<br/><hr/>";
                             foreach ($imgs_ as $img_) {
                                 if (FeedValidator::isValidURL($img_['url'])) {
                                     $EM_Event->post_content .= "<img src='" . $img_['url'] . "' width='" . $img_['width'] . "' height='" . $img_['height'] . "' style='display:inline;margin:5px;'/>";
                                 }
                             }
                             // -- UPDATE event's description with thumbnail images at the bottom
                             $res = $EM_Event->save();
                         }
                     }
                     // end add media
                     // == TICKETS ==========
                     if (@count($EM_Tickets->tickets) > 0 && get_option('dbem_rsvp_enabled')) {
                         $EM_Tickets->blog_id = $blog_id;
                         $EM_Tickets->event_id = $EM_Event->event_id;
                         if ($EM_Tickets->save() === FALSE) {
                             $ESS_Notices->add_error($EM_Tickets->get_errors());
                         }
                     }
                     // end assign event to categories
                     // == CATEGORIES ==========
                     if (@count($EM_Categories->categories) > 0 && get_option('dbem_categories_enabled')) {
                         $EM_Categories->blog_id = $blog_id;
                         $EM_Categories->event_id = $EM_Event->event_id;
                         if ($EM_Categories->save() === FALSE) {
                             $ESS_Notices->add_error($EM_Categories->get_errors());
                         }
                     }
                     // end assign event to categories
                     // == TAGS ==========
                     if (@count($EM_Tags->tags) > 0 && get_option('dbem_tags_enabled')) {
                         //var_dump( $EM_Tags->tags );
                         $EM_Tags->blog_id = $blog_id;
                         $EM_Tags->event_id = $EM_Event->event_id;
                         // this function doesn't seem to work...
                         if ($EM_Tags->save() === FALSE) {
                             $ESS_Notices->add_error($EM_Tags->get_errors());
                         }
                         $tags_ = array();
                         foreach ($EM_Tags->tags as $EM_Tag) {
                             if (strlen($EM_Tag->slug) > 0) {
                                 array_push($tags_, $EM_Tag->slug);
                             }
                         }
                         if (@count($tags_) > 0) {
                             wp_set_object_terms($EM_Event->post_id, $tags_, EM_TAXONOMY_TAG);
                         }
                     }
                     // end assign event to tags
                     // == LOCATION ==========
                     ESS_Database::clear_locations();
                     //dd( $EM_Event );
                     ESS_IO::set_save_filter(TRUE);
                 }
             } else {
                 $ESS_Notices->add_error($EM_Event->get_errors());
             }
         }
     }
     return $EM_Event;
 }