Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -193,22 +193,26 @@ class _Feed extends \IPS\Node\Model
|
||||
|
||||
if ( $response->httpResponseCode == 401 )
|
||||
{
|
||||
throw new \DomainException('rss_import_auth');
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'rss_import_auth' ) );
|
||||
}
|
||||
|
||||
$response = $response->decodeXml();
|
||||
if ( !( $response instanceof \IPS\Xml\Rss ) and !( $response instanceof \IPS\Xml\Atom ) )
|
||||
{
|
||||
throw new \DomainException('rss_import_invalid');
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'rss_import_invalid' ) );
|
||||
}
|
||||
}
|
||||
catch ( \IPS\Http\Request\Exception $e )
|
||||
{
|
||||
throw new \DomainException( 'form_url_bad' );
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'form_url_bad' ) );
|
||||
}
|
||||
catch( \RuntimeException $e )
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'rss_import_invalid' ) );
|
||||
}
|
||||
catch ( \ErrorException $e )
|
||||
{
|
||||
throw new \DomainException( 'rss_import_invalid' );
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'rss_import_invalid' ) );
|
||||
}
|
||||
|
||||
$values['title'] = (string) $request->get()->decodeXml()->channel->title;
|
||||
@@ -274,15 +278,22 @@ class _Feed extends \IPS\Node\Model
|
||||
$inserts = array();
|
||||
$request = $request->decodeXml();
|
||||
|
||||
if( !( $request instanceof \IPS\Xml\RssOne ) AND !( $request instanceof \IPS\Xml\Rss ) AND !( $request instanceof \IPS\Xml\Atom ) )
|
||||
if( !( $request instanceof \IPS\Xml\Rss1 ) AND !( $request instanceof \IPS\Xml\Rss ) AND !( $request instanceof \IPS\Xml\Atom ) )
|
||||
{
|
||||
throw new \RuntimeException( 'rss_import_invalid' );
|
||||
}
|
||||
|
||||
|
||||
$post = NULL;
|
||||
foreach ( $request->articles( $this->id ) as $guid => $article )
|
||||
{
|
||||
if ( !in_array( $guid, $previouslyImportedGuids ) )
|
||||
{
|
||||
/* Don't post future date content - this breaks things like marking as read */
|
||||
if( $article['date']->getTimestamp() > time() )
|
||||
{
|
||||
$artice['date'] = \IPS\DateTime::create();
|
||||
}
|
||||
|
||||
$topic = \IPS\forums\Topic::createItem( \IPS\Member::load( $this->mid ), NULL, $article['date'], $container, $this->topic_hide );
|
||||
$topic->title = $this->topic_pre . $article['title'];
|
||||
if ( !$this->topic_open )
|
||||
@@ -290,6 +301,13 @@ class _Feed extends \IPS\Node\Model
|
||||
$topic->state = 'closed';
|
||||
}
|
||||
$topic->save();
|
||||
|
||||
/* Send notifications */
|
||||
if ( !$this->topic_hide )
|
||||
{
|
||||
$topic->sendNotifications();
|
||||
}
|
||||
|
||||
|
||||
/* Add to search index */
|
||||
\IPS\Content\Search\Index::i()->index( $topic );
|
||||
@@ -347,9 +365,12 @@ class _Feed extends \IPS\Node\Model
|
||||
|
||||
$this->last_import = time();
|
||||
$this->save();
|
||||
|
||||
$container->setLastComment();
|
||||
$container->save();
|
||||
|
||||
if ( $post !== NULL )
|
||||
{
|
||||
$container->setLastComment( $post );
|
||||
$container->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -323,8 +323,11 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
{
|
||||
try
|
||||
{
|
||||
/* We prefer fetching post, joining topic, etc. but that is not efficient and causes a temp table and filesort against posts table so we'll lean on the cached last_post value for the topic */
|
||||
$select = \IPS\Db::i()->select( '*', 'forums_topics', array( "forums_topics.forum_id=? AND forums_topics.approved=1 AND forums_topics.state != ?", $this->id, 'link' ), 'forums_topics.last_post DESC', 1 )->first();
|
||||
/*
|
||||
* We prefer fetching post, joining topic, etc. but that is not efficient and causes a temp table and filesort against posts table so we'll lean on the cached last_post value for the topic
|
||||
* We also need to fetch from the write server in the event that something has just been deleted and the comment hasn't been passed
|
||||
*/
|
||||
$select = \IPS\Db::i()->select( '*', 'forums_topics', array( "forums_topics.forum_id=? AND forums_topics.approved=1 AND forums_topics.state != ?", $this->id, 'link' ), 'forums_topics.last_post DESC', 1, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
|
||||
$topic = \IPS\forums\Topic::constructFromData( $select );
|
||||
|
||||
if ( $topic->last_poster_id and ! $topic->last_poster_name )
|
||||
@@ -405,10 +408,11 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
parent::resetCommentCounts();
|
||||
|
||||
/* Archiving? */
|
||||
if ( \IPS\Settings::i()->archive_on )
|
||||
try
|
||||
{
|
||||
$this->_comments += \IPS\forums\Topic\ArchivedPost::db()->select( 'COUNT(*)', 'forums_archive_posts', array( 'archive_forum_id=?', $this->id ) )->first();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -759,7 +763,7 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if ( in_array( $permission, array( 'add', 'reply' ) ) and $this->min_posts_post and $this->min_posts_post >= $_member->member_posts )
|
||||
if ( in_array( $permission, array( 'add', 'reply' ) ) and $this->min_posts_post and $this->min_posts_post > $_member->member_posts )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -1407,7 +1411,7 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
$this->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If there is only one forum (and it isn't a redirect forum or password protected), that forum, or NULL
|
||||
*
|
||||
@@ -1415,7 +1419,7 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
*/
|
||||
public static function theOnlyForum()
|
||||
{
|
||||
return static::theOnlyNode( array( 'redirect_url' => FALSE, 'password' => FALSE, 'club_id' => 0 ), FALSE );
|
||||
return static::theOnlyNode( array( 'redirect_url' => FALSE, 'password' => FALSE ), FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1641,7 +1645,15 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
public function disabledPermissions()
|
||||
{
|
||||
$disabled = array();
|
||||
$guestGroup = \IPS\Member\Group::load( \IPS\Settings::i()->guest_group );
|
||||
|
||||
try
|
||||
{
|
||||
$guestGroup = \IPS\Member\Group::load( \IPS\Settings::i()->guest_group );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
throw new \UnderflowException( 'invalid_guestgroup_admin', 199 );
|
||||
}
|
||||
|
||||
if( $this->sub_can_post and !$this->can_view_others )
|
||||
{
|
||||
@@ -1700,13 +1712,14 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
/**
|
||||
* Get output for API
|
||||
*
|
||||
* @param \IPS\Member|NULL $authorizedMember The member making the API request or NULL for API Key / client_credentials
|
||||
* @return array
|
||||
* @apiresponse int id ID number
|
||||
* @apiresponse string name Forum name
|
||||
* @apiresponse int topics Number of topics in forum
|
||||
* @apiresponse string url URL
|
||||
*/
|
||||
public function apiOutput()
|
||||
public function apiOutput( \IPS\Member $authorizedMember = NULL )
|
||||
{
|
||||
return array(
|
||||
'id' => $this->id,
|
||||
@@ -1744,6 +1757,12 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
{
|
||||
$this->name_seo = \IPS\Http\Url\Friendly::seoTitle( $values['club_node_name'] );
|
||||
}
|
||||
|
||||
if ( !$this->_id )
|
||||
{
|
||||
$this->save();
|
||||
\IPS\File::claimAttachments( 'forums-new-forum', $this->id, NULL, 'description' );
|
||||
}
|
||||
}
|
||||
|
||||
/* !Simple view */
|
||||
@@ -1764,6 +1783,12 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
return false;
|
||||
}
|
||||
|
||||
/* If this was called via CLI (e.g. tasks ran via cron), then use the default */
|
||||
if( !\IPS\Dispatcher::hasInstance() )
|
||||
{
|
||||
return \IPS\Settings::i()->forums_default_view === 'fluid' ? true : false;
|
||||
}
|
||||
|
||||
/* Guests are locked to the admin choice */
|
||||
if ( ! \IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
@@ -1809,11 +1834,14 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
try
|
||||
{
|
||||
$method = \IPS\Db::i()->select( 'method', 'forums_view_method', array( 'member_id=?', \IPS\Member::loggedIn()->member_id ) )->first();
|
||||
|
||||
/* Attempt to set the cookie again */
|
||||
\IPS\Request::i()->setCookie( 'forum_view', $method, ( new \IPS\DateTime )->add( new \DateInterval( 'P1Y' ) ) );
|
||||
}
|
||||
catch( \UnderFlowException $e ){ }
|
||||
catch( \UnderFlowException $e )
|
||||
{
|
||||
$method = \IPS\Settings::i()->forums_default_view;
|
||||
}
|
||||
|
||||
/* Attempt to set the cookie again */
|
||||
\IPS\Request::i()->setCookie( 'forum_view', $method, ( new \IPS\DateTime )->add( new \DateInterval( 'P1Y' ) ) );
|
||||
}
|
||||
|
||||
if ( ! $method or ( $chooseable != '*' AND ! in_array( $method, $chooseable ) ) )
|
||||
|
||||
@@ -221,10 +221,22 @@ class _SavedAction extends \IPS\Node\Model
|
||||
{
|
||||
/* Permission Checks */
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
|
||||
/* Check the member can use saved actions, and they can moderate in this forum */
|
||||
if ( !$member->modPermission('can_use_saved_actions') )
|
||||
{
|
||||
throw new \DomainException('NO_PERMISSION');
|
||||
}
|
||||
|
||||
if ( $member->modPermission( 'forums' ) !== -1 AND $member->modPermission( 'forums' ) !== TRUE )
|
||||
{
|
||||
if ( !is_array( $member->modPermission( 'forums' ) ) or !in_array( $topic->container()->_id, $member->modPermission( 'forums' ) ) )
|
||||
{
|
||||
throw new \DomainException('NO_PERMISSION');
|
||||
}
|
||||
}
|
||||
|
||||
/* Check the action is enabled and allowed for the content item */
|
||||
if ( !$this->mm_enabled )
|
||||
{
|
||||
throw new \DomainException('DISABLED');
|
||||
@@ -283,7 +295,7 @@ class _SavedAction extends \IPS\Node\Model
|
||||
/* Reply */
|
||||
if ( $this->topic_reply )
|
||||
{
|
||||
$reply = \IPS\forums\Topic\Post::create( $topic, $this->topic_reply_content, FALSE, NULL, $this->topic_reply_postcount );
|
||||
$reply = \IPS\forums\Topic\Post::create( $topic, $this->topic_reply_content, FALSE, NULL, isset( $this->topic_reply_postcount ) AND $this->topic_reply_postcount ? TRUE : FALSE );
|
||||
}
|
||||
|
||||
/* Move */
|
||||
|
||||
@@ -21,9 +21,9 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
/**
|
||||
* Post Model
|
||||
*/
|
||||
class _Post extends \IPS\Content\Comment implements \IPS\Content\ReportCenter, \IPS\Content\EditHistory, \IPS\Content\Hideable, \IPS\Content\Shareable, \IPS\Content\Searchable, \IPS\Content\Embeddable
|
||||
class _Post extends \IPS\Content\Comment implements \IPS\Content\EditHistory, \IPS\Content\Hideable, \IPS\Content\Shareable, \IPS\Content\Searchable, \IPS\Content\Embeddable
|
||||
{
|
||||
use \IPS\Content\Reactable;
|
||||
use \IPS\Content\Reactable, \IPS\Content\Reportable;
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Store
|
||||
@@ -169,7 +169,7 @@ class _Post extends \IPS\Content\Comment implements \IPS\Content\ReportCenter, \
|
||||
*/
|
||||
public static function incrementPostCount( \IPS\Node\Model $container = NULL )
|
||||
{
|
||||
return $container and $container->inc_postcount;
|
||||
return !$container or $container->inc_postcount;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -324,6 +324,17 @@ class _Post extends \IPS\Content\Comment implements \IPS\Content\ReportCenter, \
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* [ActiveRecord] Save
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
parent::save();
|
||||
$this->item()->clearVotes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Post
|
||||
@@ -400,22 +411,23 @@ class _Post extends \IPS\Content\Comment implements \IPS\Content\ReportCenter, \
|
||||
/**
|
||||
* Definite Article
|
||||
*
|
||||
* @param array $containerData Basic data about the container. Only includes columns returned by container::basicDataColumns()
|
||||
* @param \IPS\Lang $lang The language to use, or NULL for the language of the currently logged in member
|
||||
* @return string
|
||||
* @param array $containerData Basic data about the container. Only includes columns returned by container::basicDataColumns()
|
||||
* @param \IPS\Lang|NULL $language 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
|
||||
* @return string
|
||||
*/
|
||||
public static function _definiteArticle( array $containerData = NULL, \IPS\Lang $lang = NULL )
|
||||
public static function _definiteArticle( array $containerData = NULL, \IPS\Lang $lang = NULL, $options = array() )
|
||||
{
|
||||
$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();
|
||||
return $lang->addToStack( '__defart_answer', FALSE );
|
||||
return $lang->addToStack( '__defart_answer', FALSE, $options );
|
||||
}
|
||||
else
|
||||
{
|
||||
return parent::_definiteArticle( $containerData, $lang );
|
||||
return parent::_definiteArticle( $containerData, $lang, $options );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ class _Topic extends \IPS\Content\Item implements
|
||||
\IPS\Content\Tags,
|
||||
\IPS\Content\Followable,
|
||||
\IPS\Content\Shareable,
|
||||
\IPS\Content\ReportCenter,
|
||||
\IPS\Content\ReadMarkers,
|
||||
\IPS\Content\Views,
|
||||
\IPS\Content\Polls, \SplObserver,
|
||||
@@ -36,6 +35,8 @@ class _Topic extends \IPS\Content\Item implements
|
||||
\IPS\Content\Embeddable,
|
||||
\IPS\Content\MetaData
|
||||
{
|
||||
use \IPS\Content\Reportable;
|
||||
|
||||
const ARCHIVE_NOT = 0;
|
||||
const ARCHIVE_DONE = 1;
|
||||
const ARCHIVE_WORKING = 2;
|
||||
@@ -343,7 +344,7 @@ class _Topic extends \IPS\Content\Item implements
|
||||
{
|
||||
$joinContainer = TRUE;
|
||||
|
||||
$whereClause = array( '( forums_forums.can_view_others=1 OR forums_topics.starter_id=? )', $member->member_id );
|
||||
$whereClause = array( '( forums_forums.can_view_others=1 OR forums_topics.starter_id=? )', (int) $member->member_id );
|
||||
|
||||
if ( $member->modPermission( 'can_read_all_topics' ) )
|
||||
{
|
||||
@@ -364,7 +365,7 @@ class _Topic extends \IPS\Content\Item implements
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
$joinContainer = TRUE;
|
||||
$where['container'][] = array( 'forums_forums.min_posts_view<=?', \IPS\Member::loggedIn()->member_posts );
|
||||
$where['container'][] = array( 'forums_forums.min_posts_view<=?', $member->member_posts );
|
||||
}
|
||||
|
||||
/* Return */
|
||||
@@ -689,7 +690,10 @@ class _Topic extends \IPS\Content\Item implements
|
||||
{
|
||||
$popularNowInterval = new \DateInterval( 'PT' . $popularNowSettings['minutes'] . 'M' );
|
||||
|
||||
$comments = $this->comments( NULL, NULL, 'date', 'desc', NULL, FALSE, \IPS\DateTime::create()->sub( $popularNowInterval ) );
|
||||
$comments = iterator_to_array( new \IPS\Patterns\ActiveRecordIterator(
|
||||
\IPS\Db::i()->select( '*', 'forums_posts', array( 'queued IN(0,2) AND post_date >? AND topic_id=?', \IPS\DateTime::create()->sub( $popularNowInterval )->getTimestamp(), $this->tid ), 'post_date DESC', NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER ),
|
||||
'IPS\\forums\\Topic\\Post'
|
||||
) );
|
||||
if ( count( $comments ) >= $popularNowSettings['posts'] )
|
||||
{
|
||||
$commentToBasePopularNowTimeOff = array_slice( $comments, ( $popularNowSettings['posts'] - 1 ), 1 );
|
||||
@@ -866,9 +870,9 @@ class _Topic extends \IPS\Content\Item implements
|
||||
*/
|
||||
public static function contentTableTemplate()
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'forums.css', 'forums' ) );
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'forums_responsive.css', 'forums' ) );
|
||||
return array( \IPS\Theme::i()->getTemplate( 'global', 'forums' ), 'rows' );
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'forums.css', 'forums', 'front' ) );
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'forums_responsive.css', 'forums', 'front' ) );
|
||||
return array( \IPS\Theme::i()->getTemplate( 'global', 'forums', 'front' ), 'rows' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -922,7 +926,7 @@ class _Topic extends \IPS\Content\Item implements
|
||||
{
|
||||
if ( $container and ( $container->preview_posts == 1 or $container->preview_posts == 2 ) and !$member->group['g_avoid_q'] )
|
||||
{
|
||||
return TRUE;
|
||||
return !static::modPermission( 'approve', $member, $container );
|
||||
}
|
||||
|
||||
return parent::moderateNewItems( $member, $container );
|
||||
@@ -1325,7 +1329,7 @@ class _Topic extends \IPS\Content\Item implements
|
||||
}
|
||||
|
||||
/* Have we already voted? */
|
||||
if ( $rating !== 0 or !\IPS\Settings::i()->forums_answers_downvote )
|
||||
if ( $rating !== 0 or !\IPS\Settings::i()->forums_questions_downvote )
|
||||
{
|
||||
$ratings = $this->votes();
|
||||
if ( isset( $ratings[ $member->member_id ] ) and $ratings[ $member->member_id ] === $rating )
|
||||
@@ -1367,6 +1371,29 @@ class _Topic extends \IPS\Content\Item implements
|
||||
return $this->votes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear Votes Cache
|
||||
*
|
||||
* @return void
|
||||
* @note This is necessary so that when voting on a question or answer, the cached votes ($votes and $answerVotes) are reloaded properly.
|
||||
*/
|
||||
public function clearVotes()
|
||||
{
|
||||
$this->votes = NULL;
|
||||
$this->answerVotes = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* [ActiveRecord] Save
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
parent::save();
|
||||
$this->clearVotes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indefinite Article
|
||||
*
|
||||
@@ -1391,21 +1418,23 @@ class _Topic extends \IPS\Content\Item implements
|
||||
/**
|
||||
* Definite Article
|
||||
*
|
||||
* @param \IPS\Lang|NULL $language The language to use, or NULL for the language of the currently logged in member
|
||||
* @param array $containerData Basic data about the container. Only includes columns returned by container::basicDataColumns()
|
||||
* @param \IPS\Lang|NULL $language 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
|
||||
* @return string
|
||||
*/
|
||||
public static function _definiteArticle( array $containerData = NULL, \IPS\Lang $lang = NULL )
|
||||
public static function _definiteArticle( array $containerData = NULL, \IPS\Lang $lang = NULL, $options = array() )
|
||||
{
|
||||
$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();
|
||||
return $lang->addToStack( '__defart_question', FALSE );
|
||||
return $lang->addToStack( '__defart_question', FALSE, $options );
|
||||
}
|
||||
else
|
||||
{
|
||||
return parent::_definiteArticle( $containerData, $lang );
|
||||
return parent::_definiteArticle( $containerData, $lang, $options );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1492,10 +1521,12 @@ class _Topic extends \IPS\Content\Item implements
|
||||
|
||||
$time = \IPS\DateTime::ts( $taskData['next_run'] );
|
||||
$postsToBeUnarchived = \IPS\Db::i()->select( 'SUM(posts) + COUNT(*)', 'forums_topics', array( 'topic_archive_status=?', static::ARCHIVE_RESTORE ) )->first();
|
||||
if ( $postsToBeUnarchived )
|
||||
|
||||
if ( $postsToBeUnarchived AND $postsToBeUnarchived > \IPS\forums\tasks\unarchive::PROCESS_PER_BATCH )
|
||||
{
|
||||
$total = $postsToBeUnarchived / \IPS\forums\tasks\unarchive::PROCESS_PER_BATCH;
|
||||
$interval = new \DateInterval( $taskData['frequency'] );
|
||||
foreach ( range( 1, $postsToBeUnarchived ) as $i )
|
||||
foreach ( range( 1, $total ) as $i )
|
||||
{
|
||||
$time->add( $interval );
|
||||
}
|
||||
@@ -1728,9 +1759,10 @@ class _Topic extends \IPS\Content\Item implements
|
||||
* @param mixed $extraWhereClause Additional where clause(s) (see \IPS\Db::build for details)
|
||||
* @param bool|NULL $bypassCache Used in cases where comments may have already been loaded i.e. splitting comments on an item.
|
||||
* @param bool $includeDeleted Include Deleted Content
|
||||
* @param bool|NULL $canViewWarn TRUE to include Warning information, NULL to determine automatically based on moderator permissions.
|
||||
* @return array|NULL|\IPS\Content\Comment If $limit is 1, will return \IPS\Content\Comment or NULL for no results. For any other number, will return an array.
|
||||
*/
|
||||
public function comments( $limit=NULL, $offset=NULL, $order='date', $orderDirection='asc', $member=NULL, $includeHiddenComments=NULL, $cutoff=NULL, $extraWhereClause=NULL, $bypassCache=FALSE, $includeDeleted=FALSE )
|
||||
public function comments( $limit=NULL, $offset=NULL, $order='date', $orderDirection='asc', $member=NULL, $includeHiddenComments=NULL, $cutoff=NULL, $extraWhereClause=NULL, $bypassCache=FALSE, $includeDeleted=FALSE, $canViewWarn=NULL )
|
||||
{
|
||||
static $comments = array();
|
||||
$idField = static::$databaseColumnId;
|
||||
@@ -1741,7 +1773,7 @@ class _Topic extends \IPS\Content\Item implements
|
||||
return $comments[ $_hash ];
|
||||
}
|
||||
|
||||
$includeWarnings = NULL;
|
||||
$includeWarnings = $canViewWarn;
|
||||
$commentClass = NULL;
|
||||
|
||||
if ( $this->isArchived() )
|
||||
@@ -1855,19 +1887,19 @@ class _Topic extends \IPS\Content\Item implements
|
||||
/**
|
||||
* Returns the meta description
|
||||
*
|
||||
* @param string|NULL $return Specific description to use (useful for paginated displays to prevent having to run extra queries)
|
||||
* @return string
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
public function metaDescription()
|
||||
public function metaDescription( $return = NULL )
|
||||
{
|
||||
/* We have to store and restore this for the topic controller */
|
||||
if( isset( $_SESSION['_findComment'] ) )
|
||||
{
|
||||
$_findComment = $_SESSION['_findComment'];
|
||||
|
||||
}
|
||||
|
||||
$metaDescription = parent::metaDescription();
|
||||
$metaDescription = parent::metaDescription( $return );
|
||||
|
||||
if( isset( $_findComment ) )
|
||||
{
|
||||
@@ -1880,12 +1912,13 @@ class _Topic extends \IPS\Content\Item implements
|
||||
/**
|
||||
* Get output for API
|
||||
*
|
||||
* @param \IPS\Member|NULL $authorizedMember The member making the API request or NULL for API Key / client_credentials
|
||||
* @return array
|
||||
* @apiresponse int id ID number
|
||||
* @apiresponse string title Title
|
||||
* @apiresponse \IPS\forums\Forum forum Forum
|
||||
* @apiresponse int posts Number of posts
|
||||
* @apiresponse int views Number of posts
|
||||
* @apiresponse int views Number of views
|
||||
* @apiresponse string prefix The prefix tag, if there is one
|
||||
* @apiresponse [string] tags The tags
|
||||
* @apiresponse \IPS\forums\Topic\Post firstPost The first post in the topic
|
||||
@@ -1900,7 +1933,7 @@ class _Topic extends \IPS\Content\Item implements
|
||||
* @apiresponse string url URL
|
||||
* @apiresponse float rating Average Rating
|
||||
*/
|
||||
public function apiOutput()
|
||||
public function apiOutput( \IPS\Member $authorizedMember = NULL )
|
||||
{
|
||||
$firstPost = $this->comments( 1, 0, 'date', 'asc' );
|
||||
$lastPost = $this->comments( 1, 0, 'date', 'desc' );
|
||||
@@ -1908,20 +1941,20 @@ class _Topic extends \IPS\Content\Item implements
|
||||
return array(
|
||||
'id' => $this->tid,
|
||||
'title' => $this->title,
|
||||
'forum' => $this->container()->apiOutput(),
|
||||
'forum' => $this->container()->apiOutput( $authorizedMember ),
|
||||
'posts' => $this->posts,
|
||||
'views' => $this->views,
|
||||
'prefix' => $this->prefix(),
|
||||
'tags' => $this->tags(),
|
||||
'firstPost' => $firstPost ? $firstPost->apiOutput() : null,
|
||||
'lastPost' => $lastPost ? $lastPost->apiOutput() : null,
|
||||
'bestAnswer' => $bestAnswer ? $bestAnswer->apiOutput() : null,
|
||||
'firstPost' => $firstPost ? $firstPost->apiOutput( $authorizedMember ) : null,
|
||||
'lastPost' => $lastPost ? $lastPost->apiOutput( $authorizedMember ) : null,
|
||||
'bestAnswer' => $bestAnswer ? $bestAnswer->apiOutput( $authorizedMember ) : null,
|
||||
'locked' => (bool) $this->locked(),
|
||||
'hidden' => (bool) $this->hidden(),
|
||||
'pinned' => (bool) $this->mapped('pinned'),
|
||||
'featured' => (bool) $this->mapped('featured'),
|
||||
'archived' => (bool) $this->isArchived(),
|
||||
'poll' => $this->poll_state ? \IPS\Poll::load( $this->poll_state )->apiOutput() : null,
|
||||
'poll' => $this->poll_state ? \IPS\Poll::load( $this->poll_state )->apiOutput( $authorizedMember ) : null,
|
||||
'url' => (string) $this->url(),
|
||||
'rating' => $this->averageRating(),
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user