/** * 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 ? '&' : '?'; if (em_verify_admin()) { //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 } //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 } } } //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 <strong>Events Manager</strong>. If you want to display your content, you can can assign another page to <strong>Events Manager</strong> in the the <a href='%s'>Settings</a>. ", 'dbem'), 'admin.php?page=events-manager-options'); $notice = "<div class='error'><p>{$message}</p></div>"; echo $notice; } }
function em_create_events_submenu() { if (function_exists('add_submenu_page')) { //Count pending bookings $num = ''; if (get_option('dbem_bookings_approval') == 1) { $bookings_pending_count = count(EM_Bookings::get(array('status' => 0))); //TODO Add flexible permissions if ($bookings_pending_count > 0) { $num = '<span class="update-plugins count-' . $bookings_pending_count . '"><span class="plugin-count">' . $bookings_pending_count . '</span></span>'; } } add_object_page(__('Events', 'dbem'), __('Events', 'dbem') . $num, EM_MIN_CAPABILITY, 'events-manager', 'em_admin_events_page', '../wp-content/plugins/events-manager/includes/images/calendar-16.png'); // Add a submenu to the custom top-level menu: $plugin_pages = array(); $plugin_pages[] = add_submenu_page('events-manager', __('Edit'), __('Edit'), EM_MIN_CAPABILITY, 'events-manager', 'em_admin_events_page'); $plugin_pages[] = add_submenu_page('events-manager', __('Add new', 'dbem'), __('Add new', 'dbem'), EM_MIN_CAPABILITY, 'events-manager-event', "em_admin_event_page"); if (get_option('dbem_permissions_locations') != 1 || em_verify_admin()) { $plugin_pages[] = add_submenu_page('events-manager', __('Locations', 'dbem'), __('Locations', 'dbem'), EM_MIN_CAPABILITY, 'events-manager-locations', "em_admin_locations_page"); } if (get_option('dbem_rsvp_enabled') == 1) { $plugin_pages[] = add_submenu_page('events-manager', __('Bookings', 'dbem'), __('Bookings', 'dbem') . $num, EM_MIN_CAPABILITY, 'events-manager-bookings', "em_bookings_page"); } if (get_option('dbem_permissions_categories') != 1 || em_verify_admin()) { $plugin_pages[] = add_submenu_page('events-manager', __('Event Categories', 'dbem'), __('Categories', 'dbem'), EM_MIN_CAPABILITY, "events-manager-categories", 'em_admin_categories_page'); } $plugin_pages[] = add_submenu_page('events-manager', __('Events Manager Settings', 'dbem'), __('Settings', 'dbem'), EM_SETTING_CAPABILITY, "events-manager-options", 'em_admin_options_page'); $plugin_pages[] = add_submenu_page('events-manager', __('Getting Help for Events Manager', 'dbem'), __('Help', 'dbem'), EM_SETTING_CAPABILITY, "events-manager-help", 'em_admin_help_page'); foreach ($plugin_pages as $plugin_page) { add_action('admin_print_scripts-' . $plugin_page, 'em_admin_load_scripts'); add_action('admin_head-' . $plugin_page, 'em_admin_general_script'); add_action('admin_print_styles-' . $plugin_page, 'em_admin_load_styles'); } } }
<?php /* * This page will search for either a specific location via GET "id" variable * or will search for events by name via the GET "q" variable. */ require_once '../../../../wp-load.php'; global $wpdb; $locations_table = $wpdb->prefix . EM_LOCATIONS_TABLE; $location_cond = get_option('dbem_permissions_locations') < 1 && !em_verify_admin() ? "AND location_owner=" . get_current_user_id() : ''; $term = isset($_GET['term']) ? '%' . $_GET['term'] . '%' : '%' . $_GET['q'] . '%'; $sql = $wpdb->prepare("\n\tSELECT \n\t\tConcat( location_name, ', ', location_address, ', ', location_town) AS `label`,\n\t\tlocation_name AS `value`,\n\t\tlocation_address AS `address`, \n\t\tlocation_town AS `town`, \n\t\tlocation_id AS `id`\n\tFROM {$locations_table} \n\tWHERE ( `location_name` LIKE %s ) {$location_cond} LIMIT 10\n", $term); $locations_array = $wpdb->get_results($sql); echo EM_Object::json_encode($locations_array); /* $return_string_array = array(); foreach($locations_array as $location){ $return_string_class = array(); foreach($location as $key => $value ){ $return_string_class[] = "$key : '".addslashes($value)."'"; } $return_string_array[] = '{'. implode(',', $return_string_class) .'}'; } echo '['. implode(',', $return_string_array) .']'; */
function get_default_search($array = array()) { $defaults = array('scope' => false, 'eventful' => false, 'eventless' => false); if (is_admin()) { //by default, we only get categories the owner can manage switch (get_option('dbem_permissions_categories')) { case 0: $defaults['owner'] = get_current_user_id(); break; case 1: $wp_user_search = new WP_User_Search(null, null, 'administrator'); $users = $wp_user_search->get_results(); $users[] = get_current_user_id(); $users[] = 0; $defaults['owner'] = implode(',', $users); break; case 2: $defaults['owner'] = false; break; } $defaults['owner'] = em_verify_admin() ? false : $defaults['owner']; } return apply_filters('em_categories_get_default_search', parent::get_default_search($defaults, $array), $array, $defaults); }
/** * Can the user manage this event? */ function can_manage() { return get_option('dbem_permissions_events') || $this->owner == get_current_user_id() || em_verify_admin(); }
function get_default_search($array = array()) { $defaults = array('status' => false, 'person' => true); if (true || is_admin()) { //figure out default owning permissions switch (get_option('dbem_permissions_events')) { case 0: $defaults['owner'] = get_current_user_id(); break; case 1: $defaults['owner'] = false; break; } $defaults['owner'] = em_verify_admin() ? false : $defaults['owner']; } return apply_filters('em_bookings_get_default_search', parent::get_default_search($defaults, $array), $array, $defaults); }
function get_default_search($array = array()) { $defaults = array('scope' => false, 'eventful' => false, 'eventless' => false); //figure out default owning permissions, but since public is for viewing events, only impose limitations in admin area if (is_admin()) { switch (get_option('dbem_permissions_events')) { case 0: $defaults['owner'] = get_current_user_id(); break; case 1: $defaults['owner'] = false; break; } $defaults['owner'] = em_verify_admin() ? false : $defaults['owner']; } return apply_filters('em_people_get_default_search', parent::get_default_search($defaults, $array), $array, $defaults); }
/** * Can the user manage this event? */ function can_manage($error_msg = false) { $can_manage = get_option('dbem_permissions_events') || $this->author == get_current_user_id() || empty($this->id) || em_verify_admin(); if ($error_msg && !$can_manage) { $this->errors[] = __('You do not have permission to manage this event.', 'dbem'); } return apply_filters('em_event_can_manage', $can_manage, $this); }
function get_default_search($array = array()) { $defaults = array('orderby' => get_option('dbem_events_default_orderby'), 'order' => get_option('dbem_events_default_order'), 'rsvp' => false); if (is_admin()) { //figure out default owning permissions switch (get_option('dbem_permissions_events')) { case 0: $defaults['owner'] = get_current_user_id(); break; case 1: $defaults['owner'] = false; break; } $defaults['owner'] = em_verify_admin() ? false : $defaults['owner']; } return apply_filters('em_events_get_default_search', parent::get_default_search($defaults, $array), $array, $defaults); }
function can_use() { switch (get_option('dbem_permissions_locations')) { case 0: return $this->owner == get_current_user_id(); case 1: return em_verify_admin($this->owner); case 2: return true; } }
/** * Generates Event Admin page, for adding and updating a single (or recurring) event. * @param $title * @return null */ function em_admin_event_page() { global $EM_Event, $current_user; global $localised_date_formats; //check that user can access this page if (is_object($EM_Event) && !$EM_Event->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; } if (is_object($EM_Event) && $EM_Event->id > 0) { if ($EM_Event->is_recurring()) { $title = __("Reschedule", 'dbem') . " '{$EM_Event->name}'"; } else { $title = __("Edit Event", 'dbem') . " '" . $EM_Event->name . "'"; } } else { $EM_Event = is_object($EM_Event) && get_class($EM_Event) == 'EM_Event' ? $EM_Event : new EM_Event(); $title = __("Insert New Event", 'dbem'); //Give a default location & category $default_cat = get_option('dbem_default_category'); $default_loc = get_option('dbem_default_location'); if (is_numeric($default_cat) && $default_cat > 0) { $EM_Event->category_id = $default_cat; $EM_Event->category = new EM_Category($default_cat); } if (is_numeric($default_loc) && $default_loc > 0 && (empty($EM_Event->location->id) && empty($EM_Event->location->name) && empty($EM_Event->location->address) && empty($EM_Event->location->town))) { $EM_Event->location_id = $default_loc; $EM_Event->location = new EM_Location($default_loc); } } $use_select_for_locations = get_option('dbem_use_select_for_locations'); // change prefix according to event/recurrence $pref = "event_"; $locale_code = substr(get_locale(), 0, 2); $localised_date_format = $localised_date_formats[$locale_code]; //FIXME time useage is very flimsy imho $hours_locale_regexp = "H:i"; // Setting 12 hours format for those countries using it if (preg_match("/en|sk|zh|us|uk/", $locale_code)) { $hours_locale_regexp = "h:iA"; } $days_names = array(1 => __('Mon'), 2 => __('Tue'), 3 => __('Wed'), 4 => __('Thu'), 5 => __('Fri'), 6 => __('Sat'), 0 => __('Sun')); ?> <?php if (count($EM_Event->errors) > 0 || !empty($_GET['error'])) { ?> <div id='message' class='error '> <p> <?php if (count($EM_Event->errors)) { ?> <strong><?php echo __("Ach, there's a problem here:", "dbem"); ?> </strong><br /><br /> <?php echo implode('<br />', $EM_Event->errors); ?> <?php } else { echo $_GET['error']; } ?> </p> </div> <?php } ?> <?php if (!empty($EM_Event->feedback_message) || !empty($_GET['message'])) { ?> <div id='message' class='updated fade'> <p><?php echo !empty($EM_Event->feedback_message) ? $EM_Event->feedback_message : $_GET['message']; ?> </p> </div> <?php } ?> <form id="event-form" method="post" action=""> <div class="wrap"> <div id="icon-events" class="icon32"><br /></div> <h2><?php echo $title; ?> </h2> <?php if ($EM_Event->is_recurrence() || $EM_Event->is_recurring()) { ?> <p id='recurrence_warning'> <?php //TODO better warning system when changing a recurring event (e.g. when removing recurrences). if ($EM_Event->is_recurring()) { _e('WARNING: This is a recurring event.', 'dbem'); echo "<br />"; _e('Modifying these data all the events linked to this recurrence will be rescheduled', 'dbem'); echo " "; _e('and all booking information will be deleted!', 'dbem'); } elseif ($EM_Event->is_recurrence()) { //TODO Terminology confusing with methods, maybe worth changing? _e('WARNING: This is a recurrence.', 'dbem'); echo "<br />"; _e('If you change these data and save, this will become an independent event.', 'dbem'); } ?> </p> <?php } ?> <div id="poststuff" class="metabox-holder has-right-sidebar"> <!-- SIDEBAR --> <div id="side-info-column" class='inner-sidebar'> <div id='side-sortables'> <?php if (get_option('dbem_recurrence_enabled')) { ?> <!-- START recurrence postbox --> <div class="postbox "> <div class="handlediv" title="Fare clic per cambiare."><br /> </div> <h3 class='hndle'><span> <?php _e("Recurrence", 'dbem'); ?> </span></h3> <div class="inside"> <?php //TODO add js warning if rescheduling, since all bookings are deleted ?> <?php if (!$EM_Event->id || $EM_Event->is_recurring()) { ?> <p> <input id="event-recurrence" type="checkbox" name="repeated_event" value="1" <?php echo $EM_Event->is_recurring() ? 'checked="checked"' : ''; ?> /> <?php _e('Repeated event', 'dbem'); ?> </p> <div id="event_recurrence_pattern"> <p> Frequency: <select id="recurrence-frequency" name="recurrence_freq"> <?php $freq_options = array("daily" => __('Daily', 'dbem'), "weekly" => __('Weekly', 'dbem'), "monthly" => __('Monthly', 'dbem')); em_option_items($freq_options, $EM_Event->freq); ?> </select> </p> <p> <?php _e('Every', 'dbem'); ?> <input id="recurrence-interval" name='recurrence_interval' size='2' value='<?php echo $EM_Event->interval; ?> ' /> <span class='interval-desc' id="interval-daily-singular"> <?php _e('day', 'dbem'); ?> </span> <span class='interval-desc' id="interval-daily-plural"> <?php _e('days', 'dbem'); ?> </span> <span class='interval-desc' id="interval-weekly-singular"> <?php _e('week', 'dbem'); ?> </span> <span class='interval-desc' id="interval-weekly-plural"> <?php _e('weeks', 'dbem'); ?> </span> <span class='interval-desc' id="interval-monthly-singular"> <?php _e('month', 'dbem'); ?> </span> <span class='interval-desc' id="interval-monthly-plural"> <?php _e('months', 'dbem'); ?> </span> </p> <p class="alternate-selector" id="weekly-selector"> <?php $saved_bydays = $EM_Event->is_recurring() ? explode(",", $EM_Event->byday) : array(); em_checkbox_items('recurrence_bydays[]', $days_names, $saved_bydays); ?> </p> <p class="alternate-selector" id="monthly-selector"> <?php _e('Every', 'dbem'); ?> <select id="monthly-modifier" name="recurrence_byweekno"> <?php $weekno_options = array("1" => __('first', 'dbem'), '2' => __('second', 'dbem'), '3' => __('third', 'dbem'), '4' => __('fourth', 'dbem'), '-1' => __('last', 'dbem')); em_option_items($weekno_options, $EM_Event->byweekno); ?> </select> <select id="recurrence-weekday" name="recurrence_byday"> <?php em_option_items($days_names, $EM_Event->byday); ?> </select> </p> </div> <p id="recurrence-tip"> <?php _e('Check if your event happens more than once according to a regular pattern', 'dbem'); ?> </p> <?php } elseif ($EM_Event->is_recurrence()) { ?> <p> <?php echo $EM_Event->get_recurrence_description(); ?> <br /> <a href="<?php bloginfo('wpurl'); ?> /wp-admin/admin.php?page=events-manager-event&event_id=<?php echo $EM_Event->recurrence_id; ?> "> <?php _e('Reschedule', 'dbem'); ?> </a> <input type="hidden" name="recurrence_id" value="<?php echo $EM_Event->recurrence_id; ?> " /> </p> <?php } else { ?> <p><?php _e('This is\'t a recurrent event', 'dbem'); ?> </p> <?php } ?> </div> </div> <!-- END recurrence postbox --> <?php } ?> <?php if (get_option('dbem_rsvp_enabled')) { ?> <!-- START RSVP --> <?php if (em_verify_admin()) { ?> <div class="postbox "> <div class="handlediv" title="Fare clic per cambiare."><br /> </div> <h3 class='hndle'><span> <?php _e('Contact Person', 'dbem'); ?> </span></h3> <div class="inside"> <p><?php _e('Contact', 'dbem'); ?> <?php wp_dropdown_users(array('name' => 'event_contactperson_id', 'show_option_none' => __("Select...", 'dbem'), 'selected' => $EM_Event->contactperson_id)); ?> </p> </div> </div> <?php } else { ?> <input type="hidden" name="event_contactperson_id" value="<?php get_current_user_id(); ?> " /> <?php } ?> <div class="postbox "> <div class="handlediv" title="Fare clic per cambiare."><br /> </div> <h3 class='hndle'><span><?php _e('RSVP', 'dbem'); ?> </span></h3> <div class="inside"> <p> <input id="rsvp-checkbox" name='event_rsvp' value='1' type='checkbox' <?php echo $EM_Event->rsvp ? 'checked="checked"' : ''; ?> /> <?php _e('Enable registration for this event', 'dbem'); ?> </p> <div id='rsvp-data'> <?php if ($EM_Event->contactperson_id != NULL) { $selected = $EM_Event->contactperson_id; } else { $selected = '0'; } ?> <p> <?php _e('Spaces', 'dbem'); ?> : <input id="seats-input" type="text" name="event_seats" size='5' value="<?php echo $EM_Event->seats; ?> " /> </p> <!-- START RSVP Stats --> <?php if ($EM_Event->rsvp) { $available_seats = $EM_Event->get_bookings()->get_available_seats(); $booked_seats = $EM_Event->get_bookings()->get_booked_seats(); if (count($EM_Event->get_bookings()->bookings) > 0) { ?> <div class='wrap'> <p><strong><?php echo __('Available Spaces', 'dbem') . ': ' . $EM_Event->get_bookings()->get_available_seats(); ?> </strong></p> <p><strong><?php echo __('Confirmed Spaces', 'dbem') . ': ' . $EM_Event->get_bookings()->get_booked_seats(); ?> </strong></p> <p><strong><?php echo __('Pending Spaces', 'dbem') . ': ' . $EM_Event->get_bookings()->get_pending_seats(); ?> </strong></p> </div> <br class='clear'/> <div id='major-publishing-actions'> <div id='publishing-action'> <a id='printable' href='<?php echo get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager-bookings&event_id=" . $EM_Event->id; ?> '><?php _e('manage bookings', 'dbem'); ?> </a><br /> <a target='_blank' href='<?php echo get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager-bookings&action=bookings_report&event_id=" . $EM_Event->id; ?> '><?php _e('printable view', 'dbem'); ?> </a> <a href='<?php echo get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager-bookings&action=export_csv&event_id=" . $EM_Event->id; ?> '><?php _e('export csv', 'dbem'); ?> </a> <br class='clear'/> </div> <br class='clear'/> </div> <?php } else { ?> <p><em><?php _e('No responses yet!'); ?> </em></p> <?php } } ?> <!-- END RSVP Stats --> </div> </div> </div> <!-- END RSVP --> <?php } ?> <?php if (get_option('dbem_categories_enabled')) { ?> <!-- START Categories --> <div class="postbox "> <div class="handlediv" title="Fare clic per cambiare."><br /> </div> <h3 class='hndle'><span> <?php _e('Category', 'dbem'); ?> </span></h3> <div class="inside"> <?php $categories = EM_Categories::get(array('orderby' => 'category_name')); ?> <?php if (count($categories) > 0) { ?> <p><?php _e('Category:', 'dbem'); ?> <select name="event_category_id"> <option value="" <?php echo $EM_Event->category_id == '' ? "selected='selected'" : ''; ?> ><?php _e('no category', 'dbem'); ?> </option> <?php foreach ($categories as $EM_Category) { $selected = $EM_Category->id == $EM_Event->category_id ? "selected='selected'" : ''; ?> <option value="<?php echo $EM_Category->id; ?> " <?php echo $selected; ?> > <?php echo $EM_Category->name; ?> </option> <?php } ?> </select> </p> <?php } else { ?> <p><?php sprintf(__('No categories available, <a href="%s">create one here first</a>', 'dbem'), get_bloginfo('wpurl') . '/wp-admin/admin.php?page=events-manager-categories'); ?> </p> <?php } ?> </div> </div> <!-- END Categories --> <?php } ?> </div> </div> <!-- END OF SIDEBAR --> <div id="post-body"> <div id="post-body-content"> <div id="event_name" class="stuffbox"> <h3> <?php _e('Name', 'dbem'); ?> </h3> <div class="inside"> <input type="text" name="event_name" id="event-name" value="<?php echo htmlspecialchars($EM_Event->name, ENT_QUOTES); ?> " /> <br /> <?php _e('The event name. Example: Birthday party', 'dbem'); ?> </div> </div> <div id="event_start_date" class="stuffbox"> <h3 id='event-date-title'> <?php _e('Event date', 'dbem'); ?> </h3> <h3 id='recurrence-dates-title'> <?php _e('Recurrence dates', 'dbem'); ?> </h3> <div class="inside"> <input id="localised-date" type="text" name="localised_event_date" style="display: none;" /> <input id="date-to-submit" type="text" name="event_start_date" value="<?php echo $EM_Event->start_date; ?> " style="background: #FCFFAA" /> <input id="localised-end-date" type="text" name="localised_event_end_date" style="display: none;" /> <input id="end-date-to-submit" type="text" name="event_end_date" value="<?php echo $EM_Event->end_date; ?> " style="background: #FCFFAA" /> <br /> <span id='event-date-explanation'> <?php _e('The event date.', 'dbem'); /* Marcus Begin Edit */ echo " "; _e('When not reoccurring, this event spans between the beginning and end date.', 'dbem'); /* Marcus End Edit */ ?> </span> <span id='recurrence-dates-explanation'> <?php _e('The recurrence beginning and end date.', 'dbem'); ?> </span> </div> </div> <div id="event_end_day" class="stuffbox"> <h3> <?php _e('Event time', 'dbem'); ?> </h3> <div class="inside"> <input id="start-time" type="text" size="8" maxlength="8" name="event_start_time" value="<?php echo date($hours_locale_regexp, strtotime($EM_Event->start_time)); ?> " /> - <input id="end-time" type="text" size="8" maxlength="8" name="event_end_time" value="<?php echo date($hours_locale_regexp, strtotime($EM_Event->end_time)); ?> " /> <br /> <?php _e('The time of the event beginning and end', 'dbem'); ?> . </div> </div> <div id="location_coordinates" class="stuffbox" style='display: none;'> <h3> <?php _e('Coordinates', 'dbem'); ?> </h3> <div class="inside"> <input id='location-latitude' name='location_latitude' type='text' value='<?php echo $EM_Event->latitude; ?> ' size='15' /> - <input id='location-longitude' name='location_longitude' type='text' value='<?php echo $EM_Event->longitude; ?> ' size='15' /> </div> </div> <div id="location_info" class="stuffbox"> <h3> <?php _e('Location', 'dbem'); ?> </h3> <div class="inside"> <table id="dbem-location-data"> <tr> <td style="padding-right:20px"> <table> <?php if ($use_select_for_locations) { ?> <tr> <th><?php _e('Location:', 'dbem'); ?> </th> <td> <select name="location-select-id" id='location-select-id' size="1"> <?php $locations = EM_Locations::get(); foreach ($locations as $location) { $selected = ""; if (is_object($EM_Event->location)) { if ($EM_Event->location->id == $location->id) { $selected = "selected='selected' "; } } ?> <option value="<?php echo $location->id; ?> " title="<?php echo "{$location->latitude},{$location->longitude}"; ?> " <?php echo $selected; ?> ><?php echo $location->name; ?> </option> <?php } ?> </select> <p><?php _e('The name of the location where the event takes place. You can use the name of a venue, a square, etc', 'dbem'); ?> </p> </td> </tr> <?php } else { ?> <tr> <th><?php _e('Name:'); ?> </th> <td> <input id="location-name" type="text" name="location_name" value="<?php echo htmlspecialchars($EM_Event->location->name, ENT_QUOTES); ?> " /> <p><?php _e('Select a location for your event', 'dbem'); ?> </p> </td> </tr> <tr> <th><?php _e('Address:'); ?> </th> <td> <input id="location-address" type="text" name="location_address" value="<?php echo htmlspecialchars($EM_Event->location->address, ENT_QUOTES); ?> " /> <p><?php _e('The address of the location where the event takes place. Example: 21, Dominick Street', 'dbem'); ?> </p> </td> </tr> <tr> <th><?php _e('Town:'); ?> </th> <td> <input id="location-town" type="text" name="location_town" value="<?php echo htmlspecialchars($EM_Event->location->town, ENT_QUOTES); ?> " /> <p><?php _e('The town where the location is located. If you\'re using the Google Map integration and want to avoid geotagging ambiguities include the country in the town field. Example: Verona, Italy.', 'dbem'); ?> </p> </td> </tr> <?php } ?> </table> </td> <?php if (get_option('dbem_gmap_is_active')) { ?> <td width="400"> <div id='em-map-404' style='width: 400px; vertical-align:middle; text-align: center;'> <p><em><?php _e('Location not found', 'dbem'); ?> </em></p> </div> <div id='em-map' style='width: 400px; height: 300px; display: none;'></div> </td> <?php } ?> </tr> </table> </div> </div> <div id="event_notes" class="postbox"> <h3> <?php _e('Details', 'dbem'); ?> </h3> <div class="inside"> <div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?> " class="postarea"> <?php the_editor($EM_Event->notes); ?> </div> <br /> <?php _e('Details about the event', 'dbem'); ?> </div> </div> <?php if (get_option('dbem_attributes_enabled')) { ?> <div id="event_attributes" class="postbox"> <h3> <?php _e('Attributes', 'dbem'); ?> </h3> <div class="inside"> <?php //We also get a list of attribute names and create a ddm list (since placeholders are fixed) $formats = get_option('dbem_event_list_item_format') . get_option('dbem_event_page_title_format') . get_option('dbem_full_calendar_event_format') . get_option('dbem_location_baloon_format') . get_option('dbem_location_event_list_item_format') . get_option('dbem_location_page_title_format') . get_option('dbem_map_text_format') . get_option('dbem_rss_description_format') . get_option('dbem_rss_title_format') . get_option('dbem_single_event_format') . get_option('dbem_single_location_format') . get_option('dbem_placeholders_custom'); //We now have one long string of formats, get all the attribute placeholders preg_match_all('/#_ATT\\{.+?\\}(\\{.+?\\})?/', $formats, $placeholders); //Now grab all the unique attributes we can use in our event. $attributes = array(); foreach ($placeholders[0] as $result) { $attribute = substr(substr($result, 0, strpos($result, '}')), 6); if (!in_array($attribute, $attributes)) { $attributes[] = $attribute; } } ?> <div class="wrap"> <?php if (count($attributes) > 0) { ?> <h2>Attributes</h2> <p>Add attributes here</p> <table class="form-table"> <thead> <tr valign="top"> <td><strong>Attribute Name</strong></td> <td><strong>Value</strong></td> </tr> </thead> <tfoot> <tr valign="top"> <td colspan="3"><a href="#" id="mtm_add_tag">Add new tag</a></td> </tr> </tfoot> <tbody id="mtm_body"> <?php $count = 1; if (is_array($EM_Event->attributes) and count($EM_Event->attributes) > 0) { foreach ($EM_Event->attributes as $name => $value) { ?> <tr valign="top" id="mtm_<?php echo $count; ?> "> <td scope="row"> <select name="mtm_<?php echo $count; ?> _ref"> <?php if (!in_array($name, $attributes)) { echo "<option value='{$name}'>{$name} (" . __('Not defined in templates', 'dbem') . ")</option>"; } foreach ($attributes as $attribute) { if ($attribute == $name) { echo "<option selected='selected'>{$attribute}</option>"; } else { echo "<option>{$attribute}</option>"; } } ?> </select> <a href="#" rel="<?php echo $count; ?> ">Remove</a> </td> <td> <input type="text" name="mtm_<?php echo $count; ?> _name" value="<?php echo htmlspecialchars($value, ENT_QUOTES); ?> " /> </td> </tr> <?php $count++; } } else { ?> <tr valign="top" id="mtm_<?php echo $count; ?> "> <td scope="row"> <select name="mtm_<?php echo $count; ?> _ref"> <?php foreach ($attributes as $attribute) { echo "<option>{$attribute}</option>"; } ?> </select> <a href="#" rel="<?php echo $count; ?> ">Remove</a> </td> <td> <input type="text" name="mtm_<?php echo $count; ?> _name" /> </td> </tr> <?php } ?> </tbody> </table> <?php } else { ?> <p> <?php _e('In order to use attributes, you must define some in your templates, otherwise they\'ll never show. Go to Events > Settings to add attribute placeholders.', 'dbem'); ?> </p> <script> jQuery(document).ready(function($){ $('#event_attributes').addClass('closed'); }); </script> <?php } ?> </div> </div> </div> <?php } ?> </div> <p class="submit"> <input type="submit" name="events_update" value="<?php _e('Submit Event', 'dbem'); ?> »" /> </p> <input type="hidden" name="p" value="<?php echo !empty($_REQUEST['pno']) ? $_REQUEST['pno'] : ''; ?> " /><a> <input type="hidden" name="scope" value="<?php echo !empty($_REQUEST['scope']) ? $_REQUEST['scope'] : ''; ?> " /></a> <input type="hidden" name="action" value="save" /> </div> </div> </div> </form> <script type="text/javascript"> jQuery(document).ready( function($) { <?php if ($EM_Event->is_recurring()) { ?> //Recurrence Warnings $('#event_form').submit( function(event){ confirmation = confirm('<?php _e('Are you sure you want to reschedule this recurring event? If you do this, you will lose all booking information and the old recurring events will be deleted.', 'dbem'); ?> '); if( confirmation == false ){ event.preventDefault(); } }); <?php } ?> <?php if ($EM_Event->rsvp == 1) { ?> //RSVP Warning $('#rsvp-checkbox').click( function(event){ if( !this.checked ){ confirmation = confirm('<?php _e('Are you sure you want to disable bookings? If you do this and save, you will lose all previous bookings. If you wish to prevent further bookings, reduce the number of seats available to the amount of bookings you currently have', 'dbem'); ?> '); if( confirmation == false ){ event.preventDefault(); } } }); <?php } ?> }); </script> <?php }
/** * 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> <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 Events', 'dbem'); ?> " class="button" /> </p> <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%')); $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 { ?> <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('Name', 'dbem'); ?> </th> <th> </th> <th><?php _e('Location', 'dbem'); ?> </th> <th colspan="2"><?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"); $location_summary = "<b>" . $event->location->name . "</b><br/>" . $event->location->address . " - " . $event->location->town; $category = new EM_Category($event->category_id); 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-event&event_id=<?php echo $event->id; ?> &scope=<?php echo $scope; ?> &p=<?php echo $page; ?> "><?php echo $event->name; ?> </a> </strong> <?php if (is_object($category)) { ?> <br/><span title='<?php echo __('Category', 'dbem') . ": " . $category->name; ?> '><?php echo $category->name; ?> </span> <?php } ?> <?php if (get_option('dbem_rsvp_enabled') == 1 && $event->rsvp == 1) { ?> <br/> <a href="<?php bloginfo('wpurl'); ?> /wp-admin/admin.php?page=events-manager-bookings&event_id=<?php echo $event->id; ?> "><?php echo __("Bookings", 'dbem'); ?> </a> – <?php _e("Booked", '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> <a href="<?php bloginfo('wpurl'); ?> /wp-admin/admin.php?page=events-manager-event&action=duplicate&event_id=<?php echo $event->id; ?> &scope=<?php echo $scope; ?> &p=<?php echo $page; ?> " title="<?php _e('Duplicate this event', 'dbem'); ?> "> <strong>+</strong> </a> </td> <td> <?php echo $location_summary; ?> </td> <td> <?php echo $localised_start_date; ?> <?php echo $localised_end_date != $localised_start_date ? " - {$localised_end_date}" : ''; ?> <br /> <?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> <td> <?php if ($event->is_recurrence()) { ?> <strong> <?php echo $event->get_recurrence_description(); ?> <br /> <a href="<?php bloginfo('wpurl'); ?> /wp-admin/admin.php?page=events-manager-event&event_id=<?php echo $event->recurrence_id; ?> &scope=<?php echo $scope; ?> &p=<?php echo $page; ?> "><?php _e('Reschedule', 'dbem'); ?> </a> </strong> <?php } ?> </td> </tr> <?php } $event_count++; } ?> </tbody> </table> <?php } // end of table ?> <div class='tablenav'> <div class="alignleft actions"> <br class='clear' /> </div> <?php if ($events_count >= $limit) { ?> <div class="tablenav-pages"> <?php echo $events_nav; ?> </div> <?php } ?> <br class='clear' /> </div> </form> </div> <?php }