Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Base file: events-manager-extened.php
- <?php
- /***************************************************************************/
- /* Plugin Name: Events Manager Extended */
- /* Plugin URI: http://wp-events-plugin.com */
- /* Description: This plugin extends the standard events manager plugin */
- /* to allow for multiple rooms/classrooms where classes */
- /* and/or events can be held and allows for rental of the */
- /* rooms, setting of fee/rental schedule for the rooms and */
- /* setting of fees to the attendee, with payment account */
- /* for the class/event creator. */
- /* File: events-manager-extened.php Path: ../wp-content/plugins */
- /* /events-manager-ext */
- /* Author: Nyle E. Davis Create Date: 10/25/11 */
- /* Author URI: http://technopool.wordpress.com */
- /* Version: 1.0 Copyright (C): 2011 WebPrimacy */
- /* License: GPL2 */
- /***************************************************************************/
- define('EMXT_VERSION', 1.0);
- define('EMXT_SLUG', plugin_basename( __FILE__ ));
- include ('classes/emxt-class.php');
- //Add translation
- load_plugin_textdomain('emxt', false, dirname( plugin_basename( __FILE__ ) ).'/langs');
- // Get system DIR vars
- define('EMXT_DIR', dirname( __FILE__ )); //an absolute path to this directory
- // Set path to forms
- $hom_dir = EMXT_DIR;
- $adm_dir = EMXT_DIR . '/admin/';
- $frm_dir = EMXT_DIR . '/templates/forms/';
- // Set path to main EM dir
- $rot_pos = strpos(EMXT_DIR, '/event');
- $rot_dir = substr(EMXT_DIR,0,$rot_pos+1);
- $mem_dir = $rot_dir.'events-manager/';
- //echo "M=> $mem_dir <= <br>";
- // Set functions path
- global $wpdb;
- if ( get_site_option('dbem_ms_global_table') ){
- $prefix = $wpdb->base_prefix;
- } else {
- $prefix = $wpdb->prefix;
- } // end if get_site_option
- // Define the new forms
- define('EMXT_OPTIONS_FORM', $frm_dir.'emxt-admin-optform.php'); //FORM NAME
- define('EMXT_FEES_FORM',$frm_dir.'emxt-admin-fees.php'); //FORM NAME
- define('EMXT_ROOMS_FORM', $frm_dir.'emxt-admin-rooms.php'); //FORM NAME
- define('EMXT_CREATE_FORM', $frm_dir.'emxt-create.php'); //FORM NAME
- define('EMXT_EDIT_FORM',$frm_dir.'emxt-editor.php'); //FORM NAME
- define('EMXT_GUEST_FORM',$frm_dir.'emxt-editor-guest.php'); //FORM NAME
- define('EMXT_MIN_CAPABILITY', $prefix.'edit_events'); // Minimum user level to add events
- define('EMXT_EDITOR_CAPABILITY',$prefix. 'publish_events'); // Minimum user level to access calendars
- define('EMXT_SETTING_CAPABILITY', $prefix.'activate_plugins'); // Minimum user level to edit settings in EM
- //Include admin files if needed
- if (is_admin()){
- //include_once('em-pro-admin.php');
- //include_once($adm_dir.'emxt-admin-options.php'); //updateadmin page
- include_once('emxt-updates.php'); //update manager
- }
- /* Creating the tables to store extended data*/
- function emxt_activate() {
- global $wp_rewrite;
- $wp_rewrite->flush_rules();
- }
- register_activation_hook( __FILE__,'emxt_activate');
- // Start plugin
- global $EM_Ext;
- $EM_Ext = new EM_Ext();
- ?>
- Install file: emxt-install.php
- <?php
- /***************************************************************************/
- /* File: emxt-install.php Path: ../wp-content/plugins */
- /* /events-manager */
- /* Author: unknown Create Date: unknown */
- /* Mod by: Nyle E. Davis Mod Date: 10/25/11 */
- /* Purpose: This file is the file/page for creation of an event/class t */
- /* allow the teacher/event creator to define his/her event/cla */
- /* set the fees and enter the description of the class for disay */
- /* to the calendar, etc. */
- /* Mod: The file was modified to clean up appreance, change ticketi, */
- /* set fees, pay for and reserve facilities. */
- /***************************************************************************/
- function emxt_install() {
- global $wp_rewrite;
- $wp_rewrite->flush_rules();
- $old_version = get_option('dbem_version');
- if ( $old_version != '' && $old_version < 3.096 ){
- function em_update_required_notification(){
- global $EM_Booking;
- ?><div class="error"><p><strong>Events Manager upgrade not complete,
- please upgrade to the version 3.0.96 or higher first from
- <a href="http://wordpress.org/extend/plugins/events-manager/download/">here</a>
- first before upgrading to this version.
- <a href="http://wp-events-plugin.com/news/upgrade-issues-screencast-walkthrough/">We
- made a screencast</a> to help you out.</strong></p></div>
- <?php
- } // end function
- add_action ( 'admin_notices', 'em_update_required_notification' );
- return;
- } // end if $old_version
- // Create the tables
- emxt_create_tables();
- emxt_add_menu ();
- add_action ('admin_menu','emxt_add_menu');
- // emxt_set_capabilities();
- emxt_createpages();
- update_option('dbemxt_version', EMXT_VERSION);
- } // end function
- function emxt_create_tables() {
- global $wpdb;
- require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
- if ( get_site_option('dbem_ms_global_table') ){
- $prefix = $wpdb->base_prefix;
- } else {
- $prefix = $wpdb->prefix;
- } // end if get_site_option
- $t1_name = $prefix.'em_accounts';
- $sql_1 = "CREATE TABLE IF NOT EXISTS ".$t1_name." (
- `acc_id` bigint(20) unsigned NOT NULL auto_increment COMMENT 'Table Index',
- `acc_cdx` bigint(20) unsigned NOT NULL COMMENT 'Xref to event creator index (users table)',
- `acc_rdx` bigint(20) unsigned NOT NULL COMMENT 'Xref to role index (Must be role_t)',
- `acc_num` varchar(14) NOT NULL COMMENT 'Account Number (System Local yy-mm-dd-nnnnn)',
- `acc_bdt` datetime COMMENT 'Date of last account balance post',
- `acc_cdt` datetime COMMENT 'Date of account creation',
- PRIMARY KEY (`acc_id`)
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;";
- dbDelta($sql_1);
- $t2_name = $prefix.'em_account_trans';
- $sql_2 = "CREATE TABLE IF NOT EXISTS ".$t2_name." (
- `act_id` bigint(20) unsigned NOT NULL auto_increment COMMENT 'Table Index',
- `act_adx` bigint(20) unsigned NOT NULL COMMENT 'Xref to account index',
- `act_pdx` bigint(20) unsigned NOT NULL COMMENT 'Xref to person index (id of payee)',
- `act_num` varchar(14) NOT NULL COMMENT 'Account Number (System Local yy-mm-dd-nnnnn)',
- `act_bal` decimal(11,2) COMMENT 'Account Balance',
- `act_bdt` datetime COMMENT 'Date of account balance post',
- PRIMARY KEY (`act_id`)
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;";
- dbDelta($sql_2);
- $t3_name = $prefix.'em_assign';
- $sql_3 = "CREATE TABLE IF NOT EXISTS ".$t3_name." (
- `ass_id` bigint(20) unsigned NOT NULL auto_increment COMMENT 'Table Index',
- `ass_edx` bigint(20) unsigned NOT NULL COMMENT 'Xref to event index',
- `ass_rdx` bigint(20) unsigned NOT NULL COMMENT 'Xref to room index',
- `ass_tdx` bigint(20) unsigned NOT NULL COMMENT 'Xref to ticket index',
- `ass_pdx` bigint(20) unsigned NOT NULL COMMENT 'Xref to person/atendee index',
- `ass_pky` bigint(20) unsigned NOT NULL COMMENT 'Xref to product id key',
- `ass_pdt` datetime COMMENT 'Date of attendee sign up',
- `ass_edt` datetime COMMENT 'Date of event assigment/reservation',
- PRIMARY KEY (`ass_id`)
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
- dbDelta($sql_3);
- $t4_name = $prefix.'em_fee_schedule';
- $sql_4 = "CREATE TABLE IF NOT EXISTS ".$t4_name." (
- `sched_id` bigint(20) unsigned NOT NULL auto_increment COMMENT 'Table Index',
- `sched_type` varchar(1) NOT NULL COMMENT 'F=Facility Fee A=Atendee Fee',
- `sched_name` tinytext NOT NULL COMMENT 'Fee Schedule Name',
- `sched_description` text COMMENT 'Fee Schedule Description',
- PRIMARY KEY (`sched_id`)
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
- dbDelta($sql_4);
- $t5_name = $prefix.'em_multi_role';
- $sql_5 = "CREATE TABLE IF NOT EXISTS ".$t5_name." (
- `role_id` bigint(20) unsigned NOT NULL auto_increment,
- `role_a` binary default true COMMENT 'Attendee Role',
- `role_c` binary default false COMMENT 'Creator Role',
- `role_s` binary default false COMMENT 'Sponsor Role',
- `role_t` binary default false COMMENT 'Teacher Role',
- PRIMARY KEY (`role_id`)
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
- dbDelta($sql_5);
- $t6_name = $prefix.'em_multi_role';
- $sql_6 = "CREATE TABLE IF NOT EXISTS ".$t6_name." (
- `room_id` bigint(20) unsigned NOT NULL auto_increment COMMENT 'Table Index',
- `room_no` int(5) NOT NULL COMMENT 'Room Number',
- `room_name` varchar(22) COMMENT 'Room Name',
- `room_desc` varchar(220) COMMENT 'Room Description',
- `room_seats` int(5) NOT NULL COMMENT 'Room Capacity/Seats',
- `room_cost` decimal(10,2) default NULL COMMENT 'Room Cost (Facility)',
- `room_scost` decimal(10,2) default NULL COMMENT 'Room Cost/Seat',
- PRIMARY KEY (`room_id`)
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
- dbDelta($sql_6);
- } // end function
- function emxt_add_menu () {
- add_submenu_page('events-manager',__('Extended Options'), 'manage_options', basename(__FILE__), 'emxt_options_page');
- //add_menu_page('WPS Poll', __('WPS Poll'),'manage_options',basename(__FILE__), 'wps_poll_options_page');
- //add_submenu_page('index.php','Extended Options', 'administrator', __FILE__, 'emxt_options_page');
- //call register settings function
- add_action( 'admin_init', 'register_mysettings' );
- } // end function
- function emxt_options_page () {
- //$display = require_once (ABSPATH . 'wp-content/plugins/events-manager-ext/templates/forms/emxt-admin-options.php');
- //echo $display;
- ?>
- <?php include (ABSPATH . 'wp-content/plugins/events-manager-ext/templates/forms/emxt-admin-options.php'); ?>
- <?php
- } // end function
- function register_mysettings() {
- //register our settings
- register_setting( 'emxt-settings-group', 'emxt_options' );
- register_setting( 'emxt-settings-group', 'room_options' );
- register_setting( 'emxt-settings-group', 'account_options' );
- } // end function
- function emxt_createpages(){
- global $wpdb,$current_user;
- if( get_option('dbem_events_page') == '' && get_option('dbem_dismiss_events_page') != 1 && !is_object( get_page( get_option('dbem_events_page') )) ){
- $post_data = array(
- 'post_status' => 'publish',
- 'post_type' => 'page',
- 'ping_status' => get_option('default_ping_status'),
- 'post_content' => 'CONTENTS',
- 'post_excerpt' => 'CONTENTS',
- 'post_title' => __('Events','dbem')
- );
- $post_id = wp_insert_post($post_data, false);
- if( $post_id > 0 ){
- update_option('dbem_events_page', $post_id);
- }
- }
- } // end function
- function em_set_capabilities(){
- //Get default roles
- global $wp_roles;
- if( get_option('dbem_version') == '' || get_option('dbem_version') < 4 ){
- //Assign caps in groups, as we go down, permissions are "looser"
- $caps = array('publish_events', 'edit_others_events', 'delete_others_events', 'edit_others_locations', 'delete_others_locations', 'manage_others_bookings', 'edit_categories');
- em_set_mass_caps( array('administrator','editor'), $caps );
- //Add all the open caps
- $users = array('administrator','editor');
- $caps = array('edit_events', 'edit_locations', 'delete_events', 'manage_bookings', 'delete_locations', 'edit_recurrences', 'read_others_locations');
- em_set_mass_caps( array('administrator','editor'), $caps );
- if( get_option('dbem_version') == '' ){ //so pre v4 doesn't get security loopholes
- em_set_mass_caps(array('contributor','author','subscriber'), $caps);
- }
- }
- } // end function
- ?>
- <?php
- /*
- function em_add_options() {
- $contact_person_email_body_localizable = __("#_BOOKINGNAME (#_BOOKINGEMAIL) will attend #_NAME on #F #j, #Y. He wants to reserve #_BOOKINGSPACES spaces.<br/> Now there are #_BOOKEDSPACES spaces reserved, #_AVAILABLESPACES are still available.<br/>Yours faithfully,<br/>Events Manager - http://wp-events-plugin.com",'dbem').__('<br/><br/>-------------------------------<br/>Powered by Events Manager - http://wp-events-plugin.com','dbem');
- $contact_person_email_cancelled_body_localizable = __("#_BOOKINGNAME (#_BOOKINGEMAIL) cancelled his booking at #_NAME on #F #j, #Y. He wanted to reserve #_BOOKINGSPACES spaces.<br/> Now there are #_BOOKEDSPACES spaces reserved, #_AVAILABLESPACES are still available.<br/>Yours faithfully,<br/>Events Manager - http://wp-events-plugin.com",'dbem').__('<br/><br/>-------------------------------<br/>Powered by Events Manager - http://wp-events-plugin.com','dbem');
- $respondent_email_body_localizable = __("Dear #_BOOKINGNAME, <br/>you have successfully reserved #_BOOKINGSPACES space/spaces for #_NAME.<br/>Yours faithfully,<br/>#_CONTACTNAME",'dbem').__('<br/><br/>-------------------------------<br/>Powered by Events Manager - http://wp-events-plugin.com','dbem');
- $respondent_email_pending_body_localizable = __("Dear #_BOOKINGNAME, <br/>You have requested #_BOOKINGSPACES space/spaces for #_NAME.<br/>Your booking is currently pending approval by our administrators. Once approved you will receive an automatic confirmation.<br/>Yours faithfully,<br/>#_CONTACTNAME",'dbem').__('<br/><br/>-------------------------------<br/>Powered by Events Manager - http://wp-events-plugin.com','dbem');
- $respondent_email_rejected_body_localizable = __("Dear #_BOOKINGNAME, <br/>Your requested booking for #_BOOKINGSPACES spaces at #_NAME on #F #j, #Y has been rejected.<br/>Yours faithfully,<br/>#_CONTACTNAME",'dbem').__('<br/><br/>-------------------------------<br/>Powered by Events Manager - http://wp-events-plugin.com','dbem');
- $respondent_email_cancelled_body_localizable = __("Dear #_BOOKINGNAME, <br/>Your requested booking for #_BOOKINGSPACES spaces at #_NAME on #F #j, #Y has been cancelled.<br/>Yours faithfully,<br/>#_CONTACTNAME",'dbem').__('<br/><br/>-------------------------------<br/>Powered by Events Manager - http://wp-events-plugin.com','dbem');
- $event_approved_email_body = __("Dear #_CONTACTNAME, <br/>Your event #_NAME on #F #j, #Y has been approved.<br/>You can view your event here: #_EVENTURL",'dbem').__('<br/><br/>-------------------------------<br/>Powered by Events Manager - http://wp-events-plugin.com','dbem');
- $dbem_options = array(
- //defaults
- 'dbem_default_category'=>0,
- 'dbem_default_location'=>0,
- //Event List Options
- 'dbem_events_default_orderby' => 'start_date,start_time,name',
- 'dbem_events_default_order' => 'ASC',
- 'dbem_events_default_limit' => 10,
- 'dbem_list_events_page' => 1,
- //Event Anonymous submissions
- 'dbem_events_anonymous_submissions' => 0,
- 'dbem_events_anonymous_user' => 0,
- 'dbem_events_anonymous_result_success' => 'You have successfully submitted your event, which will be published pending approval.',
- //Event Emails
- 'dbem_event_approved_email_subject' => __("Event Approved",'dbem'). " - #_NAME" ,
- 'dbem_event_approved_email_body' => str_replace("<br/>", "\n\r", $event_approved_email_body),
- //Event Formatting
- 'dbem_events_page_title' => __('Events','dbem'),
- 'dbem_events_page_scope' => 'future',
- 'dbem_events_page_search' => 1,
- 'dbem_event_list_item_format_header' => '<table cellpadding="0" cellspacing="0" id="current-events" >
- <thead>
- <tr>
- <th id="event-time" width="150">Date/Time</th>
- <th id="event-description" width="*">Event</th>
- </thead>
- <tbody>',
- 'dbem_event_list_item_format' => '<tr>
- <td>
- #_{d/m/Y} #@_{- d/m/Y}<br/>
- #H:#i -#@H:#@i
- </td>
- <td>
- #_EVENTLINK<br/>
- <i>#_LOCATIONNAME, #_LOCATIONTOWN #_LOCATIONSTATE</i>
- </td>
- </tr>',
- 'dbem_event_list_item_format_footer' => '</tbody></table>',
- 'dbem_display_calendar_in_events_page' => 0,
- 'dbem_single_event_format' => '<div style="float:right; margin:0px 0px 15px 15px;">#_MAP</div>
- <p>
- <strong>Date/Time</strong><br/>
- Date(s) - #j #M #Y #@_{ \u\n\t\i\l j M Y}<br />
- <i>#_12HSTARTTIME - #_12HENDTIME</i>
- </p>
- <p>
- <strong>Location</strong><br/>
- #_LOCATIONLINK
- </p>
- <p>
- <strong>Category(ies)</strong>
- #_CATEGORIES
- </p>
- <br style="clear:both" />
- #_NOTES
- {has_bookings}
- <h3>Bookings</h3>
- #_BOOKINGFORM
- {/has_bookings}',
- 'dbem_event_page_title_format' => '#_NAME',
- 'dbem_no_events_message' => sprintf(__( 'No %s', 'dbem' ),__('Events','dbem')),
- //Location Formatting
- 'dbem_locations_default_orderby' => 'name',
- 'dbem_locations_default_order' => 'ASC',
- 'dbem_locations_page_title' => __('Event','dbem')." ".__('Locations','dbem'),
- 'dbem_no_locations_message' => sprintf(__( 'No %s', 'dbem' ),__('Locations','dbem')),
- 'dbem_location_default_country' => 'US',
- 'dbem_location_list_item_format' => '#_LOCATIONLINK<ul><li>#_ADDRESS, #_LOCATIONTOWN, #_LOCATIONSTATE</li></ul>',
- 'dbem_location_page_title_format' => '#_LOCATIONNAME',
- 'dbem_single_location_format' => '<div style="float:right; margin:0px 0px 15px 15px;">#_MAP</div>
- <p>
- <strong>Address</strong><br/>
- #_LOCATIONADDRESS<br/>
- #_LOCATIONTOWN<br/>
- #_LOCATIONSTATE<br/>
- #_LOCATIONREGION<br/>
- #_LOCATIONPOSTCODE<br/>
- #_LOCATIONCOUNTRY
- </p>
- <br style="clear:both" />
- #_DESCRIPTION
- <h3>Upcoming Events</h3>
- <p>#_NEXTEVENTS</p>',
- 'dbem_location_no_events_message' => __('<li>No events in this location</li>', 'dbem'),
- 'dbem_location_event_list_item_format' => "<li>#_EVENTLINK - #j #M #Y - #H:#i</li>",
- //Category Formatting
- 'dbem_category_page_title_format' => '#_CATEGORYNAME',
- 'dbem_category_page_format' => '<p>#_CATEGORYNAME</p>#_CATEGORYNOTES<h3>Upcoming Events</h3>#_CATEGORYNEXTEVENTS',
- 'dbem_categories_page_title' => __('Event','dbem')." ".__('Categories','dbem'),
- 'dbem_categories_list_item_format' => '<li>#_CATEGORYLINK</li>',
- 'dbem_no_categories_message' => sprintf(__( 'No %s', 'dbem' ),__('Categories','dbem')),
- 'dbem_categories_default_orderby' => 'name',
- 'dbem_categories_default_order' => 'ASC',
- 'dbem_category_no_events_message' => __('<li>No events in this category</li>', 'dbem'),
- 'dbem_category_event_list_item_format' => "<li>#_EVENTLINK - #j #M #Y - #H:#i</li>",
- //RSS Stuff
- 'dbem_rss_limit' => 10,
- 'dbem_rss_scope' => 'future',
- 'dbem_rss_main_title' => get_bloginfo('title')." - ".__('Events', 'dbem'),
- 'dbem_rss_main_description' => get_bloginfo('description')." - ".__('Events', 'dbem'),
- 'dbem_rss_description_format' => "#j #M #y - #H:#i <br/>#_LOCATION <br/>#_LOCATIONADDRESS <br/>#_LOCATIONTOWN",
- 'dbem_rss_title_format' => "#_NAME",
- //iCal Stuff
- 'dbem_ical_limit' => 0,
- 'dbem_ical_description_format' => "#_NAME - #_LOCATIONNAME - #j #M #y #H:#i",
- //Google Maps
- 'dbem_gmap_is_active'=> 1,
- 'dbem_location_baloon_format' => "<strong>#_LOCATIONNAME</strong><br/>#_LOCATIONADDRESS - #_LOCATIONTOWN<br/><a href='#_LOCATIONPAGEURL'>Details</a>",
- 'dbem_map_text_format' => '<strong>#_LOCATION</strong><p>#_LOCATIONADDRESS</p><p>#_LOCATIONTOWN</p>',
- //Email Config
- 'dbem_email_disable_registration' => 0,
- 'dbem_rsvp_mail_port' => 465,
- 'dbem_smtp_host' => 'localhost',
- 'dbem_mail_sender_name' => '',
- 'dbem_rsvp_mail_send_method' => 'mail',
- 'dbem_rsvp_mail_SMTPAuth' => 1,
- //Image Manipulation
- 'dbem_image_max_width' => 700,
- 'dbem_image_max_height' => 700,
- 'dbem_image_max_size' => 204800,
- //Calendar Options
- 'dbem_list_date_title' => __('Events', 'dbem').' - #j #M #y',
- 'dbem_full_calendar_event_format' => '<li>#_EVENTLINK</li>',
- 'dbem_full_calendar_long_events' => '0',
- 'dbem_small_calendar_event_title_format' => "#_NAME",
- 'dbem_small_calendar_event_title_separator' => ", ",
- //General Settings
- 'dbem_use_select_for_locations' => 0,
- 'dbem_attributes_enabled' => 1,
- 'dbem_recurrence_enabled'=> 1,
- 'dbem_rsvp_enabled'=> 1,
- 'dbem_categories_enabled'=> 1,
- 'dbem_placeholders_custom' => '',
- //Title rewriting compatability
- 'dbem_disable_title_rewrites'=> false,
- 'dbem_title_html' => '<h2>#_PAGETITLE</h2>',
- //Bookings
- 'dbem_bookings_form_max' => 20,
- 'dbem_bookings_registration_disable' => 0,
- 'dbem_bookings_registration_user' => '',
- 'dbem_bookings_anonymous' => 1,
- 'dbem_bookings_approval' => 1, //approval is on by default
- 'dbem_bookings_approval_reserved' => 0, //overbooking before approval?
- 'dbem_bookings_login_form' => 1, //show login form on booking area
- 'dbem_bookings_approval_overbooking' => 0, //overbooking possible when approving?
- 'dbem_bookings_double'=>0,//double bookings or more, users can't double book by default
- 'dbem_bookings_user_cancellation' => 1, //can users cancel their booking?
- 'dbem_bookings_tax' => 0, //extra tax
- 'dbem_bookings_tax_auto_add' => 0, //adjust prices to show tax?
- //messages
- 'dbem_booking_feedback_pending' =>__('Booking successful, pending confirmation (you will also receive an email once confirmed).', 'dbem'),
- 'dbem_booking_feedback' => __('Booking successful.', 'dbem'),
- 'dbem_booking_feedback_full' => __('Booking cannot be made, not enough spaces available!', 'dbem'),
- 'dbem_booking_feedback_log_in' => __('You must log in or register to make a booking.','dbem'),
- 'dbem_booking_feedback_nomail' => __('However, there were some problems whilst sending confirmation emails to you and/or the event contact person. You may want to contact them directly and letting them know of this error.', 'dbem'),
- 'dbem_booking_feedback_error' => __('Booking could not be created','dbem').':',
- 'dbem_booking_feedback_email_exists' => __('This email already exists in our system, please log in to register to proceed with your booking.','dbem'),
- 'dbem_booking_feedback_new_user' => __('A new user account has been created for you. Please check your email for access details.','dbem'),
- 'dbem_booking_feedback_reg_error' => __('There was a problem creating a user account, please contact a website administrator.','dbem'),
- 'dbem_booking_feedback_already_booked' => __('You already have booked a seat at this event.','dbem'),
- 'dbem_booking_feedback_min_space' => __('You must request at least one space to book an event.','dbem'),
- //Emails
- 'dbem_default_contact_person' => 1, //admin
- 'dbem_bookings_notify_admin' => 0,
- 'dbem_bookings_contact_email' => 1,
- 'dbem_bookings_contact_email_subject' => __("New booking",'dbem'),
- 'dbem_bookings_contact_email_body' => str_replace("<br/>", "\n\r", $contact_person_email_body_localizable),
- 'dbem_contactperson_email_cancelled_subject' => __("Booking Cancelled",'dbem'),
- 'dbem_contactperson_email_cancelled_body' => str_replace("<br/>", "\n\r", $contact_person_email_cancelled_body_localizable),
- 'dbem_bookings_email_pending_subject' => __("Booking Pending",'dbem'),
- 'dbem_bookings_email_pending_body' => str_replace("<br/>", "\n\r", $respondent_email_pending_body_localizable),
- 'dbem_bookings_email_rejected_subject' => __("Booking Rejected",'dbem'),
- 'dbem_bookings_email_rejected_body' => str_replace("<br/>", "\n\r", $respondent_email_rejected_body_localizable),
- 'dbem_bookings_email_confirmed_subject' => __('Booking Confirmed','dbem'),
- 'dbem_bookings_email_confirmed_body' => str_replace("<br/>", "\n\r", $respondent_email_body_localizable),
- 'dbem_bookings_email_cancelled_subject' => __('Booking Cancelled','dbem'),
- 'dbem_bookings_email_cancelled_body' => str_replace("<br/>", "\n\r", $respondent_email_cancelled_body_localizable),
- //Bookings Form - beta - not working at all yet
- 'dbem_bookings_page' => '<p>Date/Time - #j #M #Y #_12HSTARTTIME #@_{ \u\n\t\i\l j M Y}<br />Where - #_LOCATIONLINK</p>#_EXCERPT #_BOOKINGFORM<p>'.__('Powered by','dbem').'<a href="http://wp-events-plugin.com">events manager</a></p>',
- 'dbem_bookings_page_title' => __('Bookings - #_NAME','dbem'),
- //Ticket Specific Options
- 'dbem_bookings_tickets_orderby' => 'ticket_price DESC, ticket_name ASC',
- 'dbem_bookings_tickets_priority' => 0,
- 'dbem_bookings_tickets_show_unavailable' => 0,
- 'dbem_bookings_tickets_show_loggedout' => 1,
- 'dbem_bookings_tickets_single' => 0,
- 'dbem_bookings_tickets_single_form' => 0,
- //My Bookings Page
- 'dbem_bookings_my_title_format' => __('My Bookings','dbem'),
- //Flags
- 'dbem_hello_to_user' => 1,
- //BP Settings
- 'dbem_bp_events_list_format_header' => '<ul class="em-events-list">',
- 'dbem_bp_events_list_format' => '<li>#_EVENTLINK - #j #M #Y #_12HSTARTTIME #@_{ \u\n\t\i\l j M Y}<ul><li>#_LOCATIONLINK - #_LOCATIONADDRESS, #_LOCATIONTOWN</li></ul></li>',
- 'dbem_bp_events_list_format_footer' => '</ul>',
- 'dbem_bp_events_list_none_format' => '<p class="em-events-list">'.__('No Events','dbem').'</p>'
- );
- foreach($dbem_options as $key => $value){
- add_option($key, $value);
- }
- if( !get_option('dbem_version') ){ add_option('dbem_credits',1); }
- if( get_option('dbem_version') < 4.16 ){
- update_option('dbem_ical_limit',0); //fix, would rather do this than change the option name.
- update_option('dbem_category_no_events_message',get_option('dbem_location_no_events_message'));
- update_option('dbem_category_event_list_item_format',get_option('dbem_location_event_list_item_format'));
- }
- if( get_option('dbem_version') < 4.18 ){
- if( get_option('dbem_category_page_format') == '<p>#_CATEGORYNAME</p>#_CATEGORYNOTES<div><h3>Upcoming Events</h3>#_CATEGORYNEXTEVENTS' ){
- update_option('dbem_category_page_format',$dbem_options['dbem_category_page_format']);
- }
- }
- }
- function em_set_mass_caps( $roles, $caps ){
- global $wp_roles;
- foreach( $roles as $user_role ){
- foreach($caps as $cap){
- $wp_roles->add_cap($user_role, $cap);
- }
- }
- }
- // migrate old dbem tables to new em ones
- function em_migrate_v3(){
- global $wpdb, $current_user;
- get_currentuserinfo();
- $errors = array();
- //approve all old events
- $wpdb->query('UPDATE '.EM_EVENTS_TABLE.' SET event_status=1');
- //give all old events a default ticket
- $wpdb->query('TRUNCATE TABLE '.EM_TICKETS_TABLE);
- $wpdb->query("INSERT INTO ".EM_TICKETS_TABLE." (`event_id`, `ticket_name`, `ticket_spaces`) SELECT event_id, 'Standard' as ticket_name, event_spaces FROM ".EM_EVENTS_TABLE." WHERE recurrence!=1 and event_rsvp=1");
- //create permalinks for each location, category, event
- $array = array('event' => EM_EVENTS_TABLE, 'location' => EM_LOCATIONS_TABLE, 'category' => EM_CATEGORIES_TABLE);
- foreach( $array as $prefix => $table ){
- $used_slugs = array();
- $results = $wpdb->get_results("SELECT {$prefix}_id AS id, {$prefix}_slug AS slug, {$prefix}_name AS name FROM $table", ARRAY_A);
- foreach($results as $row){
- $slug = sanitize_title($row['name']);
- $count = 2;
- while( in_array($slug, $used_slugs) ){
- $slug = preg_replace('/\-[0-9]+$/', '', $slug).'-'.$count;
- $count++;
- }
- $wpdb->query("UPDATE $table SET {$prefix}_slug='$slug' WHERE {$prefix}_id={$row['id']}");
- $used_slugs[] = $slug;
- }
- }
- //categories
- $wpdb->query('DELETE FROM '.EM_META_TABLE." WHERE meta_key='event-category'");
- $wpdb->query('INSERT INTO '.EM_META_TABLE." (`meta_key`,`meta_value`,`object_id`) SELECT 'event-category' as meta_key, event_category_id, event_id FROM ".EM_EVENTS_TABLE ." WHERE recurrence!=1 AND event_category_id IS NOT NULL");
- update_option('em_notice_migrate_v3',1);
- //change some old values so it doesn't surprise admins with new features
- update_option('dbem_events_page_search', 0);
- $time_limit = get_option('dbem_events_page_time_limit');
- if ( is_numeric($time_limit) && $time_limit > 0 ){
- $scopes = em_get_scopes();
- if( array_key_exists($time_limit.'-months',$scopes) ){
- update_option('dbem_events_page_scope',$time_limit.'-months');
- }elseif( array_key_exists('month',$scopes) ){
- update_option('dbem_events_page_scope','month');
- }else{
- update_option('dbem_events_page_scope','future');
- }
- }
- }
- function em_migrate_bookings(){
- global $wpdb;
- if( $wpdb->get_var("SHOW TABLES LIKE '".EM_PEOPLE_TABLE."'") == EM_PEOPLE_TABLE && current_user_can('activate_plugins') && wp_verify_nonce($_REQUEST['_wpnonce'], 'bookings_migrate') ){
- $new_people = array();
- $ticket_bookings = array();
- $errors = array();
- foreach( $wpdb->get_results("SELECT ticket_id, b.booking_id, booking_spaces, b.person_id, person_name, person_email, person_phone FROM ".EM_BOOKINGS_TABLE." b LEFT JOIN ".EM_PEOPLE_TABLE." p ON p.person_id=b.person_id LEFT JOIN ".EM_EVENTS_TABLE." e ON e.event_id=b.event_id LEFT JOIN ".EM_TICKETS_TABLE." tt ON tt.event_id=e.event_id", ARRAY_A) as $booking_array ){
- if( $booking_array['person_email'] != ''){
- //first we create the user if we hadn't before
- $user = get_user_by_email($booking_array['person_email']);
- if( is_object($user) ){
- //User exists, whether from current insert or not, so ammend array
- $new_people[$booking_array['person_id']] = $user->ID;
- }else{
- $username_root = explode('@', $booking_array['person_email']);
- $username_rand = $username_root[0].rand(1,1000);
- while( username_exists($username_rand) ){
- $username_rand = $username_root[0].rand(1,1000);
- }
- $user_array = array(
- 'user_email' => $booking_array['person_email'],
- 'user_login' => $username_rand,
- 'first_name' => $booking_array['person_name'],
- 'display_name'=> $booking_array['person_name'],
- );
- $new_people[$booking_array['person_id']] = wp_insert_user($user_array);
- update_user_meta($new_people[$booking_array['person_id']], 'dbem_phone', $booking_array['person_phone']);
- }
- //save the booking
- if( !is_object($new_people[$booking_array['person_id']]) ){
- $ticket_bookings[] = "({$booking_array['booking_id']} , {$booking_array['ticket_id']}, {$booking_array['booking_spaces']}, '0')";
- }
- }else{
- if( !in_array('You have some bookings without a corresponding person in the database. These bookings will be deleted when you delete the people table.', $errors) ){
- $errors[] = 'You have some bookings without a corresponding person in the database. These bookings will be deleted when you delete the people table.';
- }
- }
- }
- //modify the booking to have data about the new people, we do this here to avoid duplicate names
- foreach($new_people as $old_id => $new_id){
- if( !is_object($new_id) ){
- $wpdb->query('UPDATE '.EM_BOOKINGS_TABLE." SET person_id='".$new_id."', booking_status=1 WHERE person_id='".$old_id."'");
- }elseif( get_class($new_id) == 'WP_Error' ){
- /* @var $new_id WP_Error */ /*
- $errors[] = "Person ID - $old_id : ".$new_id->get_error_message();
- }
- }
- //Finally insert all the tickets bookings
- $wpdb->query('TRUNCATE TABLE '.EM_TICKETS_BOOKINGS_TABLE); //empty tickets bookings table first
- $sql = "INSERT INTO ". EM_TICKETS_BOOKINGS_TABLE.' ( `booking_id` ,`ticket_id` ,`ticket_booking_spaces` ,`ticket_booking_price`) VALUES' . implode(',',$ticket_bookings);
- $ticket_inserts = $wpdb->query($sql);
- if($ticket_inserts === false){
- /* @var $wpdb WPDB */ /*
- $errors[] = 'DB Error when adding ticket bookings : '.$wpdb->last_error;
- }
- if( count($errors) > 0 ){
- echo "<div class='error'><p>There were some errors during the upgrade. It might be that you can ignore these errors, depending on what kind of data was on your database.</p>";
- foreach($errors as $error){
- echo "<p>$error</p>";
- }
- echo "</div>";
- }
- echo "<div class='updated'><p>Bookings have been migrated. Please verify this in the <a href='admin.php?page=events-manager-bookings'>bookings</a> and wordpress <a href='users.php'>users</a> sections (or for older bookings, access the booking info via the admin events list). If this didn't work you can try migrating again or delete the old persons database table which is not in use anymore.</p></div>";
- }
- }
- function em_migrate_bookings_delete(){
- global $wpdb;
- if( wp_verify_nonce($_REQUEST['_wpnonce'], 'bookings_migrate_delete') ){
- //REMOVE ALL NULL BOOKINGS
- $wpdb->query('DELETE FROM '.EM_BOOKINGS_TABLE." WHERE booking_id IN (SELECT b.booking_id FROM ".EM_BOOKINGS_TABLE." b LEFT JOIN ".EM_PEOPLE_TABLE." p ON p.person_id=b.person_id LEFT JOIN ".EM_EVENTS_TABLE." e ON e.event_id=b.event_id LEFT JOIN ".EM_TICKETS_TABLE." tt ON tt.event_id=e.event_id) WHERE person_email IS NULL");
- $wpdb->query('DROP TABLE '.$wpdb->prefix.'em_people');
- echo "<div class='updated'><p>Old People table deleted, enjoy Events Manager 4!</p></div>";
- }
- }
- */
- ?> $wpdb->query('UPDATE '.EM_BOOKINGS_TABLE." SET person_id='".$new_id."', booking_status=1 WHERE person_id='".$old_id."'");
- }elseif( get_class($new_id) == 'WP_Error' ){
- /* @var $new_id WP_Error */ /*
- $errors[] = "Person ID - $old_id : ".$new_id->get_error_message();
- }
- }
- //Finally insert all the tickets bookings
- $wpdb->query('TRUNCATE TABLE '.EM_TICKETS_BOOKINGS_TABLE); //empty tickets bookings table first
- $sql = "INSERT INTO ". EM_TICKETS_BOOKINGS_TABLE.' ( `booking_id` ,`ticket_id` ,`ticket_booking_spaces` ,`ticket_booking_price`) VALUES' . implode(',',$ticket_bookings);
- $ticket_inserts = $wpdb->query($sql);
- if($ticket_inserts === false){
- /* @var $wpdb WPDB */ /*
- $errors[] = 'DB Error when adding ticket bookings : '.$wpdb->last_error;
- }
- if( count($errors) > 0 ){
- echo "<div class='error'><p>There were some errors during the upgrade. It might be that you can ignore these errors, depending on what kind of data was on your database.</p>";
- foreach($errors as $error){
- echo "<p>$error</p>";
- }
- echo "</div>";
- }
- echo "<div class='updated'><p>Bookings have been migrated. Please verify this in the <a href='admin.php?page=events-manager-bookings'>bookings</a> and wordpress <a href='users.php'>users</a> sections (or for older bookings, access the booking info via the admin events list). If this didn't work you can try migrating again or delete the old persons database table which is not in use anymore.</p></div>";
- }
- }
- function em_migrate_bookings_delete(){
- global $wpdb;
- if( wp_verify_nonce($_REQUEST['_wpnonce'], 'bookings_migrate_delete') ){
- //REMOVE ALL NULL BOOKINGS
- $wpdb->query('DELETE FROM '.EM_BOOKINGS_TABLE." WHERE booking_id IN (SELECT b.booking_id FROM ".EM_BOOKINGS_TABLE." b LEFT JOIN ".EM_PEOPLE_TABLE." p ON p.person_id=b.person_id LEFT JOIN ".EM_EVENTS_TABLE." e ON e.event_id=b.event_id LEFT JOIN ".EM_TICKETS_TABLE." tt ON tt.event_id=e.event_id) WHERE person_email IS NULL");
- $wpdb->query('DROP TABLE '.$wpdb->prefix.'em_people');
- echo "<div class='updated'><p>Old People table deleted, enjoy Events Manager 4!</p></div>";
- }
- }
- */
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement