Example #1
0
function em_admin_locations($message = '', $fill_fields = false)
{
    global $current_site;
    ?>
		<div class='wrap'>
			<div id='icon-edit' class='icon32'>
				<br/>
			</div>
 	 		<h2>
 	 			<?php 
    _e('Locations', 'dbem');
    ?>
 	 			<span><a href="<?php 
    echo em_add_get_params($_SERVER['REQUEST_URI'], array('action' => 'edit'));
    ?>
" class="button add-new-h2"><?php 
    _e('Add New', 'dbem');
    ?>
</a></span>
 	 		</h2>   
			<?php 
    em_locate_template('tables/locations.php', true, array('url' => $_SERVER['REQUEST_URI']));
    ?>
		</div>
  	<?php 
}
Example #2
0
    function em_debug_notification()
    {
        ?>
<div class="error"><p><strong><?php 
        echo sprintf(__('You are in Events Manager debug mode. To turn debug mode off, go to the <a href="%s">settings</a> page.', 'events-manager'), em_add_get_params($_SERVER['REQUEST_URI'], array('dbem_debug_off' => 1)));
        ?>
</strong></p></div><?php 
    }
Example #3
0
 function get_bookings_url()
 {
     if (get_option('dbem_edit_bookings_page') && (!is_admin() || !empty($_REQUEST['is_public']))) {
         $my_bookings_page = get_permalink(get_option('dbem_edit_bookings_page'));
         $bookings_link = em_add_get_params($my_bookings_page, array('person_id' => $this->ID, 'event_id' => null, 'ticket_id' => null, 'booking_id' => null), false);
     } else {
         $bookings_link = EM_ADMIN_URL . "&page=events-manager-bookings&person_id=" . $this->ID;
     }
     return apply_filters('em_person_get_bookings_url', $bookings_link, $this);
 }
Example #4
0
function em_admin_event_actions()
{
    if (current_user_can(EM_MIN_CAPABILITY) && !empty($_GET['page']) && $_GET['page'] == 'events-manager-event' && !empty($_REQUEST['action'])) {
        global $wpdb;
        global $EM_Event;
        //if dealing with new event, we still want an event object
        if (!is_object($EM_Event)) {
            $EM_Event = new EM_Event();
        }
        // UPDATE or CREATE action
        if ($_REQUEST['action'] == 'save') {
            $validation = $EM_Event->get_post();
            if ($validation) {
                //EM_Event gets the event if submitted via POST and validates it (safer than to depend on JS)
                //Save
                if ($EM_Event->save()) {
                    $page = !empty($_REQUEST['pno']) ? $_REQUEST['pno'] : '';
                    $scope = !empty($_REQUEST['scope']) ? $_REQUEST['scope'] : '';
                    wp_redirect(get_bloginfo('wpurl') . '/wp-admin/admin.php?page=events-manager&p=' . $page . '&scope=' . $scope . '&message=' . urlencode($EM_Event->feedback_message));
                }
            }
            //errors added automatically to event global object
        }
        //Copy the event
        if ($_REQUEST['action'] == 'duplicate') {
            global $EZSQL_ERROR;
            $EM_Event = $EM_Event->duplicate();
            if ($EM_Event === false) {
                $redirect_url = em_add_get_params($_SERVER['HTTP_REFERER'], array('error' => __('There was an error duplicating the event. Try again maybe?', 'dbem'), 'message' => ''), false);
                wp_redirect($redirect_url);
            } else {
                $page = !empty($_REQUEST['pno']) ? $_REQUEST['pno'] : '';
                $scope = !empty($_REQUEST['scope']) ? $_REQUEST['scope'] : '';
                wp_redirect(get_bloginfo('wpurl') . '/wp-admin/admin.php?page=events-manager-event&event_id=' . $EM_Event->id . '&p=' . $page . '&scope=' . $scope . '&message=' . urlencode($EM_Event->feedback_message));
            }
        }
    }
}
Example #5
0
/**
 * Generates a "widget" table of confirmed bookings for a specific event.
 * 
 * @param int $event_id
 */
function em_bookings_person_table()
{
    global $wpdb, $current_user, $EM_Person;
    if (!is_object($EM_Person)) {
        return false;
    }
    $action_scope = !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_confirmed_table';
    $action = $action_scope && !empty($_GET['action']) ? $_GET['action'] : '';
    $order = $action_scope && !empty($_GET['order']) ? $_GET['order'] : 'ASC';
    $limit = $action_scope && !empty($_GET['limit']) ? $_GET['limit'] : 20;
    //Default limit
    $page = $action_scope && !empty($_GET['pno']) ? $_GET['pno'] : 1;
    $offset = $action_scope && $page > 1 ? ($page - 1) * $limit : 0;
    $bookings = $EM_Person->get_bookings();
    $bookings_count = count($bookings);
    if ($bookings_count > 0) {
        //Get events here in one query to speed things up
        foreach ($bookings as $EM_Booking) {
            $event_ids[] = $EM_Booking->event_id;
        }
        $events = EM_Events::get($event_ids);
    }
    ?>
		<div class='wrap em_bookings_pending_table em_obj'>
			<form id='bookings-filter' method='get' action='<?php 
    bloginfo('wpurl');
    ?>
/wp-admin/edit.php'>
				<input type="hidden" name="em_obj" value="em_bookings_pending_table" />
				<!--
				<ul class="subsubsub">
					<li>
						<a href='edit.php?post_type=post' class="current">All <span class="count">(1)</span></a> |
					</li>
				</ul>
				<p class="search-box">
					<label class="screen-reader-text" for="post-search-input"><?php 
    _e('Search');
    ?>
:</label>
					<input type="text" id="post-search-input" name="em_search" value="<?php 
    echo !empty($_GET['em_search']) ? $_GET['em_search'] : '';
    ?>
" />
					<input type="submit" value="<?php 
    _e('Search');
    ?>
" class="button" />
				</p>
				-->
				<?php 
    if ($bookings_count >= $limit) {
        ?>
				<div class='tablenav'>
					<!--
					<div class="alignleft actions">
						<select name="action">
							<option value="-1" selected="selected">
								<?php 
        _e('Bulk Actions');
        ?>
							</option>
							<option value="approve">
								<?php 
        _e('Approve', 'dbem');
        ?>
							</option>
							<option value="decline">
								<?php 
        _e('Decline', 'dbem');
        ?>
							</option>
						</select> 
						<input type="submit" id="post-query-submit" value="Filter" class="button-secondary" />
					</div>
					-->
					<!--
					<div class="view-switch">
						<a href="/wp-admin/edit.php?mode=list"><img class="current" id="view-switch-list" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="List View" alt="List View" name="view-switch-list" /></a> <a href="/wp-admin/edit.php?mode=excerpt"><img id="view-switch-excerpt" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="Excerpt View" alt="Excerpt View" name="view-switch-excerpt" /></a>
					</div>
					-->
					<?php 
        if ($bookings_count >= $limit) {
            $bookings_nav = em_admin_paginate($bookings_count, $limit, $page, array('em_ajax' => 0, 'em_obj' => 'em_bookings_confirmed_table'));
            echo $bookings_nav;
        }
        ?>
					<div class="clear"></div>
				</div>
				<?php 
    }
    ?>
				<div class="clear"></div>
				<?php 
    if ($bookings_count > 0) {
        ?>
				<div class='table-wrap'>
				<table id='dbem-bookings-table' class='widefat post '>
					<thead>
						<tr>
							<th class='manage-column column-cb check-column' scope='col'>
								<input class='select-all' type="checkbox" value='1' />
							</th>
							<th class='manage-column' scope='col'>Event</th>
							<th class='manage-column' scope='col'>Spaces</th>
							<th class='manage-column' scope='col'>Status</th>
							<th class='manage-column' scope='col'>&nbsp;</th>
						</tr>
					</thead>
					<tbody>
						<?php 
        $rowno = 0;
        $event_count = 0;
        foreach ($bookings as $EM_Booking) {
            $EM_Event = $events[$EM_Booking->event_id];
            if ($EM_Event->can_manage('edit_events', 'edit_others_events') && ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0)) {
                $rowno++;
                ?>
								<tr>
									<th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php 
                echo $EM_Booking->id;
                ?>
' name='bookings[]'/></th>
									<td><a class="row-title" href="<?php 
                bloginfo('wpurl');
                ?>
/wp-admin/admin.php?page=events-manager-bookings&amp;event_id=<?php 
                echo $EM_Event->id;
                ?>
"><?php 
                echo $EM_Event->name;
                ?>
</a></td>
									<td><?php 
                echo $EM_Booking->get_spaces();
                ?>
</td>
									<td><?php 
                echo $EM_Booking->status_array[$EM_Booking->status];
                ?>
									</td>
									<td>
										<?php 
                $unapprove_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action' => 'bookings_unapprove', 'bookings' => $EM_Booking->id));
                $approve_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action' => 'bookings_approve', 'bookings' => $EM_Booking->id));
                $reject_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action' => 'bookings_reject', 'bookings' => $EM_Booking->id));
                $delete_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action' => 'bookings_delete', 'bookings' => $EM_Booking->id));
                ?>
										<?php 
                if (get_option('dbem_bookings_approval') && $EM_Booking->status == 0) {
                    ?>
										<a class="em-bookings-approve" href="<?php 
                    echo $approve_url;
                    ?>
"><?php 
                    _e('Approve', 'dbem');
                    ?>
</a> |
										<?php 
                }
                ?>
										<?php 
                if (get_option('dbem_bookings_approval') && $EM_Booking->status == 1) {
                    ?>
										<a class="em-bookings-unapprove" href="<?php 
                    echo $unapprove_url;
                    ?>
"><?php 
                    _e('Unapprove', 'dbem');
                    ?>
</a> |
										<?php 
                }
                ?>
										<?php 
                if ($EM_Booking->status == 2) {
                    ?>
										<a class="em-bookings-approve" href="<?php 
                    echo $approve_url;
                    ?>
"><?php 
                    _e('Restore', 'dbem');
                    ?>
</a> |
										<?php 
                }
                ?>
										<?php 
                if ($EM_Booking->status == 0 || $EM_Booking->status == 1) {
                    ?>
										<a class="em-bookings-reject" href="<?php 
                    echo $reject_url;
                    ?>
"><?php 
                    _e('Reject', 'dbem');
                    ?>
</a> |
										<?php 
                }
                ?>
										<a class="em-bookings-edit" href="<?php 
                bloginfo('wpurl');
                ?>
/wp-admin/admin.php?page=events-manager-bookings&amp;booking_id=<?php 
                echo $EM_Booking->id;
                ?>
"><?php 
                _e('Edit/View', 'dbem');
                ?>
</a> |
										<span class="trash"><a class="em-bookings-delete" href="<?php 
                echo $delete_url;
                ?>
"><?php 
                _e('Delete', 'dbem');
                ?>
</a></span>
									</td>
								</tr>
								<?php 
            }
            $event_count++;
        }
        ?>
					</tbody>
				</table>
				</div>
				<?php 
    } else {
        ?>
					<?php 
        _e('No confirmed bookings.', 'dbem');
        ?>
				<?php 
    }
    ?>
			</form>
			<?php 
    if (!empty($bookings_nav) && $bookings >= $limit) {
        ?>
			<div class='tablenav'>
				<?php 
        echo $bookings_nav;
        ?>
				<div class="clear"></div>
			</div>
			<?php 
    }
    ?>
		</div>	
	<?php 
}
Example #6
0
									<td><?php 
                echo date_i18n(get_option('date_format'), $EM_Event->start);
                ?>
</td>
									<td><?php 
                echo $EM_Booking->get_spaces();
                ?>
</td>
									<td>
										<?php 
                echo apply_filters('em_my_bookings_booking_status', $EM_Booking->status_array[$EM_Booking->status], $EM_Booking);
                ?>
									</td>
									<td>
										<?php 
                $cancel_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action' => 'booking_cancel', 'booking_id' => $EM_Booking->id, '_wpnonce' => $nonce));
                $cancel_link = '<a class="em-bookings-cancel" href="' . $cancel_url . '" onclick="if( !confirm(\'' . __('Are you sure you want to cancel your booking?', 'dbem') . '\') ){ return false; }">' . __('Cancel', 'dbem') . '</a>';
                echo apply_filters('em_my_bookings_booking_actions', $cancel_link, $EM_Booking);
                ?>
									</td>
								</tr>								
								<?php 
            }
            do_action('em_my_bookings_booking_loop', $EM_Booking);
            $event_count++;
        }
        ?>
					</tbody>
				</table>
				</div>
				<?php 
Example #7
0
/**
 * Generates a "widget" table of confirmed bookings for a specific event.
 * 
 * @param int $event_id
 */
function em_bookings_rejected_table()
{
    global $EM_Event, $EM_Ticket, $wpdb, $current_user;
    $action_scope = !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_confirmed_table';
    $action = $action_scope && !empty($_GET['action']) ? $_GET['action'] : '';
    $order = $action_scope && !empty($_GET['order']) ? $_GET['order'] : 'ASC';
    $limit = $action_scope && !empty($_GET['limit']) ? $_GET['limit'] : 20;
    //Default limit
    $page = $action_scope && !empty($_GET['pno']) ? $_GET['pno'] : 1;
    $offset = $action_scope && $page > 1 ? ($page - 1) * $limit : 0;
    if (is_object($EM_Ticket)) {
        $EM_Bookings = $EM_Ticket->get_bookings()->get_rejected_bookings();
    } else {
        if (is_object($EM_Event)) {
            $EM_Bookings = $EM_Event->get_bookings()->get_rejected_bookings();
        } else {
            return false;
        }
    }
    $bookings_count = is_array($EM_Bookings->bookings) ? count($EM_Bookings->bookings) : 0;
    ?>
		<div class='wrap em_bookings_pending_table em_obj'>
			<form id='bookings-filter' method='get' action='<?php 
    bloginfo('wpurl');
    ?>
/wp-admin/edit.php'>
				<input type="hidden" name="em_obj" value="em_bookings_pending_table" />
				<!--
				<ul class="subsubsub">
					<li>
						<a href='edit.php?post_type=post' class="current">All <span class="count">(1)</span></a> |
					</li>
				</ul>
				<p class="search-box">
					<label class="screen-reader-text" for="post-search-input"><?php 
    _e('Search', 'events-manager');
    ?>
:</label>
					<input type="text" id="post-search-input" name="em_search" value="<?php 
    echo !empty($_GET['em_search']) ? esc_attr($_GET['em_search']) : '';
    ?>
" />
					<input type="submit" value="<?php 
    _e('Search', 'events-manager');
    ?>
" class="button" />
				</p>
				-->
				<?php 
    if ($bookings_count >= $limit) {
        ?>
				<div class='tablenav'>
					<!--
					<div class="alignleft actions">
						<select name="action">
							<option value="-1" selected="selected">
								<?php 
        _e('Bulk Actions', 'events-manager');
        ?>
							</option>
							<option value="approve">
								<?php 
        _e('Approve', 'events-manager');
        ?>
							</option>
							<option value="decline">
								<?php 
        _e('Decline', 'events-manager');
        ?>
							</option>
						</select> 
						<input type="submit" id="post-query-submit" value="Filter" class="button-secondary" />
					</div>
					-->
					<!--
					<div class="view-switch">
						<a href="/wp-admin/edit.php?mode=list"><img class="current" id="view-switch-list" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="List View" alt="List View" name="view-switch-list" /></a> <a href="/wp-admin/edit.php?mode=excerpt"><img id="view-switch-excerpt" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="Excerpt View" alt="Excerpt View" name="view-switch-excerpt" /></a>
					</div>
					-->
					<?php 
        if ($bookings_count >= $limit) {
            $bookings_nav = em_admin_paginate($bookings_count, $limit, $page, array('em_ajax' => 0, 'em_obj' => 'em_bookings_confirmed_table'));
            echo $bookings_nav;
        }
        ?>
					<div class="clear"></div>
				</div>
				<?php 
    }
    ?>
				<div class="clear"></div>
				<?php 
    if ($bookings_count > 0) {
        ?>
				<div class='table-wrap'>
				<table id='dbem-bookings-table' class='widefat post '>
					<thead>
						<tr>
							<th class='manage-column column-cb check-column' scope='col'>
								<input class='select-all' type="checkbox" value='1' />
							</th>
							<th class='manage-column' scope='col'><?php 
        _e('Booker', 'events-manager');
        ?>
</th>
							<th class='manage-column' scope='col'><?php 
        _e('E-mail', 'events-manager');
        ?>
</th>
							<th class='manage-column' scope='col'><?php 
        _e('Phone number', 'events-manager');
        ?>
</th>
							<th class='manage-column' scope='col'><?php 
        _e('Spaces', 'events-manager');
        ?>
</th>
							<th class='manage-column' scope='col'>&nbsp;</th>
						</tr>
					</thead>
					<tbody>
						<?php 
        $rowno = 0;
        $event_count = 0;
        foreach ($EM_Bookings->bookings as $EM_Booking) {
            if (($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0)) {
                $rowno++;
                ?>
								<tr>
									<th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php 
                echo $EM_Booking->booking_id;
                ?>
' name='bookings[]'/></th>
									<td><a href="<?php 
                echo EM_ADMIN_URL;
                ?>
&amp;page=events-manager-bookings&amp;person_id=<?php 
                echo $EM_Booking->person->ID;
                ?>
"><?php 
                echo $EM_Booking->person->get_name();
                ?>
</a></td>
									<td><?php 
                echo $EM_Booking->person->user_email;
                ?>
</td>
									<td><?php 
                echo $EM_Booking->person->phone;
                ?>
</td>
									<td><?php 
                echo $EM_Booking->get_spaces();
                ?>
</td>
									<td>
										<?php 
                $approve_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action' => 'bookings_approve', 'booking_id' => $EM_Booking->booking_id));
                $delete_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action' => 'bookings_delete', 'booking_id' => $EM_Booking->booking_id));
                $edit_url = em_add_get_params($_SERVER['REQUEST_URI'], array('booking_id' => $EM_Booking->booking_id, 'em_ajax' => null, 'em_obj' => null));
                ?>
										<a class="em-bookings-approve" href="<?php 
                echo $approve_url;
                ?>
"><?php 
                _e('Approve', 'events-manager');
                ?>
</a> |
										<a class="em-bookings-edit" href="<?php 
                echo $edit_url;
                ?>
"><?php 
                _e('Edit/View', 'events-manager');
                ?>
</a> |
										<span class="trash"><a class="em-bookings-delete" href="<?php 
                echo $delete_url;
                ?>
"><?php 
                _e('Delete', 'events-manager');
                ?>
</a></span>
									</td>
								</tr>
								<?php 
            }
            $event_count++;
        }
        ?>
					</tbody>
				</table>
				</div>
				<?php 
    } else {
        ?>
					<?php 
        _e('No rejected bookings.', 'events-manager');
        ?>
				<?php 
    }
    ?>
			</form>
			<?php 
    if (!empty($bookings_nav) && $EM_Bookings >= $limit) {
        ?>
			<div class='tablenav'>
				<?php 
        echo $bookings_nav;
        ?>
				<div class="clear"></div>
			</div>
			<?php 
    }
    ?>
		</div>	
	<?php 
}
Example #8
0
' <?php 
    echo isset($_GET['view']) && $_GET['view'] == 'draft' ? 'class="current"' : '';
    ?>
><?php 
    _e('Draft', 'dbem');
    ?>
 <span class="count">(<?php 
    echo $draft_count;
    ?>
)</span></a> &nbsp;|&nbsp;
				<?php 
}
?>

				<a href='<?php 
echo em_add_get_params($_SERVER['REQUEST_URI'], $default_params + array('view' => 'past'));
?>
' <?php 
echo isset($_GET['view']) && $_GET['view'] == 'past' ? 'class="current"' : '';
?>
><?php 
_e('Past Events', 'dbem');
?>
 <span class="count">(<?php 
echo $past_count;
?>
)</span></a>
			</div>
			<p class="search-box">
				<label class="screen-reader-text" for="post-search-input"><?php 
