Version 4.1.2

This commit is contained in:
Neo committed 2025-12-19 05:32:19 -08:00
1 parent 3ba79295ee
commit 28bd025b35
1131 files changed
+63658 -20579

No files matched your search

@@ -44,7 +44,26 @@ class _upcomingEvents extends \IPS\Widget\PermissionCache
* @note We allow this cache to be valid for 12 hours
*/
public $cacheExpiration = 43200;
/**
* Constructor
*
* @param String $uniqueKey Unique key for this specific instance
* @param array $configuration Widget custom configuration
* @param null|string|array $access Array/JSON string of executable apps (core=sidebar only, content=IP.Content only, etc)
* @param null|string $orientation Orientation (top, bottom, right, left)
* @param boolean $allowReuse If true, when the block is used, it will remain in the sidebar so it can be used again.
* @param string $menuStyle Menu is a drop down menu, modal is a bigger modal panel.
* @return void
*/
public function __construct( $uniqueKey, array $configuration, $access=null, $orientation=null )
{
parent::__construct( $uniqueKey, $configuration, $access, $orientation );
/* We need to adjust for timezone too */
$this->cacheKey = "widget_{$this->key}_" . $this->uniqueKey . '_' . md5( json_encode( $configuration ) . "_" . \IPS\Member::loggedIn()->language()->id . "_" . \IPS\Member::loggedIn()->skin . "_" . json_encode( \IPS\Member::loggedIn()->groups ) . "_" . $orientation . \IPS\Member::loggedIn()->timezone );
}
/**
* Initialize this widget
*
@@ -70,12 +89,36 @@ class _upcomingEvents extends \IPS\Widget\PermissionCache
$form = new \IPS\Helpers\Form;
}
/* Container */
$form->add( new \IPS\Helpers\Form\Node( 'widget_calendar', isset( $this->configuration['widget_calendar'] ) ? $this->configuration['widget_calendar'] : 0, FALSE, array(
'class' => '\IPS\calendar\Calendar',
'zeroVal' => 'all',
'permissionCheck' => 'view',
'multiple' => true
) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'auto_hide', isset( $this->configuration['auto_hide'] ) ? $this->configuration['auto_hide'] : FALSE, FALSE ) );
$form->add( new \IPS\Helpers\Form\Number( 'days_ahead', isset( $this->configuration['days_ahead'] ) ? $this->configuration['days_ahead'] : NULL, TRUE, array( 'unlimited' => -1 ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'maximum_count', isset( $this->configuration['maximum_count'] ) ? $this->configuration['maximum_count'] : 5, TRUE, array( 'unlimited' => -1 ) ) );
return $form;
}
/**
* Ran before saving widget configuration
*
* @param array $values Values from form
* @return array
*/
public function preConfig( $values )
{
if ( is_array( $values['widget_calendar'] ) )
{
$values['widget_calendar'] = array_keys( $values['widget_calendar'] );
}
return $values;
}
/**
* Render a widget
*
@@ -97,8 +140,15 @@ class _upcomingEvents extends \IPS\Widget\PermissionCache
{
$endDate = $_today->adjust( "+" . $this->configuration['days_ahead'] . " days" );
}
$events = \IPS\calendar\Event::retrieveEvents( $_today, $endDate, NULL, ( isset( $this->configuration['maximum_count'] ) AND $this->configuration['maximum_count'] > 0 ) ? $this->configuration['maximum_count'] : 5, FALSE );
$calendars = NULL;
if ( ! empty( $this->configuration['widget_calendar'] ) )
{
$calendars = $this->configuration['widget_calendar'];
}
$events = \IPS\calendar\Event::retrieveEvents( $_today, $endDate, $calendars, ( isset( $this->configuration['maximum_count'] ) AND $this->configuration['maximum_count'] > 0 ) ? $this->configuration['maximum_count'] : 5, FALSE );
/* Auto hiding? */
if( !count($events) AND isset( $this->configuration['auto_hide'] ) AND $this->configuration['auto_hide'] )