Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

+27 -28
View File
@@ -12,7 +12,7 @@
namespace IPS\forums\widgets;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -37,24 +37,7 @@ class _poll extends \IPS\Widget
* @brief Plugin
*/
public $plugin = '';
/**
* Initialise this widget
*
* @return void
*/
public function init()
{
// Use this to perform any set up and to assign a template that is not in the following format:
// $this->template( array( \IPS\Theme::i()->getTemplate( 'widgets', $this->app, 'front' ), $this->key ) );
// If you are creating a plugin, uncomment this line:
// $this->template( array( \IPS\Theme::i()->getTemplate( 'plugins', 'core', 'global' ), $this->key ) );
// And then create your template at located at plugins/<your plugin>/dev/html/poll.phtml
parent::init();
}
/**
* Specify widget configuration
*
@@ -63,16 +46,24 @@ class _poll extends \IPS\Widget
*/
public function configuration( &$form=null )
{
if ( $form === null )
{
$form = new \IPS\Helpers\Form;
}
$form = parent::configuration( $form );
$form->add( new \IPS\Helpers\Form\Item( 'widget_poll_tid', ( isset( $this->configuration['widget_poll_tid'] ) ? $this->configuration['widget_poll_tid'] : NULL ), TRUE, array(
'class' => '\IPS\forums\Topic',
'maxItems' => 1,
'where' => array( array( '(poll_state<>0 AND poll_state IS NOT NULL)' ) )
) ) );
), function( $val ) {
/* Even though we only allow one item, $val here is always an array. */
foreach( $val AS $id => $topic )
{
$poll = $topic->getPoll();
if ( $poll === NULL )
{
/* poll_state is set to something other than 0 or NULL, but the poll doesn't exist, so let the user know. */
throw new \DomainException( 'poll_widget_no_poll' );
}
}
} ) );
return $form;
}
@@ -106,10 +97,18 @@ class _poll extends \IPS\Widget
{
$topic = \IPS\forums\Topic::loadAndCheckPerms( $this->configuration['widget_poll_tid'] );
$poll = $topic->getPoll();
$poll->displayTemplate = array( \IPS\Theme::i()->getTemplate( 'widgets', 'forums', 'front' ), 'pollWidget' );
$poll->url = $topic->url();
return $this->output( $topic, $poll );
if ( $poll )
{
$poll->displayTemplate = array( \IPS\Theme::i()->getTemplate( 'widgets', 'forums', 'front' ), 'pollWidget' );
$poll->url = $topic->url();
return $this->output( $topic, $poll );
}
else
{
return '';
}
}
catch( \Exception $ex )
{