strtotime( $event['ending_date'] ),
'timestamp'
);
+ $event['recurDays'] = $this->getEventRecurDays( $event );
}
}
$this->postAddTimes = false;
strtotime( $event['ending_date'] ),
'timestamp'
);
+ $event['recurDays'] = $this->getEventRecurDays( $event );
$this->postAddTimes = false;
$this->postAddLocations = false;
return $event;
*/
abstract public function modelAction($actionData = false);
+ public function getEventRecurDays( $event )
+ {
+ $eventDates = '';
+ if ( isset( $event['recurrences'] ) && count( $event['times'] > 1) ) {
+ foreach ( $event['recurrences'] as $recur ) {
+ if ( $recur['recurring']['name'] == 'Yes' && $recur['day_of_week']['names'] ) {
+ if ( $recur['week_of_month']['names'] ) {
+ $weeksOfMonth = array();
+ foreach ( $recur['week_of_month']['names'] as $wom ) {
+ $recurs = array();
+ switch ( $wom ) {
+ case 'First':
+ $weeksOfMonth[] = '1st';
+ break;
+ case 'Second':
+ $weeksOfMonth[] = '2nd';
+ break;
+ case 'Third':
+ $weeksOfMonth[] = '3rd';
+ break;
+ case 'Fourth':
+ $weeksOfMonth[] = '4th';
+ break;
+ case 'Fifth':
+ $weeksOfMonth[] = '5th';
+ break;
+ case 'Last':
+ $weeksOfMonth[] = 'last';
+ break;
+ }
+ $recurs[] = implode( ' ', $weeksOfMonth );
+ }
+ $eventDates .= 'Every ' . implode( ' ', $recurs );
+ }
+ $daysOfWeek = array();
+ foreach ( $recur['day_of_week']['names'] as $dow ) {
+ switch ( $dow ) {
+ case 'Sunday':
+ $daysOfWeek[] = 'Sun';
+ break;
+ case 'Monday':
+ $daysOfWeek[] = 'Mon';
+ break;
+ case 'Tuesday':
+ $daysOfWeek[] = 'Tue';
+ break;
+ case 'Wednesday':
+ $daysOfWeek[] = 'Wed';
+ break;
+ case 'Thursday':
+ $daysOfWeek[] = 'Thu';
+ break;
+ case 'Friday':
+ $daysOfWeek[] = 'Fri';
+ break;
+ case 'Saturday':
+ $daysOfWeek[] = 'Sat';
+ break;
+ }
+ }
+ if ( count( $daysOfWeek ) < 7 ) {
+ $eventDates .= ' ' . implode(', ', $daysOfWeek);
+ }
+ }
+ }
+ }
+ return ( $eventDates ) ? '('.$eventDates.')' : '';
+ }
+
/**
* get_event_date: make the event date human readable
*
switch ($action) {
case 'event-detail':
if ( $eventId ) {
- $event = $this->getModelEventData($eventId);
+ $this->postAddRecurrences = true;
+ $event = $this->getModelEventData($eventId);
+ $this->postAddRecurrences = false;
// Check the end date to see if this event has expired.
if ( $event['ending_timestamp'] < strtotime( 'today' ) ) {
$expired = true;
default:
// for the dashboard need to get list of event categories and
// filter out the events
- $events = $this->getModelEventsData();
- $view = 'agenda.html';
- $categoryEvents = array();
+ $this->postAddRecurrences = true;
+ $events = $this->getModelEventsData();
+ $this->postAddRecurrences = false;
+ $view = 'agenda.html';
+ $categoryEvents = array();
break;
}
if ( isset ( $actionData['request']['template'] ) && $actionData['request']['template'] ) {
break;
}
} else {
- // This is the default date range for this agenda view
+ // This is the default date range for this agenda view.
$total_current_events = $this->checkHaveAnyEvents( $memberId );
+ // Set default number of events wanted in default view.
$total_events_wanted = 5;
+ // Set default number of weeks to view.
+ $weeks_to_check = 4;
+
if ( $total_events_wanted > $total_current_events ) {
- $total_events_wanted = ( $total_current_events > 1 ) ? $total_current_events - 1: 1;
+ $total_events_wanted = ( $total_current_events > 1 ) ? $total_current_events: 1;
}
- $weeks_to_check = 1;
+ // Default range of weeks to check.
+ $weeks_to_check = 4;
$event_count = 0;
do {
$event_count = $this->getEventCountForWeekRange( ++$weeks_to_check, $memberId );
} while ( $event_count < $total_events_wanted && $total_current_events >= $total_events_wanted );
$week_string = ( $weeks_to_check === 1 ) ? 'weeks': 'week';
- $toDate = date('m/d/Y', strtotime( '+ ' . $weeks_to_check . ' ' . $week_string ));
+ $toDate = date('m/d/Y', strtotime( '+ ' . $weeks_to_check . ' ' . $week_string ));
}
}
if ( $fromDate && $toDate && !(isset($_REQUEST['event_name']) && $_REQUEST['event_name'])) {
// dates
$dates = new SetaPDF_Core_Text_Block( $boldFont, self::PDF_FONT_SIZE );
$eventDates = $event['dates'];
- if ( $event['recurrences'][0]['recurring']['name'] == 'Yes' && count( $event['times'] > 1) && isset( $event['recurrences'] ) ) {
- if ( $event['recurrences'][0]['day_of_week']['names'] ) {
- $daysOfWeek = array();
- foreach ( $event['recurrences'][0]['day_of_week']['names'] as $dow ) {
- switch ( $dow ) {
- case 'Sunday':
- $daysOfWeek[] = 'Sun';
- break;
- case 'Monday':
- $daysOfWeek[] = 'Mon';
- break;
- case 'Tuesday':
- $daysOfWeek[] = 'Tue';
- break;
- case 'Wednesday':
- $daysOfWeek[] = 'Wed';
- break;
- case 'Thursday':
- $daysOfWeek[] = 'Thu';
- break;
- case 'Friday':
- $daysOfWeek[] = 'Fri';
- break;
- case 'Saturday':
- $daysOfWeek[] = 'Sat';
- break;
- }
- }
- if ( count( $daysOfWeek ) < 7 ) {
- $eventDates .= ' (' . implode(', ', $daysOfWeek) . ')';
- }
- }
+ if ( isset( $event['recurDays'] ) && ( $event['recurDays'] ) ) {
+ $eventDates .= ' ' . $event['recurDays'];
}
if ( !$event['all_day'] ) {
$startTime = strftime( "%l:%M %P", strtotime( $event['starting_date'] ) );
public function checkHaveAnyEvents( $member_id = null )
{
$from = date( 'Y-m-d' );
+ /*
$sql = "SELECT count(id)
FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events
WHERE status = 10
AND id IN (
SELECT event
FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times
- WHERE DATE(start_time) >= %s)";
+ WHERE DATE(start_time) >= %s)";
+ */
+ $sql = "
+ SELECT count(id)
+ FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times
+ WHERE event IN (
+ SELECT id
+ FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events
+ WHERE status = 10 )
+ AND DATE(start_time) >= %s";
+
if ( $member_id = filter_var( $member_id, FILTER_VALIDATE_INT ) ) {
$sql .= " AND ref_dest = " . $member_id;
}
$from = date( 'Y-m-d' );
$week_string = ( $weeks === 1 ) ? 'weeks': 'week';
$to = date( 'Y-m-d', strtotime( '+ ' . $weeks . ' ' . $week_string) );
- $sql = "SELECT count(id)
- FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times
- WHERE DATE(start_time) BETWEEN %s AND %s";
+ $sql = "
+ SELECT count(id)
+ FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times
+ WHERE DATE(start_time) BETWEEN %s AND %s
+ AND event IN (
+ SELECT id
+ FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events
+ WHERE status = 10 )";
if ( $member_id = filter_var( $member_id, FILTER_VALIDATE_INT ) ) {
$sql .= " AND event in (SELECT id FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events
WHERE ref_dest = " . $member_id . ")";