Skip to content

Commit

Permalink
Merge pull request #42 from shashachu/5.11-upgrade
Browse files Browse the repository at this point in the history
5.11 upgrade
  • Loading branch information
shashachu authored May 2, 2024
2 parents d90e1ea + 212f3e4 commit 53e0509
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 52 deletions.
21 changes: 3 additions & 18 deletions admin/em-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,7 @@ function em_admin_menu(){
$bookings_num = '';
$bookings_pending_count = 0;
}
//Count pending events
$events_num = '';
$events_pending_count = EM_Events::count(array('status'=>0, 'scope'=>'all', 'blog'=>get_current_blog_id()));
//TODO Add flexible permissions
if($events_pending_count > 0){
$events_num = '<span class="update-plugins count-'.$events_pending_count.'"><span class="plugin-count">'.$events_pending_count.'</span></span>';
}
//Count pending recurring events
$events_recurring_num = '';
$events_recurring_pending_count = EM_Events::count(array('status'=>0, 'recurring'=>1, 'scope'=>'all', 'blog'=>get_current_blog_id()));
//TODO Add flexible permissions
if($events_recurring_pending_count > 0){
$events_recurring_num = '<span class="update-plugins count-'.$events_recurring_pending_count.'"><span class="plugin-count">'.$events_recurring_pending_count.'</span></span>';
}
$both_pending_count = apply_filters('em_items_pending_count', $events_pending_count + $bookings_pending_count + $events_recurring_pending_count);
$both_num = ($both_pending_count > 0) ? '<span class="update-plugins count-'.$both_pending_count.'"><span class="plugin-count">'.$both_pending_count.'</span></span>':'';
// GGG - Remove pending event count
// Add a submenu to the custom top-level menu:
$plugin_pages = array();
if( get_option('dbem_rsvp_enabled') ){
Expand All @@ -46,11 +31,11 @@ function em_admin_menu(){
}
$plugin_pages = apply_filters('em_create_events_submenu',$plugin_pages);
//We have to modify the menus manually
if( !empty($both_num) ){ //Main Event Menu
if( !empty($bookings_num) ){ //Main Event Menu
//go through the menu array and modify the events menu if found
foreach ( (array)$menu as $key => $parent_menu ) {
if ( $parent_menu[2] == 'edit.php?post_type='.EM_POST_TYPE_EVENT ){
$menu[$key][0] = $menu[$key][0]. $both_num;
$menu[$key][0] = $menu[$key][0]. $bookings_num;
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion admin/em-docs.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function em_docs_init($force_init = false){
'recurrences' => array( 'desc'=> 'Show only recurrences if set to 1 or non-recurrences if set to 0, shows all events if not used.'),
'recurrence' => array( 'desc'=> 'If set to the event id of the recurring event, this will show only events this event recurrences.', 'default'=>0),
'recurring' => array( 'desc'=> 'If set to 1, will only show recurring event templates. Only useful if you know what you\'re doing, use recurrence or recurrences if you want to filter event recurrences.', 'default'=>0),
'scope' => array( 'desc'=> 'Choose the time frame of events to show. Additionally you can supply dates (in format of YYYY-MM-DD), either single for events on a specific date or two dates separated by a comma (e.g. 2010-12-25,2010-12-31) for events ocurring between these dates.', 'default'=>'future', 'args'=>array("future", "past", "today", "tomorrow", "month", "next-month", "1-months", "2-months", "3-months", "6-months", "12-months","all")),
'scope' => array( 'desc'=> 'Choose the time frame of events to show. Additionally you can supply dates (in format of YYYY-MM-DD), either single for events on a specific date or two dates separated by a comma (e.g. 2010-12-25,2010-12-31) for events ocurring between these dates.', 'default'=>'future', 'args'=>array("future", "past", "today", "tomorrow", 'week', 'this-week', "month", 'this-month', "next-month", "1-months", "2-months", "3-months", "6-months", "12-months","all")),
'search' => array( 'desc'=> 'Do a search for this string within event name, details and location address.' ),
'status' => array( 'desc' => sprintf('Limit search to %s with a spefic status (1 is active, 0 is pending approval)','events'), 'default'=>1),
'tag' => array( 'desc'=> str_replace('%s', 'tags', 'Supply a single id, slug or comma-separated ids or slugs (e.g. "1,%s-slug,3") to limit the search to events in any of these %s. You can also use negative numbers and slugs to exclude specific %s (e.g. -1,-exclude-%s,-3). If you mix inclusions and exclusions, all events with included %s AND without excluded %s will be shown. You can also use &amp; to separate ids and slugs, in which case events must contain (or not contain) both %s to be shown.'), 'default'=>0),
Expand Down
5 changes: 4 additions & 1 deletion classes/em-booking.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function em_get_booking($id = false) {
* Contains all information and relevant functions surrounding a single booking made with Events Manager
* @property int|false $booking_status
* @property string $language
* @property EM_Person $person
*/
class EM_Booking extends EM_Object{
//DB Fields
Expand Down Expand Up @@ -78,7 +79,7 @@ class EM_Booking extends EM_Object{
/**
* @var EM_Person
*/
var $person;
protected $person;
var $required_fields = array('booking_id', 'event_id', 'person_id', 'booking_spaces');
var $feedback_message = "";
var $errors = array();
Expand Down Expand Up @@ -176,6 +177,8 @@ function __get( $var ){
}
}elseif( $var == 'booking_status' ){
return ($this->booking_status == 0 && !get_option('dbem_bookings_approval') ) ? 1:$this->booking_status;
}elseif( $var == 'person' ){
return $this->get_person();
}
return null;
}
Expand Down
32 changes: 32 additions & 0 deletions classes/em-datetime.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,4 +336,36 @@ public static function createFromFormat( $format, $time, $timezone = null ){
if( $DateTime === false ) return false;
return new EM_DateTime($DateTime->format('Y-m-d H:i:s'), $timezone);
}

/**
* Gets a set of start/end dates for the relative week of this $EM_DateTime, until the day before the starting weekday as per WP Settings.
*
* Accepts two scopes for $scope, both which calculate relative dates until the day before next start day of week.:
* 'this-week' - events for the rest of the week starting 'today'
* 'week' - events from start of relative week since previous start day of week
*
* @param string $scope
* @return string[]
*/
public function get_week_dates( $scope = 'week' ) {
$start_of_week = get_option('start_of_week');
$days_of_week = array( 0 => 'Sunday', 1 => 'Monday', 2 => 'Tuesday', 3 => 'Wednesday', 4 => 'Thursday', 5 => 'Friday', 6 => 'Saturday');
$EM_DateTime = $this->copy(); // so we don't modify this $EM_DateTime
$today_day_of_week = $EM_DateTime->format('w');
$end_of_week = $start_of_week > 0 ? $start_of_week-1 : 6;
$end_of_week_name = $days_of_week[$end_of_week];
// get stat date, either today if it's start of week or 'this-week' scope, or the previous start day of week
if( $scope == 'this-week' || $today_day_of_week == $start_of_week ){
$start_date = $EM_DateTime->getDate();
}else{
$start_of_week_name = $days_of_week[$start_of_week];
$start_date = $EM_DateTime->modify('last '. $start_of_week_name)->getDate();
}
$end_date = $start_date; // set as today in event it's the last day of week
if( $scope == 'week' || $today_day_of_week != $end_of_week ){
// if we're looking for whole week, $EM_DateTime is set to start of week, so get relative end of week even if it's today
$end_date = $EM_DateTime->modify('next '. $end_of_week_name)->getDate();
}
return array($start_date, $end_date);
}
}
13 changes: 11 additions & 2 deletions classes/em-event-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,17 +366,26 @@ public static function parse_query(){
}else{
$query[] = array( 'key' => '_event_end', 'value' => $EM_DateTime->getDateTime(), 'compare' => $compare, 'type' => 'DATETIME' );
}
}elseif ($scope == "month" || $scope == "next-month" ){
}elseif ($scope == "month" || $scope == "next-month" || $scope == 'this-month'){
$EM_DateTime = new EM_DateTime(); //create default time in blog timezone
if( $scope == 'next-month' ) $EM_DateTime->add('P1M');
$start_month = $EM_DateTime->modify('first day of this month')->getDate();
$start_month = $scope == 'this-month' ? $EM_DateTime->getDate() : $EM_DateTime->modify('first day of this month')->getDate();
$end_month = $EM_DateTime->modify('last day of this month')->getDate();
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
$query[] = array( 'key' => '_event_start_date', 'value' => array($start_month,$end_month), 'type' => 'DATE', 'compare' => 'BETWEEN');
}else{
$query[] = array( 'key' => '_event_start_date', 'value' => $end_month, 'compare' => '<=', 'type' => 'DATE' );
$query[] = array( 'key' => '_event_end_date', 'value' => $start_month, 'compare' => '>=', 'type' => 'DATE' );
}
}elseif ($scope == "week" || $scope == 'this-week'){
$EM_DateTime = new EM_DateTime(); //create default time in blog timezone
list($start_date, $end_date) = $EM_DateTime->get_week_dates( $scope );
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
$query[] = array( 'key' => '_event_start_date', 'value' => array($start_date,$end_date), 'type' => 'DATE', 'compare' => 'BETWEEN');
}else{
$query[] = array( 'key' => '_event_start_date', 'value' => $end_date, 'compare' => '<=', 'type' => 'DATE' );
$query[] = array( 'key' => '_event_end_date', 'value' => $start_date, 'compare' => '>=', 'type' => 'DATE' );
}
}elseif( preg_match('/(\d\d?)\-months/',$scope,$matches) ){ // next x months means this month (what's left of it), plus the following x months until the end of that month.
$EM_DateTime = new EM_DateTime(); //create default time in blog timezone
$months_to_add = $matches[1];
Expand Down
2 changes: 1 addition & 1 deletion classes/em-event.php
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,7 @@ public function start( $utc_timezone = false ){
public function end( $utc_timezone = false ){
return apply_filters('em_event_end', $this->get_datetime('end', $utc_timezone), $this);
}

/**
* GGG: Returns an EM_DateTime object of the EC RSVP date in local timezone of event
* @param bool $utc_timezone Returns EM_DateTime with UTC timezone if set to true, returns local timezone by default.
Expand Down
10 changes: 8 additions & 2 deletions classes/em-object.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,15 @@ public static function build_sql_conditions( $args = array() ){
if( !get_option('dbem_events_current_are_past') ){
$conditions['scope'] .= " OR (event_start_date <= CAST('".$EM_DateTime->getDate()."' AS DATE) AND event_end_date >= CAST('".$EM_DateTime->getDate()."' AS DATE))";
}
}elseif ($scope == "month" || $scope == "next-month"){
}elseif ($scope == "week" || $scope == 'this-week'){
list($start_date, $end_date) = $EM_DateTime->get_week_dates( $scope );
$conditions['scope'] = " (event_start_date BETWEEN CAST('$start_date' AS DATE) AND CAST('$end_date' AS DATE))";
if( !get_option('dbem_events_current_are_past') ){
$conditions['scope'] .= " OR (event_start_date < CAST('$start_date' AS DATE) AND event_end_date >= CAST('$start_date' AS DATE))";
}
}elseif ($scope == "month" || $scope == "next-month" || $scope == 'this-month'){
if( $scope == 'next-month' ) $EM_DateTime->add('P1M');
$start_month = $EM_DateTime->modify('first day of this month')->getDate();
$start_month = $scope == 'this-month' ? $EM_DateTime->getDate() : $EM_DateTime->modify('first day of this month')->getDate();
$end_month = $EM_DateTime->modify('last day of this month')->getDate();
$conditions['scope'] = " (event_start_date BETWEEN CAST('$start_month' AS DATE) AND CAST('$end_month' AS DATE))";
if( !get_option('dbem_events_current_are_past') ){
Expand Down
23 changes: 4 additions & 19 deletions em-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -614,25 +614,10 @@ function em_init_actions() {
if( is_user_logged_in() ){
//Admin operations
//Specific Oject Ajax
if( !empty($_REQUEST['em_obj']) ){
switch( $_REQUEST['em_obj'] ){
case 'em_bookings_events_table':
include_once('admin/bookings/em-events.php');
em_bookings_events_table();
exit();
break;
case 'em_bookings_pending_table':
include_once('admin/bookings/em-pending.php');
em_bookings_pending_table();
exit();
break;
case 'em_bookings_confirmed_table':
//add some admin files just in case
include_once('admin/bookings/em-confirmed.php');
em_bookings_confirmed_table();
exit();
break;
}
if( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_events_table' ){
include_once('admin/bookings/em-events.php');
em_bookings_events_table();
exit();
}
}
//Export CSV - WIP
Expand Down
7 changes: 7 additions & 0 deletions em-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,20 @@ function em_get_countries($add_blank = false, $sort = true){
* Returns an array of scopes available to events manager. Hooking into this function's em_get_scopes filter will allow you to add scope options to the event pages.
*/
function em_get_scopes(){
global $wp_locale;
$start_of_week = get_option('start_of_week');
$end_of_week_name = $start_of_week > 0 ? $wp_locale->get_weekday($start_of_week-1) : $wp_locale->get_weekday(6);
$start_of_week_name = $wp_locale->get_weekday($start_of_week);
$scopes = array(
'all' => __('All events','events-manager'),
'future' => __('Future events','events-manager'),
'past' => __('Past events','events-manager'),
'today' => __('Today\'s events','events-manager'),
'tomorrow' => __('Tomorrow\'s events','events-manager'),
'week' => sprintf(__('Events this whole week (%s to %s)','events-manager'), $wp_locale->get_weekday_abbrev($start_of_week_name), $wp_locale->get_weekday_abbrev($end_of_week_name)),
'this-week' => sprintf(__('Events this week (today to %s)','events-manager'), $wp_locale->get_weekday_abbrev($end_of_week_name)),
'month' => __('Events this month','events-manager'),
'this-month' => __('Events this month (today onwards)', 'events-manager'),
'next-month' => __('Events next month','events-manager'),
'1-months' => __('Events current and next month','events-manager'),
'2-months' => __('Events within 2 months','events-manager'),
Expand Down
4 changes: 0 additions & 4 deletions em-install.php
Original file line number Diff line number Diff line change
Expand Up @@ -1221,10 +1221,6 @@ function em_upgrade_current_installation(){
}
$wpdb->query($sql);
}
// GGG
if( get_option('dbem_version') != '' && get_option('dbem_version') < 5.951 ){
em_create_costumes_table();
}
}

function em_set_mass_caps( $roles, $caps ){
Expand Down
2 changes: 1 addition & 1 deletion events-manager.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
Plugin Name: GGG Events Manager
Version: 5.9.1000
Version: 5.11.1
Plugin URI: https://github.com/shashachu/ggg-events-manager/
Description: Customized version of the Events Manager plugin by Marcus Sykes, tailored towards trooping signups for the Golden Gate Garrison.
Author: Marcus Sykes, Sha Sha Chu
Expand Down
10 changes: 7 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tags: bookings, calendar, tickets, events, buddypress, event management, google
Text Domain: events-manager
Requires at least: 5.2
Tested up to: 5.8
Stable tag: 5.10.1
Stable tag: 5.11.1
Requires PHP: 5.3

Fully featured event registration management including recurring events, locations management, calendar, Google map integration, booking management
Expand Down Expand Up @@ -119,8 +119,12 @@ See our [FAQ](http://wp-events-plugin.com/documentation/faq/) page, which is upd
6. Manage attendees with various booking reports

== Changelog ==
= 5.10.1 =
* 5.10 with GGG mods
= 5.11.1 =
* 5.11 with GGG mods

= 5.11 =
* fixed booking-related php errors deriving from accessing $EM_Booking->people directly since 5.10
* added 'week', 'this-week' and 'this-month' scopes

= 5.10 =
* fixed a minor PHPMailer PHP warning tiggered when mailing errors occur
Expand Down

0 comments on commit 53e0509

Please sign in to comment.