Ejemplo n.º 1
0
/**
 * Check if there's any actions to take for bookings
 * @return null
 */
function em_actions_bookings()
{
    global $dbem_form_messages_booking_delete, $dbem_form_messages_booking_add;
    global $wpdb;
    global $EM_Event;
    if (@get_class($EM_Event) == 'EM_Event') {
        //ADD/EDIT Booking
        if (isset($_POST['eventAction']) && $_POST['eventAction'] == 'add_booking') {
            //$EM_Event->get_bookings();
            if ($EM_Event->get_bookings()->add(new EM_Booking($_POST))) {
                $dbem_form_messages_booking_add['success'] = $EM_Event->get_bookings()->feedback_message;
            } else {
                $dbem_form_messages_booking_add['error'] = implode('<br />', $EM_Event->get_bookings()->errors);
            }
        }
        //DELETE Booking
        if (isset($_POST['eventAction']) && $_POST['eventAction'] == 'delete_booking') {
            $EM_Person = new EM_Person();
            if ($EM_Person->get(array('person_name' => $_POST['person_name'], 'person_email' => $_POST['person_email']))) {
                $deleted = 0;
                foreach ($EM_Event->get_bookings()->bookings as $EM_Booking) {
                    if ($EM_Booking->person->id == $EM_Person->id) {
                        $EM_Booking->cancel();
                        $deleted++;
                    }
                }
            }
            if ($deleted > 0) {
                $dbem_form_messages_booking_delete['success'] = __('Booking deleted', 'dbem');
            } else {
                $dbem_form_messages_booking_delete['error'] = __('There are no bookings associated to this name and e-mail', 'dbem');
            }
        }
    }
}
Ejemplo n.º 2
0
 function get_new($args = array())
 {
     global $wpdb;
     $people_table = $wpdb->prefix . EM_PEOPLE_TABLE;
     $bookings_table = $wpdb->prefix . EM_BOOKINGS_TABLE;
     //Quick version, we can accept an array of IDs, which is easy to retrieve
     if (self::array_is_numeric($args)) {
         //Array of numbers, assume they are event IDs to retreive
         //We can just get all the events here and return them
         $sql = "SELECT * FROM {$people_table} WHERE person_id=" . implode(" OR person_id=", $args);
         $results = $wpdb->get_results(apply_filters('em_people_get_sql', $sql), ARRAY_A);
         $people = array();
         foreach ($results as $result) {
             $people[$result['person_id']] = new EM_Person($result);
         }
         return $people;
         //We return all the people matched as an EM_Event array.
     }
     //We assume it's either an empty array or array of search arguments to merge with defaults
     $args = self::get_default_search($args);
     $limit = $args['limit'] && is_numeric($args['limit']) ? "LIMIT {$args['limit']}" : '';
     $offset = $limit != "" && is_numeric($args['offset']) ? "OFFSET {$args['offset']}" : '';
     //Get the default conditions
     $conditions = self::build_sql_conditions($args);
     //Put it all together
     $where = count($conditions) > 0 ? " WHERE " . implode(" AND ", $conditions) : '';
     //Get ordering instructions
     $EM_Person = new EM_Person();
     $accepted_fields = $EM_Person->get_fields(true);
     $orderby = self::build_sql_orderby($args, $accepted_fields, get_option('dbem_people_default_order'));
     //Now, build orderby sql
     $orderby_sql = count($orderby) > 0 ? 'ORDER BY ' . implode(', ', $orderby) : '';
     //Create the SQL statement and execute
     $sql = "\n\t\t\tSELECT * FROM {$people_table}\n\t\t\tLEFT JOIN {$bookings_table} ON {$bookings_table}.person_id={$people_table}.person_id\n\t\t\t{$where}\n\t\t\tGROUP BY person_id\n\t\t\t{$orderby_sql}\n\t\t\t{$limit} {$offset}\n\t\t";
     $results = $wpdb->get_results(apply_filters('em_people_get_sql', $sql, $args), ARRAY_A);
     //If we want results directly in an array, why not have a shortcut here?
     if ($args['array'] == true) {
         return $results;
     }
     //Make returned results EM_Event objects
     $results = is_array($results) ? $results : array();
     $people = array();
     foreach ($results as $person_array) {
         $people[$person_array['person_id']] = new EM_Person($person_array);
     }
     return apply_filters('em_people_get', $people);
 }
Ejemplo n.º 3
0
 /**
  * Handles the action of someone being deleted on WordPress
  * @param int $id
  */
 public static function delete_user($id)
 {
     global $wpdb;
     if ($_REQUEST['delete_option'] == 'reassign' && is_numeric($_REQUEST['reassign_user'])) {
         $wpdb->update(EM_EVENTS_TABLE, array('event_owner' => $_REQUEST['reassign_user']), array('event_owner' => $id));
     } else {
         //User is being deleted, so we delete their events and cancel their bookings.
         $wpdb->query("DELETE FROM " . EM_EVENTS_TABLE . " WHERE event_owner={$id}");
     }
     //delete the booking completely
     if (!get_option('dbem_bookings_registration_disable') || $id != get_option('dbem_bookings_registration_user')) {
         $EM_Person = new EM_Person();
         $EM_Person->ID = $EM_Person->person_id = $id;
         foreach ($EM_Person->get_bookings() as $EM_Booking) {
             $EM_Booking->manage_override = true;
             $EM_Booking->delete();
         }
     } else {
         //user is the no-user mode assigned user, so don't delete all the guest bookings, in case of mistake.
         $wpdb->update(EM_BOOKINGS_TABLE, array('booking_status' => 3, 'person_id' => 0, 'booking_comment' => __('User deleted by administrators', 'dbem')), array('person_id' => $id));
     }
 }
Ejemplo n.º 4
0
            ?>
