WordPress.org

Plugin Directory

Changeset 1753147


Ignore:
Timestamp:
10/26/17 12:39:30 (4 weeks ago)
Author:
netweblogic
Message:

5.7.3.4 (dev)

Location:
events-manager/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • events-manager/trunk/classes/em-booking.php

    r1720802 r1753147  
    103103     
    104104    /** 
    105      * Creates booking object and retreives booking data (default is a blank booking object). Accepts either array of booking data (from db) or a booking id. 
     105     * Creates booking object and retrieves booking data (default is a blank booking object). Accepts either array of booking data (from db) or a booking id. 
    106106     * @param mixed $booking_data 
    107107     * @return null 
     
    116116                $booking = $booking_data; 
    117117            }elseif( is_numeric($booking_data) ){ 
    118                 //Retreiving from the database 
     118                //Retrieving from the database 
    119119                $sql = "SELECT * FROM ". EM_BOOKINGS_TABLE ." WHERE booking_id ='$booking_data'"; 
    120120                $booking = $wpdb->get_row($sql, ARRAY_A); 
     
    141141        $this->get_tax_rate(); 
    142142        if( !empty($this->legacy_tax_rate) ){ 
    143             //reset booking_price, it'll be recalculated later (if you're using this property directly, don't, use $this->get_price()) 
     143            //reset booking_price, it'll be recalculated later (if you're using this property directly, don't use $this->get_price()) 
    144144            $this->booking_price = $this->booking_taxes = null; 
    145145        } 
     
    225225     
    226226    /** 
    227      * Load an record into this object by passing an associative array of table criterie to search for.  
     227     * Load an record into this object by passing an associative array of table criteria to search for.  
    228228     * Returns boolean depending on whether a record is found or not.  
    229229     * @param $search 
     
    286286            $this->get_person(); 
    287287            //re-run compatiblity keys function 
    288             $this->compat_keys(); //depricating in 6.0 
     288            $this->compat_keys(); //depracating in 6.0 
    289289        } 
    290290        return apply_filters('em_booking_get_post',count($this->errors) == 0,$this); 
     
    330330     
    331331    /** 
    332      * Get the total number of spaces booked in THIS booking. Seting $force_refresh to true will recheck spaces, even if previously done so. 
     332     * Get the total number of spaces booked in THIS booking. Setting $force_refresh to true will recheck spaces, even if previously done so. 
    333333     * @param unknown_type $force_refresh 
    334334     * @return mixed 
     
    630630     
    631631    /** 
    632      * Gets the event this booking belongs to and saves a refernece in the event property 
     632     * Gets the event this booking belongs to and saves a reference in the event property 
    633633     * @return EM_Event 
    634634     */ 
     
    848848    function cancel($email = true){ 
    849849        if( $this->person->ID == get_current_user_id() ){ 
    850             $this->manage_override = true; //normally, users can't manage a bookiing, only event owners, so we allow them to mod their booking status in this case only. 
     850            $this->manage_override = true; //normally, users can't manage a booking, only event owners, so we allow them to mod their booking status in this case only. 
    851851        } 
    852852        return $this->set_status(3, $email); 
  • events-manager/trunk/classes/em-bookings.php

    r1722840 r1753147  
    6464        if( $var == 'bookings' ){ 
    6565            return $this->load(); 
     66        } 
     67    } 
     68     
     69    public function __set( $var, $val ){ 
     70        if( $var == 'bookings' ){ 
     71            if( is_array($val) ){ 
     72                $this->bookings = $val; 
     73            }else{ 
     74                $this->bookings = null; 
     75            } 
    6676        } 
    6777    } 
     
    284294        global $wpdb; 
    285295        $booking_ids = array(); 
    286         //get the booking ids tied to this event 
    287         foreach( $this->bookings as $EM_Booking ){ 
    288             $booking_ids[] = $EM_Booking->booking_id; 
    289         } 
    290         $result_tickets = true; 
    291         $result = true; 
    292         if( count($booking_ids) > 0 ){ 
    293             //Delete bookings and ticket bookings 
    294             $result_tickets = $wpdb->query("DELETE FROM ". EM_TICKETS_BOOKINGS_TABLE ." WHERE booking_id IN (".implode(',',$booking_ids).");"); 
    295             $result = $wpdb->query("DELETE FROM ".EM_BOOKINGS_TABLE." WHERE booking_id IN (".implode(',',$booking_ids).")"); 
     296        if( !empty($this->bookings) ){ 
     297            //get the booking ids tied to this event or preloaded into this object 
     298            foreach( $this->bookings as $EM_Booking ){ 
     299                $booking_ids[] = $EM_Booking->booking_id; 
     300            } 
     301            $result_tickets = true; 
     302            $result = true; 
     303            if( count($booking_ids) > 0 ){ 
     304                //Delete bookings and ticket bookings 
     305                $result_tickets = $wpdb->query("DELETE FROM ". EM_TICKETS_BOOKINGS_TABLE ." WHERE booking_id IN (".implode(',',$booking_ids).");"); 
     306                $result = $wpdb->query("DELETE FROM ".EM_BOOKINGS_TABLE." WHERE booking_id IN (".implode(',',$booking_ids).")"); 
     307            } 
     308        }elseif( !empty($this->event_id) ){ 
     309            //faster way of deleting bookings for an event circumventing the need to load all bookings if it hasn't been loaded already 
     310            $event_id = absint($this->event_id); 
     311            $booking_ids = $wpdb->get_col("SELECT booking_id FROM ".EM_BOOKINGS_TABLE." WHERE event_id = '$event_id'"); 
     312            $result_tickets = $wpdb->query("DELETE FROM ". EM_TICKETS_BOOKINGS_TABLE ." WHERE booking_id IN (SELECT booking_id FROM ".EM_BOOKINGS_TABLE." WHERE event_id = '$event_id')"); 
     313            $result = $wpdb->query("DELETE FROM ".EM_BOOKINGS_TABLE." WHERE event_id = '$event_id'"); 
     314        }else{ 
     315            $result = $result_tickets == true; 
    296316        } 
    297317        do_action('em_bookings_deleted', $result, $booking_ids); 
  • events-manager/trunk/classes/em-event-post-admin.php

    r1720802 r1753147  
    162162                    $sql = $wpdb->prepare("UPDATE ".EM_EVENTS_TABLE." SET event_name=%s, event_owner=%d, event_slug=%s, event_status={$event_status}, event_private=%d WHERE event_id=%d", $where_array); 
    163163                    $wpdb->query($sql); 
     164                    //If we're saving via quick-edit in MS Global mode, then the categories need to be pushed to the ms global index 
     165                    if( EM_MS_GLOBAL && get_option('dbem_categories_enabled') && is_main_site() ){ 
     166                        $EM_Event->get_categories()->save_index(); //just save to index, WP should have saved the taxonomy data 
     167                    } 
     168                    //deal with recurrences 
    164169                    if( $EM_Event->is_recurring() && ($EM_Event->is_published() || (defined('EM_FORCE_RECURRENCES_SAVE') && EM_FORCE_RECURRENCES_SAVE)) ){ 
    165170                        //recurrences are (re)saved only if event is published 
  • events-manager/trunk/classes/em-event.php

    r1720802 r1753147  
    281281                } 
    282282            }else{ 
     283                //if searching specifically by post_id and in MS Global mode, then assume we're looking in the current blog we're in 
     284                if( $search_by == 'post_id' && EM_MS_GLOBAL ) $search_by = get_current_blog_id(); 
     285                //get post data based on ID and search context 
    283286                if(!$is_post){ 
    284287                    if( is_multisite() && (is_numeric($search_by) || $search_by == '') ){ 
     
    403406        } 
    404407        if( empty($this->location_id) && !empty($this->event_id) ) $this->location_id = 0; //just set location_id to 0 and avoid any doubt 
     408        if( EM_MS_GLOBAL && empty($this->blog_id) ) $this->blog_id = get_current_site()->blog_id; //events created before going multisite may have null values, so we set it to main site id 
    405409    } 
    406410     
    407411    function get_event_meta($blog_id = false){ 
     412        if( !empty($this->blog_id) ) $blog_id = $this->blog_id; //if there's a blog id already, there's no doubt where to look for 
    408413        if( is_numeric($blog_id) && $blog_id > 0 && is_multisite() ){ 
    409414            // if in multisite mode, switch blogs quickly to get the right post meta. 
  • events-manager/trunk/classes/em-events.php

    r1722840 r1753147  
    365365        $args['header_format'] = !empty($args['header_format']) ? $args['header_format'] :  get_option('dbem_event_list_groupby_header_format', '<h2>#s</h2>'); 
    366366        $args['date_format'] = !empty($args['date_format']) ? $args['date_format'] :  get_option('dbem_event_list_groupby_format',''); 
     367        $args = apply_filters('em_events_output_grouped_args', self::get_default_search($args)); 
    367368        //Reset some vars for counting events and displaying set arrays of events 
    368369        $atts = (array) $args; 
     
    652653            'private_only' => false, 
    653654            'post_id' => false, 
     655            //ouput_grouped specific arguments 
     656            'mode' => false, 
     657            'header_format' => false, 
     658            'date_format' => false, 
    654659            //event-specific search attributes 
    655660            'has_location' => false, //search events with a location 
  • events-manager/trunk/classes/em-taxonomy-term.php

    r1720802 r1753147  
    115115    public function get_color(){ 
    116116        if( empty($this->color) ){ 
    117             global $wpdb; 
    118             $color = $wpdb->get_var('SELECT meta_value FROM '.EM_META_TABLE." WHERE object_id='{$this->term_id}' AND meta_key='". $this->option_name ."-bgcolor' LIMIT 1"); 
    119             $this->color = ($color != '') ? $color:get_option('dbem_'.$this->option_name.'_default_color', '#FFFFFF'); 
     117            $color = wp_cache_get($this->term_id, 'em_'.$this->option_name.'_colors'); 
     118            if( $color ){ 
     119                $this->color = $color; 
     120            }else{ 
     121                global $wpdb; 
     122                $color = $wpdb->get_var('SELECT meta_value FROM '.EM_META_TABLE." WHERE object_id='{$this->term_id}' AND meta_key='". $this->option_name ."-bgcolor' LIMIT 1"); 
     123                $this->color = ($color != '') ? $color:get_option('dbem_'.$this->option_name.'_default_color', '#FFFFFF'); 
     124                wp_cache_set($this->term_id, $this->color, 'em_'.$this->option_name.'_colors'); 
     125            } 
    120126        } 
    121127        return $this->color; 
  • events-manager/trunk/classes/em-ticket.php

    r1720802 r1753147  
    233233        } 
    234234        $this->compat_keys(); 
    235         do_action('em_ticket_get_post', $this); 
     235        do_action('em_ticket_get_post', $this, $post); 
    236236    } 
    237237     
  • events-manager/trunk/classes/em-tickets.php

    r1694715 r1753147  
    105105        //get all the ticket ids 
    106106        $result = false; 
    107         $ticket_ids = array(); 
    108         foreach( $this->tickets as $EM_Ticket ){ 
    109             $ticket_ids[] = $EM_Ticket->ticket_id; 
    110         } 
    111         //check that tickets don't have bookings 
    112         if(count($ticket_ids) > 0){ 
    113             $bookings = $wpdb->get_var("SELECT COUNT(*) FROM ". EM_TICKETS_BOOKINGS_TABLE." WHERE ticket_id IN (".implode(',',$ticket_ids).")"); 
     107        if( !empty($this->tickets) ){ 
     108            //get ticket ids if tickets are already preloaded into the object 
     109            $ticket_ids = array(); 
     110            foreach( $this->tickets as $EM_Ticket ){ 
     111                $ticket_ids[] = $EM_Ticket->ticket_id; 
     112            } 
     113            //check that tickets don't have bookings 
     114            if(count($ticket_ids) > 0){ 
     115                $bookings = $wpdb->get_var("SELECT COUNT(*) FROM ". EM_TICKETS_BOOKINGS_TABLE." WHERE ticket_id IN (".implode(',',$ticket_ids).")"); 
     116                if( $bookings > 0 ){ 
     117                    $result = false; 
     118                    $this->add_error(__('You cannot delete tickets if there are any bookings associated with them. Please delete these bookings first.','events-manager')); 
     119                }else{ 
     120                    $result = $wpdb->query("DELETE FROM ".EM_TICKETS_TABLE." WHERE ticket_id IN (".implode(',',$ticket_ids).")"); 
     121                } 
     122            } 
     123        }elseif( !empty($this->event_id) ){ 
     124            //if tickets aren't preloaded into object and this belongs to an event, delete via the event ID without loading any tickets 
     125            $event_id = absint($this->event_id); 
     126            $bookings = $wpdb->get_var("SELECT COUNT(*) FROM ". EM_TICKETS_BOOKINGS_TABLE." WHERE ticket_id IN (SELECT ticket_id FROM ".EM_TICKETS_TABLE." WHERE event_id='$event_id')"); 
    114127            if( $bookings > 0 ){ 
    115128                $result = false; 
    116129                $this->add_error(__('You cannot delete tickets if there are any bookings associated with them. Please delete these bookings first.','events-manager')); 
    117130            }else{ 
    118                 $result = $wpdb->query("DELETE FROM ".EM_TICKETS_TABLE." WHERE ticket_id IN (".implode(',',$ticket_ids).")"); 
     131                $result = $wpdb->query("DELETE FROM ".EM_TICKETS_TABLE." WHERE event_id='$event_id'"); 
    119132            } 
    120133        } 
  • events-manager/trunk/events-manager.php

    r1722840 r1753147  
    22/* 
    33Plugin Name: Events Manager 
    4 Version: 5.7.3.3 
     4Version: 5.7.3.4 
    55Plugin URI: http://wp-events-plugin.com 
    66Description: Event registration and booking management for WordPress. Recurring events, locations, google maps, rss, ical, booking registration and more! 
     
    2929 
    3030// Setting constants 
    31 define('EM_VERSION', 5.733); //self expanatory 
     31define('EM_VERSION', 5.734); //self expanatory 
    3232define('EM_PRO_MIN_VERSION', 2.392); //self expanatory 
    3333define('EM_PRO_MIN_VERSION_CRITICAL', 2.377); //self expanatory 
  • events-manager/trunk/readme.txt

    r1722840 r1753147  
    100100 
    101101== Changelog == 
    102 = 5.7.3.3 = 
     102= 5.7.3.4 (dev) = 
    103103* fixed category color picker and image uploader problems 
    104104* created base classes for EM taxonomies to make adding custom EM taxonomies even easier in the future, 
     
    163163* changed bookings/tickets template for event editor to avoid loading all bookings for counting purposes 
    164164* added $include_adjustments argument to get_price_pre_taxes and get_price_post_taxes for calculation of prices without discounts/surcharges (those making use of the em_booking_get_price_post_taxes and em_booking_get_price_pre_taxes filters should check for this passed argument in their custom code) 
     165* fixed bug where event categories saved via quick or bulk edit in multisite global mode aren't reflected in subsite event lists filtering by that category 
     166* fixed events created before changing to multisite and enabling global mode not displaying images via placeholders 
     167* fixed bug in filter em_ticket_get_post where function argument $post was not passed on 
     168* improved taxonomy color retrieval so it makes use of caching 
     169* improved/optimized deletion of multiple bookings and tickets at once if belonging to an event 
    165170 
    166171= 5.7.3 = 
Note: See TracChangeset for help on using the changeset viewer.