Exemple #1
0
 /**
  * Hooks into em_event_get_post and writes the original event translation data into the current event, to avoid validation errors and correct data saving.
  * @param boolean $result
  * @param EM_Event $EM_Event
  * @return boolean
  */
 public static function event_get_post_meta($result, $EM_Event)
 {
     //check if this is a master event, if not then we need to get the relevant master event info and populate this object with it so it passes validation and saves correctly.
     if (!EM_ML::is_original($EM_Event)) {
         //get original event object
         $event = EM_ML::get_original_event($EM_Event);
         EM_ML_IO::event_merge_original_meta($EM_Event, $event);
         if ($EM_Event->location_id == 0) {
             $_POST['no_location'] = 1;
         }
         // We need to save ticket translations here as well to the ticket objects
         foreach ($EM_Event->get_tickets()->tickets as $EM_Ticket) {
             /* @var $EM_Ticket EM_Ticket */
             $ticket_translation = array();
             if (!empty($_REQUEST['ticket_translations'][$EM_Ticket->ticket_id]['ticket_name'])) {
                 $ticket_translation['ticket_name'] = wp_kses_data(stripslashes($_REQUEST['ticket_translations'][$EM_Ticket->ticket_id]['ticket_name']));
             }
             if (!empty($_REQUEST['ticket_translations'][$EM_Ticket->ticket_id]['ticket_description'])) {
                 $ticket_translation['ticket_description'] = wp_kses_post(stripslashes($_REQUEST['ticket_translations'][$EM_Ticket->ticket_id]['ticket_description']));
             }
             if (!empty($ticket_translation)) {
                 $EM_Ticket->ticket_meta['langs'][EM_ML::$current_language] = $ticket_translation;
             }
         }
     } elseif (!empty($EM_Event->location_id)) {
         //we need to make sure the location is the original location
         $EM_Location = $EM_Event->get_location();
         if (!EM_ML::is_original($EM_Location)) {
             $EM_Event->location_id = EM_ML::get_original_location($EM_Location)->location_id;
         }
     }
     return $result;
 }