_e('Search Events', 'dbem');
Example #9
0
 function output($format, $target = "html")
 {
     $location_string = $format;
     //First let's do some conditional placeholder removals
     for ($i = 0; $i < EM_CONDITIONAL_RECURSIONS; $i++) {
         //you can add nested recursions by modifying this setting in your wp_options table
         preg_match_all('/\\{([a-zA-Z0-9_]+)\\}(.+?)\\{\\/\\1\\}/s', $location_string, $conditionals);
         if (count($conditionals[0]) > 0) {
             //Check if the language we want exists, if not we take the first language there
             foreach ($conditionals[1] as $key => $condition) {
                 $show_condition = false;
                 if ($condition == 'has_loc_image') {
                     //does this event have an image?
                     $show_condition = $this->get_image_url() != '';
                 } elseif ($condition == 'no_loc_image') {
                     //does this event have an image?
                     $show_condition = $this->get_image_url() == '';
                 }
                 $show_condition = apply_filters('em_location_output_show_condition', $show_condition, $condition, $conditionals[0][$key], $this);
                 if ($show_condition) {
                     //calculate lengths to delete placeholders
                     $placeholder_length = strlen($condition) + 2;
                     $replacement = substr($conditionals[0][$key], $placeholder_length, strlen($conditionals[0][$key]) - ($placeholder_length * 2 + 1));
                 } else {
                     $replacement = '';
                 }
                 $location_string = str_replace($conditionals[0][$key], apply_filters('em_location_output_condition', $replacement, $condition, $conditionals[0][$key], $this), $location_string);
             }
         }
     }
     //This is for the custom attributes
     preg_match_all('/#_LATT\\{([^}]+)\\}(\\{([^}]+)\\})?/', $location_string, $results);
     foreach ($results[0] as $resultKey => $result) {
         //Strip string of placeholder and just leave the reference
         $attRef = substr(substr($result, 0, strpos($result, '}')), 7);
         $attString = '';
         if (is_array($this->location_attributes) && array_key_exists($attRef, $this->location_attributes) && !empty($this->location_attributes[$attRef])) {
             $attString = $this->location_attributes[$attRef];
         } elseif (!empty($results[3][$resultKey])) {
             //Check to see if we have a second set of braces;
             $attString = $results[3][$resultKey];
         }
         $attString = apply_filters('em_location_output_placeholder', $attString, $this, $result, $target);
         $location_string = str_replace($result, $attString, $location_string);
     }
     preg_match_all("/(#@?_?[A-Za-z0-9]+)({([^}]+)})?/", $location_string, $placeholders);
     $replaces = array();
     foreach ($placeholders[1] as $key => $result) {
         $replace = '';
         $full_result = $placeholders[0][$key];
         switch ($result) {
             case '#_LOCATIONID':
                 $replace = $this->location_id;
                 break;
             case '#_LOCATIONPOSTID':
                 $replace = $this->post_id;
                 break;
             case '#_NAME':
                 //Depricated
             //Depricated
             case '#_LOCATION':
                 //Depricated
             //Depricated
             case '#_LOCATIONNAME':
                 $replace = $this->location_name;
                 break;
             case '#_ADDRESS':
                 //Depricated
             //Depricated
             case '#_LOCATIONADDRESS':
                 $replace = $this->location_address;
                 break;
             case '#_TOWN':
                 //Depricated
             //Depricated
             case '#_LOCATIONTOWN':
                 $replace = $this->location_town;
                 break;
             case '#_LOCATIONSTATE':
                 $replace = $this->location_state;
                 break;
             case '#_LOCATIONPOSTCODE':
                 $replace = $this->location_postcode;
                 break;
             case '#_LOCATIONREGION':
                 $replace = $this->location_region;
                 break;
             case '#_LOCATIONCOUNTRY':
                 $replace = $this->get_country();
                 break;
             case '#_LOCATIONFULLLINE':
                 $replace = $this->location_address;
                 $replace .= empty($this->location_town) ? '' : ', ' . $this->location_town;
                 $replace .= empty($this->location_state) ? '' : ', ' . $this->location_state;
                 $replace .= empty($this->location_postcode) ? '' : ', ' . $this->location_postcode;
                 $replace .= empty($this->location_region) ? '' : ', ' . $this->location_region;
                 break;
             case '#_LOCATIONFULLBR':
                 $replace = $this->location_address;
                 $replace .= empty($this->location_town) ? '' : '<br />' . $this->location_town;
                 $replace .= empty($this->location_state) ? '' : '<br />' . $this->location_state;
                 $replace .= empty($this->location_postcode) ? '' : '<br />' . $this->location_postcode;
                 $replace .= empty($this->location_region) ? '' : '<br />' . $this->location_region;
                 break;
             case '#_MAP':
                 //Depricated (but will remain)
             //Depricated (but will remain)
             case '#_LOCATIONMAP':
                 ob_start();
                 $args = array();
                 if (!empty($placeholders[3][$key])) {
                     $dimensions = explode(',', $placeholders[3][$key]);
                     if (!empty($dimensions[0])) {
                         $args['width'] = $dimensions[0];
                     }
                     if (!empty($dimensions[1])) {
                         $args['height'] = $dimensions[1];
                     }
                 }
                 $template = em_locate_template('placeholders/locationmap.php', true, array('args' => $args, 'EM_Location' => $this));
                 $replace = ob_get_clean();
                 break;
             case '#_LOCATIONLONGITUDE':
                 $replace = $this->location_longitude;
                 break;
             case '#_LOCATIONLATITUDE':
                 $replace = $this->location_latitude;
                 break;
             case '#_DESCRIPTION':
                 //Depricated
             //Depricated
             case '#_EXCERPT':
                 //Depricated
             //Depricated
             case '#_LOCATIONNOTES':
             case '#_LOCATIONEXCERPT':
                 $replace = $this->post_content;
                 if ($result == "#_EXCERPT" || $result == "#_LOCATIONEXCERPT") {
                     if (!empty($this->post_excerpt)) {
                         $replace = $this->post_excerpt;
                     } else {
                         $excerpt_length = 55;
                         $excerpt_more = apply_filters('em_excerpt_more', ' ' . '[...]');
                         if (!empty($placeholders[3][$key])) {
                             $trim = true;
                             $ph_args = explode(',', $placeholders[3][$key]);
                             if (is_numeric($ph_args[0])) {
                                 $excerpt_length = $ph_args[0];
                             }
                             if (!empty($ph_args[1])) {
                                 $excerpt_more = $ph_args[1];
                             }
                         }
                         if (preg_match('/<!--more(.*?)?-->/', $replace, $matches)) {
                             $content = explode($matches[0], $replace, 2);
                             $replace = force_balance_tags($content[0]);
                         }
                         if (!empty($trim)) {
                             //shorten content by supplied number - copied from wp_trim_excerpt
                             $replace = strip_shortcodes($replace);
                             $replace = str_replace(']]>', ']]&gt;', $replace);
                             $replace = wp_trim_words($replace, $excerpt_length, $excerpt_more);
                         }
                     }
                 }
                 break;
             case '#_LOCATIONIMAGEURL':
             case '#_LOCATIONIMAGE':
                 if ($this->get_image_url() != '') {
                     $image_url = esc_url($this->get_image_url());
                     if ($result == '#_LOCATIONIMAGEURL') {
                         $replace = $this->get_image_url();
                     } else {
                         if (empty($placeholders[3][$key])) {
                             $replace = "<img src='" . $image_url . "' alt='" . esc_attr($this->location_name) . "'/>";
                         } else {
                             $image_size = explode(',', $placeholders[3][$key]);
                             if (self::array_is_numeric($image_size) && count($image_size) > 1) {
                                 if (EM_MS_GLOBAL && get_current_blog_id() != $this->blog_id) {
                                     //get a thumbnail
                                     if (get_option('dbem_disable_thumbnails')) {
                                         $image_attr = '';
                                         $image_args = array();
                                         if (empty($image_size[1]) && !empty($image_size[0])) {
                                             $image_attr = 'width="' . $image_size[0] . '"';
                                             $image_args['w'] = $image_size[0];
                                         } elseif (empty($image_size[0]) && !empty($image_size[1])) {
                                             $image_attr = 'height="' . $image_size[1] . '"';
                                             $image_args['h'] = $image_size[1];
                                         } elseif (!empty($image_size[0]) && !empty($image_size[1])) {
                                             $image_attr = 'width="' . $image_size[0] . '" height="' . $image_size[1] . '"';
                                             $image_args = array('w' => $image_size[0], 'h' => $image_size[1]);
                                         }
                                         $replace = "<img src='" . esc_url(em_add_get_params($image_url, $image_args)) . "' alt='" . esc_attr($this->location_name) . "' {$image_attr} />";
                                     } else {
                                         //location belongs to another blog, so switch blog then call the default wp fucntion
                                         if (EM_MS_GLOBAL && get_current_blog_id() != $this->blog_id) {
                                             switch_to_blog($this->blog_id);
                                             $switch_back = true;
                                         }
                                         $replace = get_the_post_thumbnail($this->ID, $image_size);
                                         if (!empty($switch_back)) {
                                             restore_current_blog();
                                         }
                                     }
                                 } else {
                                     $replace = get_the_post_thumbnail($this->ID, $image_size);
                                 }
                             } else {
                                 $replace = "<img src='" . $image_url . "' alt='" . esc_attr($this->location_name) . "'/>";
                             }
                         }
                     }
                 }
                 break;
             case '#_LOCATIONURL':
             case '#_LOCATIONLINK':
             case '#_LOCATIONPAGEURL':
                 //Depricated
                 $link = esc_url($this->get_permalink());
                 $replace = $result == '#_LOCATIONURL' || $result == '#_LOCATIONPAGEURL' ? $link : '<a href="' . $link . '" title="' . esc_attr($this->location_name) . '">' . esc_html($this->location_name) . '</a>';
                 break;
             case '#_LOCATIONEDITURL':
             case '#_LOCATIONEDITLINK':
                 if ($this->can_manage('edit_locations', 'edit_others_locations')) {
                     $link = esc_url($this->get_edit_url());
                     $replace = $result == '#_LOCATIONEDITURL' ? $link : '<a href="' . $link . '" title="' . esc_attr($this->location_name) . '">' . esc_html(sprintf(__('Edit Location', 'dbem'))) . '</a>';
                 }
                 break;
             case '#_LOCATIONICALURL':
             case '#_LOCATIONICALLINK':
                 $replace = $this->get_ical_url();
                 if ($result == '#_LOCATIONICALLINK') {
                     $replace = '<a href="' . esc_url($replace) . '">iCal</a>';
                 }
                 break;
             case '#_LOCATIONRSSURL':
             case '#_LOCATIONRSSLINK':
                 $replace = $this->get_rss_url();
                 if ($result == '#_LOCATIONRSSLINK') {
                     $replace = '<a href="' . esc_url($replace) . '">RSS</a>';
                 }
                 break;
             case '#_PASTEVENTS':
                 //Depricated
             //Depricated
             case '#_LOCATIONPASTEVENTS':
             case '#_NEXTEVENTS':
                 //Depricated
             //Depricated
             case '#_LOCATIONNEXTEVENTS':
             case '#_ALLEVENTS':
                 //Depricated
             //Depricated
             case '#_LOCATIONALLEVENTS':
                 //TODO: add limit to lists of events
                 //convert depreciated placeholders for compatability
                 $result = $result == '#_PASTEVENTS' ? '#_LOCATIONPASTEVENTS' : $result;
                 $result = $result == '#_NEXTEVENTS' ? '#_LOCATIONNEXTEVENTS' : $result;
                 $result = $result == '#_ALLEVENTS' ? '#_LOCATIONALLEVENTS' : $result;
                 //forget it ever happened? :/
                 if ($result == '#_LOCATIONPASTEVENTS') {
                     $scope = 'past';
                 } elseif ($result == '#_LOCATIONNEXTEVENTS') {
                     $scope = 'future';
                 } else {
                     $scope = 'all';
                 }
                 $events_count = EM_Events::count(array('location' => $this->location_id, 'scope' => $scope));
                 if ($events_count > 0) {
                     $args = array('location' => $this->location_id, 'scope' => $scope, 'pagination' => 1, 'ajax' => 0);
                     $args['format_header'] = get_option('dbem_location_event_list_item_header_format');
                     $args['format_footer'] = get_option('dbem_location_event_list_item_footer_format');
                     $args['format'] = get_option('dbem_location_event_list_item_format');
                     $args['limit'] = get_option('dbem_location_event_list_limit');
                     $args['page'] = !empty($_REQUEST['pno']) && is_numeric($_REQUEST['pno']) ? $_REQUEST['pno'] : 1;
                     $replace = EM_Events::output($args);
                 } else {
                     $replace = get_option('dbem_location_no_events_message');
                 }
                 break;
             case '#_LOCATIONNEXTEVENT':
                 $events = EM_Events::get(array('location' => $this->location_id, 'scope' => 'future', 'limit' => 1, 'orderby' => 'event_start_date,event_start_time'));
                 $replace = get_option('dbem_location_no_event_message');
                 foreach ($events as $EM_Event) {
                     $replace = $EM_Event->output(get_option('dbem_location_event_single_format'));
                 }
                 break;
             default:
                 $replace = $full_result;
                 break;
         }
         $replaces[$full_result] = apply_filters('em_location_output_placeholder', $replace, $this, $full_result, $target);
     }
     //sort out replacements so that during replacements shorter placeholders don't overwrite longer varieties.
     krsort($replaces);
     foreach ($replaces as $full_result => $replacement) {
         if (!in_array($full_result, array('#_DESCRIPTION', '#_LOCATIONNOTES'))) {
             $location_string = str_replace($full_result, $replacement, $location_string);
         } else {
             $desc_replace[$full_result] = $replacement;
         }
     }
     //Finally, do the location notes, so that previous placeholders don't get replaced within the content, which may use shortcodes
     if (!empty($desc_replace)) {
         foreach ($desc_replace as $full_result => $replacement) {
             $location_string = str_replace($full_result, $replacement, $location_string);
         }
     }
     return apply_filters('em_location_output', $location_string, $this, $format, $target);
 }
Example #10
0
function em_user_action_links($actions, $user)
{
    if (!is_network_admin() && current_user_can('manage_others_bookings')) {
        if (get_option('dbem_edit_bookings_page') && (!is_admin() || !empty($_REQUEST['is_public']))) {
            $my_bookings_page = get_permalink(get_option('dbem_edit_bookings_page'));
            $bookings_link = em_add_get_params($my_bookings_page, array('person_id' => $user->ID), false);
        } else {
            $bookings_link = EM_ADMIN_URL . "&page=events-manager-bookings&person_id=" . $user->ID;
        }
        $actions['bookings'] = "<a href='{$bookings_link}'>" . __('Bookings', 'events-manager') . "</a>";
    }
    return $actions;
}
Example #11
0
/**
 * Outputs table of locations belonging to user
 * @param array $args
 */
function em_locations_admin($args = array())
{
    global $EM_Location;
    if (is_user_logged_in() && current_user_can('edit_locations')) {
        if (!empty($_GET['action']) && $_GET['action'] == 'edit') {
            if (empty($_REQUEST['redirect_to'])) {
                $_REQUEST['redirect_to'] = em_add_get_params($_SERVER['REQUEST_URI'], array('action' => null, 'location_id' => null));
            }
            em_location_form();
        } else {
            if (get_option('dbem_css_editors')) {
                echo '<div class="css-locations-admin">';
            }
            $limit = !empty($_REQUEST['limit']) ? $_REQUEST['limit'] : 20;
            //Default limit
            $page = !empty($_REQUEST['pno']) ? $_REQUEST['pno'] : 1;
            $offset = $page > 1 ? ($page - 1) * $limit : 0;
            $order = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'ASC';
            if (array_key_exists('status', $_REQUEST)) {
                $status = $_REQUEST['status'] ? 1 : 0;
            } else {
                $status = false;
            }
            $blog = false;
            if (EM_MS_GLOBAL && !get_site_option('dbem_ms_mainblog_locations') && !is_main_site()) {
                //set current blog id if not on main site and using global mode whilst not forcing all locations to be on main blog
                $blog = get_current_blog_id();
            }
            $args = array('limit' => $limit, 'offset' => $offset, 'status' => $status, 'blog' => $blog);
            //count locations
            $locations_mine_count = EM_Locations::count(array('owner' => get_current_user_id(), 'blog' => $blog, 'status' => false));
            $locations_all_count = current_user_can('read_others_locations') ? EM_Locations::count(array('blog' => $blog, 'status' => false, 'owner' => false)) : 0;
            //get set of locations
            if (!empty($_REQUEST['view']) && $_REQUEST['view'] == 'others' && current_user_can('read_others_locations')) {
                $locations = EM_Locations::get($args);
                $locations_count = $locations_all_count;
            } else {
                $locations = EM_Locations::get(array_merge($args, array('owner' => get_current_user_id())));
                $locations_count = $locations_mine_count;
            }
            em_locate_template('tables/locations.php', true, array('args' => $args, 'locations' => $locations, 'locations_count' => $locations_count, 'locations_mine_count' => $locations_mine_count, 'locations_all_count' => $locations_all_count, 'page' => $page, 'limit' => $limit, 'offset' => $offset, 'show_add_new' => true));
            if (get_option('dbem_css_editors')) {
                echo '</div>';
            }
        }
    } else {
        if (get_option('dbem_css_editors')) {
            echo '<div class="css-locations-admin">';
        }
        echo '<div class="css-locations-admin-login">' . __("You must log in to view and manage your locations.", 'dbem') . '</div>';
        if (get_option('dbem_css_editors')) {
            echo '</div>';
        }
    }
}
 /**
  * Customize Booking Table Actions
  * @since 1.3
  * @version 1.0
  */
 function bookings_table_actions($actions, $EM_Booking)
 {
     if ($EM_Booking->booking_status == 1 && $this->uses_gateway($EM_Booking)) {
         return array('reject' => '<a class="em-bookings-reject" href="' . em_add_get_params($url, array('action' => 'bookings_reject', 'booking_id' => $EM_Booking->booking_id)) . '">' . __('Reject', 'mycred') . '</a>', 'delete' => '<span class="trash"><a class="em-bookings-delete" href="' . em_add_get_params($url, array('action' => 'bookings_delete', 'booking_id' => $EM_Booking->booking_id)) . '">' . __('Delete', 'mycred') . '</a></span>', 'edit' => '<a class="em-bookings-edit" href="' . em_add_get_params($EM_Booking->get_event()->get_bookings_url(), array('booking_id' => $EM_Booking->booking_id, 'em_ajax' => null, 'em_obj' => null)) . '">' . __('Edit/View', 'mycred') . '</a>');
     }
     return $actions;
 }
Example #13
0
/**
 * Perform init actions
 */
