Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
+167
-55
@@ -12,7 +12,7 @@
|
||||
namespace IPS\Content;
|
||||
|
||||
/* 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;
|
||||
@@ -27,6 +27,11 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
* Class
|
||||
*/
|
||||
protected static $class;
|
||||
|
||||
/**
|
||||
* Skip the getItemsWithPermission check?
|
||||
*/
|
||||
protected static $skipPermissions = FALSE;
|
||||
|
||||
/**
|
||||
* Specify widget configuration
|
||||
@@ -36,36 +41,51 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
/* Init */
|
||||
$class = static::$class;
|
||||
if ( $form === null )
|
||||
$form = parent::configuration( $form );
|
||||
|
||||
foreach( $this->formElements() as $element )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
}
|
||||
|
||||
$form->add( $element );
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the form elements to use
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function formElements()
|
||||
{
|
||||
/* Init */
|
||||
$class = static::$class;
|
||||
$return = array();
|
||||
|
||||
/* Block title */
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'widget_feed_title', isset( $this->configuration['language_key'] ) ? NULL : \IPS\Member::loggedIn()->language()->addToStack( $class::$title . '_pl' ), FALSE, array( 'app' => 'core', 'key' => ( isset( $this->configuration['language_key'] ) ? $this->configuration['language_key'] : NULL ) ) ) );
|
||||
$return['title'] = new \IPS\Helpers\Form\Translatable( 'widget_feed_title', isset( $this->configuration['language_key'] ) ? NULL : \IPS\Member::loggedIn()->language()->addToStack( $class::$title . '_pl' ), FALSE, array( 'app' => 'core', 'key' => ( isset( $this->configuration['language_key'] ) ? $this->configuration['language_key'] : NULL ) ) );
|
||||
|
||||
/* Container */
|
||||
if ( isset( $class::$containerNodeClass ) )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'widget_feed_container_' . $class::$title, isset( $this->configuration['widget_feed_container'] ) ? $this->configuration['widget_feed_container'] : 0, FALSE, array(
|
||||
$return['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',
|
||||
'permissionCheck' => 'view',
|
||||
'multiple' => true,
|
||||
'forceOwner' => false,
|
||||
) ) );
|
||||
'clubs' => TRUE
|
||||
) );
|
||||
}
|
||||
|
||||
/* Use permissions? */
|
||||
if ( in_array( 'IPS\Content\Permissions', class_implements( $class ) ) )
|
||||
if ( \in_array( 'IPS\Content\Permissions', class_implements( $class ) ) )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'widget_feed_use_perms', isset( $this->configuration['widget_feed_use_perms'] ) ? $this->configuration['widget_feed_use_perms'] : TRUE, FALSE ) );
|
||||
$return['permissions'] = new \IPS\Helpers\Form\YesNo( 'widget_feed_use_perms', isset( $this->configuration['widget_feed_use_perms'] ) ? $this->configuration['widget_feed_use_perms'] : TRUE, FALSE );
|
||||
}
|
||||
|
||||
/* Types */
|
||||
if ( in_array( 'IPS\Content\Lockable', class_implements( $class ) ) )
|
||||
if ( \in_array( 'IPS\Content\Lockable', class_implements( $class ) ) )
|
||||
{
|
||||
$types = array(
|
||||
'any' => 'mod_confirm_either',
|
||||
@@ -73,9 +93,9 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
'closed' => 'mod_confirm_lock'
|
||||
);
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'widget_feed_status_locked', isset( $this->configuration['widget_feed_status_locked'] ) ? $this->configuration['widget_feed_status_locked'] : 'any', FALSE, array( 'options' => $types ) ) );
|
||||
$return['locked'] = new \IPS\Helpers\Form\Radio( 'widget_feed_status_locked', isset( $this->configuration['widget_feed_status_locked'] ) ? $this->configuration['widget_feed_status_locked'] : 'any', FALSE, array( 'options' => $types ) );
|
||||
}
|
||||
if ( in_array( 'IPS\Content\Pinnable', class_implements( $class ) ) )
|
||||
if ( \in_array( 'IPS\Content\Pinnable', class_implements( $class ) ) )
|
||||
{
|
||||
$types = array(
|
||||
'any' => 'mod_confirm_either',
|
||||
@@ -83,9 +103,9 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
'notpinned' => 'mod_confirm_unpin'
|
||||
);
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'widget_feed_status_pinned', isset( $this->configuration['widget_feed_status_pinned'] ) ? $this->configuration['widget_feed_status_pinned'] : 'any', FALSE, array( 'options' => $types ) ) );
|
||||
$return['pinned'] = new \IPS\Helpers\Form\Radio( 'widget_feed_status_pinned', isset( $this->configuration['widget_feed_status_pinned'] ) ? $this->configuration['widget_feed_status_pinned'] : 'any', FALSE, array( 'options' => $types ) );
|
||||
}
|
||||
if ( in_array( 'IPS\Content\Featurable', class_implements( $class ) ) )
|
||||
if ( \in_array( 'IPS\Content\Featurable', class_implements( $class ) ) )
|
||||
{
|
||||
$types = array(
|
||||
'any' => 'mod_confirm_either',
|
||||
@@ -93,9 +113,9 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
'notfeatured' => 'mod_confirm_unfeature'
|
||||
);
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'widget_feed_status_featured', isset( $this->configuration['widget_feed_status_featured'] ) ? $this->configuration['widget_feed_status_featured'] : 'any', FALSE, array( 'options' => $types ) ) );
|
||||
$return['featured'] = new \IPS\Helpers\Form\Radio( 'widget_feed_status_featured', isset( $this->configuration['widget_feed_status_featured'] ) ? $this->configuration['widget_feed_status_featured'] : 'any', FALSE, array( 'options' => $types ) );
|
||||
}
|
||||
if ( in_array( 'IPS\Content\Hideable', class_implements( $class ) ) )
|
||||
if ( \in_array( 'IPS\Content\Hideable', class_implements( $class ) ) )
|
||||
{
|
||||
$types = array(
|
||||
'any' => 'mod_confirm_either',
|
||||
@@ -103,14 +123,35 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
'hidden' => 'mod_confirm_hidden'
|
||||
);
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'widget_feed_comment_status_visible', isset( $this->configuration['widget_feed_comment_status_visible'] ) ? $this->configuration['widget_feed_comment_status_visible'] : 'any', FALSE, array( 'options' => $types ) ) );
|
||||
$return['hidden'] = new \IPS\Helpers\Form\Radio( 'widget_feed_comment_status_visible', isset( $this->configuration['widget_feed_comment_status_visible'] ) ? $this->configuration['widget_feed_comment_status_visible'] : 'any', FALSE, array( 'options' => $types ) );
|
||||
}
|
||||
if ( \IPS\IPS::classUsesTrait( $class, 'IPS\Content\Solvable' ) )
|
||||
{
|
||||
$types = array(
|
||||
'any' => 'solved_either',
|
||||
'solved' => 'solved_solved',
|
||||
'unsolved' => 'solved_unsolved'
|
||||
);
|
||||
|
||||
$return['solved'] = new \IPS\Helpers\Form\Radio( 'widget_feed_status_solved', isset( $this->configuration['widget_feed_status_solved'] ) ? $this->configuration['widget_feed_status_solved'] : 'any', FALSE, array( 'options' => $types ) );
|
||||
}
|
||||
|
||||
if ( \in_array( 'IPS\Content\FuturePublishing', class_implements( $class ) ) )
|
||||
{
|
||||
$types = array(
|
||||
'any' => 'mod_confirm_either',
|
||||
'published' => 'mod_confirm_publish',
|
||||
'unpublished' => 'mod_confirm_unpublish'
|
||||
);
|
||||
|
||||
$return['published'] = new \IPS\Helpers\Form\Radio( 'widget_feed_status_published', isset( $this->configuration['widget_feed_status_published'] ) ? $this->configuration['widget_feed_status_published'] : 'any', FALSE, array( 'options' => $types ) );
|
||||
}
|
||||
|
||||
/* Author */
|
||||
$author = NULL;
|
||||
try
|
||||
{
|
||||
if ( isset( $this->configuration['widget_feed_author'] ) and is_array( $this->configuration['widget_feed_author'] ) )
|
||||
if ( isset( $this->configuration['widget_feed_author'] ) and \is_array( $this->configuration['widget_feed_author'] ) )
|
||||
{
|
||||
foreach( $this->configuration['widget_feed_author'] as $id )
|
||||
{
|
||||
@@ -119,48 +160,55 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
}
|
||||
}
|
||||
catch( \OutOfRangeException $ex ) { }
|
||||
$form->add( new \IPS\Helpers\Form\Member( 'widget_feed_author', $author, FALSE, array( 'multiple' => NULL ) ) );
|
||||
$return['author'] = new \IPS\Helpers\Form\Member( 'widget_feed_author', $author, FALSE, array( 'multiple' => NULL ) );
|
||||
|
||||
/* Minimum comments/reviews */
|
||||
if ( isset( $class::$commentClass ) )
|
||||
{
|
||||
if ( $class::$firstCommentRequired )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'widget_feed_min_posts', isset( $this->configuration['widget_feed_min_posts'] ) ? $this->configuration['widget_feed_min_posts'] : 0, FALSE, array( 'unlimitedLang' => 'any', 'unlimited' => 0 ) ) );
|
||||
$return['min_posts'] = new \IPS\Helpers\Form\Number( 'widget_feed_min_posts', isset( $this->configuration['widget_feed_min_posts'] ) ? $this->configuration['widget_feed_min_posts'] : 0, FALSE, array( 'unlimitedLang' => 'any', 'unlimited' => 0 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'widget_feed_min_comments', isset( $this->configuration['widget_feed_min_comments'] ) ? $this->configuration['widget_feed_min_comments'] : 0, FALSE, array( 'unlimitedLang' => 'any', 'unlimited' => 0 ) ) );
|
||||
$return['min_comments'] = new \IPS\Helpers\Form\Number( 'widget_feed_min_comments', isset( $this->configuration['widget_feed_min_comments'] ) ? $this->configuration['widget_feed_min_comments'] : 0, FALSE, array( 'unlimitedLang' => 'any', 'unlimited' => 0 ) );
|
||||
}
|
||||
}
|
||||
if ( isset( $class::$reviewClass ) )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'widget_feed_min_reviews', isset( $this->configuration['widget_feed_min_reviews'] ) ? $this->configuration['widget_feed_min_reviews'] : 0, FALSE, array( 'unlimitedLang' => 'any', 'unlimited' => 0 ) ) );
|
||||
$return['min_reviews'] = new \IPS\Helpers\Form\Number( 'widget_feed_min_reviews', isset( $this->configuration['widget_feed_min_reviews'] ) ? $this->configuration['widget_feed_min_reviews'] : 0, FALSE, array( 'unlimitedLang' => 'any', 'unlimited' => 0 ) );
|
||||
}
|
||||
|
||||
/* Rating */
|
||||
if ( in_array( 'IPS\Content\Ratings', class_implements( $class ) ) and isset( $class::$databaseColumnMap['rating_average'] ) )
|
||||
if ( \in_array( 'IPS\Content\Ratings', class_implements( $class ) ) and isset( $class::$databaseColumnMap['rating_average'] ) )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Rating( 'widget_feed_min_rating', isset( $this->configuration['widget_feed_min_rating'] ) ? $this->configuration['widget_feed_min_rating'] : 0, FALSE, array() ) );
|
||||
$return['rating'] = new \IPS\Helpers\Form\Rating( 'widget_feed_min_rating', isset( $this->configuration['widget_feed_min_rating'] ) ? $this->configuration['widget_feed_min_rating'] : 0, FALSE, array() );
|
||||
}
|
||||
|
||||
/* Number to show */
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'widget_feed_show', isset( $this->configuration['widget_feed_show'] ) ? $this->configuration['widget_feed_show'] : 5, TRUE ) );
|
||||
$return['show'] = new \IPS\Helpers\Form\Number( 'widget_feed_show', isset( $this->configuration['widget_feed_show'] ) ? $this->configuration['widget_feed_show'] : 5, TRUE );
|
||||
|
||||
/* Date restrict */
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'widget_feed_restrict_days', isset( $this->configuration['widget_feed_restrict_days'] ) ? $this->configuration['widget_feed_restrict_days'] : -1, FALSE, array( 'unlimited' => -1 ), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('widget_feed_restrict_days_suffix') ) );
|
||||
$options = array( 'unlimited' => -1 );
|
||||
|
||||
if ( $class::databaseTableCount() AND $class::databaseTableCount() > \IPS\UPGRADE_LARGE_TABLE_SIZE )
|
||||
{
|
||||
$options['unlimitedLang'] = 'search_year';
|
||||
}
|
||||
|
||||
$return['date_restrict'] = new \IPS\Helpers\Form\Number( 'widget_feed_restrict_days', isset( $this->configuration['widget_feed_restrict_days'] ) ? $this->configuration['widget_feed_restrict_days'] : -1, FALSE, $options, NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('widget_feed_restrict_days_suffix') );
|
||||
|
||||
/* Sort */
|
||||
$sortOptions = $class::getWidgetSortOptions();
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'widget_feed_sort_on', isset( $this->configuration['widget_feed_sort_on'] ) ? $this->configuration['widget_feed_sort_on'] : $class::$databaseColumnMap['updated'], FALSE, array( 'options' => $sortOptions ) ), NULL, NULL, NULL, 'widget_feed_sort_on' );
|
||||
$return['sort'] = new \IPS\Helpers\Form\Select( 'widget_feed_sort_on', isset( $this->configuration['widget_feed_sort_on'] ) ? $this->configuration['widget_feed_sort_on'] : $class::$databaseColumnMap['updated'], FALSE, array( 'options' => $sortOptions ), NULL, NULL, NULL, 'widget_feed_sort_on' );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'widget_feed_sort_dir', isset( $this->configuration['widget_feed_sort_dir'] ) ? $this->configuration['widget_feed_sort_dir'] : 'desc', FALSE, array(
|
||||
$return['direction'] = new \IPS\Helpers\Form\Select( 'widget_feed_sort_dir', isset( $this->configuration['widget_feed_sort_dir'] ) ? $this->configuration['widget_feed_sort_dir'] : 'desc', FALSE, array(
|
||||
'options' => array(
|
||||
'desc' => 'descending',
|
||||
'asc' => 'ascending'
|
||||
)
|
||||
) ) );
|
||||
) );
|
||||
|
||||
/* Tags */
|
||||
if( \IPS\Settings::i()->tags_enabled )
|
||||
@@ -178,11 +226,11 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
$options['autocomplete']['prefix'] = FALSE;
|
||||
$options['autocomplete']['minimized'] = FALSE;
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'widget_feed_tags', ( isset( $this->configuration['widget_feed_tags'] ) ? $this->configuration['widget_feed_tags'] : array( 'tags' => NULL ) ), FALSE, $options ) );
|
||||
$return['tags'] = new \IPS\Helpers\Form\Text( 'widget_feed_tags', ( isset( $this->configuration['widget_feed_tags'] ) ? $this->configuration['widget_feed_tags'] : array( 'tags' => NULL ) ), FALSE, $options );
|
||||
|
||||
}
|
||||
|
||||
return $form;
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,13 +243,13 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
{
|
||||
$class = static::$class;
|
||||
|
||||
if ( is_array( $values[ 'widget_feed_container_' . $class::$title ] ) )
|
||||
if ( \is_array( $values[ 'widget_feed_container_' . $class::$title ] ) )
|
||||
{
|
||||
$values['widget_feed_container'] = array_keys( $values[ 'widget_feed_container_' . $class::$title ] );
|
||||
unset( $values[ 'widget_feed_container_' . $class::$title ] );
|
||||
}
|
||||
|
||||
if ( is_array( $values['widget_feed_author'] ) )
|
||||
if ( \is_array( $values['widget_feed_author'] ) )
|
||||
{
|
||||
$members = array();
|
||||
foreach( $values['widget_feed_author'] as $member )
|
||||
@@ -233,15 +281,47 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
{
|
||||
$class = static::$class;
|
||||
$where = array();
|
||||
|
||||
|
||||
/* Reset now as this could have been previously set to TRUE if using multiple Content widgets */
|
||||
static::$skipPermissions = FALSE;
|
||||
|
||||
/* Container */
|
||||
if ( isset( $class::$containerNodeClass ) and !empty( $this->configuration['widget_feed_container'] ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['container'], $this->configuration['widget_feed_container'] ) );
|
||||
$nodeIds = array();
|
||||
|
||||
if ( ! empty( $this->configuration['widget_feed_use_perms'] ) )
|
||||
{
|
||||
static::$skipPermissions = TRUE;
|
||||
}
|
||||
|
||||
foreach( $this->configuration['widget_feed_container'] as $id )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( ! empty( $this->configuration['widget_feed_use_perms'] ) )
|
||||
{
|
||||
if ( $class::$containerNodeClass::load( $id )->can('read') )
|
||||
{
|
||||
$nodeIds[] = $id;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$nodeIds[] = $id;
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$where[] = array( \IPS\Db::i()->in( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['container'], $nodeIds ) );
|
||||
}
|
||||
|
||||
/* Status */
|
||||
if ( isset( $this->configuration['widget_feed_status_locked'] ) and in_array( 'IPS\Content\Lockable', class_implements( $class ) ) )
|
||||
if ( isset( $this->configuration['widget_feed_status_locked'] ) and \in_array( 'IPS\Content\Lockable', class_implements( $class ) ) )
|
||||
{
|
||||
if ( $this->configuration['widget_feed_status_locked'] == 'closed' )
|
||||
{
|
||||
@@ -253,7 +333,7 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $this->configuration['widget_feed_status_featured'] ) and in_array( 'IPS\Content\Featurable', class_implements( $class ) ) )
|
||||
if ( isset( $this->configuration['widget_feed_status_featured'] ) and \in_array( 'IPS\Content\Featurable', class_implements( $class ) ) )
|
||||
{
|
||||
if ( $this->configuration['widget_feed_status_featured'] == 'notfeatured' )
|
||||
{
|
||||
@@ -264,8 +344,13 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
$where[] = array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['featured'] . '=1' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $this->configuration['widget_feed_status_pinned'] ) and in_array( 'IPS\Content\Pinnable', class_implements( $class ) ) )
|
||||
|
||||
if ( isset( $this->configuration['widget_feed_status_solved'] ) and $this->configuration['widget_feed_status_solved'] != 'any' )
|
||||
{
|
||||
$where['item'][] = $this->configuration['widget_feed_status_solved'] == 'solved' ? array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['solved_comment_id'] . '>0' ) : array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['solved_comment_id'] . '=0' );
|
||||
}
|
||||
|
||||
if ( isset( $this->configuration['widget_feed_status_pinned'] ) and \in_array( 'IPS\Content\Pinnable', class_implements( $class ) ) )
|
||||
{
|
||||
if ( $this->configuration['widget_feed_status_pinned'] == 'notpinned' )
|
||||
{
|
||||
@@ -277,8 +362,20 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
}
|
||||
}
|
||||
|
||||
if( isset( $this->configuration['widget_feed_status_published'] ) AND $this->configuration['widget_feed_status_published'] )
|
||||
{
|
||||
if ( $this->configuration['widget_feed_status_published'] == 'published' )
|
||||
{
|
||||
$where[] = array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['is_future_entry'] . '=?', 0 ) ;
|
||||
}
|
||||
elseif ( $this->configuration['widget_feed_status_published'] == 'unpublished' )
|
||||
{
|
||||
$where[] = array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['is_future_entry'] . '!=?', 0 ) ;
|
||||
}
|
||||
}
|
||||
|
||||
/* Author */
|
||||
if ( isset( $this->configuration['widget_feed_author'] ) and is_array( $this->configuration['widget_feed_author'] ) and count( $this->configuration['widget_feed_author'] ) )
|
||||
if ( isset( $this->configuration['widget_feed_author'] ) and \is_array( $this->configuration['widget_feed_author'] ) and \count( $this->configuration['widget_feed_author'] ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['author'], $this->configuration['widget_feed_author'] ) );
|
||||
}
|
||||
@@ -290,11 +387,11 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
}
|
||||
if ( isset( $this->configuration['widget_feed_min_comments'] ) and $this->configuration['widget_feed_min_comments'] )
|
||||
{
|
||||
$where[] = array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['num_comments'] . '>?', (int) $this->configuration['widget_feed_min_comments'] );
|
||||
$where[] = array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['num_comments'] . '>=?', (int) $this->configuration['widget_feed_min_comments'] );
|
||||
}
|
||||
if ( isset( $this->configuration['widget_feed_min_reviews'] ) and $this->configuration['widget_feed_min_reviews'] )
|
||||
{
|
||||
$where[] = array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['num_reviews'] . '>?', (int) $this->configuration['widget_feed_min_reviews'] );
|
||||
$where[] = array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['num_reviews'] . '>=?', (int) $this->configuration['widget_feed_min_reviews'] );
|
||||
}
|
||||
|
||||
/* Rating */
|
||||
@@ -304,9 +401,23 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
}
|
||||
|
||||
/* Limit to days */
|
||||
if ( isset( $this->configuration['widget_feed_restrict_days'] ) and $this->configuration['widget_feed_restrict_days'] > 0 )
|
||||
if ( $class::databaseTableCount() > \IPS\UPGRADE_LARGE_TABLE_SIZE )
|
||||
{
|
||||
$where[] = array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['date'] . '>?', \IPS\DateTime::create()->sub( new \DateInterval( 'P' . $this->configuration['widget_feed_restrict_days'] . 'D' ) )->getTimestamp() );
|
||||
if ( isset( $this->configuration['widget_feed_restrict_days'] ) and $this->configuration['widget_feed_restrict_days'] > 0 and $this->configuration['widget_feed_restrict_days'] <= 365 )
|
||||
{
|
||||
$where[] = array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['date'] . '>?', \IPS\DateTime::create()->sub( new \DateInterval( 'P' . $this->configuration['widget_feed_restrict_days'] . 'D' ) )->getTimestamp() );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where[] = array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['date'] . '>?', \IPS\DateTime::create()->sub( new \DateInterval( 'P1Y' ) )->getTimestamp() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isset( $this->configuration['widget_feed_restrict_days'] ) and $this->configuration['widget_feed_restrict_days'] > 0 )
|
||||
{
|
||||
$where[] = array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['date'] . '>?', \IPS\DateTime::create()->sub( new \DateInterval( 'P' . $this->configuration['widget_feed_restrict_days'] . 'D' ) )->getTimestamp() );
|
||||
}
|
||||
}
|
||||
|
||||
return $where;
|
||||
@@ -322,7 +433,7 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
$class = static::$class;
|
||||
$where = $this->buildWhere();
|
||||
|
||||
if ( \IPS\Settings::i()->tags_enabled and isset( $this->configuration['widget_feed_tags'] ) and is_array( $this->configuration['widget_feed_tags'] ) and count( $this->configuration['widget_feed_tags'] ) )
|
||||
if ( \IPS\Settings::i()->tags_enabled and isset( $this->configuration['widget_feed_tags'] ) and \is_array( $this->configuration['widget_feed_tags'] ) and \count( $this->configuration['widget_feed_tags'] ) )
|
||||
{
|
||||
$tagWhere = array();
|
||||
$binds = array( $class::$application, $class::$module );
|
||||
@@ -353,17 +464,18 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
}
|
||||
|
||||
/* As the block config can try and search all rows in topics/records, etc, we can end up with a tmp table and block nested buffer on members table, so we just query members after separately */
|
||||
$skipPerms = ( !isset( $this->configuration['widget_feed_use_perms'] ) or $this->configuration['widget_feed_use_perms'] ) ? FALSE : TRUE;
|
||||
$skipPerms = ( !isset( $this->configuration['widget_feed_use_perms'] ) or $this->configuration['widget_feed_use_perms'] ) ? static::$skipPermissions : TRUE;
|
||||
$items = iterator_to_array( $class::getItemsWithPermission(
|
||||
$where, /* Where clause */
|
||||
( isset( $this->configuration['widget_feed_sort_on'] ) and isset( $this->configuration['widget_feed_sort_dir'] ) ) ? ( ( $this->configuration['widget_feed_sort_on'] == '_rand' ) ? $this->configuration['widget_feed_sort_on'] : ( $class::$databasePrefix . $this->configuration['widget_feed_sort_on'] . ' ' . $this->configuration['widget_feed_sort_dir'] ) ) : ( $class::$databasePrefix . $class::$databaseColumnMap['updated'] . ' DESC' ), /* Order */
|
||||
( isset( $this->configuration['widget_feed_sort_on'] ) and isset( $this->configuration['widget_feed_sort_dir'] ) ) ? ( ( $this->configuration['widget_feed_sort_on'] == '_rand' ) ? $this->configuration['widget_feed_sort_on'] : ( $class::$databaseTable . '.' . $class::$databasePrefix . $this->configuration['widget_feed_sort_on'] . ' ' . $this->configuration['widget_feed_sort_dir'] ) ) : ( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['updated'] . ' DESC' ), /* Order */
|
||||
|
||||
( isset( $this->configuration['widget_feed_show'] ) AND $this->configuration['widget_feed_show'] ) ? $this->configuration['widget_feed_show'] : 5, /* Limit */
|
||||
$skipPerms ? NULL : 'read', /* Permission key to check against */
|
||||
( $skipPerms ) ? NULL : 'read', /* Permission key to check against */
|
||||
$hidden, /* Whether or not to include hidden items */
|
||||
0, NULL, FALSE, FALSE, FALSE, FALSE, NULL, $skipPerms, TRUE, FALSE, FALSE
|
||||
$class::SELECT_IDS_FIRST
|
||||
) );
|
||||
|
||||
if ( count( $items ) )
|
||||
if ( \count( $items ) )
|
||||
{
|
||||
$memberIds = array();
|
||||
$members = array();
|
||||
@@ -380,11 +492,11 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
$memberIds = array_unique( $memberIds );
|
||||
}
|
||||
|
||||
if ( count( $memberIds ) )
|
||||
if ( \count( $memberIds ) )
|
||||
{
|
||||
$members = \IPS\Db::i()->select( '*', 'core_members', array( \IPS\Db::i()->in( 'member_id', $memberIds ) ) )->setKeyField('member_id');
|
||||
|
||||
if ( count( $members ) )
|
||||
if ( \count( $members ) )
|
||||
{
|
||||
foreach( $members as $member )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user