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

+10 -162
View File
@@ -20,9 +20,9 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
}
/**
* latestTopics Widget
* postFeed Widget
*/
class _postFeed extends \IPS\Widget\PermissionCache
class _postFeed extends \IPS\Content\WidgetComment
{
/**
* @brief Widget Key
@@ -40,174 +40,22 @@ class _postFeed extends \IPS\Widget\PermissionCache
public $plugin = '';
/**
* Specify widget configuration
*
* @param null|\IPS\Helpers\Form $form Form object
* @return \IPS\Helpers\Form
* Class
*/
public function configuration( &$form=null )
{
if ( $form === null )
{
$form = new \IPS\Helpers\Form;
}
$form->add( new \IPS\Helpers\Form\Text( 'tfb_title', isset( $this->configuration['tfb_title'] ) ? $this->configuration['tfb_title'] : \IPS\Member::loggedIn()->language()->addToStack('block_postFeed_title') ) );
$form->add( new \IPS\Helpers\Form\Node( 'tfb_forums', ( isset( $this->configuration['tfb_forums'] ) and is_array( $this->configuration['tfb_forums'] ) ) ? array_keys( $this->configuration['tfb_forums'] ) : 0, FALSE, array(
'class' => '\IPS\forums\Forum',
'zeroVal' => 'tfb_all_forums',
'permissionCheck' => 'view',
'multiple' => true
) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'tfb_use_perms', isset( $this->configuration['tfb_use_perms'] ) ? $this->configuration['tfb_use_perms'] : TRUE, FALSE ) );
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'tfb_topic_status', isset( $this->configuration['tfb_topic_status'] ) ? $this->configuration['tfb_topic_status'] : array( 'open', 'pinned', 'notpinned', 'visible', 'featured', 'notfeatured' ), FALSE, array(
'options' => array(
'open' => 'tfb_open_status_open',
'closed' => 'tfb_open_status_closed',
'pinned' => 'tfb_open_status_pinned',
'notpinned' => 'tfb_open_status_notpinned',
'visible' => 'tfb_open_status_visible',
'hidden' => 'tfb_open_status_hidden',
'featured' => 'tfb_open_status_featured',
'notfeatured' => 'tfb_open_status_notfeatured'
)
) ) );
$author = NULL;
try
{
if ( isset( $this->configuration['tfb_author'] ) and is_array( $this->configuration['tfb_author'] ) )
{
foreach( $this->configuration['tfb_author'] as $id )
{
$author[ $id ] = \IPS\Member::load( $id );
}
}
}
catch( \OutOfRangeException $ex ) { }
$form->add( new \IPS\Helpers\Form\Member( 'tfb_author', $author, FALSE, array( 'multiple' => NULL ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'tfb_min_posts', isset( $this->configuration['tfb_min_posts'] ) ? $this->configuration['tfb_min_posts'] : 0, FALSE, array( 'unlimitedLang' => 'tfb_any_posts', 'unlimited' => 0 ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'tfb_show', isset( $this->configuration['tfb_show'] ) ? $this->configuration['tfb_show'] : 5, TRUE ) );
$form->add( new \IPS\Helpers\Form\Select( 'tfb_sort_dir', isset( $this->configuration['tfb_sort_dir'] ) ? $this->configuration['tfb_sort_dir'] : 'desc', FALSE, array(
'options' => array(
'desc' => 'tfb_sort_dir_dsc',
'asc' => 'tfb_sort_dir_asc'
)
) ) );
return $form;
}
/**
* Adjust configuration values we are about to save
*
* @param array $values Values from form submission
* @return array
*/
public function preConfig( $values )
{
if( isset( $values['tfb_author'] ) AND $values['tfb_author'] )
{
$values['tfb_author'] = array_keys( $values['tfb_author'] );
}
return $values;
}
protected static $class = 'IPS\forums\Topic\Post';
/**
* Render a widget
* Get where clause
*
* @return string
* @return array
*/
public function render()
protected function buildWhere()
{
$where = array();
$order = NULL;
$limit = isset( $this->configuration['tfb_show'] ) ? $this->configuration['tfb_show'] : 5;
$permissionKey = ( !isset( $this->configuration['tfb_use_perms'] ) or $this->configuration['tfb_use_perms'] ) ? 'read' : NULL;
$includeHidden = false;
if ( isset( $this->configuration['tfb_forums'] ) and is_array( $this->configuration['tfb_forums'] ) )
{
$where['item'][] = array( 'forum_id IN (' . implode( ",", array_keys( $this->configuration['tfb_forums'] ) ) . ')' );
}
if ( isset( $this->configuration['tfb_topic_status'] ) and is_array( $this->configuration['tfb_topic_status'] ) )
{
$status = $this->configuration['tfb_topic_status'];
if ( ! in_array( 'open', $status ) or ! in_array( 'closed', $status ) )
{
if ( ! in_array( 'open', $status ) )
{
$where['item'][] = array( "state='closed'" );
}
else if ( ! in_array( 'closed', $status ) )
{
$where['item'][] = array( "state='open'" );
}
}
if ( in_array( 'hidden', $status ) )
{
$includeHidden = true;
}
if ( ! in_array( 'featured', $status ) or ! in_array( 'notfeatured', $status ) )
{
if ( ! in_array( 'featured', $status ) )
{
$where['item'][] = array( 'featured=0' );
}
else if ( ! in_array( 'notfeatured', $status ) )
{
$where['item'][] = array( 'featured=1' );
}
}
if ( ! in_array( 'pinned', $status ) or ! in_array( 'notpinned', $status ) )
{
if ( ! in_array( 'pinned', $status ) )
{
$where['item'][] = array( 'pinned=0' );
}
else if ( ! in_array( 'notpinned', $status ) )
{
$where['item'][] = array( 'pinned=1' );
}
}
}
if ( isset( $this->configuration['tfb_author'] ) and is_array( $this->configuration['tfb_author'] ) )
{
$where[] = array( "starter_id IN(" . implode( ',', $this->configuration['tfb_author'] ) . ")" );
}
if ( isset( $this->configuration['tfb_sort_dir'] ) )
{
$order = 'post_date ' . $this->configuration['tfb_sort_dir'];
}
if ( $permissionKey )
$where = parent::buildWhere();
if ( !isset( $this->configuration['widget_feed_use_perms'] ) or $this->configuration['widget_feed_use_perms'] )
{
$where['container'][] = array( 'forums_forums.password IS NULL AND forums_forums.can_view_others=1' );
}
$posts = \IPS\forums\Topic\Post::getItemsWithPermission( $where, $order, $limit, $permissionKey ?: NULL, $includeHidden );
if ( count( $posts ) )
{
return $this->output( $posts, isset( $this->configuration['tfb_title'] ) ? $this->configuration['tfb_title'] : \IPS\Member::loggedIn()->language()->addToStack('block_postFeed_title') );
}
else
{
return '';
}
return $where;
}
}