function em_init()
{
    //Hard Links
    global $EM_Mailer, $wp_rewrite;
    if (get_option("dbem_events_page") > 0) {
        define('EM_URI', get_permalink(get_option("dbem_events_page")));
        //PAGE URI OF EM
    } else {
        if ($wp_rewrite->using_permalinks()) {
            define('EM_URI', trailingslashit(home_url()) . EM_POST_TYPE_EVENT_SLUG . '/');
            //PAGE URI OF EM
        } else {
            define('EM_URI', trailingslashit(home_url()) . '?post_type=' . EM_POST_TYPE_EVENT);
            //PAGE URI OF EM
        }
    }
    if ($wp_rewrite->using_permalinks()) {
        define('EM_RSS_URI', trailingslashit(home_url()) . EM_POST_TYPE_EVENT_SLUG . '/feed/');
        //RSS PAGE URI via CPT archives page
    } else {
        define('EM_RSS_URI', em_add_get_params(home_url(), array('post_type' => EM_POST_TYPE_EVENT, 'feed' => 'rss2')));
        //RSS PAGE URI
    }
    $EM_Mailer = new EM_Mailer();
    //Upgrade/Install Routine
    if (is_admin() && current_user_can('list_users')) {
        if (EM_VERSION > get_option('dbem_version', 0) || is_multisite() && !EM_MS_GLOBAL && get_option('em_ms_global_install')) {
            require_once dirname(__FILE__) . '/em-install.php';
            em_install();
        }
    }
    //add custom functions.php file
    locate_template('plugins/events-manager/functions.php', true);
}
Example #14
0
 /**
  * Generates pagination for classes like EM_Events based on supplied arguments and whether AJAX is enabled.
  * 
  * @param array $args The arguments being searched for
  * @param integer $count The number of total items to paginate through
  * @param string $search_action The name of the action query var used to trigger a search - used in AJAX requests and normal searches
  * @param array $default_args The default arguments and values this object accepts, used to compare against $args to create a querystring
  * @param array $accepted_args Variables that can be passed on via a querystring and should be added to pagination links, objects should make use of this since the default may be EM_Object::get_default_search() due to late static binding issues
  * @return string
  * @uses em_paginate()
  */
 public static function get_pagination_links($args, $count, $search_action, $default_args = array())
 {
     $limit = !empty($args['limit']) && is_numeric($args['limit']) ? $args['limit'] : false;
     $page = !empty($args['page']) && is_numeric($args['page']) ? $args['page'] : 1;
     $pno = !empty($args['page_queryvar']) ? $args['page_queryvar'] : 'pno';
     $default_pag_args = array($pno => '%PAGE%', 'page' => null, 'search' => null, 'action' => null, 'pagination' => null);
     //clean out the bad stuff, set up page number template
     $page_url = $_SERVER['REQUEST_URI'];
     //$default_args are values that can be added to the querystring for use in searching events in pagination either in searches or ajax pagination
     if (!empty($_REQUEST['action']) && $_REQUEST['action'] == $search_action && empty($default_args)) {
         //due to late static binding issues in PHP, this'll always return EM_Object::get_default_search so this is a fall-back
         $default_args = self::get_default_search();
     }
     //go through default arguments (if defined) and build a list of unique non-default arguments that should go into the querystring
     $unique_args = array();
     //this is the set of unique arguments we'll add to the querystring
     $ignored_args = array('offset', 'ajax', 'array', 'pagination', 'format', 'format_header', 'format_footer');
     foreach ($default_args as $arg_key => $arg_default_val) {
         if (array_key_exists($arg_key, $args) && !in_array($arg_key, $ignored_args)) {
             //if array exists, implode it in case one value is already imploded for matching purposes
             $arg_val = is_array($args[$arg_key]) ? implode(',', $args[$arg_key]) : $args[$arg_key];
             $arg_default_val = is_array($arg_default_val) ? implode(',', $arg_default_val) : $arg_default_val;
             if ($arg_val != $arg_default_val) {
                 $unique_args[$arg_key] = $arg_val;
             }
         }
     }
     if (!empty($unique_args['search'])) {
         $unique_args['em_search'] = $unique_args['search'];
         //special case, since em_search is used in links rather than search, which we remove below
         unset($unique_args['search']);
     }
     //build general page link with all arguments
     $pag_args = array_merge($unique_args, $default_pag_args);
     //if we're using ajax or already did an events search via a form, add the action here for pagination links
     if (!empty($args['ajax']) || !empty($_REQUEST['action']) && $_REQUEST['action'] == $search_action) {
         $unique_args['action'] = $pag_args['action'] = $search_action;
     }
     //if we're in an ajax call, make sure we aren't calling admin-ajax.php
     if (defined('DOING_AJAX')) {
         $page_url = wp_get_referer();
     }
     //finally, glue the url with querystring and pass onto pagination function
     $page_link_template = em_add_get_params($page_url, $pag_args, false);
     //don't html encode, so em_paginate does its thing;
     if (empty($args['ajax']) || defined('DOING_AJAX')) {
         $unique_args = array();
     }
     //don't use data method if ajax is disabled or if we're already in an ajax request (SERP irrelevenat)
     $return = apply_filters('em_object_get_pagination_links', em_paginate($page_link_template, $count, $limit, $page, $unique_args), $page_link_template, $count, $limit, $page);
     //if PHP is 5.3 or later, you can specifically filter by class e.g. em_events_output_pagination - this replaces the old filter originally located in the actual child classes
     if (function_exists('get_called_class')) {
         $return = apply_filters(strtolower(get_called_class()) . '_output_pagination', $return, $page_link_template, $count, $limit, $page);
     }
     return $return;
 }
Example #15
0
    }
    ?>
				<?php 
}
?>
			</div>
			
			<?php 
do_action('em_front_event_form_footer');
?>
		</div>
		<p class="submit">
			<input type="submit" name="events_update" value="<?php 
_e('Submit Event', 'dbem');
?>
 &raquo;" />
		</p>
		<input type="hidden" name="event_id" value="<?php 
echo $EM_Event->id;
?>
" />
		<input type="hidden" name="_wpnonce" value="<?php 
echo wp_create_nonce('wpnonce_event_save');
?>
" />
		<input type="hidden" name="action" value="event_save" />
		<input type="hidden" name="redirect_to" value="<?php 
echo em_add_get_params($_SERVER['REQUEST_URI'], array('successful' => '1'));
?>
" />
	</form>
 /**
  * Output a set of matched of events
  * @param array $args
  * @return string
  */
 function output($args)
 {
     global $EM_Location;
     $EM_Location_old = $EM_Location;
     //When looping, we can replace EM_Location global with the current event in the loop
     //Can be either an array for the get search or an array of EM_Location objects
     if (is_object(current($args)) && get_class(current($args)) == 'EM_Location') {
         $func_args = func_get_args();
         $locations = $func_args[0];
         $args = !empty($func_args[1]) ? $func_args[1] : array();
         $args = apply_filters('em_locations_output_args', self::get_default_search($args), $locations);
         $limit = !empty($args['limit']) && is_numeric($args['limit']) ? $args['limit'] : false;
         $offset = !empty($args['offset']) && is_numeric($args['offset']) ? $args['offset'] : 0;
         $page = !empty($args['page']) && is_numeric($args['page']) ? $args['page'] : 1;
         $locations_count = count($locations);
     } else {
         $args = apply_filters('em_locations_output_args', self::get_default_search($args));
         $limit = !empty($args['limit']) && is_numeric($args['limit']) ? $args['limit'] : false;
         $offset = !empty($args['offset']) && is_numeric($args['offset']) ? $args['offset'] : 0;
         $page = !empty($args['page']) && is_numeric($args['page']) ? $args['page'] : 1;
         $args_count = $args;
         $args_count['limit'] = 0;
         $args_count['offset'] = 0;
         $args_count['page'] = 1;
         $locations_count = self::count($args_count);
         $locations = self::get($args);
     }
     //What format shall we output this to, or use default
     $format = $args['format'] == '' ? get_option('dbem_location_list_item_format') : $args['format'];
     $output = "";
     $locations = apply_filters('em_locations_output_locations', $locations);
     if (count($locations) > 0) {
         foreach ($locations as $EM_Location) {
             $output .= $EM_Location->output($format);
         }
         //Add headers and footers to output
         if ($format == get_option('dbem_location_list_item_format')) {
             $single_event_format_header = get_option('dbem_location_list_item_format_header');
             $single_event_format_footer = get_option('dbem_location_list_item_format_footer');
             $output = $single_event_format_header . $output . $single_event_format_footer;
         }
         //Pagination (if needed/requested)
         if (!empty($args['pagination']) && !empty($limit) && $locations_count >= $limit) {
             //Show the pagination links (unless there's less than 10 events
             $page_link_template = preg_replace('/(&|\\?)pno=\\d+/i', '', $_SERVER['REQUEST_URI']);
             $page_link_template = em_add_get_params($page_link_template, array('pno' => '%PAGE%'), false);
             //don't html encode, so em_paginate does its thing
             $output .= apply_filters('em_events_output_pagination', em_paginate($page_link_template, $locations_count, $limit, $page), $page_link_template, $locations_count, $limit, $page);
         }
     } else {
         $output = get_option('dbem_no_locations_message');
     }
     //FIXME check if reference is ok when restoring object, due to changes in php5 v 4
     $EM_Location_old = $EM_Location;
     return apply_filters('em_locations_output', $output, $locations, $args);
 }
Example #17
0
/**
 * Determines whether to show event page or events page, and saves any updates to the event or events
 * @return null
 */
function em_bookings_events_table()
{
    //TODO Simplify panel for events, use form flags to detect certain actions (e.g. submitted, etc)
    global $wpdb;
    global $EM_Event;
    $scope_names = array('past' => __('Past events', 'dbem'), 'all' => __('All events', 'dbem'), 'future' => __('Future events', 'dbem'));
    $action_scope = !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_events_table';
    $action = $action_scope && !empty($_GET['action']) ? $_GET['action'] : '';
    $order = $action_scope && !empty($_GET['order']) ? $_GET['order'] : 'ASC';
    $limit = $action_scope && !empty($_GET['limit']) ? $_GET['limit'] : 20;
    //Default limit
    $page = $action_scope && !empty($_GET['pno']) ? $_GET['pno'] : 1;
    $offset = $action_scope && $page > 1 ? ($page - 1) * $limit : 0;
    $scope = $action_scope && !empty($_GET['scope']) && array_key_exists($_GET['scope'], $scope_names) ? $_GET['scope'] : 'future';
    // No action, only showing the events list
    switch ($scope) {
        case "past":
            $title = __('Past Events', 'dbem');
            break;
        case "all":
            $title = __('All Events', 'dbem');
            break;
        default:
            $title = __('Future Events', 'dbem');
            $scope = "future";
    }
    $events = EM_Events::get(array('scope' => $scope, 'limit' => 0, 'order' => $order, 'rsvp' => true));
    $events_count = count($events);
    $use_events_end = get_option('dbem_use_event_end');
    ?>
	<div class="wrap em_bookings_events_table em_obj">
		<form id="posts-filter" action="<?php 
    echo $_SERVER['REQUEST_URI'];
    ?>
" method="get">
			<input type="hidden" name="em_obj" value="em_bookings_events_table" />
			<?php 
    if (!empty($_GET['page'])) {
        ?>
			<input type='hidden' name='page' value='events-manager-bookings' />
			<?php 
    }
    ?>
			<ul class="subsubsub">
				<li><a href='#' class="current"><?php 
    _e('Total', 'dbem');
    ?>
 <span class="count">(<?php 
    echo count($events);
    ?>
)</span></a></li>
			</ul>			
			<div class="tablenav">			
				<div class="alignleft actions">
					<!--
					<select name="action">
						<option value="-1" selected="selected"><?php 
    _e('Bulk Actions');
    ?>
</option>
						<option value="deleteEvents"><?php 
    _e('Delete selected', 'dbem');
    ?>
</option>
					</select> 
					<input type="submit" value="<?php 
    _e('Apply');
    ?>
" name="doaction2" id="doaction2" class="button-secondary action" />
					 --> 
					<select name="scope">
						<?php 
    foreach ($scope_names as $key => $value) {
        $selected = "";
        if ($key == $scope) {
            $selected = "selected='selected'";
        }
        echo "<option value='{$key}' {$selected}>{$value}</option>  ";
    }
    ?>
					</select>
					<input id="post-query-submit" class="button-secondary" type="submit" value="<?php 
    _e('Filter');
    ?>
" />
				</div>
				<!--
				<div class="view-switch">
					<a href="/wp-admin/edit.php?mode=list"><img class="current" id="view-switch-list" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="List View" alt="List View" name="view-switch-list" /></a> <a href="/wp-admin/edit.php?mode=excerpt"><img id="view-switch-excerpt" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="Excerpt View" alt="Excerpt View" name="view-switch-excerpt" /></a>
				</div>
				-->
				<?php 
    if ($events_count >= $limit) {
        $page_link_template = em_add_get_params($_SERVER['REQUEST_URI'], array('pno' => '%PAGE%', 'em_ajax' => 0, 'em_obj' => 'em_bookings_events_table'));
        $events_nav = em_admin_paginate($page_link_template, $events_count, $limit, $page, 5);
        echo $events_nav;
    }
    ?>
				<br class="clear" />
			</div>
				
			<?php 
    if (empty($events)) {
        // TODO localize
        _e('no events', 'dbem');
    } else {
        ?>
			<div class='table-wrap'>	
			<table class="widefat">
				<thead>
					<tr>
						<th class='manage-column column-cb check-column' scope='col'>
							<input class='select-all' type="checkbox" value='1' />
						</th>
						<th><?php 
        _e('Event', 'dbem');
        ?>
</th>
						<th><?php 
        _e('Date and time', 'dbem');
        ?>
</th>
					</tr>
				</thead>
				<tbody>
					<?php 
        $rowno = 0;
        $event_count = 0;
        foreach ($events as $event) {
            /* @var $event EM_Event */
            if (($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0)) {
                $rowno++;
                $class = $rowno % 2 ? ' class="alternate"' : '';
                // FIXME set to american
                $localised_start_date = date_i18n('D d M Y', $event->start);
                $localised_end_date = date_i18n('D d M Y', $event->end);
                $style = "";
                $today = date("Y-m-d");
                if ($event->start_date < $today && $event->end_date < $today) {
                    $style = "style ='background-color: #FADDB7;'";
                }
                ?>
							<tr <?php 
                echo "{$class} {$style}";
                ?>
>
				
								<td>
									<input type='checkbox' class='row-selector' value='<?php 
                echo $event->id;
                ?>
' name='events[]' />
								</td>
								<td>
									<strong>
										<a class="row-title" href="<?php 
                bloginfo('wpurl');
                ?>
/wp-admin/admin.php?page=events-manager-bookings&amp;event_id=<?php 
                echo $event->id;
                ?>
"><?php 
                echo $event->name;
                ?>
</a>
									</strong>
									&ndash; 
									<?php 
                _e("Booked Seats", 'dbem');
                ?>
: <?php 
                echo $event->get_bookings()->get_booked_seats() . "/" . $event->seats;
                ?>
									<?php 
                if (get_option('dbem_bookings_approval') == 1) {
                    ?>
										| <?php 
                    _e("Pending", 'dbem');
                    ?>
: <?php 
                    echo $event->get_bookings()->get_pending_seats();
                    ?>
									<?php 
                }
                ?>
								</td>
						
								<td>
									<?php 
                echo $localised_start_date;
                ?>
									<?php 
                echo $localised_end_date != $localised_start_date ? " - {$localised_end_date}" : '';
                ?>
									&ndash;
									<?php 
                //TODO Should 00:00 - 00:00 be treated as an all day event?
                echo substr($event->start_time, 0, 5) . " - " . substr($event->end_time, 0, 5);
                ?>
								</td>
							</tr>
							<?php 
            }
            $event_count++;
        }
        ?>
				</tbody>
			</table>
			</div>
			<?php 
    }
    // end of table
    ?>
			<div class='tablenav'>
				<div class="alignleft actions">
				<br class='clear' />
				</div>
			<?php 
    if (!empty($events_nav)) {
        ?>
				<div class="tablenav-pages">
					<?php 
        echo $events_nav;
        ?>
				</div>
				<?php 
    }
    ?>
				<br class='clear' />
			</div>
		</form>
	</div>
	<?php 
}
    static function view_page()
    {
        global $EM_Notices, $EM_Coupon, $wpdb;
        //check that user can access this page
        if (is_object($EM_Coupon) && !$EM_Coupon->can_manage('manage_bookings', 'manage_others_bookings')) {
            ?>
			<div class="wrap"><h2><?php 
            esc_html_e_emp('Unauthorized Access', 'dbem');
            ?>
</h2><p><?php 
            echo sprintf(esc_html__emp('You do not have the rights to manage this %s.', 'dbem'), __('coupon', 'em-pro'));
            ?>
</p></div>
			<?php 
            return false;
        } elseif (!is_object($EM_Coupon)) {
            $EM_Coupon = new EM_Coupon();
        }
        $limit = !empty($_GET['limit']) ? $_GET['limit'] : 20;
        //Default limit
        $page = !empty($_GET['pno']) ? $_GET['pno'] : 1;
        $offset = $page > 1 ? ($page - 1) * $limit : 0;
        //a bit hacky, but this is the only way at least for now
        $coupon_search = str_replace('a:1:{', '', serialize(array('coupon_code' => $EM_Coupon->coupon_code)));
        $coupon_search = substr($coupon_search, 0, strlen($coupon_search) - 1);
        $bookings = $wpdb->get_col('SELECT booking_id FROM ' . EM_BOOKINGS_TABLE . " WHERE booking_meta LIKE '%{$coupon_search}%' LIMIT {$limit} OFFSET {$offset}");
        //FIXME : coupon count not syncing correctly, using this as a fallback
        $coupons_count = $wpdb->get_var('SELECT COUNT(*) FROM ' . EM_BOOKINGS_TABLE . " WHERE booking_meta LIKE '%{$coupon_search}%'");
        $bookings_count = 0;
        $EM_Bookings = array();
        foreach ($bookings as $booking_id) {
            $EM_Booking = em_get_booking($booking_id);
            if (!empty($EM_Booking->booking_meta['coupon'])) {
                $coupon = new EM_Coupon($EM_Booking->booking_meta['coupon']);
                if ($EM_Coupon->coupon_code == $coupon->coupon_code && $EM_Coupon->coupon_id == $coupon->coupon_id) {
                    $bookings_count++;
                    $EM_Bookings[] = $EM_Booking;
                }
            }
        }
        ?>
		<div class='wrap nosubsub'>
			<div class="icon32" id="icon-bookings"><br></div>
			<h2><?php 
        _e('Coupon Usage History', 'em-pro');
        ?>
</h2>
			<?php 
        echo $EM_Notices;
        ?>
			<p><?php 
        echo sprintf(__('You are viewing the details of coupon %s - <a href="%s">edit</a>', 'em-pro'), '<code>' . $EM_Coupon->coupon_code . '</code>', add_query_arg(array('action' => 'edit')));
        ?>
</p>
			<p>
				<strong><?php 
        echo __('Uses', 'em-pro');
        ?>
:</strong> 
				<?php 
        if (!empty($EM_Coupon->coupon_max)) {
            echo esc_html($coupons_count . ' / ' . $EM_Coupon->coupon_max);
        } else {
            echo esc_html($coupons_count . '/' . __('Unlimited', 'em-pro'));
        }
        ?>
			</p>
			<?php 
        if ($coupons_count >= $limit) {
            ?>
			<div class='tablenav'>
				<?php 
            $bookings_nav = em_admin_paginate($coupons_count, $limit, $page, array());
            echo $bookings_nav;
            ?>
				<div class="clear"></div>
			</div>
			<?php 
        }
        ?>
			<div class="clear"></div>
			<?php 
        if ($bookings_count > 0) {
            ?>
			<div class='table-wrap'>
				<table id='dbem-bookings-table' class='widefat post '>
					<thead>
						<tr>
							<th class='manage-column' scope='col'><?php 
            esc_html_e_emp('Event', 'dbem');
            ?>
</th>
							<th class='manage-column' scope='col'><?php 
            esc_html_e_emp('Booker', 'dbem');
            ?>
</th>
							<th class='manage-column' scope='col'><?php 
            esc_html_e_emp('Spaces', 'dbem');
            ?>
</th>
							<th><?php 
            _e('Original Total Price', 'em-pro');
            ?>
</th>
							<th><?php 
            _e('Coupon Discount', 'em-pro');
            ?>
</th>
							<th><?php 
            _e('Final Price', 'em-pro');
            ?>
</th>
							<th>&nbsp;</th>
						</tr>
					</thead>
					<tfoot>
						<tr>
							<th class='manage-column' scope='col'><?php 
            esc_html_e_emp('Event', 'dbem');
            ?>
</th>
							<th class='manage-column' scope='col'><?php 
            esc_html_e_emp('Booker', 'dbem');
            ?>
</th>
							<th class='manage-column' scope='col'><?php 
            esc_html_e_emp('Spaces', 'dbem');
            ?>
</th>
							<th><?php 
            _e('Original Total Price', 'em-pro');
            ?>
</th>
							<th><?php 
            _e('Coupon Discount', 'em-pro');
            ?>
</th>
							<th><?php 
            _e('Final Price', 'em-pro');
            ?>
</th>
							<th>&nbsp;</th>
						</tr>
					</tfoot>
					<tbody>
						<?php 
            foreach ($EM_Bookings as $EM_Booking) {
                ?>
							<tr>
								<td><?php 
                echo $EM_Booking->output('#_BOOKINGSLINK');
                ?>
</td>
								<td><a href="<?php 
                echo EM_ADMIN_URL;
                ?>
&amp;page=events-manager-bookings&amp;person_id=<?php 
                echo $EM_Booking->person_id;
                ?>
"><?php 
                echo $EM_Booking->person->get_name();
                ?>
</a></td>
								<td><?php 
                echo $EM_Booking->get_spaces();
                ?>
</td>
								<td><?php 
                echo em_get_currency_formatted($EM_Booking->booking_meta['original_price']);
                ?>
</td>
								<td><?php 
                echo em_get_currency_formatted($EM_Booking->booking_meta['original_price'] - $EM_Booking->get_price());
                ?>
 <em>(<?php 
                echo $EM_Coupon->get_discount_text();
                ?>
)</em></td>
								<td><?php 
                echo em_get_currency_formatted($EM_Booking->get_price());
                ?>
</td>
								<td>										
									<?php 
                $edit_url = em_add_get_params($_SERVER['REQUEST_URI'], array('booking_id' => $EM_Booking->booking_id, 'em_ajax' => null, 'em_obj' => null));
                ?>
									<?php 
                if ($EM_Booking->can_manage()) {
                    ?>
									<a class="em-bookings-edit" href="<?php 
                    echo $edit_url;
                    ?>
"><?php 
                    esc_html_e_emp('Edit/View', 'dbem');
                    ?>
</a>
									<?php 
                }
                ?>
								</td>
							</tr>
							<?php 
            }
            ?>
					</tbody>
				</table>
			</div> <!-- table-wrap -->
			<?php 
        } else {
            ?>
			<p><?php 
            _e('Your coupon hasn\'t been used yet!', 'em-pro');
            ?>
</p>
			<?php 
        }
        ?>
		</div> <!-- wrap -->
		<?php 
    }
 /**
  * @param EM_Booking $EM_Booking
  * @return mixed
  */
 function get_booking_actions($EM_Booking)
 {
     $booking_actions = array();
     $url = $EM_Booking->get_event()->get_bookings_url();
     switch ($EM_Booking->booking_status) {
         case 0:
             if (get_option('dbem_bookings_approval')) {
                 $booking_actions = array('approve' => '<a class="em-bookings-approve" href="' . em_add_get_params($url, array('action' => 'bookings_approve', 'booking_id' => $EM_Booking->booking_id)) . '">' . __('Approve', 'dbem') . '</a>', 'reject' => '<a class="em-bookings-reject" href="' . em_add_get_params($url, array('action' => 'bookings_reject', 'booking_id' => $EM_Booking->booking_id)) . '">' . __('Reject', 'dbem') . '</a>', 'delete' => '<span class="trash"><a class="em-bookings-delete" href="' . em_add_get_params($url, array('action' => 'bookings_delete', 'booking_id' => $EM_Booking->booking_id)) . '">' . __('Delete', 'dbem') . '</a></span>', 'edit' => '<a class="em-bookings-edit" href="' . em_add_get_params($EM_Booking->get_event()->get_bookings_url(), array('booking_id' => $EM_Booking->booking_id, 'em_ajax' => null, 'em_obj' => null)) . '">' . __('Edit/View', 'dbem') . '</a>');
                 break;
             }
             //if approvals are off, treat as a 1
         //if approvals are off, treat as a 1
         case 1:
             $booking_actions = array('unapprove' => '<a class="em-bookings-unapprove" href="' . em_add_get_params($url, array('action' => 'bookings_unapprove', 'booking_id' => $EM_Booking->booking_id)) . '">' . __('Unapprove', 'dbem') . '</a>', 'reject' => '<a class="em-bookings-reject" href="' . em_add_get_params($url, array('action' => 'bookings_reject', 'booking_id' => $EM_Booking->booking_id)) . '">' . __('Reject', 'dbem') . '</a>', 'delete' => '<span class="trash"><a class="em-bookings-delete" href="' . em_add_get_params($url, array('action' => 'bookings_delete', 'booking_id' => $EM_Booking->booking_id)) . '">' . __('Delete', 'dbem') . '</a></span>', 'edit' => '<a class="em-bookings-edit" href="' . em_add_get_params($EM_Booking->get_event()->get_bookings_url(), array('booking_id' => $EM_Booking->booking_id, 'em_ajax' => null, 'em_obj' => null)) . '">' . __('Edit/View', 'dbem') . '</a>');
             break;
         case 2:
             $booking_actions = array('approve' => '<a class="em-bookings-approve" href="' . em_add_get_params($url, array('action' => 'bookings_approve', 'booking_id' => $EM_Booking->booking_id)) . '">' . __('Approve', 'dbem') . '</a>', 'delete' => '<span class="trash"><a class="em-bookings-delete" href="' . em_add_get_params($url, array('action' => 'bookings_delete', 'booking_id' => $EM_Booking->booking_id)) . '">' . __('Delete', 'dbem') . '</a></span>', 'edit' => '<a class="em-bookings-edit" href="' . em_add_get_params($EM_Booking->get_event()->get_bookings_url(), array('booking_id' => $EM_Booking->booking_id, 'em_ajax' => null, 'em_obj' => null)) . '">' . __('Edit/View', 'dbem') . '</a>');
             break;
         case 3:
             $booking_actions = array('approve' => '<a class="em-bookings-approve" href="' . em_add_get_params($url, array('action' => 'bookings_approve', 'booking_id' => $EM_Booking->booking_id)) . '">' . __('Approve', 'dbem') . '</a>', 'delete' => '<span class="trash"><a class="em-bookings-delete" href="' . em_add_get_params($url, array('action' => 'bookings_delete', 'booking_id' => $EM_Booking->booking_id)) . '">' . __('Delete', 'dbem') . '</a></span>', 'edit' => '<a class="em-bookings-edit" href="' . em_add_get_params($EM_Booking->get_event()->get_bookings_url(), array('booking_id' => $EM_Booking->booking_id, 'em_ajax' => null, 'em_obj' => null)) . '">' . __('Edit/View', 'dbem') . '</a>');
             break;
         case 4:
             $booking_actions = apply_filters('em_bookings_table_booking_actions_4', array('delete' => '<span class="trash"><a class="em-bookings-delete" href="' . em_add_get_params($url, array('action' => 'bookings_delete', 'booking_id' => $EM_Booking->booking_id)) . '">' . __('Delete', 'dbem') . '</a></span>'), $EM_Booking);
             break;
         case 5:
             $booking_actions = apply_filters('em_bookings_table_booking_actions_5', array('delete' => '<span class="trash"><a class="em-bookings-delete" href="' . em_add_get_params($url, array('action' => 'bookings_delete', 'booking_id' => $EM_Booking->booking_id)) . '">' . __('Delete', 'dbem') . '</a></span>'), $EM_Booking);
             break;
         default:
             $booking_actions = apply_filters('em_bookings_table_booking_actions_' . $EM_Booking->booking_status, array(), $EM_Booking);
             break;
     }
     if (!get_option('dbem_bookings_approval')) {
         unset($booking_actions['unapprove']);
     }
     return apply_filters('em_bookings_table_cols_col_action', $booking_actions, $EM_Booking);
 }
