Version 4.7.23
This commit is contained in:
1 parent
7124a02564
commit
25ddeb65d6
1791 files changed
+76990
-44452
No files matched your search
+79
-18
@@ -10,6 +10,10 @@
|
||||
|
||||
namespace IPS\Node;
|
||||
|
||||
use IPS\Content\Comment;
|
||||
use IPS\Login;
|
||||
use IPS\Settings;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
@@ -19,6 +23,9 @@ if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
/**
|
||||
* Node Model
|
||||
* @mixin \IPS\Node\DelayedCount
|
||||
* @mixin \IPS\Node\Colorize
|
||||
* @mixin \IPS\Node\Statistics
|
||||
*/
|
||||
abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
{
|
||||
@@ -105,6 +112,11 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
*/
|
||||
public static $maxFormHelperResults = NULL;
|
||||
|
||||
/**
|
||||
* @brief [Node] Cache Total Followers Count
|
||||
*/
|
||||
public int $followerCount = 0;
|
||||
|
||||
/**
|
||||
* @brief [Node] ACP Restrictions
|
||||
* @code
|
||||
@@ -428,10 +440,11 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
$order = static::$databaseColumnOrder !== NULL ? static::$databasePrefix . static::$databaseColumnOrder : NULL;
|
||||
if ( \in_array( 'IPS\Node\Permissions', class_implements( \get_called_class() ) ) and $permissionCheck !== NULL )
|
||||
{
|
||||
$where[] = array( '(' . \IPS\Db::i()->findInSet( 'perm_' . static::$permissionMap[ $permissionCheck ], $member->permissionArray() ) . ' OR ' . 'perm_' . static::$permissionMap[ $permissionCheck ] . '=? )', '*' );
|
||||
$where[] = array(
|
||||
'(' . static::$databaseTable . '.' . static::$databasePrefix . static::$databaseColumnId . ' IN(?) )',
|
||||
\IPS\Db::i()->select( 'perm_type_id', 'core_permission_index', array( "core_permission_index.app=? AND core_permission_index.perm_type=? AND ( ( " . \IPS\Db::i()->findInSet( 'perm_' . static::$permissionMap[ $permissionCheck ], $member->permissionArray() ) . ' ) OR perm_' . static::$permissionMap[ $permissionCheck ] . '=? )', static::$permApp, static::$permType, '*' ) ) );
|
||||
|
||||
$select = \IPS\Db::i()->select( '*', static::$databaseTable, $where, $order, NULL, NULL, NULL, \IPS\Db::SELECT_MULTIDIMENSIONAL_JOINS )
|
||||
->join( 'core_permission_index', array( "core_permission_index.app=? AND core_permission_index.perm_type=? AND core_permission_index.perm_type_id=" . static::$databaseTable . "." . static::$databasePrefix . static::$databaseColumnId, static::$permApp, static::$permType ) );
|
||||
$select = \IPS\Db::i()->select( '*', static::$databaseTable, $where, $order, NULL, NULL, NULL, \IPS\Db::SELECT_MULTIDIMENSIONAL_JOINS );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1045,12 +1058,50 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
/**
|
||||
* Set last comment
|
||||
*
|
||||
* @param \IPS\Content\Comment|NULL $comment The latest comment or NULL to work it out
|
||||
* @return int
|
||||
* @param \IPS\Content\Comment|null $comment The latest comment or NULL to work it out
|
||||
* @param \IPS\Content\Item|null $updatedItem We sometimes run setLastComment() when an item has been edited, if so, that item will be here
|
||||
* @return void
|
||||
*/
|
||||
public function setLastComment( \IPS\Content\Comment $comment=NULL )
|
||||
public function setLastComment( ?\IPS\Content\Comment $comment=NULL, ?\IPS\Content\Item $updatedItem=NULL )
|
||||
{
|
||||
// Don't do anything by default, but nodes could extract data
|
||||
/* If either the comment or item are hidden, set to null so that we will load the correct one */
|
||||
if( $comment !== null and $comment->hidden() <> 0 )
|
||||
{
|
||||
$comment = null;
|
||||
}
|
||||
|
||||
if( ( $updatedItem !== null and $updatedItem->hidden() <> 0 ) )
|
||||
{
|
||||
$updatedItem = null;
|
||||
}
|
||||
|
||||
/* If we have a comment and no item, use the item from the comment */
|
||||
if( $comment !== null and $updatedItem === null and $comment->item()->hidden() === 0 )
|
||||
{
|
||||
$updatedItem = $comment->item();
|
||||
}
|
||||
|
||||
/* Let each node set the last comment data */
|
||||
$this->_setLastComment( $comment, $updatedItem );
|
||||
|
||||
$this->save();
|
||||
|
||||
if( \IPS\IPS::classUsesTrait( $this, 'IPS\Node\DelayedCount' ) )
|
||||
{
|
||||
$this->storeUpdateTime();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from Model::setLastComment(), must be implemented by each class
|
||||
*
|
||||
* @param Comment|null $comment
|
||||
* @param \IPS\Content\Item|null $updatedItem
|
||||
* @return void
|
||||
*/
|
||||
protected function _setLastComment( \IPS\Content\Comment $comment=null, \IPS\Content\Item $updatedItem=null )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2054,7 +2105,8 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
$groupsToCheck = $member->groups;
|
||||
|
||||
/* Work out which to use taking Post Before Registering into consideration and return */
|
||||
$considerPostBeforeRegistering = ( $considerPostBeforeRegistering and \IPS\Settings::i()->post_before_registering and \IPS\Login::registrationType() != 'disabled' );
|
||||
$considerPostBeforeRegistering = ( $considerPostBeforeRegistering and \IPS\Settings::i()->post_before_registering
|
||||
and \IPS\Login::registrationType() != 'disabled' and \IPS\Settings::i()->bot_antispam_type !== 'none' );
|
||||
if ( !$member->member_id and $considerPostBeforeRegistering )
|
||||
{
|
||||
$groupsToCheck[] = \IPS\Settings::i()->member_group;
|
||||
@@ -2429,7 +2481,8 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
$relevantPermissionArray = array_filter( explode( ',', $relevantPermissionString ) );
|
||||
|
||||
/* Work out which to use taking Post Before Registering into consideration and return */
|
||||
$considerPostBeforeRegistering = ( $considerPostBeforeRegistering and \IPS\Settings::i()->post_before_registering and \IPS\Login::registrationType() != 'disabled' );
|
||||
$considerPostBeforeRegistering = ( $considerPostBeforeRegistering and Settings::i()->post_before_registering
|
||||
and Login::registrationType() != 'disabled' and Settings::i()->bot_antispam_type !== 'none' );
|
||||
if( $member instanceof \IPS\Member\Group )
|
||||
{
|
||||
if ( $considerPostBeforeRegistering and $member->g_id == \IPS\Settings::i()->guest_group )
|
||||
@@ -2581,9 +2634,10 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
|
||||
/* Number of comments is less than */
|
||||
if ( isset( $data['additional']['num_comments'] ) AND $data['additional']['num_comments'] > 0 )
|
||||
if ( isset( $data['additional']['num_comments'] ) AND $data['additional']['num_comments'] >= 0 )
|
||||
{
|
||||
$where[] = array( $contentItemClass::$databasePrefix . $contentItemClass::$databaseColumnMap['num_comments'].'<=?', $data['additional']['num_comments'] );
|
||||
$number = $contentItemClass::$firstCommentRequired ? $data['additional']['num_comments'] +1 : $data['additional']['num_comments'];
|
||||
$where[] = array( $contentItemClass::$databasePrefix . $contentItemClass::$databaseColumnMap['num_comments'].'<=?', $number );
|
||||
}
|
||||
|
||||
/* Last post was before */
|
||||
@@ -2683,7 +2737,14 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
{
|
||||
if ( !isset( static::$contentItemClass ) )
|
||||
{
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
/* If we have delayed counts, don't slam the write server now, we'll handle it later */
|
||||
iF( \IPS\IPS::classUsesTrait( $this, 'IPS\Node\DelayedCount' ) )
|
||||
{
|
||||
$this->storeUpdateTime();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Update container */
|
||||
@@ -2774,7 +2835,7 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
}
|
||||
|
||||
$this->_comments = (int) \IPS\Db::i()->select( "SUM({$itemClass::$databasePrefix}{$itemClass::$databaseColumnMap['num_comments']})", $itemClass::$databaseTable, $commentWhere, NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
|
||||
$this->_comments = (int) \IPS\Db::i()->select( "SUM({$itemClass::$databasePrefix}{$itemClass::$databaseColumnMap['num_comments']})", $itemClass::$databaseTable, $commentWhere )->first();
|
||||
}
|
||||
|
||||
if ( $this->_reviews !== NULL AND $reviewClass !== NULL )
|
||||
@@ -2796,7 +2857,7 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
$this->_reviews = \IPS\Db::i()->select( 'COUNT(*)', array(
|
||||
array( $reviewClass::$databaseTable, $reviewClass::$databaseTable ),
|
||||
array( $itemClass::$databaseTable, $itemClass::$databaseTable )
|
||||
), $reviewWhere, NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
|
||||
), $reviewWhere )->first();
|
||||
}
|
||||
|
||||
if ( \in_array( 'IPS\Content\Hideable', class_implements( $itemClass ) ) )
|
||||
@@ -2844,7 +2905,7 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
$this->_unapprovedComments = \IPS\Db::i()->select( 'COUNT(*)', array(
|
||||
array( $commentClass::$databaseTable, $commentClass::$databaseTable ),
|
||||
array( $itemClass::$databaseTable, $itemClass::$databaseTable )
|
||||
), $commentWhere, NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
|
||||
), $commentWhere )->first();
|
||||
}
|
||||
/* If we have a cached value, use that instead */
|
||||
elseif( $this->_unapprovedComments !== NULL AND isset( $itemClass::$databaseColumnMap['unapproved_comments'] ) )
|
||||
@@ -2865,7 +2926,7 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
}
|
||||
|
||||
$this->_unapprovedComments = (int) \IPS\Db::i()->select( "SUM({$itemClass::$databasePrefix}{$itemClass::$databaseColumnMap['unapproved_comments']})", $itemClass::$databaseTable, $commentWhere, NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
|
||||
$this->_unapprovedComments = (int) \IPS\Db::i()->select( "SUM({$itemClass::$databasePrefix}{$itemClass::$databaseColumnMap['unapproved_comments']})", $itemClass::$databaseTable, $commentWhere )->first();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2888,7 +2949,7 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
$this->_unapprovedReviews = \IPS\Db::i()->select( 'COUNT(*)', array(
|
||||
array( $reviewClass::$databaseTable, $reviewClass::$databaseTable ),
|
||||
array( $itemClass::$databaseTable, $itemClass::$databaseTable )
|
||||
), $reviewWhere, NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
|
||||
), $reviewWhere )->first();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3901,4 +3962,4 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user