Version 4.7.6

This commit is contained in:
Neo committed 2025-12-19 16:05:19 -08:00
1 parent 8ba7d43898
commit 7b7404e741
1085 files changed
+30590 -7837

No files matched your search

+166 -18
View File
@@ -252,7 +252,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
/* Score by timestamp for trending */
\IPS\Redis::i()->zIncrBy( 'trending', time() * 0.1, $class .'__' . $item->$idColumn );
}
catch( \Exception $e ) {}
catch( \RedisException $e ) {}
}
if ( ! $countUpdated )
@@ -648,7 +648,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
catch ( \BadMethodCallException $e ) {}
/* Make sure we can edit and tag */
if ( ( !$item->canEdit() OR !$item::canTag( NULL, $container ) ) )
if ( !$item->canEdit() OR ( !$item::canTag( NULL, $container ) AND !\count( $item->tags() ) ) )
{
throw new \OutOfRangeException;
}
@@ -953,9 +953,15 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\Text( 'hide_reason' ) );
$this->moderationAlertField($form, $item);
if ( $values = $form->values() )
{
$item->modAction( \IPS\Request::i()->action, NULL, $values['hide_reason'] );
if( isset( $values['moderation_alert_content']) AND $values['moderation_alert_content'])
{
$this->sendModerationAlert($values, $item);
}
}
else
{
@@ -969,6 +975,30 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
}
else
{
if( \IPS\Request::i()->action === 'lock' )
{
if ( \IPS\Member::loggedIn()->modPermission('can_manage_alerts') AND $item->author()->member_id )
{
$form = new \IPS\Helpers\Form;
$this->moderationAlertField($form, $item);
$this->_setBreadcrumbAndTitle( $item );
if ( $values = $form->values() )
{
if( isset( $values['moderation_alert_content']) AND $values['moderation_alert_content'])
{
$this->sendModerationAlert($values, $item);
}
}
else
{
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
return;
}
}
}
$item->modAction( \IPS\Request::i()->action );
}
@@ -1076,6 +1106,8 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
},
'clubs' => TRUE
) ) );
$this->moderationAlertField( $form, $item);
if ( isset( $class::$databaseColumnMap['moved_to'] ) )
{
@@ -1107,6 +1139,10 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
{
$item->markRead( NULL, NULL, NULL, TRUE );
}
if( isset( $values['moderation_alert_content']) AND $values['moderation_alert_content'] )
{
$this->sendModerationAlert($values, $item);
}
\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 );
@@ -1369,19 +1405,32 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
$class = static::$contentModel;
$item = $class::loadAndCheckPerms( \IPS\Request::i()->id );
$item->react( \IPS\Content\Reaction::load( \IPS\Request::i()->reaction ) );
$reaction = \IPS\Content\Reaction::load( \IPS\Request::i()->reaction );
$item->react( $reaction );
if ( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->json( array(
$output = array(
'status' => 'ok',
'count' => \count( $item->reactions() ),
'score' => $item->reactionCount(),
'blurb' => ( \IPS\Settings::i()->reaction_count_display == 'count' ) ? '' : \IPS\Theme::i()->getTemplate( 'global', 'core' )->reactionBlurb( $item )
));
);
if ( \IPS\Settings::i()->core_datalayer_enabled )
{
$output['datalayer'] = array_replace( $item->getDataLayerProperties(), ['reaction_type' => $reaction->_title] );
}
\IPS\Output::i()->json( $output );
}
else
{
if ( \IPS\Settings::i()->core_datalayer_enabled )
{
\IPS\core\DataLayer::i()->addEvent( 'content_react', array_replace( $item->getDataLayerProperties(), [ 'reaction_type' => $reaction->_title ] ) );
}
\IPS\Output::i()->redirect( $item->url() );
}
}
@@ -2218,7 +2267,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
$comment = NULL;
if ( mb_substr( $method, -7 ) === 'Comment' )
{
if ( isset( $class::$commentClass ) )
if ( isset( $class::$commentClass ) and ( isset( \IPS\Request::i()->comment ) OR mb_substr( $method, 0, 8 ) === 'multimod' ) )
{
$class = $class::$commentClass;
$method = '_' . mb_substr( $method, 0, mb_strlen( $method ) - 7 );
@@ -2228,7 +2277,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
}
elseif ( mb_substr( $method, -6 ) === 'Review' )
{
if ( isset( $class::$reviewClass ) )
if ( isset( $class::$reviewClass ) and ( isset( \IPS\Request::i()->review ) OR mb_substr( $method, 0, 8 ) === 'multimod' ) )
{
$class = $class::$reviewClass;
$method = '_' . mb_substr( $method, 0, mb_strlen( $method ) - 6 );
@@ -2243,7 +2292,15 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
if ( !$comment or !method_exists( $this, $method ) )
{
\IPS\Output::i()->error( 'page_not_found', '2S136/B', 404, '' );
if ( mb_substr( $method, 0, 4 ) === 'find' )
{
/* Nothing found, redirect to main URL */
\IPS\Output::i()->redirect( $item->url() );
}
else
{
\IPS\Output::i()->error( 'page_not_found', '2S136/B', 404, '' );
}
}
else
{
@@ -2381,9 +2438,16 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
{
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\Text( 'hide_reason' ) );
$this->moderationAlertField( $form, $comment);
if ( $values = $form->values() )
{
$comment->modAction( 'hide', NULL, $values['hide_reason'] );
if( isset( $values['moderation_alert_content']) AND $values['moderation_alert_content'])
{
$this->sendModerationAlert($values, $comment);
}
}
else
{
@@ -2662,6 +2726,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
$currentPageCount = $item->commentPageCount();
$valueField = $commentClass::$databaseColumnMap['content'];
$idField = $commentClass::$databaseColumnId;
if ( $item::$firstCommentRequired and $comment->mapped( 'first' ) )
{
@@ -2700,6 +2765,13 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
\IPS\Output::i()->error( 'node_noperm_delete', '3S136/1K', 403, '' );
}
}
/* Reset best answer */
if( $item->topic_answered_pid and $item->topic_answered_pid == $comment->$idField )
{
$item->topic_answered_pid = 0;
$item->save();
}
if ( \IPS\Request::i()->isAjax() )
{
@@ -2759,7 +2831,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
$oldItem = $item;
/* Construct a form */
$form = $this->_splitForm( $item );
$form = $this->_splitForm( $item, $comment );
/* Handle submissions */
if ( $values = $form->values() )
@@ -2855,6 +2927,11 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
$oldItem->url()->__toString() => FALSE,
$oldItem->mapped( 'title' ) => FALSE
), $item );
if( isset( $values['moderation_alert_content'] ) AND $values['moderation_alert_content'] )
{
$this->sendModerationAlert( $values, $comment );
}
/* Redirect to it */
\IPS\Output::i()->redirect( $item->url() );
@@ -3007,20 +3084,38 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
try
{
\IPS\Session::i()->csrfCheck();
$comment->react( \IPS\Content\Reaction::load( \IPS\Request::i()->reaction ) );
$reaction = \IPS\Content\Reaction::load( \IPS\Request::i()->reaction );
$comment->react( $reaction );
if ( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->json( array(
$output = array(
'status' => 'ok',
'count' => \count( $comment->reactions() ),
'score' => $comment->reactionCount(),
'blurb' => ( \IPS\Settings::i()->reaction_count_display == 'count' ) ? '' : \IPS\Theme::i()->getTemplate( 'global', 'core' )->reactionBlurb( $comment )
));
);
if ( \IPS\Settings::i()->core_datalayer_enabled )
{
$item = $item ?? $comment->item();
$object = ( !isset( $item::$databaseColumnMap['content'] ) AND ( $item::$commentClass ) AND $comment->isFirst() ) ? $item : $comment;
$output['datalayer'] = array_replace( $object->getDataLayerProperties(), ['reaction_type' => $reaction->_title] );
}
\IPS\Output::i()->json( $output );
}
else
{
/* Data Layer Event */
if ( \IPS\Settings::i()->core_datalayer_enabled )
{
$properties = $comment->getDataLayerProperties();
$properties['reaction_type'] = $reaction->_title;
\IPS\core\DataLayer::i()->addEvent( 'content_react', $properties );
}
\IPS\Output::i()->redirect( $comment->url() );
}
}
@@ -3058,9 +3153,14 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
$form = new \IPS\Helpers\Form( 'form', 'add_recommend_content' );
$form->class = 'ipsForm_vertical ipsForm_fullWidth';
$form->add( new \IPS\Helpers\Form\Text( 'feature_mod_note', NULL, FALSE ) );
$this->moderationAlertField($form, $comment);
if ( $values = $form->values() )
{
$item->featureComment( $comment, $values['feature_mod_note'] );
if( isset( $values['moderation_alert_content']) AND $values['moderation_alert_content'])
{
$this->sendModerationAlert($values, $item);
}
\IPS\Session::i()->modLog( 'modlog__featured_comment', array(
(string) $comment->url() => FALSE,
@@ -3291,7 +3391,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
$classToCheck = $item;
$checkAgainst = 'split_merge';
}
if ( !$classToCheck::modPermission( $checkAgainst, NULL, $item->containerWrapper() ) )
{
throw new \DomainException;
@@ -3693,7 +3793,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
* @param \IPS\Content\Item $item The item
* @return \IPS\Helpers\Form
*/
protected function _splitForm( \IPS\Content\Item $item )
protected function _splitForm( \IPS\Content\Item $item, ?\IPS\Content\Comment $comment = NULL )
{
try
{
@@ -3808,7 +3908,13 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
}
}
}, NULL, NULL, 'split_into_url' ) );
/* multi mod doesn't support moderation alerts , so if $comment isn't set, we can't use it */
if( $comment )
{
$this->moderationAlertField($form, $comment );
}
return $form;
}
@@ -4062,4 +4168,46 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
protected function finishManage( $item )
{
}
/**
* Get the moderation alert fields
*
* @param \IPS\Helpers\Form $form
* @return void
*/
protected function moderationAlertField( \IPS\Helpers\Form $form, \IPS\Content $item )
{
if( \IPS\Member::loggedIn()->modPermission('can_manage_alerts') AND $item->author()->member_id )
{
$form->add( new \IPS\Helpers\Form\YesNo( 'moderation_alert', FALSE, FALSE, array( 'togglesOn' => array( 'moderation_alert_title', 'moderation_alert_content','moderation_alert_anonymous','moderation_alert_reply' ) ) ) );
\IPS\Member::loggedIn()->language()->words[ 'moderation_alert'] = \IPS\Member::loggedIn()->language()->addToStack('moderation_alert_name', FALSE, ['sprintf' => [ $item->author()->name ] ] );
$form->add( new \IPS\Helpers\Form\Text( 'moderation_alert_title', NULL, TRUE, array( 'maxLength' => 255 ), NULL, NULL, NULL, 'moderation_alert_title' ) );
$form->add( new \IPS\Helpers\Form\Editor( 'moderation_alert_content', NULL, TRUE, array( 'app' => 'core', 'key' => 'Alert', 'autoSaveKey' => 'createAlert', 'attachIds' => NULL ), NULL, NULL, NULL, 'moderation_alert_content' ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'moderation_alert_anonymous', FALSE, TRUE, array( 'togglesOff' => array( 'moderation_alert_reply') ), NULL, NULL, NULL, 'moderation_alert_anonymous' ) );
$form->add( new \IPS\Helpers\Form\Radio( 'moderation_alert_reply', 0, TRUE, array( 'disabled' => (bool) \IPS\Member::loggedIn()->members_disable_pm, 'options' => array( '0' => 'alert_no_reply', '1' => 'alert_can_reply', '2' => 'alert_must_reply' ) ), NULL, NULL, NULL, 'moderation_alert_reply' ) );
if ( \IPS\Member::loggedIn()->members_disable_pm )
{
\IPS\Member::loggedIn()->language()->words['alert_reply_desc'] = \IPS\Member::loggedIn()->language()->get('alert_reply__nopm_desc');
}
}
}
/**
* Send the alert
*
* @param array $values
* @param Item|Comment $content
* @return \IPS\core\Alerts\Alert
*/
protected function sendModerationAlert( array $values, \IPS\Content\Item|\IPS\Content\Comment $content ) : \IPS\core\Alerts\Alert
{
$values['alert_title'] = $values['moderation_alert_title'];
$values['alert_content'] = $values['moderation_alert_content'];
$values['alert_recipient_type'] = 'user';
$values['alert_recipient_user'] = $content->author()->member_id;
$values['alert_anonymous'] = $values['moderation_alert_anonymous'];
$values['alert_reply'] = $values['moderation_alert_reply'];
return \IPS\core\Alerts\Alert::_createFromForm( $values, NULL );
}
}