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,30 @@
namespace IPS\convert\Software\Forums;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use Exception;
use IPS\Content;
use IPS\convert\Software;
use IPS\convert\Software\Core\Punbb;
use IPS\Http\Url;
use IPS\Node\Model;
use IPS\Request;
use IPS\Task;
use OutOfRangeException;
use UnderflowException;
use function defined;
use function is_null;
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;
}
/**
* PunBB Forums Converter
*/
class _Punbb extends \IPS\convert\Software
class Punbb extends Software
{
/**
* Software Name
@@ -96,24 +110,26 @@ class _Punbb 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( 'convert', 'RebuildContent', array( 'app' => $this->app->app_id, 'link' => 'forums_posts', 'class' => 'IPS\forums\Topic\Post' ), 2, array( 'app', 'link', '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' ) );
Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\forums\Forum', 'count' => 0 ), 4, array( 'class' ) );
Task::queue( 'convert', 'RebuildContent', array( 'app' => $this->app->app_id, 'link' => 'forums_posts', 'class' => 'IPS\forums\Topic\Post' ), 2, array( 'app', 'link', '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' ) );
return array( "f_forum_last_post_data", "f_rebuild_posts", "f_recounting_forums", "f_recounting_topics" );
}
/**
* Fix post data
* Pre-process content for the Invision Community text parser
*
* @param string $post Raw post data
* @return string Parsed post data
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @return string The converted post
*/
public static function fixPostData( $post )
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
{
return \IPS\convert\Software\Core\Punbb::fixPostData( $post );
return Punbb::fixPostData( $post, $className, $contentId );
}
/**
@@ -134,7 +150,7 @@ class _Punbb extends \IPS\convert\Software
{
$catId = $this->app->getLink( '1000' . $row['cat_id'], 'forums_forums' );
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException $e )
{
try
{
@@ -147,7 +163,7 @@ class _Punbb extends \IPS\convert\Software
'position' => $category['disp_position']
) );
}
catch( \UnderflowException $e ) {}
catch( UnderflowException $e ) {}
}
/* They don't store the last poster ID. Makes me sad. */
@@ -157,7 +173,7 @@ class _Punbb extends \IPS\convert\Software
/* Better hope they haven't changed their name */
$last_poster_id = $this->db->select( 'id', 'users', array( "username=?", $row['last_poster'] ) )->first();
}
catch( \UnderflowException $e ) {}
catch( UnderflowException $e ) {}
$info = array(
'id' => $row['id'],
@@ -198,14 +214,14 @@ class _Punbb extends \IPS\convert\Software
{
$last_poster_id = $this->db->select( 'id', 'users', array( "username=?", $row['last_poster'] ) )->first();
}
catch( \UnderflowException $e ) {}
catch( UnderflowException $e ) {}
$starter_id = 0;
try
{
$starter_id = $this->db->select( 'id', 'users', array( "username=?", $row['poster'] ) )->first();
}
catch( \UnderflowException $e ) {}
catch( UnderflowException $e ) {}
$moved_to = NULL;
if ( $row['moved_to'] )
@@ -215,7 +231,7 @@ class _Punbb extends \IPS\convert\Software
$moved_to_forum = $this->db->select( 'forum_id', 'topics', array( "id=?", $row['moved_to'] ) )->first();
$moved_to = [ $row['moved_to'], $moved_to_forum ];
}
catch( \UnderflowException $e ) {}
catch( UnderflowException $e ) {}
}
$info = array(
@@ -232,7 +248,7 @@ class _Punbb extends \IPS\convert\Software
'last_poster_name' => $row['last_poster'],
'pinned' => ( $row['sticky'] OR $row['announcement'] ) ? 1 : 0,
'moved_to' => $moved_to,
'moved_on' => ( !\is_null( $moved_to ) ) ? $row['posted'] : 0,
'moved_on' => ( !is_null( $moved_to ) ) ? $row['posted'] : 0,
);
$libraryClass->convertForumsTopic( $info );
@@ -294,32 +310,32 @@ class _Punbb 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( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'viewtopic.php' ) !== FALSE )
if( mb_strpos( $url->data[ Url::COMPONENT_PATH ], 'viewtopic.php' ) !== FALSE )
{
if( isset( \IPS\Request::i()->pid ) )
if( isset( Request::i()->pid ) )
{
$class = '\IPS\forums\Topic\Post';
$types = array( 'posts', 'forums_posts' );
$oldId = \IPS\Request::i()->pid;
$oldId = Request::i()->pid;
}
else
{
$class = '\IPS\forums\Topic';
$types = array( 'topics', 'forums_topics' );
$oldId = \IPS\Request::i()->id;
$oldId = Request::i()->id;
}
}
elseif( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'viewforum.php' ) !== FALSE )
elseif( mb_strpos( $url->data[ Url::COMPONENT_PATH ], 'viewforum.php' ) !== FALSE )
{
$class = '\IPS\forums\Forum';
$types = array( 'forums', 'forums_forums' );
$oldId = \IPS\Request::i()->id;
$oldId = Request::i()->id;
}
if( isset( $class ) )
@@ -330,20 +346,20 @@ class _Punbb 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' ) )
{
@@ -351,7 +367,7 @@ class _Punbb extends \IPS\convert\Software
}
}
}
catch( \Exception $e )
catch( Exception $e )
{
return NULL;
}