Version 4.7.0
This commit is contained in:
1 parent
517a5e1f70
commit
8ba7d43898
1933 files changed
+65613
-11332
No files matched your search
@@ -40,23 +40,16 @@ class _ArchivedPost extends Post
|
||||
public static function db()
|
||||
{
|
||||
/* Connect to the remote DB if needed */
|
||||
if ( \IPS\CIC2 )
|
||||
{
|
||||
return \IPS\Cicloud\getForumArchiveDb();
|
||||
}
|
||||
else
|
||||
{
|
||||
return ( !\IPS\Settings::i()->archive_remote_sql_host ) ? \IPS\Db::i() : \IPS\Db::i( 'archive', array(
|
||||
'sql_host' => \IPS\Settings::i()->archive_remote_sql_host,
|
||||
'sql_user' => \IPS\Settings::i()->archive_remote_sql_user,
|
||||
'sql_pass' => \IPS\Settings::i()->archive_remote_sql_pass,
|
||||
'sql_database' => \IPS\Settings::i()->archive_remote_sql_database,
|
||||
'sql_port' => \IPS\Settings::i()->archive_sql_port,
|
||||
'sql_socket' => \IPS\Settings::i()->archive_sql_socket,
|
||||
'sql_tbl_prefix'=> \IPS\Settings::i()->archive_sql_tbl_prefix,
|
||||
'sql_utf8mb4' => isset( \IPS\Settings::i()->sql_utf8mb4 ) ? \IPS\Settings::i()->sql_utf8mb4 : FALSE
|
||||
) );
|
||||
}
|
||||
return ( !\IPS\Settings::i()->archive_remote_sql_host ) ? \IPS\Db::i() : \IPS\Db::i( 'archive', array(
|
||||
'sql_host' => \IPS\Settings::i()->archive_remote_sql_host,
|
||||
'sql_user' => \IPS\Settings::i()->archive_remote_sql_user,
|
||||
'sql_pass' => \IPS\Settings::i()->archive_remote_sql_pass,
|
||||
'sql_database' => \IPS\Settings::i()->archive_remote_sql_database,
|
||||
'sql_port' => \IPS\Settings::i()->archive_sql_port,
|
||||
'sql_socket' => \IPS\Settings::i()->archive_sql_socket,
|
||||
'sql_tbl_prefix'=> \IPS\Settings::i()->archive_sql_tbl_prefix,
|
||||
'sql_utf8mb4' => isset( \IPS\Settings::i()->sql_utf8mb4 ) ? \IPS\Settings::i()->sql_utf8mb4 : FALSE
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,8 +84,8 @@ class _ArchivedPost extends Post
|
||||
* @brief Bitwise values for post_bwoptions field
|
||||
*/
|
||||
public static $bitOptions = array(
|
||||
'bwoptions' => array(
|
||||
'bwoptions' => array(
|
||||
'post_bwoptions' => array(
|
||||
'post_bwoptions' => array(
|
||||
'best_answer' => 1
|
||||
)
|
||||
)
|
||||
@@ -102,28 +95,38 @@ class _ArchivedPost extends Post
|
||||
* @brief Database Column ID
|
||||
*/
|
||||
public static $databaseColumnId = 'id';
|
||||
|
||||
|
||||
/**
|
||||
* Post count for member
|
||||
*
|
||||
* @param \IPS\Member $member The memner
|
||||
* @param \IPS\Member $member The member
|
||||
* @param bool $includeNonPostCountIncreasing If FALSE, will skip any posts which would not cause the user's post count to increase
|
||||
* @param bool $includeHiddenAndPendingApproval If FALSE, will skip any hidden posts, or posts pending approval
|
||||
* @return int
|
||||
*/
|
||||
public static function memberPostCount( \IPS\Member $member, bool $includeNonPostCountIncreasing = FALSE, bool $includeHiddenAndPendingApproval = TRUE )
|
||||
{
|
||||
$where = [];
|
||||
$where[] = [ 'archive_author_id=?', $member->member_id ];
|
||||
|
||||
if ( !$includeNonPostCountIncreasing )
|
||||
|
||||
try
|
||||
{
|
||||
$where[] = [ \IPS\Db::i()->in( 'archive_forum_id', iterator_to_array( \IPS\Db::i()->select( 'id', 'forums_forums', 'inc_postcount=0' ) ) ) ];
|
||||
if ( !$includeNonPostCountIncreasing )
|
||||
{
|
||||
$where[] = [ static::db()->in( 'archive_forum_id', iterator_to_array( \IPS\Db::i()->select( 'id', 'forums_forums', 'inc_postcount=1' ) ) ) ];
|
||||
}
|
||||
if ( !$includeHiddenAndPendingApproval )
|
||||
{
|
||||
$where[] = [ 'archive_queued=0' ];
|
||||
}
|
||||
|
||||
return static::db()->select( 'COUNT(*)', static::$databaseTable, $where )->first();
|
||||
}
|
||||
if ( !$includeHiddenAndPendingApproval )
|
||||
catch ( \IPS\Db\Exception $e )
|
||||
{
|
||||
$where[] = [ 'archive_queued=0' ];
|
||||
return 0;
|
||||
}
|
||||
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'forums_posts', $where )->first();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,4 +210,4 @@ class _ArchivedPost extends Post
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -110,6 +110,21 @@ class _Post extends \IPS\Content\Comment implements \IPS\Content\EditHistory, \I
|
||||
*/
|
||||
public static $joinProfileFields = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Used for the datalayer
|
||||
*/
|
||||
public static $commentType = 'reply';
|
||||
|
||||
/**
|
||||
* @brief Value to set for the 'tab' parameter when redirecting to the comment (via _find())
|
||||
*/
|
||||
public static $tabParameter = NULL; /* We do not want ?tab=comments appended to links in from findComment links */
|
||||
|
||||
/**
|
||||
* @brief Whether to track the sentiment scores in cloud_sentiment_scores for this content
|
||||
*/
|
||||
public $trackSentimentScore = true;
|
||||
|
||||
/**
|
||||
* Create comment
|
||||
*
|
||||
@@ -122,11 +137,12 @@ class _Post extends \IPS\Content\Comment implements \IPS\Content\EditHistory, \I
|
||||
* @param \IPS\DateTime|NULL $time The time
|
||||
* @param string|NULL $ipAddress The IP address or NULL to detect automatically
|
||||
* @param int|NULL $hiddenStatus NULL to set automatically or override: 0 = unhidden; 1 = hidden, pending moderator approval; -1 = hidden (as if hidden by a moderator)
|
||||
* @param int|NULL $anonymous NULL for no value, 0 or 1 for a value (0=no, 1=yes)
|
||||
* @return static
|
||||
*/
|
||||
public static function create( $item, $comment, $first=FALSE, $guestName=NULL, $incrementPostCount=NULL, $member=NULL, \IPS\DateTime $time=NULL, $ipAddress=NULL, $hiddenStatus=NULL )
|
||||
public static function create( $item, $comment, $first=FALSE, $guestName=NULL, $incrementPostCount=NULL, $member=NULL, \IPS\DateTime $time=NULL, $ipAddress=NULL, $hiddenStatus=NULL, $anonymous=NULL )
|
||||
{
|
||||
$comment = parent::create( $item, $comment, $first, $guestName, $incrementPostCount, $member, $time, $ipAddress, $hiddenStatus );
|
||||
$comment = parent::create( $item, $comment, $first, $guestName, $incrementPostCount, $member, $time, $ipAddress, $hiddenStatus, $anonymous );
|
||||
|
||||
if ( !$comment->hidden() )
|
||||
{
|
||||
|
||||
@@ -174,6 +174,11 @@ class _Topic extends \IPS\Content\Item implements
|
||||
* @brief Setting name for show_meta
|
||||
*/
|
||||
public static $showMetaSettingKey = 'forums_topics_show_meta';
|
||||
|
||||
/**
|
||||
* @brief Whether to track the sentiment scores in cloud_sentiment_scores for this content
|
||||
*/
|
||||
public $trackSentimentScore = true;
|
||||
|
||||
/**
|
||||
* Callback from \IPS\Http\Url\Inernal::correctUrlFromVerifyClass()
|
||||
@@ -337,7 +342,7 @@ class _Topic extends \IPS\Content\Item implements
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
$containerClass = static::$containerNodeClass;
|
||||
|
||||
if ( $containerClass::hasPasswordForums() )
|
||||
if ( $containerClass::customPermissionNodes() )
|
||||
{
|
||||
$whereString = 'forums_forums.password=? OR ' . \IPS\Db::i()->findInSet( 'forums_forums.password_override', $member->groups );
|
||||
$whereParams = array( NULL );
|
||||
@@ -459,6 +464,23 @@ class _Topic extends \IPS\Content\Item implements
|
||||
{
|
||||
return parent::contentCount( $container, FALSE, TRUE, $includeReviews, $depth );
|
||||
}
|
||||
|
||||
/**
|
||||
* Total item, items only \count(including children)
|
||||
*
|
||||
* @param \IPS\Node\Model $container The container
|
||||
* @param bool $includeItems If TRUE, items will be included (this should usually be true)
|
||||
* @param bool $includeComments If TRUE, comments will be included
|
||||
* @param bool $includeReviews If TRUE, reviews will be included
|
||||
* @param int $depth Used to keep track of current depth to avoid going too deep
|
||||
* @return int|NULL|string When depth exceeds 10, will return "NULL" and initial call will return something like "100+"
|
||||
* @note This method may return something like "100+" if it has lots of children to avoid exahusting memory. It is intended only for display use
|
||||
* @note This method includes counts of hidden and unapproved content items as well
|
||||
*/
|
||||
public static function contentCountItemsOnly( \IPS\Node\Model $container )
|
||||
{
|
||||
return parent::contentCount( $container, TRUE, FALSE, FALSE, 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get elements for add/edit form
|
||||
@@ -1059,8 +1081,8 @@ class _Topic extends \IPS\Content\Item implements
|
||||
\IPS\Db::i()->delete( 'forums_question_ratings', array( 'topic=?', $this->tid ) );
|
||||
\IPS\Db::i()->delete( 'forums_answer_ratings', array( 'topic=?', $this->tid ) );
|
||||
|
||||
/* Delete any moved topic links that point to this topic */
|
||||
\IPS\Db::i()->delete( 'forums_topics', array( "state=? AND moved_to LIKE CONCAT( ?, '%' )", 'link', $this->tid . '&' ) );
|
||||
/* Delete any moved topic links that point to this topic - moved_on>? is for query optimisation purposes */
|
||||
\IPS\Db::i()->delete( 'forums_topics', array( "moved_on>? AND moved_to LIKE CONCAT( ?, '%' ) AND state=?", 0, $this->tid . '&', 'link' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1163,8 +1185,8 @@ class _Topic extends \IPS\Content\Item implements
|
||||
*/
|
||||
public function hide( $member, $reason = NULL )
|
||||
{
|
||||
/* Hide any moved topic links that point to this topic */
|
||||
foreach( \IPS\Db::i()->select( '*', 'forums_topics', array( "state=? AND moved_to LIKE CONCAT( ?, '%' )", 'link', $this->tid . '&' ) ) as $link )
|
||||
/* Hide any moved topic links that point to this topic - moved_on>? is for query optimisation purposes */
|
||||
foreach( \IPS\Db::i()->select( '*', 'forums_topics', array( "moved_on>? AND moved_to LIKE CONCAT( ?, '%' ) AND state=?", 0, $this->tid . '&', 'link' ) ) as $link )
|
||||
{
|
||||
\IPS\forums\Topic::constructFromData( $link )->hide( $member, $reason );
|
||||
}
|
||||
@@ -1180,8 +1202,8 @@ class _Topic extends \IPS\Content\Item implements
|
||||
*/
|
||||
public function unhide( $member )
|
||||
{
|
||||
/* Unhide any moved topic links that point to this topic */
|
||||
foreach( \IPS\Db::i()->select( '*', 'forums_topics', array( "state=? AND moved_to LIKE CONCAT( ?, '%' )", 'link', $this->tid . '&' ) ) as $link )
|
||||
/* Unhide any moved topic links that point to this topic - moved_on>? is for query optimisation purposes */
|
||||
foreach( \IPS\Db::i()->select( '*', 'forums_topics', array( "moved_on>? AND moved_to LIKE CONCAT( ?, '%' ) AND state=?", 0, $this->tid . '&', 'link' ) ) as $link )
|
||||
{
|
||||
\IPS\forums\Topic::constructFromData( $link )->unhide( $member );
|
||||
}
|
||||
@@ -1541,6 +1563,11 @@ class _Topic extends \IPS\Content\Item implements
|
||||
*/
|
||||
public static function _indefiniteArticle( array $containerData = NULL, \IPS\Lang $lang = NULL )
|
||||
{
|
||||
if ( !$containerData )
|
||||
{
|
||||
return parent::_indefiniteArticle( $containerData, $lang );
|
||||
}
|
||||
|
||||
$bitOptions = ( $containerData['forums_bitoptions'] instanceof \IPS\Patterns\Bitwise ) ? $containerData['forums_bitoptions'] : new \IPS\Patterns\Bitwise( array( 'forums_bitoptions' => $containerData['forums_bitoptions'] ), \IPS\forums\Forum::$bitOptions['forums_bitoptions'] );
|
||||
|
||||
if ( $bitOptions['bw_enable_answers'] )
|
||||
|
||||
Reference in new issue
Block a user