Version 4.1.2
This commit is contained in:
1 parent
3ba79295ee
commit
28bd025b35
1131 files changed
+63658
-20579
No files matched your search
@@ -177,6 +177,13 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
*/
|
||||
protected function checkForNewReplies()
|
||||
{
|
||||
/* If auto-polling isn't enabled, kill the polling now */
|
||||
if ( !\IPS\Settings::i()->auto_polling_enabled )
|
||||
{
|
||||
\IPS\Output::i()->json( array( 'error' => 'auto_polling_disabled' ) );
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$class = static::$contentModel;
|
||||
@@ -206,11 +213,20 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
}
|
||||
}
|
||||
|
||||
$newComments = $item->comments( NULL, 0, 'date', 'asc', NULL, NULL, \IPS\DateTime::ts( $lastComment->$commentDateColumn ), array_merge( $where, array( "{$authorColumn} != " . \IPS\Member::loggedIn()->member_id ) ) );
|
||||
/* We will fetch up to 200 comments - anything over this is excessive.
|
||||
@see https://community.invisionpower.com/4bugtrack/active-reports/x-new-replies-doesnt-show-more-than-15-replies-r7192/ */
|
||||
$newComments = $item->comments( 200, 0, 'date', 'asc', NULL, NULL, \IPS\DateTime::ts( $lastComment->$commentDateColumn ), array_merge( $where, array( "{$authorColumn} != " . \IPS\Member::loggedIn()->member_id ) ) );
|
||||
|
||||
if ( \IPS\Request::i()->type === 'count' )
|
||||
{
|
||||
$data = array( 'count' => (int) count( $newComments ), 'totalCount' => $item->mapped('num_comments') );
|
||||
$data = array(
|
||||
'totalNewCount' => (int) count( $newComments ),
|
||||
'count' => (int) count( $newComments ), /* This is here for legacy purposes only */
|
||||
'perPage' => $class::getCommentsPerPage(),
|
||||
'totalCount' => $item->mapped('num_comments'),
|
||||
'title' => $item->mapped('title') ,
|
||||
'spillOverUrl' => $item->url( 'getNewComment' )
|
||||
);
|
||||
|
||||
if( $data['count'] === 1 ){
|
||||
$itemData = reset( $newComments );
|
||||
@@ -254,9 +270,9 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
{
|
||||
$class = static::$contentModel;
|
||||
$item = $class::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
if ( !$item->canEdit() )
|
||||
if ( !$item->canEdit() and !\IPS\Request::i()->form_submitted ) // We check if the form has been submitted to prevent the user loosing their content
|
||||
{
|
||||
throw new \DomainException;
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form( 'form', \IPS\Member::loggedIn()->language()->addToStack( $class::$formLangPrefix . '_save' ) ? $class::$formLangPrefix . '_save' : 'save' );
|
||||
@@ -291,39 +307,46 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$item->processForm( $values );
|
||||
if ( isset( $item::$databaseColumnMap['updated'] ) )
|
||||
{
|
||||
$column = $item::$databaseColumnMap['updated'];
|
||||
$item->$column = time();
|
||||
}
|
||||
|
||||
if ( isset( $item::$databaseColumnMap['date'] ) and isset( $values[ $item::$formLangPrefix . 'date' ] ) )
|
||||
{
|
||||
$column = $item::$databaseColumnMap['date'];
|
||||
|
||||
if ( $values[ $item::$formLangPrefix . 'date' ] instanceof \IPS\DateTime )
|
||||
{
|
||||
$item->$column = $values[ $item::$formLangPrefix . 'date' ]->getTimestamp();
|
||||
}
|
||||
else
|
||||
if ( $item->canEdit() )
|
||||
{
|
||||
$item->processForm( $values );
|
||||
if ( isset( $item::$databaseColumnMap['updated'] ) )
|
||||
{
|
||||
$column = $item::$databaseColumnMap['updated'];
|
||||
$item->$column = time();
|
||||
}
|
||||
|
||||
if ( isset( $item::$databaseColumnMap['date'] ) and isset( $values[ $item::$formLangPrefix . 'date' ] ) )
|
||||
{
|
||||
$column = $item::$databaseColumnMap['date'];
|
||||
|
||||
if ( $values[ $item::$formLangPrefix . 'date' ] instanceof \IPS\DateTime )
|
||||
{
|
||||
$item->$column = $values[ $item::$formLangPrefix . 'date' ]->getTimestamp();
|
||||
}
|
||||
else
|
||||
{
|
||||
$item->$column = time();
|
||||
}
|
||||
}
|
||||
|
||||
$item->save();
|
||||
$item->processAfterEdit( $values );
|
||||
|
||||
\IPS\Output::i()->redirect( $item->url() );
|
||||
}
|
||||
else
|
||||
{
|
||||
$form->error = \IPS\Member::loggedIn()->language()->addToStack('edit_no_perm_err');
|
||||
}
|
||||
|
||||
$item->save();
|
||||
$item->processAfterEdit( $values );
|
||||
|
||||
\IPS\Output::i()->redirect( $item->url() );
|
||||
}
|
||||
|
||||
$this->_setBreadcrumbAndTitle( $item );
|
||||
\IPS\Output::i()->output = $form;
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'forms', 'core' )->editContentForm( \IPS\Member::loggedIn()->language()->addToStack( 'edit_title', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $item::$title ) ) ) ), $form );
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2S136/E', 404, '' );
|
||||
\IPS\Output::i()->error( 'edit_no_perm_err', '2S136/E', 404, '' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -505,6 +528,8 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
}
|
||||
|
||||
$item->move( $values['move_to'], isset( $values['move_keep_link'] ) ? $values['move_keep_link'] : FALSE );
|
||||
\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 );
|
||||
|
||||
\IPS\Output::i()->redirect( $item->url() );
|
||||
}
|
||||
|
||||
@@ -536,11 +561,15 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
}
|
||||
$form = new \IPS\Helpers\Form( 'form', 'merge' );
|
||||
$form->class = 'ipsForm_vertical';
|
||||
$form->add( new \IPS\Helpers\Form\Url( 'merge_with', NULL, TRUE, array(), function ( $val ) use ( $class )
|
||||
$form->add( new \IPS\Helpers\Form\Url( 'merge_with', NULL, TRUE, array(), function ( $val ) use ( $class, $item )
|
||||
{
|
||||
try
|
||||
{
|
||||
$class::loadFromUrl( $val );
|
||||
$toMerge = $class::loadFromUrl( $val );
|
||||
if ( $toMerge == $item )
|
||||
{
|
||||
throw new \DomainException;
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
@@ -618,9 +647,11 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
|
||||
if( $values = $form->values() )
|
||||
{
|
||||
$email = \IPS\Email::buildFromContent( $values['email_subject'], $values['email_content'] );
|
||||
$email->from = ( isset( $values['mail_from_email'] ) ) ? $values['mail_from_email'] : \IPS\Member::loggedIn()->email;
|
||||
$email->fromName = ( isset( $values['mail_from_name'] ) ) ? $values['mail_from_name'] : \IPS\Member::loggedIn()->name;
|
||||
$email = \IPS\Email::buildFromContent( $values['email_subject'], $values['email_content'] );
|
||||
$fromName = ( isset( $values['mail_from_name'] ) ) ? $values['mail_from_name'] : \IPS\Member::loggedIn()->name;
|
||||
|
||||
/* Set contact email as Reply-To instead of From, so that it will pass Spam/SPF checks */
|
||||
$email->headers['Reply-To'] = '=?UTF-8?B?' . base64_encode( $fromName ) . "?= <" . ( isset( $values['mail_from_email'] ) ? $values['mail_from_email'] : \IPS\Member::loggedIn()->email ) . '>';
|
||||
|
||||
$email->emailBody['html'] = $email->parseTextForEmail( $email->emailBody['html'] );
|
||||
$email->send( $values['email_email'] );
|
||||
@@ -698,6 +729,10 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
}
|
||||
|
||||
$this->_setBreadcrumbAndTitle( $item );
|
||||
|
||||
/* 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( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core' ) ), 'popupTemplate' ) );
|
||||
}
|
||||
catch ( \LogicException $e )
|
||||
@@ -751,7 +786,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
{
|
||||
if ( \IPS\Request::i()->mini )
|
||||
{
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core' )->reputationMini( $item ) );
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core' )->reputationMini( $item->reputation(), $item->canGiveReputation( 1 ), $item->canGiveReputation( -1 ), $item->url('showRep'), $item->url('rep') ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -862,6 +897,13 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
if ( array_key_exists( $item->container()->_id, $resetTimes ) )
|
||||
{
|
||||
$comment = $item->comments( 1, NULL, 'date', 'asc', NULL, NULL, \IPS\DateTime::ts( $resetTimes[ $item->container()->_id ] ) );
|
||||
|
||||
if ( $class::$firstCommentRequired and $comment->isFirst() )
|
||||
{
|
||||
/* link https://community.invisionpower.com/4bugtrack/active-reports/go-to-unread-link-also-links-to-the-fist-postcomment-even-for-totally-unread-content-r7864/ */
|
||||
\IPS\Output::i()->redirect( $item->url() );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( $comment ? $comment->url() : $item->url() );
|
||||
}
|
||||
else
|
||||
@@ -1164,7 +1206,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'comment_value', $comment->$valueField, TRUE, array(
|
||||
'app' => $class::$application,
|
||||
'key' => ucfirst( $class::$module ),
|
||||
'autoSaveKey' => 'editComment-' . $class::$application . '/' . $class::$module . '-' . $comment->id,
|
||||
'autoSaveKey' => 'editComment-' . $class::$application . '/' . $class::$module . '-' . $comment->$idField,
|
||||
'attachIds' => $comment->attachmentIds()
|
||||
) ) );
|
||||
|
||||
@@ -1178,14 +1220,14 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
}
|
||||
if ( \IPS\Member::loggedIn()->group['g_append_edit'] )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Checkbox( 'comment_log_edit', \IPS\Member::loggedIn()->member_id == $comment->author()->member_id ) );
|
||||
$form->add( new \IPS\Helpers\Form\Checkbox( 'comment_log_edit', FALSE ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
/* Log History */
|
||||
if ( $comment instanceof \IPS\Content\EditHistory )
|
||||
if ( $comment instanceof \IPS\Content\EditHistory and \IPS\Settings::i()->edit_log )
|
||||
{
|
||||
$editIsPublic = \IPS\Member::loggedIn()->group['g_append_edit'] ? $values['comment_log_edit'] : TRUE;
|
||||
|
||||
@@ -1239,7 +1281,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
$comment->editContents( $values['comment_value'] );
|
||||
|
||||
/* Moderator log */
|
||||
\IPS\Session::i()->modLog( 'modlog__comment_edit', array( $comment->url()->__toString() => FALSE, $item::$title => FALSE, $item->url()->__toString() => FALSE, $item->mapped('title') => FALSE ), $item );
|
||||
\IPS\Session::i()->modLog( 'modlog__comment_edit', array( $comment->url()->__toString() => FALSE, $item::$title => TRUE, $item->url()->__toString() => FALSE, $item->mapped('title') => FALSE ), $item );
|
||||
|
||||
/* Display */
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
@@ -1299,7 +1341,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
$comment->delete();
|
||||
|
||||
/* Log */
|
||||
\IPS\Session::i()->modLog( 'modlog__comment_delete', array( $item::$title => FALSE, $item->url()->__toString() => FALSE, $item->mapped('title') => FALSE ), $item );
|
||||
\IPS\Session::i()->modLog( 'modlog__comment_delete', array( $item::$title => TRUE, $item->url()->__toString() => FALSE, $item->mapped('title') => FALSE ), $item );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1783,6 +1825,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
}
|
||||
|
||||
$item->resyncCommentCounts();
|
||||
$item->save();
|
||||
|
||||
if ( $object and \IPS\Request::i()->multimod != 'delete' )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user