本文整理汇总了PHP中EM_Object::array_is_numeric方法的典型用法代码示例。如果您正苦于以下问题:PHP EM_Object::array_is_numeric方法的具体用法?PHP EM_Object::array_is_numeric怎么用?PHP EM_Object::array_is_numeric使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EM_Object
的用法示例。
在下文中一共展示了EM_Object::array_is_numeric方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_bookings
function get_bookings($ids_only = false, $status = false)
{
global $wpdb;
$status_condition = $blog_condition = '';
if (is_multisite()) {
if (!is_main_site()) {
//not the main blog, force single blog search
$blog_condition = "AND e.blog_id=" . get_current_blog_id();
} elseif (is_main_site() && !get_option('dbem_ms_global_events')) {
$blog_condition = "AND (e.blog_id=" . get_current_blog_id() . ' OR e.blog_id IS NULL)';
}
}
if (is_numeric($status)) {
$status_condition = " AND booking_status={$status}";
} elseif (EM_Object::array_is_numeric($status)) {
$status_condition = " AND booking_status IN (" . implode(',', $status) . ")";
}
$EM_Booking = em_get_booking();
//empty booking for fields
$results = $wpdb->get_results("SELECT b." . implode(', b.', array_keys($EM_Booking->fields)) . " FROM " . EM_BOOKINGS_TABLE . " b, " . EM_EVENTS_TABLE . " e WHERE e.event_id=b.event_id AND person_id={$this->ID} {$blog_condition} {$status_condition} ORDER BY " . get_option('dbem_bookings_default_orderby', 'event_start_date') . " " . get_option('dbem_bookings_default_order', 'ASC'), ARRAY_A);
$bookings = array();
if ($ids_only) {
foreach ($results as $booking_data) {
$bookings[] = $booking_data['booking_id'];
}
return apply_filters('em_person_get_bookings', $bookings, $this);
} else {
foreach ($results as $booking_data) {
$bookings[] = em_get_booking($booking_data);
}
return apply_filters('em_person_get_bookings', new EM_Bookings($bookings), $this);
}
}
示例2: can_manage
function can_manage($event_ids = false, $admin_capability = false, $user_to_check = false)
{
global $wpdb;
if (current_user_can('edit_others_events')) {
return apply_filters('em_events_can_manage', true, $event_ids);
}
if (EM_Object::array_is_numeric($event_ids)) {
$condition = implode(" OR event_id=", $event_ids);
//we try to find any of these events that don't belong to this user
$results = $wpdb->get_var("SELECT COUNT(*) FROM " . EM_EVENTS_TABLE . " WHERE event_owner != '" . get_current_user_id() . "' event_id={$condition};");
return apply_filters('em_events_can_manage', $results == 0, $event_ids);
}
return apply_filters('em_events_can_manage', false, $event_ids);
}
示例3: em_init_actions
/**
* 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);
//.........这里部分代码省略.........
示例4: em_init_actions
//.........这里部分代码省略.........
//Success notice
if (is_user_logged_in()) {
if (empty($_REQUEST['event_id'])) {
$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_form_result_success_updated')), 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), false, false);
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)) {
$event = $EM_Event->duplicate();
if ($event === false) {
$EM_Notices->add_error($EM_Event->errors, true);
wp_redirect(wp_get_referer());
} else {
$EM_Notices->add_confirm($EM_Event->feedback_message, true);
wp_redirect($event->get_edit_url());
}
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;
示例5: set_status
/**
* @param int $status
* @param array|int $booking_ids
* @return bool
*/
function set_status($status, $booking_ids)
{
//FIXME there is a vulnerability where any user can approve/reject bookings if they know the ID
if (EM_Object::array_is_numeric($booking_ids)) {
//Get all the bookings
$results = array();
$mails = array();
foreach ($booking_ids as $booking_id) {
$EM_Booking = new EM_Booking($booking_id);
$results[] = $EM_Booking->set_status($status);
}
if (!in_array('false', $results)) {
$this->feedback_message = __('Bookings %s. Mails Sent.', 'dbem');
return true;
} else {
//TODO Better error handling needed if some bookings fail approval/failure
$this->feedback_message = __('An error occurred.', 'dbem');
return false;
}
} elseif (is_numeric($booking_ids) || is_object($booking_ids)) {
$EM_Booking = is_object($booking_ids) && get_class($booking_ids) == 'EM_Booking' ? $booking_ids : new EM_Booking($booking_ids);
$result = $EM_Booking->set_status($status);
$this->feedback_message = $EM_Booking->feedback_message;
return $result;
}
return false;
}
示例6: em_init_actions
//.........这里部分代码省略.........
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)
$EM_Notices->add_confirm($EM_Event->feedback_message);
if (is_admin()) {
$page = !empty($_REQUEST['pno']) ? $_REQUEST['pno'] : '';
$scope = !empty($_REQUEST['scope']) ? $_REQUEST['scope'] : '';
//wp_redirect( get_bloginfo('wpurl').'/wp-admin/admin.php?page=events-manager&pno='.$page.'&scope='.$scope.'&message='.urlencode($EM_Event->feedback_message));
} else {
$redirect = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : wp_get_referer();
wp_redirect($redirect);
}
$events_result = true;
} else {
$EM_Notices->add_error($EM_Event->get_errors());
$events_result = false;
}
}
if ($_REQUEST['action'] == 'event_duplicate') {
global $EZSQL_ERROR;
$EM_Event = $EM_Event->duplicate();
if ($EM_Event === false) {
$EM_Notices->add_error($EM_Event->errors, true);
} else {
if ($EM_Event->id == $_REQUEST['event_id']) {
$EM_Notices->add_confirm($EM_Event->feedback_message . " " . sprintf(__('You are now viewing the duplicated %s.', 'dbem'), __('event', 'dbem')), true);
} else {
$EM_Notices->add_confirm($EM_Event->feedback_message, true);
}
}
}
if ($_REQUEST['action'] == 'event_delete') {
//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 = is_object($EM_Event) ? $EM_Event->feedback_message : sprintf(__('%s successfully deleted.', 'dbem'), $plural);
$EM_Notices->add_confirm($message);
} else {
$message = is_object($EM_Event) ? $EM_Event->errors : sprintf(__('%s could not be deleted.', 'dbem'), $plural);
$EM_Notices->add_confirm($message);
}
} elseif ($_REQUEST['action'] == 'event_approve') {
//Approve Action
$events_result = $EM_Event->approve();
if ($events_result) {
$EM_Notices->add_confirm($EM_Event->feedback_message);
} else {
$EM_Notices->add_error($EM_Event->errors);
}
}
//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') {
示例7: 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;
}
}
}
}
示例8: can_manage
function can_manage($event_ids)
{
global $wpdb;
if (em_verify_admin()) {
return apply_filters('em_events_can_manage', true, $event_ids);
}
if (EM_Object::array_is_numeric($event_ids)) {
$condition = implode(" OR event_id=", $event_ids);
//Delete all the bookings
$results = $wpdb->query("SELECT event_author FROM " . $wpdb->prefix . EM_BOOKINGS_TABLE . " WHERE author_id != '" . get_current_user_id() . "' event_id={$condition};");
return apply_filters('em_events_can_manage', count($results) > 0, $event_ids);
}
return apply_filters('em_events_can_manage', false, $event_ids);
}
示例9: em_admin_events_page
/**
* Determines whether to show event page or events page, and saves any updates to the event or events
* @return null
*/
function em_admin_events_page()
{
//TODO Simplify panel for events, use form flags to detect certain actions (e.g. submitted, etc)
global $wpdb;
global $EM_Event;
$action = !empty($_GET['action']) ? $_GET['action'] : '';
$order = !empty($_GET['order']) ? $_GET['order'] : 'ASC';
$limit = !empty($_GET['limit']) ? $_GET['limit'] : 20;
//Default limit
$page = !empty($_GET['pno']) ? $_GET['pno'] : 1;
$offset = $page > 1 ? ($page - 1) * $limit : 0;
$scope_names = array('past' => __('Past events', 'dbem'), 'all' => __('All events', 'dbem'), 'future' => __('Future events', 'dbem'));
$scope = !empty($_GET['scope']) && array_key_exists($_GET['scope'], $scope_names) ? $_GET['scope'] : 'future';
$selectedEvents = !empty($_GET['events']) ? $_GET['events'] : '';
// DELETE action
if ($action == 'deleteEvents' && EM_Object::array_is_numeric($selectedEvents)) {
EM_Events::delete($selectedEvents);
}
// 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";
}
$args = array('scope' => $scope, 'limit' => 0, 'order' => $order);
if (!get_option('dbem_permissions_events') && !em_verify_admin()) {
$args['owner'] = get_current_user_id();
}
$events = EM_Events::get($args);
$events_count = count($events);
$use_events_end = get_option('dbem_use_event_end');
?>
<div class="wrap">
<div id="icon-events" class="icon32"><br />
</div>
<h2>
<?php
echo $title;
?>
<a href="admin.php?page=events-manager-event" class="button add-new-h2"><?php
_e('Add New', 'dbem');
?>
</a>
</h2>
<?php
$link = array();
$link['past'] = "<a href='" . get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager&scope=past&order=desc'>" . __('Past events', 'dbem') . "</a>";
$link['all'] = " <a href='" . get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager&scope=all&order=desc'>" . __('All events', 'dbem') . "</a>";
$link['future'] = " <a href='" . get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager&scope=future'>" . __('Future events', 'dbem') . "</a>";
?>
<?php
if (!empty($_GET['error'])) {
?>
<div id='message' class='error'>
<p><?php
echo $_GET['error'];
?>
</p>
</div>
<?php
}
?>
<?php
if (!empty($_GET['message'])) {
?>
<div id='message' class='updated fade'>
<p><?php
echo $_GET['message'];
?>
</p>
</div>
<?php
}
?>
<form id="posts-filter" action="" method="get"><input type='hidden' name='page' value='events-manager' />
<ul class="subsubsub">
<li><a href='#' class="current"><?php
_e('Total', 'dbem');
?>
<span class="count">(<?php
echo count($events);
?>
)</span></a></li>
</ul>
<p class="search-box">
<label class="screen-reader-text" for="post-search-input"><?php
_e('Search Events', 'dbem');
?>
:</label>
//.........这里部分代码省略.........