예제 #1
0
 public static function override_bookings($EM_Bookings, $EM_Event)
 {
     if (!EM_ML::is_original($EM_Event)) {
         $event = EM_ML::get_original_event($EM_Event);
         if (!empty($EM_Bookings->translated)) {
             //we've already done this before, so we just need to make sure the event id isn't being reset to the translated event id
             $EM_Bookings->event_id = $event->event_id;
         } else {
             //bookings hasn't been 'translated' yet, so we get the original event, get the EM_Bookings object and replace the current event with it.
             $EM_Bookings = new EM_Bookings($event);
             $EM_Bookings->event_id = $event->event_id;
             $EM_Bookings->translated = true;
             //go through tickets and translate to appropriate language
             $event_lang = EM_ML::get_the_language($EM_Event);
             foreach ($EM_Bookings->get_tickets()->tickets as $EM_Ticket) {
                 /* @var $EM_Ticket EM_Ticket */
                 if (!empty($EM_Ticket->ticket_meta['langs'][$event_lang]['ticket_name'])) {
                     $EM_Ticket->ticket_name = $EM_Ticket->ticket_meta['langs'][$event_lang]['ticket_name'];
                 }
                 if (!empty($EM_Ticket->ticket_meta['langs'][$event_lang]['ticket_description'])) {
                     $EM_Ticket->ticket_description = $EM_Ticket->ticket_meta['langs'][$event_lang]['ticket_description'];
                 }
             }
         }
     }
     return $EM_Bookings;
 }
예제 #2
0
 public static function meta_boxes()
 {
     global $EM_Event, $EM_Location;
     //decide if it's a master event, if not then hide the meta boxes
     if (!empty($EM_Event) && !EM_ML::is_original($EM_Event)) {
         //remove meta boxes for events
         remove_meta_box('em-event-when', EM_POST_TYPE_EVENT, 'side');
         remove_meta_box('em-event-where', EM_POST_TYPE_EVENT, 'normal');
         remove_meta_box('em-event-bookings', EM_POST_TYPE_EVENT, 'normal');
         remove_meta_box('em-event-bookings-stats', EM_POST_TYPE_EVENT, 'side');
         remove_meta_box('em-event-group', EM_POST_TYPE_EVENT, 'side');
         if (get_option('dbem_attributes_enabled', true)) {
             remove_meta_box('em-event-attributes', EM_POST_TYPE_EVENT, 'normal');
             add_meta_box('em-event-attributes', __('Attributes', 'events-manager'), 'EM_ML_Admin::event_meta_box_attributes', EM_POST_TYPE_EVENT, 'normal', 'default');
         }
         //add translation-specific meta boxes
         add_meta_box('em-event-translation', __('Translated Event Information', 'events-manager'), 'EM_ML_Admin::meta_box_translated_event', EM_POST_TYPE_EVENT, 'side', 'high');
         $event = EM_ML::get_original_event($EM_Event);
         if ($event->event_rsvp) {
             add_meta_box('em-event-bookings-translation', __('Bookings/Registration', 'events-manager'), 'EM_ML_Admin::meta_box_bookings_translation', EM_POST_TYPE_EVENT, 'normal', 'high');
         }
     }
     //locations, decide if it's a master location, if not then hide the meta boxes
     if (!empty($EM_Location) && !EM_ML::is_original($EM_Location)) {
         //add translation-specific meta boxes
         add_meta_box('em-event-translation', __('Translated Event Information', 'events-manager'), 'EM_ML_Admin::meta_box_translated_location', EM_POST_TYPE_LOCATION, 'side', 'high');
         //remove other meta boxes
         remove_meta_box('em-location-where', EM_POST_TYPE_LOCATION, 'normal');
         if (get_option('dbem_location_attributes_enabled')) {
             remove_meta_box('em-location-attributes', EM_POST_TYPE_LOCATION, 'normal');
             add_meta_box('em-location-attributes', __('Attributes', 'events-manager'), 'EM_ML_Admin::location_meta_box_attributes', EM_POST_TYPE_LOCATION, 'normal', 'default');
         }
     }
 }
예제 #3
0
 public static function em_object_get_default_search($defaults, $array, $super_defaults)
 {
     if (!empty($defaults['location'])) {
         //check that this location ID is the original one, given that all events of any language will refer to the location_id of the original
         $EM_Location = em_get_location($defaults['location']);
         if (!EM_ML::is_original($EM_Location)) {
             $defaults['location'] = EM_ML::get_original_location($EM_Location)->location_id;
         }
     }
     return $defaults;
 }
예제 #4
0
 /**
  * When saving an original location, save shared meta to translations as well.
  * @param boolean $result
  * @param EM_Location $EM_Location
  * @return boolean
  */
 public static function location_save_meta($result, $EM_Location)
 {
     if ($result && EM_ML::is_original($EM_Location)) {
         //save post meta for all others as well
         foreach (EM_ML::get_langs() as $lang_code => $language) {
             $location = EM_ML::get_translation($EM_Location, $lang_code);
             /* @var $EM_Location EM_Location */
             if ($location->location_id != $EM_Location->location_id) {
                 self::location_merge_original_meta($location, $EM_Location);
                 $location->save_meta();
             }
         }
     }
     return $result;
 }
예제 #5
0
 /**
  * Modifies the duplication URL so that it contains the lang query parameter of the original event that is being duplicated.
  * 
  * @param string $url
  * @param EM_Event $EM_Event
  * @return string
  */
 public static function event_duplicate_url($url, $EM_Event)
 {
     global $sitepress;
     if (!EM_ML::is_original($EM_Event)) {
         $EM_Event = EM_ML::get_original_event($EM_Event);
         $sitepress_lang = $sitepress->get_language_for_element($EM_Event->post_id, 'post_' . $EM_Event->post_type);
         $url = add_query_arg(array('lang' => $sitepress_lang), $url);
         //gets escaped later
     }
     return $url;
 }