Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
+485
-123
@@ -61,6 +61,31 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
{
|
||||
$class = static::$contentModel;
|
||||
$item = $class::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
|
||||
/* Have we moved? If a user has loaded a forum, and a moderator merges two topics leaving a link, then we need to account for this if the
|
||||
user happens to hover over the topic that was removed before refreshing the page. */
|
||||
if ( isset( $class::$databaseColumnMap['state'] ) AND isset( $class::$databaseColumnMap['moved_to'] ) )
|
||||
{
|
||||
$stateColumn = $class::$databaseColumnMap['state'];
|
||||
$movedToColumn = $class::$databaseColumnMap['moved_to'];
|
||||
$movedTo = explode( '&', $item->$movedToColumn );
|
||||
|
||||
if ( $item->$stateColumn == 'link' OR $item->$stateColumn == 'merged' )
|
||||
{
|
||||
try
|
||||
{
|
||||
$moved = $class::loadAndCheckPerms( $movedTo[0] );
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() AND \IPS\Request::i()->preview )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( $moved->url(), '', 301 );
|
||||
}
|
||||
catch( \OutOfRangeException $e ) { }
|
||||
}
|
||||
}
|
||||
|
||||
/* If this is an AJAX request (like the topic hovercard), we don't want to do any of the below like update views and mark read */
|
||||
if ( \IPS\Request::i()->isAjax() and !$this->updateViewsAndMarkersOnAjax )
|
||||
@@ -78,10 +103,24 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
$idColumn = $class::$databaseColumnId;
|
||||
if ( in_array( 'IPS\Content\Views', class_implements( $class ) ) AND isset( $class::$databaseColumnMap['views'] ) )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_view_updates', array(
|
||||
'classname' => $class,
|
||||
'id' => $item->$idColumn
|
||||
) );
|
||||
$countUpdated = false;
|
||||
if ( \IPS\REDIS_ENABLED and \IPS\CACHE_METHOD == 'Redis' and \IPS\CACHE_CONFIG )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Redis::i()->zIncrBy( 'topic_views', 1, $class .'__' . $item->$idColumn );
|
||||
$countUpdated = true;
|
||||
}
|
||||
catch( \Exception $e ) {}
|
||||
}
|
||||
|
||||
if ( ! $countUpdated )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_view_updates', array(
|
||||
'classname' => $class,
|
||||
'id' => $item->$idColumn
|
||||
) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +163,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
$pageCount = call_user_func( array( $item, "{$paginationType}PageCount" ) );
|
||||
if ( $pageCount and \IPS\Request::i()->page > $pageCount )
|
||||
{
|
||||
\IPS\Output::i()->redirect( call_user_func( array( $item, 'last' . ucfirst( $paginationType ) . 'PageUrl' ) ), NULL, 303 );
|
||||
\IPS\Output::i()->redirect( call_user_func( array( $item, 'last' . mb_ucfirst( $paginationType ) . 'PageUrl' ) ), NULL, 303 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,10 +202,24 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
$idColumn = $class::$databaseColumnId;
|
||||
if ( in_array( 'IPS\Content\Views', class_implements( $class ) ) AND isset( $class::$databaseColumnMap['views'] ) )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_view_updates', array(
|
||||
'classname' => $class,
|
||||
'id' => $item->$idColumn
|
||||
) );
|
||||
$countUpdated = false;
|
||||
if ( \IPS\REDIS_ENABLED and \IPS\CACHE_METHOD == 'Redis' and \IPS\CACHE_CONFIG )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Redis::i()->zIncrBy( 'topic_views', 1, $class .'__' . $item->$idColumn );
|
||||
$countUpdated = true;
|
||||
}
|
||||
catch( \Exception $e ) {}
|
||||
}
|
||||
|
||||
if ( ! $countUpdated )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_view_updates', array(
|
||||
'classname' => $class,
|
||||
'id' => $item->$idColumn
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
/* Mark read */
|
||||
@@ -181,24 +234,6 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
}
|
||||
}
|
||||
|
||||
/* Have we moved? */
|
||||
if ( isset( $class::$databaseColumnMap['state'] ) AND isset( $class::$databaseColumnMap['moved_to'] ) )
|
||||
{
|
||||
$stateColumn = $class::$databaseColumnMap['state'];
|
||||
$movedToColumn = $class::$databaseColumnMap['moved_to'];
|
||||
$movedTo = explode( '&', $item->$movedToColumn );
|
||||
|
||||
if ( $item->$stateColumn == 'link' OR $item->$stateColumn == 'merged' )
|
||||
{
|
||||
try
|
||||
{
|
||||
$moved = $class::loadAndCheckPerms( $movedTo[0] );
|
||||
\IPS\Output::i()->redirect( $moved->url(), '', 301 );
|
||||
}
|
||||
catch( \OutOfRangeException $e ) { }
|
||||
}
|
||||
}
|
||||
|
||||
/* Set navigation and title */
|
||||
$this->_setBreadcrumbAndTitle( $item, FALSE );
|
||||
|
||||
@@ -209,6 +244,16 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
\IPS\Output::i()->metaTags['og:type'] = 'object';
|
||||
\IPS\Output::i()->metaTags['og:url'] = (string) $item->url();
|
||||
\IPS\Output::i()->metaTags['og:description'] = $item->metaDescription();
|
||||
|
||||
/* Facebook Pixel */
|
||||
$itemId = $class::$databaseColumnId;
|
||||
\IPS\core\Facebook\Pixel::i()->PageView = array(
|
||||
'item_id' => $item->$itemId,
|
||||
'item_name' => $item->mapped( 'title' ),
|
||||
'item_type' => isset( $class::$contentType ) ? $class::$contentType : $class::$title,
|
||||
'category_name' => isset( $item::$databaseColumnMap['container'] ) ? $item->container()->_title : NULL
|
||||
);
|
||||
|
||||
if( $item->mapped( 'updated' ) OR $item->mapped( 'last_comment' ) OR $item->mapped( 'last_review' ) )
|
||||
{
|
||||
\IPS\Output::i()->metaTags['og:updated_time'] = \IPS\DateTime::ts( $item->mapped( 'updated' ) ? $item->mapped( 'updated' ) : ( $item->mapped( 'last_comment' ) ? $item->mapped( 'last_comment' ) : $item->mapped( 'last_review' ) ) )->rfc3339();
|
||||
@@ -216,22 +261,19 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
|
||||
$tags = array();
|
||||
|
||||
if( $item->prefix() !== NULL )
|
||||
{
|
||||
$tags[] = $item->prefix();
|
||||
}
|
||||
|
||||
if( $item->tags() !== NULL )
|
||||
{
|
||||
if( $item->prefix() !== NULL )
|
||||
{
|
||||
$tags[] = $item->prefix();
|
||||
}
|
||||
$tags = array_merge( $tags, $item->tags() );
|
||||
}
|
||||
|
||||
foreach( $item->tags() as $tag )
|
||||
{
|
||||
$tags[] = $tag;
|
||||
}
|
||||
|
||||
if( count( $tags ) )
|
||||
{
|
||||
\IPS\Output::i()->metaTags['keywords'] = implode( ', ', $tags );
|
||||
}
|
||||
if( count( $tags ) )
|
||||
{
|
||||
\IPS\Output::i()->metaTags['keywords'] = implode( ', ', $tags );
|
||||
}
|
||||
|
||||
/* Add contextual search options */
|
||||
@@ -260,6 +302,8 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
*/
|
||||
protected function checkForNewReplies()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
/* If auto-polling isn't enabled, kill the polling now */
|
||||
if ( !\IPS\Settings::i()->auto_polling_enabled )
|
||||
{
|
||||
@@ -269,6 +313,13 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
|
||||
try
|
||||
{
|
||||
/* no need for polling for embeds */
|
||||
if ( !isset( static::$contentModel ) )
|
||||
{
|
||||
\IPS\Output::i()->json( array( 'error' => 'auto_polling_disabled' ) );
|
||||
return;
|
||||
}
|
||||
|
||||
$class = static::$contentModel;
|
||||
|
||||
/* no need for polling if the content item doesn't have comments */
|
||||
@@ -322,7 +373,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
$itemData = reset( $newComments );
|
||||
$author = $itemData->author();
|
||||
|
||||
$data['name'] = htmlspecialchars( $author->name, \IPS\HTMLENTITIES | ENT_QUOTES, 'UTF-8', FALSE );
|
||||
$data['name'] = htmlspecialchars( $author->name, ENT_DISALLOWED | ENT_QUOTES, 'UTF-8', FALSE );
|
||||
$data['photo'] = (string) $author->photo;
|
||||
}
|
||||
|
||||
@@ -340,13 +391,14 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
|
||||
/* Only mark as read if we'll be staying on this page, otherise we'll be marking it read despite
|
||||
the user not having seen everything */
|
||||
if( (int) \IPS\Request::i()->showing + (int) count( $newComments ) <= $class::getCommentsPerPage() ){
|
||||
if( (int) \IPS\Request::i()->showing + (int) count( $newComments ) <= $class::getCommentsPerPage() )
|
||||
{
|
||||
$item->markRead();
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->json( array(
|
||||
'content' => $output,
|
||||
'content' => \IPS\Output::i()->replaceEmojiWithImages( $output ),
|
||||
'id' => $lastId,
|
||||
'totalCount' => $item->mapped( 'num_comments' ),
|
||||
'totalNewCount' => (int) count( $newComments ),
|
||||
@@ -426,7 +478,15 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
}
|
||||
|
||||
$this->_setBreadcrumbAndTitle( $item );
|
||||
\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, $container );
|
||||
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core' ) ), 'popupTemplate' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\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, $container );
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
@@ -468,7 +528,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
}
|
||||
|
||||
/* If the tag form field is generated, create the form, otherwise throw an exception */
|
||||
if( $tagsField = $item::tagsFormField( $item, $container ) )
|
||||
if( $tagsField = $item::tagsFormField( $item, $container, TRUE ) )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form( 'form', \IPS\Member::loggedIn()->language()->checkKeyExists( $item::$formLangPrefix . '_save' ) ? $item::$formLangPrefix . '_save' : 'save' );
|
||||
$form->class = 'ipsForm_vertical ipsForm_fullWidth';
|
||||
@@ -498,7 +558,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
|
||||
/* Now set the tags */
|
||||
$name = $tagsField->name;
|
||||
\IPS\Request::i()->$name = implode( ',', $existingTags );
|
||||
\IPS\Request::i()->$name = implode( "\n", $existingTags );
|
||||
|
||||
if( isset( $existingTags['prefix'] ) )
|
||||
{
|
||||
@@ -577,7 +637,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
|
||||
$class = static::$contentModel;
|
||||
$item = $class::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
if ( !$item->canEdit() )
|
||||
if ( !$item->canEditTitle() )
|
||||
{
|
||||
throw new \DomainException;
|
||||
}
|
||||
@@ -665,7 +725,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
\IPS\Output::i()->breadcrumb[] = array( $link ? $item->url() : NULL, $item->mapped( 'title' ) );
|
||||
|
||||
$title = ( isset( \IPS\Request::i()->page ) and \IPS\Request::i()->page > 1 ) ? \IPS\Member::loggedIn()->language()->addToStack( 'title_with_page_number', FALSE, array( 'sprintf' => array( $item->mapped( 'title' ), \IPS\Request::i()->page ) ) ) : $item->mapped( 'title' );
|
||||
\IPS\Output::i()->title = $container ? ( $title . ' - ' . $container->_stripTagsTitle ) : $title;
|
||||
\IPS\Output::i()->title = $container ? ( $title . ' - ' . $container->_title ) : $title;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -686,7 +746,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
{
|
||||
if ( !$poll->canClose() )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_permission', '2S136/Z', 403, '' );
|
||||
\IPS\Output::i()->error( 'no_module_permission', '2S136/Z', 403, '' );
|
||||
}
|
||||
|
||||
$newStatus = ( \IPS\Request::i()->value == 1 ? 0 : 1 );
|
||||
@@ -777,7 +837,11 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
catch( \InvalidArgumentException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'mod_error_invalid_action', '3S136/1A', 403, 'mod_error_invalid_action_admin' );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2S136/1', 404, '' );
|
||||
}
|
||||
@@ -812,7 +876,13 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( $node->can( 'add' ) and $item::modPermission( 'move', \IPS\Member::loggedIn(), $node ) )
|
||||
/* If the item is in a club, only allow moving to other clubs that you moderate */
|
||||
if ( \IPS\IPS::classUsesTrait( $item->container(), 'IPS\Content\ClubContainer' ) and $item->container()->club() )
|
||||
{
|
||||
return $item::modPermission( 'move', \IPS\Member::loggedIn(), $node ) and $node->can( 'add' ) ;
|
||||
}
|
||||
|
||||
if ( $node->can( 'add' ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -841,8 +911,21 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_move_invalid', '1S136/L', 403, '' );
|
||||
}
|
||||
|
||||
|
||||
/* If this item is read, we need to re-mark it as such after moving */
|
||||
if( $item instanceof \IPS\Content\ReadMarkers )
|
||||
{
|
||||
$unread = $item->unread();
|
||||
}
|
||||
|
||||
$item->move( $values['move_to'], isset( $values['move_keep_link'] ) ? $values['move_keep_link'] : FALSE );
|
||||
|
||||
/* Mark it as read */
|
||||
if( $item instanceof \IPS\Content\ReadMarkers and $unread == 0 )
|
||||
{
|
||||
$item->markRead();
|
||||
}
|
||||
|
||||
\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( ( isset( \IPS\Request::i()->returnto ) AND \IPS\Request::i()->returnto == 'item' ) ? $item->url() : $container->url() );
|
||||
@@ -874,43 +957,9 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
{
|
||||
throw new \DomainException;
|
||||
}
|
||||
$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, $item )
|
||||
{
|
||||
/* Load it */
|
||||
try
|
||||
{
|
||||
$toMerge = $class::loadFromUrl( $val );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'form_url_bad_item', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $class::$title, FALSE, array( 'strtolower' => TRUE ) ) ) ) ) );
|
||||
}
|
||||
|
||||
/* Make sure it isn't the same */
|
||||
if ( $toMerge == $item )
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'cannot_merge_with_self' ) );
|
||||
}
|
||||
|
||||
/* And that we have permission */
|
||||
if ( !$toMerge->canMerge() )
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'no_merge_permission', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $class::$title, FALSE, array( 'strtolower' => TRUE ) ) ) ) ) );
|
||||
}
|
||||
|
||||
} ) );
|
||||
\IPS\Member::loggedIn()->language()->words['merge_with_desc'] = \IPS\Member::loggedIn()->language()->addToStack( 'merge_with__desc', FALSE, array( 'sprintf' => array( $item->indefiniteArticle(), $item->mapped( 'title' ) ) ) );
|
||||
if ( isset( $class::$databaseColumnMap['moved_to'] ) )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Checkbox( 'move_keep_link' ) );
|
||||
|
||||
if ( \IPS\Settings::i()->topic_redirect_prune )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['move_keep_link_desc'] = \IPS\Member::loggedIn()->language()->addToStack( '_move_keep_link_desc', FALSE, array( 'pluralize' => array( \IPS\Settings::i()->topic_redirect_prune ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
$form = $item->mergeForm();
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$item->mergeIn( array( $class::loadFromUrl( $values['merge_with'] ) ), isset( $values['move_keep_link'] ) ? $values['move_keep_link'] : FALSE );
|
||||
@@ -921,7 +970,6 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'merge_item', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $class::$title ) ) ) );
|
||||
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core' ) ), 'popupTemplate' ) );
|
||||
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
@@ -1021,6 +1069,46 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a report
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function deleteReport()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
/* Make sure the user confirmed the deletion */
|
||||
\IPS\Request::i()->confirmedDelete();
|
||||
|
||||
try
|
||||
{
|
||||
$report = \IPS\Db::i()->select( '*', 'core_rc_reports', array( 'id=? AND report_by=? AND date_reported > ?', \IPS\Request::i()->cid, \IPS\Member::loggedIn()->member_id, time() - ( \IPS\Settings::i()->automoderation_report_again_mins * 60 ) ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'automoderation_cannot_find_report', '2S136/1G', 404, '' );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$index = \IPS\core\Reports\Report::load( $report['rid'] );
|
||||
}
|
||||
catch( \OutofRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'automoderation_cannot_find_report', '2S136/1H', 404, '' );
|
||||
}
|
||||
|
||||
$class = $index->class;
|
||||
|
||||
\IPS\Db::i()->delete( 'core_rc_reports', array( 'id=?', \IPS\Request::i()->cid ) );
|
||||
|
||||
/* Recalculate, we may have dropped below the threshold needed to hide a thing */
|
||||
$index->runAutomaticModeration();
|
||||
|
||||
\IPS\Output::i()->redirect( $class::load( $index->content_id )->url(), 'automoderation_deleted' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Report Item
|
||||
*
|
||||
@@ -1037,23 +1125,48 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
|
||||
/* Permission check */
|
||||
$canReport = $item->canReport();
|
||||
if ( $canReport !== TRUE )
|
||||
if ( $canReport !== TRUE AND !( $canReport == 'report_err_already_reported' AND \IPS\Settings::i()->automoderation_enabled ) )
|
||||
{
|
||||
\IPS\Output::i()->error( $canReport, '2S136/6', 404, '' );
|
||||
\IPS\Output::i()->error( $canReport, '2S136/6', 403, '' );
|
||||
}
|
||||
|
||||
/* Show form */
|
||||
$form = new \IPS\Helpers\Form( NULL, 'report_submit' );
|
||||
$form->class = 'ipsForm_vertical';
|
||||
$idColumn = $class::$databaseColumnId;
|
||||
|
||||
/* As we group by user id to determine if max points have been reached, guests cannot contribute to counts */
|
||||
if ( \IPS\Member::loggedIn()->member_id and \IPS\Settings::i()->automoderation_enabled )
|
||||
{
|
||||
/* Has this member already reported this in the past 24 hours */
|
||||
try
|
||||
{
|
||||
$index = \IPS\core\Reports\Report::loadByClassAndId( get_class( $item ), $item->$idColumn );
|
||||
$report = \IPS\Db::i()->select( '*', 'core_rc_reports', array( 'rid=? and report_by=? and date_reported > ?', $index->id, \IPS\Member::loggedIn()->member_id, time() - ( \IPS\Settings::i()->automoderation_report_again_mins * 60 ) ) )->first();
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'system', 'core' )->reportedAlready( $index, $report, $item );
|
||||
return;
|
||||
}
|
||||
catch( \Exception $e ) { }
|
||||
|
||||
$options = array( \IPS\core\Reports\Report::TYPE_MESSAGE => \IPS\Member::loggedIn()->language()->addToStack('report_message_item') );
|
||||
foreach( \IPS\core\Reports\Types::roots() as $type )
|
||||
{
|
||||
$options[ $type->id ] = $type->_title;
|
||||
}
|
||||
|
||||
$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' ) ) );
|
||||
|
||||
if( !\IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Captcha );
|
||||
}
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$report = $item->report( $values['report_message'] );
|
||||
$report = $item->report( $values['report_message'], ( isset( $values['report_type'] ) ) ? $values['report_type'] : 0 );
|
||||
\IPS\File::claimAttachments( "report-{$class::$application}-{$class::$module}-{$item->$idColumn}", $report->id );
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
@@ -1234,6 +1347,8 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
{
|
||||
$url = $url->setQueryString( 'reaction', $activeTab );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->metaTags['robots'] = 'noindex';
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() AND isset( \IPS\Request::i()->changed ) )
|
||||
{
|
||||
@@ -1263,7 +1378,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
{
|
||||
if( !\IPS\Member::loggedIn()->modPermission( 'can_view_moderation_log' ) )
|
||||
{
|
||||
throw new \DomainException;
|
||||
\IPS\Output::i()->error( 'no_module_permission', '2S136/1F', 403, '' );
|
||||
}
|
||||
|
||||
try
|
||||
@@ -1408,7 +1523,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
|
||||
if ( $comment !== NULL )
|
||||
{
|
||||
\IPS\Output::i()->redirect( $comment->url() );
|
||||
$this->_find( get_class( $comment ), $comment, $item );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1470,7 +1585,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
|
||||
if ( $comment !== NULL )
|
||||
{
|
||||
\IPS\Output::i()->redirect( $comment->url() );
|
||||
$this->_find( get_class( $comment ), $comment, $item );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1551,6 +1666,108 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
\IPS\Output::i()->error( 'node_error', '2S136/9', 404, '' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow the author of a content item to reply to a review
|
||||
*
|
||||
* @param bool $editing TRUE if we are editing our response
|
||||
* @return void
|
||||
*/
|
||||
protected function _respond( $editing=FALSE )
|
||||
{
|
||||
try
|
||||
{
|
||||
/* Init */
|
||||
$class = static::$contentModel;
|
||||
$reviewClass = $class::$reviewClass;
|
||||
$item = $class::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
$review = $reviewClass::loadAndCheckPerms( \IPS\Request::i()->review );
|
||||
|
||||
/* Are we allowed to respond? */
|
||||
if( $editing === TRUE )
|
||||
{
|
||||
if ( !$review->canEditResponse() )
|
||||
{
|
||||
throw new \DomainException;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !$review->canRespond() )
|
||||
{
|
||||
throw new \DomainException;
|
||||
}
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'reviewResponse', $editing ? $review->mapped('author_response') : NULL, TRUE, array(
|
||||
'app' => 'core',
|
||||
'key' => 'ReviewResponses',
|
||||
'autoSaveKey' => 'reviewResponse-' . $class::$application . '/' . $class::$module . '-' . \IPS\Request::i()->review,
|
||||
'attachIds' => array( \IPS\Request::i()->id, \IPS\Request::i()->review, get_class( $item ) )
|
||||
) ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$review->author_response = $values['reviewResponse'];
|
||||
$review->save();
|
||||
|
||||
\IPS\Output::i()->redirect( $review->url() );
|
||||
}
|
||||
|
||||
\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 )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2S136/1I', 403, '' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow the author of a content item to edit their review response
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _editResponse()
|
||||
{
|
||||
return $this->_respond( TRUE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a review response
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _deleteResponse()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
try
|
||||
{
|
||||
/* Init */
|
||||
$class = static::$contentModel;
|
||||
$reviewClass = $class::$reviewClass;
|
||||
$item = $class::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
$review = $reviewClass::loadAndCheckPerms( \IPS\Request::i()->review );
|
||||
|
||||
/* Are we allowed to delete responses? */
|
||||
if ( !$review->canDeleteResponse() )
|
||||
{
|
||||
throw new \DomainException;
|
||||
}
|
||||
|
||||
$review->author_response = NULL;
|
||||
$review->save();
|
||||
|
||||
\IPS\Output::i()->redirect( $review->url() );
|
||||
}
|
||||
catch ( \LogicException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2S136/1J', 403, '' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Message Form
|
||||
@@ -1560,14 +1777,27 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
protected function messageForm()
|
||||
{
|
||||
$class = static::$contentModel;
|
||||
$item = $class::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
$current = NULL;
|
||||
|
||||
$metaData = $item->getMeta();
|
||||
if ( isset( \IPS\Request::i()->meta_id ) AND isset( $metaData['core_ContentMessages'][ \IPS\Request::i()->meta_id ] ) )
|
||||
try
|
||||
{
|
||||
$current = $metaData['core_ContentMessages'][ \IPS\Request::i()->meta_id ];
|
||||
$item = $class::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
|
||||
$current = NULL;
|
||||
$metaData = $item->getMeta();
|
||||
if ( isset( \IPS\Request::i()->meta_id ) AND isset( $metaData['core_ContentMessages'][ \IPS\Request::i()->meta_id ] ) )
|
||||
{
|
||||
$current = $metaData['core_ContentMessages'][ \IPS\Request::i()->meta_id ];
|
||||
}
|
||||
|
||||
if ( !$item->canOnMessage( $current ? 'edit' : 'add' ) )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2S136/1D', 404, '' );
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'message', $current ? $current['message'] : NULL , TRUE, array( 'app' => 'core', 'key' => 'Meta', 'autoSaveKey' => $current ? "meta-message-" . \IPS\Request::i()->meta_id : "meta-message-new", 'attachIds' => $current ? array( \IPS\Request::i()->meta_id, NULL, 'message' ) : NULL ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Custom( 'message_color', isset( $current['color'] ) ? $current['color'] : 'none', FALSE, array( 'getHtml' => function( $element )
|
||||
@@ -1613,8 +1843,19 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
$class = static::$contentModel;
|
||||
$item = $class::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
try
|
||||
{
|
||||
$class = static::$contentModel;
|
||||
$item = $class::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
if ( !$item->canOnMessage('delete') )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2S136/1E', 404, '' );
|
||||
}
|
||||
|
||||
$item->deleteMessage( \IPS\Request::i()->meta_id );
|
||||
|
||||
@@ -1897,9 +2138,16 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
{
|
||||
$form = new \IPS\Helpers\Form( 'form', false );
|
||||
$form->class = 'ipsForm_vertical';
|
||||
|
||||
if ( in_array( 'IPS\Content\Review', class_parents( $comment ) ) )
|
||||
{
|
||||
$ratingField = $commentClass::$databaseColumnMap['rating'];
|
||||
$form->add( new \IPS\Helpers\Form\Rating( 'rating_value', $comment->$ratingField, TRUE, array( 'max' => \IPS\Settings::i()->reviews_rating_out_of ) ) );
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'comment_value', $comment->$valueField, TRUE, array(
|
||||
'app' => $class::$application,
|
||||
'key' => ucfirst( $class::$module ),
|
||||
'key' => mb_ucfirst( $class::$module ),
|
||||
'autoSaveKey' => 'editComment-' . $class::$application . '/' . $class::$module . '-' . $comment->$idField,
|
||||
'attachIds' => $comment->attachmentIds()
|
||||
) ) );
|
||||
@@ -1979,11 +2227,25 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
/* Do it */
|
||||
$comment->editContents( $values['comment_value'] );
|
||||
|
||||
/* Edit rating */
|
||||
$reloadPage = false;
|
||||
if ( isset( $values['rating_value'] ) and in_array( 'IPS\Content\Review', class_parents( $comment ) ) )
|
||||
{
|
||||
/* The star rating changes but is outside of JS scope to change when editing a comment */
|
||||
$ratingField = $comment::$databaseColumnMap['rating'];
|
||||
if ( $comment->$ratingField != $values['rating_value'] )
|
||||
{
|
||||
$reloadPage = true;
|
||||
}
|
||||
|
||||
$comment->editRating( $values['rating_value'] );
|
||||
}
|
||||
|
||||
/* 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 );
|
||||
|
||||
/* If this is an AJAX request and the comment hidden status has not changed just output the comment HTML */
|
||||
if ( \IPS\Request::i()->isAjax() AND $isHidden == $comment->hidden() )
|
||||
if ( \IPS\Request::i()->isAjax() AND $isHidden == $comment->hidden() AND $reloadPage === false )
|
||||
{
|
||||
\IPS\Output::i()->output = $comment->html();
|
||||
return;
|
||||
@@ -2083,7 +2345,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new \UnderflowException;
|
||||
\IPS\Output::i()->error( 'node_noperm_delete', '3S136/1L', 403, '' );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2147,7 +2409,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new \UnexpectedValueException;
|
||||
\IPS\Output::i()->error( 'node_noperm_delete', '3S136/1K', 403, '' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2340,9 +2602,9 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
|
||||
/* Permission check */
|
||||
$canReport = $comment->canReport();
|
||||
if ( $canReport !== TRUE )
|
||||
if ( $canReport !== TRUE AND !( $canReport == 'report_err_already_reported' AND \IPS\Settings::i()->automoderation_enabled ) )
|
||||
{
|
||||
\IPS\Output::i()->error( $canReport, '2S136/4', 404, '' );
|
||||
\IPS\Output::i()->error( $canReport, '2S136/4', 403, '' );
|
||||
}
|
||||
|
||||
/* Show form */
|
||||
@@ -2350,6 +2612,30 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
$form->class = 'ipsForm_vertical';
|
||||
$itemIdColumn = $class::$databaseColumnId;
|
||||
$idColumn = $comment::$databaseColumnId;
|
||||
|
||||
/* As we group by user id to determine if max points have been reached, guests cannot contribute to counts */
|
||||
if ( \IPS\Member::loggedIn()->member_id and \IPS\Settings::i()->automoderation_enabled )
|
||||
{
|
||||
/* Has this member already reported this in the past 24 hours */
|
||||
try
|
||||
{
|
||||
$index = \IPS\core\Reports\Report::loadByClassAndId( get_class( $comment ), $comment->$idColumn );
|
||||
$report = \IPS\Db::i()->select( '*', 'core_rc_reports', array( 'rid=? and report_by=? and date_reported > ?', $index->id, \IPS\Member::loggedIn()->member_id, time() - ( \IPS\Settings::i()->automoderation_report_again_mins * 60 ) ) )->first();
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'system', 'core' )->reportedAlready( $index, $report, $comment );
|
||||
return;
|
||||
}
|
||||
catch( \Exception $e ) { }
|
||||
|
||||
$options = array( \IPS\core\Reports\Report::TYPE_MESSAGE => \IPS\Member::loggedIn()->language()->addToStack('report_message_comment') );
|
||||
foreach( \IPS\core\Reports\Types::roots() as $type )
|
||||
{
|
||||
$options[ $type->id ] = $type->_title;
|
||||
}
|
||||
|
||||
$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->$itemIdColumn}-{$comment->$idColumn}", 'minimize' => 'report_message_placeholder' ) ) );
|
||||
if( !\IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
@@ -2358,7 +2644,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$report = $comment->report( $values['report_message'] );
|
||||
$report = $comment->report( $values['report_message'], ( isset( $values['report_type'] ) ) ? $values['report_type'] : 0 );
|
||||
\IPS\File::claimAttachments( "report-{$class::$application}-{$class::$module}-{$item->$itemIdColumn}-{$comment->$idColumn}", $report->id );
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
@@ -2438,6 +2724,10 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
protected function _feature( $commentClass, $comment, $item )
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
if ( !$item->canFeatureComment() )
|
||||
{
|
||||
throw new \DomainException;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
@@ -2548,6 +2838,10 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
protected function _unfeature( $commentClass, $comment, $item )
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
if ( !$item->canUnfeatureComment() )
|
||||
{
|
||||
throw new \DomainException;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
@@ -2625,6 +2919,8 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
{
|
||||
$url = $url->setQueryString( 'reaction', $activeTab );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->metaTags['robots'] = 'noindex';
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() AND isset( \IPS\Request::i()->changed ) )
|
||||
{
|
||||
@@ -2647,6 +2943,19 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
protected function _multimod( $commentClass, $item )
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
$checkAgainst = \IPS\Request::i()->modaction;
|
||||
|
||||
if( $checkAgainst == 'split' OR $checkAgainst == 'merge' )
|
||||
{
|
||||
$checkAgainst = 'split_merge';
|
||||
}
|
||||
|
||||
if ( !$item::modPermission( $checkAgainst, NULL, $item->containerWrapper() ) )
|
||||
{
|
||||
throw new \DomainException;
|
||||
}
|
||||
|
||||
if ( \IPS\Request::i()->modaction == 'split' )
|
||||
{
|
||||
$form = $this->_splitForm( $item );
|
||||
@@ -2678,6 +2987,13 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
$firstComment = $comment;
|
||||
break;
|
||||
}
|
||||
|
||||
/* If we don't have a $firstComment, something went wrong - perhaps the input multimod comment ids are all from a different topic for instance */
|
||||
if( !isset( $firstComment ) )
|
||||
{
|
||||
$form->error = \IPS\Member::loggedIn()->language()->addToStack( 'mod_error_invalid_action' );
|
||||
goto splitFormError;
|
||||
}
|
||||
|
||||
if ( isset( $values['_split_type'] ) and $values['_split_type'] === 'new' )
|
||||
{
|
||||
@@ -2770,6 +3086,8 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Label for goto command */
|
||||
splitFormError:
|
||||
$this->_setBreadcrumbAndTitle( $item );
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core' ) ), 'popupTemplate' ) );
|
||||
|
||||
@@ -2830,7 +3148,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
\IPS\Db::i()->update( 'core_attachments_map', array(
|
||||
'id1' => $item->$idColumn,
|
||||
'id2' => $firstComment->$commentIdColumn,
|
||||
), array( 'location_key=? AND id1=? AND id2=?', (string) $item::$application . '_' . ucfirst( $item::$module ), $item->$idColumn, $comment->$commentIdColumn ) );
|
||||
), array( 'location_key=? AND id1=? AND id2=?', (string) $item::$application . '_' . mb_ucfirst( $item::$module ), $item->$idColumn, $comment->$commentIdColumn ) );
|
||||
|
||||
/* Merge likes */
|
||||
if ( \IPS\IPS::classUsesTrait( $commentClass, 'IPS\Content\Reactable' ) )
|
||||
@@ -2843,6 +3161,12 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
catch( \Exception $e ) {}
|
||||
}
|
||||
|
||||
/* Fix duplicated reactions */
|
||||
if ( \IPS\IPS::classUsesTrait( $commentClass, 'IPS\Content\Reactable' ) )
|
||||
{
|
||||
\IPS\Db::i()->query( 'DELETE row1 FROM ' . \IPS\Db::i()->prefix . 'core_reputation_index row1, ' . \IPS\Db::i()->prefix . 'core_reputation_index row2 WHERE row1.id > row2.id AND row1.member_id = row2.member_id AND row1.app = \'' . $item::$application . '\' AND row1.type = \'' . $comment::reactionType() . '\' AND row1.type_id = row2.type_id' );
|
||||
}
|
||||
|
||||
$item->rebuildFirstAndLastCommentData();
|
||||
|
||||
/* Log it */
|
||||
@@ -2999,7 +3323,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
if ( $item::canCreate( \IPS\Member::loggedIn(), $container ) )
|
||||
if ( $item::canCreate( \IPS\Member::loggedIn() ) )
|
||||
{
|
||||
$toAdd = array();
|
||||
$toggles = array();
|
||||
@@ -3008,7 +3332,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
{
|
||||
if ( !in_array( $k, array( 'poll', 'content', 'comment_edit_reason', 'comment_log_edit' ) ) )
|
||||
{
|
||||
if ( $k === 'container' )
|
||||
if ( $k === 'container' AND ( $container AND $container->can( 'add' ) ) )
|
||||
{
|
||||
$field->defaultValue = $container;
|
||||
if ( !$field->value )
|
||||
@@ -3037,23 +3361,61 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
|
||||
foreach ( $toAdd as $field )
|
||||
{
|
||||
if ( $field->name == $item::$formLangPrefix . 'container' )
|
||||
{
|
||||
/* Add a custom permission check for splitting comments */
|
||||
$field->options['permissionCheck'] = function( $node ) use ( $item )
|
||||
{
|
||||
try
|
||||
{
|
||||
/* If the item is in a club, only allow moving to other clubs that you moderate */
|
||||
if ( \IPS\IPS::classUsesTrait( $item->container(), 'IPS\Content\ClubContainer' ) and $item->container()->club() )
|
||||
{
|
||||
return $item::modPermission( 'move', \IPS\Member::loggedIn(), $node ) and $node->can( 'add' ) ;
|
||||
}
|
||||
|
||||
if ( $node->can( 'add' ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch( \OutOfBoundsException $e ) { }
|
||||
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
$form->add( $field );
|
||||
}
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\Url( '_split_into_url', NULL, FALSE, array(), function ( $val ) use ( $item )
|
||||
{
|
||||
try
|
||||
if ( \IPS\Request::i()->_split_type == 'existing' OR !isset( \IPS\Request::i()->_split_type ) )
|
||||
{
|
||||
if ( $val )
|
||||
try
|
||||
{
|
||||
$item::loadFromUrl( $val );
|
||||
/* Validate the URL */
|
||||
$test = $item::loadFromUrl( $val );
|
||||
|
||||
/* Make sure the URL matches the content type we're splitting */
|
||||
foreach( array( 'app', 'module', 'controller') as $index )
|
||||
{
|
||||
if( $test->url()->hiddenQueryString[ $index ] != $val->hiddenQueryString[ $index ] )
|
||||
{
|
||||
throw new \InvalidArgumentException;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'form_url_bad_item', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( '__defart_' . $item::$title ) ) ) ) );
|
||||
}
|
||||
|
||||
if( !$test->canMerge() )
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'no_merge_permission', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( '__defart_' . $item::$title ) ) ) ) );
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'form_url_bad_item', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $item::$title ) ) ) ) );
|
||||
}
|
||||
|
||||
}, NULL, NULL, 'split_into_url' ) );
|
||||
|
||||
return $form;
|
||||
@@ -3079,7 +3441,7 @@ class _Controller extends \IPS\Helpers\CoverPhoto\Controller
|
||||
$class = static::$contentModel;
|
||||
$item = $class::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
|
||||
if( $item->tags() === NULL AND $item->prefix( FALSE ) === NULL )
|
||||
if( !$item instanceof \IPS\Content\Tags OR ( $item->tags() === NULL AND $item->prefix( FALSE ) === NULL ) )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user