Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -46,10 +46,7 @@ class _hotTopics extends \IPS\Widget\PermissionCache
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
if ( $form === null )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
}
|
||||
$form = parent::configuration( $form );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'number_to_show', isset( $this->configuration['number_to_show'] ) ? $this->configuration['number_to_show'] : 5, TRUE ) );
|
||||
|
||||
@@ -64,7 +61,7 @@ class _hotTopics extends \IPS\Widget\PermissionCache
|
||||
public function render()
|
||||
{
|
||||
$topics = \IPS\forums\Topic::getItemsWithPermission( array( array( 'popular_time > ? AND forums_forums.password IS NULL AND forums_forums.can_view_others=1', time() ) ), NULL, isset( $this->configuration['number_to_show'] ) ? $this->configuration['number_to_show'] : 5, 'read', \IPS\Content\Hideable::FILTER_PUBLIC_ONLY );
|
||||
if ( count( $topics ) )
|
||||
if ( \count( $topics ) )
|
||||
{
|
||||
return $this->output( $topics );
|
||||
}
|
||||
|
||||
@@ -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 )
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
@@ -48,6 +48,33 @@ class _postFeed extends \IPS\Content\WidgetComment
|
||||
*/
|
||||
protected $moderatorPermissions = array( 'can_view_hidden_content', 'can_view_hidden_post' );
|
||||
|
||||
/**
|
||||
* Return the form elements to use
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function formElements()
|
||||
{
|
||||
$elements = parent::formElements();
|
||||
|
||||
$class = static::$class;
|
||||
$itemClass = $class::$itemClass;
|
||||
|
||||
$elements['container'] = new \IPS\Helpers\Form\Node( 'widget_feed_container_' . $itemClass::$title, isset( $this->configuration['widget_feed_container'] ) ? $this->configuration['widget_feed_container'] : 0, FALSE, array(
|
||||
'class' => $itemClass::$containerNodeClass,
|
||||
'zeroVal' => 'all_public',
|
||||
'permissionCheck' => function ( $forum )
|
||||
{
|
||||
return $forum->can('view') and $forum->sub_can_post and !$forum->redirect_url and $forum->can_view_others;
|
||||
},
|
||||
'multiple' => true,
|
||||
'forceOwner' => false,
|
||||
'clubs' => TRUE
|
||||
) );
|
||||
|
||||
return $elements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get where clause
|
||||
*
|
||||
|
||||
@@ -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;
|
||||
@@ -43,6 +43,32 @@ class _topicFeed extends \IPS\Content\Widget
|
||||
*/
|
||||
protected static $class = 'IPS\forums\Topic';
|
||||
|
||||
/**
|
||||
* Return the form elements to use
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function formElements()
|
||||
{
|
||||
$elements = parent::formElements();
|
||||
|
||||
$class = static::$class;
|
||||
|
||||
$elements['container'] = new \IPS\Helpers\Form\Node( 'widget_feed_container_' . $class::$title, isset( $this->configuration['widget_feed_container'] ) ? $this->configuration['widget_feed_container'] : 0, FALSE, array(
|
||||
'class' => $class::$containerNodeClass,
|
||||
'zeroVal' => 'all_public',
|
||||
'permissionCheck' => function ( $forum )
|
||||
{
|
||||
return $forum->can('view') and $forum->sub_can_post and !$forum->redirect_url and $forum->can_view_others;
|
||||
},
|
||||
'multiple' => true,
|
||||
'forceOwner' => false,
|
||||
'clubs' => TRUE
|
||||
) );
|
||||
|
||||
return $elements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get where clause
|
||||
*
|
||||
@@ -55,6 +81,7 @@ class _topicFeed extends \IPS\Content\Widget
|
||||
{
|
||||
$where['container'][] = array( 'forums_forums.password IS NULL AND forums_forums.can_view_others=1' );
|
||||
}
|
||||
|
||||
return $where;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user