Version 4.7.0
This commit is contained in:
1 parent
517a5e1f70
commit
8ba7d43898
1933 files changed
+65613
-11332
No files matched your search
@@ -339,6 +339,23 @@ class _ItemController extends \IPS\Api\Controller
|
||||
}
|
||||
}
|
||||
|
||||
/** We intentionally allow anonymous content in nodes where it's possible (but where it's disabled via the settings */
|
||||
if( isset( \IPS\Request::i()->anonymous ) AND \in_array( 'IPS\Content\Anonymous', class_implements( \get_class( $item ) ) ) )
|
||||
{
|
||||
/* we need to save the item before we set the anonymous data */
|
||||
$idColumn = $item::$databaseColumnId;
|
||||
if ( !$item->$idColumn )
|
||||
{
|
||||
$item->save();
|
||||
}
|
||||
try
|
||||
{
|
||||
$item->setAnonymous( (bool) \IPS\Request::i()->anonymous, $item->author() );
|
||||
}
|
||||
catch ( \BadMethodCallException $e ){}
|
||||
|
||||
}
|
||||
|
||||
/* Update first comment if required, and it's not a new item */
|
||||
$field = isset( $item::$databaseColumnMap['first_comment_id'] ) ? $item::$databaseColumnMap['first_comment_id'] : NULL;
|
||||
$commentClass = $item::$commentClass;
|
||||
@@ -392,9 +409,10 @@ class _ItemController extends \IPS\Api\Controller
|
||||
|
||||
/* Create item */
|
||||
$item = $class::createItem( $author, ( !$this->member and \IPS\Request::i()->ip_address ) ? \IPS\Request::i()->ip_address : \IPS\Request::i()->ipAddress(), $date, $container );
|
||||
|
||||
$this->_createOrUpdate( $item, 'add' );
|
||||
$item->save();
|
||||
|
||||
|
||||
/* Create post */
|
||||
if ( $class::$firstCommentRequired )
|
||||
{
|
||||
@@ -404,9 +422,9 @@ class _ItemController extends \IPS\Api\Controller
|
||||
{
|
||||
$postContents = \IPS\Text\Parser::parseStatic( $postContents, TRUE, NULL, $this->member, $class::$application . '_' . mb_ucfirst( $class::$module ) );
|
||||
}
|
||||
|
||||
|
||||
$commentClass = $item::$commentClass;
|
||||
$post = $commentClass::create( $item, $postContents, TRUE, $author->member_id ? NULL : $author->real_name, NULL, $author, $date, ( !$this->member and \IPS\Request::i()->ip_address ) ? \IPS\Request::i()->ip_address : \IPS\Request::i()->ipAddress() );
|
||||
$post = $commentClass::create( $item, $postContents, TRUE, $author->member_id ? NULL : $author->real_name, NULL, $author, $date, ( !$this->member and \IPS\Request::i()->ip_address ) ? \IPS\Request::i()->ip_address : \IPS\Request::i()->ipAddress(), NULL, ( isset( \IPS\Request::i()->anonymous ) ? (bool) \IPS\Request::i()->anonymous : NULL ) );
|
||||
|
||||
if ( isset( $class::$databaseColumnMap['first_comment_id'] ) )
|
||||
{
|
||||
@@ -516,21 +534,24 @@ class _ItemController extends \IPS\Api\Controller
|
||||
}
|
||||
$itemIdColumn = $itemClass::$databaseColumnId;
|
||||
$where [] = array( $commentClass::$databasePrefix . $commentClass::$databaseColumnMap['item'] . '=?', $item->$itemIdColumn );
|
||||
|
||||
/* Hidden? */
|
||||
if ( isset( \IPS\Request::i()->hidden ) AND \in_array( 'IPS\Content\Hideable', class_implements( $commentClass ) ) )
|
||||
|
||||
/* Hideable? */
|
||||
if ( \in_array( 'IPS\Content\Hideable', class_implements( $commentClass ) ) )
|
||||
{
|
||||
if ( \IPS\Request::i()->hidden )
|
||||
/* If request for hidden comments, only show if request is via API key or by a moderator */
|
||||
if ( isset( \IPS\Request::i()->hidden ) AND \IPS\Request::i()->hidden
|
||||
AND ( $this->member === NULL OR $commentClass::modPermission( 'view_hidden', $this->member ) ) )
|
||||
{
|
||||
if ( isset( $commentClass::$databaseColumnMap['hidden'] ) )
|
||||
{
|
||||
$where[] = array( $commentClass::$databasePrefix . $commentClass::$databaseColumnMap['hidden'] . '<>0' );
|
||||
$where[] = array( $commentClass::$databasePrefix . $commentClass::$databaseColumnMap['hidden'] . ' NOT IN( -3, -2 )' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where[] = array( $commentClass::$databasePrefix . $commentClass::$databaseColumnMap['approved'] . '<>1' );
|
||||
$where[] = array( $commentClass::$databasePrefix . $commentClass::$databaseColumnMap['approved'] . ' NOT IN( -3, -2 )' );
|
||||
}
|
||||
}
|
||||
/* Do not show hidden comments */
|
||||
else
|
||||
{
|
||||
if ( isset( $commentClass::$databaseColumnMap['hidden'] ) )
|
||||
|
||||
Reference in new issue
Block a user