本文整理汇总了PHP中EM_Event::can_manage方法的典型用法代码示例。如果您正苦于以下问题:PHP EM_Event::can_manage方法的具体用法?PHP EM_Event::can_manage怎么用?PHP EM_Event::can_manage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EM_Event
的用法示例。
在下文中一共展示了EM_Event::can_manage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: elseif
_e('The event name. Example: Birthday party', 'dbem');
?>
<?php
em_locate_template('forms/event/group.php', true);
?>
</div>
<h3 class="event-form-when"><?php
_e('When', 'dbem');
?>
</h3>
<div class="inside event-form-when">
<?php
if (empty($EM_Event->event_id) && $EM_Event->can_manage('edit_recurring_events', 'edit_others_recurring_events') && get_option('dbem_recurrence_enabled')) {
em_locate_template('forms/event/when-with-recurring.php', true);
} elseif ($EM_Event->is_recurring()) {
em_locate_template('forms/event/recurring-when.php', true);
} else {
em_locate_template('forms/event/when.php', true);
}
?>
</div>
<?php
if (get_option('dbem_locations_enabled')) {
?>
<h3 class="event-form-where"><?php
示例2: 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);
//.........这里部分代码省略.........
示例3:
/**
* Called instead of the filter in EM_Gateways if a manual booking is being made
* @param EM_Event $EM_Event
*/
function em_booking_form_footer($EM_Event)
{
if ($EM_Event->can_manage('manage_bookings', 'manage_others_bookings')) {
//Admin is adding a booking here, so let's show a different form here.
?>
<input type="hidden" name="gateway" value="<?php
echo $this->gateway;
?>
" />
<input type="hidden" name="manual_booking" value="<?php
echo wp_create_nonce('em_manual_booking_' . $EM_Event->event_id);
?>
" />
<p class="em-booking-gateway" id="em-booking-gateway">
<label><?php
_e('Amount Paid', 'em-pro');
?>
</label>
<input type="text" name="payment_amount" id="em-payment-amount" value="<?php
if (!empty($_REQUEST['payment_amount'])) {
echo esc_attr($_REQUEST['payment_amount']);
}
?>
">
<?php
_e('Fully Paid', 'em-pro');
?>
<input type="checkbox" name="payment_full" id="em-payment-full" value="1"><br />
<em><?php
_e('If you check this as fully paid, and leave the amount paid blank, it will be assumed the full payment has been made.', 'em-pro');
?>
</em>
</p>
<?php
}
return;
}
示例4: 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()) {
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;
}
//.........这里部分代码省略.........
示例5: create_event_from_feed
public static function create_event_from_feed(array $FEED_ = NULL, $event_id = NULL)
{
global $ESS_Notices, $current_site;
$EM_Event = NULL;
if ($FEED_ != NULL) {
//dd( $FEED_ );
$EM_Event = new EM_Event(intval($event_id) > 0 ? $event_id : 0);
// set eventID for update
// -- Populate $_POST global var for EM functions
if (ESS_Import::set_post_from_feed($FEED_)) {
//dd($_POST);
if ($EM_Event->can_manage('edit_events', 'edit_recurring_events', 'edit_others_events') && $EM_Event->get_post()) {
// -- temporarily remove the save listener to prevent multi-pushing to search engines
ESS_IO::set_save_filter(FALSE);
$EM_Location = NULL;
$EM_Categories = NULL;
$EM_Tickets = NULL;
$blog_id = isset($current_site) ? $current_site->blog_id : NULL;
// used as global by some functions (Cf: EM_location::save())
if (empty($event_id)) {
$EM_Event->force_status = intval(get_option('ess_syndication_status')) >= 1 ? ESS_Database::EVENT_STATUS_PUBLISH : ESS_Database::EVENT_STATUS_DRAFT;
$EM_Event->event_status = 1;
$EM_Event->previous_status = 1;
} else {
$EM_Event->event_id = $event_id;
// -- Remove old images in case of event's update
if (get_option('ess_feed_import_images') && intval($EM_Event->post_id) > 0) {
ESS_Images::delete($EM_Event->post_id);
}
}
$EM_Event->post_status = strtolower($_POST['event_access']) == 'private' ? 'private' : ESS_Database::EVENT_STATUS_PUBLISH;
// == GENERAL
if (strlen($_POST['content']) > 0) {
if (get_option('ess_backlink_enabled')) {
$feed_uri = $FEED_['generals']['uri'];
$feed_uri_host = parse_url($feed_uri, PHP_URL_HOST);
$_POST['content'] .= "<h6>" . __("Source:", 'dbem') . " <a title=\"" . __("Source:", 'dbem') . " " . $feed_uri_host . "\" href=\"" . $feed_uri . "\">" . parse_url($feed_uri, PHP_URL_HOST) . "</a></h6>";
}
}
// == PLACE / LOCATION
//dd( $_POST['location_name'] );
if ($_POST['no_location'] === FALSE && strlen($_POST['location_name']) > 0 && get_option('dbem_locations_enabled')) {
$EM_Location = new EM_Location();
if ($EM_Location->can_manage('publish_locations') && $EM_Location->get_post(FALSE)) {
//d( $EM_Location );
// -- Search if this location already exists in the database
$similar_ = ESS_Import::load_similar_location(array('location_name' => $EM_Location->location_name, 'location_address' => $EM_Location->location_address, 'location_town' => $EM_Location->location_town, 'location_state' => $EM_Location->location_state, 'location_postcode' => $EM_Location->location_postcode, 'location_country' => $EM_Location->location_country));
//dd( $similar_ );
// if the location already exists use it instead.
if (@count($similar_) > 0 && $similar_ != NULL) {
foreach ($similar_ as $key => $val) {
$EM_Location->{$key} = $val;
}
} else {
$EM_Location->post_status = 'publish';
$EM_Location->location_status = 1;
$EM_Location->post_content = '';
}
// -- Search & defines latitude / longitude if not set
if (FeedValidator::isValidLatitude((string) $_POST['location_latitude']) == FALSE || FeedValidator::isValidLongitude((string) $_POST['location_longitude']) == FALSE) {
require_once EM_ESS_DIR . "/inc/libs/geocoder/GoogleGeocode.php";
$geocode_ = GoogleGeocode::getGeocodeFromAddress(trim($EM_Location->location_address . " " . $EM_Location->location_town . " " . $EM_Location->location_postcode . " " . $EM_Location->location_country));
$lat = (string) $geocode_['results'][0]['geometry']['location']['lat'];
$lng = (string) $geocode_['results'][0]['geometry']['location']['lng'];
//echo "latitude: " . $lat . " ==> ".((FeedValidator::isValidLatitude( $lat ))?'TRUE':'FALSE')."<br/>";
//echo "longitude: " . $lng . " ==> ".((FeedValidator::isValidLongitude( $lng ))?'TRUE':'FALSE')."<br/>";
if (FeedValidator::isValidLatitude($lat) && FeedValidator::isValidLongitude($lng)) {
$EM_Location->location_latitude = $lat;
$EM_Location->location_longitude = $lng;
}
}
if ($EM_Location->save() === FALSE) {
$ESS_Notices->add_error($EM_Location->get_errors());
}
$EM_Event->location_id = $EM_Location->location_id;
} else {
$ESS_Notices->add_error($EM_Location->get_errors());
}
}
// end add location
//dd( $EM_Location );
// == PRICE / TICKETS
//dd( $_POST['em_tickets'] );
if (@count($_POST['em_tickets']) > 0 && get_option('dbem_rsvp_enabled')) {
$EM_Tickets = new EM_Tickets($EM_Event);
$ticket_data = NULL;
// Create tickets only if they doesn't exists
if (@count($EM_Tickets->tickets) <= 0) {
foreach ($_POST['em_tickets'] as $ticket_data) {
$EM_Ticket = new EM_Ticket();
$EM_Ticket->get_post($ticket_data);
$EM_Tickets->tickets[] = $EM_Ticket;
}
}
if ($ticket_data != NULL) {
$EM_Event->event_rsvp = TRUE;
$EM_Event->event_rsvp_date = $ticket_data['event_rsvp_date'];
$EM_Event->event_rsvp_time = $ticket_data['event_rsvp_time'];
$EM_Event->event_spaces = $ticket_data['event_spaces'];
$EM_Event->rsvp_time = $ticket_data['event_rsvp_time'];
//.........这里部分代码省略.........