本文整理汇总了PHP中EM_Event::get_bookings方法的典型用法代码示例。如果您正苦于以下问题:PHP EM_Event::get_bookings方法的具体用法?PHP EM_Event::get_bookings怎么用?PHP EM_Event::get_bookings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EM_Event
的用法示例。
在下文中一共展示了EM_Event::get_bookings方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
function ajax_add_booking()
{
/* Check the nonce */
check_admin_referer('add_booking', '_wpnonce_add_booking');
if (!empty($_REQUEST['event_id']) && is_numeric($_REQUEST['event_id'])) {
$EM_Event = new EM_Event($_REQUEST['event_id']);
$result = $EM_Event->get_bookings()->add_from_post();
if ($result) {
$return = array('result' => true, 'message' => $EM_Event->get_bookings()->feedback_message);
} else {
$return = array('result' => false, 'message' => implode('<br />', $EM_Event->get_bookings()->errors));
}
echo EM_Object::json_encode($return);
exit;
} else {
$return = array('result' => false, 'message' => '');
echo EM_Object::json_encode($return);
exit;
}
}
示例2: em_init_actions
//.........这里部分代码省略.........
$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 {
示例3: em_init_actions
//.........这里部分代码省略.........
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']) ? em_get_booking($_REQUEST['booking_id']) : em_get_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();
if (!defined('WP_CACHE') || !WP_CACHE) {
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())) {
$EM_Booking->get_post();
$post_validation = $EM_Booking->validate();
do_action('em_booking_add', $EM_Event, $EM_Booking, $post_validation);
if ($post_validation) {
//register the user - or not depending - according to the booking
$registration = em_booking_add_registration($EM_Booking);
$EM_Bookings = $EM_Event->get_bookings();
if ($registration && $EM_Bookings->add($EM_Booking)) {
if (is_user_logged_in() && is_multisite() && !is_user_member_of_blog(get_current_user_id(), get_current_blog_id())) {
add_user_to_blog(get_current_blog_id(), get_current_user_id(), get_option('default_role'));
}
$result = true;
$EM_Notices->add_confirm($EM_Bookings->feedback_message);
$feedback = $EM_Bookings->feedback_message;
} else {
$result = false;
if (!$registration) {
$EM_Notices->add_error($EM_Booking->get_errors());
$feedback = $EM_Booking->feedback_message;
} else {
$EM_Notices->add_error($EM_Bookings->get_errors());
$feedback = $EM_Bookings->feedback_message;
}
}
global $em_temp_user_data;
$em_temp_user_data = false;
//delete registered user temp info (if exists)
} else {
$result = false;
$EM_Notices->add_error($EM_Booking->get_errors());
}
} else {
示例4: em_ajax_actions
function em_ajax_actions()
{
//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['dbem_ajax_action']) && $_REQUEST['dbem_ajax_action'] == 'booking_data') {
if (isset($_REQUEST['id'])) {
$EM_Event = new EM_Event($_REQUEST['id']);
echo "[{bookedSeats:" . $EM_Event->get_bookings()->get_booked_seats() . ", availableSeats:" . $EM_Event->get_bookings()->get_available_seats() . "}]";
}
die;
}
if (isset($_REQUEST['em_ajax_action']) && $_REQUEST['em_ajax_action'] == 'get_location') {
if (isset($_REQUEST['id'])) {
$EM_Location = new EM_Location($_REQUEST['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['query']) && $_REQUEST['query'] == 'GlobalMapData') {
$locations = EM_Locations::get($_REQUEST);
$json_locations = array();
foreach ($locations as $location_key => $location) {
$json_locations[$location_key] = $location->to_array();
$json_locations[$location_key]['location_balloon'] = $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);
die;
}
//EM Ajax requests require this flag.
if (is_admin()) {
//Admin operations
//Booking Actions
global $EM_Booking;
if (!empty($_REQUEST['bookings']) || is_object($EM_Booking)) {
if (is_object($EM_Booking)) {
$_REQUEST['bookings'] = $EM_Booking;
//small hack to prevent unecessary db reads
}
$EM_Bookings = new EM_Bookings();
//Empty, not bound to event.
if ($_REQUEST['action'] == 'bookings_approve') {
$EM_Bookings->approve($_REQUEST['bookings']);
echo $EM_Bookings->feedback_message;
die;
} elseif ($_REQUEST['action'] == 'bookings_reject') {
$EM_Bookings->reject($_REQUEST['bookings']);
echo $EM_Bookings->feedback_message;
die;
} elseif ($_REQUEST['action'] == 'bookings_unapprove') {
$EM_Bookings->unapprove($_REQUEST['bookings']);
echo $EM_Bookings->feedback_message;
die;
} elseif ($_REQUEST['action'] == 'bookings_delete') {
//Just do it here, since we may be deleting bookings of different events.
$result = false;
if (EM_Object::array_is_numeric($_REQUEST['bookings'])) {
$results = array();
foreach ($_REQUEST['bookings'] as $booking_id) {
$EM_Booking = new EM_Booking($booking_id);
$results[] = $EM_Booking->delete();
}
$result = !in_array(false, $results);
} elseif (is_numeric($_REQUEST['bookings'])) {
$EM_Booking = new EM_Booking($_REQUEST['bookings']);
$result = $EM_Booking->delete();
} elseif (is_object($EM_Booking)) {
$result = $EM_Booking->delete();
}
if ($result) {
echo __('Booking Deleted', 'dbem');
} else {
echo '<span style="color:red">' . __('Booking deletion unsuccessful', 'dbem') . '</span>';
}
die;
}
}
//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':
call_user_func($_REQUEST['em_obj']);
break;
}
die;
}
}
}
}