Version 4.7.0
This commit is contained in:
1 parent
517a5e1f70
commit
8ba7d43898
1933 files changed
+65613
-11332
No files matched your search
@@ -476,6 +476,12 @@ class _Stream extends \IPS\Node\Model
|
||||
'unread' => 'stream_read_unread',
|
||||
) ) ) );
|
||||
|
||||
/* Solved */
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'stream_solved', $this->solved, TRUE, array( 'options' => array(
|
||||
'all' => 'stream_solved_all',
|
||||
'solved' => 'stream_solved_solved',
|
||||
'unsolved' => 'stream_solved_unsolved',
|
||||
) ) ) );
|
||||
|
||||
/* Follow */
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'stream_follow', $this->follow, TRUE, array(
|
||||
@@ -940,6 +946,15 @@ class _Stream extends \IPS\Node\Model
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if ( $this->solved == 'unsolved' )
|
||||
{
|
||||
$terms[] = \IPS\Member::loggedIn()->language()->addToStack('stream_blurb_unsolved');
|
||||
}
|
||||
else if ( $this->solved =='solved')
|
||||
{
|
||||
$terms[] = \IPS\Member::loggedIn()->language()->addToStack('stream_blurb_solved');
|
||||
}
|
||||
|
||||
if ( \count( $terms ) )
|
||||
{
|
||||
@@ -971,6 +986,7 @@ class _Stream extends \IPS\Node\Model
|
||||
'stream_ownership' => $this->ownership,
|
||||
'stream_date_type' => $this->date_type,
|
||||
'stream_classes' => NULL,
|
||||
'stream_solved' => $this->solved,
|
||||
'containers' => static::containersToUrl( $this->containers ),
|
||||
);
|
||||
|
||||
@@ -1105,6 +1121,9 @@ class _Stream extends \IPS\Node\Model
|
||||
{
|
||||
/* Init */
|
||||
$query = \IPS\Content\Search\Query::init( $member );
|
||||
|
||||
/* Get Member */
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
|
||||
/* Content Filters */
|
||||
$filters = array();
|
||||
@@ -1130,15 +1149,16 @@ class _Stream extends \IPS\Node\Model
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Build the filters */
|
||||
foreach ( $classes as $class => $options )
|
||||
{
|
||||
/* Init */
|
||||
if ( ! $this->include_comments or ( isset( $options['items'] ) and !isset( $options['comments'] ) and \in_array( 'IPS\Content\Item', class_parents( $class ) ) and $class::$firstCommentRequired ) )
|
||||
{
|
||||
/* items with no comments are flagged as being the last comment */
|
||||
$filter = \IPS\Content\Search\ContentFilter::init( $class, TRUE, TRUE, TRUE )->onlyLastComment();
|
||||
/* As we do not want comments to appear separately, we want to only show the content item if no comments
|
||||
or the last comment of the content item */
|
||||
$filter= \IPS\Content\Search\ContentFilter::init( $class, TRUE, TRUE, TRUE )->onlyLastComment();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1166,6 +1186,8 @@ class _Stream extends \IPS\Node\Model
|
||||
{
|
||||
if( !$this->include_comments )
|
||||
{
|
||||
/* As we do not want comments to appear separately, we want to only show the content item if no comments
|
||||
or the last comment of the content item */
|
||||
$filters[] = \IPS\Content\Search\ContentFilter::init( $class, TRUE, TRUE, TRUE )->onlyLastComment();
|
||||
}
|
||||
|
||||
@@ -1200,7 +1222,7 @@ class _Stream extends \IPS\Node\Model
|
||||
switch ( $this->ownership )
|
||||
{
|
||||
case 'started':
|
||||
$query->filterByItemAuthor( \IPS\Member::loggedIn() );
|
||||
$query->filterByItemAuthor( $member );
|
||||
break;
|
||||
|
||||
case 'postedin':
|
||||
@@ -1232,7 +1254,7 @@ class _Stream extends \IPS\Node\Model
|
||||
switch ( $this->date_type )
|
||||
{
|
||||
case 'last_visit':
|
||||
$query->$filterDateMethod( \IPS\DateTime::ts( \IPS\Member::loggedIn()->last_visit ) );
|
||||
$query->$filterDateMethod( \IPS\DateTime::ts( $member->last_visit ) );
|
||||
break;
|
||||
case 'relative':
|
||||
if ( \is_array( $this->date_relative_days ) )
|
||||
@@ -1247,6 +1269,16 @@ class _Stream extends \IPS\Node\Model
|
||||
$query->$filterDateMethod( $this->date_start ? \IPS\DateTime::ts( $this->date_start ) : NULL, $this->date_end ? \IPS\DateTime::ts( $this->date_end ) : NULL );
|
||||
break;
|
||||
}
|
||||
|
||||
/* Solved */
|
||||
if ( $this->solved == 'unsolved' )
|
||||
{
|
||||
$query->filterByUnsolved();
|
||||
}
|
||||
else if( $this->solved == 'solved' )
|
||||
{
|
||||
$query->filterBySolved();
|
||||
}
|
||||
|
||||
/* Sort */
|
||||
if ( $this->include_comments )
|
||||
@@ -1315,6 +1347,9 @@ class _Stream extends \IPS\Node\Model
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
/* Delete Subscriptions */
|
||||
\IPS\Db::i()->delete( 'core_stream_subscriptions', ['stream_id=?', $this->id ] );
|
||||
|
||||
if ( $this->member )
|
||||
{
|
||||
parent::delete();
|
||||
@@ -1345,4 +1380,80 @@ class _Stream extends \IPS\Node\Model
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the member subscribe to this stream?
|
||||
*
|
||||
* @param \IPS\Member|null $member
|
||||
* @return bool
|
||||
*/
|
||||
public function canSubscribe( \IPS\Member $member = NULL ) : bool
|
||||
{
|
||||
if( !\IPS\Settings::i()->activity_stream_subscriptions )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if( !$this->id )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
|
||||
if( !$member->member_id )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( \IPS\Db::i()->select( 'COUNT(*)', 'core_stream_subscriptions', array( 'member_id=?', $member->member_id ) )->first() >= \IPS\Settings::i()->activity_stream_subscriptions_max )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return !$this->isSubscribed($member);
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the member unsubscribe from this stream?
|
||||
*
|
||||
* @param \IPS\Member|null $member
|
||||
* @return bool
|
||||
*/
|
||||
public function canUnsubscribe( \IPS\Member $member = NULL ) : bool
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
return $this->isSubscribed($member);
|
||||
}
|
||||
|
||||
/**
|
||||
* Are we already subscribed to this stream?
|
||||
*
|
||||
* @param \IPS\Member|null $member
|
||||
* @return bool
|
||||
*/
|
||||
public function isSubscribed( \IPS\Member $member = NULL ) : bool
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
return (bool) \IPS\Db::i()->select( 'COUNT(*)', 'core_stream_subscriptions', array( 'stream_id=? AND member_id=?', $this->id, $member->member_id ) )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Return the custom badge for each row
|
||||
*
|
||||
* @return NULL|array Null for no badge, or an array of badge data (0 => CSS class type, 1 => language string, 2 => optional raw HTML to show instead of language string)
|
||||
*/
|
||||
protected function get__badge()
|
||||
{
|
||||
$badge = NULL;
|
||||
if ( $this->default )
|
||||
{
|
||||
$badge = array(
|
||||
0 => 'positive ipsPos_right',
|
||||
1 => 'default_no_parenthesis'
|
||||
);
|
||||
}
|
||||
|
||||
return $badge;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user