Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -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 ) ) )
|
||||
|
||||
Reference in new issue
Block a user