Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -20,9 +20,9 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
/**
|
||||
* Status Update Model
|
||||
*/
|
||||
class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \IPS\Content\Lockable, \IPS\Content\Hideable, \IPS\Content\Searchable, \IPS\Content\Shareable
|
||||
class _Status extends \IPS\Content\Item implements \IPS\Content\Lockable, \IPS\Content\Hideable, \IPS\Content\Searchable, \IPS\Content\Shareable
|
||||
{
|
||||
use \IPS\Content\Reactable;
|
||||
use \IPS\Content\Reactable, \IPS\Content\Reportable;
|
||||
|
||||
/* !\IPS\Patterns\ActiveRecord */
|
||||
|
||||
@@ -50,12 +50,7 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \I
|
||||
* @brief Multiton Store
|
||||
*/
|
||||
protected static $multitons;
|
||||
|
||||
/**
|
||||
* @brief [Content\Item] Include the ability to search this content item in global site searches
|
||||
*/
|
||||
public static $includeInSiteSearch = FALSE;
|
||||
|
||||
|
||||
/**
|
||||
* Columns needed to query for search result / stream view
|
||||
*
|
||||
@@ -167,7 +162,7 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \I
|
||||
*/
|
||||
public function get_title()
|
||||
{
|
||||
return strip_tags( $this->mapped('content') );
|
||||
return trim( preg_replace( "/\s+/u", ' ', strip_tags( str_replace( '<', ' <', \IPS\Text\Parser::removeElements( $this->mapped('content'), 'div[class="ipsSpoiler"]' ) ) ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -476,7 +471,7 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \I
|
||||
*/
|
||||
public function sendNotifications()
|
||||
{
|
||||
parent::sendNotifications();
|
||||
$sentTo = parent::sendNotifications();
|
||||
|
||||
/* Notify when somebody comments on my profile */
|
||||
if( $this->author()->member_id != $this->member_id )
|
||||
@@ -502,7 +497,7 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \I
|
||||
}
|
||||
}
|
||||
|
||||
$notification->send();
|
||||
$notification->send( $sentTo );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -517,7 +512,7 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \I
|
||||
{
|
||||
if ( $member->moderateNewContent() or \IPS\Settings::i()->profile_comment_approval )
|
||||
{
|
||||
return TRUE;
|
||||
return !static::modPermission( 'approve', $member, $container );
|
||||
}
|
||||
|
||||
return parent::moderateNewItems( $member, $container );
|
||||
@@ -534,17 +529,6 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \I
|
||||
return ( $member->moderateNewContent() or \IPS\Settings::i()->profile_comment_approval );
|
||||
}
|
||||
|
||||
/**
|
||||
* Can edit?
|
||||
*
|
||||
* @param \IPS\Member|NULL $member The member to check for (NULL for currently logged in member)
|
||||
* @return bool
|
||||
*/
|
||||
public function canEdit( $member=NULL )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can delete?
|
||||
*
|
||||
@@ -564,6 +548,11 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \I
|
||||
return parent::canDelete( $member );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Cached comment count
|
||||
*/
|
||||
protected $commentCount = NULL;
|
||||
|
||||
/**
|
||||
* Get comment count
|
||||
*
|
||||
@@ -571,55 +560,60 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \I
|
||||
*/
|
||||
public function commentCount()
|
||||
{
|
||||
$count = parent::commentCount();
|
||||
|
||||
if( $this->canViewHiddenComments() )
|
||||
if( $this->commentCount === NULL )
|
||||
{
|
||||
$idColumn = static::$databaseColumnId;
|
||||
$class = static::$commentClass;
|
||||
$authorCol = $class::$databasePrefix . $class::$databaseColumnMap['author'];
|
||||
$where = array( array( $class::$databasePrefix . $class::$databaseColumnMap['item'] . '=?', $this->$idColumn ) );
|
||||
$count = parent::commentCount();
|
||||
|
||||
if ( isset( static::$databaseColumnMap['hidden_comments'] ) )
|
||||
if( $this->canViewHiddenComments() )
|
||||
{
|
||||
$count += $this->mapped('hidden_comments');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isset( $class::$databaseColumnMap['approved'] ) )
|
||||
$idColumn = static::$databaseColumnId;
|
||||
$class = static::$commentClass;
|
||||
$authorCol = $class::$databasePrefix . $class::$databaseColumnMap['author'];
|
||||
$where = array( array( $class::$databasePrefix . $class::$databaseColumnMap['item'] . '=?', $this->$idColumn ) );
|
||||
|
||||
if ( isset( static::$databaseColumnMap['hidden_comments'] ) )
|
||||
{
|
||||
$col = $class::$databasePrefix . $class::$databaseColumnMap['approved'];
|
||||
$where[] = array( "{$col}=-1" );
|
||||
$count += $this->mapped('hidden_comments');
|
||||
}
|
||||
elseif( isset( $class::$databaseColumnMap['hidden'] ) )
|
||||
else
|
||||
{
|
||||
$col = $class::$databasePrefix . $class::$databaseColumnMap['hidden'];
|
||||
$where[] = array( "{$col}=-1" );
|
||||
if ( isset( $class::$databaseColumnMap['approved'] ) )
|
||||
{
|
||||
$col = $class::$databasePrefix . $class::$databaseColumnMap['approved'];
|
||||
$where[] = array( "{$col}=-1" );
|
||||
}
|
||||
elseif( isset( $class::$databaseColumnMap['hidden'] ) )
|
||||
{
|
||||
$col = $class::$databasePrefix . $class::$databaseColumnMap['hidden'];
|
||||
$where[] = array( "{$col}=-1" );
|
||||
}
|
||||
$count += \IPS\Db::i()->select( 'COUNT(*)', $class::$databaseTable, $where )->first();
|
||||
}
|
||||
|
||||
if ( isset( static::$databaseColumnMap['unapproved_comments'] ) )
|
||||
{
|
||||
$count += $this->mapped('unapproved_comments');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isset( $class::$databaseColumnMap['approved'] ) )
|
||||
{
|
||||
$col = $class::$databasePrefix . $class::$databaseColumnMap['approved'];
|
||||
$where[] = array( "{$col}=0" );
|
||||
}
|
||||
elseif( isset( $class::$databaseColumnMap['hidden'] ) )
|
||||
{
|
||||
$col = $class::$databasePrefix . $class::$databaseColumnMap['hidden'];
|
||||
$where[] = array( "{$col}=1" );
|
||||
}
|
||||
$count += \IPS\Db::i()->select( 'COUNT(*)', $class::$databaseTable, $where )->first();
|
||||
}
|
||||
$count += \IPS\Db::i()->select( 'COUNT(*)', $class::$databaseTable, $where )->first();
|
||||
}
|
||||
|
||||
if ( isset( static::$databaseColumnMap['unapproved_comments'] ) )
|
||||
{
|
||||
$count += $this->mapped('unapproved_comments');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isset( $class::$databaseColumnMap['approved'] ) )
|
||||
{
|
||||
$col = $class::$databasePrefix . $class::$databaseColumnMap['approved'];
|
||||
$where[] = array( "{$col}=0" );
|
||||
}
|
||||
elseif( isset( $class::$databaseColumnMap['hidden'] ) )
|
||||
{
|
||||
$col = $class::$databasePrefix . $class::$databaseColumnMap['hidden'];
|
||||
$where[] = array( "{$col}=1" );
|
||||
}
|
||||
$count += \IPS\Db::i()->select( 'COUNT(*)', $class::$databaseTable, $where )->first();
|
||||
}
|
||||
$this->commentCount = $count;
|
||||
}
|
||||
|
||||
return $count;
|
||||
return $this->commentCount;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -682,7 +676,7 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \I
|
||||
*/
|
||||
public static function contentTableTemplate()
|
||||
{
|
||||
return array( \IPS\Theme::i()->getTemplate( 'statuses', 'core' ), 'statusContentRows' );
|
||||
return array( \IPS\Theme::i()->getTemplate( 'statuses', 'core', 'front' ), 'statusContentRows' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -738,7 +732,7 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \I
|
||||
*/
|
||||
protected function autoShare( $className )
|
||||
{
|
||||
$className::publish( html_entity_decode( trim( strip_tags( $this->content ) ), ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8' ) );
|
||||
$className::publish( html_entity_decode( trim( strip_tags( $this->content ) ), ENT_QUOTES | ENT_DISALLOWED, 'UTF-8' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -750,4 +744,24 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \I
|
||||
{
|
||||
return 'status_id';
|
||||
}
|
||||
|
||||
/**
|
||||
* Can view hidden items?
|
||||
*
|
||||
* @param \IPS\Member|NULL $member The member to check for (NULL for currently logged in member)
|
||||
* @param \IPS\Node\Model|null $container Container
|
||||
* @return bool
|
||||
* @note If called without passing $container, this method falls back to global "can view hidden content" moderator permission which isn't always what you want - pass $container if in doubt or use canViewHiddenItemsContainers()
|
||||
*/
|
||||
public static function canViewHiddenItems( $member=NULL, \IPS\Node\Model $container = NULL )
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
|
||||
if( $member->modPermission( "can_view_hidden_member_status" ) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return parent::canViewHiddenItems( $member, $container );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user