Version 4.2.0

This commit is contained in:
Neo committed 2025-12-19 05:44:59 -08:00
1 parent 0dc2aee5ed
commit 96997ddd8e
2074 files changed
+125454 -55780

No files matched your search

@@ -1,13 +1,12 @@
<?php
/**
* @brief Calendars
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Calendar
* @since 18 Dec 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\calendar\modules\admin\calendars;
@@ -1,13 +1,12 @@
<?php
/**
* @brief iCalendar feed management
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Calendar
* @since 19 Dec 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\calendar\modules\admin\calendars;
@@ -130,25 +129,25 @@ class _ical extends \IPS\Dispatcher\Controller
/* Root buttons */
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'calendar', 'calendars', 'calendar_feeds_add' ) )
{
$table->rootButtons = array(
'add' => array(
'icon' => 'plus',
'title' => 'calendar_feeds_add',
'link' => \IPS\Http\Url::internal( 'app=calendar&module=calendars&controller=ical&do=add' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('calendar_feeds_add') )
),
'upload' => array(
'icon' => 'upload',
'title' => 'calendar_feeds_upload',
'link' => \IPS\Http\Url::internal( 'app=calendar&module=calendars&controller=ical&do=upload' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('calendar_feeds_upload') )
),
\IPS\Output::i()->sidebar['actions']['add'] = array(
'primary' => true,
'icon' => 'plus',
'title' => 'calendar_feeds_add',
'link' => \IPS\Http\Url::internal( 'app=calendar&module=calendars&controller=ical&do=add' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('calendar_feeds_add') )
);
\IPS\Output::i()->sidebar['actions']['upload'] = array(
'icon' => 'upload',
'title' => 'calendar_feeds_upload',
'link' => \IPS\Http\Url::internal( 'app=calendar&module=calendars&controller=ical&do=upload' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('calendar_feeds_upload') )
);
}
/* Display */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('ical_title');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( 'title', (string) $table );
\IPS\Output::i()->output = (string) $table;
}
/**
@@ -169,6 +168,10 @@ class _ical extends \IPS\Dispatcher\Controller
$form->add( new \IPS\Helpers\Form\Text( 'feed_title', NULL, TRUE ) );
$form->add( new \IPS\Helpers\Form\Url( 'feed_url', NULL, TRUE, array( 'allowedProtocols' => array( 'http', 'https', 'webcal', 'webcals' ) ) ) );
$form->add( new \IPS\Helpers\Form\Node( 'feed_calendar_id', NULL, TRUE, array( 'class' => 'IPS\calendar\Calendar', 'url' => \IPS\Http\Url::internal( 'app=calendar&module=calendars&controller=ical&do=add', 'admin' ) ) ) );
if( \IPS\Settings::i()->calendar_venues_enabled )
{
$form->add( new \IPS\Helpers\Form\Node( 'feed_venue_id', NULL, FALSE, array( 'class' => 'IPS\calendar\Venue', 'url' => \IPS\Http\Url::internal( 'app=calendar&module=calendars&controller=ical&do=add', 'admin' ) ) ) );
}
$form->add( new \IPS\Helpers\Form\Member( 'feed_member_id', NULL, TRUE, array() ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'feed_allow_rsvp', NULL, FALSE ) );
@@ -194,6 +197,12 @@ class _ical extends \IPS\Dispatcher\Controller
$feed->title = $values['feed_title'];
$feed->url = $values['feed_url'];
$feed->calendar_id = $values['feed_calendar_id']->_id;
if( \IPS\Settings::i()->calendar_venues_enabled )
{
$feed->venue_id = $values['feed_venue_id']->_id;
}
$feed->member_id = $values['feed_member_id']->member_id;
$feed->allow_rsvp = $values['feed_allow_rsvp'];
$feed->save();
@@ -230,6 +239,13 @@ class _ical extends \IPS\Dispatcher\Controller
'url' => \IPS\Http\Url::internal( 'app=calendar&module=calendars&controller=ical&do=upload' ),
'class' => 'IPS\calendar\Calendar',
) ) );
if( \IPS\Settings::i()->calendar_venues_enabled )
{
$form->add( new \IPS\Helpers\Form\Node( 'feed_venue_id', NULL, TRUE, array(
'url' => \IPS\Http\Url::internal( 'app=calendar&module=calendars&controller=ical&do=upload' ),
'class' => 'IPS\calendar\Venue',
) ) );
}
$form->add( new \IPS\Helpers\Form\Member( 'feed_member_id', NULL, TRUE ) );
/* Handle submissions */
@@ -239,7 +255,7 @@ 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'] );
$count = $icsParser->parse( \file_get_contents( $values['feed_file'] ), $values['feed_calendar_id'], $values['feed_member_id'], $values['feed_venue_id'] );
}
catch( \UnexpectedValueException $e )
{
@@ -290,6 +306,12 @@ class _ical extends \IPS\Dispatcher\Controller
}
$form->add( new \IPS\Helpers\Form\Select( 'feed_calendar_id', $feed->calendar_id, TRUE, array( 'options' => $options, 'parse' => 'normal' ) ) );
if( \IPS\Settings::i()->calendar_venues_enabled )
{
$form->add( new \IPS\Helpers\Form\Node( 'feed_venue_id', NULL, FALSE, array( 'class' => 'IPS\calendar\Venue', 'url' => \IPS\Http\Url::internal( 'app=calendar&module=calendars&controller=ical&do=edit', 'admin' ) ) ) );
}
$form->add( new \IPS\Helpers\Form\Member( 'feed_member_id', \IPS\Member::load( $feed->member_id )->name, TRUE ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'feed_allow_rsvp', $feed->allow_rsvp, FALSE ) );
@@ -314,6 +336,12 @@ class _ical extends \IPS\Dispatcher\Controller
$feed->title = $values['feed_title'];
$feed->url = $values['feed_url'];
$feed->calendar_id = $values['feed_calendar_id'];
if( \IPS\Settings::i()->calendar_venues_enabled )
{
$feed->venue_id = $values['feed_venue_id']->_id;
}
$feed->member_id = $values['feed_member_id']->member_id;
$feed->allow_rsvp = $values['feed_allow_rsvp'];
$feed->save();
@@ -1,13 +1,12 @@
<?php
/**
* @brief Settings
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Calendar
* @since 18 Dec 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\calendar\modules\admin\calendars;
@@ -57,6 +56,8 @@ class _settings extends \IPS\Dispatcher\Controller
$form->add( new \IPS\Helpers\Form\YesNo( 'calendar_rss_feed', \IPS\Settings::i()->calendar_rss_feed, FALSE, array( 'togglesOn' => array( 'calendar_rss_feed_days' ) ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'calendar_rss_feed_days', \IPS\Settings::i()->calendar_rss_feed_days, FALSE, array( 'unlimited' => -1 ), NULL, NULL, NULL, 'calendar_rss_feed_days' ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'calendar_venues_enabled', \IPS\Settings::i()->calendar_venues_enabled ) );
if ( $values = $form->values() )
{
if( $values['calendar_date_format'] == -1 AND !$values['calendar_date_format_custom'] )
@@ -0,0 +1,41 @@
<?php
/**
* @brief venues
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Calendar
* @since 24 Feb 2017
*/
namespace IPS\calendar\modules\admin\calendars;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* venues
*/
class _venues extends \IPS\Node\Controller
{
/**
* Node Class
*/
protected $nodeClass = '\IPS\calendar\Venue';
/**
* Execute
*
* @return void
*/
public function execute()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'venues_manage' );
parent::execute();
}
}
@@ -1,13 +1,12 @@
<?php
/**
* @brief View Event Controller
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Calendar
* @since 14 Jan 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\calendar\modules\front\calendar;
@@ -106,17 +105,136 @@ class _event extends \IPS\Content\Controller
/* Online User Location */
\IPS\Session::i()->setLocation( $this->event->url(), $this->event->onlineListPermissions(), 'loc_calendar_viewing_event', array( $this->event->title => FALSE ) );
/* Reminder */
$reminder = NULL;
try
{
$reminder = \IPS\Db::i()->select( '*', 'calendar_event_reminders', array( 'reminder_event_id=? and reminder_member_id=?', $this->event->id, (int) \IPS\Member::loggedIn()->member_id ) )->first();
}
catch ( \UnderflowException $e ) {}
/* Address */
$address = NULL;
if ( $this->event->location )
$location = NULL;
$addressName = NULL;
if ( \IPS\Settings::i()->calendar_venues_enabled and $this->event->venue() )
{
$address = \IPS\GeoLocation::buildFromjson( $this->event->location )->toString();
$location = \IPS\GeoLocation::buildFromjson( $this->event->venue()->address );
$address = $location->toString();
$addressName = $this->event->venue()->_title;
}
else if ( $this->event->location )
{
$location = \IPS\GeoLocation::buildFromjson( $this->event->location );
$address = $location->toString();
}
/* Add JSON-LD */
\IPS\Output::i()->jsonLd['event'] = array(
'@context' => "http://schema.org",
'@type' => "Event",
'url' => (string) $this->event->url(),
'name' => htmlspecialchars( $this->event->mapped('title'), ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'description' => strip_tags( $this->event->truncated() ),
'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 )
);
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 );
}
if( $this->event->container()->allow_reviews )
{
\IPS\Output::i()->jsonLd['event']['aggregateRating'] = array(
'@type' => 'AggregateRating',
'reviewCount' => $this->event->reviews,
'ratingValue' => $this->event->averageReviewRating(),
'bestRating' => \IPS\Settings::i()->reviews_rating_out_of,
);
\IPS\Output::i()->jsonLd['event']['interactionStatistic'][] = array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/ReviewAction",
'userInteractionCount' => $this->event->reviews
);
}
if( $this->event->container()->allow_comments )
{
\IPS\Output::i()->jsonLd['event']['interactionStatistic'][] = array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/CommentAction",
'userInteractionCount' => $this->event->mapped('num_comments')
);
\IPS\Output::i()->jsonLd['event']['commentCount'] = $this->event->mapped('num_comments');
}
if( $this->event->coverPhoto()->file )
{
\IPS\Output::i()->jsonLd['event']['image'] = (string) $this->event->coverPhoto()->file->url;
}
if( $this->event->rsvp )
{
\IPS\Output::i()->jsonLd['event']['potentialAction'] = array(
'@type' => 'RsvpAction',
'target' => (string) $this->event->url( 'rsvp' )->setQueryString( 'action', '{rsvpResponse}' ),
'rsvpResponse-input' => "required name=rsvpResponse"
);
if( count( $attendees[1] ) )
{
\IPS\Output::i()->jsonLd['event']['attendee'] = array();
foreach( $attendees[1] as $attendee )
{
\IPS\Output::i()->jsonLd['event']['attendee'][] = array(
'@type' => 'Person',
'name' => htmlspecialchars( $attendee->name, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE )
);
}
}
}
if( $location )
{
\IPS\Output::i()->jsonLd['event']['location'] = array(
'@type' => 'Place',
'address' => array(
'@type' => 'PostalAddress',
'streetAddress' => implode( ', ', $location->addressLines ),
'addressLocality' => $location->city,
'addressRegion' => $location->region,
'postalCode' => $location->postalCode,
'addressCountry' => $location->country,
)
);
if( $addressName )
{
\IPS\Output::i()->jsonLd['event']['location']['name'] = $addressName;
}
}
else
{
\IPS\Output::i()->jsonLd['event']['location'] = array(
'@type' => 'Place',
'name' => \IPS\Settings::i()->board_name,
'address' => \IPS\Output::i()->jsonLd['event']['url'],
'url' => \IPS\Output::i()->jsonLd['event']['url']
);
}
/* Display */
//\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate( 'view' )->eventSidebar( $this->event, $attendees );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'view' )->view( $this->event, $commentsAndReviews, $attendees, $address );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'view' )->view( $this->event, $commentsAndReviews, $attendees, $address, $reminder );
}
/**
@@ -263,4 +381,116 @@ class _event extends \IPS\Content\Controller
return parent::edit();
}
/**
* Set a reminder
*
* @return void
*/
protected function setReminder()
{
\IPS\Session::i()->csrfCheck();
/* Existing reminder? */
$existing = NULL;
try
{
$existing = \IPS\Db::i()->select( '*', 'calendar_event_reminders', array( 'reminder_event_id=? and reminder_member_id=?', $this->event->id, (int) \IPS\Member::loggedIn()->member_id ) )->first();
}
catch ( \UnderflowException $e ) {}
/* Build the form */
/* How far in the future is this event so we can set realistic max reminders */
$diff = $this->event->_start_date->diff( \IPS\DateTime::create() );
$max = $diff->d;
$form = new \IPS\Helpers\Form;
$form->class = 'ipsForm_vertical';
$form->add( new \IPS\Helpers\Form\Number( 'event_remind_me', isset( $existing ) ? $existing['reminder_days_before'] : ( ( $max < 3 ) ? $max : 3 ), TRUE, array( 'min' => 1, 'max' => (int) $max ), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('event_remind_days_before'), 'event_remind_me' ) );
if ( $existing )
{
$form->addButton( 'event_dont_remind', 'link', \IPS\Http\Url::internal( "app=calendar&module=calendar&controller=event&do=removeReminder&action=remove&id={$this->event->id}")->csrf(), 'ipsButton ipsButton_negative ipsPos_right', array('data-action' => 'removereminder') );
}
if( $values = $form->values() )
{
/* Delete existing */
\IPS\Db::i()->delete( 'calendar_event_reminders', array( 'reminder_event_id=? AND reminder_member_id=?', $this->event->id, (int) \IPS\Member::loggedIn()->member_id ) );
\IPS\Db::i()->insert( 'calendar_event_reminders', array(
'reminder_event_id' => $this->event->id,
'reminder_member_id' => (int) \IPS\Member::loggedIn()->member_id,
'reminder_date' => $this->event->_start_date->sub( new \DateInterval( 'P' . (int) $values['event_remind_me'] . 'D' ) )->getTimestamp(),
'reminder_days_before' => (int) $values['event_remind_me'],
) );
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => 1 ), array( '`key`=?', 'eventreminders' ) );
$message = 'event_reminder_added';
\IPS\Output::i()->redirect( $this->event->url(), $message );
}
/* 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' ) );
if( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->sendOutput( $output, 200, 'text/html', \IPS\Output::i()->httpHeaders );
}
else
{
\IPS\Output::i()->output = $output;
}
}
/**
* Remve Reminder
*
* @return void
*/
protected function removeReminder()
{
\IPS\Session::i()->csrfCheck();
if ( \IPS\Request::i()->action == 'remove' )
{
/* Delete existing */
\IPS\Db::i()->delete( 'calendar_event_reminders', array( 'reminder_event_id=? AND reminder_member_id=?', $this->event->id, (int) \IPS\Member::loggedIn()->member_id ) );
$message = 'event_reminder_removed';
}
if ( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->json( 'ok' );
}
else
{
\IPS\Output::i()->redirect( $this->event->url(), $message );
}
}
/**
* Reminder button
*
* @return void
*/
protected function reminderButton()
{
/* Existing reminder? */
$existing = NULL;
try
{
$existing = \IPS\Db::i()->select( '*', 'calendar_event_reminders', array( 'reminder_event_id=? and reminder_member_id=?', $this->event->id, (int)\IPS\Member::loggedIn()->member_id ) )->first();
}
catch ( \UnderflowException $e )
{
}
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'view', 'calendar', 'front' )->reminderButton( $this->event, $existing ) );
}
}
@@ -1,13 +1,12 @@
<?php
/**
* @brief Submit Event Controller
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Calendar
* @since 8 Jan 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\calendar\modules\front\calendar;
@@ -48,6 +47,12 @@ class _submit extends \IPS\Dispatcher\Controller
$form->hiddenValues['d'] = \IPS\Request::i()->d;
}
/* Are we coming from a venue? */
if( \IPS\Settings::i()->calendar_venues_enabled and \IPS\Request::i()->venue )
{
$form->hiddenValues['venue'] = \IPS\Request::i()->venue;
}
if ( $values = $form->values() )
{
$url = \IPS\Http\Url::internal( 'app=calendar&module=calendar&controller=submit&do=submit', 'front', 'calendar_submit' )->setQueryString( 'id', $values['calendar']->_id );
@@ -57,6 +62,11 @@ class _submit extends \IPS\Dispatcher\Controller
$url = $url->setQueryString( 'd', $values['d'] )->setQueryString( 'm', $values['m'] )->setQueryString( 'y', $values['y'] );
}
if( \IPS\Settings::i()->calendar_venues_enabled and isset( $values['venue'] ) )
{
$url = $url->setQueryString( 'venue', $values['venue'] );
}
\IPS\Output::i()->redirect( $url );
}
@@ -74,10 +84,26 @@ class _submit extends \IPS\Dispatcher\Controller
*/
protected function submit()
{
$calendar = NULL;
$club = NULL;
try
{
$calendar = \IPS\calendar\Calendar::loadAndCheckPerms( \IPS\Request::i()->id );
if ( $club = $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( $calendar->url(), $calendar->_title );
if ( \IPS\Settings::i()->clubs_header == 'sidebar' )
{
\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate( 'clubs', 'core' )->header( $club, $calendar, 'sidebar' );
}
}
}
catch ( \OutOfRangeException $e )
{
@@ -86,7 +112,7 @@ 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\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() ) )
{
@@ -95,8 +121,90 @@ class _submit extends \IPS\Dispatcher\Controller
/* Display */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'submit_event' );
\IPS\Output::i()->sidebar['enabled'] = FALSE;
\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' ) );
}
/**
* Copy Event
*
* @return void
*/
protected function copy()
{
try
{
$existing = \IPS\calendar\Event::loadAndCheckPerms( \IPS\Request::i()->event_id );
}
catch ( \OutOfRangeException $e )
{
\IPS\Output::i()->redirect( IPS\Http\Url::internal( 'app=calendar&module=calendar&controller=submit', 'front', 'calendar_submit' ) );
}
/* Are we the author of the existing event? */
if( $existing->author() !== \IPS\Member::loggedIn() )
{
\IPS\Output::i()->redirect( IPS\Http\Url::internal( 'app=calendar&module=calendar&controller=submit', 'front', 'calendar_submit' ) );
}
/* Reset elements we don't want to copy */
$existing->start_date = NULL;
$existing->end_date = NULL;
$form = new \IPS\Helpers\Form( 'form', \IPS\Member::loggedIn()->language()->checkKeyExists( \IPS\Calendar\Event::$formLangPrefix . '_save' ) ? \IPS\Calendar\Event::$formLangPrefix . '_save' : 'save' );
$form->class = 'ipsForm_vertical';
$formElements = \IPS\Calendar\Event::formElements( $existing, $existing->container() );
foreach ( $formElements as $key => $object )
{
if ( is_object( $object ) )
{
$form->add( $object );
}
else
{
$form->addMessage( $object, NULL, FALSE, $key );
}
}
if ( $values = $form->values() )
{
/* Disable read/write separation */
\IPS\Db::i()->readWriteSeparation = FALSE;
try
{
$obj = \IPS\calendar\Event::createFromForm( $values );
if ( !\IPS\Member::loggedIn()->member_id and $obj->hidden() )
{
\IPS\Output::i()->redirect( $obj->container()->url(), 'mod_queue_message' );
}
else if ( $obj->hidden() == 1 )
{
\IPS\Output::i()->redirect( $obj->url(), 'mod_queue_message' );
}
else
{
\IPS\Output::i()->redirect( $obj->url() );
}
}
catch ( \DomainException $e )
{
$form->error = $e->getMessage();
}
}
\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 ) ) );
if ( \IPS\calendar\Event::moderateNewItems( \IPS\Member::loggedIn() ) )
{
\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;
}
/* Display */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('copy_cal_event_header', TRUE, array( 'sprintf' => $existing->title ) );
\IPS\Output::i()->sidebar['enabled'] = FALSE;
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->addToStack('copy_cal_event_header', TRUE, array( 'sprintf' => $existing->title ) ) );
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_submit.js', 'calendar', 'front' ) );
}
}
@@ -0,0 +1,122 @@
<?php
/**
* @brief Venue
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Calendar
* @since 27 Feb 2017
*/
namespace IPS\calendar\modules\front\calendar;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* venue
*/
class _venue extends \IPS\Dispatcher\Controller
{
/**
* @brief Venue we are viewing
*/
protected $venue = NULL;
/**
* Init
*
* @return void
*/
public function execute()
{
try
{
$this->venue = \IPS\calendar\Venue::loadAndCheckPerms( \IPS\Request::i()->id );
}
catch ( \OutOfRangeException $e )
{
\IPS\Output::i()->error( 'node_error', '2L354/1', 404, '' );
}
parent::execute();
}
/**
* Manage
*
* @return void
*/
public function manage()
{
/* Load the css for Calendar badges */
\IPS\calendar\Calendar::addCss();
$today = \IPS\calendar\Date::getDate();
/* Get the month data */
$day = NULL;
if( ( !\IPS\Request::i()->y OR \IPS\Request::i()->y == $today->year ) AND ( !\IPS\Request::i()->m OR \IPS\Request::i()->m == $today->mon ) )
{
$day = $today->mday;
}
try
{
$date = \IPS\calendar\Date::getDate( \IPS\Request::i()->y ?: NULL, \IPS\Request::i()->m ?: NULL, $day );
}
catch( \InvalidArgumentException $e )
{
\IPS\Output::i()->error( 'error_bad_date', '', 403, '' ); //@todo
}
$upcoming = \IPS\calendar\Event::retrieveEvents(
\IPS\calendar\Date::getDate( $date->firstDayOfMonth('year'), $date->firstDayOfMonth('mon'), $date->firstDayOfMonth('mday') ),
\IPS\calendar\Date::getDate( $date->lastDayOfMonth('year'), $date->lastDayOfMonth('mon'), $date->lastDayOfMonth('mday'), 23, 59, 59 ),
NULL,
NULL,
FALSE,
NULL,
$this->venue
);
$upcomingOutput = \IPS\Theme::i()->getTemplate( 'venue', 'calendar', 'front' )->upcomingStream( $date, $upcoming, $this->venue );
/* Address */
$address = NULL;
if ( $this->venue->address )
{
$address = \IPS\GeoLocation::buildFromjson( $this->venue->address )->toString();
}
/* Display */
if( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->sendOutput( $upcomingOutput, 200, 'text/html', \IPS\Output::i()->httpHeaders );
}
else
{
/* Add JSON-LD */
\IPS\Output::i()->jsonLd['eventVenue'] = array(
'@context' => "http://schema.org",
'@type' => "EventVenue",
'url' => (string) $this->venue->url(),
'name' => htmlspecialchars( $this->venue->_title, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE )
);
\IPS\Output::i()->title = $this->venue->_title;
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_venue.js', 'calendar', 'front' ) );
/* 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') );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'venue', 'calendar', 'front' )->view( $this->venue, $upcomingOutput, NULL, $address );
}
}
}
@@ -1,13 +1,12 @@
<?php
/**
* @brief Calendar Views
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Calendar
* @since 23 Dec 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\calendar\modules\front\calendar;
@@ -71,6 +70,20 @@ class _view extends \IPS\Dispatcher\Controller
{
\IPS\Output::i()->error( 'node_error', '2L182/2', 404, '' );
}
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 );
if ( \IPS\Settings::i()->clubs_header == 'sidebar' )
{
\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate( 'clubs', 'core' )->header( $club, $this->_calendar, 'sidebar' );
}
}
}
if( $this->_calendar !== NULL AND $this->_calendar->_id )
@@ -138,22 +151,22 @@ class _view extends \IPS\Dispatcher\Controller
try
{
$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();
/* Get the events within this range */
$events = \IPS\calendar\Event::retrieveEvents(
\IPS\calendar\Date::getDate( $date->firstDayOfMonth('year'), $date->firstDayOfMonth('mon'), $date->firstDayOfMonth('mday') ),
\IPS\calendar\Date::getDate( $date->lastDayOfMonth('year'), $date->lastDayOfMonth('mon'), $date->lastDayOfMonth('mday'), 23, 59, 59 ),
$this->_calendar
);
}
catch( \Exception $e )
{
\IPS\Output::i()->error( 'error_bad_date', '3L182/3', 403, '' );
}
/* Get birthdays */
$birthdays = ( $this->_calendar === NULL OR count( $calendars ) == 1 ) ? $date->getBirthdays( FALSE, TRUE ) : array();
/* Get the events within this range */
$events = \IPS\calendar\Event::retrieveEvents(
\IPS\calendar\Date::getDate( $date->firstDayOfMonth('year'), $date->firstDayOfMonth('mon'), $date->firstDayOfMonth('mday') ),
\IPS\calendar\Date::getDate( $date->lastDayOfMonth('year'), $date->lastDayOfMonth('mon'), $date->lastDayOfMonth('mday'), 23, 59, 59 ),
$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 )
{
@@ -161,7 +174,6 @@ class _view extends \IPS\Dispatcher\Controller
}
/* Display */
/* @see http://community.invisionpower.com/4bugtrack/follow-button-adds-meta-title-and-link-tags-r3209/ */
$output = \IPS\Theme::i()->getTemplate( 'browse' )->calendarMonth( $calendars, $date, $featured, $birthdays, $events, $this->_today, $this->_calendar, $jump );
if( \IPS\Request::i()->isAjax() )
@@ -236,7 +248,6 @@ class _view extends \IPS\Dispatcher\Controller
}
/* Display */
/* @see http://community.invisionpower.com/4bugtrack/follow-button-adds-meta-title-and-link-tags-r3209/ */
$output = \IPS\Theme::i()->getTemplate( 'browse' )->calendarWeek( $calendars, $date, $featured, $birthdays, $events, $nextWeek, $lastWeek, $days, $this->_today, $this->_calendar, $jump );
if( \IPS\Request::i()->isAjax() )
@@ -347,7 +358,6 @@ class _view extends \IPS\Dispatcher\Controller
}
/* Display */
/* @see http://community.invisionpower.com/4bugtrack/follow-button-adds-meta-title-and-link-tags-r3209/ */
$output = \IPS\Theme::i()->getTemplate( 'browse' )->calendarDay( $calendars, $date, $featured, $birthdays, $birthdayCount, $dayEvents, $tomorrow, $yesterday, $this->_today, $this->_calendar, $jump );
if( \IPS\Request::i()->isAjax() )
@@ -412,6 +422,28 @@ class _view extends \IPS\Dispatcher\Controller
FALSE
);
/* Sort */
$startDate = \IPS\calendar\Date::getDate();
@usort( $events, function( $a, $b ) use ( $startDate )
{
if( $a->nextOccurrence( $startDate, 'startDate' ) === NULL )
{
return -1;
}
if( $b->nextOccurrence( $startDate, 'startDate' ) === NULL )
{
return 1;
}
if ( $a->nextOccurrence( $startDate, 'startDate' )->mysqlDatetime() == $b->nextOccurrence( $startDate, 'startDate' )->mysqlDatetime() )
{
return 0;
}
return ( $a->nextOccurrence( $startDate, 'startDate' )->mysqlDatetime() < $b->nextOccurrence( $startDate, 'startDate' )->mysqlDatetime() ) ? -1 : 1;
} );
/* Pagination */
$pagination = array(
'page' => ( isset( \IPS\Request::i()->page ) ) ? \IPS\Request::i()->page : 1,
@@ -435,7 +467,6 @@ class _view extends \IPS\Dispatcher\Controller
}
/* Display */
/* @see http://community.invisionpower.com/4bugtrack/follow-button-adds-meta-title-and-link-tags-r3209/ */
$output = \IPS\Theme::i()->getTemplate( 'browse' )->calendarStream( $calendars, $date, $featured, $events, $this->_calendar, $jump, $pagination );
if( \IPS\Request::i()->isAjax() )
@@ -444,6 +475,9 @@ class _view extends \IPS\Dispatcher\Controller
}
else
{
/* We can show the sidebar in stream view */
\IPS\Output::i()->sidebar['enabled'] = TRUE;
\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,