Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -1,23 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @brief Converter BBPress Class
|
||||
* @brief Converter bbPress Class
|
||||
* @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 Nov 2016
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* BBPress Forums Converter
|
||||
*/
|
||||
class _Bbpress extends \IPS\convert\Software
|
||||
{
|
||||
/**
|
||||
@@ -28,7 +31,7 @@ class _Bbpress extends \IPS\convert\Software
|
||||
public static function softwareName()
|
||||
{
|
||||
/* Child classes must override this method */
|
||||
return "BBPress (for WordPress)";
|
||||
return "bbPress (for WordPress)";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,11 +96,11 @@ class _Bbpress 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" );
|
||||
}
|
||||
@@ -129,9 +132,7 @@ class _Bbpress extends \IPS\convert\Software
|
||||
}
|
||||
|
||||
/**
|
||||
* User cache to minimise repeated DB lookups
|
||||
*
|
||||
* @var array $userCache
|
||||
* @brief User cache to minimise repeated DB lookups
|
||||
*/
|
||||
protected static $userCache = array();
|
||||
|
||||
|
||||
@@ -5,19 +5,22 @@
|
||||
* @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 17 June 2016
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* ExpressionEngine Forums Converter
|
||||
*/
|
||||
class _Expressionengine extends \IPS\convert\Software
|
||||
{
|
||||
/**
|
||||
@@ -77,14 +80,21 @@ class _Expressionengine 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['convertOtherPosts'] = $rows['convertForumsPosts'];
|
||||
$rows['convertOtherPosts']['step_method'] = 'convertOtherPosts';
|
||||
$rows['convertOtherPosts']['source_rows'] = array( 'table' => static::canConvert()['convertOtherPosts']['table'], 'where' => static::canConvert()['convertOtherPosts']['where'] );
|
||||
$rows = array();
|
||||
$rows['convertOtherPosts'] = array(
|
||||
'step_title' => 'convert_forums_posts',
|
||||
'step_method' => 'convertOtherPosts',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'forums_posts' ),
|
||||
'source_rows' => array( 'table' => static::canConvert()['convertOtherPosts']['table'], 'where' => static::canConvert()['convertOtherPosts']['where'] ),
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertForumsPosts' ),
|
||||
'link_type' => 'forums_posts',
|
||||
'requires_rebuild' => TRUE
|
||||
);
|
||||
|
||||
return $rows;
|
||||
}
|
||||
@@ -152,16 +162,16 @@ class _Expressionengine extends \IPS\convert\Software
|
||||
/**
|
||||
* Finish - Adds everything it needs to the queues and clears data store
|
||||
*
|
||||
* @return string Message to display
|
||||
* @return array Messages to display
|
||||
*/
|
||||
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" );
|
||||
}
|
||||
@@ -169,8 +179,8 @@ class _Expressionengine 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 )
|
||||
{
|
||||
|
||||
@@ -5,19 +5,22 @@
|
||||
* @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 26 July 2017
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invision Forums Converter
|
||||
*/
|
||||
class _Invisioncommunity extends \IPS\convert\Software
|
||||
{
|
||||
/**
|
||||
@@ -30,6 +33,14 @@ class _Invisioncommunity extends \IPS\convert\Software
|
||||
*/
|
||||
public static $dbNeeded = FALSE;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \IPS\convert\App $app The application to reference for database and other information.
|
||||
* @param bool $needDB Establish a DB connection
|
||||
* @return void
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct( \IPS\convert\App $app, $needDB=TRUE )
|
||||
{
|
||||
/* Set filename obscuring flag */
|
||||
@@ -50,7 +61,7 @@ class _Invisioncommunity extends \IPS\convert\Software
|
||||
}
|
||||
|
||||
/* Get parent sauce */
|
||||
$this->parent = $this->app->get__parent()->getSource();
|
||||
$this->parent = $this->app->_parent->getSource();
|
||||
}
|
||||
|
||||
return $return;
|
||||
@@ -108,11 +119,11 @@ class _Invisioncommunity extends \IPS\convert\Software
|
||||
'where' => NULL,
|
||||
),
|
||||
'convertForumsRssImports' => array(
|
||||
'table' => 'forums_rss_import',
|
||||
'where' => NULL,
|
||||
'table' => 'core_rss_import',
|
||||
'where' => array( 'rss_import_class=?', 'IPS\\forums\\Topic' ),
|
||||
),
|
||||
'convertForumsRssImported' => array(
|
||||
'table' => 'forums_rss_imported',
|
||||
'table' => 'core_rss_imported',
|
||||
'where' => NULL,
|
||||
),
|
||||
'convertForumsQuestionRatings' => array(
|
||||
@@ -130,6 +141,36 @@ class _Invisioncommunity extends \IPS\convert\Software
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Count Source Rows for a specific step
|
||||
*
|
||||
* @param string $table The table containing the rows to count.
|
||||
* @param array|NULL $where WHERE clause to only count specific rows, or NULL to count all.
|
||||
* @param bool $recache Skip cache and pull directly (updating cache)
|
||||
* @return integer
|
||||
* @throws \IPS\convert\Exception
|
||||
*/
|
||||
public function countRows( $table, $where=NULL, $recache=FALSE )
|
||||
{
|
||||
switch( $table )
|
||||
{
|
||||
case 'core_rss_imported':
|
||||
try
|
||||
{
|
||||
return $this->db->select( 'COUNT(*)', 'core_rss_imported', array( 'rss_imported_import_id IN(' . (string) \IPS\Db::i()->select( 'rss_import_id', 'core_rss_import', array( "rss_import_class='IPS\\forums\\Topic'" ) ) . ')' ) )->first() ;
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
throw new \IPS\convert\Exception( sprintf( \IPS\Member::loggedIn()->language()->get( 'could_not_count_rows' ), $table ) );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return parent::countRows( $table, $where, $recache );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Requires Parent
|
||||
*
|
||||
@@ -201,10 +242,10 @@ class _Invisioncommunity 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( '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' ) );
|
||||
\IPS\Task::queue( 'convert', 'InvisionCommunityRebuildContent', array( 'app' => $this->app->app_id, 'link' => 'forums_posts', 'class' => 'IPS\forums\Topic\Post' ), 2, array( 'app', 'link', 'class' ) );
|
||||
|
||||
/* Caches */
|
||||
@@ -217,6 +258,26 @@ class _Invisioncommunity extends \IPS\convert\Software
|
||||
return array( "f_forum_last_post_data", "f_rebuild_posts", "f_recounting_forums", "f_recounting_topics", "f_topic_tags_recount" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert question ratings
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertForumsAnswerRatings()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
$libraryClass::setKey( 'id' );
|
||||
|
||||
foreach( $this->fetch( 'forums_answer_ratings', 'id' ) AS $row )
|
||||
{
|
||||
/* Remove non-standard columns */
|
||||
$this->parent->unsetNonStandardColumns( $row, 'forums_answer_ratings', 'forums' );
|
||||
|
||||
$libraryClass->convertForumsAnswerRating( $row );
|
||||
$libraryClass->setLastKeyValue( $row['id'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert forums
|
||||
*
|
||||
@@ -236,6 +297,10 @@ class _Invisioncommunity extends \IPS\convert\Software
|
||||
$row['name'] = $this->parent->getWord( 'forums_forum_' . $row['id'] );
|
||||
$row['description'] = $this->parent->getWord( 'forums_forum_' . $row['id'] . '_desc' );
|
||||
|
||||
/* Rename bit options so we can pass them through the conversion method */
|
||||
$row['ips_forums_bitoptions'] = $row['forums_bitoptions'];
|
||||
unset( $row['forums_bitoptions'] );
|
||||
|
||||
$libraryClass->convertForumsForum( $row );
|
||||
|
||||
/* Convert Follows */
|
||||
@@ -323,6 +388,10 @@ class _Invisioncommunity extends \IPS\convert\Software
|
||||
/* Remove non-standard columns */
|
||||
$this->parent->unsetNonStandardColumns( $row, 'forums_posts', 'forums' );
|
||||
|
||||
/* Rename bit options so we can pass them through the conversion method */
|
||||
$row['ips_post_bwoptions'] = $row['post_bwoptions'];
|
||||
unset( $row['post_bwoptions'] );
|
||||
|
||||
$libraryClass->convertForumsPost( $row );
|
||||
|
||||
/* Convert Edit History */
|
||||
@@ -347,6 +416,26 @@ class _Invisioncommunity extends \IPS\convert\Software
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert question ratings
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertForumsQuestionRatings()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
$libraryClass::setKey( 'id' );
|
||||
|
||||
foreach( $this->fetch( 'forums_question_ratings', 'id' ) AS $row )
|
||||
{
|
||||
/* Remove non-standard columns */
|
||||
$this->parent->unsetNonStandardColumns( $row, 'forums_question_ratings', 'forums' );
|
||||
|
||||
$libraryClass->convertForumsQuestionRating( $row );
|
||||
$libraryClass->setLastKeyValue( $row['id'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert topics mmod
|
||||
*
|
||||
@@ -380,10 +469,13 @@ class _Invisioncommunity extends \IPS\convert\Software
|
||||
$libraryClass = $this->getLibrary();
|
||||
$libraryClass::setKey( 'rss_import_id' );
|
||||
|
||||
foreach( $this->fetch( 'forums_rss_import', 'rss_import_id' ) AS $row )
|
||||
foreach( $this->fetch( 'core_rss_import', 'rss_import_id', array( 'rss_import_class=?', 'IPS\\forums\\Topic' ) ) AS $row )
|
||||
{
|
||||
/* Remove non-standard columns */
|
||||
$this->parent->unsetNonStandardColumns( $row, 'forums_rss_import', 'forums' );
|
||||
$this->parent->unsetNonStandardColumns( $row, 'core_rss_import', 'core' );
|
||||
|
||||
/* JSON Decode settings (we expect an array) */
|
||||
$row['rss_import_settings'] = json_decode( $row['rss_import_settings'], TRUE );
|
||||
|
||||
$libraryClass->convertForumsRssImport( $row );
|
||||
$libraryClass->setLastKeyValue( $row['rss_import_id'] );
|
||||
@@ -399,10 +491,10 @@ class _Invisioncommunity extends \IPS\convert\Software
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
|
||||
foreach( $this->fetch( 'forums_rss_imported', 'rss_imported_tid' ) AS $row )
|
||||
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 )
|
||||
{
|
||||
/* Remove non-standard columns */
|
||||
$this->parent->unsetNonStandardColumns( $row, 'forums_rss_imported', 'forums' );
|
||||
$this->parent->unsetNonStandardColumns( $row, 'core_rss_imported', 'core' );
|
||||
|
||||
$libraryClass->convertForumsRssImported( $row );
|
||||
}
|
||||
@@ -459,7 +551,15 @@ class _Invisioncommunity extends \IPS\convert\Software
|
||||
{
|
||||
$url = \IPS\Request::i()->url();
|
||||
|
||||
if( preg_match( '#/ips4merge/(forum|topic)/([0-9]+)-(.+?)#i', $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
|
||||
if( !\stristr( $url->data[ \IPS\Http\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 ];
|
||||
|
||||
if( preg_match( '#/(forum|topic)/([0-9]+)-(.+?)#i', $searchOn, $matches ) )
|
||||
{
|
||||
$oldId = (int) $matches[2];
|
||||
|
||||
|
||||
@@ -5,19 +5,22 @@
|
||||
* @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
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* MyBB Forums Converter
|
||||
*/
|
||||
class _Mybb extends \IPS\convert\Software
|
||||
{
|
||||
/**
|
||||
@@ -129,7 +132,7 @@ class _Mybb extends \IPS\convert\Software
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Radio',
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array( 'parse' => 'image', 'options' => $options, 'descriptions' => $descriptions ),
|
||||
'field_extra' => array( 'parse' => 'image', 'options' => $options, 'descriptions' => $descriptions, 'gridspan' => 2 ),
|
||||
'field_hint' => NULL,
|
||||
'field_validation' => NULL,
|
||||
),
|
||||
@@ -137,7 +140,7 @@ class _Mybb extends \IPS\convert\Software
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Radio',
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array( 'parse' => 'image', 'options' => $options, 'descriptions' => $descriptions ),
|
||||
'field_extra' => array( 'parse' => 'image', 'options' => $options, 'descriptions' => $descriptions, 'gridspan' => 2 ),
|
||||
'field_hint' => NULL,
|
||||
'field_validation' => NULL,
|
||||
),
|
||||
@@ -169,11 +172,11 @@ class _Mybb 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' ) );
|
||||
|
||||
/* Rebuild Leaderboard */
|
||||
\IPS\Task::queue( 'core', 'RebuildReputationLeaderboard', array(), 4 );
|
||||
@@ -188,8 +191,8 @@ class _Mybb extends \IPS\convert\Software
|
||||
/**
|
||||
* Fix Post Data
|
||||
*
|
||||
* @param string Post
|
||||
* @return string Fixed Posts
|
||||
* @param string $post Post
|
||||
* @return string Fixed Post
|
||||
*/
|
||||
public static function fixPostData( $post )
|
||||
{
|
||||
@@ -574,7 +577,26 @@ class _Mybb extends \IPS\convert\Software
|
||||
'attach_filesize' => $row['filesize'],
|
||||
);
|
||||
|
||||
$libraryClass->convertAttachment( $info, $map, rtrim( $this->app->_session['more_info']['convertAttachments']['attach_location'], '/' ) . '/' . $row['attachname'] );
|
||||
$attachId = $libraryClass->convertAttachment( $info, $map, rtrim( $this->app->_session['more_info']['convertAttachments']['attach_location'], '/' ) . '/' . $row['attachname'] );
|
||||
|
||||
/* Update Post if we can */
|
||||
try
|
||||
{
|
||||
if ( $attachId !== FALSE )
|
||||
{
|
||||
$pid = $this->app->getLink( $row['pid'], 'forums_posts' );
|
||||
|
||||
$post = \IPS\Db::i()->select( 'post', 'forums_posts', array( "pid=?", $pid ) )->first();
|
||||
|
||||
if( \preg_match( '#\[attachment=' . $row['aid'] . ']#i', $post ) )
|
||||
{
|
||||
$post = str_ireplace( '[attachment=' . $row['aid'] . ']', '[attachment=' . $attachId . ':name]', $post );
|
||||
\IPS\Db::i()->update( 'forums_posts', array( 'post' => $post ), array( "pid=?", $pid ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException $e ) {}
|
||||
catch( \OutOfRangeException $e ) {}
|
||||
|
||||
$libraryClass->setLastKeyValue( $row['aid'] );
|
||||
}
|
||||
|
||||
@@ -5,19 +5,22 @@
|
||||
* @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
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* PhpBB Forums Converter
|
||||
*/
|
||||
class _Phpbb extends \IPS\convert\Software
|
||||
{
|
||||
/**
|
||||
@@ -159,11 +162,11 @@ class _Phpbb 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" );
|
||||
}
|
||||
@@ -171,8 +174,8 @@ class _Phpbb 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 )
|
||||
{
|
||||
|
||||
@@ -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 6 December 2016
|
||||
* @note Only redirect scripts are supported right now
|
||||
*/
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
* PhpMyForum Forums Converter
|
||||
*/
|
||||
class _Phpmyforum extends \IPS\convert\Software
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -5,19 +5,22 @@
|
||||
* @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
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* PunBB Forums Converter
|
||||
*/
|
||||
class _Punbb extends \IPS\convert\Software
|
||||
{
|
||||
/**
|
||||
@@ -93,11 +96,11 @@ class _Punbb 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" );
|
||||
}
|
||||
@@ -105,8 +108,8 @@ class _Punbb 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 )
|
||||
{
|
||||
@@ -229,7 +232,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 );
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Converter
|
||||
* @subpackage convert
|
||||
* @since 21 Jan 2015
|
||||
* @version
|
||||
*/
|
||||
@@ -12,12 +12,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;
|
||||
}
|
||||
|
||||
/**
|
||||
* UBBThreads Forums Converter
|
||||
*/
|
||||
class _UBBthreads extends \IPS\convert\Software
|
||||
{
|
||||
/**
|
||||
@@ -39,7 +42,7 @@ class _UBBthreads extends \IPS\convert\Software
|
||||
public static function softwareKey()
|
||||
{
|
||||
/* Child classes must override this method */
|
||||
return "UBBthreads";
|
||||
return "ubbthreads";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,11 +89,11 @@ class _UBBthreads 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 = array();
|
||||
$count = $this->countRows( static::canConvert()['convertForumsTopicsRatings']['table'], static::canConvert()['convertForumsTopicsRatings']['where'] );
|
||||
|
||||
if( $count )
|
||||
@@ -100,7 +103,7 @@ class _UBBthreads extends \IPS\convert\Software
|
||||
'step_title' => 'convert_ratings',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'core_ratings' ),
|
||||
'source_rows' => $count,
|
||||
'per_cycle' => 1500,
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertForumsTopics' ),
|
||||
'link_type' => 'topic_ratings',
|
||||
);
|
||||
@@ -115,7 +118,7 @@ class _UBBthreads extends \IPS\convert\Software
|
||||
'step_title' => 'convert_follows',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'core_follow' ),
|
||||
'source_rows' => $count,
|
||||
'per_cycle' => 1000,
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertForumsTopics' ),
|
||||
'link_type' => 'core_follows',
|
||||
);
|
||||
@@ -161,7 +164,7 @@ class _UBBthreads extends \IPS\convert\Software
|
||||
*/
|
||||
public static function parents()
|
||||
{
|
||||
return array( 'core' => array( 'UBBthreads' ) );
|
||||
return array( 'core' => array( 'ubbthreads' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,11 +215,11 @@ class _UBBthreads 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" );
|
||||
}
|
||||
@@ -224,8 +227,8 @@ class _UBBthreads 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 )
|
||||
{
|
||||
@@ -385,7 +388,7 @@ class _UBBthreads extends \IPS\convert\Software
|
||||
'title' => mb_substr( $row['TOPIC_SUBJECT'], 0, 250 ),
|
||||
'forum_id' => $row['FORUM_ID'],
|
||||
'state' => ( $row['TOPIC_STATUS'] == 'C' ) ? 'closed' : 'open',
|
||||
'posts' => $row['TOPIC_TOTAL_REPLIES'],
|
||||
'posts' => $row['TOPIC_REPLIES'],
|
||||
'starter_id' => $row['USER_ID'],
|
||||
'start_date' => \IPS\DateTime::create()->setTimestamp( $row['TOPIC_CREATED_TIME'] ),
|
||||
'last_poster_id' => $row['TOPIC_LAST_POSTER_ID'],
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Converter
|
||||
* @subpackage convert
|
||||
* @since 21 Jan 2015
|
||||
*/
|
||||
|
||||
@@ -12,12 +12,15 @@ namespace IPS\convert\Software\Forums;
|
||||
use \IPS\convert\Software\Core\Vanilla as VanillaCore;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vanilla Forums Converter
|
||||
*/
|
||||
class _Vanilla extends \IPS\convert\Software
|
||||
{
|
||||
/**
|
||||
@@ -28,8 +31,8 @@ class _Vanilla extends \IPS\convert\Software
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \IPS\convert\App The application to reference for database and other information.
|
||||
* @param bool Establish a DB connection
|
||||
* @param \IPS\convert\App $app The application to reference for database and other information.
|
||||
* @param bool $needDB Establish a DB connection
|
||||
* @return void
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
@@ -122,13 +125,21 @@ class _Vanilla 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['convertForumsPosts2'] = $rows['convertForumsPosts'];
|
||||
$rows['convertForumsPosts2']['step_method'] = 'convertForumsPosts2';
|
||||
$rows = array();
|
||||
$rows['convertForumsPosts2'] = array(
|
||||
'step_title' => 'convert_forums_posts',
|
||||
'step_method' => 'convertForumsPosts2',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'forums_posts' ),
|
||||
'source_rows' => array( 'table' => static::canConvert()['convertForumsPosts2']['table'], 'where' => static::canConvert()['convertForumsPosts2']['where'] ),
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertForumsPosts' ),
|
||||
'link_type' => 'forums_posts',
|
||||
'requires_rebuild' => TRUE
|
||||
);
|
||||
|
||||
return $rows;
|
||||
}
|
||||
@@ -147,10 +158,17 @@ class _Vanilla extends \IPS\convert\Software
|
||||
switch( $table )
|
||||
{
|
||||
case 'Comment':
|
||||
$count = 0;
|
||||
$count += $this->db->select( 'COUNT(*)', 'Discussion' )->first();
|
||||
$count += $this->db->select( 'COUNT(*)', 'Comment' )->first();
|
||||
return $count;
|
||||
try
|
||||
{
|
||||
$count = 0;
|
||||
$count += $this->db->select( 'COUNT(*)', 'Discussion' )->first();
|
||||
$count += $this->db->select( 'COUNT(*)', 'Comment' )->first();
|
||||
return $count;
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
throw new \IPS\convert\Exception( sprintf( \IPS\Member::loggedIn()->language()->get( 'could_not_count_rows' ), $table ) );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -263,11 +281,11 @@ class _Vanilla 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' ) );
|
||||
|
||||
/* Rebuild Leaderboard */
|
||||
\IPS\Task::queue( 'core', 'RebuildReputationLeaderboard', array(), 4 );
|
||||
@@ -282,8 +300,8 @@ class _Vanilla 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 )
|
||||
{
|
||||
@@ -463,7 +481,7 @@ class _Vanilla extends \IPS\convert\Software
|
||||
{
|
||||
$tags = explode( ',', $row['Tags'] );
|
||||
|
||||
if ( count( $tags ) )
|
||||
if ( \count( $tags ) )
|
||||
{
|
||||
foreach( $tags AS $tag )
|
||||
{
|
||||
|
||||
@@ -5,19 +5,22 @@
|
||||
* @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
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* vBulletin Forums Converter
|
||||
*/
|
||||
class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
/**
|
||||
@@ -38,8 +41,8 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \IPS\convert\App The application to reference for database and other information.
|
||||
* @param bool Establish a DB connection
|
||||
* @param \IPS\convert\App $app The application to reference for database and other information.
|
||||
* @param bool $needDB Establish a DB connection
|
||||
* @return void
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
@@ -68,7 +71,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
|
||||
|
||||
/* If this is vB4, what is the content type ID for posts? */
|
||||
if ( static::$postContentType === NULL AND ( static::$isLegacy === FALSE OR is_null( static::$isLegacy ) ) )
|
||||
if ( static::$postContentType === NULL AND ( static::$isLegacy === FALSE OR \is_null( static::$isLegacy ) ) )
|
||||
{
|
||||
static::$postContentType = $this->db->select( 'contenttypeid', 'contenttype', array( "class=?", 'Post' ) )->first();
|
||||
}
|
||||
@@ -115,7 +118,12 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
),
|
||||
'convertForumsTopics' => array(
|
||||
'table' => 'thread',
|
||||
'where' => NULL
|
||||
'where' => NULL,
|
||||
'extra_steps' => array( 'convertForumsTopicsFollowers' )
|
||||
),
|
||||
'convertForumsTopicsFollowers' => array(
|
||||
'table' => 'subscribethread',
|
||||
'where' => NULL,
|
||||
),
|
||||
'convertForumsPosts' => array(
|
||||
'table' => 'post',
|
||||
@@ -135,11 +143,33 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
),
|
||||
'convertAttachments' => array(
|
||||
'table' => 'attachment',
|
||||
'where' => ( static::$isLegacy === FALSE OR is_null( static::$isLegacy ) ) ? array( "contenttypeid=?", static::$postContentType ) : NULL
|
||||
'where' => ( static::$isLegacy === FALSE OR \is_null( static::$isLegacy ) ) ? array( "contenttypeid=?", static::$postContentType ) : NULL
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows software to add additional menu row options
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function extraMenuRows()
|
||||
{
|
||||
$rows = array();
|
||||
$rows['convertForumsTopicsFollowers'] = array(
|
||||
'step_title' => 'convert_forums_topics_followers',
|
||||
'step_method' => 'convertForumsTopicsFollowers',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'core_follow', array( 'follow_app=? AND follow_area=?', 'forums', 'topics' ) ),
|
||||
'source_rows' => array( 'table' => static::canConvert()['convertForumsTopicsFollowers']['table'], 'where' => static::canConvert()['convertForumsTopicsFollowers']['where'] ),
|
||||
'per_cycle' => 2000,
|
||||
'dependencies' => array( 'convertForumsTopics' ),
|
||||
'link_type' => 'core_follows',
|
||||
'requires_rebuild' => FALSE
|
||||
);
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requires Parent
|
||||
*
|
||||
@@ -168,11 +198,11 @@ class _Vbulletin 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' ), 2, array( 'class' ) ); // This must run before the CMS item count task runs.
|
||||
\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' ) );
|
||||
|
||||
/* Rebuild Leaderboard */
|
||||
\IPS\Task::queue( 'core', 'RebuildReputationLeaderboard', array(), 4 );
|
||||
@@ -187,7 +217,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
/**
|
||||
* Fix Post Data
|
||||
*
|
||||
* @param string Post
|
||||
* @param string $post Post
|
||||
* @return string Fixed Posts
|
||||
*/
|
||||
public static function fixPostData( $post )
|
||||
@@ -234,7 +264,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Radio',
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array( 'parse' => 'image', 'options' => $options, 'descriptions' => $descriptions ),
|
||||
'field_extra' => array( 'parse' => 'image', 'options' => $options, 'descriptions' => $descriptions, 'gridspan' => 2 ),
|
||||
'field_hint' => NULL,
|
||||
'field_validation' => NULL,
|
||||
),
|
||||
@@ -242,7 +272,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Radio',
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array( 'parse' => 'image', 'options' => $options, 'descriptions' => $descriptions ),
|
||||
'field_extra' => array( 'parse' => 'image', 'options' => $options, 'descriptions' => $descriptions, 'gridspan' => 2 ),
|
||||
'field_hint' => NULL,
|
||||
'field_validation' => NULL,
|
||||
),
|
||||
@@ -250,7 +280,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Radio',
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array( 'parse' => 'image', 'options' => $options, 'descriptions' => $descriptions ),
|
||||
'field_extra' => array( 'parse' => 'image', 'options' => $options, 'descriptions' => $descriptions, 'gridspan' => 2 ),
|
||||
'field_hint' => NULL,
|
||||
'field_validation' => NULL,
|
||||
),
|
||||
@@ -265,8 +295,8 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(
|
||||
'options' => array(
|
||||
'database' => \IPS\Member::loggedIn()->language()->addToStack( 'database' ),
|
||||
'file_system' => \IPS\Member::loggedIn()->language()->addToStack( 'file_system' ),
|
||||
'database' => \IPS\Member::loggedIn()->language()->addToStack( 'conv_store_database' ),
|
||||
'file_system' => \IPS\Member::loggedIn()->language()->addToStack( 'conv_store_file_system' ),
|
||||
),
|
||||
'userSuppliedInput' => 'file_system',
|
||||
),
|
||||
@@ -317,7 +347,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
'topics' => $forum['threadcount'],
|
||||
'posts' => $forum['replycount'],
|
||||
'last_post' => $forum['lastpost'],
|
||||
'last_poster_id' => ( static::$isLegacy === FALSE or is_null( static::$isLegacy ) ) ? $forum['lastposterid'] : 0,
|
||||
'last_poster_id' => ( static::$isLegacy === FALSE or \is_null( static::$isLegacy ) ) ? $forum['lastposterid'] : 0,
|
||||
'last_poster_name' => $forum['lastposter'],
|
||||
'parent_id' => $forum['parentid'],
|
||||
'position' => $forum['displayorder'],
|
||||
@@ -380,10 +410,11 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
public function convertForumsTopics()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
|
||||
$libraryClass::setKey( 'threadid' );
|
||||
|
||||
foreach( $this->fetch( 'thread', 'threadid' ) AS $topic )
|
||||
|
||||
$data = iterator_to_array( $this->fetch( 'thread', 'threadid' ) );
|
||||
$this->app->preCacheLinks( $data, [ 'forums_forums' => 'forumid', 'core_members' => [ 'postuserid', 'lastposterid' ] ] );
|
||||
foreach( $data AS $topic )
|
||||
{
|
||||
/* Pesky Polls */
|
||||
$poll = NULL;
|
||||
@@ -434,7 +465,9 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
|
||||
$poll['vote_data'] = array();
|
||||
$ourVotes = array();
|
||||
foreach( $this->db->select( '*', 'pollvote', array( "pollid=?", $pollData['pollid'] ) ) AS $vote )
|
||||
$voteData = iterator_to_array( $this->db->select( '*', 'pollvote', array( "pollid=?", $pollData['pollid'] ) ) );
|
||||
$this->app->preCacheLinks( $voteData, [ 'core_members' => 'userid' ] );
|
||||
foreach( $voteData AS $vote )
|
||||
{
|
||||
if ( !isset( $ourVotes[$vote['userid']] ) )
|
||||
{
|
||||
@@ -464,6 +497,21 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
catch( \UnderflowException $e ) {} # if the poll is missing, don't bother
|
||||
}
|
||||
|
||||
switch( $topic['visible'] )
|
||||
{
|
||||
case 0: // hidden awaiting approval.
|
||||
$approved = 0;
|
||||
break;
|
||||
|
||||
case 1: // Visible
|
||||
$approved = 1;
|
||||
break;
|
||||
|
||||
case 2: // Soft Deleted in vBulletin is equivalent to hidden by a moderator in IPS.
|
||||
$approved = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
$info = array(
|
||||
'tid' => $topic['threadid'],
|
||||
'title' => $topic['title'],
|
||||
@@ -472,59 +520,26 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
'posts' => $topic['replycount'],
|
||||
'starter_id' => $topic['postuserid'],
|
||||
'start_date' => $topic['dateline'],
|
||||
'last_poster_id' => ( static::$isLegacy === FALSE OR is_null( static::$isLegacy ) ) ? $topic['lastposterid'] : NULL,
|
||||
'last_poster_id' => ( static::$isLegacy === FALSE OR \is_null( static::$isLegacy ) ) ? $topic['lastposterid'] : NULL,
|
||||
'last_post' => $topic['lastpost'],
|
||||
'starter_name' => $topic['postusername'],
|
||||
'last_poster_name' => $topic['lastposter'],
|
||||
'poll_state' => $poll,
|
||||
'last_vote' => $lastVote,
|
||||
'views' => $topic['views'],
|
||||
'approved' => $topic['visible'],
|
||||
'approved' => $approved,
|
||||
'pinned' => $topic['sticky'],
|
||||
'topic_hiddenposts' => $topic['hiddencount'] + $topic['deletedcount']
|
||||
);
|
||||
|
||||
unset( $poll );
|
||||
|
||||
$topic_id = $libraryClass->convertForumsTopic( $info );
|
||||
|
||||
/* Follows */
|
||||
foreach( $this->db->select( '*', 'subscribethread', array( "threadid=?", $topic['threadid'] ) ) AS $follow )
|
||||
{
|
||||
$frequency = 'none';
|
||||
switch( $follow['emailupdate'] )
|
||||
{
|
||||
case 1:
|
||||
$frequency = 'immediate';
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$frequency = 'daily';
|
||||
break;
|
||||
|
||||
case 3:
|
||||
$frequency = 'weekly';
|
||||
break;
|
||||
}
|
||||
|
||||
$libraryClass->convertFollow( array(
|
||||
'follow_app' => 'forums',
|
||||
'follow_area' => 'topic',
|
||||
'follow_rel_id' => $topic['threadid'],
|
||||
'follow_rel_id_type' => 'forums_topics',
|
||||
'follow_member_id' => $follow['userid'],
|
||||
'follow_is_anon' => 0,
|
||||
'follow_added' => time(),
|
||||
'follow_notify_do' => 1,
|
||||
'follow_notify_meta' => '',
|
||||
'follow_notify_freq' => $frequency,
|
||||
'follow_notify_sent' => 0,
|
||||
'follow_visible' => 1,
|
||||
) );
|
||||
}
|
||||
$libraryClass->convertForumsTopic( $info );
|
||||
|
||||
/* Ratings */
|
||||
foreach( $this->db->select( '*', 'threadrate', array( "threadid=?", $topic['threadid'] ) ) AS $rating )
|
||||
$ratingData = iterator_to_array( $this->db->select( '*', 'threadrate', array( "threadid=?", $topic['threadid'] ) ) );
|
||||
$this->app->preCacheLinks( $ratingData, [ 'core_members' => 'userid' ] );
|
||||
foreach( $ratingData AS $rating )
|
||||
{
|
||||
$libraryClass->convertRating( array(
|
||||
'id' => $rating['threadrateid'],
|
||||
@@ -559,7 +574,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
if( $topic['taglist'] !== NULL AND !empty( $topic['taglist'] ) )
|
||||
{
|
||||
$tags = explode( ',', $topic['taglist'] );
|
||||
if ( count( $tags ) )
|
||||
if ( \count( $tags ) )
|
||||
{
|
||||
foreach( $tags AS $tag )
|
||||
{
|
||||
@@ -580,6 +595,56 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert topic follows
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertForumsTopicsFollowers()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
$libraryClass::setKey( 'subscribethreadid' );
|
||||
|
||||
/* Follows */
|
||||
$followData = iterator_to_array( $this->fetch( 'subscribethread', 'subscribethreadid' ) );
|
||||
$this->app->preCacheLinks( $followData, [ 'forums_topics' => 'threadid', 'core_members' => 'userid' ] );
|
||||
foreach( $followData AS $follow )
|
||||
{
|
||||
$frequency = 'none';
|
||||
switch( $follow['emailupdate'] )
|
||||
{
|
||||
case 1:
|
||||
$frequency = 'immediate';
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$frequency = 'daily';
|
||||
break;
|
||||
|
||||
case 3:
|
||||
$frequency = 'weekly';
|
||||
break;
|
||||
}
|
||||
|
||||
$libraryClass->convertFollow( array(
|
||||
'follow_app' => 'forums',
|
||||
'follow_area' => 'topic',
|
||||
'follow_rel_id' => $follow['threadid'],
|
||||
'follow_rel_id_type' => 'forums_topics',
|
||||
'follow_member_id' => $follow['userid'],
|
||||
'follow_is_anon' => 0,
|
||||
'follow_added' => time(),
|
||||
'follow_notify_do' => 1,
|
||||
'follow_notify_meta' => '',
|
||||
'follow_notify_freq' => $frequency,
|
||||
'follow_notify_sent' => 0,
|
||||
'follow_visible' => 1,
|
||||
) );
|
||||
|
||||
$libraryClass->setLastKeyValue( $follow['subscribethreadid'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert posts
|
||||
*
|
||||
@@ -588,11 +653,40 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
public function convertForumsPosts()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
|
||||
$libraryClass::setKey( 'postid' );
|
||||
|
||||
foreach( $this->fetch( 'post', 'postid' ) AS $post )
|
||||
|
||||
$data = iterator_to_array( $this->fetch( array( 'post', 'p' ), 'p.postid', NULL, 'p.*, t.visible AS topicvisible' )->join( array( 'thread', 't' ), 'p.threadid=t.threadid' ) );
|
||||
$this->app->preCacheLinks( $data, [ 'forums_topics' => 'threadid', 'core_members' => 'userid' ] );
|
||||
foreach( $data AS $post )
|
||||
{
|
||||
$queued = NULL;
|
||||
|
||||
/* If the topic is hidden, mark this post as hidden by the parent topic */
|
||||
if ( $post['topicvisible'] == 2 )
|
||||
{
|
||||
$queued = 2;
|
||||
}
|
||||
|
||||
/* Still here? Topic is fine, so check the post */
|
||||
if ( $queued === NULL )
|
||||
{
|
||||
switch( $post['visible'] )
|
||||
{
|
||||
case 0: // hidden pending moderator approval
|
||||
$queued = 1;
|
||||
break;
|
||||
|
||||
case 1: // Visible
|
||||
$queued = 0;
|
||||
break;
|
||||
|
||||
case 2: // Hidden by moderator
|
||||
$queued = -1;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$info = array(
|
||||
'pid' => $post['postid'],
|
||||
'topic_id' => $post['threadid'],
|
||||
@@ -601,14 +695,27 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
'author_name' => $post['username'],
|
||||
'ip_address' => $post['ipaddress'],
|
||||
'post_date' => $post['dateline'],
|
||||
'queued' => ( $post['visible'] >= 2 ) ? -1 : ( ( $post['visible'] == 0 ) ? 1 : 0 ),
|
||||
'post_htmlstate' => ( static::$isLegacy === FALSE AND in_array( $post['htmlstate'], array( 'on', 'on_nl2br' ) ) ) ? 1 : 0,
|
||||
'queued' => $queued,
|
||||
'post_htmlstate' => ( static::$isLegacy === FALSE AND \in_array( $post['htmlstate'], array( 'on', 'on_nl2br' ) ) ) ? 1 : 0,
|
||||
);
|
||||
|
||||
/* Edited? */
|
||||
try
|
||||
{
|
||||
$lastEdit = $this->db->select( '*', 'postedithistory', array( 'postid=?', $post['postid'] ), 'postedithistoryid DESC', 1 )->first();
|
||||
$info['append_edit'] = 1;
|
||||
$info['edit_time'] = $lastEdit['dateline'];
|
||||
$info['edit_name'] = $lastEdit['username'];
|
||||
$info['post_edit_reason'] = $lastEdit['reason'] ?? null;
|
||||
}
|
||||
catch( \UnderflowException $e ) {}
|
||||
|
||||
$post_id = $libraryClass->convertForumsPost( $info );
|
||||
$libraryClass->convertForumsPost( $info );
|
||||
|
||||
/* Reputation */
|
||||
foreach( $this->db->select( '*', 'reputation', array( "postid=?", $post['postid'] ) ) AS $rep )
|
||||
$reputation = iterator_to_array( $this->db->select( '*', 'reputation', array( "postid=?", $post['postid'] ) ) );
|
||||
$this->app->preCacheLinks( $reputation, [ 'core_members' => [ 'userid', 'whoadded' ] ] );
|
||||
foreach( $reputation AS $rep )
|
||||
{
|
||||
$reaction = ( $rep['reputation'] > 0 ) ?
|
||||
$this->app->_session['more_info']['convertForumsPosts']['rep_positive'] :
|
||||
@@ -627,36 +734,32 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
) );
|
||||
}
|
||||
|
||||
/* Edit History */
|
||||
$latestedit = 0;
|
||||
$reason = NULL;
|
||||
$name = NULL;
|
||||
$newText = static::fixPostData( $post['pagetext'] );
|
||||
|
||||
foreach( $this->db->select( '*', 'postedithistory', array( "postid=?", $post['postid'] ) ) AS $edit )
|
||||
/* Process edit history if some exists */
|
||||
if( isset( $info['append_edit'] ) )
|
||||
{
|
||||
$libraryClass->convertEditHistory( array(
|
||||
'id' => $edit['postedithistoryid'],
|
||||
'class' => 'IPS\\forums\\Topic\\Post',
|
||||
'comment_id' => $post['postid'],
|
||||
'member' => $edit['userid'],
|
||||
'time' => $edit['dateline'],
|
||||
'old' => static::fixPostData( $edit['pagetext'] ),
|
||||
'new' => $newText
|
||||
) );
|
||||
|
||||
$newText = static::fixPostData( $edit['pagetext'] );
|
||||
|
||||
if ( $edit['dateline'] > $latestedit )
|
||||
$newText = $info['post'];
|
||||
|
||||
foreach ( $this->db->select( '*', 'postedithistory', array( "postid=?", $post['postid'] ), 'postedithistoryid ASC' ) as $edit )
|
||||
{
|
||||
$latestedit = $edit['dateline'];
|
||||
$reason = $edit['reason'];
|
||||
$name = $edit['username'];
|
||||
$editHistory = array(
|
||||
'id' => $edit['postedithistoryid'],
|
||||
'class' => 'IPS\\forums\\Topic\\Post',
|
||||
'comment_id' => $post['postid'],
|
||||
'member' => $edit['userid'],
|
||||
'time' => $edit['dateline'],
|
||||
'old' => static::fixPostData( $edit['pagetext'] ),
|
||||
'new' => $newText
|
||||
);
|
||||
|
||||
$libraryClass->convertEditHistory( $editHistory );
|
||||
$newText = $editHistory['old'];
|
||||
}
|
||||
}
|
||||
|
||||
/* Warnings */
|
||||
foreach( $this->db->select( '*', 'infraction', array( "postid=?", $post['postid'] ) ) AS $warn )
|
||||
$warnings = iterator_to_array( $this->db->select( '*', 'infraction', array( "postid=?", $post['postid'] ) ) );
|
||||
$this->app->preCacheLinks( $warnings, [ 'core_members' => 'whoadded' ] );
|
||||
foreach( $warnings AS $warn )
|
||||
{
|
||||
$warnId = $libraryClass->convertWarnLog( array(
|
||||
'wl_id' => $warn['infractionid'],
|
||||
@@ -680,12 +783,6 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
);
|
||||
}
|
||||
|
||||
/* If we have a latest edit, then update the main post - this should really be in the library, as the converters should not be altering data */
|
||||
if ( $latestedit )
|
||||
{
|
||||
\IPS\Db::i()->update( 'forums_posts', array( 'append_edit' => 1, 'edit_time' => $latestedit, 'edit_name' => $name, 'post_edit_reason' => $reason ), array( "pid=?", $post_id ) );
|
||||
}
|
||||
|
||||
$libraryClass->setLastKeyValue( $post['postid'] );
|
||||
}
|
||||
}
|
||||
@@ -704,7 +801,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
$where = NULL;
|
||||
$column = NULL;
|
||||
|
||||
if ( static::$isLegacy === FALSE OR is_null( static::$isLegacy ) )
|
||||
if ( static::$isLegacy === FALSE OR \is_null( static::$isLegacy ) )
|
||||
{
|
||||
$where = array( "contenttypeid=?", static::$postContentType );
|
||||
$column = 'contentid';
|
||||
@@ -728,7 +825,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( static::$isLegacy === FALSE OR is_null( static::$isLegacy ) )
|
||||
if ( static::$isLegacy === FALSE OR \is_null( static::$isLegacy ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -787,9 +884,9 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
|
||||
$post = \IPS\Db::i()->select( 'post', 'forums_posts', array( "pid=?", $pid ) )->first();
|
||||
|
||||
if ( preg_match( "/\[ATTACH(.+?)?\]".$attachment['attachmentid']."\[\/ATTACH\]/i", $post ) )
|
||||
if ( preg_match( "/\[ATTACH([^\]]+?)?\]".$attachment['attachmentid']."\[\/ATTACH\]/i", $post ) )
|
||||
{
|
||||
$post = preg_replace( "/\[ATTACH(.+?)?\]" . $attachment['attachmentid'] . "\[\/ATTACH\]/i", '[attachment=' . $attach_id . ':name]', $post );
|
||||
$post = preg_replace( "/\[ATTACH([^\]]+?)?\]" . $attachment['attachmentid'] . "\[\/ATTACH\]/i", '[attachment=' . $attach_id . ':name]', $post );
|
||||
|
||||
\IPS\Db::i()->update( 'forums_posts', array( 'post' => $post ), array( "pid=?", $pid ) );
|
||||
}
|
||||
@@ -1058,19 +1155,20 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'showpost.php' ) !== FALSE OR
|
||||
preg_match( '#/threads/([0-9]+)#i', $url->data[ \IPS\Http\Url::COMPONENT_PATH ] )
|
||||
)
|
||||
AND isset( \IPS\Request::i()->p )
|
||||
AND ( isset( \IPS\Request::i()->p ) OR isset( \IPS\Request::i()->postid ) )
|
||||
)
|
||||
{
|
||||
try
|
||||
{
|
||||
$postId = \IPS\Request::i()->postid ?? \IPS\Request::i()->p;
|
||||
try
|
||||
{
|
||||
$data = (string) $this->app->getLink( (int) \IPS\Request::i()->p, array( 'posts', 'forums_posts' ) );
|
||||
$data = (string) $this->app->getLink( (int) $postId, array( 'posts', 'forums_posts' ) );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
/* Try the main table */
|
||||
$data = (string) $this->app->getLink( (int) \IPS\Request::i()->p, array( 'posts', 'forums_posts' ), FALSE, TRUE );
|
||||
$data = (string) $this->app->getLink( (int) $postId, array( 'posts', 'forums_posts' ), FALSE, TRUE );
|
||||
}
|
||||
$item = \IPS\forums\Topic\Post::load( $data );
|
||||
|
||||
@@ -1085,21 +1183,28 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
}
|
||||
}
|
||||
/* And then topic URLs, same idea */
|
||||
elseif( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'showthread.php' ) !== FALSE )
|
||||
elseif( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'showthread.php' ) !== FALSE OR
|
||||
mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'printthread.php' ) !== FALSE )
|
||||
{
|
||||
/* Topic URLs can be in one of 4 formats really...
|
||||
* /showthread.php/1-name
|
||||
* /threads/1-name
|
||||
* /showthread.php?t=1
|
||||
* /showthread.php?1-name
|
||||
* /printthread.php?t=1
|
||||
* /showthread.php?threadid=?
|
||||
*/
|
||||
$path = $url->data[ \IPS\Http\Url::COMPONENT_PATH ];
|
||||
if( mb_strpos( $path, 'showthread.php' ) !== FALSE )
|
||||
if( mb_strpos( $path, 'showthread.php' ) !== FALSE OR mb_strpos( $path, 'printthread.php' ) !== FALSE )
|
||||
{
|
||||
if( isset( \IPS\Request::i()->t ) )
|
||||
{
|
||||
$oldId = \IPS\Request::i()->t;
|
||||
}
|
||||
elseif( isset( \IPS\Request::i()->threadid ) )
|
||||
{
|
||||
$oldId = \IPS\Request::i()->threadid;
|
||||
}
|
||||
elseif( preg_match( '#^(\d+)-[^/]+#i', $url->data[ \IPS\Http\Url::COMPONENT_QUERY ], $matches ) )
|
||||
{
|
||||
$oldId = $matches[1];
|
||||
@@ -1169,8 +1274,8 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
/* And finally, archives */
|
||||
elseif( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'archive/index.php' ) !== FALSE )
|
||||
{
|
||||
$request = str_replace( '/archive/index.php/', '', $_SERVER['REQUEST_URI'] );
|
||||
$parameters = explode( '-', $request );
|
||||
$request = explode( '/', $url->data[ \IPS\Http\Url::COMPONENT_PATH ] );
|
||||
$parameters = explode( '-', array_pop( $request ) );
|
||||
$parameters[1] = str_replace( '.html', '', $parameters[1] );
|
||||
|
||||
try
|
||||
@@ -1180,11 +1285,11 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
case 't':
|
||||
try
|
||||
{
|
||||
$data = $this->getLink( (string) $parameters[1], array( 'topics', 'forums_topics' ) );
|
||||
$data = $this->app->getLink( (string) $parameters[1], array( 'topics', 'forums_topics' ) );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
$data = $this->getLink( (string) $parameters[1], array( 'topics', 'forums_topics' ), FALSE, TRUE );
|
||||
$data = $this->app->getLink( (string) $parameters[1], array( 'topics', 'forums_topics' ), FALSE, TRUE );
|
||||
}
|
||||
$item = \IPS\forums\Topic::load( $data );
|
||||
|
||||
@@ -1210,7 +1315,28 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
/* Club Discussions */
|
||||
elseif( ( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'group.php' ) !== FALSE AND isset( \IPS\Request::i()->discussionid ) ) OR
|
||||
preg_match( '#/social-groups/(.*)/([0-9]+)#i', $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
|
||||
{
|
||||
$id = \IPS\Request::i()->discussionid ?? $matches[2];
|
||||
try
|
||||
{
|
||||
$data = (string) $this->app->getLink( 'clubtopic' . $id, array( 'topics', 'forums_topics' ) );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$item = \IPS\forums\Topic::load( $data );
|
||||
|
||||
if( $item->canView() )
|
||||
{
|
||||
return $item->url();
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,19 +5,22 @@
|
||||
* @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
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* vBulletin 5 Forums Converter
|
||||
*/
|
||||
class _Vbulletin5 extends \IPS\convert\Software
|
||||
{
|
||||
/**
|
||||
@@ -63,12 +66,38 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
'where' => NULL,
|
||||
),
|
||||
'convertAttachments' => array(
|
||||
'table' => 'attachment',
|
||||
'where' => NULL,
|
||||
'extra_steps' => array( 'convertAttachments2' )
|
||||
),
|
||||
'convertAttachments2' => array(
|
||||
'table' => 'attachment',
|
||||
'where' => NULL
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows software to add additional menu row options
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function extraMenuRows()
|
||||
{
|
||||
$rows = array();
|
||||
$rows['convertAttachments2'] = array(
|
||||
'step_method' => 'convertAttachments2',
|
||||
'step_title' => 'convert_attachments',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'core_attachments_map', array( "location_key=?", 'gallery_Images' ) ),
|
||||
'source_rows' => array( 'table' => static::canConvert()['convertAttachments2']['table'], 'where' => static::canConvert()['convertAttachments2']['where'] ),
|
||||
'per_cycle' => 10,
|
||||
'dependencies' => array( 'convertAttachments' ),
|
||||
'link_type' => 'core_attachments',
|
||||
);
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count Source Rows for a specific step
|
||||
*
|
||||
@@ -83,19 +112,33 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
switch( $table )
|
||||
{
|
||||
case 'forum':
|
||||
return count( $this->fetchForums() );
|
||||
return \count( $this->fetchForums() );
|
||||
break;
|
||||
|
||||
case 'thread':
|
||||
return parent::countRows( 'node', array( \IPS\Db::i()->in( 'contenttypeid', array( $this->fetchType( 'Text' ), $this->fetchType( 'Poll' ), $this->fetchType( 'Gallery' ), $this->fetchType( 'Video' ), $this->fetchType( 'Link' ) ) ) . " AND " . \IPS\Db::i()->in( 'parentid', array_keys( $this->fetchForums() ) ), $this->fetchType( 'Text' ), $this->fetchType( 'Poll' ) ) );
|
||||
try
|
||||
{
|
||||
return parent::countRows( 'node', array( \IPS\Db::i()->in( 'contenttypeid', array( $this->fetchType( 'Text' ), $this->fetchType( 'Poll' ), $this->fetchType( 'Gallery' ), $this->fetchType( 'Video' ), $this->fetchType( 'Link' ) ) ) . " AND " . \IPS\Db::i()->in( 'parentid', array_keys( $this->fetchForums() ) ), $this->fetchType( 'Text' ), $this->fetchType( 'Poll' ) ) );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
throw new \IPS\convert\Exception( sprintf( \IPS\Member::loggedIn()->language()->get( 'could_not_count_rows' ), $table ) );
|
||||
}
|
||||
break;
|
||||
|
||||
case 'post':
|
||||
return parent::countRows( 'node', array( \IPS\Db::i()->in( 'contenttypeid', array( $this->fetchType( 'Text' ), $this->fetchType( 'Gallery' ), $this->fetchType( 'Video' ), $this->fetchType( 'Link' ), $this->fetchType( 'Poll' ) ) ) ) );
|
||||
try
|
||||
{
|
||||
return parent::countRows( 'node', array( \IPS\Db::i()->in( 'contenttypeid', array( $this->fetchType( 'Text' ), $this->fetchType( 'Gallery' ), $this->fetchType( 'Video' ), $this->fetchType( 'Link' ), $this->fetchType( 'Poll' ) ) ) ) );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
throw new \IPS\convert\Exception( sprintf( \IPS\Member::loggedIn()->language()->get( 'could_not_count_rows' ), $table ) );
|
||||
}
|
||||
break;
|
||||
|
||||
case 'attachment':
|
||||
return parent::countRows( 'node', array( "contenttypeid=?", $this->fetchType( 'Attach' ) ) );
|
||||
return parent::countRows( 'node', array( "contenttypeid IN (" . $this->fetchType( 'Attach' ) . ',' . $this->fetchType( 'Photo' ) . ")" ) );
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -132,10 +175,10 @@ class _Vbulletin5 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( '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' ) );
|
||||
|
||||
/* Rebuild Leaderboard */
|
||||
\IPS\Task::queue( 'core', 'RebuildReputationLeaderboard', array(), 4 );
|
||||
@@ -147,7 +190,7 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
/**
|
||||
* Fix Post Data
|
||||
*
|
||||
* @param string Post
|
||||
* @param string $post Post
|
||||
* @return string Fixed Posts
|
||||
*/
|
||||
public static function fixPostData( $post )
|
||||
@@ -194,7 +237,7 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Radio',
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array( 'parse' => 'image', 'options' => $options, 'descriptions' => $descriptions ),
|
||||
'field_extra' => array( 'parse' => 'image', 'options' => $options, 'descriptions' => $descriptions, 'gridspan' => 2 ),
|
||||
'field_hint' => NULL,
|
||||
'field_validation' => NULL,
|
||||
),
|
||||
@@ -209,8 +252,8 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(
|
||||
'options' => array(
|
||||
'database' => \IPS\Member::loggedIn()->language()->addToStack( 'database' ),
|
||||
'file_system' => \IPS\Member::loggedIn()->language()->addToStack( 'file_system' ),
|
||||
'database' => \IPS\Member::loggedIn()->language()->addToStack( 'conv_store_database' ),
|
||||
'file_system' => \IPS\Member::loggedIn()->language()->addToStack( 'conv_store_file_system' ),
|
||||
),
|
||||
'userSuppliedInput' => 'file_system',
|
||||
),
|
||||
@@ -301,7 +344,7 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
$libraryClass::setKey( 'node.nodeid' );
|
||||
|
||||
$clubs = $this->fetchClubs();
|
||||
foreach( $this->fetch( 'node', 'node.nodeid', array( "( " . \IPS\Db::i()->in( 'node.parentid', array_keys( $this->fetchForums() ) ) . " OR " . $this->db->in( 'node.parentid', array_keys( $clubs ) ) . " ) AND " . \IPS\Db::i()->in( 'node.contenttypeid', array( $this->fetchType( 'Text' ), $this->fetchType( 'Poll' ), $this->fetchType( 'Gallery' ), $this->fetchType( 'Video' ), $this->fetchType( 'Link' ) ) ) ) )->join( 'text', 'text.nodeid = node.nodeid' ) AS $topic )
|
||||
foreach( $this->fetch( 'node', 'node.nodeid', array( "( " . \IPS\Db::i()->in( 'node.parentid', array_keys( $this->fetchForums() ) ) . " OR " . $this->db->in( 'node.parentid', array_keys( $clubs ) ) . " ) AND " . \IPS\Db::i()->in( 'node.contenttypeid', array( $this->fetchType( 'Text' ), $this->fetchType( 'Poll' ), $this->fetchType( 'Gallery' ), $this->fetchType( 'Video' ), $this->fetchType( 'Link' ) ) ) ) ) AS $topic )
|
||||
{
|
||||
/* Pesky Polls */
|
||||
$poll = NULL;
|
||||
@@ -414,8 +457,8 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
$libraryClass = $this->getLibrary();
|
||||
|
||||
$libraryClass::setKey( 'node.nodeid' );
|
||||
|
||||
foreach( $this->fetch( 'node', 'node.nodeid', array( \IPS\Db::i()->in( 'node.contenttypeid', array( $this->fetchType( 'Text' ), $this->fetchType( 'Gallery' ), $this->fetchType( 'Video' ), $this->fetchType( 'Link' ), $this->fetchType( 'Poll' ) ) ) ) )->join( 'text', 'text.nodeid = node.nodeid' ) AS $post )
|
||||
|
||||
foreach( $this->fetch( 'node', 'node.nodeid', array( \IPS\Db::i()->in( 'node.contenttypeid', array( $this->fetchType( 'Text' ), $this->fetchType( 'Gallery' ), $this->fetchType( 'Video' ), $this->fetchType( 'Link' ), $this->fetchType( 'Poll' ) ) ) ), 'node.*, text.rawtext, text.htmlstate' )->join( 'text', 'text.nodeid = node.nodeid' ) AS $post )
|
||||
{
|
||||
/* Comments of comments of comments of comments */
|
||||
$isSubComment = FALSE;
|
||||
@@ -488,21 +531,56 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
'ip_address' => $post['ipaddress'],
|
||||
'post_date' => $post['publishdate'],
|
||||
'queued' => $queued,
|
||||
'post_htmlstate' => ( in_array( $post['htmlstate'], array( 'on', 'on_nl2br' ) ) ) ? 1 : 0,
|
||||
'post_htmlstate' => ( \in_array( $post['htmlstate'], array( 'on', 'on_nl2br' ) ) ) ? 1 : 0,
|
||||
);
|
||||
|
||||
/* Any vB5 Links? */
|
||||
if( $post['contenttypeid'] == $this->fetchType( 'Link' ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$link = $this->db->select( 'url, url_title', 'link', array('nodeid=?', $post['nodeid']) )->first();
|
||||
|
||||
if ( !empty( $link['url_title'] ) )
|
||||
{
|
||||
$info['post'] .= <<<LINK
|
||||
|
||||
[url={$link['url']}]{$link['url_title']}[/url]
|
||||
LINK;
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['post'] .= <<<LINK
|
||||
|
||||
[url]{$link['url']}[/url]
|
||||
LINK;
|
||||
}
|
||||
}
|
||||
catch ( \UnderflowException $e ) {}
|
||||
}
|
||||
|
||||
$post_id = $libraryClass->convertForumsPost( $info );
|
||||
|
||||
/* Need to insert into the SDL? */
|
||||
if ( $softDeleted )
|
||||
{
|
||||
try
|
||||
{
|
||||
$softDeleteId = $this->app->getLink( $post['deleteuserid'], 'core_members', TRUE );
|
||||
}
|
||||
/* User link doesn't exist */
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
$softDeleteId = 0;
|
||||
}
|
||||
|
||||
\IPS\Db::i()->insert( 'core_soft_delete_log', array(
|
||||
'sdl_obj_id' => $post_id,
|
||||
'sdl_obj_key' => 'post',
|
||||
'sdl_obj_member_id' => $this->app->getLink( $post['deleteuserid'], 'core_members', TRUE ),
|
||||
'sdl_obj_date' => $post['unpublishdate'] ?: time(),
|
||||
'sdl_obj_reason' => $post['deletereason'] ?: NULL,
|
||||
'sdl_locked' => 0
|
||||
'sdl_obj_id' => $post_id,
|
||||
'sdl_obj_key' => 'post',
|
||||
'sdl_obj_member_id' => $softDeleteId,
|
||||
'sdl_obj_date' => $post['unpublishdate'] ?: time(),
|
||||
'sdl_obj_reason' => $post['deletereason'] ?: NULL,
|
||||
'sdl_locked' => 0
|
||||
) );
|
||||
}
|
||||
|
||||
@@ -693,9 +771,9 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( preg_match( "/\[ATTACH=(.+?)?\]n" . $attachment['nodeid'] . "\[\/ATTACH\]/i", $post ) )
|
||||
if ( preg_match( "/\[ATTACH([^\]]+?)?\]n" . $attachment['nodeid'] . "\[\/ATTACH\]/i", $post ) )
|
||||
{
|
||||
$post = preg_replace( "/\[ATTACH(.+?)?\]" . $attachment['nodeid'] . "\[\/ATTACH\]/i", '[attachment=' . $attach_id . ':name]', $post );
|
||||
$post = preg_replace( "/\[ATTACH([^\]]+?)?\]n" . $attachment['nodeid'] . "\[\/ATTACH\]/i", '[attachment=' . $attach_id . ':name]', $post );
|
||||
|
||||
\IPS\Db::i()->update( 'forums_posts', array( 'post' => $post ), array( "pid=?", $pid ) );
|
||||
}
|
||||
@@ -712,10 +790,10 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
/* Don't fail if this table/value doesn't exist */
|
||||
catch( \Exception $e ) { }
|
||||
|
||||
if ( $oldAttachId !== NULL and preg_match( "/\[ATTACH=(.+?)?\]" . $oldAttachId . "\[\/ATTACH\]/i", $post ) )
|
||||
if ( $oldAttachId !== NULL and preg_match( "/\[ATTACH([^\]]+?)?\]" . $oldAttachId . "\[\/ATTACH\]/i", $post ) )
|
||||
{
|
||||
$update = TRUE;
|
||||
$post = preg_replace( "/\[ATTACH(.+?)?\]" . $oldAttachId . "\[\/ATTACH\]/i", '[attachment=' . $attach_id . ':name]', $post );
|
||||
$post = preg_replace( "/\[ATTACH([^\]]+?)?\]" . $oldAttachId . "\[\/ATTACH\]/i", '[attachment=' . $attach_id . ':name]', $post );
|
||||
}
|
||||
elseif( preg_match( "/\[ATTACH=JSON](.+?)\"data-attachmentid\":\"?{$attachment['nodeid']}\"?(.+?)\[\/ATTACH\]/i", $post ) )
|
||||
{
|
||||
@@ -733,6 +811,103 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
$libraryClass->setLastKeyValue( $attachment['nodeid'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert attachments (photo posts)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertAttachments2()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
|
||||
$libraryClass::setKey( 'node.nodeid' );
|
||||
|
||||
$main = $this->fetch( 'node', 'node.nodeid', array( "node.contenttypeid=?", $this->fetchType( 'Photo' ) ) )
|
||||
->join( 'photo', 'photo.nodeid = node.nodeid' )
|
||||
->join( 'filedata', 'filedata.filedataid = photo.filedataid' );
|
||||
|
||||
foreach( $main AS $attachment )
|
||||
{
|
||||
/* This is the first post in the topic */
|
||||
try
|
||||
{
|
||||
$this->app->getLink( $attachment['parentid'], 'forums_topics' );
|
||||
$post_id = $attachment['parentid'];
|
||||
}
|
||||
/* It isn't the first post in the topic */
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->app->getLink( $attachment['parentid'], 'forums_posts' );
|
||||
|
||||
$parent = $this->db->select( 'nodeid, parentid', 'node', array( "nodeid=?", $attachment['parentid'] ) )->first();
|
||||
$attachment['parentid'] = $parent['parentid'];
|
||||
$post_id = $parent['nodeid'];
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
/* No valid converter link for the parent post */
|
||||
$libraryClass->setLastKeyValue( $attachment['nodeid'] );
|
||||
$this->app->log( 'vb5_attach_missing_post_link', __METHOD__, \IPS\convert\App::LOG_WARNING, $attachment['nodeid'] );
|
||||
continue;
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
/* Parent post does not exist in vB database */
|
||||
$libraryClass->setLastKeyValue( $attachment['nodeid'] );
|
||||
$this->app->log( 'vb5_attach_missing_post', __METHOD__, \IPS\convert\App::LOG_WARNING, $attachment['nodeid'] );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$map = array(
|
||||
'id1' => $attachment['parentid'],
|
||||
'id2' => $post_id
|
||||
);
|
||||
|
||||
$info = array(
|
||||
'attach_id' => $attachment['nodeid'],
|
||||
'attach_file' => $attachment['filehash'] . '.' . $attachment['extension'],
|
||||
'attach_date' => $attachment['dateline'],
|
||||
'attach_member_id' => $attachment['userid'],
|
||||
'attach_hits' => 0,
|
||||
'attach_ext' => $attachment['extension'],
|
||||
'attach_filesize' => $attachment['filesize'],
|
||||
);
|
||||
|
||||
if ( $this->app->_session['more_info']['convertAttachments']['file_location'] == 'database' )
|
||||
{
|
||||
/* Simples! */
|
||||
$data = $attachment['filedata'];
|
||||
$path = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = NULL;
|
||||
$path = implode( '/', preg_split( '//', $attachment['userid'], -1, PREG_SPLIT_NO_EMPTY ) );
|
||||
$path = rtrim( $this->app->_session['more_info']['convertAttachments']['file_location'], '/' ) . '/' . $path . '/' . $attachment['filedataid'] . '.attach';
|
||||
|
||||
/* Apparently vBulletin had a bug between 5.0.0 and 5.1.3 where attachments were incorrectly stored in /path/userid/file.attach rather than in the user ID split location */
|
||||
if ( !file_exists( $path ) )
|
||||
{
|
||||
$path = rtrim( $this->app->_session['more_info']['convertAttachments']['file_location'], '/' ) . '/' . $attachment['userid'] . '/' . $attachment['filedataid'] . '.attach';
|
||||
}
|
||||
|
||||
/* Still not there? It might be in the database still */
|
||||
if ( !file_exists( $path ) AND $attachment['filedata'] )
|
||||
{
|
||||
$data = $attachment['filedata'];
|
||||
$path = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
$attach_id = $libraryClass->convertAttachment( $info, $map, $path, $data );
|
||||
|
||||
$libraryClass->setLastKeyValue( $attachment['nodeid'] );
|
||||
}
|
||||
}
|
||||
|
||||
/* !vBulletin Stuff */
|
||||
|
||||
@@ -769,7 +944,7 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
/**
|
||||
* Helper method to retrieve forums from nodes
|
||||
*
|
||||
* @return void
|
||||
* @return array
|
||||
*/
|
||||
protected function fetchForums()
|
||||
{
|
||||
@@ -822,11 +997,12 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
/**
|
||||
* Helper method to retrieve content type ids
|
||||
*
|
||||
* @param int|string $type The content type
|
||||
* @return void
|
||||
*/
|
||||
protected function fetchType( $type )
|
||||
{
|
||||
if ( count( $this->typesCache ) )
|
||||
if ( \count( $this->typesCache ) )
|
||||
{
|
||||
return $this->typesCache[ $type ];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,546 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @brief Converter WoltLab Forum Class
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @package Invision Community
|
||||
* @subpackage convert
|
||||
* @since 01 Apr 2020
|
||||
*/
|
||||
|
||||
namespace IPS\convert\Software\Forums;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Woltlab Forums Converter
|
||||
*/
|
||||
class _Woltlab extends \IPS\convert\Software
|
||||
{
|
||||
/**
|
||||
* @brief The WBB table prefix can change depending on the number of installs
|
||||
*/
|
||||
public static $installId = 1;
|
||||
|
||||
/**
|
||||
* Software Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function softwareName()
|
||||
{
|
||||
/* Child classes must override this method */
|
||||
return "WoltLab Suite Forum";
|
||||
}
|
||||
|
||||
/**
|
||||
* Software Key
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function softwareKey()
|
||||
{
|
||||
/* Child classes must override this method */
|
||||
return "woltlab";
|
||||
}
|
||||
|
||||
/**
|
||||
* Content we can convert from this software.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function canConvert()
|
||||
{
|
||||
return array(
|
||||
'convertForumsForums' => array(
|
||||
'table' => 'wbb' . static::$installId . '_board',
|
||||
'where' => NULL
|
||||
),
|
||||
'convertForumsTopics' => array(
|
||||
'table' => 'wbb' . static::$installId . '_thread',
|
||||
'where' => array( 'movedThreadID IS NULL' )
|
||||
),
|
||||
'convertForumsPosts' => array(
|
||||
'table' => 'wbb' . static::$installId . '_post',
|
||||
'where' => NULL
|
||||
),
|
||||
'convertAttachments' => array(
|
||||
'table' => 'wcf' . \IPS\convert\Software\Core\Woltlab::$installId . '_attachment',
|
||||
'where' => NULL
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requires Parent
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function requiresParent()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Possible Parent Conversions
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function parents()
|
||||
{
|
||||
return array( 'core' => array( 'woltlab' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Finish - Adds everything it needs to the queues and clears data store
|
||||
*
|
||||
* @return array Messages to display
|
||||
*/
|
||||
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' ) );
|
||||
|
||||
/* Rebuild Leaderboard */
|
||||
\IPS\Task::queue( 'core', 'RebuildReputationLeaderboard', array(), 4 );
|
||||
\IPS\Db::i()->delete('core_reputation_leaderboard_history');
|
||||
|
||||
/* Caches */
|
||||
\IPS\Task::queue( 'convert', 'RebuildTagCache', array( 'app' => $this->app->app_id, 'link' => 'forums_topics', 'class' => 'IPS\forums\Topic' ), 3, array( 'app', 'link', 'class' ) );
|
||||
|
||||
return array( "f_forum_last_post_data", "f_rebuild_posts", "f_recounting_forums", "f_recounting_topics", "f_topic_tags_recount" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Count Source Rows for a specific step
|
||||
*
|
||||
* @param string $table The table containing the rows to count.
|
||||
* @param array|NULL $where WHERE clause to only count specific rows, or NULL to count all.
|
||||
* @param bool $recache Skip cache and pull directly (updating cache)
|
||||
* @return integer
|
||||
* @throws \IPS\convert\Exception
|
||||
*/
|
||||
public function countRows( $table, $where=NULL, $recache=FALSE )
|
||||
{
|
||||
switch( $table )
|
||||
{
|
||||
case 'wcf' . \IPS\convert\Software\Core\Woltlab::$installId . '_attachment':
|
||||
try
|
||||
{
|
||||
$postObjects = iterator_to_array( $this->db->select( 'objectTypeID', 'wcf' . \IPS\convert\Software\Core\Woltlab::$installId . '_object_type', "objectType='com.woltlab.wbb.post'" ) );
|
||||
return $this->db->select( 'count(attachmentID)', 'wcf' . \IPS\convert\Software\Core\Woltlab::$installId . '_attachment', array( $this->db->in( 'objectTypeID', $postObjects ) ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
throw new \IPS\convert\Exception( sprintf( \IPS\Member::loggedIn()->language()->get( 'could_not_count_rows' ), $table ) );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return parent::countRows( $table, $where, $recache );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix Post Data
|
||||
*
|
||||
* @param string $post Post
|
||||
* @return string Fixed Post
|
||||
*/
|
||||
public static function fixPostData( $post )
|
||||
{
|
||||
return \IPS\convert\Software\Core\Woltlab::fixPostData( $post );
|
||||
}
|
||||
|
||||
/**
|
||||
* List of conversion methods that require additional information
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function checkConf()
|
||||
{
|
||||
return array(
|
||||
'convertAttachments',
|
||||
'convertForumsPosts'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get More Information
|
||||
*
|
||||
* @param string $method Conversion method
|
||||
* @return array
|
||||
*/
|
||||
public function getMoreInfo( $method )
|
||||
{
|
||||
$return = array();
|
||||
switch( $method )
|
||||
{
|
||||
case 'convertForumsPosts':
|
||||
/* Get our reactions to let the admin map them */
|
||||
$options = array();
|
||||
$descriptions = array();
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_reactions' ), 'IPS\Content\Reaction' ) AS $reaction )
|
||||
{
|
||||
$options[ $reaction->id ] = $reaction->_icon->url;
|
||||
$descriptions[ $reaction->id ] = \IPS\Member::loggedIn()->language()->addToStack('reaction_title_' . $reaction->id ) . '<br>' . $reaction->_description;
|
||||
}
|
||||
|
||||
$return['convertForumsPosts'] = array(
|
||||
'rep_positive' => array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Radio',
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array( 'parse' => 'image', 'options' => $options, 'descriptions' => $descriptions, 'gridspan' => 2 ),
|
||||
'field_hint' => NULL,
|
||||
'field_validation' => NULL,
|
||||
),
|
||||
'rep_negative' => array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Radio',
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array( 'parse' => 'image', 'options' => $options, 'descriptions' => $descriptions, 'gridspan' => 2 ),
|
||||
'field_hint' => NULL,
|
||||
'field_validation' => NULL,
|
||||
),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertAttachments':
|
||||
$return['convertAttachments'] = array(
|
||||
'file_location' => array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Text',
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(),
|
||||
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack('convert_woltlab_attach_path'),
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
|
||||
)
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
return ( isset( $return[ $method ] ) ) ? $return[ $method ] : array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert forums
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertForumsForums()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
$libraryClass::setKey( 'boardID' );
|
||||
|
||||
$boardObjects = iterator_to_array( $this->db->select( 'objectTypeID', 'wcf' . \IPS\convert\Software\Core\Woltlab::$installId . '_object_type', "objectType='com.woltlab.wbb.board'" ) );
|
||||
|
||||
foreach( $this->fetch( 'wbb' . static::$installId . '_board', 'boardID' ) AS $row )
|
||||
{
|
||||
$info = array(
|
||||
'id' => $row['boardID'],
|
||||
'name' => $row['title'],
|
||||
'description' => $row['description'],
|
||||
'topics' => $row['threads'],
|
||||
'posts' => $row['posts'],
|
||||
'parent_id' => !$row['parentID'] ? -1 : $row['parentID'],
|
||||
'position' => $row['position'],
|
||||
'redirect_url' => $row['externalURL'],
|
||||
'redirect_hits' => $row['clicks'],
|
||||
'inc_postcount' => $row['countUserPosts'],
|
||||
'sub_can_post' => 1,
|
||||
);
|
||||
|
||||
$libraryClass->convertForumsForum( $info );
|
||||
|
||||
/* Followers */
|
||||
foreach( $this->db->select( 'wcf' . \IPS\convert\Software\Core\Woltlab::$installId . '_user_object_watch.*', 'wcf' . \IPS\convert\Software\Core\Woltlab::$installId . '_user_object_watch', array( "objectID=? AND " . $this->db->in('objectTypeID', $boardObjects ), $row['boardID'] ) ) AS $follow )
|
||||
{
|
||||
$libraryClass->convertFollow( array(
|
||||
'follow_app' => 'forums',
|
||||
'follow_area' => 'forum',
|
||||
'follow_rel_id' => $row['boardID'],
|
||||
'follow_rel_id_type' => 'forums_forums',
|
||||
'follow_member_id' => $follow['userID'],
|
||||
'follow_is_anon' => 0,
|
||||
'follow_added' => time(),
|
||||
'follow_notify_do' => $follow['notification'],
|
||||
'follow_notify_meta' => '',
|
||||
'follow_notify_freq' => 'immediate',
|
||||
'follow_notify_sent' => 0,
|
||||
'follow_visible' => 1,
|
||||
) );
|
||||
}
|
||||
|
||||
$libraryClass->setLastKeyValue( $row['boardID'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert topics
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertForumsTopics()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
$libraryClass::setKey( 'threadID' );
|
||||
|
||||
$threadObjects = iterator_to_array( $this->db->select( 'objectTypeID', 'wcf' . \IPS\convert\Software\Core\Woltlab::$installId . '_object_type', "objectType='com.woltlab.wbb.thread'" ) );
|
||||
|
||||
foreach( $this->fetch( 'wbb' . static::$installId . '_thread', 'threadID', array( 'movedThreadID IS NULL' ) ) AS $row )
|
||||
{
|
||||
$info = array(
|
||||
'tid' => $row['threadID'],
|
||||
'title' => $row['topic'],
|
||||
'forum_id' => $row['boardID'],
|
||||
'state' => ( $row['isClosed'] == 1 ) ? 'closed' : 'open',
|
||||
'starter_id' => $row['userID'],
|
||||
'start_date' => $row['time'],
|
||||
'last_poster_id' => $row['lastPosterID'],
|
||||
'last_post' => $row['lastPostID'],
|
||||
'starter_name' => $row['username'],
|
||||
'last_poster_name' => $row['lastPoster'],
|
||||
'views' => $row['views'],
|
||||
'approved' => $row['isDeleted'] ? 0 : 1,
|
||||
'pinned' => ( $row['isSticky'] OR $row['isAnnouncement'] ) ? 1 : 0,
|
||||
);
|
||||
|
||||
$libraryClass->convertForumsTopic( $info );
|
||||
|
||||
/* Tags */
|
||||
$tags = $this->db->select( 'wcf' . \IPS\convert\Software\Core\Woltlab::$installId . '_tag_to_object.tagID', 'wcf' . \IPS\convert\Software\Core\Woltlab::$installId . '_tag_to_object', array( "objectID=? AND " . $this->db->in('objectTypeID', $threadObjects ), $row['threadID'] ) );
|
||||
$tagText = $this->db->select( 'name', 'wcf' . \IPS\convert\Software\Core\Woltlab::$installId . '_tag', array( $this->db->in( 'tagID', iterator_to_array( $tags ) ) ) );
|
||||
|
||||
foreach( $tagText as $text )
|
||||
{
|
||||
$libraryClass->convertTag( array(
|
||||
'tag_meta_app' => 'forums',
|
||||
'tag_meta_area' => 'forums',
|
||||
'tag_meta_parent_id' => $row['boardID'],
|
||||
'tag_meta_id' => $row['threadID'],
|
||||
'tag_text' => $text,
|
||||
'tag_member_id' => $row['userID'],
|
||||
) );
|
||||
}
|
||||
|
||||
/* Follows */
|
||||
foreach( $this->db->select( 'wcf' . \IPS\convert\Software\Core\Woltlab::$installId . '_user_object_watch.*', 'wcf' . \IPS\convert\Software\Core\Woltlab::$installId . '_user_object_watch', array( "objectID=? AND " . $this->db->in('objectTypeID', $threadObjects ), $row['threadID'] ) ) AS $follow )
|
||||
{
|
||||
$libraryClass->convertFollow( array(
|
||||
'follow_app' => 'forums',
|
||||
'follow_area' => 'topic',
|
||||
'follow_rel_id' => $row['threadID'],
|
||||
'follow_rel_id_type' => 'forums_topics',
|
||||
'follow_member_id' => $follow['userID'],
|
||||
'follow_is_anon' => 0,
|
||||
'follow_added' => time(),
|
||||
'follow_notify_do' => $follow['notification'],
|
||||
'follow_notify_meta' => '',
|
||||
'follow_notify_freq' => 'immediate',
|
||||
'follow_notify_sent' => 0,
|
||||
'follow_visible' => 1,
|
||||
) );
|
||||
}
|
||||
|
||||
$libraryClass->setLastKeyValue( $row['threadID'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert posts
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertForumsPosts()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
$libraryClass::setKey( 'postID' );
|
||||
|
||||
$postLikeObjects = iterator_to_array( $this->db->select( 'objectTypeID', 'wcf' . \IPS\convert\Software\Core\Woltlab::$installId . '_object_type', "objectType='com.woltlab.wbb.likeablePost'" ) );
|
||||
|
||||
foreach( $this->fetch( 'wbb' . static::$installId . '_post', 'postID' ) AS $row )
|
||||
{
|
||||
$info = array(
|
||||
'pid' => $row['postID'],
|
||||
'topic_id' => $row['threadID'],
|
||||
'post' => $row['message'],
|
||||
'edit_time' => $row['lastEditTime'],
|
||||
'author_id' => $row['userID'],
|
||||
'author_name' => $row['username'],
|
||||
'ip_address' => $row['ipAddress'],
|
||||
'post_date' => $row['time'],
|
||||
'queued' => ( $row['isDeleted'] OR $row['isClosed'] ) ? 1 : 0,
|
||||
'post_edit_reason' => $row['editReason'],
|
||||
);
|
||||
|
||||
$libraryClass->convertForumsPost( $info );
|
||||
|
||||
/* Reputation */
|
||||
foreach( $this->db->select( '*', 'wcf' . \IPS\convert\Software\Core\Woltlab::$installId . '_like', array( "objectID=? AND " . $this->db->in('objectTypeID', $postLikeObjects ), $row['postID'] ) ) AS $rep )
|
||||
{
|
||||
$reaction = ( $rep['likeValue'] > 0 ) ? $this->app->_session['more_info']['convertForumsPosts']['rep_positive'] : $this->app->_session['more_info']['convertForumsPosts']['rep_negative'];
|
||||
|
||||
$libraryClass->convertReputation( array(
|
||||
'id' => $rep['likeID'],
|
||||
'app' => 'forums',
|
||||
'type' => 'pid',
|
||||
'type_id' => $row['postID'],
|
||||
'member_id' => $rep['userID'],
|
||||
'member_received' => $rep['objectUserID'],
|
||||
'rep_date' => $rep['time'],
|
||||
'reaction' => $reaction
|
||||
) );
|
||||
}
|
||||
|
||||
$libraryClass->setLastKeyValue( $row['postID'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert attachments
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertAttachments()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
$libraryClass::setKey( 'attachmentID' );
|
||||
|
||||
$postObjects = iterator_to_array( $this->db->select( 'objectTypeID', 'wcf' . \IPS\convert\Software\Core\Woltlab::$installId . '_object_type', "objectType='com.woltlab.wbb.post'" ) );
|
||||
|
||||
foreach( $this->fetch( 'wcf' . \IPS\convert\Software\Core\Woltlab::$installId . '_attachment', 'attachmentID', array( $this->db->in( 'objectTypeID', $postObjects ) ) ) AS $row )
|
||||
{
|
||||
try
|
||||
{
|
||||
$topicId = $this->db->select( 'threadID', 'wbb' . static::$installId . '_post', array( "postID=?", $row['objectID'] ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
/* Post is orphaned */
|
||||
$libraryClass->setLastKeyValue( $row['attachmentID'] );
|
||||
continue;
|
||||
}
|
||||
|
||||
$map = array(
|
||||
'id1' => $topicId,
|
||||
'id2' => $row['objectID'],
|
||||
);
|
||||
|
||||
$info = array(
|
||||
'attach_id' => $row['attachmentID'],
|
||||
'attach_file' => $row['filename'],
|
||||
'attach_date' => $row['uploadTime'],
|
||||
'attach_member_id' => $row['userID'],
|
||||
'attach_hits' => $row['downloads'],
|
||||
'attach_filesize' => $row['filesize'],
|
||||
);
|
||||
|
||||
$attachId = $libraryClass->convertAttachment( $info, $map, rtrim( $this->app->_session['more_info']['convertAttachments']['file_location'], '/' ) . '/' . mb_substr( $row['fileHash'], 0, 2 ) . '/' . $row['attachmentID'] . '-' . $row['fileHash'] );
|
||||
|
||||
/* Update Post if we can */
|
||||
try
|
||||
{
|
||||
if ( $attachId !== FALSE )
|
||||
{
|
||||
$pid = $this->app->getLink( $row['objectID'], 'forums_posts' );
|
||||
|
||||
$post = \IPS\Db::i()->select( 'post', 'forums_posts', array( "pid=?", $pid ) )->first();
|
||||
|
||||
if( \preg_match( '#\[attach]#i', $post ) )
|
||||
{
|
||||
$post = str_ireplace( '[attach]' . $row['attachmentID'] . '[/attach]', '[attachment=' . $attachId . ':name]', $post );
|
||||
\IPS\Db::i()->update( 'forums_posts', array( 'post' => $post ), array( "pid=?", $pid ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException | \OutOfRangeException $e ) {}
|
||||
|
||||
$libraryClass->setLastKeyValue( $row['attachmentID'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we can redirect the legacy URLs from this software to the new locations
|
||||
*
|
||||
* @return NULL|\IPS\Http\Url
|
||||
*/
|
||||
public function checkRedirects()
|
||||
{
|
||||
$url = \IPS\Request::i()->url();
|
||||
|
||||
if( preg_match( '#/thread/([0-9]+)#i', $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
|
||||
{
|
||||
if( !empty( \IPS\Request::i()->postID ) )
|
||||
{
|
||||
$class = '\IPS\forums\Topic\Post';
|
||||
$types = array( 'posts', 'forums_posts' );
|
||||
$oldId = (int) \IPS\Request::i()->postID;
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = '\IPS\forums\Topic';
|
||||
$types = array( 'topics', 'forums_topics' );
|
||||
$oldId = (int) $matches[1];
|
||||
}
|
||||
}
|
||||
elseif( preg_match( '#/board/([0-9]+)#i', $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
|
||||
{
|
||||
$class = '\IPS\forums\Forum';
|
||||
$types = array( 'forums', 'forums_forums' );
|
||||
$oldId = (int) $matches[1];
|
||||
}
|
||||
|
||||
if( isset( $class ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
$data = (string) $this->app->getLink( $oldId, $types );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
$data = (string) $this->app->getLink( $oldId, $types, FALSE, TRUE );
|
||||
}
|
||||
$item = $class::load( $data );
|
||||
|
||||
if( $item instanceof \IPS\Content )
|
||||
{
|
||||
if( $item->canView() )
|
||||
{
|
||||
return $item->url();
|
||||
}
|
||||
}
|
||||
elseif( $item instanceof \IPS\Node\Model )
|
||||
{
|
||||
if( $item->can( 'view' ) )
|
||||
{
|
||||
return $item->url();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -5,21 +5,26 @@
|
||||
* @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
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Xenforo Forums Converter
|
||||
*/
|
||||
class _Xenforo extends \IPS\convert\Software
|
||||
{
|
||||
use \IPS\convert\Tools\Xenforo;
|
||||
|
||||
/**
|
||||
* @brief The similarities between XF1 and XF2 are close enough that we can use the same converter
|
||||
*/
|
||||
@@ -30,11 +35,16 @@ class _Xenforo extends \IPS\convert\Software
|
||||
*/
|
||||
public static $contentFixed = TRUE;
|
||||
|
||||
/**
|
||||
* @brief XF2.1 changed serialized data to json decoded
|
||||
*/
|
||||
public static $useJson = FALSE;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \IPS\convert\App The application to reference for database and other information.
|
||||
* @param bool Establish a DB connection
|
||||
* @param \IPS\convert\App $app The application to reference for database and other information.
|
||||
* @param bool $needDB Establish a DB connection
|
||||
* @return void
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
@@ -49,16 +59,24 @@ class _Xenforo extends \IPS\convert\Software
|
||||
/* Is this XF1 or XF2 */
|
||||
if ( static::$isLegacy === NULL )
|
||||
{
|
||||
$version = $this->db->select( 'MAX(version_id)', 'xf_template', array( "addon_id=?", 'XF' ) )->first();
|
||||
$version = $this->db->select( 'MAX(version_id)', 'xf_template', array( \IPS\Db::i()->in( 'addon_id', array( 'XF', 'XenForo' ) ) ) )->first();
|
||||
|
||||
if ( $version < 2000010 )
|
||||
{
|
||||
/* XF1 */
|
||||
static::$isLegacy = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* XF2 */
|
||||
static::$isLegacy = FALSE;
|
||||
}
|
||||
|
||||
/* Is this XF 2.1 */
|
||||
if ( $version > 2010010 )
|
||||
{
|
||||
static::$useJson = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( \Exception $e ) {} # If we can't query, we won't be able to do anything anyway
|
||||
@@ -75,7 +93,7 @@ class _Xenforo extends \IPS\convert\Software
|
||||
public static function softwareName()
|
||||
{
|
||||
/* Child classes must override this method */
|
||||
return "XenForo (1.5.x/2.0.x)";
|
||||
return "XenForo (1.5.x/2.0.x/2.1.x)";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,10 +161,16 @@ class _Xenforo extends \IPS\convert\Software
|
||||
*/
|
||||
public static function checkConf()
|
||||
{
|
||||
return array(
|
||||
'convertAttachments',
|
||||
'convertForumsPosts'
|
||||
$return = array(
|
||||
'convertAttachments'
|
||||
);
|
||||
|
||||
if( !static::$useJson )
|
||||
{
|
||||
$return[] = 'convertForumsPosts';
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,25 +185,31 @@ class _Xenforo extends \IPS\convert\Software
|
||||
switch( $method )
|
||||
{
|
||||
case 'convertForumsPosts':
|
||||
/* Get our reactions to let the admin map them */
|
||||
$options = array();
|
||||
$descriptions = array();
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_reactions' ), 'IPS\Content\Reaction' ) AS $reaction )
|
||||
/* XF 1 & 2 */
|
||||
if( !static::$useJson )
|
||||
{
|
||||
$options[ $reaction->id ] = $reaction->_icon->url;
|
||||
$descriptions[ $reaction->id ] = \IPS\Member::loggedIn()->language()->addToStack('reaction_title_' . $reaction->id ) . '<br>' . $reaction->_description;
|
||||
/* Get our reactions to let the admin map them */
|
||||
$options = array();
|
||||
$descriptions = array();
|
||||
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_reactions' ), 'IPS\Content\Reaction' ) AS $reaction )
|
||||
{
|
||||
$options[ $reaction->id ] = $reaction->_icon->url;
|
||||
$descriptions[ $reaction->id ] = \IPS\Member::loggedIn()->language()->addToStack('reaction_title_' . $reaction->id );
|
||||
}
|
||||
|
||||
$return['convertForumsPosts'] = array(
|
||||
'rep_like' => array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Radio',
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array( 'parse' => 'image', 'options' => $options, 'descriptions' => $descriptions, 'gridspan' => 2 ),
|
||||
'field_hint' => NULL,
|
||||
'field_validation' => NULL,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$return['convertForumsPosts'] = array(
|
||||
'rep_like' => array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Radio',
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array( 'parse' => 'image', 'options' => $options, 'descriptions' => $descriptions ),
|
||||
'field_hint' => NULL,
|
||||
'field_validation' => NULL,
|
||||
),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertAttachments':
|
||||
@@ -207,11 +237,11 @@ class _Xenforo 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' ) );
|
||||
|
||||
/* Caches */
|
||||
\IPS\Task::queue( 'convert', 'RebuildTagCache', array( 'app' => $this->app->app_id, 'link' => 'forums_topics', 'class' => 'IPS\forums\Topic' ), 3, array( 'app', 'link', 'class' ) );
|
||||
@@ -222,8 +252,8 @@ class _Xenforo 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 )
|
||||
{
|
||||
@@ -241,7 +271,7 @@ class _Xenforo extends \IPS\convert\Software
|
||||
{
|
||||
try
|
||||
{
|
||||
$title = ( static::$isLegacy === FALSE OR is_null( static::$isLegacy ) ) ? $xfTwoTitle : $xfOneTitle;
|
||||
$title = ( static::$isLegacy === FALSE OR \is_null( static::$isLegacy ) ) ? $xfTwoTitle : $xfOneTitle;
|
||||
return $this->db->select( 'phrase_text', 'xf_phrase', array( "title=?", $title ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
@@ -332,10 +362,11 @@ class _Xenforo extends \IPS\convert\Software
|
||||
public function convertForumsTopics()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
|
||||
$libraryClass::setKey( 'thread_id' );
|
||||
|
||||
foreach( $this->fetch( 'xf_thread', 'thread_id' ) AS $row )
|
||||
|
||||
$data = iterator_to_array( $this->fetch( 'xf_thread', 'thread_id' ) );
|
||||
$this->app->preCacheLinks( $data, [ 'forums_forums' => 'node_id', 'core_members' => [ 'user_id', 'last_post_user_id' ] ] );
|
||||
foreach( $data AS $row )
|
||||
{
|
||||
/* Poll */
|
||||
$poll = NULL;
|
||||
@@ -463,13 +494,13 @@ class _Xenforo extends \IPS\convert\Software
|
||||
'follow_visible' => 1,
|
||||
) );
|
||||
}
|
||||
|
||||
|
||||
/* Tag Prefix */
|
||||
if ( $row['prefix_id'] )
|
||||
{
|
||||
$prefix = $this->getPhrase( "thread_prefix_{$row['prefix_id']}", "thread_prefix.{$row['prefix_id']}" );
|
||||
|
||||
if ( !is_null( $prefix ) )
|
||||
if ( !\is_null( $prefix ) )
|
||||
{
|
||||
$libraryClass->convertTag( array(
|
||||
'tag_meta_app' => 'forums',
|
||||
@@ -486,8 +517,8 @@ class _Xenforo extends \IPS\convert\Software
|
||||
/* Other tags */
|
||||
if ( $row['tags'] )
|
||||
{
|
||||
$tags = \unserialize( $row['tags'] );
|
||||
if ( count( $tags ) )
|
||||
$tags = static::unpack( $row['tags'] );
|
||||
if ( \count( $tags ) )
|
||||
{
|
||||
foreach( $tags AS $key => $tag )
|
||||
{
|
||||
@@ -518,30 +549,17 @@ class _Xenforo extends \IPS\convert\Software
|
||||
$libraryClass = $this->getLibrary();
|
||||
|
||||
$libraryClass::setKey( 'post_id' );
|
||||
|
||||
foreach( $this->fetch( 'xf_post', 'post_id' ) AS $row )
|
||||
$posts = iterator_to_array( $this->fetch( 'xf_post', 'post_id', null, 'xf_post.*, xf_ip.ip, xf_thread.discussion_state' )
|
||||
->join( 'xf_ip', 'xf_post.ip_id=xf_ip.ip_id' )
|
||||
->join( 'xf_thread', 'xf_post.thread_id=xf_thread.thread_id' ) );
|
||||
$this->app->preCacheLinks( $posts, [ 'forums_topics' => 'thread_id', 'core_members' => 'user_id' ] );
|
||||
foreach( $posts AS $row )
|
||||
{
|
||||
/* Query for the IP */
|
||||
try
|
||||
{
|
||||
$ip = $this->db->select( 'ip', 'xf_ip', array( "ip_id=?", $row['ip_id'] ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
$ip = '127.0.0.1';
|
||||
}
|
||||
|
||||
/* Figure out queued stuff */
|
||||
try
|
||||
if ( $row['discussion_state'] == 'deleted' )
|
||||
{
|
||||
$topic_state = $this->db->select( 'discussion_state', 'xf_thread', array( "thread_id=?", $row['thread_id'] ) )->first();
|
||||
|
||||
if ( $topic_state == 'deleted' )
|
||||
{
|
||||
$row['message_state'] = 'topic_hidden';
|
||||
}
|
||||
$row['message_state'] = 'topic_hidden';
|
||||
}
|
||||
catch( \UnderflowException $e ) {}
|
||||
|
||||
switch( $row['message_state'] )
|
||||
{
|
||||
@@ -578,29 +596,51 @@ class _Xenforo extends \IPS\convert\Software
|
||||
'post' => static::fixPostData( $row['message'] ),
|
||||
'edit_time' => $row['last_edit_date'],
|
||||
'edit_name' => $editName,
|
||||
'append_edit' => $editName ? 1 : NULL,
|
||||
'author_id' => $row['user_id'],
|
||||
'author_name' => $row['username'],
|
||||
'ip_address' => $ip,
|
||||
'ip_address' => $row['ip'] ?? '127.0.0.1',
|
||||
'post_date' => $row['post_date'],
|
||||
'queued' => $queued,
|
||||
);
|
||||
|
||||
$post_id = $libraryClass->convertForumsPost( $info );
|
||||
$libraryClass->convertForumsPost( $info );
|
||||
|
||||
/* Reputation */
|
||||
$likes = \unserialize( $row['like_users'] );
|
||||
if ( count( $likes ) )
|
||||
if ( !static::$useJson )
|
||||
{
|
||||
foreach( $likes AS $like )
|
||||
$likes = \unserialize( $row['like_users'] );
|
||||
if ( \is_array( $likes ) AND \count( $likes ) )
|
||||
{
|
||||
foreach( $likes AS $like )
|
||||
{
|
||||
$libraryClass->convertReputation( array(
|
||||
'app' => 'forums',
|
||||
'type' => 'pid',
|
||||
'type_id' => $row['post_id'],
|
||||
'member_id' => $like['user_id'],
|
||||
'member_received' => $row['user_id'],
|
||||
'reaction' => $this->app->_session['more_info']['convertForumsPosts']['rep_like'],
|
||||
'rep_date' => $row['post_date']
|
||||
) );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$reputation = iterator_to_array( $this->db->select( '*', 'xf_reaction_content', array( "content_type=? AND content_id=?", 'post', $row['post_id'] ) ) );
|
||||
$this->app->preCacheLinks( $reputation, [ 'core_members' => 'reaction_user_id' ] );
|
||||
foreach( $reputation as $reaction )
|
||||
{
|
||||
$libraryClass->convertReputation( array(
|
||||
'id' => $reaction['reaction_content_id'],
|
||||
'app' => 'forums',
|
||||
'type' => 'pid',
|
||||
'type_id' => $row['post_id'],
|
||||
'member_id' => $like['user_id'],
|
||||
'member_id' => $reaction['reaction_user_id'],
|
||||
'member_received' => $row['user_id'],
|
||||
'reaction' => $this->app->_session['more_info']['convertForumsPosts']['rep_like'],
|
||||
'rep_date' => $row['post_date']
|
||||
'reaction' => $reaction['reaction_id'],
|
||||
'rep_date' => $reaction['reaction_date']
|
||||
) );
|
||||
}
|
||||
}
|
||||
@@ -631,14 +671,13 @@ class _Xenforo extends \IPS\convert\Software
|
||||
}
|
||||
|
||||
/* Edit History */
|
||||
$latestedit = 0;
|
||||
$reason = NULL;
|
||||
$name = NULL;
|
||||
$newText = static::fixPostData( $row['message'] );
|
||||
$newText = $info['post'];
|
||||
|
||||
foreach( $this->db->select( '*', 'xf_edit_history', array( "content_type=? AND content_id=?", 'post', $row['post_id'] ) ) AS $edit )
|
||||
{
|
||||
$libraryClass->convertEditHistory( array(
|
||||
$editHistory = array(
|
||||
'id' => $edit['edit_history_id'],
|
||||
'class' => 'IPS\\forums\\Topic\\Post',
|
||||
'comment_id' => $row['post_id'],
|
||||
@@ -646,20 +685,9 @@ class _Xenforo extends \IPS\convert\Software
|
||||
'time' => $edit['edit_date'],
|
||||
'old' => static::fixPostData( $edit['old_text'] ),
|
||||
'new' => $newText
|
||||
) );
|
||||
|
||||
$newText = static::fixPostData( $edit['old_text'] );
|
||||
|
||||
if ( $edit['edit_date'] > $latestedit )
|
||||
{
|
||||
$latestedit = $edit['edit_date'];
|
||||
}
|
||||
}
|
||||
|
||||
/* If we have a latest edit, then update the main post - this should really be in the library, as the converters should not be altering data */
|
||||
if ( $latestedit )
|
||||
{
|
||||
\IPS\Db::i()->update( 'forums_posts', array( 'append_edit' => 1, 'edit_time' => $latestedit ), array( "pid=?", $post_id ) );
|
||||
);
|
||||
$libraryClass->convertEditHistory( $editHistory );
|
||||
$newText = $editHistory['old'];
|
||||
}
|
||||
|
||||
$libraryClass->setLastKeyValue( $row['post_id'] );
|
||||
@@ -716,9 +744,9 @@ class _Xenforo extends \IPS\convert\Software
|
||||
|
||||
$post = \IPS\Db::i()->select( 'post', 'forums_posts', array( "pid=?", $pid ) )->first();
|
||||
|
||||
if ( preg_match( "/\[ATTACH(.+?)?\]" . $row['attachment_id'] . "\[\/ATTACH\]/i", $post ) )
|
||||
if ( preg_match( "/\[ATTACH([^\]]+?)?\]" . $row['attachment_id'] . "\[\/ATTACH\]/i", $post ) )
|
||||
{
|
||||
$post = preg_replace( "/\[ATTACH(.+?)?\]" . $row['attachment_id'] . "\[\/ATTACH\]/i", '[attachment=' . $attachId . ':name]', $post );
|
||||
$post = preg_replace( "/\[ATTACH([^\]]+?)?\]" . $row['attachment_id'] . "\[\/ATTACH\]/i", '[attachment=' . $attachId . ':name]', $post );
|
||||
\IPS\Db::i()->update( 'forums_posts', array( 'post' => $post ), array( "pid=?", $pid ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user