Exemplo n.º 1
0
 /**
  * Add a booking into this event (or add spaces if person already booked this), checking that there's enough space for the event
  * @param EM_Booking $EM_Booking
  * @return boolean
  */
 function add($EM_Booking)
 {
     global $wpdb, $EM_Mailer;
     if ($this->get_available_spaces() >= $EM_Booking->get_spaces(true)) {
         //Save the booking
         $email = false;
         //set status depending on approval settings
         if (empty($EM_Booking->booking_status)) {
             //if status is not set, give 1 or 0 depending on approval settings
             $EM_Booking->booking_status = get_option('dbem_bookings_approval') ? 0 : 1;
         }
         $result = $EM_Booking->save(false);
         if ($result) {
             //Success
             $this->bookings[] = $EM_Booking;
             $email = $EM_Booking->email();
             if (get_option('dbem_bookings_approval') == 1 && $EM_Booking->booking_status == 0) {
                 $this->feedback_message = get_option('dbem_booking_feedback_pending');
             } else {
                 $this->feedback_message = get_option('dbem_booking_feedback');
             }
             if (!$email) {
                 $EM_Booking->email_not_sent = true;
                 $this->feedback_message .= ' ' . get_option('dbem_booking_feedback_nomail');
                 if (current_user_can('activate_plugins')) {
                     if (count($EM_Booking->get_errors()) > 0) {
                         $this->feedback_message .= '<br/><strong>Errors:</strong> (only admins see this message)<br/><ul><li>' . implode('</li><li>', $EM_Booking->get_errors()) . '</li></ul>';
                     } else {
                         $this->feedback_message .= '<br/><strong>No errors returned by mailer</strong> (only admins see this message)';
                     }
                 }
             }
             return apply_filters('em_bookings_add', true, $EM_Booking);
         } else {
             //Failure
             $this->errors[] = "<strong>" . get_option('dbem_booking_feedback_error') . "</strong><br />" . implode('<br />', $EM_Booking->errors);
         }
     } else {
         $this->add_error(get_option('dbem_booking_feedback_full'));
     }
     return apply_filters('em_bookings_add', false, $EM_Booking);
 }
Exemplo n.º 2
0
 /**
  * Add a booking into this event (or add spaces if person already booked this), checking that there's enough space for the event
  * @param EM_Booking $EM_Booking
  * @return boolean
  */
 function add($EM_Booking)
 {
     global $wpdb, $EM_Mailer;
     if ($this->get_available_spaces() >= $EM_Booking->get_spaces(true)) {
         //Save the booking
         $email = false;
         if (!get_option('dbem_bookings_approval') && $EM_Booking->status < 2) {
             $EM_Booking->status = 1;
         }
         $result = $EM_Booking->save(false);
         if ($result) {
             //Success
             $this->bookings[] = $EM_Booking;
             $email = $EM_Booking->email();
             if (get_option('dbem_bookings_approval') == 1 && $EM_Booking->status == 0) {
                 $this->feedback_message = __('Booking successful, pending confirmation (you will also receive an email once confirmed).', 'dbem');
             } else {
                 $this->feedback_message = __('Booking successful.', 'dbem');
             }
             if (!$email) {
                 $this->feedback_message .= ' ' . __('However, there were some problems whilst sending confirmation emails to you and/or the event contact person. You may want to contact them directly and letting them know of this error.', 'dbem');
                 if (current_user_can('activate_plugins')) {
                     if (count($EM_Booking->get_errors()) > 0) {
                         $this->feedback_message .= '<br/><strong>Errors:</strong> (only admins see this message)<br/><ul><li>' . implode('</li><li>', $EM_Booking->get_errors()) . '</li></ul>';
                     } else {
                         $this->feedback_message .= '<br/><strong>No errors returned by mailer</strong> (only admins see this message)';
                     }
                 }
             }
             return true;
         } else {
             //Failure
             $this->errors[] = "<strong>" . __('Booking could not be created', 'dbem') . ":</strong><br />" . implode('<br />', $EM_Booking->errors);
         }
     } else {
         $this->add_error(__('Booking cannot be made, not enough spaces available!', 'dbem'));
     }
     return false;
 }