Example #20
0
 /**
  * Output a set of matched of events. You can pass on an array of EM_Events as well, in this event you can pass args in second param.
  * Note that you can pass a 'pagination' boolean attribute to enable pagination, default is enabled (true). 
  * @param array $args
  * @param array $secondary_args
  * @return string
  */
 function output($args)
 {
     global $EM_Event;
     $EM_Event_old = $EM_Event;
     //When looping, we can replace EM_Event global with the current event in the loop
     //Can be either an array for the get search or an array of EM_Event objects
     $func_args = func_get_args();
     $page = 1;
     //default
     if (!array_key_exists('page', $args) && !empty($_REQUEST['pno']) && is_numeric($_REQUEST['pno'])) {
         $page = $args['page'] = $_REQUEST['pno'];
     }
     if (is_object(current($args)) && get_class(current($args)) == 'EM_Event') {
         $func_args = func_get_args();
         $events = $func_args[0];
         $args = !empty($func_args[1]) && is_array($func_args[1]) ? $func_args[1] : array();
         $args = apply_filters('em_events_output_args', self::get_default_search($args), $events);
         $limit = !empty($args['limit']) && is_numeric($args['limit']) ? $args['limit'] : false;
         $offset = !empty($args['offset']) && is_numeric($args['offset']) ? $args['offset'] : 0;
         $page = !empty($args['page']) && is_numeric($args['page']) ? $args['page'] : $page;
         $events_count = count($events);
     } else {
         //Firstly, let's check for a limit/offset here, because if there is we need to remove it and manually do this
         $args = apply_filters('em_events_output_args', $args);
         $limit = !empty($args['limit']) && is_numeric($args['limit']) ? $args['limit'] : false;
         $offset = !empty($args['offset']) && is_numeric($args['offset']) ? $args['offset'] : 0;
         $page = !empty($args['page']) && is_numeric($args['page']) ? $args['page'] : $page;
         $args_count = $args;
         $args_count['limit'] = false;
         $args_count['offset'] = false;
         $args_count['page'] = false;
         $events_count = self::count($args_count);
         $events = self::get($args);
     }
     //What format shall we output this to, or use default
     $format = empty($args['format']) ? get_option('dbem_event_list_item_format') : $args['format'];
     $output = "";
     $events = apply_filters('em_events_output_events', $events);
     if ($events_count > 0) {
         foreach ($events as $EM_Event) {
             $output .= $EM_Event->output($format);
         }
         //Add headers and footers to output
         if ($format == get_option('dbem_event_list_item_format')) {
             $format_header = get_option('dbem_event_list_item_format_header') == '' ? '' : get_option('dbem_event_list_item_format_header');
             $format_footer = get_option('dbem_event_list_item_format_footer') == '' ? '' : get_option('dbem_event_list_item_format_footer');
         } else {
             $format_header = !empty($args['format_header']) ? $args['format_header'] : '';
             $format_footer = !empty($args['format_footer']) ? $args['format_footer'] : '';
         }
         $output = $format_header . $output . $format_footer;
         //Pagination (if needed/requested)
         if (!empty($args['pagination']) && !empty($limit) && $events_count > $limit) {
             //Show the pagination links (unless there's less than $limit events)
             $page_link_template = preg_replace('/(&|\\?)pno=\\d+/i', '', $_SERVER['REQUEST_URI']);
             $page_link_template = em_add_get_params($page_link_template, array('pno' => '%PAGE%'), false);
             //don't html encode, so em_paginate does its thing;
             $output .= apply_filters('em_events_output_pagination', em_paginate($page_link_template, $events_count, $limit, $page), $page_link_template, $events_count, $limit, $page);
         }
     } else {
         $output = get_option('dbem_no_events_message');
     }
     //TODO check if reference is ok when restoring object, due to changes in php5 v 4
     $EM_Event = $EM_Event_old;
     $output = apply_filters('em_events_output', $output, $events, $args);
     return $output;
 }
Example #21
0
 function output($format, $target = "html")
 {
     preg_match_all('/\\{([a-zA-Z0-9_]+)\\}([^{]+)\\{\\/[a-zA-Z0-9_]+\\}/', $format, $conditionals);
     if (count($conditionals[0]) > 0) {
         //Check if the language we want exists, if not we take the first language there
         foreach ($conditionals[1] as $key => $condition) {
             $format = str_replace($conditionals[0][$key], apply_filters('em_category_output_condition', '', $condition, $conditionals[0][$key], $this), $format);
         }
     }
     $category_string = $format;
     preg_match_all("/(#@?_?[A-Za-z0-9]+)({([a-zA-Z0-9,]+)})?/", $format, $placeholders);
     $replaces = array();
     foreach ($placeholders[1] as $key => $result) {
         $replace = '';
         $full_result = $placeholders[0][$key];
         switch ($result) {
             case '#_CATEGORYNAME':
                 $replace = $this->name;
                 break;
             case '#_CATEGORYID':
                 $replace = $this->term_id;
                 break;
             case '#_CATEGORYNOTES':
             case '#_CATEGORYDESCRIPTION':
                 $replace = $this->description;
                 break;
             case '#_CATEGORYIMAGE':
             case '#_CATEGORYIMAGEURL':
                 if ($this->get_image_url() != '') {
                     $image_url = esc_url($this->get_image_url());
                     if ($result == '#_CATEGORYIMAGEURL') {
                         $replace = $image_url;
                     } else {
                         if (empty($placeholders[3][$key])) {
                             $replace = "<img src='" . esc_url($this->get_image_url()) . "' alt='" . esc_attr($this->name) . "'/>";
                         } else {
                             $image_size = explode(',', $placeholders[3][$key]);
                             if (self::array_is_numeric($image_size) && count($image_size) > 1) {
                                 if ($this->get_image_id()) {
                                     //get a thumbnail
                                     if (get_option('dbem_disable_thumbnails')) {
                                         $image_attr = '';
                                         $image_args = array();
                                         if (empty($image_size[1]) && !empty($image_size[0])) {
                                             $image_attr = 'width="' . $image_size[0] . '"';
                                             $image_args['w'] = $image_size[0];
                                         } elseif (empty($image_size[0]) && !empty($image_size[1])) {
                                             $image_attr = 'height="' . $image_size[1] . '"';
                                             $image_args['h'] = $image_size[1];
                                         } elseif (!empty($image_size[0]) && !empty($image_size[1])) {
                                             $image_attr = 'width="' . $image_size[0] . '" height="' . $image_size[1] . '"';
                                             $image_args = array('w' => $image_size[0], 'h' => $image_size[1]);
                                         }
                                         $replace = "<img src='" . esc_url(em_add_get_params($image_url, $image_args)) . "' alt='" . esc_attr($this->name) . "' {$image_attr} />";
                                     } else {
                                         //since we previously didn't store image ids along with the url to the image (since taxonomies don't allow normal featured images), sometimes we won't be able to do this, which is why we check there's a valid image id first
                                         self::ms_global_switch();
                                         $replace = wp_get_attachment_image($this->get_image_id(), $image_size);
                                         self::ms_global_switch_back();
                                     }
                                 }
                             } else {
                                 $replace = "<img src='" . esc_url($this->get_image_url()) . "' alt='" . esc_attr($this->name) . "'/>";
                             }
                         }
                     }
                 }
                 break;
             case '#_CATEGORYCOLOR':
                 $replace = $this->get_color();
                 break;
             case '#_CATEGORYLINK':
             case '#_CATEGORYURL':
                 $link = $this->get_url();
                 $replace = $result == '#_CATEGORYURL' ? $link : '<a href="' . $link . '">' . esc_html($this->name) . '</a>';
                 break;
             case '#_CATEGORYICALURL':
             case '#_CATEGORYICALLINK':
                 $replace = $this->get_ical_url();
                 if ($result == '#_CATEGORYICALLINK') {
                     $replace = '<a href="' . esc_url($replace) . '">iCal</a>';
                 }
                 break;
             case '#_CATEGORYRSSURL':
             case '#_CATEGORYRSSLINK':
                 $replace = $this->get_rss_url();
                 if ($result == '#_CATEGORYRSSLINK') {
                     $replace = '<a href="' . esc_url($replace) . '">RSS</a>';
                 }
                 break;
             case '#_CATEGORYSLUG':
                 $replace = $this->slug;
                 break;
             case '#_CATEGORYEVENTSPAST':
                 //deprecated, erroneous documentation, left for compatability
             //deprecated, erroneous documentation, left for compatability
             case '#_CATEGORYEVENTSNEXT':
                 //deprecated, erroneous documentation, left for compatability
             //deprecated, erroneous documentation, left for compatability
             case '#_CATEGORYEVENTSALL':
                 //deprecated, erroneous documentation, left for compatability
             //deprecated, erroneous documentation, left for compatability
             case '#_CATEGORYPASTEVENTS':
             case '#_CATEGORYNEXTEVENTS':
             case '#_CATEGORYALLEVENTS':
                 //convert deprecated placeholders for compatability
                 $result = $result == '#_CATEGORYEVENTSPAST' ? '#_CATEGORYPASTEVENTS' : $result;
                 $result = $result == '#_CATEGORYEVENTSNEXT' ? '#_CATEGORYNEXTEVENTS' : $result;
                 $result = $result == '#_CATEGORYEVENTSALL' ? '#_CATEGORYALLEVENTS' : $result;
                 //forget it ever happened? :/
                 if ($result == '#_CATEGORYPASTEVENTS') {
                     $scope = 'past';
                 } elseif ($result == '#_CATEGORYNEXTEVENTS') {
                     $scope = 'future';
                 } else {
                     $scope = 'all';
                 }
                 $events_count = EM_Events::count(array('category' => $this->term_id, 'scope' => $scope));
                 if ($events_count > 0) {
                     $args = array('category' => $this->term_id, 'scope' => $scope, 'pagination' => 1, 'ajax' => 0);
                     $args['format_header'] = get_option('dbem_category_event_list_item_header_format');
                     $args['format_footer'] = get_option('dbem_category_event_list_item_footer_format');
                     $args['format'] = get_option('dbem_category_event_list_item_format');
                     $args['limit'] = get_option('dbem_category_event_list_limit');
                     $args['page'] = !empty($_REQUEST['pno']) && is_numeric($_REQUEST['pno']) ? $_REQUEST['pno'] : 1;
                     $replace = EM_Events::output($args);
                 } else {
                     $replace = get_option('dbem_category_no_events_message', '</ul>');
                 }
                 break;
             case '#_CATEGORYNEXTEVENT':
                 $events = EM_Events::get(array('category' => $this->term_id, 'scope' => 'future', 'limit' => 1, 'orderby' => 'event_start_date,event_start_time'));
                 $replace = get_option('dbem_category_no_event_message');
                 foreach ($events as $EM_Event) {
                     $replace = $EM_Event->output(get_option('dbem_category_event_single_format'));
                 }
                 break;
             default:
                 $replace = $full_result;
                 break;
         }
         $replaces[$full_result] = apply_filters('em_category_output_placeholder', $replace, $this, $full_result, $target);
     }
     krsort($replaces);
     foreach ($replaces as $full_result => $replacement) {
         $category_string = str_replace($full_result, $replacement, $category_string);
     }
     return apply_filters('em_category_output', $category_string, $this, $format, $target);
 }
Example #22
0
' <?php 
echo empty($_REQUEST['view']) ? 'class="current"' : '';
?>
><?php 
echo sprintf(__('My %s', 'dbem'), __('Locations', 'dbem'));
?>
 <span class="count">(<?php 
echo $locations_mine_count;
?>
)</span></a>
		<?php 
if (current_user_can('read_others_locations')) {
    ?>
		&nbsp;|&nbsp;
		<a href='<?php 
    echo em_add_get_params($_SERVER['REQUEST_URI'], array('view' => 'others', 'pno' => null));
    ?>
' <?php 
    echo !empty($_REQUEST['view']) && $_REQUEST['view'] == 'others' ? 'class="current"' : '';
    ?>
><?php 
    echo sprintf(__('All %s', 'dbem'), __('Locations', 'dbem'));
    ?>
<span class="count">(<?php 
    echo $locations_all_count;
    ?>
)</span></a>
		<?php 
}
?>
	</div>						
Example #23
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>			
 /**
  * Adds relevant actions to booking shown in the bookings table
  * @param EM_Booking $EM_Booking
  */
 function bookings_table_actions($actions, $EM_Booking)
 {
     return array('approve' => '<a class="em-bookings-approve em-bookings-approve-offline" href="' . em_add_get_params($_SERVER['REQUEST_URI'], array('action' => 'bookings_approve', 'booking_id' => $EM_Booking->booking_id)) . '">' . __('Approve', 'dbem') . '</a>', 'delete' => '<span class="trash"><a class="em-bookings-delete" href="' . em_add_get_params($_SERVER['REQUEST_URI'], array('action' => 'bookings_delete', 'booking_id' => $EM_Booking->booking_id)) . '">' . __('Delete', 'dbem') . '</a></span>', 'edit' => '<a class="em-bookings-edit" href="' . em_add_get_params($EM_Booking->get_event()->get_bookings_url(), array('booking_id' => $EM_Booking->booking_id, 'em_ajax' => null, 'em_obj' => null)) . '">' . __('Edit/View', 'dbem') . '</a>');
 }
