Version 4.6.0

This commit is contained in:
Neo committed 2025-12-19 05:55:31 -08:00
1 parent f79dcf067a
commit 517a5e1f70
2036 files changed
+110041 -26162

No files matched your search

+141 -132
View File
@@ -104,7 +104,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
if ( \in_array( 'IPS\Content\Views', class_implements( $class ) ) AND isset( $class::$databaseColumnMap['views'] ) )
{
$countUpdated = false;
if ( \IPS\REDIS_ENABLED and \IPS\CACHE_METHOD == 'Redis' and \IPS\CACHE_CONFIG )
if ( \IPS\REDIS_ENABLED and \IPS\CACHE_METHOD == 'Redis' and ( \IPS\CACHE_CONFIG or \IPS\REDIS_CONFIG ) )
{
try
{
@@ -206,7 +206,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
if ( \in_array( 'IPS\Content\Views', class_implements( $class ) ) AND isset( $class::$databaseColumnMap['views'] ) )
{
$countUpdated = false;
if ( \IPS\REDIS_ENABLED and \IPS\CACHE_METHOD == 'Redis' and \IPS\CACHE_CONFIG )
if ( \IPS\REDIS_ENABLED and \IPS\CACHE_METHOD == 'Redis' and ( \IPS\CACHE_CONFIG or \IPS\REDIS_CONFIG ) )
{
try
{
@@ -243,7 +243,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
/* Set meta tags */
\IPS\Output::i()->linkTags['canonical'] = (string) ( \IPS\Request::i()->page > 1 ) ? $item->url()->setPage( 'page', \IPS\Request::i()->page ) : $item->url() ;
\IPS\Output::i()->metaTags['og:title'] = $item->mapped( 'title' );
\IPS\Output::i()->metaTags['og:type'] = 'object';
\IPS\Output::i()->metaTags['og:type'] = 'website';
\IPS\Output::i()->metaTags['og:url'] = (string) $item->url();
/* Do not set description tags for page 2+ as you end up with duplicate tags */
@@ -300,10 +300,15 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
/* Return */
return $item;
}
catch ( \LogicException $e )
{
try
{
\IPS\Output::i()->redirect( $class::getRedirectFrom( \IPS\Request::i()->id )->url(), '', 301 );
}
catch( \OutOfRangeException $e ) { }
return NULL;
}
}
@@ -378,6 +383,13 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
/* We will fetch up to 200 comments - anything over this is excessive */
$newComments = $item->comments( 200, 0, 'date', 'asc', NULL, NULL, \IPS\DateTime::ts( $lastComment->$commentDateColumn ), array_merge( $where, array( "{$authorColumn} != " . \IPS\Member::loggedIn()->member_id ) ) );
/* Get the next to last comment for the spillover link as PMs do not support read markers */
$nextLastComment = NULL;
if( \count( $newComments ) )
{
$nextLastComment = reset( $newComments );
}
if ( \IPS\Request::i()->type === 'count' )
{
$data = array(
@@ -386,7 +398,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
'perPage' => $class::getCommentsPerPage(),
'totalCount' => $item->mapped( 'num_comments' ),
'title' => $item->mapped( 'title' ) ,
'spillOverUrl' => $item->url( 'getNewComment' )
'spillOverUrl' => ( $nextLastComment ) ? $nextLastComment->url() : $item->url(),
);
if( $data['count'] === 1 ){
@@ -423,7 +435,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
'totalCount' => $item->mapped( 'num_comments' ),
'totalNewCount' => (int) \count( $newComments ),
'perPage' => $class::getCommentsPerPage(),
'spillOverUrl' => $item->url( 'getNewComment' )
'spillOverUrl' => ( $nextLastComment ) ? $nextLastComment->url() : $item->url()
) );
}
catch ( \Exception $e )
@@ -545,7 +557,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
*/
protected function getEditForm( $form )
{
return $form;
return $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
}
/**
@@ -1032,7 +1044,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
/* Mark it as read */
if( $item instanceof \IPS\Content\ReadMarkers and $unread == 0 )
{
$item->markRead();
$item->markRead( NULL, NULL, NULL, TRUE );
}
\IPS\Session::i()->modLog( 'modlog__action_move', array( $item::$title => TRUE, $item->url()->__toString() => FALSE, $item->mapped( 'title' ) ?: ( method_exists( $item, 'item' ) ? $item->item()->mapped( 'title' ) : NULL ) => FALSE ), $item );
@@ -1217,7 +1229,11 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
$form->add( new \IPS\Helpers\Form\Radio( 'report_type', NULL, FALSE, array( 'options' => $options ) ) );
}
$form->add( new \IPS\Helpers\Form\Editor( 'report_message', NULL, FALSE, array( 'app' => 'core', 'key' => 'Reports', 'autoSaveKey' => "report-{$class::$application}-{$class::$module}-{$item->$idColumn}", 'minimize' => 'report_message_placeholder' ) ) );
$form->add( new \IPS\Helpers\Form\Editor( 'report_message', NULL, FALSE, array( 'app' => 'core', 'key' => 'Reports', 'autoSaveKey' => "report-{$class::$application}-{$class::$module}-{$item->$idColumn}", 'minimize' => \IPS\Request::i()->isAjax() ? 'report_message_placeholder' : NULL ) ) );
if ( !\IPS\Request::i()->isAjax() )
{
\IPS\Member::loggedIn()->language()->words['report_message'] = \IPS\Member::loggedIn()->language()->addToStack('report_message_fallback');
}
if( !\IPS\Member::loggedIn()->member_id )
{
@@ -1242,7 +1258,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
/* Even if guests can report something, we don't want the report form indexed in Google */
\IPS\Output::i()->metaTags['robots'] = 'noindex';
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
\IPS\Output::i()->output = \IPS\Request::i()->isAjax() ? $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) ) : \IPS\Theme::i()->getTemplate( 'system', 'core' )->reportForm( $form );
}
catch ( \LogicException $e )
{
@@ -1308,7 +1324,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
\IPS\Output::i()->redirect( $item->url() );
}
}
catch( \DomainException $e )
catch( \OutOfRangeException | \DomainException $e )
{
if ( \IPS\Request::i()->isAjax() )
{
@@ -2011,14 +2027,6 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
$item->toggleSolveComment( \IPS\Request::i()->answer, TRUE );
if( $comment->author()->member_id != \IPS\Member::loggedIn()->member_id )
{
$notification = new \IPS\Notification( \IPS\Application::load( 'core' ), 'best_answer', $item, array( $comment ), array( $comment->author()->member_id ) );
$notification->recipients->attach( $comment->author() );
$notification->send();
}
/* Log */
if ( \IPS\Member::loggedIn()->modPermission('can_set_best_answer') )
{
@@ -2106,17 +2114,19 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
if ( $item->itemModerationEnabled() )
{
$action = 'disable';
$actionLang = 'disabled';
}
else
{
$action = 'enable';
$actionLang = 'enabled';
}
$item->toggleItemModeration( $action );
\IPS\Session::i()->modLog( 'modlog__item_moderation_toggled', [$action => FALSE], $item );
\IPS\Session::i()->modLog( 'modlog__item_moderation_toggled', [$actionLang => TRUE], $item );
\IPS\Output::i()->redirect( $item->url(), ( $item->itemModerationEnabled() ) ? 'enabled' : 'disabled' );
\IPS\Output::i()->redirect( $item->url(), $actionLang );
}
catch( \OutOfRangeException $e )
{
@@ -2296,11 +2306,11 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
*/
public function _hide( $commentClass, $comment, $item )
{
\IPS\Session::i()->csrfCheck();
/* If this is an AJAX request, and we're coming from the approval queue, just do it. */
if ( \IPS\Request::i()->isAjax() AND isset( \IPS\Request::i()->_fromApproval ) )
{
\IPS\Session::i()->csrfCheck();
$comment->modAction( 'hide' );
\IPS\Output::i()->json( 'OK' );
}
@@ -2322,6 +2332,8 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
}
else
{
\IPS\Session::i()->csrfCheck();
$comment->modAction( 'hide' );
}
@@ -2368,10 +2380,20 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
if ( isset( \IPS\Request::i()->restoreAsHidden ) )
{
\IPS\Session::i()->modLog( 'modlog__action_restore_hidden', array(
$comment::$title => FALSE,
$comment->url()->__toString() => FALSE
) );
$comment->modAction( 'restoreAsHidden' );
}
else
{
\IPS\Session::i()->modLog( 'modlog__action_restore', array(
$comment::$title => FALSE,
$comment->url()->__toString() => FALSE
) );
$comment->modAction( 'restore' );
}
@@ -2427,6 +2449,13 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
'autoSaveKey' => 'editComment-' . $class::$application . '/' . $class::$module . '-' . $comment->$idField,
'attachIds' => $comment->attachmentIds()
) ) );
/* Post Anonymously */
$container = $item->containerWrapper();
if ( $container and $container->canPostAnonymously( $container::ANON_COMMENTS ) and $comment instanceof \IPS\Content\Anonymous and \IPS\Member::loggedIn()->member_id and \IPS\Member::loggedIn()->group['gbw_can_post_anonymously'] )
{
$form->add ( new \IPS\Helpers\Form\YesNo( 'post_anonymously', $comment->isAnonymous(), FALSE, array( 'label' => \IPS\Member::loggedIn()->language()->addToStack( 'post_anonymously_suffix' ) ), NULL, NULL, NULL, 'post_anonymously' ) );
}
$form->addButton( 'save', 'submit', null, 'ipsButton ipsButton_medium ipsButton_primary ipsButton_fullWidth', array( 'tabindex' => '2', 'accesskey' => 's' ) );
@@ -2516,6 +2545,12 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
$comment->editRating( $values['rating_value'] );
}
/* Anonymous posting */
if( isset( $values[ 'post_anonymously' ] ) )
{
$comment->setAnonymous( $values[ 'post_anonymously' ] );
}
/* Moderator log */
\IPS\Session::i()->modLog( 'modlog__comment_edit', array( $comment->url()->__toString() => FALSE, $item::$title => TRUE, $item->url()->__toString() => FALSE, $item->mapped( 'title' ) => FALSE ), $item );
@@ -2567,57 +2602,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
/* If we are retaining content for a period of time, we need to just hide it instead for deleting later - this only works, though, with items that implement \IPS\Content\Hideable */
if ( \IPS\Settings::i()->dellog_retention_period AND ( $item instanceof \IPS\Content\Hideable ) AND !isset( \IPS\Request::i()->immediately ) )
{
$log = new \IPS\core\DeletionLog;
$log->setContentAndMember( $item, \IPS\Member::loggedIn() );
$log->save();
if ( isset( $item::$databaseColumnMap['hidden'] ) )
{
$column = $item::$databaseColumnMap['hidden'];
}
else if ( isset( $item::$databaseColumnMap['approved'] ) )
{
$column = $item::$databaseColumnMap['approved'];
}
try
{
if ( $item->container() )
{
if ( $item->container()->_comments !== NULL )
{
/* Hidden content already decrements */
if ( !$item->hidden() )
{
$item->container()->_comments = ( $item->container()->_comments - $item->mapped('num_comments') );
}
}
if ( $item->container()->_unapprovedComments !== NULL )
{
$item->container()->_unapprovedComments = ( $item->container()->_unapprovedComments - $item->mapped( 'unapproved_comments' ) );
}
}
}
catch( \BadMethodCallException $e ) {}
$item->$column = -2;
$item->save();
try
{
if ( $item->container() )
{
$item->container()->setLastComment();
$this->container()->setLastReview();
$item->container()->save();
}
}
catch( \BadMethodCallException $e ) {}
}
else
{
$item->delete();
$item->logDelete();
}
}
else
@@ -2632,61 +2617,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
/* If we are retaining content for a period of time, we need to just hide it instead for deleting later - this only works, though, with items that implement \IPS\Content\Hideable */
if ( \IPS\Settings::i()->dellog_retention_period AND ( $item instanceof \IPS\Content\Hideable ) AND !isset( \IPS\Request::i()->immediately ) )
{
$log = new \IPS\core\DeletionLog;
$log->setContentAndMember( $comment, \IPS\Member::loggedIn() );
$log->save();
if ( isset( $comment::$databaseColumnMap['hidden'] ) )
{
$column = $comment::$databaseColumnMap['hidden'];
}
else if ( isset( $comment::$databaseColumnMap['approved'] ) )
{
$column = $comment::$databaseColumnMap['approved'];
}
try
{
if ( $comment->container() )
{
if ( $comment->container()->_comments !== NULL )
{
/* Hidden content already decrements */
if ( !$comment->hidden() )
{
$comment->container()->_comments = $comment->container()->_comments - 1;
}
}
}
}
catch( \BadMethodCallException $e ) {}
$comment->$column = -2;
$comment->save();
try
{
$comment->item()->rebuildFirstAndLastCommentData();
}
catch( \BadMethodCallException $e ) {}
/* Remove featured comment associations */
if( $comment->isFeatured() )
{
\IPS\Application::load('core')->extensions( 'core', 'MetaData' )['FeaturedComments']->unfeatureComment( $comment->item(), $comment );
}
/* Update solved status */
if ( \IPS\IPS::classUsesTrait( $item, 'IPS\Content\Solvable' ) and isset( $item::$databaseColumnMap['solved_comment_id'] ) )
{
/* Reset item */
$idColumn = $commentClass::$databaseColumnId;
$itemIdColumn = $item::$databaseColumnId;
if ( $item->mapped('solved_post_id') and $item->mapped('solved_post_id') == $comment->$idColumn )
{
\IPS\Db::i()->update( $item::$databaseTable, array( $item::$databaseColumnMap['solved_comment_id'] => 0 ), array( $itemIdColumn . '=?', $item->$itemIdColumn ) );
}
}
$comment->logDelete();
}
else
{
@@ -2952,6 +2883,11 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
}
$form->add( new \IPS\Helpers\Form\Editor( 'report_message', NULL, FALSE, array( 'app' => 'core', 'key' => 'Reports', 'autoSaveKey' => "report-{$class::$application}-{$class::$module}-{$item->$itemIdColumn}-{$comment->$idColumn}", 'minimize' => 'report_message_placeholder' ) ) );
if ( !\IPS\Request::i()->isAjax() )
{
\IPS\Member::loggedIn()->language()->words['report_message'] = \IPS\Member::loggedIn()->language()->addToStack('report_message_fallback');
}
if( !\IPS\Member::loggedIn()->member_id )
{
$form->add( new \IPS\Helpers\Form\Captcha );
@@ -2975,7 +2911,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
/* Even if guests can report something, we don't want the report form indexed in Google */
\IPS\Output::i()->metaTags['robots'] = 'noindex';
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
\IPS\Output::i()->output = \IPS\Request::i()->isAjax() ? $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) ) : \IPS\Theme::i()->getTemplate( 'system', 'core' )->reportForm( $form );
}
catch ( \LogicException $e )
{
@@ -3038,7 +2974,6 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
*/
protected function _feature( $commentClass, $comment, $item )
{
\IPS\Session::i()->csrfCheck();
if ( !$item->canFeatureComment() )
{
throw new \DomainException;
@@ -3611,6 +3546,15 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
}
catch( \Exception $e ) { }
}
$url = $item->url();
if ( isset( \IPS\Request::i()->page ) )
{
$url = $url->setPage( 'page', (int) \IPS\Request::i()->page );
}
\IPS\Output::i()->redirect( $url );
}
}
@@ -3836,7 +3780,8 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
'core_tags',
$where,
'tag_added DESC',
array( 0, $limit )
array( 0, $limit ),
array( 'tag_meta_app', 'tag_meta_area', 'tag_meta_id', 'tag_added' )
)->join(
'core_tags_perms',
array( 'tag_perm_aai_lookup=tag_aai_lookup' )
@@ -3926,4 +3871,68 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
return new \IPS\Helpers\CoverPhoto;
}
}
/**
* Reveal
*
* @return void
*/
protected function reveal()
{
\IPS\Session::i()->csrfCheck();
if( !\IPS\Member::loggedIn()->modPermission( 'can_view_anonymous_posters' ) )
{
\IPS\Output::i()->error( 'node_error', '2S136/1V', 403, '' );
}
$class = static::$contentModel;
$item = $class::loadAndCheckPerms( \IPS\Request::i()->id );
if( isset( \IPS\Request::i()->comment ) )
{
$class = $class::$commentClass;
$id = \IPS\Request::i()->comment;
}
else
{
$id = \IPS\Request::i()->id;
}
try
{
$anonymousAuthor = \IPS\Db::i()->select( 'anonymous_member_id', 'core_anonymous_posts', array( 'anonymous_object_class=? and anonymous_object_id=?', $class, $id ) )->first();
}
catch ( \UnderflowException $e )
{
\IPS\Output::i()->error( 'node_error', '2S136/1W', 403, '' );
}
$author = \IPS\Member::load( $anonymousAuthor );
$addWarningUrl = \IPS\Http\Url::internal( "app=core&module=system&controller=warnings&do=warn&id={$author->member_id}", 'front', 'warn_add', array( $author->members_seo_name ) );
if ( isset( \IPS\Request::i()->wr ) )
{
$addWarningUrl = $addWarningUrl->setQueryString( 'ref', \IPS\Request::i()->wr );
}
if( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'profile', 'core' )->hovercard( $author, $addWarningUrl );
}
else
{
\IPS\Output::i()->redirect( $author->url() );
}
}
/**
* Reveal Comment
*
* @return void
*/
protected function revealComment()
{
$this->reveal();
}
}