Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
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