Version 4.7.23
This commit is contained in:
1 parent
7124a02564
commit
25ddeb65d6
1791 files changed
+76990
-44452
No files matched your search
@@ -12,6 +12,9 @@
|
||||
namespace IPS\cms;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
|
||||
use IPS\Content\Comment;
|
||||
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
@@ -243,6 +246,11 @@ class _Records extends \IPS\Content\Item implements
|
||||
*/
|
||||
public static function getCommentsPerPage()
|
||||
{
|
||||
if ( static::database()->comments_perpage )
|
||||
{
|
||||
return static::database()->comments_perpage;
|
||||
}
|
||||
|
||||
if ( ! empty( \IPS\cms\Databases\Dispatcher::i()->recordId ) )
|
||||
{
|
||||
$class = 'IPS\cms\Records' . static::$customDatabaseId;
|
||||
@@ -373,7 +381,7 @@ class _Records extends \IPS\Content\Item implements
|
||||
catch( \OutOfRangeException $ex ) { }
|
||||
}
|
||||
|
||||
$where = array( array( '? LIKE CONCAT( record_dynamic_furl, \'%\') OR LOWER(record_static_furl)=?', $slug, mb_strtolower( $slug ) ) );
|
||||
$where = array( array( '(? LIKE CONCAT( record_dynamic_furl, \'%\') OR LOWER(record_static_furl)=?)', $slug, mb_strtolower( $slug ) ) );
|
||||
if ( $categoryId )
|
||||
{
|
||||
$where[] = array( 'category_id=?', $categoryId );
|
||||
@@ -755,18 +763,11 @@ class _Records extends \IPS\Content\Item implements
|
||||
* @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
|
||||
* @return int
|
||||
* @note This method includes counts of hidden and unapproved content items as well
|
||||
*/
|
||||
public static function contentCount( \IPS\Node\Model $container, $includeItems=TRUE, $includeComments=FALSE, $includeReviews=FALSE, $depth=0 )
|
||||
{
|
||||
/* Are we in too deep? */
|
||||
if ( $depth > 10 )
|
||||
{
|
||||
return '+';
|
||||
}
|
||||
|
||||
$count = $container->_items;
|
||||
|
||||
if ( static::canViewHiddenItems( NULL, $container ) )
|
||||
@@ -785,19 +786,10 @@ class _Records extends \IPS\Content\Item implements
|
||||
}
|
||||
|
||||
/* Add Children */
|
||||
$childDepth = $depth++;
|
||||
$childDepth = ++$depth;
|
||||
foreach ( $container->children() as $child )
|
||||
{
|
||||
$toAdd = static::contentCount( $child, $includeItems, $includeComments, $includeReviews, $childDepth );
|
||||
if ( \is_string( $toAdd ) )
|
||||
{
|
||||
return $count . '+';
|
||||
}
|
||||
else
|
||||
{
|
||||
$count += $toAdd;
|
||||
}
|
||||
|
||||
$count += static::contentCount( $child, $includeItems, $includeComments, $includeReviews, $childDepth );
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
@@ -2016,13 +2008,15 @@ class _Records extends \IPS\Content\Item implements
|
||||
$category->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resync last comment
|
||||
*
|
||||
* @param Comment|null $comment The comment
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function resyncLastComment()
|
||||
public function resyncLastComment( \IPS\Content\Comment $comment = NULL )
|
||||
{
|
||||
if ( $this->useForumComments() )
|
||||
{
|
||||
@@ -2056,7 +2050,7 @@ class _Records extends \IPS\Content\Item implements
|
||||
if ( $setCategory and $this->category_id )
|
||||
{
|
||||
$class = '\IPS\cms\Categories' . static::$customDatabaseId;
|
||||
$class::load( $this->category_id )->setLastComment( NULL );
|
||||
$class::load( $this->category_id )->setLastComment( $comment );
|
||||
$class::load( $this->category_id )->save();
|
||||
}
|
||||
}
|
||||
@@ -2594,8 +2588,9 @@ class _Records extends \IPS\Content\Item implements
|
||||
catch( \Exception $ex ) { }
|
||||
|
||||
/* Try again */
|
||||
/** @var \IPS\forums\Topic $topic */
|
||||
$topic = $this->topic( FALSE );
|
||||
if ( ! $topic )
|
||||
if ( ! $topic or $topic->isArchived() )
|
||||
{
|
||||
return parent::processCommentForm( $values );
|
||||
}
|
||||
@@ -2923,6 +2918,11 @@ class _Records extends \IPS\Content\Item implements
|
||||
$topic->save();
|
||||
$firstPost = $topic->comments( 1 );
|
||||
|
||||
if( !$firstPost )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$content = \IPS\Theme::i()->getTemplate( 'submit', 'cms', 'front' )->topic( $this );
|
||||
\IPS\Member::loggedIn()->language()->parseOutputForDisplay( $content );
|
||||
|
||||
@@ -3060,37 +3060,46 @@ class _Records extends \IPS\Content\Item implements
|
||||
{
|
||||
if ( $this->recordCommentPageCount === NULL or $recache === TRUE )
|
||||
{
|
||||
if ( $this->useForumComments() )
|
||||
{
|
||||
try
|
||||
{
|
||||
$topic = $this->topic();
|
||||
|
||||
if( $topic !== NULL )
|
||||
{
|
||||
/* Store the real count so it is not accidentally written as the actual value */
|
||||
$realCount = $topic->posts;
|
||||
|
||||
/* Compensate for the first post (which is actually the record) */
|
||||
$topic->posts = ( $topic->posts - 1 ) > 0 ? $topic->posts - 1 : 0;
|
||||
|
||||
/* Get our page count considering all of that */
|
||||
$this->recordCommentPageCount = $topic->commentPageCount();
|
||||
|
||||
/* Reset the count back to the real count */
|
||||
$topic->posts = $realCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->recordCommentPageCount = 1;
|
||||
}
|
||||
}
|
||||
catch( \Exception $e ) { }
|
||||
}
|
||||
else
|
||||
/* If the database has a custom per page set, use that. */
|
||||
if ( static::database()->comments_perpage )
|
||||
{
|
||||
$this->recordCommentPageCount = parent::commentPageCount( $recache );
|
||||
}
|
||||
/* Otherwise do the normal stuff */
|
||||
else
|
||||
{
|
||||
if ( $this->useForumComments() )
|
||||
{
|
||||
try
|
||||
{
|
||||
$topic = $this->topic();
|
||||
|
||||
if( $topic !== NULL )
|
||||
{
|
||||
/* Store the real count so it is not accidentally written as the actual value */
|
||||
$realCount = $topic->posts;
|
||||
|
||||
/* Compensate for the first post (which is actually the record) */
|
||||
$topic->posts = ( $topic->posts - 1 ) > 0 ? $topic->posts - 1 : 0;
|
||||
|
||||
/* Get our page count considering all of that */
|
||||
$this->recordCommentPageCount = $topic->commentPageCount();
|
||||
|
||||
/* Reset the count back to the real count */
|
||||
$topic->posts = $realCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->recordCommentPageCount = 1;
|
||||
}
|
||||
}
|
||||
catch( \Exception $e ) { }
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->recordCommentPageCount = parent::commentPageCount( $recache );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->recordCommentPageCount;
|
||||
@@ -3232,6 +3241,25 @@ class _Records extends \IPS\Content\Item implements
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the club of this record's container if there is one
|
||||
*
|
||||
* @return \IPS\Member\Club|null
|
||||
*/
|
||||
public function get_club() : \IPS\Member\Club|null
|
||||
{
|
||||
static $club = false;
|
||||
if ( $club !== null and !( $club instanceof \IPS\Member\Club ) )
|
||||
{
|
||||
$club = null;
|
||||
if ( $container = $this->container() and $container instanceof \IPS\cms\Categories )
|
||||
{
|
||||
$club = $container->_club;
|
||||
}
|
||||
}
|
||||
return $club;
|
||||
}
|
||||
|
||||
/**
|
||||
* Could edit an item?
|
||||
* Useful to see if one can edit something even if the cut off has expired
|
||||
@@ -3378,6 +3406,46 @@ class _Records extends \IPS\Content\Item implements
|
||||
return $member->canAccessModule( \IPS\Application\Module::get( static::$application, 'database', 'front' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Can a given member create this type of content?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param \IPS\Node\Model|NULL $container Container (e.g. forum), if appropriate
|
||||
* @param bool $showError If TRUE, rather than returning a boolean value, will display an error
|
||||
* @return bool
|
||||
*/
|
||||
public static function canCreate( \IPS\Member $member, \IPS\Node\Model $container=NULL, $showError=FALSE )
|
||||
{
|
||||
$return = parent::canCreate( $member, $container, $showError );
|
||||
|
||||
if( $return )
|
||||
{
|
||||
|
||||
/* Check for title and content field permissions */
|
||||
try
|
||||
{
|
||||
$class = '\IPS\cms\Fields' . static::database()->id;
|
||||
$title = $class::load( static::database()->field_title );
|
||||
$content = $class::load( static::database()->field_content );
|
||||
$return = $title->can( 'add', $member ) and $content->can( 'add', $member );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
$return = FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Return */
|
||||
if ( $showError and !$return )
|
||||
{
|
||||
$error = 'cms_no_title_content_permission';
|
||||
\IPS\Output::i()->error( $error, '2C137/3', 403 );
|
||||
}
|
||||
|
||||
return (bool) $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Already reviewed?
|
||||
*
|
||||
@@ -3813,7 +3881,7 @@ class _Records extends \IPS\Content\Item implements
|
||||
* @apiresponse string description Event description
|
||||
* @apiresponse int comments Number of comments
|
||||
* @apiresponse int reviews Number of reviews
|
||||
* @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 bool locked Event is locked
|
||||
|
||||
Reference in new issue
Block a user