Example #25
0
if ($events_count > 0) {
    //If there's a search, let's change the pagination a little here
    if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'search_events') {
        $args['pagination'] = false;
        if (get_option('dbem_event_list_groupby')) {
            $args['mode'] = get_option('dbem_event_list_groupby');
            $args['date_format'] = get_option('dbem_event_list_groupby_format');
            echo em_events_list_grouped($args);
        } else {
            echo EM_Events::output($args);
        }
        //do some custom pagination (if needed/requested)
        if (!empty($args['limit']) && $events_count > $args['limit']) {
            //Show the pagination links (unless there's less than $limit events), note that we set em_search instead of search to prevent conflicts
            $search_args = array_merge(EM_Events::get_post_search(), array('pno' => '%PAGE%', 'action' => 'search_events', 'search' => null, 'em_search' => $args['search']));
            $page_link_template = em_add_get_params($_SERVER['REQUEST_URI'], $search_args, false);
            //don't html encode, so em_paginate does its thing
            echo apply_filters('em_events_output_pagination', em_paginate($page_link_template, $events_count, $args['limit'], $args['pno']), $page_link_template, $events_count, $args['limit'], $args['pno']);
        }
    } else {
        if (get_option('dbem_event_list_groupby')) {
            $args['mode'] = get_option('dbem_event_list_groupby');
            $args['date_format'] = get_option('dbem_event_list_groupby_format');
            echo em_events_list_grouped($args);
        } else {
            echo EM_Events::output($args);
        }
    }
} else {
    echo get_option('dbem_no_events_message');
}
Example #26
0
/**
 * Generate warnings and notices in the admin area
 */
function em_admin_warnings()
{
    //If we're editing the events page show hello to new user
    $events_page_id = get_option('dbem_events_page');
    $dismiss_link_joiner = count($_GET) > 0 ? '&amp;' : '?';
    if (current_user_can('activate_plugins')) {
        //New User Intro
        if (isset($_GET['disable_hello_to_user']) && $_GET['disable_hello_to_user'] == 'true') {
            // Disable Hello to new user if requested
            update_option('dbem_hello_to_user', 0);
        } elseif (get_option('dbem_hello_to_user') == 1 && !empty($_GET['page']) && $_GET['page'] == 'events-manager-events') {
            $current_user = wp_get_current_user();
            //FIXME update welcome msg with good links
            $advice = sprintf(__("<p>Hey, <strong>%s</strong>, welcome to <strong>Events Manager</strong>! We hope you like it around here.</p> \n\t\t\t<p>Now it's time to insert events lists through  <a href='%s' title='Widgets page'>widgets</a>, <a href='%s' title='Template tags documentation'>template tags</a> or <a href='%s' title='Shortcodes documentation'>shortcodes</a>.</p>\n\t\t\t<p>By the way, have you taken a look at the <a href='%s' title='Change settings'>Settings page</a>? That's where you customize the way events and locations are displayed.</p>\n\t\t\t<p>What? Tired of seeing this advice? I hear you, <a href='%s' title='Don't show this advice again'>click here</a> and you won't see this again!</p>", 'dbem'), $current_user->display_name, get_bloginfo('url') . '/wp-admin/widgets.php', 'http://wp-events-plugin.com/documentation/template-tags/', 'http://wp-events-plugin.com/documentation/shortcodes/', get_bloginfo('url') . '/wp-admin/admin.php?page=events-manager-options', get_bloginfo('url') . '/wp-admin/admin.php?page=events-manager&disable_hello_to_user=true');
            ?>
			<div id="message" class="updated">
				<?php 
            echo $advice;
            ?>
			</div>
			<?php 
        }
        //Image upload folders
        if (is_admin() && EM_IMAGE_DS == '/') {
            $errs = array();
            if (is_writable(EM_IMAGE_UPLOAD_DIR) || @mkdir(EM_IMAGE_UPLOAD_DIR, 0777)) {
                if (!is_writable(EM_IMAGE_UPLOAD_DIR . '/events/') && !@mkdir(EM_IMAGE_UPLOAD_DIR . "events/", 0777)) {
                    $errs[] = 'events';
                }
                if (!is_writable(EM_IMAGE_UPLOAD_DIR . '/locations/') && !@mkdir(EM_IMAGE_UPLOAD_DIR . "locations/", 0777)) {
                    $errs[] = 'locations';
                }
                if (!is_writable(EM_IMAGE_UPLOAD_DIR . '/categories/') && !@mkdir(EM_IMAGE_UPLOAD_DIR . "categories/", 0777)) {
                    $errs[] = 'categories';
                }
            } elseif (!is_writable(EM_IMAGE_UPLOAD_DIR)) {
                $errs = array('events', 'categories', 'locations');
            }
            if (count($errs) > 0) {
                ?>
				<div class="updated">
					<p><?php 
                echo sprintf(__('The upload directory ' . EM_IMAGE_UPLOAD_DIR . ' is must be present with these writeable folders: %s. Please create these folders with the same write permissions you use for your normal wordpress image upload folders.', 'dbem'), implode(', ', $errs));
                ?>
</p>
				</div>
				<?php 
            }
        }
        //If events page couldn't be created
        if (!empty($_GET['em_dismiss_admin_notice'])) {
            delete_option('dbem_admin_notice_' . $_GET['em_dismiss_admin_notice']);
        } else {
            if (get_option('dbem_admin_notice_3.0.91')) {
                ?>
				<div class="updated">
					<p><?php 
                echo sprintf(__('<strong>Events Manager has some new features!</strong><ul><li>Bookings can now be approved before they count towards your event\'s space allocations.</li><li>Events now have owners, and you can restrict users so they can only manage events/locations/categories they create.<br/><br/>These new permissions are enabled by default, but since you upgraded it has been disabled to maintain the previous plugin behaviour. You can re-enable it from the <a href="%s">settings page</a>. <a href="%s">Dismiss</a>', 'dbem'), get_bloginfo('url') . '/wp-admin/admin.php?page=events-manager-options', $_SERVER['REQUEST_URI'] . $dismiss_link_joiner . 'em_dismiss_admin_notice=3.0.91');
                ?>
</p>
				</div>
				<?php 
            }
        }
        //If events page couldn't be created
        if (!empty($_GET['em_dismiss_events_page'])) {
            update_option('dbem_dismiss_events_page', 1);
        } else {
            if (!get_page($events_page_id) && !get_option('dbem_dismiss_events_page')) {
                ?>
				<div id="em_page_error" class="updated">
					<p><?php 
                echo sprintf(__('Uh Oh! For some reason wordpress could not create an events page for you (or you just deleted it). Not to worry though, all you have to do is create an empty page, name it whatever you want, and select it as your events page in your <a href="%s">settings page</a>. Sorry for the extra step! If you know what you are doing, you may have done this on purpose, if so <a href="%s">ignore this message</a>', 'dbem'), get_bloginfo('url') . '/wp-admin/admin.php?page=events-manager-options', $_SERVER['REQUEST_URI'] . $dismiss_link_joiner . 'em_dismiss_events_page=1');
                ?>
</p>
				</div>
				<?php 
            }
        }
        //If events page couldn't be created
        if (!empty($_GET['em_dismiss_notice_migrate_v3'])) {
            delete_option('em_notice_migrate_v3');
        } else {
            if (get_option('em_notice_migrate_v3')) {
                ?>
				<div id="em_page_error" class="updated">
					<p><?php 
                echo sprintf(__('A <strong>LOT</strong> has changed since Events Manager 3. We recommend you take a look at the <a href="%s">settings page</a> for new features and upgrade instructions, and you may particualarly be interested in modifying permissions. <a href="%s">Dismiss</a>'), 'admin.php?page=events-manager-options', em_add_get_params($_SERVER['REQUEST_URI'], array('em_dismiss_notice_migrate_v3' => 1)));
                ?>
</p>
				</div>
				<?php 
            }
        }
        //Fixing the RC2 fiasco
        if (!empty($_GET['em_dismiss_notice_rc_reimport'])) {
            delete_option('dbem_notice_rc_reimport');
        } else {
            if (get_option('dbem_notice_rc_reimport')) {
                ?>
				<div id="em_page_error" class="updated">
					<p><?php 
                echo sprintf(__('If you upgraded from 3.x to the RC2 and the update did not go so well, <a href="%s">try reimporting old settings</a>. Warning! Re-importing will rename all event slugs, re-import your old category settings from events, and recreate all tickets, so changes to these areas will be lost. <a href="%s">Dismiss</a>'), 'admin.php?page=events-manager-options&action=em_rc_reimport&_wpnonce=' . wp_create_nonce('em_rc_reimport'), em_add_get_params($_SERVER['REQUEST_URI'], array('em_dismiss_notice_rc_reimport' => 1)));
                ?>
</p>
				</div>
				<?php 
            }
        }
        if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'em_rc_reimport' && wp_verify_nonce($_REQUEST['_wpnonce'], 'em_rc_reimport')) {
            require_once dirname(__FILE__) . '/../em-install.php';
            em_migrate_v3();
            ?>
			<div id="em_page_error" class="updated">
				<p>Reimporting old settings was successful. Click the dismiss button on the other notification if after checking things are now working.</p>
			</div>
			<?php 
        }
    }
    //Warn about EM page edit
    if (preg_match('/(post|page).php/', $_SERVER['SCRIPT_NAME']) && isset($_GET['action']) && $_GET['action'] == 'edit' && isset($_GET['post']) && $_GET['post'] == "{$events_page_id}") {
        $message = sprintf(__("This page corresponds to <strong>Events Manager</strong> events page. Its content will be overriden by Events Manager, although if you include the word CONTENTS (exactly in capitals) and surround it with other text, only CONTENTS will be overwritten. If you want to change the way your events look, go to the <a href='%s'>settings</a> page. ", 'dbem'), 'admin.php?page=events-manager-options');
        $notice = "<div class='error'><p>{$message}</p></div>";
        echo $notice;
    }
}
Example #27
0
 function get_admin_url()
 {
     if (get_option('dbem_edit_bookings_page') && (!is_admin() || !empty($_REQUEST['is_public']))) {
         $my_bookings_page = get_permalink(get_option('dbem_edit_bookings_page'));
         $bookings_link = em_add_get_params($my_bookings_page, array('event_id' => $this->event_id, 'booking_id' => 'booking_id'), false);
     } else {
         if ($this->get_event()->blog_id != get_current_blog_id()) {
             $bookings_link = get_admin_url($this->get_event()->blog_id, 'edit.php?post_type=' . EM_POST_TYPE_EVENT . "&page=events-manager-bookings&event_id=" . $this->event_id . "&booking_id=" . $this->booking_id);
         } else {
             $bookings_link = EM_ADMIN_URL . "&page=events-manager-bookings&event_id=" . $this->event_id . "&booking_id=" . $this->booking_id;
         }
     }
     return apply_filters('em_booking_get_bookings_url', $bookings_link, $this);
 }
Example #28
0
/**
 * Performs actions on init. This works for both ajax and normal requests, the return results depends if an em_ajax flag is passed via POST or GET.
 */
