Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
@@ -33,9 +33,10 @@ class _Topic extends \IPS\Content\Item implements
|
||||
\IPS\Content\Ratings,
|
||||
\IPS\Content\Searchable,
|
||||
\IPS\Content\Embeddable,
|
||||
\IPS\Content\MetaData
|
||||
\IPS\Content\MetaData,
|
||||
\IPS\Content\Anonymous
|
||||
{
|
||||
use \IPS\Content\Reactable, \IPS\Content\Reportable, \IPS\Content\Statistics, \IPS\Content\Solvable;
|
||||
use \IPS\Content\Reactable, \IPS\Content\Reportable, \IPS\Content\Statistics, \IPS\Content\Solvable { toggleSolveComment as protected _toggleSolveComment; }
|
||||
|
||||
/**
|
||||
* @brief Not archived
|
||||
@@ -119,7 +120,9 @@ class _Topic extends \IPS\Content\Item implements
|
||||
'state' => 'state',
|
||||
'updated' => 'last_post',
|
||||
'meta_data' => 'topic_meta_data',
|
||||
'solved_comment_id' => 'topic_answered_pid'
|
||||
'solved_comment_id' => 'topic_answered_pid',
|
||||
'is_anon' => 'is_anon',
|
||||
'last_comment_anon' => 'last_poster_anon',
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -332,23 +335,27 @@ class _Topic extends \IPS\Content\Item implements
|
||||
{
|
||||
$joinContainer = TRUE;
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
|
||||
$whereString = 'forums_forums.password=? OR ' . \IPS\Db::i()->findInSet( 'forums_forums.password_override', $member->groups );
|
||||
$whereParams = array( NULL );
|
||||
if ( \IPS\Dispatcher::hasInstance() AND $member->member_id === \IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
foreach ( \IPS\Request::i()->cookie as $k => $v )
|
||||
$containerClass = static::$containerNodeClass;
|
||||
|
||||
if ( $containerClass::hasPasswordForums() )
|
||||
{
|
||||
$whereString = 'forums_forums.password=? OR ' . \IPS\Db::i()->findInSet( 'forums_forums.password_override', $member->groups );
|
||||
$whereParams = array( NULL );
|
||||
if ( \IPS\Dispatcher::hasInstance() AND $member->member_id === \IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
if ( mb_substr( $k, 0, 13 ) === 'ipbforumpass_' )
|
||||
foreach ( \IPS\Request::i()->cookie as $k => $v )
|
||||
{
|
||||
$whereString .= ' OR ( forums_forums.id=? AND MD5(forums_forums.password)=? )';
|
||||
$whereParams[] = (int) mb_substr( $k, 13 );
|
||||
$whereParams[] = $v;
|
||||
if ( mb_substr( $k, 0, 13 ) === 'ipbforumpass_' )
|
||||
{
|
||||
$whereString .= ' OR ( forums_forums.id=? AND MD5(forums_forums.password)=? )';
|
||||
$whereParams[] = (int) mb_substr( $k, 13 );
|
||||
$whereParams[] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$where['container'][] = array_merge( array( '( ' . $whereString . ' )' ), $whereParams );
|
||||
}
|
||||
|
||||
$where['container'][] = array_merge( array( '( ' . $whereString . ' )' ), $whereParams );
|
||||
}
|
||||
|
||||
/* Don't show topics from forums in which topics only show to the poster */
|
||||
@@ -370,7 +377,7 @@ class _Topic extends \IPS\Content\Item implements
|
||||
$where['item'][] = array( 'forums_topics.starter_id=?', $member->member_id );
|
||||
}
|
||||
}
|
||||
elseif ( !$member->modPermission('can_read_all_topics') or ( $member->modPermission('forums') !== TRUE and !\in_array( $skipPermission->_id, $member->modPermission('forums') ) ) )
|
||||
elseif ( !$member->modPermission('can_read_all_topics') or ( \is_array( $member->modPermission('forums') ) and !\in_array( $skipPermission->_id, $member->modPermission('forums') ) ) )
|
||||
{
|
||||
$where['item'][] = array( 'forums_topics.starter_id=?', $member->member_id );
|
||||
}
|
||||
@@ -674,17 +681,16 @@ class _Topic extends \IPS\Content\Item implements
|
||||
/* Moderator actions */
|
||||
if ( isset( $values['topic_create_state'] ) )
|
||||
{
|
||||
if ( $this->canHide() )
|
||||
if( \in_array( 'hide', $values['topic_create_state'] ) )
|
||||
{
|
||||
if( \in_array( 'hide', $values['topic_create_state'] ) )
|
||||
if ( $this->canHide() )
|
||||
{
|
||||
$this->hide( NULL );
|
||||
}
|
||||
/* Only unhide if the topic is not pending approval */
|
||||
elseif( $this->hidden() !== 1 )
|
||||
{
|
||||
$this->unhide( NULL );
|
||||
}
|
||||
}
|
||||
elseif( $this->hidden() and $this->hidden() !== 1 and $this->canUnhide() )
|
||||
{
|
||||
$this->unhide( NULL );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1040,12 +1046,15 @@ class _Topic extends \IPS\Content\Item implements
|
||||
{
|
||||
parent::delete();
|
||||
|
||||
try
|
||||
if( \in_array( $this->archive_status, array( static::ARCHIVE_DONE, static::ARCHIVE_WORKING, static::ARCHIVE_RESTORE ) ) )
|
||||
{
|
||||
\IPS\forums\Topic\ArchivedPost::db()->delete( 'forums_archive_posts', array( 'archive_topic_id=?', $this->tid ) );
|
||||
try
|
||||
{
|
||||
\IPS\forums\Topic\ArchivedPost::db()->delete( 'forums_archive_posts', array( 'archive_topic_id=?', $this->tid ) );
|
||||
}
|
||||
/* catch db exceptions if e.g. if the connection credentials didn't work or if the database doesn't exist anymore */
|
||||
catch ( \IPS\Db\Exception $e ){}
|
||||
}
|
||||
/* catch db exceptions if e.g. if the connection credentials didn't work or if the database doesn't exist anymore */
|
||||
catch ( \IPS\Db\Exception $e ){}
|
||||
|
||||
\IPS\Db::i()->delete( 'forums_question_ratings', array( 'topic=?', $this->tid ) );
|
||||
\IPS\Db::i()->delete( 'forums_answer_ratings', array( 'topic=?', $this->tid ) );
|
||||
@@ -1314,7 +1323,25 @@ class _Topic extends \IPS\Content\Item implements
|
||||
*/
|
||||
public function containerAllowsMemberSolvable()
|
||||
{
|
||||
return $this->container()->forums_bitoptions['bw_enable_answers_member'];
|
||||
return ( $this->containerAllowsSolvable() AND $this->container()->forums_bitoptions['bw_enable_answers_member'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle the solve value of a comment
|
||||
*
|
||||
* @param int $commentId The comment ID
|
||||
* @param boolean $value TRUE/FALSE value
|
||||
* @param \IPS\Member $member The member (null for currently logged in member)
|
||||
*/
|
||||
public function toggleSolveComment( $commentId, $value, \IPS\Member $member = NULL )
|
||||
{
|
||||
if ( $value )
|
||||
{
|
||||
$post = \IPS\forums\Topic\Post::load( $commentId );
|
||||
$post->author()->achievementAction( 'forums', 'AnswerMarkedBest', $post );
|
||||
}
|
||||
|
||||
return $this->_toggleSolveComment( $commentId, $value, $member );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1533,21 +1560,34 @@ class _Topic extends \IPS\Content\Item implements
|
||||
* @param array $containerData Basic data about the container. Only includes columns returned by container::basicDataColumns()
|
||||
* @param \IPS\Lang|NULL $lang The language to use, or NULL for the language of the currently logged in member
|
||||
* @param array $options Options to pass to \IPS\Lang::addToStack
|
||||
* @param integer|boolean $count Number of items. If not false, pluralized version of phrase will be used.
|
||||
* @return string
|
||||
*/
|
||||
public static function _definiteArticle( array $containerData = NULL, \IPS\Lang $lang = NULL, $options = array() )
|
||||
public static function _definiteArticle( array $containerData = NULL, \IPS\Lang $lang = NULL, $options = array(), $count = FALSE )
|
||||
{
|
||||
$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( $containerData !== NULL )
|
||||
{
|
||||
$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'] )
|
||||
{
|
||||
$lang = $lang ?: \IPS\Member::loggedIn()->language();
|
||||
|
||||
if( $count === TRUE || \is_int( $count ) )
|
||||
{
|
||||
if( \is_int( $count ) )
|
||||
{
|
||||
$options['pluralize'] = array( $count );
|
||||
}
|
||||
|
||||
return $lang->addToStack( '__defart_question_plural', FALSE, $options );
|
||||
}
|
||||
|
||||
return $lang->addToStack( '__defart_question', FALSE, $options );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $bitOptions['bw_enable_answers'] )
|
||||
{
|
||||
$lang = $lang ?: \IPS\Member::loggedIn()->language();
|
||||
return $lang->addToStack( '__defart_question', FALSE, $options );
|
||||
}
|
||||
else
|
||||
{
|
||||
return parent::_definiteArticle( $containerData, $lang, $options );
|
||||
}
|
||||
return parent::_definiteArticle( $containerData, $lang, $options, $count );
|
||||
}
|
||||
|
||||
/* !Sitemap */
|
||||
@@ -2149,8 +2189,6 @@ class _Topic extends \IPS\Content\Item implements
|
||||
|
||||
/* ! Reactions */
|
||||
|
||||
public $reputation = array();
|
||||
|
||||
/**
|
||||
* Reaction type
|
||||
*
|
||||
@@ -2265,4 +2303,34 @@ class _Topic extends \IPS\Content\Item implements
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* We need to force an index so that super long topics load when fetching IDs before running the main query
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
/**
|
||||
* We need to force an index so that super long topics load when fetching IDs before running the main query
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function forceIndexForPaginatedIds()
|
||||
{
|
||||
if ( ! $this->isArchived() )
|
||||
{
|
||||
return 'first_post';
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* WHERE clause for getting items for ACP overview statistics
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function overviewStatisticsWhere()
|
||||
{
|
||||
return array( array( \IPS\Db::i()->in( 'state', array( 'link', 'merged' ), TRUE ) ) );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user