Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

@@ -12,7 +12,7 @@
namespace IPS\calendar\modules\admin\calendars;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -23,6 +23,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _calendars extends \IPS\Node\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Node Class
*/
@@ -12,7 +12,7 @@
namespace IPS\calendar\modules\admin\calendars;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -22,7 +22,12 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
* iCalendar feed management
*/
class _ical extends \IPS\Dispatcher\Controller
{
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Execute
*
@@ -99,7 +104,7 @@ class _ical extends \IPS\Dispatcher\Controller
$return = array( 'update' => array(
'icon' => 'refresh',
'title' => 'update_ical',
'link' => \IPS\Http\Url::internal( 'app=calendar&module=calendars&controller=ical&do=refresh&id=' ) . $row['feed_id'],
'link' => \IPS\Http\Url::internal( 'app=calendar&module=calendars&controller=ical&do=refresh&id=' . $row['feed_id'] )->csrf(),
'hotkey' => 'r'
) );
@@ -118,7 +123,7 @@ class _ical extends \IPS\Dispatcher\Controller
$return['delete'] = array(
'icon' => 'times-circle',
'title' => 'delete',
'link' => \IPS\Http\Url::internal( 'app=calendar&module=calendars&controller=ical&do=delete&id=' ) . $row['feed_id'],
'link' => \IPS\Http\Url::internal( 'app=calendar&module=calendars&controller=ical&do=delete&id=' . $row['feed_id'] )->csrf(),
'data' => array( 'delete' => '' ),
);
}
@@ -241,7 +246,7 @@ class _ical extends \IPS\Dispatcher\Controller
) ) );
if( \IPS\Settings::i()->calendar_venues_enabled )
{
$form->add( new \IPS\Helpers\Form\Node( 'feed_venue_id', NULL, TRUE, array(
$form->add( new \IPS\Helpers\Form\Node( 'feed_venue_id', NULL, FALSE, array(
'url' => \IPS\Http\Url::internal( 'app=calendar&module=calendars&controller=ical&do=upload' ),
'class' => 'IPS\calendar\Venue',
) ) );
@@ -255,7 +260,8 @@ class _ical extends \IPS\Dispatcher\Controller
try
{
$icsParser = new \IPS\calendar\Icalendar\ICSParser;
$count = $icsParser->parse( \file_get_contents( $values['feed_file'] ), $values['feed_calendar_id'], $values['feed_member_id'], ( isset( $values['feed_venue_id'] ) ) ? $values['feed_venue_id']->_id : NULL );
$count = $icsParser->parse( \file_get_contents( $values['feed_file'] ), $values['feed_calendar_id'], $values['feed_member_id'], NULL, ( isset( $values['feed_venue_id'] ) AND $values['feed_venue_id'] ) ? $values['feed_venue_id']->_id : NULL );
}
catch( \UnexpectedValueException $e )
{
@@ -305,7 +311,7 @@ class _ical extends \IPS\Dispatcher\Controller
$options[ $calendar->id ] = $calendar->_title;
}
$form->add( new \IPS\Helpers\Form\Select( 'feed_calendar_id', $feed->calendar_id, TRUE, array( 'options' => $options, 'parse' => 'normal' ) ) );
$form->add( new \IPS\Helpers\Form\Node( 'feed_calendar_id', \IPS\calendar\Calendar::load( $feed->calendar_id ), TRUE, array( 'class' => 'IPS\calendar\Calendar', 'url' => \IPS\Http\Url::internal( 'app=calendar&module=calendars&controller=ical&do=edit&id=' . \IPS\Request::i()->id, 'admin' ) ) ) );
if( \IPS\Settings::i()->calendar_venues_enabled )
{
@@ -369,6 +375,7 @@ class _ical extends \IPS\Dispatcher\Controller
{
/* Check permissions */
\IPS\Dispatcher::i()->checkAcpPermission( 'calendar_feeds_delete' );
\IPS\Session::i()->csrfCheck();
/* Build the form */
$form = new \IPS\Helpers\Form( 'form', 'delete' );
@@ -412,6 +419,8 @@ class _ical extends \IPS\Dispatcher\Controller
*/
public function refresh()
{
\IPS\Session::i()->csrfCheck();
/* Refresh the feed */
try
{
@@ -12,7 +12,7 @@
namespace IPS\calendar\modules\admin\calendars;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -23,6 +23,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _settings extends \IPS\Dispatcher\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Execute
*
@@ -60,11 +65,10 @@ class _settings extends \IPS\Dispatcher\Controller
1 => 'calendar_rss_feed_order_publish'
) ), NULL, NULL, NULL, 'calendar_rss_feed_order' ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'calendar_venues_enabled', \IPS\Settings::i()->calendar_venues_enabled ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'calendar_block_past_changes', \IPS\Settings::i()->calendar_block_past_changes ) );
if ( $values = $form->values() )
{
if( $values['calendar_date_format'] == -1 AND !$values['calendar_date_format_custom'] )
@@ -12,7 +12,7 @@
namespace IPS\calendar\modules\admin\calendars;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -23,6 +23,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _venues extends \IPS\Node\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Node Class
*/
@@ -12,7 +12,7 @@
namespace IPS\calendar\modules\front\calendar;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -55,6 +55,8 @@ class _event extends \IPS\Content\Controller
{
\IPS\Output::i()->error( 'node_error', '2L179/2', 404, '' );
}
$this->event->container()->clubCheckRules();
/* We want to present the same breadcrumb structure as the rest of the calendar */
\IPS\Output::i()->breadcrumb['module'] = array( \IPS\Http\Url::internal( "app=calendar&module=calendar&controller=view", 'front', 'calendar' ), \IPS\Member::loggedIn()->language()->addToStack('module__calendar_calendar') );
@@ -88,9 +90,9 @@ class _event extends \IPS\Content\Controller
$tab = isset( \IPS\Request::i()->tab ) ? \IPS\Request::i()->tab : array_shift( $_tabs );
$activeTabContents = $this->event->commentReviews( $tab );
if ( count( $tabs ) > 1 )
if ( \count( $tabs ) > 1 )
{
$commentsAndReviews = count( $tabs ) ? \IPS\Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $tab, $activeTabContents, $this->event->url(), 'tab', FALSE, TRUE ) : NULL;
$commentsAndReviews = \count( $tabs ) ? \IPS\Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $tab, $activeTabContents, $this->event->url(), 'tab', FALSE, TRUE ) : NULL;
}
else
{
@@ -131,23 +133,24 @@ class _event extends \IPS\Content\Controller
}
/* Add JSON-LD */
$format = $this->event->all_day ? "Y-m-d" : \IPS\DateTime::ISO8601;
\IPS\Output::i()->jsonLd['event'] = array(
'@context' => "http://schema.org",
'@type' => "Event",
'url' => (string) $this->event->url(),
'name' => $this->event->mapped('title'),
'description' => strip_tags( $this->event->truncated() ),
'description' => $this->event->truncated( TRUE, NULL ),
'eventStatus' => "EventScheduled",
'startDate' => $this->event->nextOccurrence( \IPS\calendar\Date::getDate(), 'startDate' ) ?
$this->event->nextOccurrence( \IPS\calendar\Date::getDate(), 'startDate' )->format( \IPS\DateTime::ISO8601 ) :
$this->event->lastOccurrence( 'startDate' )->format( \IPS\DateTime::ISO8601 )
$this->event->nextOccurrence( \IPS\calendar\Date::getDate(), 'startDate' )->format( $format ) :
$this->event->lastOccurrence( 'startDate' )->format( $format )
);
if( $this->event->_end_date )
{
\IPS\Output::i()->jsonLd['event']['endDate'] = $this->event->nextOccurrence( $this->event->nextOccurrence( \IPS\calendar\Date::getDate(), 'startDate' ) ?: \IPS\calendar\Date::getDate(), 'endDate' ) ?
$this->event->nextOccurrence( $this->event->nextOccurrence( \IPS\calendar\Date::getDate(), 'startDate' ) ?: \IPS\calendar\Date::getDate(), 'endDate' )->format( \IPS\DateTime::ISO8601 ) :
$this->event->lastOccurrence( 'endDate' )->format( \IPS\DateTime::ISO8601 );
$this->event->nextOccurrence( $this->event->nextOccurrence( \IPS\calendar\Date::getDate(), 'startDate' ) ?: \IPS\calendar\Date::getDate(), 'endDate' )->format( $format ) :
$this->event->lastOccurrence( 'endDate' )->format( $format );
}
if( $this->event->container()->allow_reviews AND $this->event->reviews AND $this->event->averageReviewRating() )
@@ -167,7 +170,7 @@ class _event extends \IPS\Content\Controller
if( $this->event->rsvp )
{
if( count( $attendees[1] ) )
if( \count( $attendees[1] ) )
{
\IPS\Output::i()->jsonLd['event']['attendee'] = array();
@@ -227,7 +230,7 @@ class _event extends \IPS\Content\Controller
{
$dateBits = explode( '-', \IPS\Request::i()->sd );
if( count( $dateBits ) === 3 )
if( \count( $dateBits ) === 3 )
{
$date = \IPS\calendar\Date::getDate( $dateBits[0], $dateBits[1], $dateBits[2] );
}
@@ -288,6 +291,11 @@ class _event extends \IPS\Content\Controller
\IPS\Output::i()->error( 'rsvp_error', '2L179/3', 403, '' );
}
if( $this->event->hasPassed() AND \IPS\Settings::i()->calendar_block_past_changes )
{
\IPS\Output::i()->error( 'no_rsvp_past_event', '2L179/6', 403, '' );
}
\IPS\Session::i()->csrfCheck();
/* We delete either way at this point, because even if we select a different action we have to remove any existing RSVP preference */
@@ -327,7 +335,7 @@ class _event extends \IPS\Content\Controller
}
/* And we have to actually check the limit */
if( $_go == \IPS\calendar\Event::RSVP_YES and count( $this->event->attendees( \IPS\calendar\Event::RSVP_YES ) ) >= $this->event->rsvp_limit )
if( $_go == \IPS\calendar\Event::RSVP_YES and \count( $this->event->attendees( \IPS\calendar\Event::RSVP_YES ) ) >= $this->event->rsvp_limit )
{
\IPS\Output::i()->error( 'rsvp_limit_reached', '3L179/5', 403, '' );
}
@@ -353,11 +361,32 @@ class _event extends \IPS\Content\Controller
*/
protected function edit()
{
/* Are we blocking changes to past events? */
if( $this->event->hasPassed() AND \IPS\Settings::i()->calendar_block_past_changes )
{
if ( !\IPS\calendar\Event::modPermission( 'edit', \IPS\Member::loggedIn(), $this->event->containerWrapper() ) )
{
\IPS\Output::i()->error( 'no_edit_past_event', '2L179/7', 403, '' );
}
}
/* Output resources and go */
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_submit.js', 'calendar', 'front' ) );
return parent::edit();
}
/**
* Return the form for editing. Abstracted so controllers can define a custom template if desired.
*
* @param \IPS\Helpers\Form $form The form
* @return string
*/
protected function getEditForm( $form )
{
return $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'submit', 'calendar' ), 'submitForm' ) );
}
/**
* Set a reminder
*
@@ -417,11 +446,11 @@ class _event extends \IPS\Content\Controller
/* Display */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'event_set_reminder' );
$output = $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'view', 'calendar' ) ), 'reminderForm' ) );
$output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'view', 'calendar' ), 'reminderForm' ) );
if( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->sendOutput( $output, 200, 'text/html', \IPS\Output::i()->httpHeaders );
\IPS\Output::i()->sendOutput( $output, 200, 'text/html' );
}
else
{
@@ -12,7 +12,7 @@
namespace IPS\calendar\modules\front\calendar;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -113,14 +113,16 @@ class _submit extends \IPS\Dispatcher\Controller
$form = \IPS\calendar\Event::create( $calendar );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'submit' )->submitPage( $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'submit', 'calendar' ) ), 'submitForm' ) ), \IPS\Member::loggedIn()->language()->addToStack('add_cal_event_header'), $calendar );
if ( \IPS\calendar\Event::moderateNewItems( \IPS\Member::loggedIn() ) )
$extraOutput = '';
$guestPostBeforeRegister = ( !\IPS\Member::loggedIn()->member_id ) ? ( $calendar and !$calendar->can( 'add', \IPS\Member::loggedIn(), FALSE ) ) : NULL;
$modQueued = \IPS\calendar\Event::moderateNewItems( \IPS\Member::loggedIn(), $calendar, $guestPostBeforeRegister );
if ( $guestPostBeforeRegister or $modQueued )
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'forms', 'core' )->modQueueMessage( \IPS\Member::loggedIn()->warnings( 5, NULL, 'mq' ), \IPS\Member::loggedIn()->mod_posts ) . \IPS\Output::i()->output;
}
$extraOutput .= \IPS\Theme::i()->getTemplate( 'forms', 'core' )->postingInformation( $guestPostBeforeRegister, $modQueued, TRUE );
}
/* Display */
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'submit' )->submitPage( $extraOutput . $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'submit', 'calendar' ), 'submitForm' ) ), \IPS\Member::loggedIn()->language()->addToStack('add_cal_event_header'), $calendar );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'submit_event' );
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->addToStack( 'add_cal_event_header' ) );
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_submit.js', 'calendar', 'front' ) );
@@ -143,7 +145,7 @@ class _submit extends \IPS\Dispatcher\Controller
}
/* Are we the author of the existing event? */
if( $existing->author() !== \IPS\Member::loggedIn() )
if( $existing->author()->member_id !== \IPS\Member::loggedIn()->member_id )
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=calendar&module=calendar&controller=submit', 'front', 'calendar_submit' ) );
}
@@ -153,7 +155,7 @@ class _submit extends \IPS\Dispatcher\Controller
$formElements = \IPS\Calendar\Event::formElements( $existing, $existing->container() );
foreach ( $formElements as $key => $object )
{
if ( is_object( $object ) )
if ( \is_object( $object ) )
{
$form->add( $object );
}
@@ -204,7 +206,7 @@ class _submit extends \IPS\Dispatcher\Controller
}
}
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'submit' )->submitPage( $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'submit', 'calendar' ) ), 'submitForm' ) ), \IPS\Member::loggedIn()->language()->addToStack('copy_cal_event_header', TRUE, array( 'sprintf' => $existing->title ) ) );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'submit' )->submitPage( $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'submit', 'calendar' ), 'submitForm' ) ), \IPS\Member::loggedIn()->language()->addToStack('copy_cal_event_header', TRUE, array( 'sprintf' => $existing->title ) ) );
if ( \IPS\calendar\Event::moderateNewItems( \IPS\Member::loggedIn() ) )
{
@@ -12,7 +12,7 @@
namespace IPS\calendar\modules\front\calendar;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -98,7 +98,7 @@ class _venue extends \IPS\Dispatcher\Controller
/* Display */
if( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->sendOutput( $upcomingOutput, 200, 'text/html', \IPS\Output::i()->httpHeaders );
\IPS\Output::i()->sendOutput( $upcomingOutput, 200, 'text/html' );
}
else
{
@@ -12,7 +12,7 @@
namespace IPS\calendar\modules\front\calendar;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -33,6 +33,11 @@ class _view extends \IPS\Dispatcher\Controller
*/
protected $_today = NULL;
/**
* @brief Root nodes
*/
protected $roots = NULL;
/**
* Route
*
@@ -52,11 +57,11 @@ class _view extends \IPS\Dispatcher\Controller
}
/* Is there only one calendar? */
$roots = \IPS\Settings::i()->club_nodes_in_apps ? \IPS\calendar\Calendar::rootsWithClubs() : \IPS\calendar\Calendar::roots();
if ( count( $roots ) == 1 AND !isset( \IPS\Request::i()->id ) )
$this->roots = \IPS\Settings::i()->club_nodes_in_apps ? \IPS\calendar\Calendar::rootsWithClubs() : \IPS\calendar\Calendar::roots();
if ( \count( $this->roots ) == 1 AND !isset( \IPS\Request::i()->id ) )
{
$roots = array_shift( $roots );
$this->_calendar = \IPS\calendar\Calendar::loadAndCheckPerms( $roots->_id );
$root = array_shift( $this->roots );
$this->_calendar = \IPS\calendar\Calendar::loadAndCheckPerms( $root->_id );
}
/* Are we viewing a specific calendar only? */
@@ -70,19 +75,17 @@ class _view extends \IPS\Dispatcher\Controller
{
\IPS\Output::i()->error( 'node_error', '2L182/2', 404, '' );
}
/* If we're viewing a club, set the breadcrumbs appropriately */
if ( $club = $this->_calendar->club() )
{
\IPS\core\FrontNavigation::$clubTabActive = TRUE;
\IPS\Output::i()->breadcrumb = array();
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=core&module=clubs&controller=directory', 'front', 'clubs_list' ), \IPS\Member::loggedIn()->language()->addToStack('module__core_clubs') );
\IPS\Output::i()->breadcrumb[] = array( $club->url(), $club->name );
\IPS\Output::i()->breadcrumb[] = array( $this->_calendar->url(), $this->_calendar->_title );
$this->_calendar->clubCheckRules();
if ( \IPS\Settings::i()->clubs_header == 'sidebar' )
{
\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate( 'clubs', 'core' )->header( $club, $this->_calendar, 'sidebar' );
}
$club->setBreadcrumbs( $this->_calendar );
}
else
{
\IPS\Output::i()->breadcrumb[] = array( NULL, $this->_calendar->_title );
}
}
@@ -125,7 +128,7 @@ class _view extends \IPS\Dispatcher\Controller
/* Online User Location */
if ( $this->_calendar )
{
\IPS\Session::i()->setLocation( $this->_calendar->url(), array(), 'loc_calendar_viewing_calendar', array( "calendar_calendar_{$this->_calendar->id}" => TRUE ) );
\IPS\Session::i()->setLocation( $this->_calendar->url(), $this->_calendar->permissions()['perm_view'], 'loc_calendar_viewing_calendar', array( "calendar_calendar_{$this->_calendar->id}" => TRUE ) );
}
else
{
@@ -142,9 +145,6 @@ class _view extends \IPS\Dispatcher\Controller
*/
protected function _viewMonth( $jump, $featured=array() )
{
/* Get the calendars we can view */
$calendars = \IPS\Settings::i()->club_nodes_in_apps ? \IPS\calendar\Calendar::rootsWithClubs() : \IPS\calendar\Calendar::roots();
/* Get the month data */
$day = NULL;
@@ -158,7 +158,7 @@ class _view extends \IPS\Dispatcher\Controller
$date = \IPS\calendar\Date::getDate( \IPS\Request::i()->y ?: NULL, \IPS\Request::i()->m ?: NULL, $day );
/* Get birthdays */
$birthdays = ( $this->_calendar === NULL OR count( $calendars ) == 1 ) ? $date->getBirthdays( FALSE, TRUE ) : array();
$birthdays = ( $this->_calendar === NULL OR \count( $this->roots ) == 1 ) ? $date->getBirthdays( FALSE, TRUE ) : array();
/* Get the events within this range */
$events = \IPS\calendar\Event::retrieveEvents(
@@ -173,17 +173,17 @@ class _view extends \IPS\Dispatcher\Controller
}
/* If there are no events, tell search engines not to index the page but do NOT tell them not to follow links */
if( count($events) === 0 )
if( \count($events) === 0 )
{
\IPS\Output::i()->metaTags['robots'] = 'noindex';
}
/* Display */
$output = \IPS\Theme::i()->getTemplate( 'browse' )->calendarMonth( $calendars, $date, $featured, $birthdays, $events, $this->_today, $this->_calendar, $jump );
$output = \IPS\Theme::i()->getTemplate( 'browse' )->calendarMonth( $this->roots, $date, $featured, $birthdays, $events, $this->_today, $this->_calendar, $jump );
if( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->sendOutput( $output, 200, 'text/html', \IPS\Output::i()->httpHeaders );
\IPS\Output::i()->sendOutput( $output, 200, 'text/html' );
}
else
{
@@ -191,7 +191,7 @@ class _view extends \IPS\Dispatcher\Controller
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->calendarWrapper(
$output,
$calendars,
$this->roots,
$this->_calendar,
$jump,
$date,
@@ -210,9 +210,6 @@ class _view extends \IPS\Dispatcher\Controller
*/
protected function _viewWeek( $jump, $featured=array() )
{
/* Get the calendars we can view */
$calendars = \IPS\Settings::i()->club_nodes_in_apps ? \IPS\calendar\Calendar::rootsWithClubs() : \IPS\calendar\Calendar::roots();
/* Get the month data */
$week = \IPS\Request::i()->w ? explode( '-', \IPS\Request::i()->w ) : NULL;
try
@@ -238,7 +235,7 @@ class _view extends \IPS\Dispatcher\Controller
}
/* Get birthdays */
$birthdays = ( $this->_calendar === NULL OR count( $calendars ) == 1 ) ? $date->getBirthdays( FALSE, TRUE ) : array();
$birthdays = ( $this->_calendar === NULL OR \count( $this->roots ) == 1 ) ? $date->getBirthdays( FALSE, TRUE ) : array();
/* Get the events within this range */
$events = \IPS\calendar\Event::retrieveEvents(
@@ -253,17 +250,17 @@ class _view extends \IPS\Dispatcher\Controller
}
/* If there are no events, tell search engines not to index the page but do NOT tell them not to follow links */
if( count( $events ) === 0 )
if( \count( $events ) === 0 )
{
\IPS\Output::i()->metaTags['robots'] = 'noindex';
}
/* Display */
$output = \IPS\Theme::i()->getTemplate( 'browse' )->calendarWeek( $calendars, $date, $featured, $birthdays, $events, $nextWeek, $lastWeek, $days, $this->_today, $this->_calendar, $jump );
$output = \IPS\Theme::i()->getTemplate( 'browse' )->calendarWeek( $this->roots, $date, $featured, $birthdays, $events, $nextWeek, $lastWeek, $days, $this->_today, $this->_calendar, $jump );
if( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->sendOutput( $output, 200, 'text/html', \IPS\Output::i()->httpHeaders );
\IPS\Output::i()->sendOutput( $output, 200, 'text/html' );
}
else
{
@@ -278,7 +275,7 @@ class _view extends \IPS\Dispatcher\Controller
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->calendarWrapper(
$output,
$calendars,
$this->roots,
$this->_calendar,
$jump,
$date,
@@ -297,9 +294,6 @@ class _view extends \IPS\Dispatcher\Controller
*/
protected function _viewDay( $jump, $featured=array() )
{
/* Get the calendars we can view */
$calendars = \IPS\Settings::i()->club_nodes_in_apps ? \IPS\calendar\Calendar::rootsWithClubs() : \IPS\calendar\Calendar::roots();
/* Get the month data */
try
{
@@ -310,8 +304,8 @@ class _view extends \IPS\Dispatcher\Controller
\IPS\Output::i()->error( 'error_bad_date', '2L182/9', 403, '' );
}
$tomorrow = $date->adjust( '+1 day' );
$yesterday = $date->adjust( '-1 day' );
$tomorrow = clone $date->adjust( '+1 day' );
$yesterday = clone $date->adjust( '-1 day' );
/* Get birthdays */
if( isset( \IPS\Request::i()->show ) AND \IPS\Request::i()->show == 'birthdays' AND \IPS\Settings::i()->show_bday_calendar )
@@ -327,14 +321,14 @@ class _view extends \IPS\Dispatcher\Controller
return;
}
$birthdayCount = ( $this->_calendar === NULL OR count( $calendars ) == 1 ) ? $date->getBirthdays( TRUE, TRUE ) : array();
$birthdays = ( $this->_calendar === NULL OR count( $calendars ) == 1 ) ? $date->getBirthdays( TRUE, FALSE ) : array();
$birthdayCount = ( $this->_calendar === NULL OR \count( $this->roots ) == 1 ) ? $date->getBirthdays( TRUE, TRUE ) : array();
$birthdays = ( $this->_calendar === NULL OR \count( $this->roots ) == 1 ) ? $date->getBirthdays( TRUE, FALSE ) : array();
/* Get the events within this range */
$events = \IPS\calendar\Event::retrieveEvents( $date, $date, $this->_calendar );
$events = \IPS\calendar\Event::retrieveEvents( clone $date, clone $date, $this->_calendar );
/* If there are no events, tell search engines not to index the page but do NOT tell them not to follow links */
if( count($events) === 0 )
if( \count($events) === 0 )
{
\IPS\Output::i()->metaTags['robots'] = 'noindex';
}
@@ -370,18 +364,18 @@ class _view extends \IPS\Dispatcher\Controller
}
/* Display */
$output = \IPS\Theme::i()->getTemplate( 'browse' )->calendarDay( $calendars, $date, $featured, $birthdays, $birthdayCount, $dayEvents, $tomorrow, $yesterday, $this->_today, $this->_calendar, $jump );
$output = \IPS\Theme::i()->getTemplate( 'browse' )->calendarDay( $this->roots, $date, $featured, $birthdays, $birthdayCount, $dayEvents, $tomorrow, $yesterday, $this->_today, $this->_calendar, $jump );
if( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->sendOutput( $output, 200, 'text/html', \IPS\Output::i()->httpHeaders );
\IPS\Output::i()->sendOutput( $output, 200, 'text/html' );
}
else
{
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('cal_month_day', FALSE, array( 'sprintf' => array( $date->monthName, $date->mday, $date->year ) ) );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->calendarWrapper(
$output,
$calendars,
$this->roots,
$this->_calendar,
$jump,
$date,
@@ -405,9 +399,6 @@ class _view extends \IPS\Dispatcher\Controller
*/
protected function _viewStream( $jump, $featured=array() )
{
/* Get the calendars we can view */
$calendars = \IPS\Settings::i()->club_nodes_in_apps ? \IPS\calendar\Calendar::rootsWithClubs() : \IPS\calendar\Calendar::roots();
/* Get the month data */
$day = NULL;
@@ -459,7 +450,7 @@ class _view extends \IPS\Dispatcher\Controller
/* Pagination */
$pagination = array(
'page' => ( isset( \IPS\Request::i()->page ) ) ? \IPS\Request::i()->page : 1,
'pages' => ( count( $events ) > 0 ) ? ceil( count( $events ) / $this->streamPerPage ) : 1,
'pages' => ( \count( $events ) > 0 ) ? ceil( \count( $events ) / $this->streamPerPage ) : 1,
'limit' => $this->streamPerPage
);
@@ -469,27 +460,27 @@ class _view extends \IPS\Dispatcher\Controller
}
/* If there are no events, tell search engines not to index the page but do NOT tell them not to follow links */
if( count( $events ) === 0 )
if( \count( $events ) === 0 )
{
\IPS\Output::i()->metaTags['robots'] = 'noindex';
}
else
{
$events = array_slice( $events, ( $pagination['page'] - 1 ) * $this->streamPerPage, $this->streamPerPage );
$events = \array_slice( $events, ( $pagination['page'] - 1 ) * $this->streamPerPage, $this->streamPerPage );
}
/* Non-existent page */
if( $pagination['page'] > 1 AND !count( $events ) )
if( $pagination['page'] > 1 AND !\count( $events ) )
{
\IPS\Output::i()->error( 'no_events_month', '2L182/B', 404, '' );
}
/* Display */
$output = \IPS\Theme::i()->getTemplate( 'browse' )->calendarStream( $calendars, $date, $featured, $events, $this->_calendar, $jump, $pagination );
$output = \IPS\Theme::i()->getTemplate( 'browse' )->calendarStream( $this->roots, $date, $featured, $events, $this->_calendar, $jump, $pagination );
if( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->sendOutput( $output, 200, 'text/html', \IPS\Output::i()->httpHeaders );
\IPS\Output::i()->sendOutput( $output, 200, 'text/html' );
}
else
{
@@ -499,7 +490,7 @@ class _view extends \IPS\Dispatcher\Controller
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'cal_month_stream_title', FALSE, array( 'sprintf' => array( $date->monthName, $date->year ) ) );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->calendarWrapper(
$output,
$calendars,
$this->roots,
$this->_calendar,
$jump,
$date,