function em_init_actions()
{
    global $wpdb, $EM_Notices, $EM_Event;
    if (defined('DOING_AJAX') && DOING_AJAX) {
        $_REQUEST['em_ajax'] = true;
    }
    //NOTE - No EM objects are globalized at this point, as we're hitting early init mode.
    //TODO Clean this up.... use a uniformed way of calling EM Ajax actions
    if (!empty($_REQUEST['em_ajax']) || !empty($_REQUEST['em_ajax_action'])) {
        if (isset($_REQUEST['em_ajax_action']) && $_REQUEST['em_ajax_action'] == 'get_location') {
            if (isset($_REQUEST['id'])) {
                $EM_Location = new EM_Location($_REQUEST['id'], 'location_id');
                $location_array = $EM_Location->to_array();
                $location_array['location_balloon'] = $EM_Location->output(get_option('dbem_location_baloon_format'));
                echo EM_Object::json_encode($location_array);
            }
            die;
        }
        if (isset($_REQUEST['em_ajax_action']) && $_REQUEST['em_ajax_action'] == 'delete_ticket') {
            if (isset($_REQUEST['id'])) {
                $EM_Ticket = new EM_Ticket($_REQUEST['id']);
                $result = $EM_Ticket->delete();
                if ($result) {
                    $result = array('result' => true);
                } else {
                    $result = array('result' => false, 'error' => $EM_Ticket->feedback_message);
                }
            } else {
                $result = array('result' => false, 'error' => __('No ticket id provided', 'dbem'));
            }
            echo EM_Object::json_encode($result);
            die;
        }
        if (isset($_REQUEST['query']) && $_REQUEST['query'] == 'GlobalMapData') {
            $EM_Locations = EM_Locations::get($_REQUEST);
            $json_locations = array();
            foreach ($EM_Locations as $location_key => $EM_Location) {
                $json_locations[$location_key] = $EM_Location->to_array();
                $json_locations[$location_key]['location_balloon'] = $EM_Location->output(get_option('dbem_map_text_format'));
            }
            echo EM_Object::json_encode($json_locations);
            die;
        }
        if (isset($_REQUEST['ajaxCalendar']) && $_REQUEST['ajaxCalendar']) {
            //FIXME if long events enabled originally, this won't show up on ajax call
            echo EM_Calendar::output($_REQUEST, false);
            die;
        }
    }
    //Event Actions
    if (!empty($_REQUEST['action']) && substr($_REQUEST['action'], 0, 5) == 'event') {
        //Load the event object, with saved event if requested
        if (!empty($_REQUEST['event_id'])) {
            $EM_Event = new EM_Event($_REQUEST['event_id']);
        } else {
            $EM_Event = new EM_Event();
        }
        //Save Event, only via BP or via [event_form]
        if ($_REQUEST['action'] == 'event_save' && $EM_Event->can_manage('edit_events', 'edit_others_events')) {
            //Check Nonces
            if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'wpnonce_event_save')) {
                exit('Trying to perform an illegal action.');
            }
            //Grab and validate submitted data
            if ($EM_Event->get_post() && $EM_Event->save()) {
                //EM_Event gets the event if submitted via POST and validates it (safer than to depend on JS)
                $events_result = true;
                //Success notice
                if (is_user_logged_in()) {
                    $EM_Notices->add_confirm($EM_Event->output(get_option('dbem_events_form_result_success')), true);
                } else {
                    $EM_Notices->add_confirm($EM_Event->output(get_option('dbem_events_anonymous_result_success')), true);
                }
                $redirect = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : wp_get_referer();
                $redirect = em_add_get_params($redirect, array('success' => 1));
                wp_redirect($redirect);
                exit;
            } else {
                $EM_Notices->add_error($EM_Event->get_errors());
                $events_result = false;
            }
        }
        if ($_REQUEST['action'] == 'event_duplicate' && wp_verify_nonce($_REQUEST['_wpnonce'], 'event_duplicate_' . $EM_Event->event_id)) {
            $EM_Event = $EM_Event->duplicate();
            if ($EM_Event === false) {
                $EM_Notices->add_error($EM_Event->errors, true);
            } else {
                $EM_Notices->add_confirm($EM_Event->feedback_message, true);
            }
            wp_redirect(wp_get_referer());
            exit;
        }
        if ($_REQUEST['action'] == 'event_delete' && wp_verify_nonce($_REQUEST['_wpnonce'], 'event_delete_' . $EM_Event->event_id)) {
            //DELETE action
            $selectedEvents = !empty($_REQUEST['events']) ? $_REQUEST['events'] : '';
            if (EM_Object::array_is_numeric($selectedEvents)) {
                $events_result = EM_Events::delete($selectedEvents);
            } elseif (is_object($EM_Event)) {
                $events_result = $EM_Event->delete();
            }
            $plural = count($selectedEvents) > 1 ? __('Events', 'dbem') : __('Event', 'dbem');
            if ($events_result) {
                $message = !empty($EM_Event->feedback_message) ? $EM_Event->feedback_message : sprintf(__('%s successfully deleted.', 'dbem'), $plural);
                $EM_Notices->add_confirm($message, true);
            } else {
                $message = !empty($EM_Event->errors) ? $EM_Event->errors : sprintf(__('%s could not be deleted.', 'dbem'), $plural);
                $EM_Notices->add_error($message, true);
            }
            wp_redirect(wp_get_referer());
            exit;
        } elseif ($_REQUEST['action'] == 'event_detach' && wp_verify_nonce($_REQUEST['_wpnonce'], 'event_detach_' . get_current_user_id() . '_' . $EM_Event->event_id)) {
            //Detach event and move on
            if ($EM_Event->detach()) {
                $EM_Notices->add_confirm($EM_Event->feedback_message, true);
            } else {
                $EM_Notices->add_error($EM_Event->errors, true);
            }
            wp_redirect(wp_get_referer());
            exit;
        } elseif ($_REQUEST['action'] == 'event_attach' && !empty($_REQUEST['undo_id']) && wp_verify_nonce($_REQUEST['_wpnonce'], 'event_attach_' . get_current_user_id() . '_' . $EM_Event->event_id)) {
            //Detach event and move on
            if ($EM_Event->attach($_REQUEST['undo_id'])) {
                $EM_Notices->add_confirm($EM_Event->feedback_message, true);
            } else {
                $EM_Notices->add_error($EM_Event->errors, true);
            }
            wp_redirect(wp_get_referer());
            exit;
        }
        //AJAX Exit
        if (isset($events_result) && !empty($_REQUEST['em_ajax'])) {
            if ($events_result) {
                $return = array('result' => true, 'message' => $EM_Event->feedback_message);
            } else {
                $return = array('result' => false, 'message' => $EM_Event->feedback_message, 'errors' => $EM_Event->errors);
            }
        }
    }
    //Location Actions
    if (!empty($_REQUEST['action']) && substr($_REQUEST['action'], 0, 8) == 'location') {
        global $EM_Location, $EM_Notices;
        //Load the location object, with saved event if requested
        if (!empty($_REQUEST['location_id'])) {
            $EM_Location = new EM_Location($_REQUEST['location_id']);
        } else {
            $EM_Location = new EM_Location();
        }
        if ($_REQUEST['action'] == 'location_save' && current_user_can('edit_locations')) {
            if (get_site_option('dbem_ms_mainblog_locations')) {
                EM_Object::ms_global_switch();
            }
            //switch to main blog if locations are global
            //Check Nonces
            em_verify_nonce('location_save');
            //Grab and validate submitted data
            if ($EM_Location->get_post() && $EM_Location->save()) {
                //EM_location gets the location if submitted via POST and validates it (safer than to depend on JS)
                $EM_Notices->add_confirm($EM_Location->feedback_message, true);
                $redirect = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : wp_get_referer();
                wp_redirect($redirect);
                exit;
            } else {
                $EM_Notices->add_error($EM_Location->get_errors());
                $result = false;
            }
            if (get_site_option('dbem_ms_mainblog_locations')) {
                EM_Object::ms_global_switch_back();
            }
        } elseif (!empty($_REQUEST['action']) && $_REQUEST['action'] == "location_delete") {
            //delete location
            //get object or objects
            if (!empty($_REQUEST['locations']) || !empty($_REQUEST['location_id'])) {
                $args = !empty($_REQUEST['locations']) ? $_REQUEST['locations'] : $_REQUEST['location_id'];
                $locations = EM_Locations::get($args);
                foreach ($locations as $location) {
                    if (!$location->delete()) {
                        $EM_Notices->add_error($location->get_errors());
                        $errors = true;
                    }
                }
                if (empty($errors)) {
                    $result = true;
                    $location_term = count($locations) > 1 ? __('Locations', 'dbem') : __('Location', 'dbem');
                    $EM_Notices->add_confirm(sprintf(__('%s successfully deleted', 'dbem'), $location_term));
                } else {
                    $result = false;
                }
            }
        } elseif (!empty($_REQUEST['action']) && $_REQUEST['action'] == "locations_search" && (!empty($_REQUEST['term']) || !empty($_REQUEST['q']))) {
            $results = array();
            if (is_user_logged_in() || get_option('dbem_events_anonymous_submissions') && user_can(get_option('dbem_events_anonymous_user'), 'read_others_locations')) {
                $location_cond = is_user_logged_in() && !current_user_can('read_others_locations') ? "AND location_owner=" . get_current_user_id() : '';
                $term = isset($_REQUEST['term']) ? '%' . $_REQUEST['term'] . '%' : '%' . $_REQUEST['q'] . '%';
                $sql = $wpdb->prepare("\r\n\t\t\t\t\tSELECT \r\n\t\t\t\t\t\tlocation_id AS `id`,\r\n\t\t\t\t\t\tConcat( location_name, ', ', location_address, ', ', location_town)  AS `label`,\r\n\t\t\t\t\t\tlocation_name AS `value`,\r\n\t\t\t\t\t\tlocation_address AS `address`, \r\n\t\t\t\t\t\tlocation_town AS `town`, \r\n\t\t\t\t\t\tlocation_state AS `state`,\r\n\t\t\t\t\t\tlocation_region AS `region`,\r\n\t\t\t\t\t\tlocation_postcode AS `postcode`,\r\n\t\t\t\t\t\tlocation_country AS `country`\r\n\t\t\t\t\tFROM " . EM_LOCATIONS_TABLE . " \r\n\t\t\t\t\tWHERE ( `location_name` LIKE %s ) AND location_status=1 {$location_cond} LIMIT 10\r\n\t\t\t\t", $term);
                $results = $wpdb->get_results($sql);
            }
            echo EM_Object::json_encode($results);
            die;
        }
        if (isset($result) && $result && !empty($_REQUEST['em_ajax'])) {
            $return = array('result' => true, 'message' => $EM_Location->feedback_message);
            echo EM_Object::json_encode($return);
            die;
        } elseif (isset($result) && !$result && !empty($_REQUEST['em_ajax'])) {
            $return = array('result' => false, 'message' => $EM_Location->feedback_message, 'errors' => $EM_Notices->get_errors());
            echo EM_Object::json_encode($return);
            die;
        }
    }
    //Booking Actions
    if (!empty($_REQUEST['action']) && substr($_REQUEST['action'], 0, 7) == 'booking' && (is_user_logged_in() || $_REQUEST['action'] == 'booking_add' && get_option('dbem_bookings_anonymous'))) {
        global $EM_Event, $EM_Booking, $EM_Person;
        //Load the booking object, with saved booking if requested
        $EM_Booking = !empty($_REQUEST['booking_id']) ? new EM_Booking($_REQUEST['booking_id']) : new EM_Booking();
        if (!empty($EM_Booking->event_id)) {
            //Load the event object, with saved event if requested
            $EM_Event = $EM_Booking->get_event();
        } elseif (!empty($_REQUEST['event_id'])) {
            $EM_Event = new EM_Event($_REQUEST['event_id']);
        }
        $allowed_actions = array('bookings_approve' => 'approve', 'bookings_reject' => 'reject', 'bookings_unapprove' => 'unapprove', 'bookings_delete' => 'delete');
        $result = false;
        $feedback = '';
        if ($_REQUEST['action'] == 'booking_add') {
            //ADD/EDIT Booking
            ob_start();
            em_verify_nonce('booking_add');
            if (!is_user_logged_in() || get_option('dbem_bookings_double') || !$EM_Event->get_bookings()->has_booking(get_current_user_id())) {
                $post_validation = $EM_Booking->get_post();
                do_action('em_booking_add', $EM_Event, $EM_Booking, $post_validation);
                if ($post_validation) {
                    //Does this user need to be registered first?
                    $registration = true;
                    //TODO do some ticket validation before registering the user
                    if ($EM_Event->get_bookings()->get_available_spaces() >= $EM_Booking->get_spaces(true)) {
                        if ((!is_user_logged_in() || defined('EM_FORCE_REGISTRATION')) && get_option('dbem_bookings_anonymous') && !get_option('dbem_bookings_registration_disable')) {
                            //find random username - less options for user, less things go wrong
                            $username_root = explode('@', $_REQUEST['user_email']);
                            $username_rand = $username_root[0] . rand(1, 1000);
                            while (username_exists($username_root[0] . rand(1, 1000))) {
                                $username_rand = $username_root[0] . rand(1, 1000);
                            }
                            $_REQUEST['dbem_phone'] = !empty($_REQUEST['dbem_phone']) ? $_REQUEST['dbem_phone'] : '';
                            //fix to prevent warnings
                            $_REQUEST['user_name'] = !empty($_REQUEST['user_name']) ? $_REQUEST['user_name'] : '';
                            //fix to prevent warnings
                            $user_data = array('user_login' => $username_rand, 'user_email' => $_REQUEST['user_email'], 'user_name' => $_REQUEST['user_name'], 'dbem_phone' => $_REQUEST['dbem_phone']);
                            $id = em_register_new_user($user_data);
                            if (is_numeric($id)) {
                                $EM_Person = new EM_Person($id);
                                $EM_Booking->person_id = $id;
                                $feedback = get_option('dbem_booking_feedback_new_user');
                                $EM_Notices->add_confirm($feedback);
                            } else {
                                $registration = false;
                                if (is_object($id) && get_class($id) == 'WP_Error') {
                                    /* @var $id WP_Error */
                                    if ($id->get_error_code() == 'email_exists') {
                                        $EM_Notices->add_error(get_option('dbem_booking_feedback_email_exists'));
                                    } else {
                                        $EM_Notices->add_error($id->get_error_messages());
                                    }
                                } else {
                                    $EM_Notices->add_error(get_option('dbem_booking_feedback_reg_error'));
                                }
                            }
                        } elseif ((!is_user_logged_in() || defined('EM_FORCE_REGISTRATION')) && get_option('dbem_bookings_registration_disable')) {
                            //Validate name, phone and email
                            $user_data = array();
                            if (empty($EM_Booking->booking_meta['registration'])) {
                                $EM_Booking->booking_meta['registration'] = array();
                            }
                            // Check the e-mail address
                            if ($_REQUEST['user_email'] == '') {
                                $registration = false;
                                $EM_Notices->add_error(__('<strong>ERROR</strong>: Please type your e-mail address.', 'dbem'));
                            } elseif (!is_email($_REQUEST['user_email'])) {
                                $registration = false;
                                $EM_Notices->add_error(__('<strong>ERROR</strong>: The email address isn&#8217;t correct.', 'dbem'));
                            } elseif (email_exists($_REQUEST['user_email'])) {
                                $registration = false;
                                $EM_Notices->add_error(get_option('dbem_booking_feedback_email_exists'));
                            } else {
                                $user_data['user_email'] = $_REQUEST['user_email'];
                            }
                            //Check the user name
                            if (!empty($_REQUEST['user_name'])) {
                                $name_string = explode(' ', wp_kses($_REQUEST['user_name'], array()));
                                $user_data['first_name'] = array_shift($name_string);
                                $user_data['last_name'] = implode(' ', $name_string);
                            }
                            //Check the first/last name
                            if (!empty($_REQUEST['first_name'])) {
                                $user_data['first_name'] = wp_kses($_REQUEST['first_name'], array());
                            }
                            if (!empty($_REQUEST['last_name'])) {
                                $user_data['last_name'] = wp_kses($_REQUEST['last_name'], array());
                            }
                            //Check the phone
                            if (!empty($_REQUEST['dbem_phone'])) {
                                $user_data['dbem_phone'] = wp_kses($_REQUEST['dbem_phone'], array());
                            }
                            //Add booking meta
                            $EM_Booking->booking_meta['registration'] = array_merge($EM_Booking->booking_meta['registration'], $user_data);
                            //in case someone else added stuff
                            //Save default person to booking
                            $EM_Booking->person_id = get_option('dbem_bookings_registration_user');
                        } elseif (!is_user_logged_in()) {
                            $registration = false;
                            $EM_Notices->add_error(get_option('dbem_booking_feedback_log_in'));
                        } elseif (empty($EM_Booking->person_id)) {
                            //user must be logged in, so we make this person the current user id
                            $EM_Booking->person_id = get_current_user_id();
                        }
                    }
                    $EM_Bookings = $EM_Event->get_bookings();
                    if ($registration && $EM_Bookings->add($EM_Booking)) {
                        $result = true;
                        $EM_Notices->add_confirm($EM_Bookings->feedback_message);
                        $feedback = $EM_Bookings->feedback_message;
                    } else {
                        $result = false;
                        $EM_Notices->add_error($EM_Bookings->get_errors());
                        $feedback = $EM_Bookings->feedback_message;
                    }
                } else {
                    $result = false;
                    $EM_Notices->add_error($EM_Booking->get_errors());
                }
            } else {
                $result = false;
                $feedback = get_option('dbem_booking_feedback_already_booked');
                $EM_Notices->add_error($feedback);
            }
            ob_clean();
        } elseif ($_REQUEST['action'] == 'booking_add_one' && is_object($EM_Event) && is_user_logged_in()) {
            //ADD/EDIT Booking
            em_verify_nonce('booking_add_one');
            if (!$EM_Event->get_bookings()->has_booking(get_current_user_id()) || get_option('dbem_bookings_double')) {
                $EM_Booking = new EM_Booking(array('person_id' => get_current_user_id(), 'event_id' => $EM_Event->event_id, 'booking_spaces' => 1));
                //new booking
                $EM_Ticket = $EM_Event->get_bookings()->get_tickets()->get_first();
                //get first ticket in this event and book one place there. similar to getting the form values in EM_Booking::get_post_values()
                $EM_Ticket_Booking = new EM_Ticket_Booking(array('ticket_id' => $EM_Ticket->ticket_id, 'ticket_booking_spaces' => 1));
                $EM_Booking->tickets_bookings = new EM_Tickets_Bookings();
                $EM_Booking->tickets_bookings->booking = $EM_Ticket_Booking->booking = $EM_Booking;
                $EM_Booking->tickets_bookings->add($EM_Ticket_Booking);
                //Now save booking
                if ($EM_Event->get_bookings()->add($EM_Booking)) {
                    $result = true;
                    $EM_Notices->add_confirm($EM_Event->get_bookings()->feedback_message);
                    $feedback = $EM_Event->get_bookings()->feedback_message;
                } else {
                    $result = false;
                    $EM_Notices->add_error($EM_Event->get_bookings()->get_errors());
                    $feedback = $EM_Event->get_bookings()->feedback_message;
                }
            } else {
                $result = false;
                $feedback = get_option('dbem_booking_feedback_already_booked');
                $EM_Notices->add_error($feedback);
            }
        } elseif ($_REQUEST['action'] == 'booking_cancel') {
            //Cancel Booking
            em_verify_nonce('booking_cancel');
            if ($EM_Booking->can_manage() || $EM_Booking->person->ID == get_current_user_id() && get_option('dbem_bookings_user_cancellation')) {
                if ($EM_Booking->cancel()) {
                    $result = true;
                    if (!defined('DOING_AJAX')) {
                        if ($EM_Booking->person->ID == get_current_user_id()) {
                            $EM_Notices->add_confirm(get_option('dbem_booking_feedback_cancelled'), true);
                        } else {
                            $EM_Notices->add_confirm($EM_Booking->feedback_message, true);
                        }
                        wp_redirect($_SERVER['HTTP_REFERER']);
                        exit;
                    }
                } else {
                    $result = false;
                    $EM_Notices->add_error($EM_Booking->get_errors());
                    $feedback = $EM_Booking->feedback_message;
                }
            } else {
                $EM_Notices->add_error(__('You must log in to cancel your booking.', 'dbem'));
            }
            //TODO user action shouldn't check permission, booking object should.
        } elseif (array_key_exists($_REQUEST['action'], $allowed_actions) && $EM_Event->can_manage('manage_bookings', 'manage_others_bookings')) {
            //Event Admin only actions
            $action = $allowed_actions[$_REQUEST['action']];
            //Just do it here, since we may be deleting bookings of different events.
            if (!empty($_REQUEST['bookings']) && EM_Object::array_is_numeric($_REQUEST['bookings'])) {
                $results = array();
                foreach ($_REQUEST['bookings'] as $booking_id) {
                    $EM_Booking = new EM_Booking($booking_id);
                    $result = $EM_Booking->{$action}();
                    $results[] = $result;
                    if (!in_array(false, $results) && !$result) {
                        $feedback = $EM_Booking->feedback_message;
                    }
                }
                $result = !in_array(false, $results);
            } elseif (is_object($EM_Booking)) {
                $result = $EM_Booking->{$action}();
                $feedback = $EM_Booking->feedback_message;
            }
            //FIXME not adhereing to object's feedback or error message, like other bits in this file.
            //TODO multiple deletion won't work in ajax
            if (!empty($_REQUEST['em_ajax'])) {
                if ($result) {
                    echo $feedback;
                } else {
                    echo '<span style="color:red">' . $feedback . '</span>';
                }
                die;
            }
        } elseif ($_REQUEST['action'] == 'booking_save') {
            em_verify_nonce('booking_save_' . $EM_Booking->booking_id);
            do_action('em_booking_save', $EM_Event, $EM_Booking);
            if ($EM_Booking->can_manage('manage_bookings', 'manage_others_bookings')) {
                if ($EM_Booking->get_post(true) && $EM_Booking->save(false)) {
                    $EM_Notices->add_confirm($EM_Booking->feedback_message, true);
                    $redirect = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : wp_get_referer();
                    wp_redirect($redirect);
                    exit;
                } else {
                    $result = false;
                    $EM_Notices->add_error($EM_Booking->get_errors());
                    $feedback = $EM_Booking->feedback_message;
                }
            }
        } elseif ($_REQUEST['action'] == 'booking_set_status') {
            em_verify_nonce('booking_set_status_' . $EM_Booking->booking_id);
            if ($EM_Booking->can_manage('manage_bookings', 'manage_others_bookings') && $_REQUEST['booking_status'] != $EM_Booking->booking_status) {
                if ($EM_Booking->set_status($_REQUEST['booking_status'], false)) {
                    if (!empty($_REQUEST['send_email'])) {
                        if ($EM_Booking->email(false)) {
                            $EM_Booking->feedback_message .= " " . __('Mail Sent.', 'dbem');
                        } else {
                            $EM_Booking->feedback_message .= ' <span style="color:red">' . __('ERROR : Mail Not Sent.', 'dbem') . '</span>';
                        }
                    }
                    $EM_Notices->add_confirm($EM_Booking->feedback_message, true);
                    $redirect = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : wp_get_referer();
                    wp_redirect($redirect);
                    exit;
                } else {
                    $result = false;
                    $EM_Notices->add_error($EM_Booking->get_errors());
                    $feedback = $EM_Booking->feedback_message;
                }
            }
        } elseif ($_REQUEST['action'] == 'booking_resend_email') {
            em_verify_nonce('booking_resend_email_' . $EM_Booking->booking_id);
            if ($EM_Booking->can_manage('manage_bookings', 'manage_others_bookings')) {
                if ($EM_Booking->email(false, true)) {
                    $EM_Notices->add_confirm(__('Mail Sent.', 'dbem'), true);
                    $redirect = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : wp_get_referer();
                    wp_redirect($redirect);
                    exit;
                } else {
                    $result = false;
                    $EM_Notices->add_error(__('ERROR : Mail Not Sent.', 'dbem'));
                    $feedback = $EM_Booking->feedback_message;
                }
            }
        }
        if ($result && defined('DOING_AJAX')) {
            $return = array('result' => true, 'message' => $feedback);
            echo EM_Object::json_encode(apply_filters('em_action_' . $_REQUEST['action'], $return, $EM_Booking));
            die;
        } elseif (!$result && defined('DOING_AJAX')) {
            $return = array('result' => false, 'message' => $feedback, 'errors' => $EM_Notices->get_errors());
            echo EM_Object::json_encode(apply_filters('em_action_' . $_REQUEST['action'], $return, $EM_Booking));
            die;
        }
    } elseif (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'booking_add' && !is_user_logged_in() && !get_option('dbem_bookings_anonymous')) {
        $EM_Notices->add_error(get_option('dbem_booking_feedback_log_in'));
        if (!$result && defined('DOING_AJAX')) {
            $return = array('result' => false, 'message' => $EM_Booking->feedback_message, 'errors' => $EM_Notices->get_errors());
            echo EM_Object::json_encode(apply_filters('em_action_' . $_REQUEST['action'], $return, $EM_Booking));
        }
        die;
    }
    //AJAX call for searches
    if (!empty($_REQUEST['action']) && substr($_REQUEST['action'], 0, 6) == 'search') {
        if ($_REQUEST['action'] == 'search_states') {
            $results = array();
            $conds = array();
            if (!empty($_REQUEST['country'])) {
                $conds[] = $wpdb->prepare("(location_country = '%s' OR location_country IS NULL )", $_REQUEST['country']);
            }
            if (!empty($_REQUEST['region'])) {
                $conds[] = $wpdb->prepare("( location_region = '%s' OR location_region IS NULL )", $_REQUEST['region']);
            }
            $cond = count($conds) > 0 ? "AND " . implode(' AND ', $conds) : '';
            $results = $wpdb->get_col("SELECT DISTINCT location_state FROM " . EM_LOCATIONS_TABLE . " WHERE location_state IS NOT NULL AND location_state != '' {$cond} ORDER BY location_state");
            if ($_REQUEST['return_html']) {
                //quick shortcut for quick html form manipulation
                ob_start();
                ?>
				<option value=''><?php 
                echo get_option('dbem_search_form_states_label');
                ?>
</option>
				<?php 
                foreach ($results as $result) {
                    echo "<option>{$result}</option>";
                }
                $return = ob_get_clean();
                echo apply_filters('em_ajax_search_states', $return);
                exit;
            } else {
                echo EM_Object::json_encode($results);
                exit;
            }
        }
        if ($_REQUEST['action'] == 'search_towns') {
            $results = array();
            $conds = array();
            if (!empty($_REQUEST['country'])) {
                $conds[] = $wpdb->prepare("(location_country = '%s' OR location_country IS NULL )", $_REQUEST['country']);
            }
            if (!empty($_REQUEST['region'])) {
                $conds[] = $wpdb->prepare("( location_region = '%s' OR location_region IS NULL )", $_REQUEST['region']);
            }
            if (!empty($_REQUEST['state'])) {
                $conds[] = $wpdb->prepare("(location_state = '%s' OR location_state IS NULL )", $_REQUEST['state']);
            }
            $cond = count($conds) > 0 ? "AND " . implode(' AND ', $conds) : '';
            $results = $wpdb->get_col("SELECT DISTINCT location_town FROM " . EM_LOCATIONS_TABLE . " WHERE location_town IS NOT NULL AND location_town != '' {$cond}  ORDER BY location_town");
            if ($_REQUEST['return_html']) {
                //quick shortcut for quick html form manipulation
                ob_start();
                ?>
				<option value=''><?php 
                echo get_option('dbem_search_form_towns_label');
                ?>
</option>
				<?php 
                foreach ($results as $result) {
                    echo "<option>{$result}</option>";
                }
                $return = ob_get_clean();
                echo apply_filters('em_ajax_search_towns', $return);
                exit;
            } else {
                echo EM_Object::json_encode($results);
                exit;
            }
        }
        if ($_REQUEST['action'] == 'search_regions') {
            if (!empty($_REQUEST['country'])) {
                $conds[] = $wpdb->prepare("(location_country = '%s' OR location_country IS NULL )", $_REQUEST['country']);
            }
            $cond = count($conds) > 0 ? "AND " . implode(' AND ', $conds) : '';
            $results = $wpdb->get_results("SELECT DISTINCT location_region AS value FROM " . EM_LOCATIONS_TABLE . " WHERE location_region IS NOT NULL AND location_region != '' {$cond}  ORDER BY location_region");
            if ($_REQUEST['return_html']) {
                //quick shortcut for quick html form manipulation
                ob_start();
                ?>
				<option value=''><?php 
                echo get_option('dbem_search_form_regions_label');
                ?>
</option>
				<?php 
                foreach ($results as $result) {
                    echo "<option>{$result->value}</option>";
                }
                $return = ob_get_clean();
                echo apply_filters('em_ajax_search_regions', $return);
                exit;
            } else {
                echo EM_Object::json_encode($results);
                exit;
            }
        } elseif ($_REQUEST['action'] == 'search_events' && get_option('dbem_events_page_search') && defined('DOING_AJAX')) {
            $args = EM_Events::get_post_search();
            $args['owner'] = false;
            ob_start();
            em_locate_template('templates/events-list.php', true, array('args' => $args));
            //if successful, this template overrides the settings and defaults, including search
            echo apply_filters('em_ajax_search_events', ob_get_clean(), $args);
            exit;
        }
    }
    //EM Ajax requests require this flag.
    if (is_user_logged_in()) {
        //Admin operations
        //Specific Oject Ajax
        if (!empty($_REQUEST['em_obj'])) {
            switch ($_REQUEST['em_obj']) {
                case 'em_bookings_events_table':
                case 'em_bookings_pending_table':
                case 'em_bookings_confirmed_table':
                    //add some admin files just in case
                    include_once 'admin/bookings/em-confirmed.php';
                    include_once 'admin/bookings/em-events.php';
                    include_once 'admin/bookings/em-pending.php';
                    call_user_func($_REQUEST['em_obj']);
                    exit;
                    break;
            }
        }
    }
    //Export CSV - WIP
    if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'export_bookings_csv' && wp_verify_nonce($_REQUEST['_wpnonce'], 'export_bookings_csv')) {
        //sort out cols
        if (!empty($_REQUEST['cols']) && is_array($_REQUEST['cols'])) {
            $cols = array();
            foreach ($_REQUEST['cols'] as $col => $active) {
                if ($active) {
                    $cols[] = $col;
                }
            }
            $_REQUEST['cols'] = $cols;
        }
        $_REQUEST['limit'] = 0;
        //generate bookings export according to search request
        $show_tickets = !empty($_REQUEST['show_tickets']);
        $EM_Bookings_Table = new EM_Bookings_Table($show_tickets);
        header("Content-Type: application/octet-stream; charset=utf-8");
        header("Content-Disposition: Attachment; filename=" . sanitize_title(get_bloginfo()) . "-bookings-export.csv");
        echo sprintf(__('Exported booking on %s', 'dbem'), date_i18n('D d M Y h:i', current_time('timestamp'))) . "\n";
        echo '"' . implode('","', $EM_Bookings_Table->get_headers(true)) . '"' . "\n";
        //Rows
        $EM_Bookings_Table->limit = 150;
        //if you're having server memory issues, try messing with this number
        $EM_Bookings = $EM_Bookings_Table->get_bookings();
        $handle = fopen("php://output", "w");
        while (!empty($EM_Bookings)) {
            foreach ($EM_Bookings as $EM_Booking) {
                //Display all values
                /* @var $EM_Booking EM_Booking */
                /* @var $EM_Ticket_Booking EM_Ticket_Booking */
                if ($show_tickets) {
                    foreach ($EM_Booking->get_tickets_bookings()->tickets_bookings as $EM_Ticket_Booking) {
                        $row = $EM_Bookings_Table->get_row_csv($EM_Ticket_Booking);
                        fputcsv($handle, $row);
                    }
                } else {
                    $row = $EM_Bookings_Table->get_row_csv($EM_Booking);
                    fputcsv($handle, $row);
                }
            }
            //reiterate loop
            $EM_Bookings_Table->offset += $EM_Bookings_Table->limit;
            $EM_Bookings = $EM_Bookings_Table->get_bookings();
        }
        fclose($handle);
        exit;
    }
}
Example #29
0
 /**
  * Will output a event in the format passed in $format by replacing placeholders within the format.
  * @param string $format
  * @param string $target
  * @return string
  */
 function output($format, $target = "html")
 {
     $event_string = $format;
     //Time place holder that doesn't show if empty.
     //TODO add filter here too
     preg_match_all('/#@?_\\{[^}]+\\}/', $format, $results);
     foreach ($results[0] as $result) {
         if (substr($result, 0, 3) == "#@_") {
             $date = 'end_date';
             $offset = 4;
         } else {
             $date = 'start_date';
             $offset = 3;
         }
         if ($date == 'end_date' && $this->event_end_date == $this->event_start_date) {
             $replace = __(apply_filters('em_event_output_placeholder', '', $this, $result, $target));
         } else {
             $replace = __(apply_filters('em_event_output_placeholder', mysql2date(substr($result, $offset, strlen($result) - ($offset + 1)), $this->{$date}), $this, $result, $target));
         }
         $event_string = str_replace($result, $replace, $event_string);
     }
     //This is for the custom attributes
     preg_match_all('/#_ATT\\{([^}]+)\\}(\\{([^}]+)\\})?/', $event_string, $results);
     $attributes = em_get_attributes();
     foreach ($results[0] as $resultKey => $result) {
         //Strip string of placeholder and just leave the reference
         $attRef = substr(substr($result, 0, strpos($result, '}')), 6);
         $attString = '';
         if (is_array($this->event_attributes) && array_key_exists($attRef, $this->event_attributes)) {
             $attString = $this->event_attributes[$attRef];
         } elseif (!empty($results[3][$resultKey])) {
             //Check to see if we have a second set of braces;
             $attString = $results[3][$resultKey];
         } elseif (!empty($attributes['values'][$attRef][0])) {
             $attString = $attributes['values'][$attRef][0];
         }
         $attString = apply_filters('em_event_output_placeholder', $attString, $this, $result, $target);
         $event_string = str_replace($result, $attString, $event_string);
     }
     //First let's do some conditional placeholder removals
     for ($i = 0; $i < EM_CONDITIONAL_RECURSIONS; $i++) {
         //you can add nested recursions by modifying this setting in your wp_options table
         preg_match_all('/\\{([a-zA-Z0-9_\\-]+)\\}(.+?)\\{\\/\\1\\}/s', $event_string, $conditionals);
         if (count($conditionals[0]) > 0) {
             //Check if the language we want exists, if not we take the first language there
             foreach ($conditionals[1] as $key => $condition) {
                 $show_condition = false;
                 if ($condition == 'has_bookings') {
                     //check if there's a booking, if not, remove this section of code.
                     $show_condition = $this->event_rsvp && get_option('dbem_rsvp_enabled');
                 } elseif ($condition == 'no_bookings') {
                     //check if there's a booking, if not, remove this section of code.
                     $show_condition = !$this->event_rsvp && get_option('dbem_rsvp_enabled');
                 } elseif ($condition == 'no_location') {
                     //does this event have a valid location?
                     $show_condition = empty($this->location_id) || !$this->get_location()->location_status;
                 } elseif ($condition == 'has_location') {
                     //does this event have a valid location?
                     $show_condition = !empty($this->location_id) && $this->get_location()->location_status;
                 } elseif ($condition == 'has_image') {
                     //does this event have an image?
                     $show_condition = $this->get_image_url() != '';
                 } elseif ($condition == 'no_image') {
                     //does this event have an image?
                     $show_condition = $this->get_image_url() == '';
                 } elseif ($condition == 'has_time') {
                     //are the booking times different and not an all-day event
                     $show_condition = $this->event_start_time != $this->event_end_time && !$this->event_all_day;
                 } elseif ($condition == 'no_time') {
                     //are the booking times exactly the same and it's not an all-day event.
                     $show_condition = $this->event_start_time == $this->event_end_time && !$this->event_all_day;
                 } elseif ($condition == 'all_day') {
                     //is it an all day event
                     $show_condition = !empty($this->event_all_day);
                 } elseif ($condition == 'logged_in') {
                     //user is logged in
                     $show_condition = is_user_logged_in();
                 } elseif ($condition == 'not_logged_in') {
                     //not logged in
                     $show_condition = !is_user_logged_in();
                 } elseif ($condition == 'has_spaces') {
                     //there are still empty spaces
                     $show_condition = $this->event_rsvp && $this->get_bookings()->get_available_spaces() > 0;
                 } elseif ($condition == 'fully_booked') {
                     //event is fully booked
                     $show_condition = $this->event_rsvp && $this->get_bookings()->get_available_spaces() <= 0;
                 } elseif ($condition == 'bookings_open') {
                     //bookings are still open
                     $show_condition = $this->event_rsvp && $this->get_bookings()->is_open();
                 } elseif ($condition == 'bookings_closed') {
                     //bookings are still closed
                     $show_condition = $this->event_rsvp && !$this->get_bookings()->is_open();
                 } elseif ($condition == 'is_free' || $condition == 'is_free_now') {
                     //is it a free day event, if _now then free right now
                     $show_condition = !$this->event_rsvp || $this->is_free($condition == 'is_free_now');
                 } elseif ($condition == 'not_free' || $condition == 'not_free_now') {
                     //is it a paid event, if _now then paid right now
                     $show_condition = $this->event_rsvp && !$this->is_free($condition == 'not_free_now');
                 } elseif ($condition == 'is_long') {
                     //is it an all day event
                     $show_condition = $this->event_start_date != $this->event_end_date;
                 } elseif ($condition == 'not_long') {
                     //is it an all day event
                     $show_condition = $this->event_start_date == $this->event_end_date;
                 } elseif ($condition == 'is_past') {
                     //if event is past
                     if (get_option('dbem_events_current_are_past')) {
                         $show_condition = $this->start <= current_time('timestamp');
                     } else {
                         $show_condition = $this->end <= current_time('timestamp');
                     }
                 } elseif ($condition == 'is_future') {
                     //if event is upcoming
                     $show_condition = $this->start > current_time('timestamp');
                 } elseif ($condition == 'is_current') {
                     //if event is upcoming
                     $ts = current_time('timestamp');
                     $show_condition = $this->start <= $ts && $this->end >= $ts;
                 } elseif ($condition == 'is_recurrence') {
                     //if event is a recurrence
                     $show_condition = $this->is_recurrence();
                 } elseif ($condition == 'not_recurrence') {
                     //if event is not a recurrence
                     $show_condition = !$this->is_recurrence();
                 } elseif ($condition == 'is_private') {
                     //if event is a recurrence
                     $show_condition = $this->event_private == 1;
                 } elseif ($condition == 'not_private') {
                     //if event is not a recurrence
                     $show_condition = $this->event_private == 0;
                 } elseif (preg_match('/^has_category_([a-zA-Z0-9_\\-]+)$/', $condition, $category_match)) {
                     //event is in this category
                     $show_condition = has_term($category_match[1], EM_TAXONOMY_CATEGORY, $this->post_id);
                 } elseif (preg_match('/^no_category_([a-zA-Z0-9_\\-]+)$/', $condition, $category_match)) {
                     //event is NOT in this category
                     $show_condition = !has_term($category_match[1], EM_TAXONOMY_CATEGORY, $this->post_id);
                 } elseif (preg_match('/^has_tag_([a-zA-Z0-9_\\-]+)$/', $condition, $tag_match)) {
                     //event has this tag
                     $show_condition = has_term($tag_match[1], EM_TAXONOMY_TAG, $this->post_id);
                 } elseif (preg_match('/^no_tag_([a-zA-Z0-9_\\-]+)$/', $condition, $tag_match)) {
                     //event doesn't have this tag
                     $show_condition = !has_term($tag_match[1], EM_TAXONOMY_TAG, $this->post_id);
                 }
                 //other potential ones - has_attribute_... no_attribute_... has_categories_...
                 $show_condition = apply_filters('em_event_output_show_condition', $show_condition, $condition, $conditionals[0][$key], $this);
                 if ($show_condition) {
                     //calculate lengths to delete placeholders
                     $placeholder_length = strlen($condition) + 2;
                     $replacement = substr($conditionals[0][$key], $placeholder_length, strlen($conditionals[0][$key]) - ($placeholder_length * 2 + 1));
                 } else {
                     $replacement = '';
                 }
                 $event_string = str_replace($conditionals[0][$key], apply_filters('em_event_output_condition', $replacement, $condition, $conditionals[0][$key], $this), $event_string);
             }
         }
     }
     //Now let's check out the placeholders.
     preg_match_all("/(#@?_?[A-Za-z0-9]+)({([^}]+)})?/", $event_string, $placeholders);
     $replaces = array();
     foreach ($placeholders[1] as $key => $result) {
         $match = true;
         $replace = '';
         $full_result = $placeholders[0][$key];
         switch ($result) {
             //Event Details
             case '#_EVENTID':
                 $replace = $this->event_id;
                 break;
             case '#_EVENTPOSTID':
                 $replace = $this->post_id;
                 break;
             case '#_NAME':
                 //depreciated
             //depreciated
             case '#_EVENTNAME':
                 $replace = $this->event_name;
                 break;
             case '#_NOTES':
                 //depreciated
             //depreciated
             case '#_EXCERPT':
                 //depreciated
             //depreciated
             case '#_EVENTNOTES':
             case '#_EVENTEXCERPT':
                 $replace = $this->post_content;
                 if ($result == "#_EXCERPT" || $result == "#_EVENTEXCERPT") {
                     if (!empty($this->post_excerpt)) {
                         $replace = $this->post_excerpt;
                     } else {
                         $excerpt_length = 55;
                         $excerpt_more = apply_filters('em_excerpt_more', ' ' . '[...]');
                         if (!empty($placeholders[3][$key])) {
                             $trim = true;
                             $ph_args = explode(',', $placeholders[3][$key]);
                             if (is_numeric($ph_args[0])) {
                                 $excerpt_length = $ph_args[0];
                             }
                             if (!empty($ph_args[1])) {
                                 $excerpt_more = $ph_args[1];
                             }
                         }
                         if (preg_match('/<!--more(.*?)?-->/', $replace, $matches)) {
                             $content = explode($matches[0], $replace, 2);
                             $replace = force_balance_tags($content[0]);
                         }
                         if (!empty($trim)) {
                             //shorten content by supplied number - copied from wp_trim_excerpt
                             $replace = strip_shortcodes($replace);
                             $replace = str_replace(']]>', ']]&gt;', $replace);
                             $replace = wp_trim_words($replace, $excerpt_length, $excerpt_more);
                         }
                     }
                 }
                 break;
             case '#_EVENTIMAGEURL':
             case '#_EVENTIMAGE':
                 if ($this->get_image_url() != '') {
                     if ($result == '#_EVENTIMAGEURL') {
                         $replace = esc_url($this->image_url);
                     } else {
                         if (empty($placeholders[3][$key])) {
                             $replace = "<img src='" . esc_url($this->image_url) . "' alt='" . esc_attr($this->event_name) . "'/>";
                         } else {
                             $image_size = explode(',', $placeholders[3][$key]);
                             $image_url = $this->image_url;
                             if (self::array_is_numeric($image_size) && count($image_size) > 1) {
                                 //get a thumbnail
                                 if (get_option('dbem_disable_thumbnails')) {
                                     $image_attr = '';
                                     $image_args = array();
                                     if (empty($image_size[1]) && !empty($image_size[0])) {
                                         $image_attr = 'width="' . $image_size[0] . '"';
                                         $image_args['w'] = $image_size[0];
                                     } elseif (empty($image_size[0]) && !empty($image_size[1])) {
                                         $image_attr = 'height="' . $image_size[1] . '"';
                                         $image_args['h'] = $image_size[1];
                                     } elseif (!empty($image_size[0]) && !empty($image_size[1])) {
                                         $image_attr = 'width="' . $image_size[0] . '" height="' . $image_size[1] . '"';
                                         $image_args = array('w' => $image_size[0], 'h' => $image_size[1]);
                                     }
                                     $replace = "<img src='" . esc_url(em_add_get_params($image_url, $image_args)) . "' alt='" . esc_attr($this->event_name) . "' {$image_attr} />";
                                 } else {
                                     if (EM_MS_GLOBAL && get_current_blog_id() != $this->blog_id) {
                                         switch_to_blog($this->blog_id);
                                         $switch_back = true;
                                     }
                                     $replace = get_the_post_thumbnail($this->ID, $image_size);
                                     if (!empty($switch_back)) {
                                         restore_current_blog();
                                     }
                                 }
                             } else {
                                 $replace = "<img src='" . esc_url($image_url) . "' alt='" . esc_attr($this->event_name) . "'/>";
                             }
                         }
                     }
                 }
                 break;
                 //Times & Dates
             //Times & Dates
             case '#_24HSTARTTIME':
             case '#_24HENDTIME':
                 $time = $result == '#_24HSTARTTIME' ? $this->event_start_time : $this->event_end_time;
                 $replace = substr($time, 0, 5);
                 break;
             case '#_12HSTARTTIME':
             case '#_12HENDTIME':
                 $time = $result == '#_12HSTARTTIME' ? $this->event_start_time : $this->event_end_time;
                 $replace = date('g:i A', strtotime($time));
                 break;
             case '#_EVENTTIMES':
                 //get format of time to show
                 if (!$this->event_all_day) {
                     $time_format = get_option('dbem_time_format') ? get_option('dbem_time_format') : get_option('time_format');
                     if ($this->event_start_time != $this->event_end_time) {
                         $replace = date_i18n($time_format, $this->start) . get_option('dbem_times_separator') . date_i18n($time_format, $this->end);
                     } else {
                         $replace = date_i18n($time_format, $this->start);
                     }
                 } else {
                     $replace = get_option('dbem_event_all_day_message');
                 }
                 break;
             case '#_EVENTDATES':
                 //get format of time to show
                 $date_format = get_option('dbem_date_format') ? get_option('dbem_date_format') : get_option('date_format');
                 if ($this->event_start_date != $this->event_end_date) {
                     $replace = date_i18n($date_format, $this->start) . get_option('dbem_dates_separator') . date_i18n($date_format, $this->end);
                 } else {
                     $replace = date_i18n($date_format, $this->start);
                 }
                 break;
                 //Links
             //Links
             case '#_EVENTPAGEURL':
                 //Depreciated
             //Depreciated
             case '#_LINKEDNAME':
                 //Depreciated
             //Depreciated
             case '#_EVENTURL':
                 //Just the URL
             //Just the URL
             case '#_EVENTLINK':
                 //HTML Link
                 $event_link = esc_url($this->get_permalink());
                 if ($result == '#_LINKEDNAME' || $result == '#_EVENTLINK') {
                     $replace = '<a href="' . $event_link . '" title="' . esc_attr($this->event_name) . '">' . esc_attr($this->event_name) . '</a>';
                 } else {
                     $replace = $event_link;
                 }
                 break;
             case '#_EDITEVENTURL':
             case '#_EDITEVENTLINK':
                 if ($this->can_manage('edit_events', 'edit_others_events')) {
                     $link = esc_url($this->get_edit_url());
                     if ($result == '#_EDITEVENTLINK') {
                         $replace = '<a href="' . $link . '">' . esc_html(sprintf(__('Edit Event', 'dbem'))) . '</a>';
                     } else {
                         $replace = $link;
                     }
                 }
                 break;
                 //Bookings
             //Bookings
             case '#_ADDBOOKINGFORM':
                 //Depreciated
             //Depreciated
             case '#_REMOVEBOOKINGFORM':
                 //Depreciated
             //Depreciated
             case '#_BOOKINGFORM':
                 if (get_option('dbem_rsvp_enabled')) {
                     if (!defined('EM_XSS_BOOKINGFORM_FILTER') && locate_template('plugins/events-manager/placeholders/bookingform.php')) {
                         //xss fix for old overriden booking forms
                         add_filter('em_booking_form_action_url', 'esc_url');
                         define('EM_XSS_BOOKINGFORM_FILTER', true);
                     }
                     ob_start();
                     $template = em_locate_template('placeholders/bookingform.php', true, array('EM_Event' => $this));
                     EM_Bookings::enqueue_js();
                     $replace = ob_get_clean();
                 }
                 break;
             case '#_BOOKINGBUTTON':
                 if (get_option('dbem_rsvp_enabled') && $this->event_rsvp) {
                     ob_start();
                     $template = em_locate_template('placeholders/bookingbutton.php', true, array('EM_Event' => $this));
                     $replace = ob_get_clean();
                 }
                 break;
             case '#_EVENTPRICERANGEALL':
                 $show_all_ticket_prices = true;
                 //continues below
             //continues below
             case '#_EVENTPRICERANGE':
                 //get the range of prices
                 $min = false;
                 $max = 0;
                 if ($this->get_bookings()->is_open() || !empty($show_all_ticket_prices)) {
                     foreach ($this->get_tickets()->tickets as $EM_Ticket) {
                         /* @var $EM_Ticket EM_Ticket */
                         if ($EM_Ticket->is_available() || get_option('dbem_bookings_tickets_show_unavailable') || !empty($show_all_ticket_prices)) {
                             if ($EM_Ticket->get_price() > $max) {
                                 $max = $EM_Ticket->get_price();
                             }
                             if ($EM_Ticket->get_price() < $min || $min === false) {
                                 $min = $EM_Ticket->get_price();
                             }
                         }
                     }
                 }
                 if ($min === false) {
                     $min = 0;
                 }
                 if ($min != $max) {
                     $replace = em_get_currency_formatted($min) . ' - ' . em_get_currency_formatted($max);
                 } else {
                     $replace = em_get_currency_formatted($min);
                 }
                 break;
             case '#_EVENTPRICEMIN':
                 //get the range of prices
                 $min = false;
                 foreach ($this->get_tickets()->tickets as $EM_Ticket) {
                     /* @var $EM_Ticket EM_Ticket */
                     if ($EM_Ticket->is_available() || get_option('dbem_bookings_tickets_show_unavailable')) {
                         if ($EM_Ticket->get_price() < $min || $min === false) {
                             $min = $EM_Ticket->get_price();
                         }
                     }
                 }
                 if ($min === false) {
                     $min = 0;
                 }
                 $replace = em_get_currency_formatted($min);
                 break;
             case '#_EVENTPRICEMAX':
                 //get the range of prices
                 $max = 0;
                 foreach ($this->get_tickets()->tickets as $EM_Ticket) {
                     /* @var $EM_Ticket EM_Ticket */
                     if ($EM_Ticket->is_available() || get_option('dbem_bookings_tickets_show_unavailable')) {
                         if ($EM_Ticket->get_price() > $max) {
                             $max = $EM_Ticket->get_price();
                         }
                     }
                 }
                 $replace = em_get_currency_formatted($max);
                 break;
             case '#_AVAILABLESEATS':
                 //Depreciated
             //Depreciated
             case '#_AVAILABLESPACES':
                 if ($this->event_rsvp && get_option('dbem_rsvp_enabled')) {
                     $replace = $this->get_bookings()->get_available_spaces();
                 } else {
                     $replace = "0";
                 }
                 break;
             case '#_BOOKEDSEATS':
                 //Depreciated
             //Depreciated
             case '#_BOOKEDSPACES':
                 //This placeholder is actually a little misleading, as it'll consider reserved (i.e. pending) bookings as 'booked'
                 if ($this->event_rsvp && get_option('dbem_rsvp_enabled')) {
                     $replace = $this->get_bookings()->get_booked_spaces();
                     if (get_option('dbem_bookings_approval_reserved')) {
                         $replace += $this->get_bookings()->get_pending_spaces();
                     }
                 } else {
                     $replace = "0";
                 }
                 break;
             case '#_PENDINGSPACES':
                 if ($this->event_rsvp && get_option('dbem_rsvp_enabled')) {
                     $replace = $this->get_bookings()->get_pending_spaces();
                 } else {
                     $replace = "0";
                 }
                 break;
             case '#_SEATS':
                 //Depreciated
             //Depreciated
             case '#_SPACES':
                 $replace = $this->get_spaces();
                 break;
             case '#_BOOKINGSURL':
             case '#_BOOKINGSLINK':
                 if ($this->can_manage('manage_bookings', 'manage_others_bookings')) {
                     $bookings_link = esc_url($this->get_bookings_url());
                     if ($result == '#_BOOKINGSLINK') {
                         $replace = '<a href="' . $bookings_link . '" title="' . esc_attr($this->event_name) . '">' . esc_html($this->event_name) . '</a>';
                     } else {
                         $replace = $bookings_link;
                     }
                 }
                 break;
             case '#_BOOKINGSCUTOFF':
             case '#_BOOKINGSCUTOFFDATE':
             case '#_BOOKINGSCUTOFFTIME':
                 $replace = '';
                 if ($this->event_rsvp && get_option('dbem_rsvp_enabled') && !empty($this->rsvp_end)) {
                     $replace_format = get_option('dbem_date_format') . ' ' . get_option('dbem_time_format');
                     if ($result == '#_BOOKINGSCUTOFFDATE') {
                         $replace_format = get_option('dbem_date_format');
                     }
                     if ($result == '#_BOOKINGSCUTOFFTIME') {
                         $replace_format = get_option('dbem_time_format');
                     }
                     $replace = date($replace_format, $this->rsvp_end);
                 }
                 break;
                 //Contact Person
             //Contact Person
             case '#_CONTACTNAME':
             case '#_CONTACTPERSON':
                 //Depreciated (your call, I think name is better)
                 $replace = $this->get_contact()->display_name;
                 break;
             case '#_CONTACTUSERNAME':
                 $replace = $this->get_contact()->user_login;
                 break;
             case '#_CONTACTEMAIL':
             case '#_CONTACTMAIL':
                 //Depreciated
                 $replace = $this->get_contact()->user_email;
                 break;
             case '#_CONTACTURL':
                 $replace = $this->get_contact()->user_url;
                 break;
             case '#_CONTACTID':
                 $replace = $this->get_contact()->ID;
                 break;
             case '#_CONTACTPHONE':
                 $replace = $this->get_contact()->phone != '' ? $this->get_contact()->phone : __('N/A', 'dbem');
                 break;
             case '#_CONTACTAVATAR':
                 $replace = get_avatar($this->get_contact()->ID, $size = '50');
                 break;
             case '#_CONTACTPROFILELINK':
             case '#_CONTACTPROFILEURL':
                 if (function_exists('bp_core_get_user_domain')) {
                     $replace = bp_core_get_user_domain($this->get_contact()->ID);
                     if ($result == '#_CONTACTPROFILELINK') {
                         $replace = '<a href="' . esc_url($replace) . '">' . __('Profile', 'dbem') . '</a>';
                     }
                 }
                 break;
             case '#_CONTACTMETA':
                 if (!empty($placeholders[3][$key])) {
                     $replace = get_user_meta($this->event_owner, $placeholders[3][$key], true);
                 }
                 break;
             case '#_ATTENDEES':
                 ob_start();
                 $template = em_locate_template('placeholders/attendees.php', true, array('EM_Event' => $this));
                 $replace = ob_get_clean();
                 break;
             case '#_ATTENDEESLIST':
                 ob_start();
                 $template = em_locate_template('placeholders/attendeeslist.php', true, array('EM_Event' => $this));
                 $replace = ob_get_clean();
                 break;
             case '#_ATTENDEESPENDINGLIST':
                 ob_start();
                 $template = em_locate_template('placeholders/attendeespendinglist.php', true, array('EM_Event' => $this));
                 $replace = ob_get_clean();
                 break;
                 //Categories and Tags
             //Categories and Tags
             case '#_EVENTCATEGORIESIMAGES':
                 ob_start();
                 $template = em_locate_template('placeholders/eventcategoriesimages.php', true, array('EM_Event' => $this));
                 $replace = ob_get_clean();
                 break;
             case '#_EVENTTAGS':
                 ob_start();
                 $template = em_locate_template('placeholders/eventtags.php', true, array('EM_Event' => $this));
                 $replace = ob_get_clean();
                 break;
             case '#_CATEGORIES':
                 //depreciated
             //depreciated
             case '#_EVENTCATEGORIES':
                 ob_start();
                 $template = em_locate_template('placeholders/categories.php', true, array('EM_Event' => $this));
                 $replace = ob_get_clean();
                 break;
                 //Ical Stuff
             //Ical Stuff
             case '#_EVENTICALURL':
             case '#_EVENTICALLINK':
                 $replace = $this->get_ical_url();
                 if ($result == '#_EVENTICALLINK') {
                     $replace = '<a href="' . esc_url($replace) . '">iCal</a>';
                 }
                 break;
             case '#_EVENTGCALURL':
             case '#_EVENTGCALLINK':
                 //get dates in UTC/GMT time
                 if ($this->event_all_day && $this->event_start_date == $this->event_end_date) {
                     $dateStart = get_gmt_from_date(date('Y-m-d H:i:s', $this->start), 'Ymd');
                     $dateEnd = get_gmt_from_date(date('Y-m-d H:i:s', $this->start + 60 * 60 * 24), 'Ymd');
                 } else {
                     $dateStart = get_gmt_from_date(date('Y-m-d H:i:s', $this->start), 'Ymd\\THis\\Z');
                     $dateEnd = get_gmt_from_date(date('Y-m-d H:i:s', $this->end), 'Ymd\\THis\\Z');
                 }
                 //build url
                 $gcal_url = 'http://www.google.com/calendar/event?action=TEMPLATE&text=event_name&dates=start_date/end_date&details=post_content&location=location_name&trp=false&sprop=event_url&sprop=name:blog_name';
                 $gcal_url = str_replace('event_name', urlencode($this->event_name), $gcal_url);
                 $gcal_url = str_replace('start_date', urlencode($dateStart), $gcal_url);
                 $gcal_url = str_replace('end_date', urlencode($dateEnd), $gcal_url);
                 $gcal_url = str_replace('location_name', urlencode($this->output('#_LOCATION')), $gcal_url);
                 $gcal_url = str_replace('blog_name', urlencode(get_bloginfo()), $gcal_url);
                 $gcal_url = str_replace('event_url', urlencode($this->get_permalink()), $gcal_url);
                 //calculate URL length so we know how much we can work with to make a description.
                 if (!empty($this->post_excerpt)) {
                     $gcal_url_description = $this->post_excerpt;
                 } else {
                     $matches = explode('<!--more', $this->post_content);
                     $gcal_url_description = wp_kses_data($matches[0]);
                 }
                 $gcal_url_length = strlen($gcal_url) - 9;
                 if (strlen($gcal_url_description) + $gcal_url_length > 1350) {
                     $gcal_url_description = substr($gcal_url_description, 0, 1380 - $gcal_url_length - 3) . '...';
                 }
                 $gcal_url = str_replace('post_content', urlencode($gcal_url_description), $gcal_url);
                 //get the final url
                 $replace = $gcal_url;
                 if ($result == '#_EVENTGCALLINK') {
                     $img_url = 'www.google.com/calendar/images/ext/gc_button2.gif';
                     $img_url = is_ssl() ? 'https://' . $img_url : 'http://' . $img_url;
                     $replace = '<a href="' . esc_url($replace) . '" target="_blank"><img src="' . esc_url($img_url) . '" alt="0" border="0"></a>';
                 }
                 break;
             default:
                 $replace = $full_result;
                 break;
         }
         $replaces[$full_result] = apply_filters('em_event_output_placeholder', $replace, $this, $full_result, $target);
     }
     //sort out replacements so that during replacements shorter placeholders don't overwrite longer varieties.
     krsort($replaces);
     foreach ($replaces as $full_result => $replacement) {
         if (!in_array($full_result, array('#_NOTES', '#_EVENTNOTES'))) {
             $event_string = str_replace($full_result, $replacement, $event_string);
         } else {
             $new_placeholder = str_replace('#_', '__#', $full_result);
             //this will avoid repeated filters when locations/categories are parsed
             $event_string = str_replace($full_result, $new_placeholder, $event_string);
             $desc_replace[$new_placeholder] = $replacement;
         }
     }
     //Time placeholders
     foreach ($placeholders[1] as $result) {
         // matches all PHP START date and time placeholders
         if (preg_match('/^#[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]$/', $result)) {
             $replace = date_i18n(ltrim($result, "#"), $this->start);
             $replace = apply_filters('em_event_output_placeholder', $replace, $this, $result, $target);
             $event_string = str_replace($result, $replace, $event_string);
         }
         // matches all PHP END time placeholders for endtime
         if (preg_match('/^#@[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]$/', $result)) {
             $replace = date_i18n(ltrim($result, "#@"), $this->end);
             $replace = apply_filters('em_event_output_placeholder', $replace, $this, $result, $target);
             $event_string = str_replace($result, $replace, $event_string);
         }
     }
     //Now do dependent objects
     if (!empty($this->location_id) && $this->get_location()->location_status) {
         $event_string = $this->get_location()->output($event_string, $target);
     } else {
         $EM_Location = new EM_Location();
         $event_string = $EM_Location->output($event_string, $target);
     }
     //for backwards compat and easy use, take over the individual category placeholders with the frirst cat in th elist.
     $EM_Categories = $this->get_categories();
     if (count($EM_Categories->categories) > 0) {
         $EM_Category = $EM_Categories->get_first();
     }
     if (empty($EM_Category)) {
         $EM_Category = new EM_Category();
     }
     $event_string = $EM_Category->output($event_string, $target);
     //Finally, do the event notes, so that previous placeholders don't get replaced within the content, which may use shortcodes
     if (!empty($desc_replace)) {
         foreach ($desc_replace as $full_result => $replacement) {
             $event_string = str_replace($full_result, $replacement, $event_string);
         }
     }
     //do some specific formatting
     //TODO apply this sort of formatting to any output() function
     if ($target == 'ical') {
         //strip html and escape characters
         $event_string = str_replace('\\', '\\\\', strip_tags($event_string));
         $event_string = str_replace(';', '\\;', $event_string);
         $event_string = str_replace(',', '\\,', $event_string);
         //remove and define line breaks in ical format
         $event_string = str_replace('\\\\n', '\\n', $event_string);
         $event_string = str_replace("\r\n", '\\n', $event_string);
         $event_string = str_replace("\n", '\\n', $event_string);
     }
     return apply_filters('em_event_output', $event_string, $this, $format, $target);
 }
