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

+81 -20
View File
@@ -11,7 +11,7 @@
namespace IPS\core\Statuses;
/* 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;
@@ -346,28 +346,66 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\Lockable, \IPS\C
unset( $formElements['title'] );
$member = isset( \IPS\Request::i()->id ) ? \IPS\Member::load( \IPS\Request::i()->id ) : \IPS\Member::loggedIn();
if ( $fromCreateMenu )
{
$minimize = NULL;
}
else
{
$member = isset( \IPS\Request::i()->id ) ? \IPS\Member::load( \IPS\Request::i()->id ) : \IPS\Member::loggedIn();
$minimize = ( $member->member_id != \IPS\Member::loggedIn()->member_id ) ?
\IPS\Member::loggedIn()->language()->addToStack( static::$formLangPrefix . '_update_placeholder_other', FALSE, array( 'sprintf' => array( $member->name ) ) ) :
static::$formLangPrefix . '_update_placeholder';
}
$formElements['status_content'] = new \IPS\Helpers\Form\Editor( static::$formLangPrefix . 'content' . ( $fromCreateMenu ? '_ajax' : '' ), ( $item ) ? $item->content : NULL, TRUE, array(
$editorName = static::$formLangPrefix . 'content' . ( $fromCreateMenu ? '_ajax' : '' );
if( $item !== NULL )
{
$editorName .= '_' . $item->id;
}
$formElements['status_content'] = new \IPS\Helpers\Form\Editor( $editorName, ( $item ) ? $item->content : NULL, TRUE, array(
'app' => static::$application,
'key' => 'Members',
'autoSaveKey' => 'status',
'autoSaveKey' => 'status' . $member->member_id . ( ( $item !== NULL ) ? '_' . $item->id : '' ),
'minimize' => $minimize,
'maxLength' => 65535,
'attachIds' => ( $item === NULL ) ? NULL : array( $item->id, NULL, $item->member_id )
), '\IPS\Helpers\Form::floodCheck' );
return $formElements;
}
/**
* Add the comment form elements
*
* @return array
*/
public function commentFormElements()
{
$formElements = parent::commentFormElements();
$idColumn = static::$databaseColumnId;
$submitted = 'commentform' . '_' . $this->$idColumn . '_submitted';
$self = $this;
$editorField = new \IPS\Helpers\Form\Editor( static::$formLangPrefix . 'comment' . '_' . $this->$idColumn, NULL, TRUE, array(
'app' => static::$application,
'key' => mb_ucfirst( static::$module ),
'maxLength' => 65535,
'autoSaveKey' => 'reply-' . static::$application . '/' . static::$module . '-' . $this->$idColumn,
'minimize' => isset( \IPS\Request::i()->$submitted ) ? NULL : static::$formLangPrefix . '_comment_placeholder'
), function() use( $self ) {
if ( !$self->mergeConcurrentComment() )
{
\IPS\Helpers\Form::floodCheck();
}
} );
$formElements['editor'] = $editorField;
return $formElements;
}
/**
* Create from form
@@ -381,7 +419,7 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\Lockable, \IPS\C
{
/* Create */
$status = parent::createFromForm( $values, $container, $sendNotification );
\IPS\File::claimAttachments( 'status', $status->id );
\IPS\File::claimAttachments( 'status', $status->id, NULL, $status->member_id );
/* Return */
return $status;
@@ -401,12 +439,19 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\Lockable, \IPS\C
/* @todo The dependency on \IPS\Request here needs to be moved to the controller */
$this->member_id = ( isset( \IPS\Request::i()->id ) AND ( isset( \IPS\Request::i()->controller ) AND \IPS\Request::i()->controller != 'ajaxcreate' ) ) ? \IPS\Request::i()->id : \IPS\Member::loggedIn()->member_id;
/* If we are editing, store the old content in memory */
$oldContent = NULL;
if ( !$this->_new )
{
$oldContent = $this->content;
}
$this->content = $values['status_content'];
if ( !$this->_new )
/* Set the content and check to make sure it passes any profanity filters */
$this->content = $this->id ? $values['status_content_' . $this->id ] : $values['status_content'];
$sendFilterNotifications = $this->checkProfanityFilters( FALSE, $this->_new, NULL, FALSE );
/* If this is an edit, and $sendFilterNotifications is FALSE, send after edit notifications */
if ( !$this->_new AND $sendFilterNotifications === FALSE )
{
$this->sendAfterEditNotifications( $oldContent );
}
@@ -452,14 +497,15 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\Lockable, \IPS\C
return $return;
}
/**
/**
* Get URL from index data
*
* @param array $indexData Data from the search index
* @param array $itemData Basic data about the item. Only includes columns returned by item::basicDataColumns()
* @param string|NULL $action Action
* @return \IPS\Http\Url
*/
public static function urlFromIndexData( $indexData, $itemData )
public static function urlFromIndexData( $indexData, $itemData, $action = NULL )
{
return \IPS\Http\Url::internal( "app=core&module=members&controller=profile&id={$indexData['index_author']}&status={$indexData['index_item_id']}&type=status", 'front', 'profile', array( $itemData['author']['members_seo_name'] ) );
}
@@ -489,7 +535,7 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\Lockable, \IPS\C
$notification = new \IPS\Notification( \IPS\Application::load( 'core' ), 'new_status', $this, array( $this ) );
$followers = \IPS\Member::load( $this->member_id )->followers( 3, array( 'immediate' ), $this->mapped('date'), NULL );
if( count( $followers ) )
if( $followers !== NULL and \count( $followers ) )
{
foreach( $followers AS $follower )
{
@@ -500,33 +546,45 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\Lockable, \IPS\C
$notification->send( $sentTo );
}
}
/**
* Disable merging of concurrent comments - Our front-end code does not handle this
*
* @return \IPS\Content\Comment|NULL
*/
public function mergeConcurrentComment()
{
return NULL;
}
/**
* Should new items be moderated?
*
* @param \IPS\Member $member The member posting
* @param \IPS\Node\Model $container The container
* @param \IPS\Member $member The member posting
* @param \IPS\Node\Model $container The container
* @param bool $considerPostBeforeRegistering If TRUE, and $member is a guest, will check if a newly registered member would be moderated
* @return bool
*/
public static function moderateNewItems( \IPS\Member $member, \IPS\Node\Model $container = NULL )
public static function moderateNewItems( \IPS\Member $member, \IPS\Node\Model $container = NULL, $considerPostBeforeRegistering = FALSE )
{
if ( $member->moderateNewContent() or \IPS\Settings::i()->profile_comment_approval )
{
return !static::modPermission( 'approve', $member, $container );
}
return parent::moderateNewItems( $member, $container );
return parent::moderateNewItems( $member, $container, $considerPostBeforeRegistering );
}
/**
* Should new comments be moderated?
*
* @param \IPS\Member $member The member posting
* @param \IPS\Member $member The member posting
* @param bool $considerPostBeforeRegistering If TRUE, and $member is a guest, will check if a newly registered member would be moderated
* @return bool
*/
public function moderateNewComments( \IPS\Member $member )
public function moderateNewComments( \IPS\Member $member, $considerPostBeforeRegistering = FALSE )
{
return ( $member->moderateNewContent() or \IPS\Settings::i()->profile_comment_approval );
return ( $member->moderateNewContent( $considerPostBeforeRegistering ) or \IPS\Settings::i()->profile_comment_approval );
}
/**
@@ -569,7 +627,6 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\Lockable, \IPS\C
$idColumn = static::$databaseColumnId;
$class = static::$commentClass;
$authorCol = $class::$databasePrefix . $class::$databaseColumnMap['author'];
$where = array( array( $class::$databasePrefix . $class::$databaseColumnMap['item'] . '=?', $this->$idColumn ) );
if ( isset( static::$databaseColumnMap['hidden_comments'] ) )
{
@@ -577,6 +634,8 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\Lockable, \IPS\C
}
else
{
$where = array( array( $class::$databasePrefix . $class::$databaseColumnMap['item'] . '=?', $this->$idColumn ) );
if ( isset( $class::$databaseColumnMap['approved'] ) )
{
$col = $class::$databasePrefix . $class::$databaseColumnMap['approved'];
@@ -596,6 +655,8 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\Lockable, \IPS\C
}
else
{
$where = array( array( $class::$databasePrefix . $class::$databaseColumnMap['item'] . '=?', $this->$idColumn ) );
if ( isset( $class::$databaseColumnMap['approved'] ) )
{
$col = $class::$databasePrefix . $class::$databaseColumnMap['approved'];
@@ -632,7 +693,7 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\Lockable, \IPS\C
{
/* Work out what page we're looking at, but only if we are actually paginating through comments */
/* @future we should probably remove the dependancy on \IPS\Request::i()->page here, as the status may be display on a page that isn't necessarily the profile (ex: My Activity) */
$page = ( isset( \IPS\Request::i()->page ) AND isset( \IPS\Request::i()->status ) ) ? intval( \IPS\Request::i()->page ) : 1;
$page = ( isset( \IPS\Request::i()->page ) AND isset( \IPS\Request::i()->status ) ) ? \intval( \IPS\Request::i()->page ) : 1;
if( $page < 1 )
{
$page = 1;