Version 4.3.0

This commit is contained in:
Neo committed 2025-12-19 05:47:12 -08:00
1 parent 96997ddd8e
commit fe1acf984a
1349 files changed
+116159 -67711

No files matched your search

@@ -58,7 +58,15 @@ class _topic extends \IPS\Dispatcher\Controller
'database' => array( $this, '_database' ),
'category' => array( $this, '_category' ),
), \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&id=" . \IPS\Request::i()->id, 'front', 'topic_copy', $this->topic->title_seo ), FALSE );
/* Set Breadcrumb */
foreach ( $this->topic->container()->parents() as $parent )
{
\IPS\Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
}
\IPS\Output::i()->breadcrumb[] = array( $this->topic->container()->url(), $this->topic->container()->_title );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'copy_topic_to_database' );
\IPS\Output::i()->output = (string) $wizard;
}
@@ -152,12 +160,21 @@ class _topic extends \IPS\Dispatcher\Controller
$contentField = "field_{$database->field_content}";
$fakeRecord = new $recordClass;
$fakeRecord->$titleField = $this->topic->mapped('title');
$fakeRecord->$contentField = $this->topic->content();
$fakeRecord->$titleField = $this->topic->mapped('title');
$fakeRecord->$contentField = $this->topic->content();
$fakeRecord->category_id = \IPS\Request::i()->category_id;
if( $fakeRecord->_forum_record AND $fakeRecord->_forum_comments )
{
\IPS\Member::loggedIn()->language()->words['copy_comments_desc'] = sprintf( \IPS\Member::loggedIn()->language()->get( 'copy_comments_assoc_desc' ), $recordClass::_definiteArticle(), $recordClass::_definiteArticle() );
}
else
{
\IPS\Member::loggedIn()->language()->words['copy_comments_desc'] = sprintf( \IPS\Member::loggedIn()->language()->get( 'copy_comments_desc' ), $recordClass::_definiteArticle() );
}
\IPS\Member::loggedIn()->language()->words['copy_comments_desc'] = sprintf( \IPS\Member::loggedIn()->language()->get( 'copy_comments_desc' ), $recordClass::_definiteArticle() );
\IPS\Member::loggedIn()->language()->words['copy_author_desc'] = sprintf( \IPS\Member::loggedIn()->language()->get( 'copy_author_desc' ), $recordClass::_definiteArticle() );
$form = new \IPS\Helpers\Form;
$form->class = 'ipsForm_vertical';
$form->hiddenValues['record_category_id'] = $category->_id;
@@ -175,7 +192,14 @@ class _topic extends \IPS\Dispatcher\Controller
if ( $database->options['comments'] )
{
$form->add( new \IPS\Helpers\Form\YesNo( 'copy_comments', FALSE ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'copy_comments', FALSE, FALSE, array( 'togglesOn' => array( 'comments_show_message' ) ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'comments_show_message', TRUE, FALSE, array( 'togglesOn' => array( 'comments_meta_message', 'comments_meta_color' ) ), NULL, NULL, NULL, 'comments_show_message' ) );
$form->add( new \IPS\Helpers\Form\Editor( 'comments_meta_message', \IPS\Member::loggedIn()->language()->addToStack('default_copyposts_message'), FALSE, array( 'app' => 'core', 'key' => 'Meta', 'autoSaveKey' => "meta-message-new", 'attachIds' => NULL ), NULL, NULL, NULL, 'comments_meta_message' ) );
$form->add( new \IPS\Helpers\Form\Custom( 'comments_meta_color', 'none', FALSE, array( 'getHtml' => function( $element )
{
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'front' )->colorSelection( $element->name, $element->value );
} ), NULL, NULL, NULL, 'comments_meta_color' ) );
}
$form->add( new \IPS\Helpers\Form\YesNo( 'copy_author', TRUE ) );
@@ -188,9 +212,29 @@ class _topic extends \IPS\Dispatcher\Controller
$comments = $values['copy_comments'];
unset( $values['copy_comments'] );
}
/* Determine if we are showing a meta message after */
$metaMessage = NULL;
/* We will only be sowing the message if we are copying comments */
if( $comments )
{
if ( array_key_exists( 'comments_show_message', $values ) )
{
$metaMessage = array( 'show' => $values['comments_show_message'], 'message' => $values['comments_meta_message'], 'color' => $values['comments_meta_color'] );
}
}
unset( $values['comments_show_message'], $values['comments_meta_message'], $values['comments_meta_color'] );
/* Figure out author */
$author = $values['copy_author'];
unset( $values['copy_author'] );
/* If we are copying comments and we use the forums for comments, skip creating a topic as we will just reassocciate */
if( $comments AND $fakeRecord->_forum_record AND $fakeRecord->_forum_comments )
{
$recordClass::$skipTopicCreation = true;
}
$record = $recordClass::createFromForm( $values, $category );
@@ -198,10 +242,40 @@ class _topic extends \IPS\Dispatcher\Controller
{
$record->changeAuthor( $this->topic->author() );
}
if ( $comments )
if( $metaMessage !== NULL )
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&do=comments&id={$this->topic->tid}", 'front', 'topic_copy', $this->topic->title_seo )->setQueryString( array( 'record_id' => $record->primary_id_field, 'database_id' => $database->_id ) ) );
if( $metaMessage['show'] )
{
$id = $record->addMessage( $metaMessage['message'], $metaMessage['color'] );
\IPS\File::claimAttachments( "meta-message-new", $id, NULL, 'core_ContentMessages' );
}
}
/* If the record syncs with the forums and we are copying topics, just associate with the existing topic */
if( $comments AND $record->_forum_record AND $record->_forum_comments )
{
$record->record_topicid = $this->topic->tid;
$record->save();
/* Reload using the proper class so first and last comment data can be rebuilt properly */
$class = 'IPS\cms\Records\RecordsTopicSync' . $database->_id;
$class::load( $this->topic->tid )->rebuildFirstAndLastCommentData();
try
{
/* If the database is on a page, go to the record */
\IPS\Output::i()->redirect( $record->url() );
}
catch( \LogicException $e )
{
/* If it is NOT then go back to the topic */
\IPS\Output::i()->redirect( $this->topic->url() );
}
}
elseif ( $comments )
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&do=comments&id={$this->topic->tid}", 'front', 'topic_copy', $this->topic->title_seo )->csrf()->setQueryString( array( 'record_id' => $record->primary_id_field, 'database_id' => $database->_id ) ) );
}
else
{
@@ -257,7 +331,9 @@ class _topic extends \IPS\Dispatcher\Controller
*/
protected function comments()
{
$mr = new \IPS\Helpers\MultipleRedirect( \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&id=" . \IPS\Request::i()->id . "&do=comments", 'front', 'topic_copy', $this->topic->title_seo )->setQueryString( array( 'database_id' => \IPS\Request::i()->database_id, 'record_id' => \IPS\Request::i()->record_id ) ), function( $data ) {
\IPS\Session::i()->csrfCheck();
$mr = new \IPS\Helpers\MultipleRedirect( \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&id=" . \IPS\Request::i()->id . "&do=comments", 'front', 'topic_copy', $this->topic->title_seo )->csrf()->setQueryString( array( 'database_id' => \IPS\Request::i()->database_id, 'record_id' => \IPS\Request::i()->record_id ) ), function( $data ) {
$database = \IPS\cms\Databases::load( \IPS\Request::i()->database_id );
$recordClass = 'IPS\cms\Records' . \IPS\Request::i()->database_id;
$commentClass = $recordClass::$commentClass;