Example #30
0
/**
 * Generates a "widget" table of pending bookings with some quick admin operation options. 
 * If event id supplied then only pending bookings for that event will show.
 * 
 * @param int $event_id
 */
function em_bookings_pending_table($event_id = false)
{
    global $EM_Event, $wpdb, $current_user;
    if (get_option('dbem_bookings_approval') == 0) {
        return false;
    }
    $action_scope = !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_pending_table';
    $action = $action_scope && !empty($_GET['action']) ? $_GET['action'] : '';
    $order = $action_scope && !empty($_GET['order']) ? $_GET['order'] : 'ASC';
    $limit = $action_scope && !empty($_GET['limit']) ? $_GET['limit'] : 20;
    //Default limit
    $page = $action_scope && !empty($_GET['pno']) ? $_GET['pno'] : 1;
    $offset = $action_scope && $page > 1 ? ($page - 1) * $limit : 0;
    if (is_object($EM_Event)) {
        $bookings = $EM_Event->get_bookings()->get_pending();
    } else {
        //To optimize performance, we can do one query here for all pending bookings to show.
        $bookings = EM_Bookings::get(array('status' => 0));
        $events = array();
        //Now let's create events and bookings for this:
        foreach ($bookings as $EM_Booking) {
            //create event
            if (!array_key_exists($EM_Booking->event_id, $events)) {
                $events[$EM_Booking->event_id] = new EM_Event($EM_Booking->event_id);
            }
        }
    }
    $bookings_count = is_array($bookings) ? count($bookings) : 0;
    ?>
		<div class='wrap em_bookings_pending_table em_obj'>
			<form id='bookings-filter' method='get' action='<?php 
    bloginfo('wpurl');
    ?>
/wp-admin/edit.php'>
				<input type="hidden" name="em_obj" value="em_bookings_pending_table" />
				<!--
				<ul class="subsubsub">
					<li>
						<a href='edit.php?post_type=post' class="current">All <span class="count">(1)</span></a> |
					</li>
				</ul>
				<p class="search-box">
					<label class="screen-reader-text" for="post-search-input"><?php 
    _e('Search');
    ?>
:</label>
					<input type="text" id="post-search-input" name="em_search" value="<?php 
    echo !empty($_GET['em_search']) ? $_GET['em_search'] : '';
    ?>
" />
					<input type="submit" value="<?php 
    _e('Search');
    ?>
" class="button" />
				</p>
				-->
				<?php 
    if ($bookings_count >= $limit) {
        ?>
				<div class='tablenav'>
					<!--
					<div class="alignleft actions">
						<select name="action">
							<option value="-1" selected="selected">
								<?php 
        _e('Bulk Actions');
        ?>
							</option>
							<option value="approve">
								<?php 
        _e('Approve', 'dbem');
        ?>
							</option>
							<option value="decline">
								<?php 
        _e('Decline', 'dbem');
        ?>
							</option>
						</select> 
						<input type="submit" id="post-query-submit" value="Filter" class="button-secondary" />
					</div>
					-->
					<!--
					<div class="view-switch">
						<a href="/wp-admin/edit.php?mode=list"><img class="current" id="view-switch-list" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="List View" alt="List View" name="view-switch-list" /></a> <a href="/wp-admin/edit.php?mode=excerpt"><img id="view-switch-excerpt" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="Excerpt View" alt="Excerpt View" name="view-switch-excerpt" /></a>
					</div>
					-->
					<?php 
        if ($bookings_count >= $limit) {
            $page_link_template = em_add_get_params($_SERVER['REQUEST_URI'], array('pno' => '%PAGE%', 'em_ajax' => 0, 'em_obj' => 'em_bookings_pending_table'));
            $bookings_nav = em_admin_paginate($page_link_template, $bookings_count, $limit, $page, 5);
            echo $bookings_nav;
        }
        ?>
					<div class="clear"></div>
				</div>
				<?php 
    }
    ?>
				<div class="clear"></div>
				<?php 
    if ($bookings_count > 0) {
        ?>
				<div class='table-wrap'>
				<table id='dbem-bookings-table' class='widefat post fixed'>
					<thead>
						<tr>
							<th class='manage-column column-cb check-column' scope='col'>
								<input class='select-all' type="checkbox" value='1' />
							</th>
							<th class='manage-column' scope='col'>Booker</th>
							<?php 
        if (!is_object($EM_Event)) {
            ?>
							<th class='manage-column' scope="col">Event</th>
							<?php 
        }
        ?>
							<th class='manage-column' scope='col'>E-mail</th>
							<th class='manage-column' scope='col'>Phone number</th>
							<th class='manage-column' scope='col'>Spaces</th>
							<th class='manage-column' scope='col'>&nbsp;</th>
						</tr>
					</thead>
					<tbody>
						<?php 
        $rowno = 0;
        $event_count = 0;
        foreach ($bookings as $EM_Booking) {
            if (($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0)) {
                $rowno++;
                ?>
								<tr>
									<th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php 
                echo $EM_Booking->id;
                ?>
' name='bookings[]'/></th>
									<td><a href="<?php 
                bloginfo('wpurl');
                ?>
/wp-admin/admin.php?page=events-manager-bookings&amp;person_id=<?php 
                echo $EM_Booking->person->id;
                ?>
"><?php 
                echo $EM_Booking->person->name;
                ?>
</a></td>
									<?php 
                if (!is_object($EM_Event)) {
                    ?>
									<td><a href="<?php 
                    bloginfo('wpurl');
                    ?>
/wp-admin/admin.php?page=events-manager-bookings&amp;event_id=<?php 
                    echo $EM_Booking->event_id;
                    ?>
"><?php 
                    echo $events[$EM_Booking->event_id]->name;
                    ?>
</a></td>
									<?php 
                }
                ?>
									<td><?php 
                echo $EM_Booking->person->email;
                ?>
</td>
									<td><?php 
                echo $EM_Booking->person->phone;
                ?>
</td>
									<td><?php 
                echo $EM_Booking->seats;
                ?>
</td>
									<td>
										<?php 
                $approve_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action' => 'bookings_approve', 'booking_id' => $EM_Booking->id));
                $reject_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action' => 'bookings_reject', 'booking_id' => $EM_Booking->id));
                ?>
										<a class="em-bookings-approve" href="<?php 
                echo $approve_url;
                ?>
"><?php 
                _e('Approve', 'dbem');
                ?>
</a> |
										<a class="em-bookings-reject" href="<?php 
                echo $reject_url;
                ?>
"><?php 
                _e('Reject', 'dbem');
                ?>
</a> |
										<a class="em-bookings-edit" href="<?php 
                bloginfo('wpurl');
                ?>
/wp-admin/admin.php?page=events-manager-bookings&amp;booking_id=<?php 
                echo $EM_Booking->id;
                ?>
"><?php 
                _e('Edit');
                ?>
</a>
									</td>
								</tr>
								<?php 
            }
            $event_count++;
        }
        ?>
					</tbody>
				</table>
				</div>
				<?php 
    } else {
        ?>
					<?php 
        _e('No pending bookings.', 'dbem');
        ?>
				<?php 
    }
    ?>
			</form>
			<?php 
    if (!empty($bookings_nav)) {
        ?>
			<div class='tablenav'>
				<?php 
        echo $bookings_nav;
        ?>
				<div class="clear"></div>
			</div>
			<?php 
    }
    ?>
		</div>	
	<?php 
}