Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

+23 -61
View File
@@ -11,7 +11,7 @@
namespace IPS\Content;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -49,12 +49,12 @@ abstract class _Review extends \IPS\Content\Comment
*/
public static function create( $item, $comment, $first=FALSE, $rating=NULL, $guestName=NULL, $member=NULL, \IPS\DateTime $time=NULL, $ipAddress=NULL, $hiddenStatus=NULL )
{
if ( !is_int( $rating ) or $rating < 1 or $rating > intval( \IPS\Settings::i()->reviews_rating_out_of ) )
if ( !\is_int( $rating ) or $rating < 1 or $rating > \intval( \IPS\Settings::i()->reviews_rating_out_of ) )
{
throw new \InvalidArgumentException;
}
$obj = parent::create( $item, $comment, $first, $guestName, NULL, $member, $time, $ipAddress );
$obj = parent::create( $item, $comment, $first, $guestName, NULL, $member, $time, $ipAddress, $hiddenStatus );
foreach ( array( 'rating', 'votes_data' ) as $k )
{
@@ -72,14 +72,14 @@ abstract class _Review extends \IPS\Content\Comment
break;
}
foreach ( is_array( static::$databaseColumnMap[ $k ] ) ? static::$databaseColumnMap[ $k ] : array( static::$databaseColumnMap[ $k ] ) as $column )
foreach ( \is_array( static::$databaseColumnMap[ $k ] ) ? static::$databaseColumnMap[ $k ] : array( static::$databaseColumnMap[ $k ] ) as $column )
{
$obj->$column = $val;
}
}
}
if( $obj->author()->member_id )
if( $obj->author()->member_id AND $obj::incrementPostCount() )
{
$obj->author()->member_last_post = time();
$obj->author()->save();
@@ -120,7 +120,7 @@ abstract class _Review extends \IPS\Content\Comment
if ( isset( $item::$databaseColumnMap['last_review'] ) )
{
$lastReviewField = $item::$databaseColumnMap['last_review'];
if ( is_array( $lastReviewField ) )
if ( \is_array( $lastReviewField ) )
{
foreach ( $lastReviewField as $column )
{
@@ -173,9 +173,9 @@ abstract class _Review extends \IPS\Content\Comment
}
/**
* @brief Cached URLs
* @brief Value to set for the 'tab' parameter when redirecting to the comment (via _find())
*/
protected $_url = array();
public static $tabParameter = array( 'tab' => 'reviews' );
/**
* Get URL
@@ -183,55 +183,14 @@ abstract class _Review extends \IPS\Content\Comment
* @param string|NULL $action Action
* @return \IPS\Http\Url
*/
public function url( $action=NULL )
public function url( $action='find' )
{
$_key = md5( $action );
$idColumn = static::$databaseColumnId;
if( !isset( $this->_url[ $_key ] ) )
{
$itemClass = static::$itemClass;
$itemField = static::$databaseColumnMap['item'];
$idColumn = static::$databaseColumnId;
$this->_url[ $_key ] = $this->item()->url();
if( $action )
{
$this->_url[ $_key ] = $this->_url[ $_key ]->setQueryString( array( 'do' => $action . 'Review', 'review' => $this->$idColumn ) );
}
else
{
$where = array( array( static::$databasePrefix . static::$databaseColumnMap['item'] . '=? AND ' . static::$databasePrefix . static::$databaseColumnId . '<=?', $this->$itemField, $this->$idColumn ) );
if ( static::commentWhere() !== NULL )
{
$where[] = static::commentWhere();
}
if ( static::modPermission( 'view_hidden' ) === FALSE )
{
if ( isset( static::$databaseColumnMap['approved'] ) )
{
$where[] = array( static::$databasePrefix . static::$databaseColumnMap['approved'] . '=?', 1 );
}
elseif( isset( static::$databaseColumnMap['hidden'] ) )
{
$where[] = array( static::$databasePrefix . static::$databaseColumnMap['hidden'] . '=?', 0 );
}
}
$commentPosition = \IPS\Db::i()->select( 'COUNT(*) AS position', static::$databaseTable, $where )->first();
$page = ceil( $commentPosition / $itemClass::$reviewsPerPage );
if ( $page != 1 )
{
$this->_url[ $_key ] = $this->_url[ $_key ]->setQueryString( 'page', $page );
}
$this->_url[ $_key ] = $this->_url[ $_key ]->setFragment( 'review-' . $this->$idColumn );
}
}
return $this->_url[ $_key ];
return $this->item()->url()->setQueryString( array(
'do' => $action . 'Review',
'review' => $this->$idColumn
) );
}
/**
@@ -328,7 +287,10 @@ abstract class _Review extends \IPS\Content\Comment
else if ( isset( $item::$databaseColumnMap['hidden_reviews'] ) )
{
$column = $item::$databaseColumnMap['hidden_reviews'];
$item->$column = $item->mapped('hidden_reviews') - 1;
if ( $item->mapped('hidden_reviews') > 0 )
{
$item->$column = $item->mapped('hidden_reviews') - 1;
}
}
if ( isset( $item::$databaseColumnMap['num_reviews'] ) )
@@ -467,7 +429,7 @@ abstract class _Review extends \IPS\Content\Comment
'rating' => $this->mapped('rating'),
'votesTotal' => $this->mapped('votes_total'),
'votesHelpful' => $this->mapped('votes_helpful'),
'content' => $this->content(),
'content' => \IPS\Text\Parser::removeLazyLoad( $this->content() ),
'hidden' => (bool) $this->hidden(),
'url' => (string) $this->url(),
'authorResponse' => $this->mapped('author_response')
@@ -496,7 +458,7 @@ abstract class _Review extends \IPS\Content\Comment
*/
public function hasAuthorResponse()
{
return !is_null( $this->mapped('author_response') );
return !\is_null( $this->mapped('author_response') );
}
/**
@@ -514,7 +476,7 @@ abstract class _Review extends \IPS\Content\Comment
if( !$this->hasAuthorResponse() )
{
/* ...and we are the author of the content item... */
if( $member->member_id == $this->item()->author()->member_id )
if( $member->member_id and $member->member_id == $this->item()->author()->member_id )
{
/* ...then we can respond to this review. */
return TRUE;
@@ -546,7 +508,7 @@ abstract class _Review extends \IPS\Content\Comment
}
/* Or maybe the member can edit their own content? */
if ( $member->member_id == $item->author()->member_id and ( $member->group['g_edit_posts'] == '1' or in_array( get_class( $item ), explode( ',', $member->group['g_edit_posts'] ) ) ) and ( !( $item instanceof \IPS\Content\Lockable ) or !$item->locked() ) )
if ( $member->member_id and $member->member_id == $item->author()->member_id and ( $member->group['g_edit_posts'] == '1' or \in_array( \get_class( $item ), explode( ',', $member->group['g_edit_posts'] ) ) ) and ( !( $item instanceof \IPS\Content\Lockable ) or !$item->locked() ) )
{
return TRUE;
}
@@ -584,7 +546,7 @@ abstract class _Review extends \IPS\Content\Comment
}
/* Or maybe the author can delete their own content? */
if( $member->member_id and $member->member_id == $this->item()->author()->member_id and ( $member->group['g_delete_own_posts'] == '1' or in_array( get_class( $this->item() ), explode( ',', $member->group['g_delete_own_posts'] ) ) ) )
if( $member->member_id and $member->member_id == $this->item()->author()->member_id and ( $member->group['g_delete_own_posts'] == '1' or \in_array( \get_class( $this->item() ), explode( ',', $member->group['g_delete_own_posts'] ) ) ) )
{
return TRUE;
}