</a>
		<?php 
        }
        ?>
		</p>
		<?php 
    }
}
?>
<h4><?php 
_e("Events I'm Attending", 'events-manager');
?>
</h4>
<?php 
$EM_Person = new EM_Person($bp->displayed_user->id);
$EM_Bookings = $EM_Person->get_bookings(false, apply_filters('em_bp_attending_status', 1));
if (count($EM_Bookings->bookings) > 0) {
    //Get events here in one query to speed things up
    $event_ids = array();
    foreach ($EM_Bookings as $EM_Booking) {
        $event_ids[] = $EM_Booking->event_id;
    }
    echo EM_Events::output(array('event' => $event_ids));
} else {
    ?>
	<p><?php 
    _e('Not attending any events yet.', 'events-manager');
    ?>
</p>
	<?php 
Ejemplo n.º 5
0
 public static function build_sql_conditions($args = array())
 {
     self::$context = EM_POST_TYPE_EVENT;
     $conditions = parent::build_sql_conditions($args);
     if (!empty($args['search'])) {
         $like_search = array('event_name', EM_EVENTS_TABLE . '.post_content', 'location_name', 'location_address', 'location_town', 'location_postcode', 'location_state', 'location_country', 'location_region');
         $conditions['search'] = "(" . implode(" LIKE '%{$args['search']}%' OR ", $like_search) . "  LIKE '%{$args['search']}%')";
     }
     $conditions['status'] = "(`event_status` >= 0 )";
     //shows pending & published if not defined
     if (array_key_exists('status', $args)) {
         if (is_numeric($args['status'])) {
             $conditions['status'] = "(`event_status`={$args['status']})";
             //pending or published
         } elseif ($args['status'] == 'pending') {
             $conditions['status'] = "(`event_status`=0)";
             //pending
         } elseif ($args['status'] == 'publish') {
             $conditions['status'] = "(`event_status`=1)";
             //published
         } elseif ($args['status'] === null || $args['status'] == 'draft') {
             $conditions['status'] = "(`event_status` IS NULL )";
             //show draft items
         } elseif ($args['status'] == 'trash') {
             $conditions['status'] = "(`event_status` = -1 )";
             //show trashed items
         } elseif ($args['status'] == 'all') {
             $conditions['status'] = "(`event_status` >= 0 OR `event_status` IS NULL)";
             //search all statuses that aren't trashed
         } elseif ($args['status'] == 'everything') {
             unset($conditions['status']);
             //search all statuses
         }
     }
     //private events
     if (empty($args['private'])) {
         $conditions['private'] = "(`event_private`=0)";
     } elseif (!empty($args['private_only'])) {
         $conditions['private_only'] = "(`event_private`=1)";
     }
     if (EM_MS_GLOBAL && !empty($args['blog'])) {
         if (is_numeric($args['blog'])) {
             if (is_main_site($args['blog'])) {
                 $conditions['blog'] = "(" . EM_EVENTS_TABLE . ".blog_id={$args['blog']} OR " . EM_EVENTS_TABLE . ".blog_id IS NULL)";
             } else {
                 $conditions['blog'] = "(" . EM_EVENTS_TABLE . ".blog_id={$args['blog']})";
             }
         } else {
             if (!is_array($args['blog']) && preg_match('/^([\\-0-9],?)+$/', $args['blog'])) {
                 $conditions['blog'] = "(" . EM_EVENTS_TABLE . ".blog_id IN ({$args['blog']}) )";
             } elseif (is_array($args['blog']) && self::array_is_numeric($args['blog'])) {
                 $conditions['blog'] = "(" . EM_EVENTS_TABLE . ".blog_id IN (" . implode(',', $args['blog']) . ") )";
             }
         }
     }
     if ($args['bookings'] === 'user' && is_user_logged_in()) {
         //get bookings of user
         $EM_Person = new EM_Person(get_current_user_id());
         $booking_ids = $EM_Person->get_bookings(true);
         if (count($booking_ids) > 0) {
             $conditions['bookings'] = "(event_id IN (SELECT event_id FROM " . EM_BOOKINGS_TABLE . " WHERE booking_id IN (" . implode(',', $booking_ids) . ")))";
         } else {
             $conditions['bookings'] = "(event_id = 0)";
         }
     }
     //post search
     if (!empty($args['post_id'])) {
         if (is_array($args['post_id'])) {
             $conditions['post_id'] = "(" . EM_EVENTS_TABLE . ".post_id IN (" . implode(',', $args['post_id']) . "))";
         } else {
             $conditions['post_id'] = "(" . EM_EVENTS_TABLE . ".post_id={$args['post_id']})";
         }
     }
     return apply_filters('em_events_build_sql_conditions', $conditions, $args);
 }
Ejemplo n.º 6
0
<?php

do_action('em_template_my_bookings_header');
global $wpdb, $current_user, $EM_Notices, $EM_Person;
if (is_user_logged_in()) {
    $EM_Person = new EM_Person(get_current_user_id());
    $EM_Bookings = $EM_Person->get_bookings();
    $bookings_count = count($EM_Bookings->bookings);
    if ($bookings_count > 0) {
        //Get events here in one query to speed things up
        $event_ids = array();
        foreach ($EM_Bookings as $EM_Booking) {
            $event_ids[] = $EM_Booking->event_id;
        }
        $EM_Events = EM_Events::get($event_ids);
    }
    $limit = !empty($_GET['limit']) ? $_GET['limit'] : 20;
    //Default limit
    $page = !empty($_GET['pno']) ? $_GET['pno'] : 1;
    $offset = $page > 1 ? ($page - 1) * $limit : 0;
    echo $EM_Notices;
    ?>
		<div class='em-my-bookings'>
				<!--
				<ul class="subsubsub">
					<li>
						<a href='edit.php?post_type=post' class="current">All <span class="count">(1)</span></a> |
					</li>
				</ul>
				-->
				<?php 
Ejemplo n.º 7
0
	<div class='wrap'>
		<div id='icon-users' class='icon32'>
			<br/>
		</div>
  		<h2>
  			<?php 
    echo sprintf(__('Ticket for %s', 'dbem'), "'{$EM_Event->name}'");
    ?>

  			<a href="<?php 
    echo $EM_Event->get_edit_url();
    ?>
" class="button add-new-h2"><?php 
    _e('View/Edit Event', 'dbem');
    ?>
</a>
  			<a href="<?php 
    echo $EM_Event->get_bookings_url();
    ?>
" class="button add-new-h2"><?php 
    _e('View Event Bookings', 'dbem');
    ?>
</a>
  		</h2> 
  		<?php 
    if (!is_admin()) {
        echo $EM_Notices;
    }
    ?>

		<div>
			<table>
				<tr><td><?php 
    echo __('Name', 'dbem');
    ?>
</td><td></td><td><?php 
    echo $EM_Ticket->ticket_name;
    ?>
</td></tr>
				<tr><td><?php 
    echo __('Description', 'dbem');
    ?>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td></td><td><?php 
    echo $EM_Ticket->ticket_description ? $EM_Ticket->ticket_description : '-';
    ?>
</td></tr>
				<tr><td><?php 
    echo __('Price', 'dbem');
    ?>
</td><td></td><td><?php 
    echo $EM_Ticket->ticket_price ? $EM_Ticket->ticket_price : '-';
    ?>
</td></tr>
				<tr><td><?php 
    echo __('Spaces', 'dbem');
    ?>
</td><td></td><td><?php 
    echo $EM_Ticket->ticket_spaces ? $EM_Ticket->ticket_spaces : '-';
    ?>
</td></tr>
				<tr><td><?php 
    echo __('Min', 'dbem');
    ?>
</td><td></td><td><?php 
    echo $EM_Ticket->ticket_min ? $EM_Ticket->ticket_min : '-';
    ?>
</td></tr>
				<tr><td><?php 
    echo __('Max', 'dbem');
    ?>
</td><td></td><td><?php 
    echo $EM_Ticket->ticket_max ? $EM_Ticket->ticket_max : '-';
    ?>
</td></tr>
				<tr><td><?php 
    echo __('Start', 'dbem');
    ?>
</td><td></td><td><?php 
    echo $EM_Ticket->ticket_start ? $EM_Ticket->ticket_start : '-';
    ?>
</td></tr>
				<tr><td><?php 
    echo __('End', 'dbem');
    ?>
</td><td></td><td><?php 
    echo $EM_Ticket->ticket_end ? $EM_Ticket->ticket_end : '-';
    ?>
</td></tr>
				<?php 
    do_action('em_booking_admin_ticket_row', $EM_Ticket);
    ?>

			</table>
		</div>
		<div class="icon32" id="icon-bookings"><br></div>
		<h2><?php 
    _e('Bookings', 'dbem');
    ?>
</h2>
		<?php 
    $EM_Bookings_Table = new EM_Bookings_Table();
    $EM_Bookings_Table->status = get_option('dbem_bookings_approval') ? 'needs-attention' : 'confirmed';
    $EM_Bookings_Table->output();
    ?>

		<?php 
    do_action('em_bookings_ticket_footer', $EM_Ticket);
    ?>

	</div>
	<?php 
}
/**
 * Shows a single booking for a single person. 
 */
function em_bookings_single()
{
    global $EM_Booking, $EM_Notices;
    /* @var $EM_Booking EM_Booking */
    //check that user can access this page
    if (is_object($EM_Booking) && !$EM_Booking->can_manage()) {
        ?>

		<div class="wrap"><h2><?php 
        _e('Unauthorized Access', 'dbem');
        ?>
</h2><p><?php 
        _e('You do not have the rights to manage this event.', 'dbem');
        ?>
</p></div>
		<?php 
        return false;
    }
    ?>

	<div class='wrap' id="em-bookings-admin-booking">
		<div class="icon32" id="icon-bookings"><br></div>
  		<h2>
  			<?php 
    _e('Edit Booking', 'dbem');
    ?>

  		</h2>
  		<?php 
    if (!is_admin()) {
        echo $EM_Notices;
    }
    ?>

  		<div id="poststuff" class="metabox-holder">
	  		<div id="post-body">
				<div id="post-body-content">
					<div class="stuffbox">
						<h3>
							<?php 
    _e('Event Details', 'dbem');
    ?>

						</h3>
						<div class="inside">
							<?php 
    $EM_Event = $EM_Booking->get_event();
    $localised_start_date = date_i18n(get_option('dbem_date_format'), $EM_Event->start);
    $localised_end_date = date_i18n(get_option('dbem_date_format'), $EM_Event->end);
    ?>

							<table>
								<tr><td><strong><?php 
    _e('Name', 'dbem');
    ?>
</strong></td><td><a class="row-title" href="<?php 
    echo $EM_Event->get_bookings_url();
    ?>
"><?php 
    echo $EM_Event->event_name;
    ?>
</a></td></tr>
								<tr>
									<td><strong><?php 
    _e('Date/Time', 'dbem');
    ?>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong></td>
									<td>
										<?php 
    echo $localised_start_date;
    ?>

										<?php 
    echo $localised_end_date != $localised_start_date ? " - {$localised_end_date}" : '';
    ?>

										<?php 
    echo substr($EM_Event->start_time, 0, 5) . " - " . substr($EM_Event->end_time, 0, 5);
    ?>

									</td>
								</tr>
							</table>
							<?php 
    do_action('em_bookings_admin_booking_event', $EM_Event);
    ?>

						</div>
					</div> 		
					<div class="stuffbox">
						<h3>
							<?php 
    _e('Personal Details', 'dbem');
    ?>

						</h3>
						<div class="inside">
							<?php 
    $no_user = get_option('dbem_bookings_registration_disable') && $EM_Booking->get_person()->ID == get_option('dbem_bookings_registration_user');
    ?>

							<div class="em-booking-person-details">
								<?php 
    echo $EM_Booking->get_person()->display_summary();
    ?>

								<?php 
    if ($no_user) {
        ?>

								<input type="button" id="em-booking-person-modify" value="<?php 
        esc_attr_e('Edit Details', 'dbem');
        ?>
" />
								<?php 
    }
    ?>

							</div>
							<?php 
    if ($no_user) {
        ?>

							<form action="" method="post" class="em-booking-person-form">
								<div class="em-booking-person-editor" style="display:none;">
									<?php 
        echo $EM_Booking->get_person_editor();
        ?>

								 	<input type='hidden' name='action' value='booking_modify_person'/>
								 	<input type='hidden' name='booking_id' value='<?php 
        echo $EM_Booking->booking_id;
        ?>
'/>
								 	<input type='hidden' name='event_id' value='<?php 
        echo $EM_Event->event_id;
        ?>
'/>
								 	<input type='hidden' name='_wpnonce' value='<?php 
        echo wp_create_nonce('booking_modify_person_' . $EM_Booking->booking_id);
        ?>
'/>
									<input type="submit" class="em-booking-person-modify-submit" id="em-booking-person-modify-submit" value="<?php 
        _e('Submit Changes', 'dbem');
        ?>
" />
									<input type="button" id="em-booking-person-modify-cancel" value="<?php 
        esc_attr_e('Cancel', 'dbem');
        ?>
" />
								</div>
							</form>	
							<script type="text/javascript">
								jQuery(document).ready( function($){
									$('#em-booking-person-modify').click(function(){
										$('.em-booking-person-details').hide();
										$('.em-booking-person-editor').show();
									});
									$('#em-booking-person-modify-cancel').click(function(){
										$('.em-booking-person-details').show();
										$('.em-booking-person-editor').hide();
									});
								});
							</script>				
							<?php 
    }
    ?>

							<?php 
    do_action('em_bookings_admin_booking_person', $EM_Booking);
    ?>

						</div>
					</div> 	
					<div class="stuffbox">
						<h3>
							<?php 
    _e('Booking Details', 'dbem');
    ?>

						</h3>
						<div class="inside">
							<?php 
    $EM_Event = $EM_Booking->get_event();
    $localised_start_date = date_i18n(get_option('date_format'), $EM_Event->start);
    $localised_end_date = date_i18n(get_option('date_format'), $EM_Event->end);
    $shown_tickets = array();
    ?>

							<div>
								<form action="" method="post" class="em-booking-single-status-info">
									<strong><?php 
    _e('Status', 'dbem');
    ?>
 : </strong>
									<?php 
    echo $EM_Booking->get_status();
    ?>

									<input type="button" class="em-booking-submit-status-modify" id="em-booking-submit-status-modify" value="<?php 
    _e('Change', 'dbem');
    ?>
" />
									<input type="submit" class="em-booking-resend-email" id="em-booking-resend-email" value="<?php 
    _e('Resend Email', 'dbem');
    ?>
" />
								 	<input type='hidden' name='action' value='booking_resend_email'/>
								 	<input type='hidden' name='booking_id' value='<?php 
    echo $EM_Booking->booking_id;
    ?>
'/>
								 	<input type='hidden' name='event_id' value='<?php 
    echo $EM_Event->event_id;
    ?>
'/>
								 	<input type='hidden' name='_wpnonce' value='<?php 
    echo wp_create_nonce('booking_resend_email_' . $EM_Booking->booking_id);
    ?>
'/>
								</form>
								<form action="" method="post" class="em-booking-single-status-edit">
									<strong><?php 
    _e('Status', 'dbem');
    ?>
 : </strong>
									<select name="booking_status">
										<?php 
    foreach ($EM_Booking->status_array as $status => $status_name) {
        ?>

										<option value="<?php 
        echo esc_attr($status);
        ?>
" <?php 
        if ($status == $EM_Booking->booking_status) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo esc_html($status_name);
        ?>
</option>
										<?php 
    }
    ?>

									</select>
									<input type="checkbox" checked="checked" name="send_email" value="1" />
									<?php 
    _e('Send Email', 'dbem');
    ?>

									<input type="submit" class="em-booking-submit-status" id="em-booking-submit-status" value="<?php 
    _e('Submit Changes', 'dbem');
    ?>
" />
									<input type="button" class="em-booking-submit-status-cancel" id="em-booking-submit-status-cancel" value="<?php 
    _e('Cancel', 'dbem');
    ?>
" />
								 	<input type='hidden' name='action' value='booking_set_status'/>
								 	<input type='hidden' name='booking_id' value='<?php 
    echo $EM_Booking->booking_id;
    ?>
'/>
								 	<input type='hidden' name='event_id' value='<?php 
    echo $EM_Event->event_id;
    ?>
'/>
								 	<input type='hidden' name='_wpnonce' value='<?php 
    echo wp_create_nonce('booking_set_status_' . $EM_Booking->booking_id);
    ?>
'/>
									<br /><em><?php 
    _e('<strong>Notes:</strong> Ticket availability not taken into account when approving new bookings (i.e. you can overbook).', 'dbem');
    ?>
</em>
								</form>
							</div>
							<form action="" method="post" class="em-booking-form">
								<table class="em-tickets-bookings-table" cellpadding="0" cellspacing="0">
									<thead>
									<tr>
										<th><?php 
    _e('<!- -:bg- ->Вид билет<!- -:- -><!- -:en- ->Ticket Type<!- -:- ->', 'dbem');
    ?>
</th>
										<th><?php 
    _e('Spaces', 'dbem');
    ?>
</th>			
Ejemplo n.º 8
0
 function build_sql_conditions($args = array())
 {
     $conditions = parent::build_sql_conditions($args);
     if (!empty($args['search'])) {
         $like_search = array('event_name', EM_EVENTS_TABLE . '.post_content', 'location_name', 'location_address', 'location_town', 'location_postcode', 'location_state', 'location_country');
         $conditions['search'] = "(" . implode(" LIKE '%{$args['search']}%' OR ", $like_search) . "  LIKE '%{$args['search']}%')";
     }
     if (array_key_exists('status', $args) && is_numeric($args['status'])) {
         $null = $args['status'] == 0 ? ' OR `event_status` = 0' : '';
         $conditions['status'] = "(`event_status`={$args['status']}{$null} )";
     } elseif (empty($args['status']) || $args['status'] != 'all') {
         $conditions['status'] = "(`event_status` IS NOT NULL )";
         //by default, we don't ever show deleted items
     }
     //private events
     if (empty($args['private'])) {
         $conditions['private'] = "(`event_private`=0)";
     } elseif (!empty($args['private_only'])) {
         $conditions['private_only'] = "(`event_private`=1)";
     }
     if (EM_MS_GLOBAL && !empty($args['blog'])) {
         if (is_numeric($args['blog'])) {
             if (is_main_site($args['blog'])) {
                 $conditions['blog'] = "(" . EM_EVENTS_TABLE . ".blog_id={$args['blog']} OR " . EM_EVENTS_TABLE . ".blog_id IS NULL)";
             } else {
                 $conditions['blog'] = "(" . EM_EVENTS_TABLE . ".blog_id={$args['blog']})";
             }
         } else {
             if (!is_array($args['blog']) && preg_match('/^([\\-0-9],?)+$/', $args['blog'])) {
                 $conditions['blog'] = "(" . EM_EVENTS_TABLE . ".blog_id IN ({$args['blog']}) )";
             } elseif (is_array($args['blog']) && $this->array_is_numeric($args['blog'])) {
                 $conditions['blog'] = "(" . EM_EVENTS_TABLE . ".blog_id IN (" . implode(',', $args['blog']) . ") )";
             }
         }
     }
     if ($args['bookings'] === 'user' && is_user_logged_in()) {
         //get bookings of user
         $EM_Person = new EM_Person(get_current_user_id());
         $booking_ids = $EM_Person->get_bookings(true);
         if (count($booking_ids) > 0) {
             $conditions['bookings'] = "(event_id IN (SELECT event_id FROM " . EM_BOOKINGS_TABLE . " WHERE booking_id IN (" . implode(',', $booking_ids) . ")))";
         } else {
             $conditions['bookings'] = "(event_id = 0)";
         }
     }
     //post search
     if (!empty($args['post_id'])) {
         if (is_array($args['post_id'])) {
             $conditions['post_id'] = "(" . EM_EVENTS_TABLE . ".post_id IN (" . implode(',', $args['post_id']) . "))";
         } else {
             $conditions['post_id'] = "(" . EM_EVENTS_TABLE . ".post_id={$args['post_id']})";
         }
     }
     return apply_filters('em_events_build_sql_conditions', $conditions, $args);
 }
Ejemplo n.º 9
0
				</div>
			</div>
			<div id="em-booking-notes" class="stuffbox">
				<h3>
					<?php 
_e('Booking Notes', 'dbem');
?>
				</h3>
				<div class="inside">
					<p><?php 
esc_html_e_emp('You can add private notes below for internal reference that only event managers will see.', 'dbem');
?>
</p>
					<?php 
foreach ($EM_Multiple_Booking->get_notes() as $note) {
    $user = new EM_Person($note['author']);
    ?>
					<div>
						<?php 
    echo sprintf(esc_html_x_emp('%1$s - %2$s wrote', '[Date] - [Name] wrote', 'dbem'), date(get_option('date_format'), $note['timestamp']), $user->get_name());
    ?>
: 
						<p style="background:#efefef; padding:5px;"><?php 
    echo nl2br($note['note']);
    ?>
</p> 
					</div>
					<?php 
}
?>
					<form method="post" action="" style="padding:5px;">
Ejemplo n.º 10
0
 /**
  * Gets data from the right location according to the field ID provided. For example, user_email (emails) are retreived from the wp_users table whereas other info is usually taken from wp_usermeta
  * @param string $field_id
  */
 public static function get_user_meta($user_id = false, $field_id, $single = true)
 {
     if (!$user_id) {
         $user_id = get_current_user_id();
     }
     if ($field_id == 'user_email') {
         $WP_User = get_user_by('id', $user_id);
         $return = $WP_User->user_email;
     } elseif ($field_id == 'name') {
         $WP_User = get_user_by('id', $user_id);
         $EM_Person = new EM_Person($WP_User);
         $return = $EM_Person->get_name();
     } else {
         $return = get_user_meta($user_id, $field_id, true);
     }
     return $return;
 }