Advertisement
TBotNik

Extension Files

Nov 16th, 2011
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.19 KB | None | 0 0
  1. Base file: events-manager-extened.php
  2.  
  3. <?php
  4. /***************************************************************************/
  5. /* Plugin Name: Events Manager Extended */
  6. /* Plugin URI: http://wp-events-plugin.com */
  7. /* Description: This plugin extends the standard events manager plugin */
  8. /* to allow for multiple rooms/classrooms where classes */
  9. /* and/or events can be held and allows for rental of the */
  10. /* rooms, setting of fee/rental schedule for the rooms and */
  11. /* setting of fees to the attendee, with payment account */
  12. /* for the class/event creator. */
  13. /* File: events-manager-extened.php Path: ../wp-content/plugins */
  14. /* /events-manager-ext */
  15. /* Author: Nyle E. Davis Create Date: 10/25/11 */
  16. /* Author URI: http://technopool.wordpress.com */
  17. /* Version: 1.0 Copyright (C): 2011 WebPrimacy */
  18. /* License: GPL2 */
  19. /***************************************************************************/
  20.  
  21. define('EMXT_VERSION', 1.0);
  22. define('EMXT_SLUG', plugin_basename( __FILE__ ));
  23. include ('classes/emxt-class.php');
  24.  
  25. //Add translation
  26. load_plugin_textdomain('emxt', false, dirname( plugin_basename( __FILE__ ) ).'/langs');
  27.  
  28. // Get system DIR vars
  29. define('EMXT_DIR', dirname( __FILE__ )); //an absolute path to this directory
  30.  
  31. // Set path to forms
  32. $hom_dir = EMXT_DIR;
  33. $adm_dir = EMXT_DIR . '/admin/';
  34. $frm_dir = EMXT_DIR . '/templates/forms/';
  35.  
  36. // Set path to main EM dir
  37. $rot_pos = strpos(EMXT_DIR, '/event');
  38. $rot_dir = substr(EMXT_DIR,0,$rot_pos+1);
  39. $mem_dir = $rot_dir.'events-manager/';
  40. //echo "M=> $mem_dir <= <br>";
  41.  
  42. // Set functions path
  43. global $wpdb;
  44. if ( get_site_option('dbem_ms_global_table') ){
  45. $prefix = $wpdb->base_prefix;
  46. } else {
  47. $prefix = $wpdb->prefix;
  48. } // end if get_site_option
  49. // Define the new forms
  50. define('EMXT_OPTIONS_FORM', $frm_dir.'emxt-admin-optform.php'); //FORM NAME
  51. define('EMXT_FEES_FORM',$frm_dir.'emxt-admin-fees.php'); //FORM NAME
  52. define('EMXT_ROOMS_FORM', $frm_dir.'emxt-admin-rooms.php'); //FORM NAME
  53. define('EMXT_CREATE_FORM', $frm_dir.'emxt-create.php'); //FORM NAME
  54. define('EMXT_EDIT_FORM',$frm_dir.'emxt-editor.php'); //FORM NAME
  55. define('EMXT_GUEST_FORM',$frm_dir.'emxt-editor-guest.php'); //FORM NAME
  56. define('EMXT_MIN_CAPABILITY', $prefix.'edit_events'); // Minimum user level to add events
  57. define('EMXT_EDITOR_CAPABILITY',$prefix. 'publish_events'); // Minimum user level to access calendars
  58. define('EMXT_SETTING_CAPABILITY', $prefix.'activate_plugins'); // Minimum user level to edit settings in EM
  59.  
  60. //Include admin files if needed
  61. if (is_admin()){
  62. //include_once('em-pro-admin.php');
  63. //include_once($adm_dir.'emxt-admin-options.php'); //updateadmin page
  64. include_once('emxt-updates.php'); //update manager
  65. }
  66.  
  67. /* Creating the tables to store extended data*/
  68. function emxt_activate() {
  69. global $wp_rewrite;
  70. $wp_rewrite->flush_rules();
  71. }
  72. register_activation_hook( __FILE__,'emxt_activate');
  73.  
  74. // Start plugin
  75. global $EM_Ext;
  76. $EM_Ext = new EM_Ext();
  77.  
  78. ?>
  79.  
  80. Install file: emxt-install.php
  81.  
  82. <?php
  83. /***************************************************************************/
  84. /* File: emxt-install.php Path: ../wp-content/plugins */
  85. /* /events-manager */
  86. /* Author: unknown Create Date: unknown */
  87. /* Mod by: Nyle E. Davis Mod Date: 10/25/11 */
  88. /* Purpose: This file is the file/page for creation of an event/class t */
  89. /* allow the teacher/event creator to define his/her event/cla */
  90. /* set the fees and enter the description of the class for disay */
  91. /* to the calendar, etc. */
  92. /* Mod: The file was modified to clean up appreance, change ticketi, */
  93. /* set fees, pay for and reserve facilities. */
  94. /***************************************************************************/
  95.  
  96. function emxt_install() {
  97. global $wp_rewrite;
  98. $wp_rewrite->flush_rules();
  99. $old_version = get_option('dbem_version');
  100. if ( $old_version != '' && $old_version < 3.096 ){
  101. function em_update_required_notification(){
  102. global $EM_Booking;
  103. ?><div class="error"><p><strong>Events Manager upgrade not complete,
  104. please upgrade to the version 3.0.96 or higher first from
  105. <a href="http://wordpress.org/extend/plugins/events-manager/download/">here</a>
  106. first before upgrading to this version.
  107. <a href="http://wp-events-plugin.com/news/upgrade-issues-screencast-walkthrough/">We
  108. made a screencast</a> to help you out.</strong></p></div>
  109. <?php
  110. } // end function
  111. add_action ( 'admin_notices', 'em_update_required_notification' );
  112. return;
  113. } // end if $old_version
  114. // Create the tables
  115. emxt_create_tables();
  116. emxt_add_menu ();
  117. add_action ('admin_menu','emxt_add_menu');
  118. // emxt_set_capabilities();
  119. emxt_createpages();
  120. update_option('dbemxt_version', EMXT_VERSION);
  121. } // end function
  122.  
  123. function emxt_create_tables() {
  124. global $wpdb;
  125. require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
  126. if ( get_site_option('dbem_ms_global_table') ){
  127. $prefix = $wpdb->base_prefix;
  128. } else {
  129. $prefix = $wpdb->prefix;
  130. } // end if get_site_option
  131. $t1_name = $prefix.'em_accounts';
  132. $sql_1 = "CREATE TABLE IF NOT EXISTS ".$t1_name." (
  133. `acc_id` bigint(20) unsigned NOT NULL auto_increment COMMENT 'Table Index',
  134. `acc_cdx` bigint(20) unsigned NOT NULL COMMENT 'Xref to event creator index (users table)',
  135. `acc_rdx` bigint(20) unsigned NOT NULL COMMENT 'Xref to role index (Must be role_t)',
  136. `acc_num` varchar(14) NOT NULL COMMENT 'Account Number (System Local yy-mm-dd-nnnnn)',
  137. `acc_bdt` datetime COMMENT 'Date of last account balance post',
  138. `acc_cdt` datetime COMMENT 'Date of account creation',
  139. PRIMARY KEY (`acc_id`)
  140. ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;";
  141. dbDelta($sql_1);
  142. $t2_name = $prefix.'em_account_trans';
  143. $sql_2 = "CREATE TABLE IF NOT EXISTS ".$t2_name." (
  144. `act_id` bigint(20) unsigned NOT NULL auto_increment COMMENT 'Table Index',
  145. `act_adx` bigint(20) unsigned NOT NULL COMMENT 'Xref to account index',
  146. `act_pdx` bigint(20) unsigned NOT NULL COMMENT 'Xref to person index (id of payee)',
  147. `act_num` varchar(14) NOT NULL COMMENT 'Account Number (System Local yy-mm-dd-nnnnn)',
  148. `act_bal` decimal(11,2) COMMENT 'Account Balance',
  149. `act_bdt` datetime COMMENT 'Date of account balance post',
  150. PRIMARY KEY (`act_id`)
  151. ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;";
  152. dbDelta($sql_2);
  153. $t3_name = $prefix.'em_assign';
  154. $sql_3 = "CREATE TABLE IF NOT EXISTS ".$t3_name." (
  155. `ass_id` bigint(20) unsigned NOT NULL auto_increment COMMENT 'Table Index',
  156. `ass_edx` bigint(20) unsigned NOT NULL COMMENT 'Xref to event index',
  157. `ass_rdx` bigint(20) unsigned NOT NULL COMMENT 'Xref to room index',
  158. `ass_tdx` bigint(20) unsigned NOT NULL COMMENT 'Xref to ticket index',
  159. `ass_pdx` bigint(20) unsigned NOT NULL COMMENT 'Xref to person/atendee index',
  160. `ass_pky` bigint(20) unsigned NOT NULL COMMENT 'Xref to product id key',
  161. `ass_pdt` datetime COMMENT 'Date of attendee sign up',
  162. `ass_edt` datetime COMMENT 'Date of event assigment/reservation',
  163. PRIMARY KEY (`ass_id`)
  164. ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
  165. dbDelta($sql_3);
  166. $t4_name = $prefix.'em_fee_schedule';
  167. $sql_4 = "CREATE TABLE IF NOT EXISTS ".$t4_name." (
  168. `sched_id` bigint(20) unsigned NOT NULL auto_increment COMMENT 'Table Index',
  169. `sched_type` varchar(1) NOT NULL COMMENT 'F=Facility Fee A=Atendee Fee',
  170. `sched_name` tinytext NOT NULL COMMENT 'Fee Schedule Name',
  171. `sched_description` text COMMENT 'Fee Schedule Description',
  172. PRIMARY KEY (`sched_id`)
  173. ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
  174. dbDelta($sql_4);
  175. $t5_name = $prefix.'em_multi_role';
  176. $sql_5 = "CREATE TABLE IF NOT EXISTS ".$t5_name." (
  177. `role_id` bigint(20) unsigned NOT NULL auto_increment,
  178. `role_a` binary default true COMMENT 'Attendee Role',
  179. `role_c` binary default false COMMENT 'Creator Role',
  180. `role_s` binary default false COMMENT 'Sponsor Role',
  181. `role_t` binary default false COMMENT 'Teacher Role',
  182. PRIMARY KEY (`role_id`)
  183. ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
  184. dbDelta($sql_5);
  185. $t6_name = $prefix.'em_multi_role';
  186. $sql_6 = "CREATE TABLE IF NOT EXISTS ".$t6_name." (
  187. `room_id` bigint(20) unsigned NOT NULL auto_increment COMMENT 'Table Index',
  188. `room_no` int(5) NOT NULL COMMENT 'Room Number',
  189. `room_name` varchar(22) COMMENT 'Room Name',
  190. `room_desc` varchar(220) COMMENT 'Room Description',
  191. `room_seats` int(5) NOT NULL COMMENT 'Room Capacity/Seats',
  192. `room_cost` decimal(10,2) default NULL COMMENT 'Room Cost (Facility)',
  193. `room_scost` decimal(10,2) default NULL COMMENT 'Room Cost/Seat',
  194. PRIMARY KEY (`room_id`)
  195. ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
  196. dbDelta($sql_6);
  197. } // end function
  198.  
  199. function emxt_add_menu () {
  200. add_submenu_page('events-manager',__('Extended Options'), 'manage_options', basename(__FILE__), 'emxt_options_page');
  201. //add_menu_page('WPS Poll', __('WPS Poll'),'manage_options',basename(__FILE__), 'wps_poll_options_page');
  202. //add_submenu_page('index.php','Extended Options', 'administrator', __FILE__, 'emxt_options_page');
  203. //call register settings function
  204. add_action( 'admin_init', 'register_mysettings' );
  205. } // end function
  206.  
  207. function emxt_options_page () {
  208. //$display = require_once (ABSPATH . 'wp-content/plugins/events-manager-ext/templates/forms/emxt-admin-options.php');
  209. //echo $display;
  210. ?>
  211. <?php include (ABSPATH . 'wp-content/plugins/events-manager-ext/templates/forms/emxt-admin-options.php'); ?>
  212. <?php
  213. } // end function
  214.  
  215. function register_mysettings() {
  216. //register our settings
  217. register_setting( 'emxt-settings-group', 'emxt_options' );
  218. register_setting( 'emxt-settings-group', 'room_options' );
  219. register_setting( 'emxt-settings-group', 'account_options' );
  220. } // end function
  221.  
  222. function emxt_createpages(){
  223. global $wpdb,$current_user;
  224. if( get_option('dbem_events_page') == '' && get_option('dbem_dismiss_events_page') != 1 && !is_object( get_page( get_option('dbem_events_page') )) ){
  225. $post_data = array(
  226. 'post_status' => 'publish',
  227. 'post_type' => 'page',
  228. 'ping_status' => get_option('default_ping_status'),
  229. 'post_content' => 'CONTENTS',
  230. 'post_excerpt' => 'CONTENTS',
  231. 'post_title' => __('Events','dbem')
  232. );
  233. $post_id = wp_insert_post($post_data, false);
  234. if( $post_id > 0 ){
  235. update_option('dbem_events_page', $post_id);
  236. }
  237. }
  238. } // end function
  239.  
  240. function em_set_capabilities(){
  241. //Get default roles
  242. global $wp_roles;
  243. if( get_option('dbem_version') == '' || get_option('dbem_version') < 4 ){
  244. //Assign caps in groups, as we go down, permissions are "looser"
  245. $caps = array('publish_events', 'edit_others_events', 'delete_others_events', 'edit_others_locations', 'delete_others_locations', 'manage_others_bookings', 'edit_categories');
  246. em_set_mass_caps( array('administrator','editor'), $caps );
  247.  
  248. //Add all the open caps
  249. $users = array('administrator','editor');
  250. $caps = array('edit_events', 'edit_locations', 'delete_events', 'manage_bookings', 'delete_locations', 'edit_recurrences', 'read_others_locations');
  251. em_set_mass_caps( array('administrator','editor'), $caps );
  252. if( get_option('dbem_version') == '' ){ //so pre v4 doesn't get security loopholes
  253. em_set_mass_caps(array('contributor','author','subscriber'), $caps);
  254. }
  255. }
  256. } // end function
  257.  
  258.  
  259. ?>
  260.  
  261.  
  262.  
  263.  
  264.  
  265. <?php
  266.  
  267. /*
  268.  
  269. function em_add_options() {
  270. $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');
  271. $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');
  272. $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');
  273. $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');
  274. $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');
  275. $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');
  276. $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');
  277.  
  278. $dbem_options = array(
  279. //defaults
  280. 'dbem_default_category'=>0,
  281. 'dbem_default_location'=>0,
  282. //Event List Options
  283. 'dbem_events_default_orderby' => 'start_date,start_time,name',
  284. 'dbem_events_default_order' => 'ASC',
  285. 'dbem_events_default_limit' => 10,
  286. 'dbem_list_events_page' => 1,
  287. //Event Anonymous submissions
  288. 'dbem_events_anonymous_submissions' => 0,
  289. 'dbem_events_anonymous_user' => 0,
  290. 'dbem_events_anonymous_result_success' => 'You have successfully submitted your event, which will be published pending approval.',
  291. //Event Emails
  292. 'dbem_event_approved_email_subject' => __("Event Approved",'dbem'). " - #_NAME" ,
  293. 'dbem_event_approved_email_body' => str_replace("<br/>", "\n\r", $event_approved_email_body),
  294. //Event Formatting
  295. 'dbem_events_page_title' => __('Events','dbem'),
  296. 'dbem_events_page_scope' => 'future',
  297. 'dbem_events_page_search' => 1,
  298. 'dbem_event_list_item_format_header' => '<table cellpadding="0" cellspacing="0" id="current-events" >
  299. <thead>
  300. <tr>
  301. <th id="event-time" width="150">Date/Time</th>
  302. <th id="event-description" width="*">Event</th>
  303. </thead>
  304. <tbody>',
  305. 'dbem_event_list_item_format' => '<tr>
  306. <td>
  307. #_{d/m/Y} #@_{- d/m/Y}<br/>
  308. #H:#i -#@H:#@i
  309. </td>
  310. <td>
  311. #_EVENTLINK<br/>
  312. <i>#_LOCATIONNAME, #_LOCATIONTOWN #_LOCATIONSTATE</i>
  313. </td>
  314. </tr>',
  315. 'dbem_event_list_item_format_footer' => '</tbody></table>',
  316. 'dbem_display_calendar_in_events_page' => 0,
  317. 'dbem_single_event_format' => '<div style="float:right; margin:0px 0px 15px 15px;">#_MAP</div>
  318. <p>
  319. <strong>Date/Time</strong><br/>
  320. Date(s) - #j #M #Y #@_{ \u\n\t\i\l j M Y}<br />
  321. <i>#_12HSTARTTIME - #_12HENDTIME</i>
  322. </p>
  323. <p>
  324. <strong>Location</strong><br/>
  325. #_LOCATIONLINK
  326. </p>
  327. <p>
  328. <strong>Category(ies)</strong>
  329. #_CATEGORIES
  330. </p>
  331. <br style="clear:both" />
  332. #_NOTES
  333. {has_bookings}
  334. <h3>Bookings</h3>
  335. #_BOOKINGFORM
  336. {/has_bookings}',
  337. 'dbem_event_page_title_format' => '#_NAME',
  338. 'dbem_no_events_message' => sprintf(__( 'No %s', 'dbem' ),__('Events','dbem')),
  339. //Location Formatting
  340. 'dbem_locations_default_orderby' => 'name',
  341. 'dbem_locations_default_order' => 'ASC',
  342. 'dbem_locations_page_title' => __('Event','dbem')." ".__('Locations','dbem'),
  343. 'dbem_no_locations_message' => sprintf(__( 'No %s', 'dbem' ),__('Locations','dbem')),
  344. 'dbem_location_default_country' => 'US',
  345. 'dbem_location_list_item_format' => '#_LOCATIONLINK<ul><li>#_ADDRESS, #_LOCATIONTOWN, #_LOCATIONSTATE</li></ul>',
  346. 'dbem_location_page_title_format' => '#_LOCATIONNAME',
  347. 'dbem_single_location_format' => '<div style="float:right; margin:0px 0px 15px 15px;">#_MAP</div>
  348. <p>
  349. <strong>Address</strong><br/>
  350. #_LOCATIONADDRESS<br/>
  351. #_LOCATIONTOWN<br/>
  352. #_LOCATIONSTATE<br/>
  353. #_LOCATIONREGION<br/>
  354. #_LOCATIONPOSTCODE<br/>
  355. #_LOCATIONCOUNTRY
  356. </p>
  357. <br style="clear:both" />
  358. #_DESCRIPTION
  359.  
  360. <h3>Upcoming Events</h3>
  361. <p>#_NEXTEVENTS</p>',
  362. 'dbem_location_no_events_message' => __('<li>No events in this location</li>', 'dbem'),
  363. 'dbem_location_event_list_item_format' => "<li>#_EVENTLINK - #j #M #Y - #H:#i</li>",
  364. //Category Formatting
  365. 'dbem_category_page_title_format' => '#_CATEGORYNAME',
  366. 'dbem_category_page_format' => '<p>#_CATEGORYNAME</p>#_CATEGORYNOTES<h3>Upcoming Events</h3>#_CATEGORYNEXTEVENTS',
  367. 'dbem_categories_page_title' => __('Event','dbem')." ".__('Categories','dbem'),
  368. 'dbem_categories_list_item_format' => '<li>#_CATEGORYLINK</li>',
  369. 'dbem_no_categories_message' => sprintf(__( 'No %s', 'dbem' ),__('Categories','dbem')),
  370. 'dbem_categories_default_orderby' => 'name',
  371. 'dbem_categories_default_order' => 'ASC',
  372. 'dbem_category_no_events_message' => __('<li>No events in this category</li>', 'dbem'),
  373. 'dbem_category_event_list_item_format' => "<li>#_EVENTLINK - #j #M #Y - #H:#i</li>",
  374. //RSS Stuff
  375. 'dbem_rss_limit' => 10,
  376. 'dbem_rss_scope' => 'future',
  377. 'dbem_rss_main_title' => get_bloginfo('title')." - ".__('Events', 'dbem'),
  378. 'dbem_rss_main_description' => get_bloginfo('description')." - ".__('Events', 'dbem'),
  379. 'dbem_rss_description_format' => "#j #M #y - #H:#i <br/>#_LOCATION <br/>#_LOCATIONADDRESS <br/>#_LOCATIONTOWN",
  380. 'dbem_rss_title_format' => "#_NAME",
  381. //iCal Stuff
  382. 'dbem_ical_limit' => 0,
  383. 'dbem_ical_description_format' => "#_NAME - #_LOCATIONNAME - #j #M #y #H:#i",
  384. //Google Maps
  385. 'dbem_gmap_is_active'=> 1,
  386. 'dbem_location_baloon_format' => "<strong>#_LOCATIONNAME</strong><br/>#_LOCATIONADDRESS - #_LOCATIONTOWN<br/><a href='#_LOCATIONPAGEURL'>Details</a>",
  387. 'dbem_map_text_format' => '<strong>#_LOCATION</strong><p>#_LOCATIONADDRESS</p><p>#_LOCATIONTOWN</p>',
  388. //Email Config
  389. 'dbem_email_disable_registration' => 0,
  390. 'dbem_rsvp_mail_port' => 465,
  391. 'dbem_smtp_host' => 'localhost',
  392. 'dbem_mail_sender_name' => '',
  393. 'dbem_rsvp_mail_send_method' => 'mail',
  394. 'dbem_rsvp_mail_SMTPAuth' => 1,
  395. //Image Manipulation
  396. 'dbem_image_max_width' => 700,
  397. 'dbem_image_max_height' => 700,
  398. 'dbem_image_max_size' => 204800,
  399. //Calendar Options
  400. 'dbem_list_date_title' => __('Events', 'dbem').' - #j #M #y',
  401. 'dbem_full_calendar_event_format' => '<li>#_EVENTLINK</li>',
  402. 'dbem_full_calendar_long_events' => '0',
  403. 'dbem_small_calendar_event_title_format' => "#_NAME",
  404. 'dbem_small_calendar_event_title_separator' => ", ",
  405. //General Settings
  406. 'dbem_use_select_for_locations' => 0,
  407. 'dbem_attributes_enabled' => 1,
  408. 'dbem_recurrence_enabled'=> 1,
  409. 'dbem_rsvp_enabled'=> 1,
  410. 'dbem_categories_enabled'=> 1,
  411. 'dbem_placeholders_custom' => '',
  412. //Title rewriting compatability
  413. 'dbem_disable_title_rewrites'=> false,
  414. 'dbem_title_html' => '<h2>#_PAGETITLE</h2>',
  415. //Bookings
  416. 'dbem_bookings_form_max' => 20,
  417. 'dbem_bookings_registration_disable' => 0,
  418. 'dbem_bookings_registration_user' => '',
  419. 'dbem_bookings_anonymous' => 1,
  420. 'dbem_bookings_approval' => 1, //approval is on by default
  421. 'dbem_bookings_approval_reserved' => 0, //overbooking before approval?
  422. 'dbem_bookings_login_form' => 1, //show login form on booking area
  423. 'dbem_bookings_approval_overbooking' => 0, //overbooking possible when approving?
  424. 'dbem_bookings_double'=>0,//double bookings or more, users can't double book by default
  425. 'dbem_bookings_user_cancellation' => 1, //can users cancel their booking?
  426. 'dbem_bookings_tax' => 0, //extra tax
  427. 'dbem_bookings_tax_auto_add' => 0, //adjust prices to show tax?
  428. //messages
  429. 'dbem_booking_feedback_pending' =>__('Booking successful, pending confirmation (you will also receive an email once confirmed).', 'dbem'),
  430. 'dbem_booking_feedback' => __('Booking successful.', 'dbem'),
  431. 'dbem_booking_feedback_full' => __('Booking cannot be made, not enough spaces available!', 'dbem'),
  432. 'dbem_booking_feedback_log_in' => __('You must log in or register to make a booking.','dbem'),
  433. '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'),
  434. 'dbem_booking_feedback_error' => __('Booking could not be created','dbem').':',
  435. 'dbem_booking_feedback_email_exists' => __('This email already exists in our system, please log in to register to proceed with your booking.','dbem'),
  436. 'dbem_booking_feedback_new_user' => __('A new user account has been created for you. Please check your email for access details.','dbem'),
  437. 'dbem_booking_feedback_reg_error' => __('There was a problem creating a user account, please contact a website administrator.','dbem'),
  438. 'dbem_booking_feedback_already_booked' => __('You already have booked a seat at this event.','dbem'),
  439. 'dbem_booking_feedback_min_space' => __('You must request at least one space to book an event.','dbem'),
  440. //Emails
  441. 'dbem_default_contact_person' => 1, //admin
  442. 'dbem_bookings_notify_admin' => 0,
  443. 'dbem_bookings_contact_email' => 1,
  444. 'dbem_bookings_contact_email_subject' => __("New booking",'dbem'),
  445. 'dbem_bookings_contact_email_body' => str_replace("<br/>", "\n\r", $contact_person_email_body_localizable),
  446. 'dbem_contactperson_email_cancelled_subject' => __("Booking Cancelled",'dbem'),
  447. 'dbem_contactperson_email_cancelled_body' => str_replace("<br/>", "\n\r", $contact_person_email_cancelled_body_localizable),
  448. 'dbem_bookings_email_pending_subject' => __("Booking Pending",'dbem'),
  449. 'dbem_bookings_email_pending_body' => str_replace("<br/>", "\n\r", $respondent_email_pending_body_localizable),
  450. 'dbem_bookings_email_rejected_subject' => __("Booking Rejected",'dbem'),
  451. 'dbem_bookings_email_rejected_body' => str_replace("<br/>", "\n\r", $respondent_email_rejected_body_localizable),
  452. 'dbem_bookings_email_confirmed_subject' => __('Booking Confirmed','dbem'),
  453. 'dbem_bookings_email_confirmed_body' => str_replace("<br/>", "\n\r", $respondent_email_body_localizable),
  454. 'dbem_bookings_email_cancelled_subject' => __('Booking Cancelled','dbem'),
  455. 'dbem_bookings_email_cancelled_body' => str_replace("<br/>", "\n\r", $respondent_email_cancelled_body_localizable),
  456. //Bookings Form - beta - not working at all yet
  457. '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>',
  458. 'dbem_bookings_page_title' => __('Bookings - #_NAME','dbem'),
  459. //Ticket Specific Options
  460. 'dbem_bookings_tickets_orderby' => 'ticket_price DESC, ticket_name ASC',
  461. 'dbem_bookings_tickets_priority' => 0,
  462. 'dbem_bookings_tickets_show_unavailable' => 0,
  463. 'dbem_bookings_tickets_show_loggedout' => 1,
  464. 'dbem_bookings_tickets_single' => 0,
  465. 'dbem_bookings_tickets_single_form' => 0,
  466. //My Bookings Page
  467. 'dbem_bookings_my_title_format' => __('My Bookings','dbem'),
  468. //Flags
  469. 'dbem_hello_to_user' => 1,
  470. //BP Settings
  471. 'dbem_bp_events_list_format_header' => '<ul class="em-events-list">',
  472. '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>',
  473. 'dbem_bp_events_list_format_footer' => '</ul>',
  474. 'dbem_bp_events_list_none_format' => '<p class="em-events-list">'.__('No Events','dbem').'</p>'
  475. );
  476.  
  477. foreach($dbem_options as $key => $value){
  478. add_option($key, $value);
  479. }
  480. if( !get_option('dbem_version') ){ add_option('dbem_credits',1); }
  481. if( get_option('dbem_version') < 4.16 ){
  482. update_option('dbem_ical_limit',0); //fix, would rather do this than change the option name.
  483. update_option('dbem_category_no_events_message',get_option('dbem_location_no_events_message'));
  484. update_option('dbem_category_event_list_item_format',get_option('dbem_location_event_list_item_format'));
  485. }
  486. if( get_option('dbem_version') < 4.18 ){
  487. if( get_option('dbem_category_page_format') == '<p>#_CATEGORYNAME</p>#_CATEGORYNOTES<div><h3>Upcoming Events</h3>#_CATEGORYNEXTEVENTS' ){
  488. update_option('dbem_category_page_format',$dbem_options['dbem_category_page_format']);
  489. }
  490. }
  491. }
  492.  
  493. function em_set_mass_caps( $roles, $caps ){
  494. global $wp_roles;
  495. foreach( $roles as $user_role ){
  496. foreach($caps as $cap){
  497. $wp_roles->add_cap($user_role, $cap);
  498. }
  499. }
  500. }
  501.  
  502. // migrate old dbem tables to new em ones
  503. function em_migrate_v3(){
  504. global $wpdb, $current_user;
  505. get_currentuserinfo();
  506. $errors = array();
  507.  
  508. //approve all old events
  509. $wpdb->query('UPDATE '.EM_EVENTS_TABLE.' SET event_status=1');
  510.  
  511. //give all old events a default ticket
  512. $wpdb->query('TRUNCATE TABLE '.EM_TICKETS_TABLE);
  513. $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");
  514.  
  515. //create permalinks for each location, category, event
  516. $array = array('event' => EM_EVENTS_TABLE, 'location' => EM_LOCATIONS_TABLE, 'category' => EM_CATEGORIES_TABLE);
  517. foreach( $array as $prefix => $table ){
  518. $used_slugs = array();
  519. $results = $wpdb->get_results("SELECT {$prefix}_id AS id, {$prefix}_slug AS slug, {$prefix}_name AS name FROM $table", ARRAY_A);
  520. foreach($results as $row){
  521. $slug = sanitize_title($row['name']);
  522. $count = 2;
  523. while( in_array($slug, $used_slugs) ){
  524. $slug = preg_replace('/\-[0-9]+$/', '', $slug).'-'.$count;
  525. $count++;
  526. }
  527. $wpdb->query("UPDATE $table SET {$prefix}_slug='$slug' WHERE {$prefix}_id={$row['id']}");
  528. $used_slugs[] = $slug;
  529. }
  530. }
  531. //categories
  532. $wpdb->query('DELETE FROM '.EM_META_TABLE." WHERE meta_key='event-category'");
  533. $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");
  534.  
  535. update_option('em_notice_migrate_v3',1);
  536. //change some old values so it doesn't surprise admins with new features
  537. update_option('dbem_events_page_search', 0);
  538.  
  539. $time_limit = get_option('dbem_events_page_time_limit');
  540. if ( is_numeric($time_limit) && $time_limit > 0 ){
  541. $scopes = em_get_scopes();
  542. if( array_key_exists($time_limit.'-months',$scopes) ){
  543. update_option('dbem_events_page_scope',$time_limit.'-months');
  544. }elseif( array_key_exists('month',$scopes) ){
  545. update_option('dbem_events_page_scope','month');
  546. }else{
  547. update_option('dbem_events_page_scope','future');
  548. }
  549. }
  550. }
  551.  
  552. function em_migrate_bookings(){
  553. global $wpdb;
  554. 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') ){
  555. $new_people = array();
  556. $ticket_bookings = array();
  557. $errors = array();
  558. 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 ){
  559. if( $booking_array['person_email'] != ''){
  560. //first we create the user if we hadn't before
  561. $user = get_user_by_email($booking_array['person_email']);
  562. if( is_object($user) ){
  563. //User exists, whether from current insert or not, so ammend array
  564. $new_people[$booking_array['person_id']] = $user->ID;
  565. }else{
  566. $username_root = explode('@', $booking_array['person_email']);
  567. $username_rand = $username_root[0].rand(1,1000);
  568. while( username_exists($username_rand) ){
  569. $username_rand = $username_root[0].rand(1,1000);
  570. }
  571. $user_array = array(
  572. 'user_email' => $booking_array['person_email'],
  573. 'user_login' => $username_rand,
  574. 'first_name' => $booking_array['person_name'],
  575. 'display_name'=> $booking_array['person_name'],
  576. );
  577. $new_people[$booking_array['person_id']] = wp_insert_user($user_array);
  578. update_user_meta($new_people[$booking_array['person_id']], 'dbem_phone', $booking_array['person_phone']);
  579. }
  580. //save the booking
  581. if( !is_object($new_people[$booking_array['person_id']]) ){
  582. $ticket_bookings[] = "({$booking_array['booking_id']} , {$booking_array['ticket_id']}, {$booking_array['booking_spaces']}, '0')";
  583. }
  584. }else{
  585. 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) ){
  586. $errors[] = 'You have some bookings without a corresponding person in the database. These bookings will be deleted when you delete the people table.';
  587. }
  588. }
  589. }
  590. //modify the booking to have data about the new people, we do this here to avoid duplicate names
  591. foreach($new_people as $old_id => $new_id){
  592. if( !is_object($new_id) ){
  593. $wpdb->query('UPDATE '.EM_BOOKINGS_TABLE." SET person_id='".$new_id."', booking_status=1 WHERE person_id='".$old_id."'");
  594. }elseif( get_class($new_id) == 'WP_Error' ){
  595. /* @var $new_id WP_Error */ /*
  596. $errors[] = "Person ID - $old_id : ".$new_id->get_error_message();
  597. }
  598. }
  599. //Finally insert all the tickets bookings
  600. $wpdb->query('TRUNCATE TABLE '.EM_TICKETS_BOOKINGS_TABLE); //empty tickets bookings table first
  601. $sql = "INSERT INTO ". EM_TICKETS_BOOKINGS_TABLE.' ( `booking_id` ,`ticket_id` ,`ticket_booking_spaces` ,`ticket_booking_price`) VALUES' . implode(',',$ticket_bookings);
  602. $ticket_inserts = $wpdb->query($sql);
  603. if($ticket_inserts === false){
  604. /* @var $wpdb WPDB */ /*
  605. $errors[] = 'DB Error when adding ticket bookings : '.$wpdb->last_error;
  606. }
  607. if( count($errors) > 0 ){
  608. 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>";
  609. foreach($errors as $error){
  610. echo "<p>$error</p>";
  611. }
  612. echo "</div>";
  613. }
  614. 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>";
  615. }
  616. }
  617.  
  618. function em_migrate_bookings_delete(){
  619. global $wpdb;
  620. if( wp_verify_nonce($_REQUEST['_wpnonce'], 'bookings_migrate_delete') ){
  621. //REMOVE ALL NULL BOOKINGS
  622. $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");
  623. $wpdb->query('DROP TABLE '.$wpdb->prefix.'em_people');
  624. echo "<div class='updated'><p>Old People table deleted, enjoy Events Manager 4!</p></div>";
  625. }
  626. }
  627.  
  628. */
  629.  
  630.  
  631. ?> $wpdb->query('UPDATE '.EM_BOOKINGS_TABLE." SET person_id='".$new_id."', booking_status=1 WHERE person_id='".$old_id."'");
  632. }elseif( get_class($new_id) == 'WP_Error' ){
  633. /* @var $new_id WP_Error */ /*
  634. $errors[] = "Person ID - $old_id : ".$new_id->get_error_message();
  635. }
  636. }
  637. //Finally insert all the tickets bookings
  638. $wpdb->query('TRUNCATE TABLE '.EM_TICKETS_BOOKINGS_TABLE); //empty tickets bookings table first
  639. $sql = "INSERT INTO ". EM_TICKETS_BOOKINGS_TABLE.' ( `booking_id` ,`ticket_id` ,`ticket_booking_spaces` ,`ticket_booking_price`) VALUES' . implode(',',$ticket_bookings);
  640. $ticket_inserts = $wpdb->query($sql);
  641. if($ticket_inserts === false){
  642. /* @var $wpdb WPDB */ /*
  643. $errors[] = 'DB Error when adding ticket bookings : '.$wpdb->last_error;
  644. }
  645. if( count($errors) > 0 ){
  646. 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>";
  647. foreach($errors as $error){
  648. echo "<p>$error</p>";
  649. }
  650. echo "</div>";
  651. }
  652. 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>";
  653. }
  654. }
  655.  
  656. function em_migrate_bookings_delete(){
  657. global $wpdb;
  658. if( wp_verify_nonce($_REQUEST['_wpnonce'], 'bookings_migrate_delete') ){
  659. //REMOVE ALL NULL BOOKINGS
  660. $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");
  661. $wpdb->query('DROP TABLE '.$wpdb->prefix.'em_people');
  662. echo "<div class='updated'><p>Old People table deleted, enjoy Events Manager 4!</p></div>";
  663. }
  664. }
  665.  
  666. */
  667.  
  668.  
  669. ?>
  670.  
  671.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement