Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

@@ -5,7 +5,7 @@
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @package Invision Community
* @subpackage Converter
* @subpackage convert
* @since 21 Jan 2015
* @todo SMF supports karma which we should be able to convert to reactions (reputation), but we need a sample database that used karma
*/
@@ -13,12 +13,15 @@
namespace IPS\convert\Software\Forums;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* SMF Forums Converter
*/
class _Smf extends \IPS\convert\Software
{
/**
@@ -78,14 +81,20 @@ class _Smf extends \IPS\convert\Software
/**
* Allows software to add additional menu row options
*
* @param array $rows Existing rows
* @return array
*/
public function extraMenuRows( $rows )
public function extraMenuRows()
{
$rows['convertForumsBoards'] = $rows['convertForumsForums'];
$rows['convertForumsBoards']['step_method'] = 'convertForumsBoards';
$rows['convertForumsBoards']['source_rows'] = array( 'table' => static::canConvert()['convertForumsBoards']['table'], 'where' => static::canConvert()['convertForumsBoards']['where'] );
$rows = array();
$rows['convertForumsBoards'] = array(
'step_title' => 'convert_forums_forums',
'step_method' => 'convertForumsBoards',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'forums_forums' ),
'source_rows' => array( 'table' => static::canConvert()['convertForumsBoards']['table'], 'where' => static::canConvert()['convertForumsBoards']['where'] ),
'per_cycle' => 200,
'dependencies' => array( 'convertForumsForums' ),
'link_type' => 'forums_forums',
);
return $rows;
}
@@ -104,7 +113,14 @@ class _Smf extends \IPS\convert\Software
switch( $table )
{
case 'forums':
return $this->db->select( 'COUNT(*)', 'categories' )->first() + $this->db->select( 'COUNT(*)', 'boards' )->first();
try
{
return $this->db->select( 'COUNT(*)', 'categories' )->first() + $this->db->select( 'COUNT(*)', 'boards' )->first();
}
catch( \Exception $e )
{
throw new \IPS\convert\Exception( sprintf( \IPS\Member::loggedIn()->language()->get( 'could_not_count_rows' ), $table ) );
}
break;
default:
@@ -182,11 +198,11 @@ class _Smf extends \IPS\convert\Software
public function finish()
{
/* Content Rebuilds */
\IPS\Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\forums\Forum', 'count' => 0 ), 5, array( 'class' ) );
\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 ), 4, array( 'app' ) );
\IPS\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" );
}
@@ -194,8 +210,8 @@ class _Smf extends \IPS\convert\Software
/**
* Fix post data
*
* @param string raw post data
* @return string parsed post data
* @param string $post Raw post data
* @return string Parsed post data
*/
public static function fixPostData( $post )
{
@@ -267,6 +283,7 @@ class _Smf extends \IPS\convert\Software
'redirect_url' => $row['redirect'],
'queued_topics' => $row['unapproved_topics'],
'queued_posts' => $row['unapproved_posts'],
'sub_can_post' => 1
);
$libraryClass->convertForumsForum( $info );
@@ -334,7 +351,12 @@ class _Smf extends \IPS\convert\Software
$poll = array(
'poll_data' => array(
'pid' => $poll_data['id_poll'],
'choices' => $choices,
'choices' => array( 1 => array(
'question' => $poll_data['question'],
'multi' => 0,
'choice' => $choices,
'votes' => $votes,
) ),
'poll_question' => $poll_data['question'],
'start_date' => $firstPost['poster_time'],
'starter_id' => $poll_data['id_member'],
@@ -431,14 +453,14 @@ class _Smf extends \IPS\convert\Software
*/
public function convertAttachments()
{
if ( is_null( static::$paths ) )
if ( \is_null( static::$paths ) )
{
try
{
static::$paths = @\unserialize( $this->db->select( 'value', 'settings', array( "variable=?", 'attachmentUploadDir' ) )->first() );
/* Unserialize failed. Set to an array so we don't try again */
if ( !is_array( static::$paths ) )
if ( !\is_array( static::$paths ) )
{
static::$paths = array();
}
@@ -497,8 +519,8 @@ class _Smf extends \IPS\convert\Software
$row['filename'] = str_replace(']', '', $row['filename']);
$row['filename'] = str_replace('&', '', $row['filename']);
$row['filename'] = str_replace('\'', '', $row['filename']);
$row['filename'] = str_replace( chr(195) . chr(182) , 'A', $row['filename']);
$row['filename'] = str_replace( chr(195) . chr(164) , 'A', $row['filename']);
$row['filename'] = str_replace( \chr(195) . \chr(182) , 'A', $row['filename']);
$row['filename'] = str_replace( \chr(195) . \chr(164) , 'A', $row['filename']);
/* General Information */
$info = array(
@@ -526,6 +548,16 @@ class _Smf extends \IPS\convert\Software
$path = rtrim( $this->app->_session['more_info']['convertAttachments']['attach_location'], '/' ) . '/' . $location;
}
}
// in 2.1 attachments are stored with a .dat extension, so we need to look for it if this path doesn't exist.
if( !file_exists( $path ) )
{
/* Check the 2.1 file */
if( file_exists( $path . '.dat' ) )
{
$path .= '.dat';
}
}
$libraryClass->convertAttachment( $info, $map, $path );