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,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' );
}
}