Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

@@ -12,16 +12,36 @@
namespace IPS\convert\Software\Forums;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use DomainException;
use Exception;
use InvalidArgumentException;
use IPS\Application;
use IPS\Content;
use IPS\convert\App;
use IPS\convert\Library;
use IPS\convert\Software;
use IPS\Db;
use IPS\Http\Url;
use IPS\Member;
use IPS\Node\Model;
use IPS\Request;
use IPS\Task;
use OutOfRangeException;
use UnderflowException;
use function defined;
use function stristr;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Invision Forums Converter
*/
class _Invisioncommunity extends \IPS\convert\Software
class Invisioncommunity extends Software
{
/**
* @brief Whether the versions of IPS4 match
@@ -36,15 +56,15 @@ class _Invisioncommunity extends \IPS\convert\Software
/**
* Constructor
*
* @param \IPS\convert\App $app The application to reference for database and other information.
* @param App $app The application to reference for database and other information.
* @param bool $needDB Establish a DB connection
* @return void
* @throws \InvalidArgumentException
* @throws InvalidArgumentException
*/
public function __construct( \IPS\convert\App $app, $needDB=TRUE )
public function __construct( App $app, $needDB=TRUE )
{
/* Set filename obscuring flag */
\IPS\convert\Library::$obscureFilenames = FALSE;
Library::$obscureFilenames = FALSE;
$return = parent::__construct( $app, $needDB );
@@ -57,7 +77,7 @@ class _Invisioncommunity extends \IPS\convert\Software
$version = $this->db->select( 'app_version', 'core_applications', array( 'app_directory=?', 'core' ) )->first();
/* We're matching against the human version since the long version can change with patches */
if ( $version == \IPS\Application::load( 'core' )->version )
if ( $version == Application::load( 'core' )->version )
{
static::$versionMatch = TRUE;
}
@@ -79,7 +99,7 @@ class _Invisioncommunity extends \IPS\convert\Software
public static function softwareName()
{
/* Child classes must override this method */
return 'Invision Community (' . \IPS\Application::load( 'core' )->version . ')';
return 'Invision Community (' . Application::load( 'core' )->version . ')';
}
/**
@@ -163,9 +183,9 @@ class _Invisioncommunity extends \IPS\convert\Software
{
return $this->db->select( 'COUNT(*)', 'core_rss_imported', array( 'rss_imported_import_id IN(' . (string) $this->db->select( 'rss_import_id', 'core_rss_import', array( "rss_import_class='IPS\\forums\\Topic'" ) ) . ')' ) )->first();
}
catch( \Exception $e )
catch( Exception $e )
{
throw new \IPS\convert\Exception( sprintf( \IPS\Member::loggedIn()->language()->get( 'could_not_count_rows' ), $table ) );
throw new \IPS\convert\Exception( sprintf( Member::loggedIn()->language()->get( 'could_not_count_rows' ), $table ) );
}
break;
@@ -210,16 +230,16 @@ class _Invisioncommunity extends \IPS\convert\Software
switch( $method )
{
case 'convertAttachments':
\IPS\Member::loggedIn()->language()->words["upload_path"] = \IPS\Member::loggedIn()->language()->addToStack( 'convert_invision_upload_input' );
\IPS\Member::loggedIn()->language()->words["upload_path_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'convert_invision_upload_input_desc' );
Member::loggedIn()->language()->words["upload_path"] = Member::loggedIn()->language()->addToStack( 'convert_invision_upload_input' );
Member::loggedIn()->language()->words["upload_path_desc"] = Member::loggedIn()->language()->addToStack( 'convert_invision_upload_input_desc' );
$return[ $method ] = array(
'upload_path' => array(
'field_class' => 'IPS\\Helpers\\Form\\Text',
'field_default' => isset( $this->parent->app->_session['more_info']['convertEmoticons']['upload_path'] ) ? $this->parent->app->_session['more_info']['convertEmoticons']['upload_path'] : NULL,
'field_required' => TRUE,
'field_extra' => array(),
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack('convert_invision_upload_path'),
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
'field_hint' => Member::loggedIn()->language()->addToStack('convert_invision_upload_path'),
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new DomainException( 'path_invalid' ); } },
)
);
break;
@@ -246,18 +266,18 @@ class _Invisioncommunity extends \IPS\convert\Software
public function finish()
{
/* Content Rebuilds */
\IPS\Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\forums\Forum', 'count' => 0 ), 4, array( 'class' ) );
\IPS\Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\forums\Topic' ), 3, array( 'class' ) );
\IPS\Task::queue( 'convert', 'RebuildFirstPostIds', array( 'app' => $this->app->app_id ), 2, array( 'app' ) );
\IPS\Task::queue( 'convert', 'DeleteEmptyTopics', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
\IPS\Task::queue( 'convert', 'InvisionCommunityRebuildContent', array( 'app' => $this->app->app_id, 'link' => 'forums_posts', 'class' => 'IPS\forums\Topic\Post' ), 2, array( 'app', 'link', 'class' ) );
Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\forums\Forum', 'count' => 0 ), 4, array( 'class' ) );
Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\forums\Topic' ), 3, array( 'class' ) );
Task::queue( 'convert', 'RebuildFirstPostIds', array( 'app' => $this->app->app_id ), 2, array( 'app' ) );
Task::queue( 'convert', 'DeleteEmptyTopics', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
Task::queue( 'convert', 'InvisionCommunityRebuildContent', array( 'app' => $this->app->app_id, 'link' => 'forums_posts', 'class' => 'IPS\forums\Topic\Post' ), 2, array( 'app', 'link', 'class' ) );
/* Caches */
\IPS\Task::queue( 'convert', 'RebuildTagCache', array( 'app' => $this->app->app_id, 'link' => 'forums_topics', 'class' => 'IPS\forums\Topic' ), 3, array( 'app', 'link', 'class' ) );
Task::queue( 'convert', 'RebuildTagCache', array( 'app' => $this->app->app_id, 'link' => 'forums_topics', 'class' => 'IPS\forums\Topic' ), 3, array( 'app', 'link', 'class' ) );
/* Rebuild Leaderboard */
\IPS\Task::queue( 'core', 'RebuildReputationLeaderboard', array(), 4 );
\IPS\Db::i()->delete('core_reputation_leaderboard_history');
Task::queue( 'core', 'RebuildReputationLeaderboard', array(), 4 );
Db::i()->delete('core_reputation_leaderboard_history');
return array( "f_forum_last_post_data", "f_rebuild_posts", "f_recounting_forums", "f_recounting_topics", "f_topic_tags_recount" );
}
@@ -495,7 +515,7 @@ class _Invisioncommunity extends \IPS\convert\Software
{
$libraryClass = $this->getLibrary();
foreach( $this->fetch( 'core_rss_imported', 'rss_imported_content_id', array( 'rss_imported_id IN(' . (string) \IPS\Db::i()->select( 'rss_import_id', 'core_rss_import', array( "rss_import_class='IPS\\forums\\Topic'" ) ) . ')' ) ) AS $row )
foreach( $this->fetch( 'core_rss_imported', 'rss_imported_content_id', array( 'rss_imported_id IN(' . (string) Db::i()->select( 'rss_import_id', 'core_rss_import', array( "rss_import_class='IPS\\forums\\Topic'" ) ) . ')' ) ) AS $row )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $row, 'core_rss_imported', 'core' );
@@ -520,7 +540,7 @@ class _Invisioncommunity extends \IPS\convert\Software
{
$attachmentMap = $this->db->select( '*', 'core_attachments_map', array( 'attachment_id=? AND location_key=?', $row['attach_id'], 'forums_Forums' ) )->first();
}
catch( \UnderflowException $e )
catch( UnderflowException $e )
{
$libraryClass->setLastKeyValue( $row['attach_id'] );
continue;
@@ -549,19 +569,19 @@ class _Invisioncommunity extends \IPS\convert\Software
/**
* Check if we can redirect the legacy URLs from this software to the new locations
*
* @return NULL|\IPS\Http\Url
* @return NULL|Url
*/
public function checkRedirects()
{
$url = \IPS\Request::i()->url();
$url = Request::i()->url();
if( !\stristr( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'ic-merge-' . $this->app->_parent->app_id ) )
if( !stristr( $url->data[ Url::COMPONENT_PATH ], 'ic-merge-' . $this->app->_parent->app_id ) )
{
return NULL;
}
/* account for non-mod_rewrite links */
$searchOn = \stristr( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'index.php' ) ? $url->data[ \IPS\Http\Url::COMPONENT_QUERY ] : $url->data[ \IPS\Http\Url::COMPONENT_PATH ];
$searchOn = stristr( $url->data[ Url::COMPONENT_PATH ], 'index.php' ) ? $url->data[ Url::COMPONENT_QUERY ] : $url->data[ Url::COMPONENT_PATH ];
if( preg_match( '#/(forum|topic)/([0-9]+)-(.+?)#i', $searchOn, $matches ) )
{
@@ -578,11 +598,11 @@ class _Invisioncommunity extends \IPS\convert\Software
$class = '\IPS\forums\Topic';
$types = array( 'topics', 'forums_topics' );
if( \IPS\Request::i()->do == 'findComment' AND \IPS\Request::i()->comment )
if( Request::i()->do == 'findComment' AND Request::i()->comment )
{
$class = '\IPS\forums\Topic\Post';
$types = array( 'posts', 'forums_posts' );
$oldId = \IPS\Request::i()->comment;
$oldId = Request::i()->comment;
}
break;
}
@@ -596,20 +616,20 @@ class _Invisioncommunity extends \IPS\convert\Software
{
$data = (string) $this->app->getLink( $oldId, $types );
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException $e )
{
$data = (string) $this->app->getLink( $oldId, $types, FALSE, TRUE );
}
$item = $class::load( $data );
if( $item instanceof \IPS\Content )
if( $item instanceof Content )
{
if( $item->canView() )
{
return $item->url();
}
}
elseif( $item instanceof \IPS\Node\Model )
elseif( $item instanceof Model )
{
if( $item->can( 'view' ) )
{
@@ -617,7 +637,7 @@ class _Invisioncommunity extends \IPS\convert\Software
}
}
}
catch( \Exception $e )
catch( Exception $e )
{
return NULL;
}