Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -12,35 +12,43 @@
|
||||
namespace IPS\calendar\modules\admin\calendars;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Member;
|
||||
use IPS\Node\Controller;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calendars
|
||||
*/
|
||||
class _calendars extends \IPS\Node\Controller
|
||||
class calendars extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = 'IPS\calendar\Calendar';
|
||||
protected string $nodeClass = 'IPS\calendar\Calendar';
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'calendars_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'calendars_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -49,17 +57,17 @@ class _calendars extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function form()
|
||||
protected function form() : void
|
||||
{
|
||||
parent::form();
|
||||
|
||||
if ( \IPS\Request::i()->id )
|
||||
if ( Request::i()->id )
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('edit_calendar') . ': ' . \IPS\Output::i()->title;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('edit_calendar') . ': ' . Output::i()->title;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('add_calendar');
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('add_calendar');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,30 +12,59 @@
|
||||
namespace IPS\calendar\modules\admin\calendars;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use IPS\calendar\Calendar;
|
||||
use IPS\calendar\Icalendar;
|
||||
use IPS\calendar\Icalendar\ICSParser;
|
||||
use IPS\DateTime;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Node;
|
||||
use IPS\Helpers\Form\Text;
|
||||
use IPS\Helpers\Form\Upload;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\Helpers\Table\Db;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use UnexpectedValueException;
|
||||
use function defined;
|
||||
use function file_get_contents;
|
||||
use const IPS\Helpers\Table\SEARCH_CONTAINS_TEXT;
|
||||
use const IPS\Helpers\Table\SEARCH_DATE_RANGE;
|
||||
use const IPS\Helpers\Table\SEARCH_NODE;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* iCalendar feed management
|
||||
*/
|
||||
class _ical extends \IPS\Dispatcher\Controller
|
||||
class ical extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'calendar_feeds_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'calendar_feeds_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -44,10 +73,10 @@ class _ical extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
/* Create the table */
|
||||
$table = new \IPS\Helpers\Table\Db( 'calendar_import_feeds', \IPS\Http\Url::internal( 'app=calendar&module=calendars&controller=ical' ) );
|
||||
$table = new Db( 'calendar_import_feeds', Url::internal( 'app=calendar&module=calendars&controller=ical' ) );
|
||||
$table->langPrefix = 'ical_';
|
||||
|
||||
/* Column stuff */
|
||||
@@ -61,37 +90,37 @@ class _ical extends \IPS\Dispatcher\Controller
|
||||
/* Search */
|
||||
$table->quickSearch = 'feed_title';
|
||||
$table->advancedSearch = array(
|
||||
'feed_title' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
|
||||
'feed_url' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
|
||||
'feed_calendar_id' => array( \IPS\Helpers\Table\SEARCH_NODE, array(
|
||||
'feed_title' => SEARCH_CONTAINS_TEXT,
|
||||
'feed_url' => SEARCH_CONTAINS_TEXT,
|
||||
'feed_calendar_id' => array( SEARCH_NODE, array(
|
||||
'class' => '\IPS\calendar\Calendar',
|
||||
'zeroVal' => 'any'
|
||||
) ),
|
||||
'feed_added' => \IPS\Helpers\Table\SEARCH_DATE_RANGE,
|
||||
'feed_lastupdated' => \IPS\Helpers\Table\SEARCH_DATE_RANGE,
|
||||
'feed_added' => SEARCH_DATE_RANGE,
|
||||
'feed_lastupdated' => SEARCH_DATE_RANGE,
|
||||
);
|
||||
|
||||
/* Formatters */
|
||||
$table->parsers = array(
|
||||
'feed_added' => function( $val, $row )
|
||||
'feed_added' => function( $val )
|
||||
{
|
||||
$date = \IPS\DateTime::ts( $val );
|
||||
$date = DateTime::ts( $val );
|
||||
|
||||
return $date->localeDate() . ' ' . $date->localeTime( FALSE ) ;
|
||||
},
|
||||
'feed_lastupdated' => function( $val, $row )
|
||||
'feed_lastupdated' => function( $val )
|
||||
{
|
||||
$date = \IPS\DateTime::ts( $val );
|
||||
$date = DateTime::ts( $val );
|
||||
|
||||
return $date->localeDate() . ' ' . $date->localeTime( FALSE ) ;
|
||||
},
|
||||
'feed_calendar_id' => function( $val, $row )
|
||||
'feed_calendar_id' => function( $val )
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\calendar\Calendar::load( $val )->_title;
|
||||
return Calendar::load( $val )->_title;
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
@@ -104,26 +133,26 @@ 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'] )->csrf(),
|
||||
'link' => Url::internal( 'app=calendar&module=calendars&controller=ical&do=refresh&id=' . $row['feed_id'] )->csrf(),
|
||||
'hotkey' => 'r'
|
||||
) );
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'calendar', 'calendars', 'calendar_feeds_edit' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'calendar', 'calendars', 'calendar_feeds_edit' ) )
|
||||
{
|
||||
$return['edit'] = array(
|
||||
'icon' => 'pencil',
|
||||
'title' => 'edit',
|
||||
'link' => \IPS\Http\Url::internal( 'app=calendar&module=calendars&controller=ical&do=edit&id=' ) . $row['feed_id'],
|
||||
'link' => Url::internal( 'app=calendar&module=calendars&controller=ical&do=edit&id=' ) . $row['feed_id'],
|
||||
'hotkey' => 'e'
|
||||
);
|
||||
}
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'calendar', 'calendars', 'calendar_feeds_delete' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'calendar', 'calendars', 'calendar_feeds_delete' ) )
|
||||
{
|
||||
$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'] )->csrf(),
|
||||
'link' => Url::internal( 'app=calendar&module=calendars&controller=ical&do=delete&id=' . $row['feed_id'] )->csrf(),
|
||||
'data' => array( 'delete' => '' ),
|
||||
);
|
||||
}
|
||||
@@ -132,27 +161,27 @@ class _ical extends \IPS\Dispatcher\Controller
|
||||
};
|
||||
|
||||
/* Root buttons */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'calendar', 'calendars', 'calendar_feeds_add' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'calendar', 'calendars', 'calendar_feeds_add' ) )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['actions']['add'] = array(
|
||||
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') )
|
||||
'link' => Url::internal( 'app=calendar&module=calendars&controller=ical&do=add' ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('calendar_feeds_add') )
|
||||
);
|
||||
|
||||
\IPS\Output::i()->sidebar['actions']['upload'] = array(
|
||||
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') )
|
||||
'link' => Url::internal( 'app=calendar&module=calendars&controller=ical&do=upload' ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('calendar_feeds_upload') )
|
||||
);
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('ical_title');
|
||||
\IPS\Output::i()->output = (string) $table;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('ical_title');
|
||||
Output::i()->output = (string) $table;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,25 +189,25 @@ class _ical extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add()
|
||||
public function add() : void
|
||||
{
|
||||
/* Check permissions */
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'calendar_feeds_add' );
|
||||
Dispatcher::i()->checkAcpPermission( 'calendar_feeds_add' );
|
||||
|
||||
/* Page title */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('calendar_feeds_add');
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('calendar_feeds_add');
|
||||
|
||||
/* Build the form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$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 = new Form;
|
||||
$form->add( new Text( 'feed_title', NULL, TRUE ) );
|
||||
$form->add( new Form\Url( 'feed_url', NULL, TRUE, array( 'allowedProtocols' => array( 'http', 'https', 'webcal', 'webcals' ) ) ) );
|
||||
$form->add( new Node( 'feed_calendar_id', NULL, TRUE, array( 'class' => 'IPS\calendar\Calendar', 'url' => Url::internal( 'app=calendar&module=calendars&controller=ical&do=add', 'admin' ) ) ) );
|
||||
if( 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 Node( 'feed_venue_id', NULL, FALSE, array( 'class' => 'IPS\calendar\Venue', 'url' => 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 ) );
|
||||
$form->add( new Form\Member( 'feed_member_id', NULL, TRUE, array() ) );
|
||||
$form->add( new YesNo( 'feed_allow_rsvp', NULL, FALSE ) );
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
@@ -187,23 +216,23 @@ class _ical extends \IPS\Dispatcher\Controller
|
||||
|
||||
try
|
||||
{
|
||||
\IPS\calendar\Icalendar\ICSParser::isValid( \IPS\Http\Url::external( str_replace( array( 'webcal://', 'webcals://' ), array( 'http://', 'https://' ), $values['feed_url'] ) )->request()->get() );
|
||||
ICSParser::isValid( Url::external( str_replace( array( 'webcal://', 'webcals://' ), array( 'http://', 'https://' ), $values['feed_url'] ) )->request()->get() );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
$form->error = ( $e instanceof \UnexpectedValueException ) ? \IPS\Member::loggedIn()->language()->addToStack('ical_error_' . $e->getMessage()) : $e->getMessage();
|
||||
$form->error = ( $e instanceof UnexpectedValueException ) ? Member::loggedIn()->language()->addToStack('ical_error_' . $e->getMessage()) : $e->getMessage();
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('global', 'core')->block('calendar_feeds_add', $form, FALSE);
|
||||
Output::i()->output = Theme::i()->getTemplate('global', 'core')->block('calendar_feeds_add', $form, FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Insert the new record */
|
||||
$feed = new \IPS\calendar\Icalendar;
|
||||
$feed = new Icalendar;
|
||||
$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 )
|
||||
if( Settings::i()->calendar_venues_enabled )
|
||||
{
|
||||
$feed->venue_id = $values['feed_venue_id']->_id;
|
||||
}
|
||||
@@ -213,16 +242,16 @@ class _ical extends \IPS\Dispatcher\Controller
|
||||
$feed->save();
|
||||
|
||||
/* Admin log */
|
||||
\IPS\Session::i()->log( 'acplog__icalfeed_created', array( $feed->title => FALSE ) );
|
||||
Session::i()->log( 'acplog__icalfeed_created', array( $feed->title => FALSE ) );
|
||||
|
||||
/* Grab the feed events */
|
||||
$feed->refresh();
|
||||
|
||||
/* Redirect */
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=calendar&module=calendars&controller=ical' ), 'saved' );
|
||||
Output::i()->redirect( Url::internal( 'app=calendar&module=calendars&controller=ical' ), 'saved' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( 'calendar_feeds_add', $form, FALSE );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global', 'core' )->block( 'calendar_feeds_add', $form, FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -230,28 +259,28 @@ class _ical extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function upload()
|
||||
public function upload() : void
|
||||
{
|
||||
/* Check permissions */
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'calendar_feeds_add' );
|
||||
Dispatcher::i()->checkAcpPermission( 'calendar_feeds_add' );
|
||||
|
||||
/* Build the form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Upload( 'feed_file', NULL, TRUE, array( 'temporary' => TRUE ) ) );
|
||||
$form = new Form;
|
||||
$form->add( new Upload( 'feed_file', NULL, TRUE, array( 'temporary' => TRUE ) ) );
|
||||
|
||||
/* Init */
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'feed_calendar_id', NULL, TRUE, array(
|
||||
'url' => \IPS\Http\Url::internal( 'app=calendar&module=calendars&controller=ical&do=upload' ),
|
||||
$form->add( new Node( 'feed_calendar_id', NULL, TRUE, array(
|
||||
'url' => Url::internal( 'app=calendar&module=calendars&controller=ical&do=upload' ),
|
||||
'class' => 'IPS\calendar\Calendar',
|
||||
) ) );
|
||||
if( \IPS\Settings::i()->calendar_venues_enabled )
|
||||
if( Settings::i()->calendar_venues_enabled )
|
||||
{
|
||||
$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' ),
|
||||
$form->add( new Node( 'feed_venue_id', NULL, FALSE, array(
|
||||
'url' => 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 ) );
|
||||
$form->add( new Form\Member( 'feed_member_id', NULL, TRUE ) );
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
@@ -259,24 +288,24 @@ class _ical extends \IPS\Dispatcher\Controller
|
||||
/* Import the events */
|
||||
try
|
||||
{
|
||||
$icsParser = new \IPS\calendar\Icalendar\ICSParser;
|
||||
$icsParser = new ICSParser;
|
||||
|
||||
$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 );
|
||||
$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 )
|
||||
catch( UnexpectedValueException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( $e->getMessage(), '1L169/4', 403, '' );
|
||||
Output::i()->error( $e->getMessage(), '1L169/4', 403, '' );
|
||||
}
|
||||
|
||||
/* Admin log */
|
||||
\IPS\Session::i()->log( 'acplog__ical_uploaded', array( $count['imported'] => FALSE, $count['skipped'] => FALSE ) );
|
||||
Session::i()->log( 'acplog__ical_uploaded', array( $count['imported'] => FALSE, $count['skipped'] => FALSE ) );
|
||||
|
||||
/* Redirect */
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=calendar&module=calendars&controller=ical' ), 'feed_uploaded' );
|
||||
Output::i()->redirect( Url::internal( 'app=calendar&module=calendars&controller=ical' ), 'feed_uploaded' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('calendar_feeds_add');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( 'calendar_feeds_add', $form, FALSE );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('calendar_feeds_add');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global', 'core' )->block( 'calendar_feeds_add', $form, FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -284,42 +313,35 @@ class _ical extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function edit()
|
||||
public function edit() : void
|
||||
{
|
||||
/* Check permissions */
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'calendar_feeds_edit' );
|
||||
Dispatcher::i()->checkAcpPermission( 'calendar_feeds_edit' );
|
||||
|
||||
/* Get existing feed */
|
||||
try
|
||||
{
|
||||
$feed = \IPS\calendar\Icalendar::load( \IPS\Request::i()->id );
|
||||
$feed = Icalendar::load( Request::i()->id );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'feed_not_found', '2L169/2', 404, '' );
|
||||
Output::i()->error( 'feed_not_found', '2L169/2', 404, '' );
|
||||
}
|
||||
|
||||
/* Build the form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'feed_title', $feed->title, TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Url( 'feed_url', $feed->url, TRUE, array( 'allowedProtocols' => array( 'http', 'https', 'webcal', 'webcals' ) ) ) );
|
||||
$form = new Form;
|
||||
$form->add( new Text( 'feed_title', $feed->title, TRUE ) );
|
||||
$form->add( new Form\Url( 'feed_url', $feed->url, TRUE, array( 'allowedProtocols' => array( 'http', 'https', 'webcal', 'webcals' ) ) ) );
|
||||
|
||||
$options = array();
|
||||
$form->add( new Node( 'feed_calendar_id', Calendar::load( $feed->calendar_id ), TRUE, array( 'class' => 'IPS\calendar\Calendar', 'url' => Url::internal( 'app=calendar&module=calendars&controller=ical&do=edit&id=' . Request::i()->id, 'admin' ) ) ) );
|
||||
|
||||
foreach( \IPS\calendar\Calendar::roots() as $calendar )
|
||||
if( Settings::i()->calendar_venues_enabled )
|
||||
{
|
||||
$options[ $calendar->id ] = $calendar->_title;
|
||||
$form->add( new Node( 'feed_venue_id', NULL, FALSE, array( 'class' => 'IPS\calendar\Venue', 'url' => Url::internal( 'app=calendar&module=calendars&controller=ical&do=edit', 'admin' ) ) ) );
|
||||
}
|
||||
|
||||
$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 )
|
||||
{
|
||||
$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 ) );
|
||||
$form->add( new Form\Member( 'feed_member_id', Member::load( $feed->member_id )->name, TRUE ) );
|
||||
$form->add( new YesNo( 'feed_allow_rsvp', $feed->allow_rsvp, FALSE ) );
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
@@ -328,13 +350,13 @@ class _ical extends \IPS\Dispatcher\Controller
|
||||
|
||||
try
|
||||
{
|
||||
\IPS\calendar\Icalendar\ICSParser::isValid( \IPS\Http\Url::external( str_replace( array( 'webcal://', 'webcals://' ), array( 'http://', 'https://' ), $values['feed_url'] ) )->request()->get() );
|
||||
ICSParser::isValid( Url::external( str_replace( array( 'webcal://', 'webcals://' ), array( 'http://', 'https://' ), $values['feed_url'] ) )->request()->get() );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
$form->error = ( $e instanceof \UnexpectedValueException ) ? \IPS\Member::loggedIn()->language()->addToStack('ical_error_' . $e->getMessage()) : $e->getMessage();
|
||||
$form->error = ( $e instanceof UnexpectedValueException ) ? Member::loggedIn()->language()->addToStack('ical_error_' . $e->getMessage()) : $e->getMessage();
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('global', 'core')->block('calendar_feeds_add', $form, FALSE);
|
||||
Output::i()->output = Theme::i()->getTemplate('global', 'core')->block('calendar_feeds_add', $form, FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -343,7 +365,7 @@ class _ical extends \IPS\Dispatcher\Controller
|
||||
$feed->url = $values['feed_url'];
|
||||
$feed->calendar_id = $values['feed_calendar_id']->_id;
|
||||
|
||||
if( \IPS\Settings::i()->calendar_venues_enabled )
|
||||
if( Settings::i()->calendar_venues_enabled )
|
||||
{
|
||||
$feed->venue_id = $values['feed_venue_id']->_id;
|
||||
}
|
||||
@@ -353,17 +375,17 @@ class _ical extends \IPS\Dispatcher\Controller
|
||||
$feed->save();
|
||||
|
||||
/* Admin log */
|
||||
\IPS\Session::i()->log( 'acplog__icalfeed_updated', array( $feed->title => FALSE ) );
|
||||
Session::i()->log( 'acplog__icalfeed_updated', array( $feed->title => FALSE ) );
|
||||
|
||||
/* Grab the feed events */
|
||||
$feed->refresh();
|
||||
|
||||
/* Redirect */
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=calendar&module=calendars&controller=ical' ), 'saved' );
|
||||
Output::i()->redirect( Url::internal( 'app=calendar&module=calendars&controller=ical' ), 'saved' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = $feed->title;
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( $feed->title, $form, FALSE );
|
||||
Output::i()->title = $feed->title;
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global', 'core' )->block( $feed->title, $form, FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -371,15 +393,15 @@ class _ical extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
public function delete() : void
|
||||
{
|
||||
/* Check permissions */
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'calendar_feeds_delete' );
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Dispatcher::i()->checkAcpPermission( 'calendar_feeds_delete' );
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
/* Build the form */
|
||||
$form = new \IPS\Helpers\Form( 'form', 'delete' );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'keep_events', TRUE, FALSE ) );
|
||||
$form = new Form( 'form', 'delete' );
|
||||
$form->add( new YesNo( 'keep_events', TRUE, FALSE ) );
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
@@ -387,7 +409,7 @@ class _ical extends \IPS\Dispatcher\Controller
|
||||
/* Delete the feed */
|
||||
try
|
||||
{
|
||||
$feed = \IPS\calendar\Icalendar::load( \IPS\Request::i()->id );
|
||||
$feed = Icalendar::load( Request::i()->id );
|
||||
|
||||
if( !$values['keep_events'] )
|
||||
{
|
||||
@@ -396,20 +418,20 @@ class _ical extends \IPS\Dispatcher\Controller
|
||||
|
||||
$feed->delete();
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'feed_not_found', '2L169/3', 404, '' );
|
||||
Output::i()->error( 'feed_not_found', '2L169/3', 404, '' );
|
||||
}
|
||||
|
||||
/* Admin log */
|
||||
\IPS\Session::i()->log( 'acplog__icalfeed_deleted', array( $feed->title => FALSE ) );
|
||||
Session::i()->log( 'acplog__icalfeed_deleted', array( $feed->title => FALSE ) );
|
||||
|
||||
/* Redirect */
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=calendar&module=calendars&controller=ical' ), 'deleted' );
|
||||
Output::i()->redirect( Url::internal( 'app=calendar&module=calendars&controller=ical' ), 'deleted' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('delete');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( 'delete', $form, FALSE );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('delete');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global', 'core' )->block( 'delete', $form, FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -417,28 +439,28 @@ class _ical extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function refresh()
|
||||
public function refresh() : void
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
/* Refresh the feed */
|
||||
try
|
||||
{
|
||||
$count = \IPS\calendar\Icalendar::load( \IPS\Request::i()->id )->refresh();
|
||||
$count = Icalendar::load( Request::i()->id )->refresh();
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'feed_not_found', '2L169/1', 404, '' );
|
||||
Output::i()->error( 'feed_not_found', '2L169/1', 404, '' );
|
||||
}
|
||||
catch( \UnexpectedValueException $e )
|
||||
catch( UnexpectedValueException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'ical_error_' . $e->getMessage(), '4L169/5', 500, '' );
|
||||
Output::i()->error( 'ical_error_' . $e->getMessage(), '4L169/5', 500, '' );
|
||||
}
|
||||
|
||||
/* Admin log */
|
||||
\IPS\Session::i()->log( 'acplog__icalfeed_refreshed', array( $count['imported'] => FALSE, $count['skipped'] => FALSE ) );
|
||||
Session::i()->log( 'acplog__icalfeed_refreshed', array( $count['imported'] => FALSE, $count['skipped'] => FALSE ) );
|
||||
|
||||
/* Redirect */
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=calendar&module=calendars&controller=ical' ), 'feed_refreshed' );
|
||||
Output::i()->redirect( Url::internal( 'app=calendar&module=calendars&controller=ical' ), 'feed_refreshed' );
|
||||
}
|
||||
}
|
||||
@@ -12,30 +12,47 @@
|
||||
namespace IPS\calendar\modules\admin\calendars;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\calendar\Date;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\GeoLocation;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Number;
|
||||
use IPS\Helpers\Form\Radio;
|
||||
use IPS\Helpers\Form\Select;
|
||||
use IPS\Helpers\Form\Text;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Session;
|
||||
use IPS\Settings as SettingsClass;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings
|
||||
*/
|
||||
class _settings extends \IPS\Dispatcher\Controller
|
||||
class settings extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'settings_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'settings_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -44,53 +61,50 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('settings');
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('settings');
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form = new Form;
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'calendar_default_view', \IPS\Settings::i()->calendar_default_view, TRUE, array( 'options' => array( 'overview' => 'cal_df_overview', 'month' => 'cal_df_month', 'week' => 'cal_df_week', 'day' => 'cal_df_day' ) ) ) );
|
||||
$form->add( new Radio( 'calendar_default_view', SettingsClass::i()->calendar_default_view, TRUE, array( 'options' => array( 'overview' => 'cal_df_overview', 'month' => 'cal_df_month', 'week' => 'cal_df_week', 'day' => 'cal_df_day' ) ) ) );
|
||||
|
||||
$options = array_combine( array_keys( \IPS\calendar\Date::$dateFormats ), array_map( function( $val ){ return "calendar_df_" . $val; }, array_keys( \IPS\calendar\Date::$dateFormats ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'calendar_date_format', \IPS\Settings::i()->calendar_date_format, TRUE, array( 'options' => $options, 'unlimited' => '-1', 'unlimitedLang' => "calendar_custom_df", 'unlimitedToggles' => array( 'calendar_date_format_custom' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'calendar_date_format_custom', \IPS\Settings::i()->calendar_date_format_custom, FALSE, array(), NULL, NULL, NULL, 'calendar_date_format_custom' ) );
|
||||
$options = array_combine( array_keys( Date::$dateFormats ), array_map( function( $val ){ return "calendar_df_" . $val; }, array_keys( Date::$dateFormats ) ) );
|
||||
$form->add( new Select( 'calendar_date_format', SettingsClass::i()->calendar_date_format, TRUE, array( 'options' => $options, 'unlimited' => '-1', 'unlimitedLang' => "calendar_custom_df", 'unlimitedToggles' => array( 'calendar_date_format_custom' ) ) ) );
|
||||
$form->add( new Text( 'calendar_date_format_custom', SettingsClass::i()->calendar_date_format_custom, FALSE, array(), NULL, NULL, NULL, 'calendar_date_format_custom' ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_calendar_mon', \IPS\Settings::i()->ipb_calendar_mon ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'calendar_rss_feed', \IPS\Settings::i()->calendar_rss_feed, FALSE, array( 'togglesOn' => array( 'calendar_rss_feed_days', 'calendar_rss_feed_order' ) ) ) );
|
||||
$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\Radio( 'calendar_rss_feed_order', \IPS\Settings::i()->calendar_rss_feed_order, FALSE, array( 'options' => array(
|
||||
$form->add( new YesNo( 'ipb_calendar_mon', SettingsClass::i()->ipb_calendar_mon ) );
|
||||
$form->add( new YesNo( 'calendar_rss_feed', SettingsClass::i()->calendar_rss_feed, FALSE, array( 'togglesOn' => array( 'calendar_rss_feed_days', 'calendar_rss_feed_order' ) ) ) );
|
||||
$form->add( new Number( 'calendar_rss_feed_days', SettingsClass::i()->calendar_rss_feed_days, FALSE, array( 'unlimited' => -1 ), NULL, NULL, NULL, 'calendar_rss_feed_days' ) );
|
||||
$form->add( new Radio( 'calendar_rss_feed_order', SettingsClass::i()->calendar_rss_feed_order, FALSE, array( 'options' => array(
|
||||
0 => 'calendar_rss_feed_order_date',
|
||||
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 YesNo( 'calendar_venues_enabled', SettingsClass::i()->calendar_venues_enabled ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'calendar_block_past_changes', \IPS\Settings::i()->calendar_block_past_changes ) );
|
||||
$form->add( new YesNo( 'calendar_block_past_changes', SettingsClass::i()->calendar_block_past_changes ) );
|
||||
|
||||
if( \IPS\GeoLocation::enabled() )
|
||||
if( GeoLocation::enabled() )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'map_center_lat', \IPS\Settings::i()->map_center_lat, FALSE, array( 'decimals' => 8, 'min' => "-180", 'max' => "180" ), NULL, NULL, NULL, 'map_center_lat' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'map_center_lon', \IPS\Settings::i()->map_center_lon, FALSE, array( 'decimals' => 8, 'min' => "-180", 'max' => "180" ), NULL, NULL, NULL, 'map_center_lon' ) );
|
||||
$form->add( new Number( 'map_center_lat', SettingsClass::i()->map_center_lat, FALSE, array( 'decimals' => 8, 'min' => "-180", 'max' => "180" ), NULL, NULL, NULL, 'map_center_lat' ) );
|
||||
$form->add( new Number( 'map_center_lon', SettingsClass::i()->map_center_lon, FALSE, array( 'decimals' => 8, 'min' => "-180", 'max' => "180" ), NULL, NULL, NULL, 'map_center_lon' ) );
|
||||
}
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
if( $values['calendar_date_format'] == -1 AND !$values['calendar_date_format_custom'] )
|
||||
{
|
||||
$form->error = \IPS\Member::loggedIn()->language()->addToStack('calendar_no_date_format');
|
||||
\IPS\Output::i()->output = $form;
|
||||
$form->error = Member::loggedIn()->language()->addToStack('calendar_no_date_format');
|
||||
Output::i()->output = $form;
|
||||
return;
|
||||
}
|
||||
|
||||
$form->saveAsSettings();
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
\IPS\Session::i()->log( 'acplogs__calendar_settings' );
|
||||
Session::i()->log( 'acplogs__calendar_settings' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = $form;
|
||||
Output::i()->output = $form;
|
||||
}
|
||||
}
|
||||
@@ -12,45 +12,51 @@
|
||||
namespace IPS\calendar\modules\admin\calendars;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Node\Model;
|
||||
use IPS\Node\Controller;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* venues
|
||||
*/
|
||||
class _venues extends \IPS\Node\Controller
|
||||
class venues extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = '\IPS\calendar\Venue';
|
||||
protected string $nodeClass = '\IPS\calendar\Venue';
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'venues_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'venues_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow overloading to change how the title is displayed in the tree
|
||||
*
|
||||
* @param $node \IPS\Node Node
|
||||
* @param $node Model Node
|
||||
* @return string
|
||||
*/
|
||||
protected static function nodeTitle( $node )
|
||||
protected static function nodeTitle( Model $node ): string
|
||||
{
|
||||
return $node->_title;
|
||||
}
|
||||
|
||||
@@ -12,25 +12,34 @@
|
||||
namespace IPS\calendar\modules\admin\stats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\Statistics\Chart;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* rsvp
|
||||
*/
|
||||
class _rsvp extends \IPS\Dispatcher\Controller
|
||||
class rsvp extends Controller
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'rsvp_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'rsvp_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -39,11 +48,12 @@ class _rsvp extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
$chart = \IPS\core\Statistics\Chart::loadFromExtension( 'calendar', 'Rsvp' )->getChart( \IPS\Http\Url::internal( "app=calendar&module=stats&controller=rsvp" ) );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__calendar_stats_rsvp');
|
||||
\IPS\Output::i()->output = (string) $chart;
|
||||
$chart = Chart::loadFromExtension( 'calendar', 'Rsvp' )->getChart( Url::internal( "app=calendar&module=stats&controller=rsvp" ) );
|
||||
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__calendar_stats_rsvp');
|
||||
Output::i()->output = (string) $chart;
|
||||
}
|
||||
|
||||
// Create new methods with the same name as the 'do' parameter which should execute it
|
||||
|
||||
@@ -12,66 +12,101 @@
|
||||
namespace IPS\calendar\modules\front\calendar;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use BadMethodCallException;
|
||||
use DateInterval;
|
||||
use DateTimeInterface;
|
||||
use Exception;
|
||||
use IPS\Api\Webhook;
|
||||
use IPS\Application;
|
||||
use IPS\calendar\Calendar;
|
||||
use IPS\calendar\Date;
|
||||
use IPS\calendar\Event as EventClass;
|
||||
use IPS\calendar\Icalendar\ICSParser;
|
||||
use IPS\Content\Controller;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\File;
|
||||
use IPS\GeoLocation;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Number;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use UnderflowException;
|
||||
use function count;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* View Event Controller
|
||||
*/
|
||||
class _event extends \IPS\Content\Controller
|
||||
class event extends Controller
|
||||
{
|
||||
/**
|
||||
* [Content\Controller] Class
|
||||
*/
|
||||
protected static $contentModel = 'IPS\calendar\Event';
|
||||
protected static string $contentModel = 'IPS\calendar\Event';
|
||||
|
||||
/**
|
||||
* @var EventClass|null
|
||||
*/
|
||||
protected ?EventClass $event = null;
|
||||
|
||||
/**
|
||||
* Init
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\calendar\Calendar::addCss();
|
||||
Calendar::addCss();
|
||||
|
||||
try
|
||||
{
|
||||
$this->event = \IPS\calendar\Event::load( \IPS\Request::i()->id );
|
||||
$this->event = EventClass::load( Request::i()->id );
|
||||
|
||||
if ( !$this->event->canView( \IPS\Member::loggedIn() ) )
|
||||
if ( !$this->event->canView( Member::loggedIn() ) )
|
||||
{
|
||||
if ( $this->event->container()->can('view') AND !$this->event->container()->can('read') )
|
||||
{
|
||||
if ( \IPS\Member::loggedIn()->member_id )
|
||||
if ( Member::loggedIn()->member_id )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_module_permission', '2L179/8', 404, '' );
|
||||
Output::i()->error( 'no_module_permission', '2L179/8', 404, '' );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_module_permission_guest', '2L179/9', 404, '' );
|
||||
Output::i()->error( 'no_module_permission_guest', '2L179/9', 404, '' );
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->error( 'node_error', '2L179/1', 403, '' );
|
||||
|
||||
Output::i()->error( 'node_error', '2L179/1', 403, '' );
|
||||
}
|
||||
|
||||
if ( $this->event->cover_photo )
|
||||
{
|
||||
\IPS\Output::i()->metaTags['og:image'] = \IPS\File::get( 'calendar_Events', $this->event->cover_photo )->url;
|
||||
Output::i()->metaTags['og:image'] = File::get( 'calendar_Events', $this->event->cover_photo )->url;
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2L179/2', 404, '' );
|
||||
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') );
|
||||
Output::i()->breadcrumb['module'] = array( Url::internal( "app=calendar&module=calendar&controller=view", 'front', 'calendar' ), Member::loggedIn()->language()->addToStack('module__calendar_calendar') );
|
||||
|
||||
parent::execute();
|
||||
}
|
||||
@@ -79,9 +114,9 @@ class _event extends \IPS\Content\Controller
|
||||
/**
|
||||
* View Event
|
||||
*
|
||||
* @return void
|
||||
* @return mixed
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : mixed
|
||||
{
|
||||
/* Init */
|
||||
parent::manage();
|
||||
@@ -91,7 +126,7 @@ class _event extends \IPS\Content\Controller
|
||||
{
|
||||
$attendees = $this->event->attendees();
|
||||
}
|
||||
catch( \BadMethodCallException $e )
|
||||
catch( BadMethodCallException $e )
|
||||
{
|
||||
$attendees = array( 0 => array(), 1 => array(), 2 => array() );
|
||||
}
|
||||
@@ -99,112 +134,107 @@ class _event extends \IPS\Content\Controller
|
||||
/* Sort out comments and reviews */
|
||||
$tabs = $this->event->commentReviewTabs();
|
||||
$_tabs = array_keys( $tabs );
|
||||
$tab = isset( \IPS\Request::i()->tab ) ? \IPS\Request::i()->tab : array_shift( $_tabs );
|
||||
$tab = isset( Request::i()->tab ) ? 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 ) ? Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $tab, $activeTabContents, $this->event->url(), 'tab', FALSE, FALSE ) : NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
$commentsAndReviews = $activeTabContents;
|
||||
}
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
if ( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->output = $activeTabContents;
|
||||
return;
|
||||
Output::i()->output = $activeTabContents;
|
||||
return null;
|
||||
}
|
||||
|
||||
/* Online User Location */
|
||||
\IPS\Session::i()->setLocation( $this->event->url(), $this->event->onlineListPermissions(), 'loc_calendar_viewing_event', array( $this->event->title => FALSE ) );
|
||||
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();
|
||||
$reminder = Db::i()->select( '*', 'calendar_event_reminders', array( 'reminder_event_id=? and reminder_member_id=?', $this->event->id, (int) Member::loggedIn()->member_id ) )->first();
|
||||
}
|
||||
catch ( \UnderflowException $e ) {}
|
||||
catch ( UnderflowException $e ) {}
|
||||
|
||||
/* Address */
|
||||
$address = NULL;
|
||||
$location = NULL;
|
||||
$addressName = NULL;
|
||||
if ( \IPS\Settings::i()->calendar_venues_enabled and $this->event->venue() )
|
||||
if ( Settings::i()->calendar_venues_enabled and $this->event->venue() )
|
||||
{
|
||||
$location = \IPS\GeoLocation::buildFromjson( $this->event->venue()->address );
|
||||
$location = 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 );
|
||||
$location = GeoLocation::buildFromjson( $this->event->location );
|
||||
$address = $location->toString();
|
||||
}
|
||||
|
||||
/* Add JSON-LD */
|
||||
$format = $this->event->all_day ? "Y-m-d" : \IPS\DateTime::ISO8601;
|
||||
\IPS\Output::i()->jsonLd['event'] = array(
|
||||
'@context' => "http://schema.org",
|
||||
$format = $this->event->all_day ? "Y-m-d" : DateTimeInterface::ATOM;
|
||||
Output::i()->jsonLd['event'] = array(
|
||||
'@context' => "https://schema.org",
|
||||
'@type' => "Event",
|
||||
'url' => (string) $this->event->url(),
|
||||
'name' => $this->event->mapped('title'),
|
||||
'description' => $this->event->truncated( TRUE, NULL ),
|
||||
'eventStatus' => "EventScheduled",
|
||||
'organizer' => array(
|
||||
'@type' => 'Person',
|
||||
'name' => $this->event->author()->name
|
||||
),
|
||||
'eventAttendanceMode' => ( $this->event->online ) ? 'OnlineEventAttendanceMode' : 'OfflineEventAttendanceMode',
|
||||
'startDate' => $this->event->nextOccurrence( \IPS\calendar\Date::getDate(), 'startDate' ) ?
|
||||
$this->event->nextOccurrence( \IPS\calendar\Date::getDate(), 'startDate' )->format( $format ) :
|
||||
'startDate' => $this->event->nextOccurrence( Date::getDate(), 'startDate' ) ?
|
||||
$this->event->nextOccurrence( 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( $format ) :
|
||||
Output::i()->jsonLd['event']['endDate'] = $this->event->nextOccurrence( $this->event->nextOccurrence( Date::getDate(), 'startDate' ) ?: Date::getDate(), 'endDate' ) ?
|
||||
$this->event->nextOccurrence( $this->event->nextOccurrence( Date::getDate(), 'startDate' ) ?: 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() )
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['event']['aggregateRating'] = array(
|
||||
Output::i()->jsonLd['event']['aggregateRating'] = array(
|
||||
'@type' => 'AggregateRating',
|
||||
'reviewCount' => $this->event->reviews,
|
||||
'ratingValue' => $this->event->averageReviewRating(),
|
||||
'bestRating' => \IPS\Settings::i()->reviews_rating_out_of,
|
||||
'bestRating' => Settings::i()->reviews_rating_out_of,
|
||||
);
|
||||
}
|
||||
|
||||
if( $this->event->coverPhoto()->file )
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['event']['image'] = (string) $this->event->coverPhoto()->file->url;
|
||||
Output::i()->jsonLd['event']['image'] = (string) $this->event->coverPhoto()->file->url;
|
||||
}
|
||||
|
||||
if( $this->event->rsvp )
|
||||
{
|
||||
if( \count( $attendees[1] ) )
|
||||
if( count( $attendees[1] ) )
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['event']['attendee'] = array();
|
||||
Output::i()->jsonLd['event']['attendee'] = array();
|
||||
|
||||
foreach( $attendees[1] as $attendee )
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['event']['attendee'][] = array(
|
||||
Output::i()->jsonLd['event']['attendee'][] = array(
|
||||
'@type' => 'Person',
|
||||
'name' => $attendee->name
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* If we have a physical location, use that. */
|
||||
if( $location )
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['event']['location'] = array(
|
||||
Output::i()->jsonLd['event']['location'] = array(
|
||||
'@type' => 'Place',
|
||||
'address' => array(
|
||||
'@type' => 'PostalAddress',
|
||||
@@ -217,31 +247,32 @@ class _event extends \IPS\Content\Controller
|
||||
);
|
||||
if( $addressName )
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['event']['location']['name'] = $addressName;
|
||||
Output::i()->jsonLd['event']['location']['name'] = $addressName;
|
||||
}
|
||||
}
|
||||
/* If not, default to events URL */
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['event']['location'] = array(
|
||||
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']
|
||||
'name' => Settings::i()->board_name,
|
||||
'address' => Output::i()->jsonLd['event']['url'],
|
||||
'url' => Output::i()->jsonLd['event']['url']
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/* Finally, if event is online and there is a URL, use that */
|
||||
if ( $this->event->online AND $this->event->url )
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['event']['location'] = array(
|
||||
Output::i()->jsonLd['event']['location'] = array(
|
||||
'@type' => 'VirtualLocation',
|
||||
'url' => $this->event->url
|
||||
);
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'view' )->view( $this->event, $commentsAndReviews, $attendees, $address, $reminder );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'view' )->view( $this->event, $commentsAndReviews, $attendees, $address, $reminder );
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -249,27 +280,27 @@ class _event extends \IPS\Content\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function hovercard()
|
||||
protected function hovercard() : void
|
||||
{
|
||||
/* Figure out our date object */
|
||||
$date = NULL;
|
||||
|
||||
if( \IPS\Request::i()->sd )
|
||||
if( Request::i()->sd )
|
||||
{
|
||||
$dateBits = explode( '-', \IPS\Request::i()->sd );
|
||||
$dateBits = explode( '-', Request::i()->sd );
|
||||
|
||||
if( \count( $dateBits ) === 3 )
|
||||
if( count( $dateBits ) === 3 )
|
||||
{
|
||||
$date = \IPS\calendar\Date::getDate( $dateBits[0], $dateBits[1], $dateBits[2] );
|
||||
$date = Date::getDate( $dateBits[0], $dateBits[1], $dateBits[2] );
|
||||
}
|
||||
}
|
||||
|
||||
if( $date === NULL )
|
||||
{
|
||||
$date = \IPS\calendar\Date::getDate();
|
||||
$date = Date::getDate();
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'view' )->eventBlock( $this->event, $date );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'view' )->eventBlock( $this->event, $date );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -277,18 +308,18 @@ class _event extends \IPS\Content\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function download()
|
||||
protected function download() : void
|
||||
{
|
||||
|
||||
$feed = new \IPS\calendar\Icalendar\ICSParser;
|
||||
$feed = new ICSParser;
|
||||
$feed->addEvent( $this->event );
|
||||
|
||||
$ics = $feed->buildICalendarFeed( $this->event->container() );
|
||||
|
||||
\IPS\Output::i()->sendHeader( "Content-type: text/calendar; charset=UTF-8" );
|
||||
\IPS\Output::i()->sendHeader( 'Content-Disposition: inline; filename=calendarEvents.ics' );
|
||||
Output::i()->sendHeader( "Content-type: text/calendar; charset=UTF-8" );
|
||||
Output::i()->sendHeader( 'Content-Disposition: inline; filename=calendarEvents.ics' );
|
||||
|
||||
\IPS\Member::loggedIn()->language()->parseOutputForDisplay( $ics );
|
||||
Member::loggedIn()->language()->parseOutputForDisplay( $ics );
|
||||
print $ics;
|
||||
exit;
|
||||
}
|
||||
@@ -298,11 +329,11 @@ class _event extends \IPS\Content\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function downloadRsvp()
|
||||
protected function downloadRsvp() : void
|
||||
{
|
||||
$output = \IPS\Theme::i()->getTemplate( 'view' )->attendees( $this->event );
|
||||
\IPS\Member::loggedIn()->language()->parseOutputForDisplay( $output );
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core' )->blankTemplate( $output ) );
|
||||
$output = Theme::i()->getTemplate( 'view' )->attendees( $this->event );
|
||||
Member::loggedIn()->language()->parseOutputForDisplay( $output );
|
||||
Output::i()->sendOutput( Theme::i()->getTemplate( 'global', 'core' )->blankTemplate( $output ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -310,44 +341,44 @@ class _event extends \IPS\Content\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function rsvp()
|
||||
protected function rsvp() : void
|
||||
{
|
||||
if( !$this->event->can('rsvp') )
|
||||
{
|
||||
\IPS\Output::i()->error( 'rsvp_error', '2L179/3', 403, '' );
|
||||
Output::i()->error( 'rsvp_error', '2L179/3', 403, '' );
|
||||
}
|
||||
|
||||
if( $this->event->hasPassed() AND \IPS\Settings::i()->calendar_block_past_changes )
|
||||
if( $this->event->hasPassed() AND Settings::i()->calendar_block_past_changes )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_rsvp_past_event', '2L179/6', 403, '' );
|
||||
Output::i()->error( 'no_rsvp_past_event', '2L179/6', 403, '' );
|
||||
}
|
||||
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
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 */
|
||||
\IPS\Db::i()->delete( 'calendar_event_rsvp', array( 'rsvp_event_id=? AND rsvp_member_id=?', $this->event->id, (int) \IPS\Member::loggedIn()->member_id ) );
|
||||
Db::i()->delete( 'calendar_event_rsvp', array( 'rsvp_event_id=? AND rsvp_member_id=?', $this->event->id, (int) Member::loggedIn()->member_id ) );
|
||||
|
||||
if( \IPS\Request::i()->action == 'leave' )
|
||||
if( Request::i()->action == 'leave' )
|
||||
{
|
||||
$message = 'rsvp_not_going';
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Figure out the action */
|
||||
switch( \IPS\Request::i()->action )
|
||||
switch( Request::i()->action )
|
||||
{
|
||||
case 'yes':
|
||||
$_go = \IPS\calendar\Event::RSVP_YES;
|
||||
$_go = EventClass::RSVP_YES;
|
||||
break;
|
||||
|
||||
case 'maybe':
|
||||
$_go = \IPS\calendar\Event::RSVP_MAYBE;
|
||||
$_go = EventClass::RSVP_MAYBE;
|
||||
break;
|
||||
|
||||
case 'no':
|
||||
default:
|
||||
\IPS\Request::i()->action = 'no';
|
||||
$_go = \IPS\calendar\Event::RSVP_NO;
|
||||
Request::i()->action = 'no';
|
||||
$_go = EventClass::RSVP_NO;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -355,39 +386,41 @@ class _event extends \IPS\Content\Controller
|
||||
if( $this->event->rsvp_limit > 0 )
|
||||
{
|
||||
/* We do not accept "maybe" in this case */
|
||||
if( $_go === \IPS\calendar\Event::RSVP_MAYBE )
|
||||
if( $_go === EventClass::RSVP_MAYBE )
|
||||
{
|
||||
\IPS\Output::i()->error( 'rsvp_limit_nomaybe', '3L179/4', 403, '' );
|
||||
Output::i()->error( 'rsvp_limit_nomaybe', '3L179/4', 403, '' );
|
||||
}
|
||||
|
||||
/* 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 == EventClass::RSVP_YES and count( $this->event->attendees( EventClass::RSVP_YES ) ) >= $this->event->rsvp_limit )
|
||||
{
|
||||
\IPS\Output::i()->error( 'rsvp_limit_reached', '3L179/5', 403, '' );
|
||||
Output::i()->error( 'rsvp_limit_reached', '3L179/5', 403, '' );
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Db::i()->insert( 'calendar_event_rsvp', array(
|
||||
Db::i()->insert( 'calendar_event_rsvp', array(
|
||||
'rsvp_event_id' => $this->event->id,
|
||||
'rsvp_member_id' => (int) \IPS\Member::loggedIn()->member_id,
|
||||
'rsvp_member_id' => (int) Member::loggedIn()->member_id,
|
||||
'rsvp_date' => time(),
|
||||
'rsvp_response' => (int) $_go
|
||||
) );
|
||||
|
||||
\IPS\Member::loggedIn()->achievementAction( 'calendar', 'Rsvp', $this->event );
|
||||
$webhookData = [
|
||||
'event' => $this->event->apiOutput(),
|
||||
'action' => Request::i()->action,
|
||||
'attendee' => Member::loggedIn()->apiOutput(),
|
||||
];
|
||||
|
||||
$message = 'rsvp_selection_' . Request::i()->action;
|
||||
|
||||
Webhook::fire( 'calendarEvent_rsvp', $webhookData );
|
||||
|
||||
\IPS\Events\Event::fire( 'onEventRsvp', Member::loggedIn(), array( $this->event, $_go ) );
|
||||
|
||||
Member::loggedIn()->achievementAction( 'calendar', 'Rsvp', $this->event );
|
||||
}
|
||||
|
||||
$webhookData = [
|
||||
'event' => $this->event->apiOutput(),
|
||||
'action' => \IPS\Request::i()->action,
|
||||
'attendee' => \IPS\Member::loggedIn()->apiOutput(),
|
||||
];
|
||||
|
||||
$message = 'rsvp_selection_' . \IPS\Request::i()->action;
|
||||
|
||||
\IPS\Api\Webhook::fire( 'calendarEvent_rsvp', $webhookData );
|
||||
|
||||
\IPS\Output::i()->redirect( $this->event->url(), $message );
|
||||
Output::i()->redirect( $this->event->url(), $message );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -395,44 +428,44 @@ class _event extends \IPS\Content\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function edit()
|
||||
protected function edit() : void
|
||||
{
|
||||
if ( \IPS\Application::appIsEnabled('cloud') and $this->event->livetopic_id )
|
||||
if ( Application::appIsEnabled('cloud') and $this->event->livetopic_id )
|
||||
{
|
||||
/* Allow live topic edit form to handle this */
|
||||
try
|
||||
{
|
||||
/* Make sure it's a valid topic */
|
||||
$liveTopic = \IPS\cloud\LiveTopic::load( $this->event->livetopic_id );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=modcp&controller=modcp&tab=livetopics&action=create&fromEvent=1&id=' . $liveTopic->id, 'front', 'modcp_livetopics' ) );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=modcp&controller=modcp&tab=livetopics&action=create&fromEvent=1&id=' . $liveTopic->id, 'front', 'modcp_livetopics' ) );
|
||||
}
|
||||
catch( \Exception ) { }
|
||||
catch( Exception ) { }
|
||||
}
|
||||
|
||||
/* Are we blocking changes to past events? */
|
||||
if( $this->event->hasPassed() AND \IPS\Settings::i()->calendar_block_past_changes )
|
||||
if( $this->event->hasPassed() AND Settings::i()->calendar_block_past_changes )
|
||||
{
|
||||
if ( !\IPS\calendar\Event::modPermission( 'edit', \IPS\Member::loggedIn(), $this->event->containerWrapper() ) )
|
||||
if ( !EventClass::modPermission( 'edit', Member::loggedIn(), $this->event->containerWrapper() ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_edit_past_event', '2L179/7', 403, '' );
|
||||
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' ) );
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'front_submit.js', 'calendar', 'front' ) );
|
||||
|
||||
return parent::edit();
|
||||
parent::edit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the form for editing. Abstracted so controllers can define a custom template if desired.
|
||||
*
|
||||
* @param \IPS\Helpers\Form $form The form
|
||||
* @param Form $form The form
|
||||
* @return string
|
||||
*/
|
||||
protected function getEditForm( $form )
|
||||
protected function getEditForm( Form $form ): string
|
||||
{
|
||||
return $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'submit', 'calendar' ), 'submitForm' ) );
|
||||
return $form->customTemplate( array( Theme::i()->getTemplate( 'submit', 'calendar' ), 'submitForm' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -440,69 +473,69 @@ class _event extends \IPS\Content\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setReminder()
|
||||
protected function setReminder() : void
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
/* Members only */
|
||||
if( !\IPS\Member::loggedIn()->member_id )
|
||||
if( !Member::loggedIn()->member_id )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '3L369/1', 403, '' );
|
||||
Output::i()->error( 'node_error', '3L369/1', 403, '' );
|
||||
}
|
||||
|
||||
/* 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();
|
||||
$existing = Db::i()->select( '*', 'calendar_event_reminders', array( 'reminder_event_id=? and reminder_member_id=?', $this->event->id, (int) Member::loggedIn()->member_id ) )->first();
|
||||
}
|
||||
catch ( \UnderflowException $e ) {}
|
||||
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() );
|
||||
$diff = $this->event->_start_date->diff( DateTime::create() );
|
||||
$max = $diff->days;
|
||||
|
||||
$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' ) );
|
||||
$form = new Form;
|
||||
$form->class = 'ipsForm--vertical ipsForm--set-reminder';
|
||||
$form->add( new Number( 'event_remind_me', isset( $existing ) ? $existing['reminder_days_before'] : ( ( $max < 3 ) ? $max : 3 ), TRUE, array( 'min' => 1, 'max' => (int) $max ), NULL, NULL, 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') );
|
||||
$form->addButton( 'event_dont_remind', 'link', Url::internal( "app=calendar&module=calendar&controller=event&do=removeReminder&action=remove&id={$this->event->id}")->csrf(), 'ipsButton ipsButton--negative', 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 ) );
|
||||
Db::i()->delete( 'calendar_event_reminders', array( 'reminder_event_id=? AND reminder_member_id=?', $this->event->id, (int) Member::loggedIn()->member_id ) );
|
||||
|
||||
\IPS\Db::i()->insert( 'calendar_event_reminders', array(
|
||||
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_member_id' => (int) 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' ) );
|
||||
Db::i()->update( 'core_tasks', array( 'enabled' => 1 ), array( '`key`=?', 'eventreminders' ) );
|
||||
|
||||
$message = 'event_reminder_added';
|
||||
|
||||
\IPS\Output::i()->redirect( $this->event->url(), $message );
|
||||
Output::i()->redirect( $this->event->url(), $message );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'event_set_reminder' );
|
||||
$output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'view', 'calendar' ), 'reminderForm' ) );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'event_set_reminder' );
|
||||
$output = $form->customTemplate( array( Theme::i()->getTemplate( 'view', 'calendar' ), 'reminderForm' ) );
|
||||
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
if( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->sendOutput( $output, 200, 'text/html' );
|
||||
Output::i()->sendOutput( $output );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->output = $output;
|
||||
Output::i()->output = $output;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -511,25 +544,25 @@ class _event extends \IPS\Content\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function removeReminder()
|
||||
protected function removeReminder() : void
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
if ( \IPS\Request::i()->action == 'remove' )
|
||||
if ( 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 ) );
|
||||
Db::i()->delete( 'calendar_event_reminders', array( 'reminder_event_id=? AND reminder_member_id=?', $this->event->id, (int) Member::loggedIn()->member_id ) );
|
||||
|
||||
$message = 'event_reminder_removed';
|
||||
}
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
if ( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json( 'ok' );
|
||||
Output::i()->json( 'ok' );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( $this->event->url(), $message );
|
||||
Output::i()->redirect( $this->event->url(), $message ?? '' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,18 +571,18 @@ class _event extends \IPS\Content\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function reminderButton()
|
||||
protected function reminderButton() : void
|
||||
{
|
||||
/* 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();
|
||||
$existing = Db::i()->select( '*', 'calendar_event_reminders', array( 'reminder_event_id=? and reminder_member_id=?', $this->event->id, (int)Member::loggedIn()->member_id ) )->first();
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
catch ( UnderflowException $e )
|
||||
{
|
||||
}
|
||||
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'view', 'calendar', 'front' )->reminderButton( $this->event, $existing ) );
|
||||
Output::i()->sendOutput( Theme::i()->getTemplate( 'view', 'calendar', 'front' )->reminderButton( $this->event, $existing ) );
|
||||
}
|
||||
}
|
||||
@@ -12,70 +12,92 @@
|
||||
namespace IPS\calendar\modules\front\calendar;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DomainException;
|
||||
use IPS\calendar\Calendar;
|
||||
use IPS\calendar\Event;
|
||||
use IPS\core\FrontNavigation;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\File;
|
||||
use IPS\File\Exception;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Node;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Platform\Bridge;
|
||||
use IPS\Request;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
use function is_object;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit Event Controller
|
||||
*/
|
||||
class _submit extends \IPS\Dispatcher\Controller
|
||||
class submit extends Controller
|
||||
{
|
||||
/**
|
||||
* Choose Calendar
|
||||
*
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
$form = new \IPS\Helpers\Form( 'select_calendar', 'continue' );
|
||||
$form->class = 'ipsForm_vertical ipsForm_noLabels';
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'calendar', NULL, TRUE, array(
|
||||
'url' => \IPS\Http\Url::internal( 'app=calendar&module=calendar&controller=submit', 'front', 'calendar_submit' ),
|
||||
$form = new Form( 'select_calendar', 'continue' );
|
||||
$form->class = 'ipsForm--vertical ipsForm--submit-event ipsForm--noLabels';
|
||||
$form->add( new Node( 'calendar', NULL, TRUE, array(
|
||||
'url' => Url::internal( 'app=calendar&module=calendar&controller=submit', 'front', 'calendar_submit' ),
|
||||
'class' => 'IPS\calendar\Calendar',
|
||||
'permissionCheck' => 'add',
|
||||
'forceOwner' => \IPS\Member::loggedIn(),
|
||||
'clubs' => \IPS\Settings::i()->club_nodes_in_apps
|
||||
'forceOwner' => Member::loggedIn(),
|
||||
'clubs' => Settings::i()->club_nodes_in_apps
|
||||
) ) );
|
||||
|
||||
/* Are we creating an event for a specific day? If yes, pass the values to the form */
|
||||
if( \IPS\Request::i()->y AND \IPS\Request::i()->m AND \IPS\Request::i()->d )
|
||||
if( Request::i()->y AND Request::i()->m AND Request::i()->d )
|
||||
{
|
||||
$form->hiddenValues['y'] = \IPS\Request::i()->y;
|
||||
$form->hiddenValues['m'] = \IPS\Request::i()->m;
|
||||
$form->hiddenValues['d'] = \IPS\Request::i()->d;
|
||||
$form->hiddenValues['y'] = Request::i()->y;
|
||||
$form->hiddenValues['m'] = Request::i()->m;
|
||||
$form->hiddenValues['d'] = Request::i()->d;
|
||||
}
|
||||
|
||||
/* Are we coming from a venue? */
|
||||
if( \IPS\Settings::i()->calendar_venues_enabled and \IPS\Request::i()->venue )
|
||||
if( Settings::i()->calendar_venues_enabled and Request::i()->venue )
|
||||
{
|
||||
$form->hiddenValues['venue'] = \IPS\Request::i()->venue;
|
||||
$form->hiddenValues['venue'] = 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 );
|
||||
$url = Url::internal( 'app=calendar&module=calendar&controller=submit&do=submit', 'front', 'calendar_submit' )->setQueryString( 'id', $values['calendar']->_id );
|
||||
|
||||
if( isset( $values['y'], $values['m'], $values['d'] ) )
|
||||
{
|
||||
$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'] ) )
|
||||
if( Settings::i()->calendar_venues_enabled and isset( $values['venue'] ) )
|
||||
{
|
||||
$url = $url->setQueryString( 'venue', $values['venue'] );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( $url );
|
||||
Output::i()->redirect( $url );
|
||||
}
|
||||
|
||||
/* 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()->output = \IPS\Theme::i()->getTemplate( 'submit' )->calendarSelector( $form );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'submit_event' );
|
||||
Output::i()->sidebar['enabled'] = FALSE;
|
||||
Output::i()->breadcrumb[] = array( NULL, Member::loggedIn()->language()->addToStack( 'add_cal_event_header' ) );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'submit' )->calendarSelector( $form );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,49 +105,48 @@ class _submit extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function submit()
|
||||
protected function submit() : void
|
||||
{
|
||||
$calendar = NULL;
|
||||
$club = NULL;
|
||||
|
||||
try
|
||||
{
|
||||
$calendar = \IPS\calendar\Calendar::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
$calendar = Calendar::loadAndCheckPerms( 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 );
|
||||
FrontNavigation::$clubTabActive = TRUE;
|
||||
Output::i()->breadcrumb = array();
|
||||
Output::i()->breadcrumb[] = array( Url::internal( 'app=core&module=clubs&controller=directory', 'front', 'clubs_list' ), Member::loggedIn()->language()->addToStack('module__core_clubs') );
|
||||
Output::i()->breadcrumb[] = array( $club->url(), $club->name );
|
||||
Output::i()->breadcrumb[] = array( $calendar->url(), $calendar->_title );
|
||||
|
||||
if ( \IPS\Settings::i()->clubs_header == 'sidebar' )
|
||||
if ( Settings::i()->clubs_header == 'sidebar' )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate( 'clubs', 'core' )->header( $club, $calendar, 'sidebar' );
|
||||
Output::i()->sidebar['contextual'] = Theme::i()->getTemplate( 'clubs', 'core' )->header( $club, $calendar, 'sidebar' );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=calendar&module=calendar&controller=submit', 'front', 'calendar_submit' ) );
|
||||
Output::i()->redirect( Url::internal( 'app=calendar&module=calendar&controller=submit', 'front', 'calendar_submit' ) );
|
||||
}
|
||||
|
||||
$form = \IPS\calendar\Event::create( $calendar );
|
||||
$form = Event::create( $calendar );
|
||||
|
||||
$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 );
|
||||
$guestPostBeforeRegister = ( !Member::loggedIn()->member_id ) ? ( $calendar and !$calendar->can( 'add', Member::loggedIn(), FALSE ) ) : FALSE;
|
||||
$modQueued = Event::moderateNewItems( Member::loggedIn(), $calendar, $guestPostBeforeRegister );
|
||||
if ( $guestPostBeforeRegister or $modQueued )
|
||||
{
|
||||
$extraOutput .= \IPS\Theme::i()->getTemplate( 'forms', 'core' )->postingInformation( $guestPostBeforeRegister, $modQueued, TRUE );
|
||||
$extraOutput .= 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' ) );
|
||||
Output::i()->output .= Theme::i()->getTemplate( 'submit' )->submitPage( $extraOutput . $form->customTemplate( array( Theme::i()->getTemplate( 'submit', 'calendar' ), 'submitForm' ) ), Member::loggedIn()->language()->addToStack('add_cal_event_header'), $calendar );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'submit_event' );
|
||||
Output::i()->breadcrumb[] = array( NULL, Member::loggedIn()->language()->addToStack( 'add_cal_event_header' ) );
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'front_submit.js', 'calendar', 'front' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,34 +154,34 @@ class _submit extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function copy()
|
||||
protected function copy() : void
|
||||
{
|
||||
try
|
||||
{
|
||||
$existing = \IPS\calendar\Event::loadAndCheckPerms( \IPS\Request::i()->event_id );
|
||||
$existing = Event::loadAndCheckPerms( Request::i()->event_id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=calendar&module=calendar&controller=submit', 'front', 'calendar_submit' ) );
|
||||
Output::i()->redirect( Url::internal( 'app=calendar&module=calendar&controller=submit', 'front', 'calendar_submit' ) );
|
||||
}
|
||||
|
||||
if( !$existing->canCopyEvent())
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_module_permission', '2L179/9', 403, '' );
|
||||
Output::i()->error( 'no_module_permission', '2L179/9', 403, '' );
|
||||
}
|
||||
|
||||
/* Are we the author of the existing event? */
|
||||
if( $existing->author()->member_id !== \IPS\Member::loggedIn()->member_id )
|
||||
if( $existing->author()->member_id !== Member::loggedIn()->member_id )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=calendar&module=calendar&controller=submit', 'front', 'calendar_submit' ) );
|
||||
Output::i()->redirect( Url::internal( 'app=calendar&module=calendar&controller=submit', 'front', 'calendar_submit' ) );
|
||||
}
|
||||
|
||||
$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(), TRUE );
|
||||
$form = new Form( 'form', Member::loggedIn()->language()->checkKeyExists( Event::$formLangPrefix . '_save' ) ? Event::$formLangPrefix . '_save' : 'save' );
|
||||
$form->class = 'ipsForm--vertical ipsForm--copy-event';
|
||||
$formElements = Event::formElements( $existing, $existing->container(), TRUE );
|
||||
foreach ( $formElements as $key => $object )
|
||||
{
|
||||
if ( \is_object( $object ) )
|
||||
if ( is_object( $object ) )
|
||||
{
|
||||
$form->add( $object );
|
||||
}
|
||||
@@ -179,54 +200,62 @@ class _submit extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Disable read/write separation */
|
||||
\IPS\Db::i()->readWriteSeparation = FALSE;
|
||||
Db::i()->readWriteSeparation = FALSE;
|
||||
|
||||
try
|
||||
{
|
||||
$obj = \IPS\calendar\Event::createFromForm( $values );
|
||||
$obj = Event::createFromForm( $values );
|
||||
|
||||
/* Set cover photo offset from original if we're using the same photo */
|
||||
if( $existing->cover_photo and $existing->cover_photo == $obj->cover_photo )
|
||||
{
|
||||
try
|
||||
{
|
||||
$obj->cover_photo = \IPS\File::get( 'calendar_Events', $existing->cover_photo )->duplicate();
|
||||
$obj->cover_photo = File::get( 'calendar_Events', $existing->cover_photo )->duplicate();
|
||||
$obj->cover_offset = $existing->cover_offset;
|
||||
$obj->save();
|
||||
}
|
||||
catch ( \IPS\File\Exception $e ){}
|
||||
catch ( Exception $e ){}
|
||||
}
|
||||
|
||||
if ( !\IPS\Member::loggedIn()->member_id and $obj->hidden() )
|
||||
if ( !Member::loggedIn()->member_id and $obj->hidden() )
|
||||
{
|
||||
\IPS\Output::i()->redirect( $obj->container()->url(), 'mod_queue_message' );
|
||||
Output::i()->redirect( $obj->container()->url(), 'mod_queue_message' );
|
||||
}
|
||||
else if ( $obj->hidden() == 1 )
|
||||
{
|
||||
\IPS\Output::i()->redirect( $obj->url(), 'mod_queue_message' );
|
||||
Output::i()->redirect( $obj->url(), 'mod_queue_message' );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( $obj->url() );
|
||||
Output::i()->redirect( $obj->url() );
|
||||
}
|
||||
}
|
||||
catch ( \DomainException $e )
|
||||
catch ( DomainException $e )
|
||||
{
|
||||
$form->error = $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
\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 ) ) );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'submit' )->submitPage( $form->customTemplate( array( Theme::i()->getTemplate( 'submit', 'calendar' ), 'submitForm' ) ), Member::loggedIn()->language()->addToStack('copy_cal_event_header', TRUE, array( 'sprintf' => $existing->title ) ) );
|
||||
|
||||
if ( \IPS\calendar\Event::moderateNewItems( \IPS\Member::loggedIn() ) )
|
||||
if ( Event::moderateNewItems( 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;
|
||||
Output::i()->output = Theme::i()->getTemplate( 'forms', 'core' )->modQueueMessage( Member::loggedIn()->warnings( 5, NULL, 'mq' ), Member::loggedIn()->mod_posts ) . 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' ) );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('copy_cal_event_header', TRUE, array( 'sprintf' => $existing->title ) );
|
||||
Output::i()->sidebar['enabled'] = FALSE;
|
||||
Output::i()->breadcrumb[] = array( NULL, Member::loggedIn()->language()->addToStack('copy_cal_event_header', TRUE, array( 'sprintf' => $existing->title ) ) );
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'front_submit.js', 'calendar', 'front' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a live topic right from the events page
|
||||
*/
|
||||
public function livetopic(): void
|
||||
{
|
||||
Bridge::i()->liveTopicCreateFormFromCalendar();
|
||||
}
|
||||
}
|
||||
@@ -12,36 +12,52 @@
|
||||
namespace IPS\calendar\modules\front\calendar;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use InvalidArgumentException;
|
||||
use IPS\calendar\Calendar;
|
||||
use IPS\calendar\Date;
|
||||
use IPS\calendar\Event;
|
||||
use IPS\calendar\Venue as VenueClass;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\GeoLocation;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* venue
|
||||
*/
|
||||
class _venue extends \IPS\Dispatcher\Controller
|
||||
class venue extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Venue we are viewing
|
||||
*/
|
||||
protected $venue = NULL;
|
||||
protected ?VenueClass $venue = NULL;
|
||||
|
||||
/**
|
||||
* Init
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->venue = \IPS\calendar\Venue::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
$this->venue = VenueClass::loadAndCheckPerms( Request::i()->id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2L354/1', 404, '' );
|
||||
Output::i()->error( 'node_error', '2L354/1', 404, '' );
|
||||
}
|
||||
|
||||
parent::execute();
|
||||
@@ -52,33 +68,33 @@ class _venue extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
public function manage() : void
|
||||
{
|
||||
/* Load the css for Calendar badges */
|
||||
\IPS\calendar\Calendar::addCss();
|
||||
Calendar::addCss();
|
||||
|
||||
$today = \IPS\calendar\Date::getDate();
|
||||
$today = 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 ) )
|
||||
if( ( !Request::i()->y OR Request::i()->y == $today->year ) AND ( !Request::i()->m OR 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 );
|
||||
$date = Date::getDate( Request::i()->y ?: NULL, Request::i()->m ?: NULL, $day );
|
||||
}
|
||||
catch( \InvalidArgumentException $e )
|
||||
catch( InvalidArgumentException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'error_bad_date', '2L354/2', 403, '' );
|
||||
Output::i()->error( 'error_bad_date', '2L354/2', 403, '' );
|
||||
}
|
||||
|
||||
$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 ),
|
||||
$upcoming = Event::retrieveEvents(
|
||||
Date::getDate( $date->firstDayOfMonth('year'), $date->firstDayOfMonth('mon'), $date->firstDayOfMonth('mday') ),
|
||||
Date::getDate( $date->lastDayOfMonth('year'), $date->lastDayOfMonth('mon'), $date->lastDayOfMonth('mday'), 23, 59, 59 ),
|
||||
NULL,
|
||||
NULL,
|
||||
FALSE,
|
||||
@@ -86,37 +102,37 @@ class _venue extends \IPS\Dispatcher\Controller
|
||||
$this->venue
|
||||
);
|
||||
|
||||
$upcomingOutput = \IPS\Theme::i()->getTemplate( 'venue', 'calendar', 'front' )->upcomingStream( $date, $upcoming, $this->venue );
|
||||
$upcomingOutput = 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();
|
||||
$address = GeoLocation::buildFromjson( $this->venue->address )->toString();
|
||||
}
|
||||
|
||||
/* Display */
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
if( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->sendOutput( $upcomingOutput, 200, 'text/html' );
|
||||
Output::i()->sendOutput( $upcomingOutput );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Add JSON-LD */
|
||||
\IPS\Output::i()->jsonLd['eventVenue'] = array(
|
||||
'@context' => "http://schema.org",
|
||||
Output::i()->jsonLd['eventVenue'] = array(
|
||||
'@context' => "https://schema.org",
|
||||
'@type' => "EventVenue",
|
||||
'url' => (string) $this->venue->url(),
|
||||
'name' => $this->venue->_title
|
||||
);
|
||||
|
||||
\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' ) );
|
||||
Output::i()->title = $this->venue->_title;
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, 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') );
|
||||
Output::i()->breadcrumb['module'] = array( Url::internal( "app=calendar&module=calendar&controller=view", 'front', 'calendar' ), Member::loggedIn()->language()->addToStack('module__calendar_calendar') );
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'venue', 'calendar', 'front' )->view( $this->venue, $upcomingOutput, NULL, $address );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'venue', 'calendar', 'front' )->view( $this->venue, $upcomingOutput, NULL, $address );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,68 +12,101 @@
|
||||
namespace IPS\calendar\modules\front\calendar;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use BadFunctionCallException;
|
||||
use DateInterval;
|
||||
use DatePeriod;
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use IPS\calendar\Calendar;
|
||||
use IPS\calendar\Date;
|
||||
use IPS\calendar\Event;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\GeoLocation;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\DateRange;
|
||||
use IPS\Helpers\Form\Select;
|
||||
use IPS\Helpers\Form\Text;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use function array_slice;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function intval;
|
||||
use function is_array;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calendar Views
|
||||
*/
|
||||
class _view extends \IPS\Dispatcher\Controller
|
||||
class view extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Calendar we are viewing
|
||||
*/
|
||||
protected $_calendar = NULL;
|
||||
protected ?Calendar $_calendar = NULL;
|
||||
|
||||
/**
|
||||
* @brief Date object for the current day
|
||||
*/
|
||||
protected $_today = NULL;
|
||||
protected ?Date $_today = NULL;
|
||||
|
||||
/**
|
||||
* @brief Root nodes
|
||||
*/
|
||||
protected $roots = NULL;
|
||||
protected ?array $roots = NULL;
|
||||
|
||||
/**
|
||||
* Route
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
/* We aren't showing a sidebar in Calendar */
|
||||
\IPS\Output::i()->sidebar['enabled'] = FALSE;
|
||||
\IPS\calendar\Calendar::addCss();
|
||||
Output::i()->sidebar['enabled'] = FALSE;
|
||||
Calendar::addCss();
|
||||
|
||||
/* Show the RSS link */
|
||||
if ( \IPS\Settings::i()->calendar_rss_feed )
|
||||
if ( Settings::i()->calendar_rss_feed )
|
||||
{
|
||||
$urls = $this->_downloadLinks();
|
||||
\IPS\Output::i()->rssFeeds['calendar_rss_title'] = $urls['rss'];
|
||||
Output::i()->rssFeeds['calendar_rss_title'] = $urls['rss'];
|
||||
}
|
||||
|
||||
/* Is there only one calendar? */
|
||||
$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 ) )
|
||||
$this->roots = Settings::i()->club_nodes_in_apps ? Calendar::rootsWithClubs() : Calendar::roots();
|
||||
if ( count( $this->roots ) == 1 AND !isset( Request::i()->id ) )
|
||||
{
|
||||
$root = array_shift( $this->roots );
|
||||
$this->_calendar = \IPS\calendar\Calendar::loadAndCheckPerms( $root->_id );
|
||||
$this->_calendar = Calendar::loadAndCheckPerms( $root->_id );
|
||||
}
|
||||
|
||||
/* Are we viewing a specific calendar only? */
|
||||
if( \IPS\Request::i()->id )
|
||||
if( Request::i()->id )
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->_calendar = \IPS\calendar\Calendar::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
$this->_calendar = Calendar::loadAndCheckPerms( Request::i()->id );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2L182/2', 404, '' );
|
||||
Output::i()->error( 'node_error', '2L182/2', 404, '' );
|
||||
}
|
||||
|
||||
/* If we're viewing a club, set the breadcrumbs appropriately */
|
||||
@@ -85,11 +118,11 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->breadcrumb[] = array( NULL, $this->_calendar->_title );
|
||||
Output::i()->breadcrumb[] = array( NULL, $this->_calendar->_title );
|
||||
}
|
||||
|
||||
/* Update Views */
|
||||
if ( !\IPS\Request::i()->isAjax() )
|
||||
if ( !Request::i()->isAjax() )
|
||||
{
|
||||
$this->_calendar->updateViews();
|
||||
}
|
||||
@@ -97,102 +130,102 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
|
||||
if( $this->_calendar !== NULL AND $this->_calendar->_id )
|
||||
{
|
||||
\IPS\Output::i()->contextualSearchOptions[ \IPS\Member::loggedIn()->language()->addToStack( 'search_contextual_item_calendars' ) ] = array( 'type' => 'calendar_event', 'nodes' => $this->_calendar->_id );
|
||||
Output::i()->contextualSearchOptions[ Member::loggedIn()->language()->addToStack( 'search_contextual_item_calendars' ) ] = array( 'type' => 'calendar_event', 'nodes' => $this->_calendar->_id );
|
||||
}
|
||||
|
||||
$this->_today = \IPS\calendar\Date::getDate();
|
||||
$this->_today = Date::getDate();
|
||||
|
||||
/* Get the date jumper - do this first in case we need to redirect */
|
||||
$jump = $this->_jump();
|
||||
|
||||
if( !\IPS\Request::i()->isAjax() )
|
||||
if( !Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_browse.js', 'calendar', 'front' ) );
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'front_browse.js', 'calendar', 'front' ) );
|
||||
}
|
||||
|
||||
/* If there is a view requested in the URL, use it */
|
||||
if( isset( \IPS\Request::i()->view ) )
|
||||
if( isset( Request::i()->view ) )
|
||||
{
|
||||
if( method_exists( $this, '_view' . ucwords( \IPS\Request::i()->view ) ) )
|
||||
if( method_exists( $this, '_view' . ucwords( Request::i()->view ) ) )
|
||||
{
|
||||
$method = "_view" . ucwords( \IPS\Request::i()->view );
|
||||
$method = "_view" . ucwords( Request::i()->view );
|
||||
$this->$method( $jump );
|
||||
}
|
||||
else
|
||||
{
|
||||
$method = "_view" . ucwords( \IPS\Settings::i()->calendar_default_view );
|
||||
$method = "_view" . ucwords( Settings::i()->calendar_default_view );
|
||||
$this->$method( $jump );
|
||||
}
|
||||
}
|
||||
/* Otherwise use ACP default preference */
|
||||
else
|
||||
{
|
||||
\IPS\Request::i()->view = \IPS\Settings::i()->calendar_default_view;
|
||||
$method = "_view" . ucwords( \IPS\Settings::i()->calendar_default_view );
|
||||
Request::i()->view = Settings::i()->calendar_default_view;
|
||||
$method = "_view" . ucwords( Settings::i()->calendar_default_view );
|
||||
$this->$method( $jump );
|
||||
}
|
||||
|
||||
/* Online User Location */
|
||||
if ( $this->_calendar )
|
||||
{
|
||||
\IPS\Session::i()->setLocation( $this->_calendar->url(), $this->_calendar->permissions()['perm_view'], 'loc_calendar_viewing_calendar', array( "calendar_calendar_{$this->_calendar->id}" => TRUE ) );
|
||||
Session::i()->setLocation( $this->_calendar->url(), $this->_calendar->permissions()['perm_view'], 'loc_calendar_viewing_calendar', array( "calendar_calendar_{$this->_calendar->id}" => TRUE ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Session::i()->setLocation( \IPS\Http\Url::internal( 'app=calendar', 'front', 'calendar' ), array(), 'loc_calendar_viewing_calendar_all' );
|
||||
Session::i()->setLocation( Url::internal( 'app=calendar', 'front', 'calendar' ), array(), 'loc_calendar_viewing_calendar_all' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show month view
|
||||
*
|
||||
* @param \IPS\Helpers\Form $jump Calendar jump
|
||||
* @param Form $jump Calendar jump
|
||||
* @return void
|
||||
*/
|
||||
protected function _viewMonth( $jump )
|
||||
protected function _viewMonth( Form $jump ) : void
|
||||
{
|
||||
/* Get the month data */
|
||||
$day = NULL;
|
||||
|
||||
if( ( !\IPS\Request::i()->y OR \IPS\Request::i()->y == $this->_today->year ) AND ( !\IPS\Request::i()->m OR \IPS\Request::i()->m == $this->_today->mon ) )
|
||||
if( ( !Request::i()->y OR Request::i()->y == $this->_today->year ) AND ( !Request::i()->m OR Request::i()->m == $this->_today->mon ) )
|
||||
{
|
||||
$day = $this->_today->mday;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$date = \IPS\calendar\Date::getDate( \IPS\Request::i()->y ?: NULL, \IPS\Request::i()->m ?: NULL, $day, 12 );
|
||||
$date = Date::getDate( Request::i()->y ?: NULL, Request::i()->m ?: NULL, $day, 12 );
|
||||
|
||||
/* 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 ),
|
||||
$events = Event::retrieveEvents(
|
||||
Date::getDate( $date->firstDayOfMonth('year'), $date->firstDayOfMonth('mon'), $date->firstDayOfMonth('mday') ),
|
||||
Date::getDate( $date->lastDayOfMonth('year'), $date->lastDayOfMonth('mon'), $date->lastDayOfMonth('mday'), 23, 59, 59 ),
|
||||
$this->_calendar
|
||||
);
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'error_bad_date', '2L182/7', 403, '' );
|
||||
Output::i()->error( 'error_bad_date', '2L182/7', 403, '' );
|
||||
}
|
||||
|
||||
/* 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';
|
||||
Output::i()->metaTags['robots'] = 'noindex';
|
||||
}
|
||||
|
||||
/* Display */
|
||||
$output = \IPS\Theme::i()->getTemplate( 'browse' )->calendarMonth( $this->roots, $date, $events, $this->_today, $this->_calendar, $jump );
|
||||
$output = Theme::i()->getTemplate( 'browse' )->calendarMonth( $this->roots, $date, $events, $this->_today, $this->_calendar, $jump );
|
||||
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
if( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->sendOutput( $output, 200, 'text/html' );
|
||||
Output::i()->sendOutput( $output );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('cal_month_title', FALSE, array( 'sprintf' => array( $date->monthName, $date->year ) ) );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('cal_month_title', FALSE, array( 'sprintf' => array( $date->monthName, $date->year ) ) );
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->calendarWrapper(
|
||||
Output::i()->output = Theme::i()->getTemplate( 'browse' )->calendarWrapper(
|
||||
$output,
|
||||
$this->roots,
|
||||
$this->_calendar,
|
||||
@@ -206,20 +239,20 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
/**
|
||||
* Show week view
|
||||
*
|
||||
* @param \IPS\Helpers\Form $jump Calendar jump
|
||||
* @param Form $jump Calendar jump
|
||||
* @return void
|
||||
*/
|
||||
protected function _viewWeek( $jump )
|
||||
protected function _viewWeek( Form $jump ) : void
|
||||
{
|
||||
/* Get the week data */
|
||||
$week = \IPS\Request::i()->w ? explode( '-', \IPS\Request::i()->w ) : NULL;
|
||||
$week = Request::i()->w ? explode( '-', Request::i()->w ) : NULL;
|
||||
try
|
||||
{
|
||||
$date = \IPS\calendar\Date::getDate( isset( $week[0] ) ? $week[0] : NULL, isset( $week[1] ) ? $week[1] : NULL, isset( $week[2] ) ? $week[2] : NULL );
|
||||
$date = Date::getDate( $week[0] ?? NULL, $week[1] ?? NULL, $week[2] ?? NULL);
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'error_bad_date', '2L182/8', 403, '' );
|
||||
Output::i()->error( 'error_bad_date', '2L182/8', 403, '' );
|
||||
}
|
||||
|
||||
$nextWeek = $date->adjust( '+1 week' );
|
||||
@@ -232,37 +265,37 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
|
||||
for( $i = 0; $i < 7; $i++ )
|
||||
{
|
||||
$days[] = \IPS\calendar\Date::getDate( $date->firstDayOfWeek('year'), $date->firstDayOfWeek('mon'), $date->firstDayOfWeek('mday') )->adjust( $i . ' days' );
|
||||
$days[] = Date::getDate( $date->firstDayOfWeek('year'), $date->firstDayOfWeek('mon'), $date->firstDayOfWeek('mday') )->adjust( $i . ' days' );
|
||||
}
|
||||
|
||||
/* Get the events within this range */
|
||||
$events = \IPS\calendar\Event::retrieveEvents(
|
||||
\IPS\calendar\Date::getDate( $date->firstDayOfWeek('year'), $date->firstDayOfWeek('mon'), $date->firstDayOfWeek('mday') ),
|
||||
\IPS\calendar\Date::getDate( $date->lastDayOfWeek('year'), $date->lastDayOfWeek('mon'), $date->lastDayOfWeek('mday'), 23, 59, 59 ),
|
||||
$events = Event::retrieveEvents(
|
||||
Date::getDate( $date->firstDayOfWeek('year'), $date->firstDayOfWeek('mon'), $date->firstDayOfWeek('mday') ),
|
||||
Date::getDate( $date->lastDayOfWeek('year'), $date->lastDayOfWeek('mon'), $date->lastDayOfWeek('mday'), 23, 59, 59 ),
|
||||
$this->_calendar
|
||||
);
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'error_bad_date', '2L182/C', 403, '' );
|
||||
Output::i()->error( 'error_bad_date', '2L182/C', 403, '' );
|
||||
}
|
||||
|
||||
/* 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';
|
||||
Output::i()->metaTags['robots'] = 'noindex';
|
||||
}
|
||||
|
||||
/* Display */
|
||||
$output = \IPS\Theme::i()->getTemplate( 'browse' )->calendarWeek( $this->roots, $date, $events, $nextWeek, $lastWeek, $days, $this->_today, $this->_calendar, $jump );
|
||||
$output = Theme::i()->getTemplate( 'browse' )->calendarWeek( $this->roots, $date, $events, $nextWeek, $lastWeek, $days, $this->_today, $this->_calendar, $jump );
|
||||
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
if( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->sendOutput( $output, 200, 'text/html' );
|
||||
Output::i()->sendOutput( $output );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('cal_week_title', FALSE, array( 'sprintf' => array(
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('cal_week_title', FALSE, array( 'sprintf' => array(
|
||||
$date->firstDayOfWeek('monthNameShort'),
|
||||
$date->firstDayOfWeek('mday'),
|
||||
$date->firstDayOfWeek('year'),
|
||||
@@ -271,7 +304,7 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
$date->lastDayOfWeek('year')
|
||||
) ) );
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->calendarWrapper(
|
||||
Output::i()->output = Theme::i()->getTemplate( 'browse' )->calendarWrapper(
|
||||
$output,
|
||||
$this->roots,
|
||||
$this->_calendar,
|
||||
@@ -285,31 +318,31 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
/**
|
||||
* Show day view
|
||||
*
|
||||
* @param \IPS\Helpers\Form $jump Calendar jump
|
||||
* @param Form $jump Calendar jump
|
||||
* @return void
|
||||
*/
|
||||
protected function _viewDay( $jump )
|
||||
protected function _viewDay( Form $jump ) : void
|
||||
{
|
||||
/* Get the day data */
|
||||
try
|
||||
{
|
||||
$date = \IPS\calendar\Date::getDate( \IPS\Request::i()->y ?: NULL, \IPS\Request::i()->m ?: NULL, \IPS\Request::i()->d ?: NULL );
|
||||
$date = Date::getDate( Request::i()->y ?: NULL, Request::i()->m ?: NULL, Request::i()->d ?: NULL );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'error_bad_date', '2L182/9', 403, '' );
|
||||
Output::i()->error( 'error_bad_date', '2L182/9', 403, '' );
|
||||
}
|
||||
|
||||
$tomorrow = clone $date->adjust( '+1 day' );
|
||||
$yesterday = clone $date->adjust( '-1 day' );
|
||||
|
||||
/* Get the events within this range */
|
||||
$events = \IPS\calendar\Event::retrieveEvents( clone $date, clone $date, $this->_calendar );
|
||||
$events = 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';
|
||||
Output::i()->metaTags['robots'] = 'noindex';
|
||||
}
|
||||
|
||||
$dayEvents = array_fill( 0, 23, array() );
|
||||
@@ -349,20 +382,20 @@ 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( $dayEvents['count'] === 0 )
|
||||
{
|
||||
\IPS\Output::i()->metaTags['robots'] = 'noindex';
|
||||
Output::i()->metaTags['robots'] = 'noindex';
|
||||
}
|
||||
|
||||
/* Display */
|
||||
$output = \IPS\Theme::i()->getTemplate( 'browse' )->calendarDay( $this->roots, $date, $dayEvents, $tomorrow, $yesterday, $this->_today, $this->_calendar, $jump );
|
||||
$output = Theme::i()->getTemplate( 'browse' )->calendarDay( $this->roots, $date, $dayEvents, $tomorrow, $yesterday, $this->_today, $this->_calendar, $jump );
|
||||
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
if( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->sendOutput( $output, 200, 'text/html' );
|
||||
Output::i()->sendOutput( $output );
|
||||
}
|
||||
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::i()->title = Member::loggedIn()->language()->addToStack('cal_month_day', FALSE, array( 'sprintf' => array( $date->monthName, $date->mday, $date->year ) ) );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'browse' )->calendarWrapper(
|
||||
$output,
|
||||
$this->roots,
|
||||
$this->_calendar,
|
||||
@@ -376,32 +409,32 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
/**
|
||||
* @brief Stream per page
|
||||
*/
|
||||
public $streamPerPage = 50;
|
||||
public int $streamPerPage = 50;
|
||||
|
||||
/**
|
||||
* Generate keyed links for RSS/iCal download
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function _downloadLinks()
|
||||
protected function _downloadLinks() : array
|
||||
{
|
||||
$downloadLinks = array( 'iCalCalendar' => '', 'iCalAll' => \IPS\Http\Url::internal( 'app=calendar&module=calendar&controller=view&do=download', 'front', 'calendar_icaldownload' ), 'rss' => \IPS\Http\Url::internal( 'app=calendar&module=calendar&controller=view&do=rss', 'front', 'calendar_rss' ) );
|
||||
$downloadLinks = array( 'iCalCalendar' => '', 'iCalAll' => Url::internal( 'app=calendar&module=calendar&controller=view&do=download', 'front', 'calendar_icaldownload' ), 'rss' => Url::internal( 'app=calendar&module=calendar&controller=view&do=rss', 'front', 'calendar_rss' ) );
|
||||
|
||||
if( $this->_calendar )
|
||||
{
|
||||
$downloadLinks['iCalCalendar'] = \IPS\Http\Url::internal( 'app=calendar&module=calendar&controller=view&id=' . $this->_calendar->id . '&do=download', 'front', 'calendar_calicaldownload', $this->_calendar->title_seo );
|
||||
$downloadLinks['iCalCalendar'] = Url::internal( 'app=calendar&module=calendar&controller=view&id=' . $this->_calendar->id . '&do=download', 'front', 'calendar_calicaldownload', $this->_calendar->title_seo );
|
||||
}
|
||||
|
||||
if ( \IPS\Member::loggedIn()->member_id )
|
||||
if ( Member::loggedIn()->member_id )
|
||||
{
|
||||
$key = \IPS\Member::loggedIn()->getUniqueMemberHash();
|
||||
$key = Member::loggedIn()->getUniqueMemberHash();
|
||||
|
||||
if( $this->_calendar )
|
||||
{
|
||||
$downloadLinks['iCalCalendar'] = $downloadLinks['iCalCalendar']->setQueryString( array( 'member' => \IPS\Member::loggedIn()->member_id , 'key' => $key ) );
|
||||
$downloadLinks['iCalCalendar'] = $downloadLinks['iCalCalendar']->setQueryString( array( 'member' => Member::loggedIn()->member_id , 'key' => $key ) );
|
||||
}
|
||||
$downloadLinks['iCalAll'] = $downloadLinks['iCalAll']->setQueryString( array( 'member' => \IPS\Member::loggedIn()->member_id , 'key' => $key ) );
|
||||
$downloadLinks['rss'] = $downloadLinks['rss']->setQueryString( array( 'member' => \IPS\Member::loggedIn()->member_id , 'key' => $key ) );
|
||||
$downloadLinks['iCalAll'] = $downloadLinks['iCalAll']->setQueryString( array( 'member' => Member::loggedIn()->member_id , 'key' => $key ) );
|
||||
$downloadLinks['rss'] = $downloadLinks['rss']->setQueryString( array( 'member' => Member::loggedIn()->member_id , 'key' => $key ) );
|
||||
}
|
||||
|
||||
return $downloadLinks;
|
||||
@@ -410,17 +443,17 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
/**
|
||||
* Return jump form and redirect if appropriate
|
||||
*
|
||||
* @return void
|
||||
* @return Form
|
||||
*/
|
||||
protected function _jump()
|
||||
protected function _jump() : Form
|
||||
{
|
||||
/* Build the form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Date( 'jump_to', \IPS\DateTime::create(), TRUE, array(), NULL, NULL, NULL, 'jump_to' ) );
|
||||
$form = new Form;
|
||||
$form->add( new Form\Date( 'jump_to', \IPS\DateTime::create(), TRUE, array(), NULL, NULL, NULL, 'jump_to' ) );
|
||||
|
||||
if( $values = $form->values() )
|
||||
{
|
||||
if( \IPS\Request::i()->goto )
|
||||
if( Request::i()->goto )
|
||||
{
|
||||
$dateToGoTo = \IPS\DateTime::create();
|
||||
}
|
||||
@@ -431,14 +464,14 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( $this->_calendar )
|
||||
{
|
||||
$url = \IPS\Http\Url::internal( "app=calendar&module=calendar&controller=view&view=day&id={$this->_calendar->_id}&y={$dateToGoTo->format('Y')}&m={$dateToGoTo->format('m')}&d={$dateToGoTo->format('j')}", 'front', 'calendar_calday', $this->_calendar->title_seo );
|
||||
$url = Url::internal( "app=calendar&module=calendar&controller=view&view=day&id={$this->_calendar->_id}&y={$dateToGoTo->format('Y')}&m={$dateToGoTo->format('m')}&d={$dateToGoTo->format('j')}", 'front', 'calendar_calday', $this->_calendar->title_seo );
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = \IPS\Http\Url::internal( "app=calendar&module=calendar&controller=view&view=day&y={$dateToGoTo->format('Y')}&m={$dateToGoTo->format('m')}&d={$dateToGoTo->format('j')}", 'front', 'calendar_day' );
|
||||
$url = Url::internal( "app=calendar&module=calendar&controller=view&view=day&y={$dateToGoTo->format('Y')}&m={$dateToGoTo->format('m')}&d={$dateToGoTo->format('j')}", 'front', 'calendar_day' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( $url );
|
||||
Output::i()->redirect( $url );
|
||||
}
|
||||
|
||||
return $form;
|
||||
@@ -449,24 +482,23 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _viewOverview()
|
||||
protected function _viewOverview() : void
|
||||
{
|
||||
$this->_today = \IPS\calendar\Date::getDate();
|
||||
$this->_today = Date::getDate();
|
||||
|
||||
/* Featured events */
|
||||
$featured = iterator_to_array( \IPS\calendar\Event::featured( 13, '_rand' ) );
|
||||
$featured = iterator_to_array( Event::featured( 13, '_rand' ) );
|
||||
|
||||
/* Get the calendars we can view */
|
||||
$calendars = \IPS\Settings::i()->club_nodes_in_apps ? \IPS\calendar\Calendar::rootsWithClubs() : \IPS\calendar\Calendar::roots();
|
||||
|
||||
|
||||
/* If there are no featured get upcoming */
|
||||
if( \count( $featured ) === 0 )
|
||||
if( count( $featured ) === 0 )
|
||||
{
|
||||
$featured = \IPS\calendar\Event::retrieveEvents(
|
||||
$featured = Event::retrieveEvents(
|
||||
$this->_today,
|
||||
\IPS\calendar\Date::getDate()->adjust( "next year" ),
|
||||
array_keys($calendars),
|
||||
Date::getDate()->adjust( "next year" ),
|
||||
array_keys( $calendars ),
|
||||
3,
|
||||
FALSE,
|
||||
NULL,
|
||||
@@ -478,30 +510,28 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Events near me */
|
||||
$location = NULL;
|
||||
if( isset( \IPS\Request::i()->lat ) and isset( \IPS\Request::i()->lon ) )
|
||||
if( isset( Request::i()->lat ) and isset( Request::i()->lon ) )
|
||||
{
|
||||
$location = array( 'lat' => \IPS\Request::i()->lat, 'lon' => \IPS\Request::i()->lon );
|
||||
$location = array( 'lat' => Request::i()->lat, 'lon' => Request::i()->lon );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Do an IP lookup */
|
||||
try
|
||||
{
|
||||
$geo = \IPS\GeoLocation::getRequesterLocation();
|
||||
$geo = GeoLocation::getRequesterLocation();
|
||||
$location = array( 'lat' => $geo->lat, 'lon' => $geo->long );
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
catch ( Exception $e )
|
||||
{
|
||||
$location = array( 'lat' => \IPS\Settings::i()->map_center_lat, 'lon' => \IPS\Settings::i()->map_center_lon );
|
||||
$location = array( 'lat' => Settings::i()->map_center_lat, 'lon' => Settings::i()->map_center_lon );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$nearme = \IPS\calendar\Event::retrieveEvents(
|
||||
$nearme = Event::retrieveEvents(
|
||||
$this->_today,
|
||||
\IPS\calendar\Date::getDate()->adjust( "next year" ),
|
||||
array_keys($calendars),
|
||||
Date::getDate()->adjust( "next year" ),
|
||||
array_keys( $calendars ),
|
||||
6,
|
||||
FALSE,
|
||||
NULL,
|
||||
@@ -519,10 +549,10 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Are we just returning nearby events? */
|
||||
if( \IPS\Request::i()->isAjax() && \IPS\Request::i()->get == 'nearMe' )
|
||||
if( Request::i()->isAjax() && Request::i()->get == 'nearMe' )
|
||||
{
|
||||
$output = \IPS\Theme::i()->getTemplate( 'events', 'calendar' )->nearMeContent( $nearme, $mapMarkers );
|
||||
\IPS\Member::loggedIn()->language()->parseOutputForDisplay( $output );
|
||||
$output = Theme::i()->getTemplate( 'events', 'calendar' )->nearMeContent( $nearme, $mapMarkers );
|
||||
Member::loggedIn()->language()->parseOutputForDisplay( $output );
|
||||
|
||||
$toReturn = array(
|
||||
'content' => $output,
|
||||
@@ -530,27 +560,26 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
'long' => (float) $location['lon']
|
||||
);
|
||||
|
||||
\IPS\Output::i()->sendOutput( json_encode($toReturn), 200, 'application/json' );
|
||||
return;
|
||||
Output::i()->sendOutput( json_encode($toReturn), 200, 'application/json' );
|
||||
}
|
||||
|
||||
/* By month */
|
||||
$day = NULL;
|
||||
|
||||
if( ( !\IPS\Request::i()->y OR \IPS\Request::i()->y == $this->_today->year ) AND ( !\IPS\Request::i()->m OR \IPS\Request::i()->m == $this->_today->mon ) )
|
||||
if( ( !Request::i()->y OR Request::i()->y == $this->_today->year ) AND ( !Request::i()->m OR Request::i()->m == $this->_today->mon ) )
|
||||
{
|
||||
$day = $this->_today->mday;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$date = \IPS\calendar\Date::getDate( \IPS\Request::i()->y ?: NULL, \IPS\Request::i()->m ?: NULL, $day );
|
||||
$date = Date::getDate( Request::i()->y ?: NULL, Request::i()->m ?: NULL, $day, 12 );
|
||||
|
||||
/* 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 ),
|
||||
array_keys($calendars),
|
||||
$events = Event::retrieveEvents(
|
||||
Date::getDate( $date->firstDayOfMonth('year'), $date->firstDayOfMonth('mon'), $date->firstDayOfMonth('mday') ),
|
||||
Date::getDate( $date->lastDayOfMonth('year'), $date->lastDayOfMonth('mon'), $date->lastDayOfMonth('mday'), 23, 59, 59 ),
|
||||
array_keys( $calendars ),
|
||||
NULL,
|
||||
FALSE,
|
||||
NULL,
|
||||
@@ -558,13 +587,13 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
FALSE
|
||||
);
|
||||
}
|
||||
catch( \InvalidArgumentException $e )
|
||||
catch( InvalidArgumentException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'error_bad_date', '', 403, '' ); //@todo
|
||||
Output::i()->error( 'error_bad_date', '', 403, '' ); //@todo
|
||||
}
|
||||
|
||||
/* Sort */
|
||||
$startDate = \IPS\calendar\Date::getDate();
|
||||
$startDate = Date::getDate();
|
||||
@usort( $events, function( $a, $b ) use ( $startDate )
|
||||
{
|
||||
if( $a->nextOccurrence( $startDate, 'startDate' ) === NULL )
|
||||
@@ -586,50 +615,49 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
} );
|
||||
|
||||
/* Pagination */
|
||||
$offset = isset( \IPS\Request::i()->offset ) ? min( [(int) \IPS\Request::i()->offset, \count( $events )] ) : 0;
|
||||
$offset = isset( Request::i()->offset ) ? min( [ (int) Request::i()->offset, count( $events ) ] ) : 0;
|
||||
|
||||
/* 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';
|
||||
Output::i()->metaTags['robots'] = 'noindex';
|
||||
}
|
||||
else
|
||||
{
|
||||
$events = \array_slice( $events, $offset, $this->streamPerPage );
|
||||
$events = array_slice( $events, $offset, $this->streamPerPage );
|
||||
}
|
||||
|
||||
/* Return events if we're after those specifically */
|
||||
if( \IPS\Request::i()->isAjax() && \IPS\Request::i()->get == 'byMonth' )
|
||||
if( Request::i()->isAjax() && Request::i()->get == 'byMonth' )
|
||||
{
|
||||
$eventHtml = "";
|
||||
|
||||
if( \count( $events ) )
|
||||
if( count( $events ) )
|
||||
{
|
||||
foreach( $events as $idx => $event )
|
||||
{
|
||||
$eventHtml .= \IPS\Theme::i()->getTemplate( 'events', 'calendar' )->event( $event );
|
||||
$eventHtml .= Theme::i()->getTemplate( 'events', 'calendar' )->event( $event );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$eventHtml = \IPS\Theme::i()->getTemplate( 'events', 'calendar' )->noEvents();
|
||||
$eventHtml = Theme::i()->getTemplate( 'events', 'calendar' )->noEvents();
|
||||
}
|
||||
|
||||
\IPS\Member::loggedIn()->language()->parseOutputForDisplay( $eventHtml );
|
||||
Member::loggedIn()->language()->parseOutputForDisplay( $eventHtml );
|
||||
|
||||
$toReturn = array(
|
||||
'count' => \count( $events ),
|
||||
'count' => count( $events ),
|
||||
'html' => $eventHtml
|
||||
);
|
||||
|
||||
\IPS\Output::i()->sendOutput( json_encode( $toReturn ), 200, 'application/json' );
|
||||
return;
|
||||
Output::i()->sendOutput( json_encode( $toReturn ), 200, 'application/json' );
|
||||
}
|
||||
|
||||
/* Non-existent page */
|
||||
if( $offset > 0 && !\count( $events ) )
|
||||
if( $offset > 0 && !count( $events ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_events_month', '2L182/B', 404, '' );
|
||||
Output::i()->error( 'no_events_month', '2L182/B', 404, '' );
|
||||
}
|
||||
|
||||
/* Clone date so we can update time without affecting other areas on this page */
|
||||
@@ -640,10 +668,10 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
$endTime->setTime(23,59,59);
|
||||
|
||||
/* Online */
|
||||
$online = \IPS\calendar\Event::retrieveEvents(
|
||||
$online = Event::retrieveEvents(
|
||||
$startTime,
|
||||
NULL,
|
||||
array_keys($calendars),
|
||||
array_keys( $calendars ),
|
||||
NULL,
|
||||
FALSE,
|
||||
NULL,
|
||||
@@ -654,42 +682,41 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
);
|
||||
|
||||
/* Build an array of month objects for the nav */
|
||||
$months = new \DatePeriod( (new \DateTime)->setDate( date('Y'), date('m'), 1 ), new \DateInterval( 'P1M' ), 11 );
|
||||
$months = new DatePeriod( (new DateTime)->setDate( date('Y'), date('m'), 1 ), new DateInterval( 'P1M' ), 11 );
|
||||
|
||||
$stream = \IPS\Theme::i()->getTemplate( 'overview', 'calendar' )->byMonth( $calendars, \IPS\calendar\Date::getDate( $date->firstDayOfMonth('year'), $date->firstDayOfMonth('mon'), $date->firstDayOfMonth('mday') ), $featured, $events, NULL, $months );
|
||||
$stream = Theme::i()->getTemplate( 'overview', 'calendar' )->byMonth( $calendars, Date::getDate( $date->firstDayOfMonth('year'), $date->firstDayOfMonth('mon'), $date->firstDayOfMonth('mday') ), $featured, $events, NULL, $months );
|
||||
|
||||
$form = $this->getForm();
|
||||
|
||||
$date = \IPS\calendar\Date::getDate();
|
||||
$date = Date::getDate();
|
||||
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
if( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->sendOutput( $stream, 200, 'text/html' );
|
||||
Output::i()->sendOutput( $stream );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_overview.js', 'calendar', 'front' ) );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( '__app_calendar' );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'overview' )->wrapper( $featured, $nearme, $stream, $form, $mapMarkers, $online, $date, $this->_downloadLinks() );
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'front_overview.js', 'calendar', 'front' ) );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( '__app_calendar' );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'overview' )->wrapper( $featured, $nearme, $stream, $form, $mapMarkers, $online, $date, $this->_downloadLinks() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Build search form
|
||||
*
|
||||
* @return \IPS\Helpers\Form
|
||||
* @return Form
|
||||
*/
|
||||
public function getForm()
|
||||
public function getForm() : Form
|
||||
{
|
||||
/* Search form */
|
||||
$form = new \IPS\Helpers\Form('form', 'search', \IPS\Http\Url::internal( 'app=calendar&module=calendar&controller=view&do=search', 'front', 'calendar_event_search' ) );
|
||||
if ( \IPS\GeoLocation::enabled() )
|
||||
$form = new Form('form', 'search', Url::internal( 'app=calendar&module=calendar&controller=view&do=search', 'front', 'calendar_event_search' ) );
|
||||
if ( GeoLocation::enabled() )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'location', FALSE, \IPS\Request::i()->location, array( 'placeholder' => \IPS\Member::loggedIn()->language()->addToStack( 'events_search_search_location') ) ) );
|
||||
$form->add( new Text( 'location', FALSE, Request::i()->location, array( 'placeholder' => Member::loggedIn()->language()->addToStack( 'events_search_search_location') ) ) );
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\DateRange( 'date', array( 'start' => NULL, 'end' => NULL ), FALSE, array() ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'show', 'all', FALSE, array( 'options' => array('all' => \IPS\Member::loggedIn()->language()->addToStack( 'all_events' ), 'online' => \IPS\Member::loggedIn()->language()->addToStack( 'online_events' ), 'physical' => \IPS\Member::loggedIn()->language()->addToStack( 'physical_events' ) ) ) ) );
|
||||
$form->add( new DateRange( 'date', array( 'start' => NULL, 'end' => NULL ), FALSE, array() ) );
|
||||
$form->add( new Select( 'show', 'all', FALSE, array( 'options' => array('all' => Member::loggedIn()->language()->addToStack( 'all_events' ), 'online' => Member::loggedIn()->language()->addToStack( 'online_events' ), 'physical' => Member::loggedIn()->language()->addToStack( 'physical_events' ) ) ) ) );
|
||||
|
||||
return $form;
|
||||
}
|
||||
@@ -699,9 +726,9 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function search()
|
||||
protected function search() : void
|
||||
{
|
||||
\IPS\Output::i()->bypassCsrfKeyCheck = TRUE;
|
||||
Output::i()->bypassCsrfKeyCheck = TRUE;
|
||||
$results = array();
|
||||
|
||||
/* Build the search form */
|
||||
@@ -714,25 +741,25 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
$where = [];
|
||||
$where[] = ['event_approved=?', 1];
|
||||
$searchNearLocation = FALSE; // Should results be limited to near the provided location only? If not, we'll just use location to allow sorting.
|
||||
|
||||
|
||||
if( $values = $form->values() )
|
||||
{
|
||||
if( isset( \IPS\Request::i()->searchNearLocation ) && \IPS\Request::i()->searchNearLocation )
|
||||
if( isset( Request::i()->searchNearLocation ) && Request::i()->searchNearLocation )
|
||||
{
|
||||
$searchNearLocation = TRUE;
|
||||
}
|
||||
|
||||
if( \IPS\GeoLocation::enabled() )
|
||||
if( GeoLocation::enabled() )
|
||||
{
|
||||
if( \IPS\Request::i()->location )
|
||||
if( Request::i()->location )
|
||||
{
|
||||
/* Is it a location? */
|
||||
$locations = static::geocodeLocation( \IPS\Request::i()->location, FALSE );
|
||||
if( \is_array( $locations ) and \count( $locations ) )
|
||||
$locations = static::geocodeLocation( Request::i()->location, FALSE );
|
||||
if( count( $locations ) )
|
||||
{
|
||||
if( $locations[0]['value'] )
|
||||
{
|
||||
$having[] = "( event_title LIKE CONCAT( '%', '" . \IPS\Db::i()->real_escape_string( $locations[0]['value'] ) . "', '%' ) OR name LIKE CONCAT( '%', '" . \IPS\Db::i()->real_escape_string( $locations[0]['value'] ) . "', '%' ) )";
|
||||
$having[] = "( event_title LIKE CONCAT( '%', '" . $locations[0]['value'] . "', '%' ) OR name LIKE CONCAT( '%', '" . $locations[0]['value'] . "', '%' ) )";
|
||||
}
|
||||
|
||||
$location = array( 'lat' => $locations[0]['lat'], 'lon' => $locations[0]['long'] );
|
||||
@@ -740,12 +767,12 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
$having[] = "( event_title LIKE CONCAT( '%', '" . \IPS\Db::i()->real_escape_string( \IPS\Request::i()->location ) . "', '%' ) OR name LIKE CONCAT( '%', '" . \IPS\Db::i()->real_escape_string( \IPS\Request::i()->location ) . "', '%' ) )";
|
||||
$having[] = "( event_title LIKE CONCAT( '%', '" . Request::i()->location . "', '%' ) OR name LIKE CONCAT( '%', '" . Request::i()->location . "', '%' ) )";
|
||||
}
|
||||
}
|
||||
else if ( isset( \IPS\Request::i()->lat ) and isset( \IPS\Request::i()->lon ) and \IPS\Request::i()->lat !== 0 and \IPS\Request::i()->lon !== 0 )
|
||||
else if ( isset( Request::i()->lat ) and isset( Request::i()->lon ) and Request::i()->lat !== 0 and Request::i()->lon !== 0 )
|
||||
{
|
||||
$location = array( 'lat' => \IPS\Request::i()->lat, 'lon' => \IPS\Request::i()->lon );
|
||||
$location = array( 'lat' => Request::i()->lat, 'lon' => Request::i()->lon );
|
||||
$searchNearLocation = TRUE;
|
||||
}
|
||||
elseif( $searchNearLocation )
|
||||
@@ -753,16 +780,16 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
/* Do an IP lookup */
|
||||
try
|
||||
{
|
||||
$geo = \IPS\GeoLocation::getRequesterLocation();
|
||||
$geo = GeoLocation::getRequesterLocation();
|
||||
$location = array( 'lat' => $geo->lat, 'lon' => $geo->long );
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
catch ( Exception $e )
|
||||
{
|
||||
$location = array( 'lat' => \IPS\Settings::i()->map_center_lat, 'lon' => \IPS\Settings::i()->map_center_lon );
|
||||
$location = array( 'lat' => Settings::i()->map_center_lat, 'lon' => Settings::i()->map_center_lon );
|
||||
}
|
||||
}
|
||||
|
||||
if ( \is_array( $location ) and isset( $location['lat'] ) and isset( $location['lon'] ) and is_numeric( $location['lat'] ) and is_numeric( $location['lon'] ) )
|
||||
if ( is_array( $location ) and isset( $location['lat'] ) and isset( $location['lon'] ) and is_numeric( $location['lat'] ) and is_numeric( $location['lon'] ) )
|
||||
{
|
||||
$select = $select . ', ( 3959 * acos( cos( radians(' . $location['lat'] . ') ) * cos( radians( event_latitude ) ) * cos( radians( event_longitude ) - radians(' . $location['lon'] . ') ) + sin( radians(' . $location['lat'] . ') ) * sin(radians(event_latitude)) ) ) AS distance';
|
||||
|
||||
@@ -771,7 +798,7 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
$having[] = 'distance < 500';
|
||||
}
|
||||
|
||||
if( isset( \IPS\Request::i()->sortBy ) && \IPS\Request::i()->sortBy == 'nearest' )
|
||||
if( isset( Request::i()->sortBy ) && Request::i()->sortBy == 'nearest' )
|
||||
{
|
||||
$sort = 'distance asc';
|
||||
}
|
||||
@@ -779,9 +806,9 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Filter? */
|
||||
if( isset( \IPS\Request::i()->show ) && \IPS\Request::i()->show !== 'all' )
|
||||
if( isset( Request::i()->show ) && Request::i()->show !== 'all' )
|
||||
{
|
||||
if( \IPS\Request::i()->show == 'online' )
|
||||
if( Request::i()->show == 'online' )
|
||||
{
|
||||
$where[] = array( '( event_online = 1 )' );
|
||||
}
|
||||
@@ -790,23 +817,23 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
$today = new \IPS\calendar\Date;
|
||||
$member = \IPS\Member::loggedIn();
|
||||
$today = new Date;
|
||||
$member = Member::loggedIn();
|
||||
|
||||
$startDate = \IPS\calendar\Date::dateTimeToCalendarDate( $values['date']['start'] ?: $today );
|
||||
$endDate = $values['date']['end'] ? \IPS\calendar\Date::dateTimeToCalendarDate( $values['date']['end'] ) : NULL;
|
||||
$startDate = Date::dateTimeToCalendarDate( $values['date']['start'] ?: $today );
|
||||
$endDate = $values['date']['end'] ? Date::dateTimeToCalendarDate( $values['date']['end'] ) : NULL;
|
||||
|
||||
/* Get timezone adjusted versions of start/end time */
|
||||
$startDateTimezone = \IPS\calendar\Date::parseTime( $startDate->mysqlDatetime(), TRUE );
|
||||
$endDateTimezone = ( $endDate !== NULL ) ? \IPS\calendar\Date::parseTime( $endDate->mysqlDatetime() ) : NULL;
|
||||
$startDateTimezone = Date::parseTime( $startDate->mysqlDatetime(), TRUE );
|
||||
$endDateTimezone = ( $endDate !== NULL ) ? Date::parseTime( $endDate->mysqlDatetime() ) : NULL;
|
||||
|
||||
if ( $member->timezone )
|
||||
{
|
||||
$startDateTimezone->setTimezone( new \DateTimeZone( 'UTC' ) );
|
||||
$startDateTimezone->setTimezone( new DateTimeZone( 'UTC' ) );
|
||||
|
||||
if( $endDateTimezone !== NULL )
|
||||
{
|
||||
$endDateTimezone->setTimezone( new \DateTimeZone( 'UTC' ) );
|
||||
$endDateTimezone->setTimezone( new DateTimeZone( 'UTC' ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -874,13 +901,13 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
);
|
||||
}
|
||||
|
||||
$offset = isset( \IPS\Request::i()->offset ) ? \intval( \IPS\Request::i()->offset ) : 0;
|
||||
$limit = isset( \IPS\Request::i()->limit ) ? min( array( \intval( \IPS\Request::i()->limit ), 50 ) ) : 20;
|
||||
$query = \IPS\Db::i()->select( $select, 'calendar_events', $where, $sort, array( $offset, $limit ), NULL, implode( " OR ", $having ) );
|
||||
$offset = isset( Request::i()->offset ) ? intval( Request::i()->offset ) : 0;
|
||||
$limit = isset( Request::i()->limit ) ? min( array( intval( Request::i()->limit ), 50 ) ) : 20;
|
||||
$query = Db::i()->select( $select, 'calendar_events', $where, $sort, array( $offset, $limit ), NULL, implode( " OR ", $having ) );
|
||||
$query->join( 'calendar_calendars', "event_calendar_id = cal_id" );
|
||||
$query->join( 'core_clubs', "cal_club_id = id" );
|
||||
|
||||
$results = new \IPS\Patterns\ActiveRecordIterator( $query, '\IPS\calendar\Event' );
|
||||
$results = new ActiveRecordIterator( $query, '\IPS\calendar\Event' );
|
||||
}
|
||||
|
||||
$mapMarkers = array();
|
||||
@@ -892,48 +919,45 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
if( \IPS\Request::i()->isAjax() ){
|
||||
|
||||
$countQuery = \IPS\Db::i()->select( $select, 'calendar_events', $where, NULL, array(), NULL, is_array( $having ) ? implode( " OR ", $having ) : NULL );
|
||||
if( Request::i()->isAjax() )
|
||||
{
|
||||
$countQuery = Db::i()->select( $select, 'calendar_events', $where, NULL, array(), NULL, is_array( $having ) ? implode( " OR ", $having ) : NULL );
|
||||
$countQuery->join( 'calendar_calendars', "event_calendar_id = cal_id" );
|
||||
$countQuery->join( 'core_clubs', "cal_club_id = id" );
|
||||
|
||||
$output = \IPS\Theme::i()->getTemplate( 'events' )->searchResults( $results );
|
||||
\IPS\Member::loggedIn()->language()->parseOutputForDisplay( $output );
|
||||
$output = Theme::i()->getTemplate( 'events' )->searchResults( $results );
|
||||
Member::loggedIn()->language()->parseOutputForDisplay( $output );
|
||||
|
||||
$toReturn = array(
|
||||
'totalCount' => $countQuery->count(),
|
||||
'count' => \count( $results ),
|
||||
'count' => count( $results ),
|
||||
'content' => $output,
|
||||
'markers' => $mapMarkers,
|
||||
'blurb' => '', // @todo
|
||||
'online' => ( \IPS\Request::i()->show == 'online' )
|
||||
'online' => ( Request::i()->show == 'online' )
|
||||
);
|
||||
|
||||
\IPS\Output::i()->sendOutput( json_encode( $toReturn ), 200, 'application/json' );
|
||||
return;
|
||||
Output::i()->sendOutput( json_encode( $toReturn ), 200, 'application/json' );
|
||||
}
|
||||
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( '__app_calendar' );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'overview' )->search( $form, $results, json_encode( $mapMarkers ) );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( '__app_calendar' );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'overview' )->search( $form, $results, json_encode( $mapMarkers ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Geocode Location
|
||||
*
|
||||
* @param string $input Location search term
|
||||
* @param string|null $input Location search term
|
||||
* @param bool $asJson Return type
|
||||
* @return array|string
|
||||
* @return array
|
||||
*/
|
||||
public static function geocodeLocation( $input = NULL, $asJson = TRUE )
|
||||
public static function geocodeLocation( ?string $input = NULL, bool $asJson = TRUE ) : array
|
||||
{
|
||||
$items = array();
|
||||
|
||||
try
|
||||
{
|
||||
$geolocation = \IPS\GeoLocation::geocodeLocation( $input );
|
||||
if( $geolocation instanceof \IPS\GeoLocation )
|
||||
if( $geolocation = GeoLocation::geocodeLocation( $input ) )
|
||||
{
|
||||
$items[] = array(
|
||||
'value' => $geolocation->placeName,
|
||||
@@ -943,11 +967,11 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
);
|
||||
}
|
||||
}
|
||||
catch( \BadFunctionCallException ){}
|
||||
catch( BadFunctionCallException $e ){}
|
||||
|
||||
if( $asJson )
|
||||
{
|
||||
\IPS\Output::i()->json( $items );
|
||||
Output::i()->json( $items );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user