Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
+97
-29
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Content Item Feed Widget
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage forums
|
||||
* @since 16 Oct 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -45,7 +45,7 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
}
|
||||
|
||||
/* Block title */
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'widget_feed_title', isset( $this->configuration['widget_feed_title'] ) ? $this->configuration['widget_feed_title'] : \IPS\Member::loggedIn()->language()->addToStack( $class::$title . '_pl' ) ) );
|
||||
$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' => 'cms', 'key' => ( isset( $this->configuration['language_key'] ) ? $this->configuration['language_key'] : NULL ) ) ) );
|
||||
|
||||
/* Container */
|
||||
if ( isset( $class::$containerNodeClass ) )
|
||||
@@ -54,7 +54,8 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
'class' => $class::$containerNodeClass,
|
||||
'zeroVal' => 'all',
|
||||
'permissionCheck' => 'view',
|
||||
'multiple' => true
|
||||
'multiple' => true,
|
||||
'forceOwner' => false,
|
||||
) ) );
|
||||
}
|
||||
|
||||
@@ -95,6 +96,16 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
|
||||
$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 ) ) );
|
||||
}
|
||||
if ( in_array( 'IPS\Content\Hideable', class_implements( $class ) ) )
|
||||
{
|
||||
$types = array(
|
||||
'any' => 'mod_confirm_either',
|
||||
'visible' => 'mod_confirm_visible',
|
||||
'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 ) ) );
|
||||
}
|
||||
|
||||
/* Author */
|
||||
$author = NULL;
|
||||
@@ -188,6 +199,15 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
$values['widget_feed_author'] = $members;
|
||||
}
|
||||
|
||||
if ( !isset( $this->configuration['language_key'] ) )
|
||||
{
|
||||
$this->configuration['language_key'] = 'widget_title_' . md5( uniqid() );
|
||||
}
|
||||
$values['language_key'] = $this->configuration['language_key'];
|
||||
|
||||
\IPS\Lang::saveCustom( 'core', $this->configuration['language_key'], $values['widget_feed_title'] );
|
||||
unset( $values['widget_feed_title'] );
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
@@ -245,7 +265,7 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
}
|
||||
|
||||
/* Author */
|
||||
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'] ) 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'] ) );
|
||||
}
|
||||
@@ -287,7 +307,7 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
public function render()
|
||||
{
|
||||
$class = static::$class;
|
||||
$joins = NULL;
|
||||
$where = $this->buildWhere();
|
||||
|
||||
if ( isset( $this->configuration['widget_feed_tags'] ) and is_array( $this->configuration['widget_feed_tags'] ) and count( $this->configuration['widget_feed_tags'] ) )
|
||||
{
|
||||
@@ -295,36 +315,84 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
$binds = array( $class::$application, $class::$module );
|
||||
foreach( $this->configuration['widget_feed_tags'] as $tag )
|
||||
{
|
||||
$tagWhere[] = "( ? LIKE CONCAT( tag_text, '%') )";
|
||||
$tagWhere[] = "( tag_text LIKE CONCAT( ?, '%') )";
|
||||
$binds[] = $tag;
|
||||
}
|
||||
|
||||
$joins = array( array(
|
||||
'select' => 'tag_id',
|
||||
'from' => 'core_tags',
|
||||
'where' => array( array_merge( array( 'tag_meta_app=? AND tag_meta_area=? AND (' . implode( ' OR ', $tagWhere ) . ') and core_tags.tag_meta_id=' . $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnId ), $binds ) ),
|
||||
'type' => 'STRAIGHT_JOIN'
|
||||
) );
|
||||
$where[] = array( $class::$databaseColumnId . ' IN (?)', \IPS\Db::i()->select( 'tag_meta_id', 'core_tags', array( array_merge( array( 'tag_meta_app=? AND tag_meta_area=? AND (' . implode( ' OR ', $tagWhere ) . ')' ), $binds ) ) ) );
|
||||
}
|
||||
|
||||
$items = $class::getItemsWithPermission(
|
||||
$this->buildWhere(),
|
||||
( isset( $this->configuration['widget_feed_sort_on'] ) and isset( $this->configuration['widget_feed_sort_dir'] ) ) ? ( $class::$databasePrefix . $this->configuration['widget_feed_sort_on'] . ' ' . $this->configuration['widget_feed_sort_dir'] ) : NULL,
|
||||
isset( $this->configuration['widget_feed_show'] ) ? $this->configuration['widget_feed_show'] : 5,
|
||||
( !isset( $this->configuration['widget_feed_use_perms'] ) or $this->configuration['widget_feed_use_perms'] ) ? 'read' : NULL,
|
||||
FALSE,
|
||||
0,
|
||||
NULL,
|
||||
FALSE,
|
||||
FALSE,
|
||||
FALSE,
|
||||
FALSE,
|
||||
$joins
|
||||
);
|
||||
|
||||
/* What visible status are we checking? */
|
||||
$hidden = \IPS\Content\Hideable::FILTER_AUTOMATIC;
|
||||
|
||||
if( isset( $this->configuration['widget_feed_comment_status_visible'] ) )
|
||||
{
|
||||
switch( $this->configuration['widget_feed_comment_status_visible'] )
|
||||
{
|
||||
case 'visible':
|
||||
$hidden = \IPS\Content\Hideable::FILTER_PUBLIC_ONLY;
|
||||
break;
|
||||
|
||||
case 'hidden':
|
||||
$hidden = \IPS\Content\Hideable::FILTER_ONLY_HIDDEN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 */
|
||||
$items = iterator_to_array( $class::getItemsWithPermission(
|
||||
$where, /* Where clause */
|
||||
( isset( $this->configuration['widget_feed_sort_on'] ) and isset( $this->configuration['widget_feed_sort_dir'] ) ) ? ( $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_show'] ) ? $this->configuration['widget_feed_show'] : 5, /* Limit */
|
||||
( !isset( $this->configuration['widget_feed_use_perms'] ) or $this->configuration['widget_feed_use_perms'] ) ? 'read' : NULL, /* Permission key to check against */
|
||||
$hidden, /* Whether or not to include hidden items */
|
||||
0, NULL, FALSE, FALSE, FALSE, FALSE, NULL, FALSE, TRUE, FALSE, FALSE
|
||||
) );
|
||||
|
||||
if ( count( $items ) )
|
||||
{
|
||||
return $this->output( $items, isset( $this->configuration['widget_feed_title'] ) ? $this->configuration['widget_feed_title'] : \IPS\Member::loggedIn()->language()->addToStack( $class::$title . '_pl' ) );
|
||||
$memberIds = array();
|
||||
$members = array();
|
||||
foreach( $items as $item )
|
||||
{
|
||||
foreach( array( 'author', 'last_comment_by' ) as $field )
|
||||
{
|
||||
if ( $item->mapped( $field ) )
|
||||
{
|
||||
$memberIds[] = $item->mapped( $field );
|
||||
}
|
||||
}
|
||||
|
||||
$memberIds = array_unique( $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 ) )
|
||||
{
|
||||
foreach( $members as $member )
|
||||
{
|
||||
\IPS\Member::constructFromData( $member, FALSE );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $this->configuration['language_key'] ) )
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( $this->configuration['language_key'], FALSE, array( 'escape' => TRUE ) );
|
||||
}
|
||||
elseif ( isset( $this->configuration['widget_feed_title'] ) )
|
||||
{
|
||||
$title = $this->configuration['widget_feed_title'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( $class::$title . '_pl' );
|
||||
}
|
||||
|
||||
return $this->output( $items, $title );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user