Version 4.3.0

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

No files matched your search

@@ -119,7 +119,8 @@ class _Bbpress extends \IPS\convert\Software
'id' => $row['ID'],
'name' => $row['post_title'],
'description' => $row['post_content'],
'parent_id' => $row['post_parent'],
'parent_id' => $row['post_parent'] ?: NULL,
'sub_can_post' => 1
);
$libraryClass->convertForumsForum( $info );
@@ -74,6 +74,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 )
{
$rows['convertOtherPosts'] = $rows['convertForumsPosts'];
$rows['convertOtherPosts']['step_method'] = 'convertOtherPosts';
$rows['convertOtherPosts']['source_rows'] = $this->countRows( static::canConvert()['convertOtherPosts']['table'], static::canConvert()['convertOtherPosts']['where'] );
return $rows;
}
/**
* Requires Parent
*
@@ -0,0 +1,524 @@
<?php
/**
* @brief Converter Invision Community Class
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @package Invision Community
* @subpackage Converter
* @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' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
class _Invisioncommunity extends \IPS\convert\Software
{
/**
* @brief Whether the versions of IPS4 match
*/
public static $versionMatch = FALSE;
/**
* @brief Whether the database has been required
*/
public static $dbNeeded = FALSE;
public function __construct( \IPS\convert\App $app, $needDB=TRUE )
{
/* Set filename obscuring flag */
\IPS\convert\Library::$obscureFilenames = FALSE;
$return = parent::__construct( $app, $needDB );
if( $needDB )
{
static::$dbNeeded = TRUE;
$version = $this->db->select( 'app_version', 'core_applications', array( 'app_directory=?', 'core' ) )->first();
/* We're matching against the human version since the long version can change with patches */
if( $version == \IPS\Application::load( 'core')->version )
{
static::$versionMatch = TRUE;
}
/* Get parent sauce */
$this->parent = $this->app->get__parent()->getSource();
}
return $return;
}
/**
* Software Name
*
* @return string
*/
public static function softwareName()
{
/* Child classes must override this method */
return 'Invision Community (' . \IPS\Application::load( 'core' )->version . ')';
}
/**
* Software Key
*
* @return string
*/
public static function softwareKey()
{
/* Child classes must override this method */
return "invisioncommunity";
}
/**
* Content we can convert from this software.
*
* @return array
*/
public static function canConvert()
{
if( !static::$versionMatch AND static::$dbNeeded )
{
throw new \IPS\convert\Exception( 'convert_invision_mismatch' );
}
return array(
'convertForumsForums' => array(
'table' => 'forums_forums',
'where' => NULL,
),
'convertForumsTopics' => array(
'table' => 'forums_topics',
'where' => NULL,
),
'convertForumsPosts' => array(
'table' => 'forums_posts',
'where' => NULL,
),
'convertForumsTopicsMultimods' => array(
'table' => 'forums_topic_mmod',
'where' => NULL,
),
'convertForumsRssImports' => array(
'table' => 'forums_rss_import',
'where' => NULL,
),
'convertForumsRssImported' => array(
'table' => 'forums_rss_imported',
'where' => NULL,
),
'convertForumsQuestionRatings' => array(
'table' => 'forums_question_ratings',
'where' => NULL,
),
'convertForumsAnswerRatings' => array(
'table' => 'forums_answer_ratings',
'where' => NULL,
),
'convertAttachments' => array(
'table' => 'core_attachments',
'where' => NULL
),
);
}
/**
* Requires Parent
*
* @return boolean
*/
public static function requiresParent()
{
return TRUE;
}
/**
* List of conversion methods that require additional information
*
* @return array
*/
public static function checkConf()
{
return array(
'convertAttachments'
);
}
/**
* Get More Information
*
* @param string $method Method name
* @return array
*/
public function getMoreInfo( $method )
{
$return = array();
switch( $method )
{
case 'convertAttachments':
\IPS\Member::loggedIn()->language()->words["upload_path"] = \IPS\Member::loggedIn()->language()->addToStack( 'convert_invision_upload_input' );
\IPS\Member::loggedIn()->language()->words["upload_path_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'convert_invision_upload_input_desc' );
$return[ $method ] = array(
'upload_path' => array(
'field_class' => 'IPS\\Helpers\\Form\\Text',
'field_default' => isset( $this->parent->app->_session['more_info']['convertEmoticons']['upload_path'] ) ? $this->parent->app->_session['more_info']['convertEmoticons']['upload_path'] : NULL,
'field_required' => TRUE,
'field_extra' => array(),
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack('convert_invision_upload_path'),
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
)
);
break;
}
return ( isset( $return[ $method ] ) ) ? $return[ $method ] : array();
}
/**
* Possible Parent Conversions
*
* @return array
*/
public static function parents()
{
return array( 'core' => array( 'invisioncommunity' ) );
}
/**
* 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 ), 5, 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', 'InvisionCommunityRebuildContent', array( 'app' => $this->app->app_id, 'link' => 'forums_posts', 'class' => 'IPS\forums\Topic\Post' ), 2, array( 'app', 'link', 'class' ) );
/* Caches */
\IPS\Task::queue( 'convert', 'RebuildTagCache', array( 'app' => $this->app->app_id, 'link' => 'forums_topics', 'class' => 'IPS\forums\Topic' ), 3, array( 'app', 'link', 'class' ) );
/* Rebuild Leaderboard */
\IPS\Task::queue( 'core', 'RebuildReputationLeaderboard', array(), 4 );
\IPS\Db::i()->delete('core_reputation_leaderboard_history');
return array( "f_forum_last_post_data", "f_rebuild_posts", "f_recounting_forums", "f_recounting_topics", "f_topic_tags_recount" );
}
/**
* Convert forums
*
* @return void
*/
public function convertForumsForums()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'id' );
foreach( $this->fetch( 'forums_forums', 'id' ) AS $row )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $row, 'forums_forums', 'forums' );
/* Add name after clearing other columns */
$row['name'] = $this->parent->getWord( 'forums_forum_' . $row['id'] );
$row['description'] = $this->parent->getWord( 'forums_forum_' . $row['id'] . '_desc' );
$libraryClass->convertForumsForum( $row );
/* Convert Follows */
foreach( $this->db->select( '*', 'core_follow', array( 'follow_app=? AND follow_area=? AND follow_rel_id=?', 'forums', 'forum', $row['id'] ) ) as $follow )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $follow, 'core_follow', 'core' );
/* Change follow data */
$follow['follow_rel_id_type'] = 'forums_forums';
$libraryClass->convertFollow( $follow );
}
$libraryClass->setLastKeyValue( $row['id'] );
}
}
/**
* Convert topics
*
* @return void
*/
public function convertForumsTopics()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'tid' );
foreach( $this->fetch( 'forums_topics', 'tid' ) AS $row )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $row, 'forums_topics', 'forums' );
$libraryClass->convertForumsTopic( $row );
/* Convert Follows */
foreach( $this->db->select( '*', 'core_follow', array( 'follow_app=? AND follow_area=? AND follow_rel_id=?', 'forums', 'topic', $row['tid'] ) ) as $follow )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $follow, 'core_follow', 'core' );
/* Change follow data */
$follow['follow_rel_id_type'] = 'forums_topics';
$libraryClass->convertFollow( $follow );
}
/* Convert Ratings */
foreach( $this->db->select( '*', 'core_ratings', array( 'class=? AND item_id=?', 'IPS\\forums\\Topic', $row['tid'] ) ) as $rating )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $rating, 'core_ratings', 'core' );
/* Change rating data */
$rating['item_link'] = 'forums_topics';
$libraryClass->convertRating( $rating );
}
/* Convert Tags */
foreach( $this->db->select( '*', 'core_tags', array( 'tag_meta_app=? AND tag_meta_area=? AND tag_meta_id=?', 'forums', 'forums', $row['tid'] ) ) as $tag )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $tag, 'core_tags', 'core' );
$libraryClass->convertTag( $tag );
}
$libraryClass->setLastKeyValue( $row['tid'] );
}
}
/**
* Convert posts
*
* @return void
*/
public function convertForumsPosts()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'pid' );
foreach( $this->fetch( 'forums_posts', 'pid' ) AS $row )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $row, 'forums_posts', 'forums' );
$libraryClass->convertForumsPost( $row );
/* Convert Edit History */
foreach( $this->db->select( '*', 'core_edit_history', array( 'class=? AND comment_id=?', 'IPS\\forums\\Topic\\Post', $row['pid'] ) ) as $history )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $history, 'core_edit_history', 'core' );
$libraryClass->convertEditHistory( $history );
}
/* Reputation */
foreach( $this->db->select( '*', 'core_reputation_index', array( "app=? AND type=? AND type_id=?", 'forums', 'pid', $row['pid'] ) ) AS $rep )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $rep, 'core_reputation_index', 'core' );
$libraryClass->convertReputation( $rep );
}
$libraryClass->setLastKeyValue( $row['pid'] );
}
}
/**
* Convert topics mmod
*
* @return void
*/
public function convertForumsTopicsMultimods()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'mm_id' );
foreach( $this->fetch( 'forums_topic_mmod', 'mm_id' ) AS $row )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $row, 'forums_topic_mmod', 'forums' );
/* Add name after clearing other columns */
$row['mm_name'] = $this->parent->getWord( 'forums_mmod_' . $row['mm_id'] );
$libraryClass->convertForumsTopicMultimod( $row );
$libraryClass->setLastKeyValue( $row['mm_id'] );
}
}
/**
* Convert rss imports
*
* @return void
*/
public function convertForumsRssImports()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'rss_import_id' );
foreach( $this->fetch( 'forums_rss_import', 'rss_import_id' ) AS $row )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $row, 'forums_rss_import', 'forums' );
$libraryClass->convertForumsRssImport( $row );
$libraryClass->setLastKeyValue( $row['rss_import_id'] );
}
}
/**
* Convert rss imported
*
* @return void
*/
public function convertForumsRssImported()
{
$libraryClass = $this->getLibrary();
foreach( $this->fetch( 'forums_rss_imported', 'rss_imported_tid' ) AS $row )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $row, 'forums_rss_imported', 'forums' );
$libraryClass->convertForumsRssImported( $row );
}
}
/**
* Convert attachments
*
* @return void
*/
public function convertAttachments()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'attach_id' );
foreach( $this->fetch( 'core_attachments', 'attach_id' ) AS $row )
{
try
{
$attachmentMap = $this->db->select( '*', 'core_attachments_map', array( 'attachment_id=? AND location_key=?', $row['attach_id'], 'forums_Forums' ) )->first();
}
catch( \UnderflowException $e )
{
$libraryClass->setLastKeyValue( $row['attach_id'] );
continue;
}
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $row, 'core_attachments' );
$this->parent->unsetNonStandardColumns( $attachmentMap, 'core_attachments_map' );
/* Remap rows */
$name = explode( '/', $row['attach_location'] );
$row['attach_container'] = isset( $name[1] ) ? $name[0] : NULL;
$thumbName = explode( '/', $row['attach_thumb_location'] );
$row['attach_thumb_container'] = isset( $thumbName[1] ) ? $thumbName[0] : NULL;
$filePath = $this->app->_session['more_info']['convertAttachments']['upload_path'] . '/' . $row['attach_location'];
$thumbnailPath = $this->app->_session['more_info']['convertAttachments']['upload_path'] . '/' . $row['attach_thumb_location'];
unset( $row['attach_file'] );
$libraryClass->convertAttachment( $row, $attachmentMap, $filePath, NULL, $thumbnailPath );
$libraryClass->setLastKeyValue( $row['attach_id'] );
}
}
/**
* 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( '#/ips4merge/(forum|topic)/([0-9]+)-(.+?)#i', $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
{
$oldId = (int) $matches[2];
switch( $matches[1] )
{
case 'forum':
$class = '\IPS\forums\Forum';
$types = array( 'forums', 'forums_forums' );
break;
case 'topic':
$class = '\IPS\forums\Topic';
$types = array( 'topics', 'forums_topics' );
if( \IPS\Request::i()->do == 'findComment' AND \IPS\Request::i()->comment )
{
$class = '\IPS\forums\Topic\Post';
$types = array( 'posts', 'forums_posts' );
$oldId = \IPS\Request::i()->comment;
}
break;
}
}
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;
}
}
@@ -185,6 +185,17 @@ class _Mybb extends \IPS\convert\Software
return array( "f_forum_last_post_data", "f_rebuild_posts", "f_recounting_forums", "f_recounting_topics", "f_topic_tags_recount" );
}
/**
* Fix Post Data
*
* @param string Post
* @return string Fixed Posts
*/
public static function fixPostData( $post )
{
return \IPS\convert\Software\Core\Mybb::fixPostData( $post );
}
/**
* Convert forums
*
@@ -237,7 +248,6 @@ class _Mybb extends \IPS\convert\Software
'follow_notify_freq' => 'immediate',
'follow_notify_sent' => 0,
'follow_visible' => 1,
'follow_index_id' => NULL
) );
}
@@ -413,7 +423,6 @@ class _Mybb extends \IPS\convert\Software
'follow_notify_freq' => 'immediate',
'follow_notify_sent' => 0,
'follow_visible' => 1,
'follow_index_id' => NULL
) );
}
@@ -498,7 +507,7 @@ class _Mybb extends \IPS\convert\Software
/* Warnings */
foreach( $this->db->select( '*', 'warnings', array( "pid=?", $row['pid'] ) ) AS $warn )
{
$libraryClass->convertWarnLog( array(
$warnId = $libraryClass->convertWarnLog( array(
'wl_id' => $warn['wid'],
'wl_member' => $warn['uid'],
'wl_moderator' => $warn['issuedby'],
@@ -506,6 +515,17 @@ class _Mybb extends \IPS\convert\Software
'wl_points' => $warn['points'],
'wl_note_mods' => $warn['notes'],
) );
/* Add a member history record for this member */
$libraryClass->convertMemberHistory( array(
'log_id' => 'w' . $warn['wid'],
'log_member' => $warn['uid'],
'log_by' => $warn['issuedby'],
'log_type' => 'warning',
'log_data' => array( 'wid' => $warnId ),
'log_date' => $warn['dateline']
)
);
}
$libraryClass->setLastKeyValue( $row['pid'] );
@@ -28,7 +28,7 @@ class _Phpbb extends \IPS\convert\Software
public static function softwareName()
{
/* Child classes must override this method */
return "phpBB 3.x";
return "phpBB (3.1.x/3.2.x)";
}
/**
@@ -229,7 +229,6 @@ class _Phpbb extends \IPS\convert\Software
'follow_notify_freq' => 'immediate',
'follow_notify_sent' => 0,
'follow_visible' => 1,
'follow_index_id' => NULL
) );
}
@@ -371,7 +370,6 @@ class _Phpbb extends \IPS\convert\Software
'follow_notify_freq' => 'immediate',
'follow_notify_sent' => 0,
'follow_visible' => 1,
'follow_index_id' => NULL
) );
}
@@ -495,10 +493,24 @@ class _Phpbb extends \IPS\convert\Software
$post = \IPS\Db::i()->select( 'post', 'forums_posts', array( "pid=?", $pid ) )->first();
$attachmentName = preg_quote( $row['real_filename'], '/' );
if ( preg_match( "/\[attachment=(.+?)?\]\<\!\-\- ia0 \-\-\>{$attachmentName}\<\!\-\- ia0 \-\-\>\[\/attachment\]/i", $post ) )
{
$post = preg_replace( "/\[attachment=(.+?)?\]\<\!\-\- ia0 \-\-\>{$attachmentName}\<\!\-\- ia0 \-\-\>\[\/attachment\]/i", '[attachment=' . $attachId . ':name]', $post );
$regex31 = '/\[attachment=(.+?)?\]\<\!\-\- ia[\d]+ \-\-\>' . $attachmentName . '\<\!\-\- ia[\d]+ \-\-\>\[\/attachment\]/i';
$regex32 = '/\<ATTACHMENT filename\="(.+?)?" index\="(.+?)?"\>\<s\>\[attachment\=(.+?)?\]\<\/s\>' . $attachmentName . '<e\>\[\/attachment\]\<\/e\>\<\/ATTACHMENT\>/i';
$changed = FALSE;
if( preg_match( $regex31, $post ) )
{
$changed = TRUE;
$post = preg_replace( $regex31, '[attachment=' . $attachId . ':name]', $post );
}
elseif( preg_match( $regex32, $post ) )
{
$changed = TRUE;
$post = preg_replace( $regex32, '[attachment=' . $attachId . ':name]', $post );
}
if( $changed )
{
\IPS\Db::i()->update( 'forums_posts', array( 'post' => $post ), array( "pid=?", $pid ) );
}
}
@@ -28,7 +28,7 @@ class _Punbb extends \IPS\convert\Software
public static function softwareName()
{
/* Child classes must override this method */
return "PunBB 1.x";
return "PunBB (1.x)";
}
/**
@@ -249,7 +249,6 @@ class _Punbb extends \IPS\convert\Software
'follow_notify_freq' => 'immediate',
'follow_notify_sent' => 0,
'follow_visible' => 1,
'follow_index_id' => NULL
) );
}
@@ -29,7 +29,7 @@ class _Smf extends \IPS\convert\Software
public static function softwareName()
{
/* Child classes must override this method */
return "Simple Machines Forum";
return "Simple Machines Forum (2.0.x)";
}
/**
@@ -75,6 +75,21 @@ 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 )
{
$rows['convertForumsBoards'] = $rows['convertForumsForums'];
$rows['convertForumsBoards']['step_method'] = 'convertForumsBoards';
$rows['convertForumsBoards']['source_rows'] = $this->countRows( static::canConvert()['convertForumsBoards']['table'], static::canConvert()['convertForumsBoards']['where'] );
return $rows;
}
/**
* Count Source Rows for a specific step
*
@@ -366,7 +381,6 @@ class _Smf extends \IPS\convert\Software
'follow_notify_freq' => 'immediate',
'follow_notify_sent' => 0,
'follow_visible' => 1,
'follow_index_id' => NULL
) );
}
@@ -83,6 +83,47 @@ 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 )
{
$count = $this->countRows( static::canConvert()['convertForumsTopicsRatings']['table'], static::canConvert()['convertForumsTopicsRatings']['where'] );
if( $count )
{
$rows['convertForumsTopicsRatings'] = array(
'step_method' => 'convertForumsTopicsRatings',
'step_title' => 'convert_ratings',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'core_ratings' )->first(),
'source_rows' => $count,
'per_cycle' => 1500,
'dependencies' => array( 'convertForumsTopics' ),
'link_type' => 'topic_ratings',
);
}
$count = $this->countRows( static::canConvert()['convertForumsTopicsFollowers']['table'], static::canConvert()['convertForumsTopicsFollowers']['where'] );
if( $count )
{
$rows['convertForumsTopicsFollowers'] = array(
'step_method' => 'convertForumsTopicsFollowers',
'step_title' => 'convert_follows',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'core_follow' )->first(),
'source_rows' => $count,
'per_cycle' => 1000,
'dependencies' => array( 'convertForumsTopics' ),
'link_type' => 'core_follows',
);
}
return $rows;
}
/**
* Count Source Rows for a specific step
*
@@ -247,7 +288,7 @@ class _UBBthreads extends \IPS\convert\Software
{
$libraryClass = $this->getLibrary();
foreach ( $this->fetch( 'WATCH_LISTS', 'WATCH_ID', array( 'WATCH_TYPE=?', 'f' ), 'USER_ID ASC, WATCH_ID ASC' ) as $row )
foreach ( $this->fetch( 'WATCH_LISTS', 'WATCH_ID', array( 'WATCH_TYPE=?', 'f' ) ) as $row )
{
$libraryClass->convertFollow( array(
'follow_app' => 'forums',
@@ -390,7 +431,7 @@ class _UBBthreads extends \IPS\convert\Software
{
$libraryClass = $this->getLibrary();
foreach ( $this->fetch( 'WATCH_LISTS', 'WATCH_ID', array( 'WATCH_TYPE=?', 't' ), 'USER_ID ASC, WATCH_ID ASC' ) as $row )
foreach ( $this->fetch( 'WATCH_LISTS', 'WATCH_ID', array( 'WATCH_TYPE=?', 't' ) ) as $row )
{
$libraryClass->convertFollow( array(
'follow_app' => 'forums',
@@ -489,7 +530,25 @@ class _UBBthreads extends \IPS\convert\Software
return NULL;
}
if( preg_match( '#/ubbthreads.php/topics/([0-9]+)($|/)#i', $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
//ubbthreads.php?ubb=showflat&Number=?
if( isset( \IPS\Request::i()->Number ) AND isset( \IPS\Request::i()->ubb ) )
{
try
{
$data = (string) $this->app->getLink( (int) \IPS\Request::i()->Number, array( 'posts', 'forums_posts' ) );
$post = \IPS\forums\Topic\Post::load( $data );
if( $post->item()->canView() )
{
return $post->url();
}
}
catch ( \OutOfRangeException $e )
{
return NULL;
}
}
elseif( preg_match( '#/ubbthreads.php/topics/([0-9]+)($|/)#i', $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
{
try
{
@@ -510,6 +569,18 @@ class _UBBthreads extends \IPS\convert\Software
}
catch( \Exception $e )
{
try
{
$data = (string) $this->app->getLink( (int) $matches[1], array( 'posts', 'forums_posts' ) );
$post = \IPS\forums\Topic\Post::load( $data );
if( $post->item()->canView() )
{
return $post->url();
}
}
catch ( \OutOfRangeException $e ) { }
return NULL;
}
}
@@ -530,6 +601,23 @@ class _UBBthreads extends \IPS\convert\Software
return NULL;
}
}
elseif( preg_match( '#ubbthreads.php/ubb/showflat/Number/([0-9]+)($|/)#i', $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
{
try
{
$data = (string) $this->app->getLink( (int) $matches[1], array( 'posts', 'forums_posts' ) );
$post = \IPS\forums\Topic\Post::load( $data );
if( $post->item()->canView() )
{
return $post->url();
}
}
catch ( \OutOfRangeException $e )
{
return NULL;
}
}
return NULL;
}
@@ -20,6 +20,31 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
class _Vanilla extends \IPS\convert\Software
{
/**
* @brief Store the result of the check for reaction support
*/
protected static $_supportsReactions = FALSE;
/**
* Constructor
*
* @param \IPS\convert\App The application to reference for database and other information.
* @param bool Establish a DB connection
* @return void
* @throws \InvalidArgumentException
*/
public function __construct( \IPS\convert\App $app, $needDB=TRUE )
{
$return = parent::__construct( $app, $needDB );
/* Check for reaction support - This is a Vanilla2 addon, so it may not be installed */
if ( $needDB )
{
static::$_supportsReactions = $this->db->checkForTable( 'Action' );
}
return $return;
}
/**
* Software Name
*
@@ -28,7 +53,7 @@ class _Vanilla extends \IPS\convert\Software
public static function softwareName()
{
/* Child classes must override this method */
return "Vanilla 2";
return "Vanilla 2 (2.2.x/2.3.x)";
}
/**
@@ -94,6 +119,20 @@ 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 )
{
$rows['convertForumsPosts2'] = $rows['convertForumsPosts'];
$rows['convertForumsPosts2']['step_method'] = 'convertForumsPosts2';
return $rows;
}
/**
* Count Source Rows for a specific step
*
@@ -170,30 +209,33 @@ class _Vanilla extends \IPS\convert\Software
);
break;
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 )
/* Get our reactions to let the admin map them - this is a Vanilla2 addon so it may not be installed */
if( static::$_supportsReactions )
{
$options[ $reaction->id ] = $reaction->_icon->url;
$descriptions[ $reaction->id ] = \IPS\Member::loggedIn()->language()->addToStack('reaction_title_' . $reaction->id ) . '<br>' . $reaction->_description;
}
$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();
$return['convertForumsPosts'] = array();
foreach( $this->db->select( '*', 'action' ) as $reaction )
{
\IPS\Member::loggedIn()->language()->words['reaction_' . $reaction['ActionID'] ] = $reaction['Name'];
\IPS\Member::loggedIn()->language()->words['reaction_' . $reaction['ActionID'] . '_desc' ] = \IPS\Member::loggedIn()->language()->addToStack('reaction_convert_help');
foreach( $this->db->select( '*', 'Action' ) as $reaction )
{
\IPS\Member::loggedIn()->language()->words['reaction_' . $reaction['ActionID'] ] = $reaction['Name'];
\IPS\Member::loggedIn()->language()->words['reaction_' . $reaction['ActionID'] . '_desc' ] = \IPS\Member::loggedIn()->language()->addToStack('reaction_convert_help');
$return['convertForumsPosts']['reaction_' . $reaction['ActionID'] ] = 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,
);
$return['convertForumsPosts']['reaction_' . $reaction['ActionID'] ] = 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':
@@ -246,16 +288,21 @@ class _Vanilla extends \IPS\convert\Software
public static function fixPostData( $post )
{
/**
* Vanilla actually only supports plaintext posts out of the box, but there is a popular quotes plugin I think
* we should accommodate for.
* Vanilla has a quotes plugin that seems to have changed formats quite often. - We'll try to match as many formats as we can
*/
$quoted = preg_replace_callback( '#<blockquote class="Quote" rel="([^"]+)">(.+)</blockquote>#', function( $match )
{
$match[1] = str_replace( '"', '', $match[1] );
return "[quote name=\"{$match[1]}\"]{$match[2]}[/quote]";
}, $post );
$post = preg_replace( '/(?:<blockquote\s+(?:class=\"(?:User)?Quote\")?(?:\s+rel=\"(?:[^\"]+)\")?>)(?:\s+)?<div class=\"QuoteAuthor\">([^\"]+)<\/div>(?:\s+)?<div class=\"QuoteText\">(?:<p>)?(.*?)(?:<\/p>)?<\/div>(?:\s+)?<\/blockquote>/i',
'[quote name="$1"]$2[/quote]' ,
$post );
return $quoted ?: $post;
$post = preg_replace( '/(?:<blockquote\s+(?:class=\"Quote (?:User)?Quote\")?(?:\s+rel=\"(?:[^\"]+)\")?>)(?:\s+)?<div class=\"QuoteText\">(?:<p>)?(.*?)(?:<\/p>)?<\/div>(?:\s+)?<\/blockquote>/i',
'[quote]$1[/quote]' ,
$post );
$post = preg_replace( '/<blockquote\s+rel=\"([^\"]+)\"?>(.*?)<\/blockquote>/i',
'[quote name="$1"]$2[/quote]' ,
$post );
return $post;
}
/**
@@ -374,16 +421,24 @@ class _Vanilla extends \IPS\convert\Software
foreach( $discussions AS $row )
{
$row['DateLastComment'] = 0;
$row['LastCommentUserID'] = 0;
$row['LastCommentUserName'] = '';
/* If last post info is empty, fetch it */
if( $row['DateLastComment'] === NULL )
{
$data = $this->db->select( 'Comment.InsertUserID, Comment.DateInserted, User.Name', 'Comment', array( 'DiscussionID=?', $row['DiscussionID'] ), 'CommentID DESC', array( 0, 1 ) )
->join( 'User', 'Comment.InsertUserID=User.UserID' )
->first();
try
{
$data = $this->db->select( 'Comment.InsertUserID, Comment.DateInserted, User.Name', 'Comment', array( 'DiscussionID=?', $row['DiscussionID'] ), 'CommentID DESC', array( 0, 1 ) )
->join( 'User', 'Comment.InsertUserID=User.UserID' )
->first();
$row['DateLastComment'] = $data['DateInserted'];
$row['LastCommentUserID'] = $data['InsertUserId'];
$row['LastCommentUserName'] = $data['Name'];
$row['DateLastComment'] = $data['DateInserted'];
$row['LastCommentUserID'] = $data['InsertUserId'];
$row['LastCommentUserName'] = $data['Name'];
}
catch( \UnderflowException $e ) {}
}
$info = array(
@@ -472,21 +527,24 @@ class _Vanilla extends \IPS\convert\Software
$libraryClass->convertForumsPost( $info );
$libraryClass->setLastKeyValue( $row['DiscussionID'] );
/* Reputation */
foreach( $this->db->select( '*', 'reaction', array( "ParentType=? AND ParentID=?", 'comment', $row['DiscussionID'] ) ) AS $rep )
/* Reputation - Reactions are only supported if the YAGA addon was used. */
if( static::$_supportsReactions )
{
$reaction = $this->app->_session['more_info']['convertForumsPosts']['reaction_' . $rep['ActionID'] ];
foreach( $this->db->select( '*', 'Reaction', array( "ParentType=? AND ParentID=?", 'comment', $row['DiscussionID'] ) ) AS $rep )
{
$reaction = $this->app->_session['more_info']['convertForumsPosts']['reaction_' . $rep['ActionID'] ];
$libraryClass->convertReputation( array(
'id' => $rep['ReactionID'],
'app' => 'forums',
'type' => 'pid',
'type_id' => 'fp-' . $row['DiscussionID'],
'member_id' => $rep['InsertUserID'],
'member_received' => $rep['ParentAuthorID'],
'rep_date' => VanillaCore::mysqlToDateTime( $row['DateInserted'] ),
'reaction' => $reaction
) );
$libraryClass->convertReputation( array(
'id' => $rep['ReactionID'],
'app' => 'forums',
'type' => 'pid',
'type_id' => 'fp-' . $row['DiscussionID'],
'member_id' => $rep['InsertUserID'],
'member_received' => $rep['ParentAuthorID'],
'rep_date' => VanillaCore::mysqlToDateTime( $row['DateInserted'] ),
'reaction' => $reaction
) );
}
}
}
}
@@ -170,7 +170,7 @@ class _Vbulletin extends \IPS\convert\Software
/* Content Rebuilds */
\IPS\Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\forums\Forum', 'count' => 0 ), 5, 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( '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' ) );
@@ -365,7 +365,6 @@ class _Vbulletin extends \IPS\convert\Software
'follow_notify_freq' => $frequency,
'follow_notify_sent' => 0,
'follow_visible' => 1,
'follow_index_id' => NULL
) );
}
@@ -521,7 +520,6 @@ class _Vbulletin extends \IPS\convert\Software
'follow_notify_freq' => $frequency,
'follow_notify_sent' => 0,
'follow_visible' => 1,
'follow_index_id' => NULL
) );
}
@@ -660,7 +658,7 @@ class _Vbulletin extends \IPS\convert\Software
/* Warnings */
foreach( $this->db->select( '*', 'infraction', array( "postid=?", $post['postid'] ) ) AS $warn )
{
$libraryClass->convertWarnLog( array(
$warnId = $libraryClass->convertWarnLog( array(
'wl_id' => $warn['infractionid'],
'wl_member' => $warn['userid'],
'wl_moderator' => $warn['whoadded'],
@@ -669,6 +667,17 @@ class _Vbulletin extends \IPS\convert\Software
'wl_note_member' => $warn['note'],
'wl_note_mods' => $warn['customreason'],
) );
/* Add a member history record for this member */
$libraryClass->convertMemberHistory( array(
'log_id' => 'w' . $warn['infractionid'],
'log_member' => $warn['userid'],
'log_by' => $warn['whoadded'],
'log_type' => 'warning',
'log_data' => array( 'wid' => $warnId ),
'log_date' => $warn['dateline']
)
);
}
/* 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 */
@@ -715,6 +724,7 @@ class _Vbulletin extends \IPS\convert\Software
{
/* If the topic is missing, there isn't much we can do. */
$libraryClass->setLastKeyValue( $attachment['attachmentid'] );
$this->app->log( 'vb_attach_missing_topic', __METHOD__, \IPS\convert\App::LOG_WARNING, $attachment['attachmentid'] );
continue;
}
@@ -728,6 +738,7 @@ class _Vbulletin extends \IPS\convert\Software
{
/* If the filedata row is missing, there isn't much we can do. */
$libraryClass->setLastKeyValue( $attachment['attachmentid'] );
$this->app->log( 'vb_attach_missing_filedata', __METHOD__, \IPS\convert\App::LOG_WARNING, $attachment['attachmentid'] );
continue;
}
}
@@ -965,21 +976,29 @@ class _Vbulletin extends \IPS\convert\Software
\IPS\Request::i()->t = $matches[1];
\IPS\Request::i()->page = $matches[2];
}
/* Normal Topics */
elseif( preg_match( "/\/(\d+)\-.+?\.html/", $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
{
$url = $url->setPath( preg_replace( "/\/(\d+)\-.+?\.html/", "/showthread.php", $url->data[ \IPS\Http\Url::COMPONENT_PATH ] ) )->setQueryString( 't', $matches[1] );
\IPS\Request::i()->t = $matches[1];
}
/* Post Links */
elseif( preg_match( "/\/(\d+)\-.+?\-post(\d+)\.html/", $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
{
$url = $url->setPath( preg_replace( "/\/(\d+)\-.+?\-post(\d+)\.html/", "/showpost.php", $url->data[ \IPS\Http\Url::COMPONENT_PATH ] ) )->setQueryString( 'p', $matches[2] );
\IPS\Request::i()->p = $matches[2];
}
}
/* Forum URLs are the same across VB 3.8 and VB 4 */
if( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'forumdisplay.php' ) !== FALSE )
{
/* Forum URLs can be in one of 3 formats really...
* /forumdisplay.php/1-name
* /forums/1-name
* /forumdisplay.php?f=1
*/
/* Forum URLs can be in one of 4 formats really...
* /forumdisplay.php/1-name
* /forums/1-name
* /forumdisplay.php?f=1
* /forumdisplay.php?1-name
*/
$path = $url->data[ \IPS\Http\Url::COMPONENT_PATH ];
if( mb_strpos( $path, 'forumdisplay.php' ) !== FALSE )
{
@@ -987,6 +1006,10 @@ class _Vbulletin extends \IPS\convert\Software
{
$oldId = \IPS\Request::i()->f;
}
elseif( preg_match( '#^(\d+)-[^/]+#i', $url->data[ \IPS\Http\Url::COMPONENT_QUERY ], $matches ) )
{
$oldId = $matches[1];
}
else
{
$queryStringPieces = explode( '-', mb_substr( $path, mb_strpos( $path, 'forumdisplay.php/' ) + mb_strlen( 'forumdisplay.php/' ) ) );
@@ -1064,11 +1087,12 @@ 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 )
{
/* Topic URLs can be in one of 3 formats really...
* /showthread.php/1-name
* /threads/1-name
* /showthread.php?t=1
*/
/* 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
*/
$path = $url->data[ \IPS\Http\Url::COMPONENT_PATH ];
if( mb_strpos( $path, 'showthread.php' ) !== FALSE )
{
@@ -1076,6 +1100,10 @@ class _Vbulletin extends \IPS\convert\Software
{
$oldId = \IPS\Request::i()->t;
}
elseif( preg_match( '#^(\d+)-[^/]+#i', $url->data[ \IPS\Http\Url::COMPONENT_QUERY ], $matches ) )
{
$oldId = $matches[1];
}
else
{
$queryStringPieces = explode( '-', mb_substr( $path, mb_strpos( $path, 'showthread.php/' ) + mb_strlen( 'showthread.php/' ) ) );
@@ -1156,7 +1184,7 @@ class _Vbulletin extends \IPS\convert\Software
}
catch( \OutOfRangeException $e )
{
$data = $this->getLink( (string) $parameters[1], array( 'topics', 'forums_topics', FALSE, TRUE ) );
$data = $this->getLink( (string) $parameters[1], array( 'topics', 'forums_topics' ), FALSE, TRUE );
}
$item = \IPS\forums\Topic::load( $data );
@@ -91,7 +91,7 @@ class _Vbulletin5 extends \IPS\convert\Software
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' ) ) ) ) );
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' ) ) ) ) );
break;
case 'attachment':
@@ -235,8 +235,19 @@ class _Vbulletin5 extends \IPS\convert\Software
$libraryClass::setKey( 'node.nodeid' );
$clubs = $this->fetchClubs();
foreach( $this->fetch( 'node', 'nodeid', array( "node.nodeid<>2 AND ( ( node.parentid=? AND node.contenttypeid=? ) OR " . $this->db->in( 'nodeid', array_keys( $clubs ) ) . " )", $this->fetchType( 'Thread' ), $this->fetchType( 'Channel' ) ) ) AS $forum )
foreach( $this->fetch( 'node', 'nodeid', array( "node.nodeid<>? AND ( ( closure.parent=? AND node.contenttypeid=? ) OR " . $this->db->in( 'nodeid', array_keys( $clubs ) ) . " )", 2, 2, $this->fetchType( 'Channel' ) ) )->join( 'closure', "closure.child=node.nodeid" ) AS $forum )
{
/* This may be a club forum that already exists */
try
{
$this->app->getLink( $forum['nodeid'], 'forums_forums' );
$libraryClass->setLastKeyValue( $forum['nodeid'] );
$this->app->log( 'vb5_skipped_forum', __METHOD__, \IPS\convert\App::LOG_WARNING );
continue;
}
catch( \OutOfRangeException $e ){}
$self = $this;
$checkpermission = function( $name, $perm ) use ( $forum, $self )
{
@@ -441,16 +452,33 @@ class _Vbulletin5 extends \IPS\convert\Software
{
/* Actually, we don't - end of the line */
$libraryClass->setLastKeyValue( $post['nodeid'] );
$this->app->log( 'vb5_post_missing_parent_post', __METHOD__, \IPS\convert\App::LOG_WARNING, $post['nodeid'] );
continue;
}
catch( \UnderflowException $e )
{
/* Loading the parent failed - move on */
$libraryClass->setLastKeyValue( $post['nodeid'] );
$this->app->log( 'vb5_post_missing_parent_post_2', __METHOD__, \IPS\convert\App::LOG_WARNING, $post['nodeid'] );
continue;
}
}
}
/* We may need to insert some data in core_soft_delete_log later if the post was hidden by a moderator. */
$softDeleted = FALSE;
$queued = 0;
if ( !$post['approved'] )
{
/* If the post is unapproved, then that's a direct translation and the post should then be marked as hidden pending approval. */
$queued = 1;
}
else if ( $post['deleteuserid'] )
{
$queued = -1;
$softDeleted = TRUE;
}
$info = array(
'pid' => $post['nodeid'],
'topic_id' => $post['parentid'],
@@ -459,12 +487,25 @@ class _Vbulletin5 extends \IPS\convert\Software
'author_name' => $post['authorname'],
'ip_address' => $post['ipaddress'],
'post_date' => $post['publishdate'],
'queued' => $post['approved'] ? 0 : -1,
'queued' => $queued,
'post_htmlstate' => ( in_array( $post['htmlstate'], array( 'on', 'on_nl2br' ) ) ) ? 1 : 0,
);
$post_id = $libraryClass->convertForumsPost( $info );
/* Need to insert into the SDL? */
if ( $softDeleted )
{
\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
) );
}
/* Reputation */
foreach( $this->db->select( '*', 'reputation', array( "nodeid=?", $post['nodeid'] ) ) AS $rep )
{
@@ -511,7 +552,7 @@ class _Vbulletin5 extends \IPS\convert\Software
/* Warnings */
foreach( $this->db->select( '*', 'infraction', array( "nodeid=?", $post['nodeid'] ) ) AS $warn )
{
$libraryClass->convertWarnLog( array(
$warnId = $libraryClass->convertWarnLog( array(
'wl_id' => $warn['infractionid'],
'wl_member' => $warn['nodeid'],
'wl_moderator' => $warn['whoadded'],
@@ -520,6 +561,17 @@ class _Vbulletin5 extends \IPS\convert\Software
'wl_note_member' => $warn['note'],
'wl_note_mods' => $warn['customreason'],
) );
/* Add a member history record for this member */
$libraryClass->convertMemberHistory( array(
'log_id' => 'w' . $warn['infractionid'],
'log_member' => $warn['userid'],
'log_by' => $warn['whoadded'],
'log_type' => 'warning',
'log_data' => array( 'wid' => $warnId ),
'log_date' => $warn['dateline']
)
);
}
/* 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 */
@@ -566,12 +618,16 @@ class _Vbulletin5 extends \IPS\convert\Software
}
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;
}
}
@@ -644,6 +700,7 @@ class _Vbulletin5 extends \IPS\convert\Software
else
{
$oldAttachId = NULL;
$update = FALSE;
/* Try old attach ID */
try
@@ -655,8 +712,17 @@ class _Vbulletin5 extends \IPS\convert\Software
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 );
}
elseif( preg_match( "/\[ATTACH=JSON](.+?)\"data-attachmentid\":\"?{$attachment['nodeid']}\"?(.+?)\[\/ATTACH\]/i", $post ) )
{
$update = TRUE;
$post = preg_replace( "/\[ATTACH=JSON](.+?)\"data-attachmentid\":\"?{$attachment['nodeid']}\"?(.+?)\[\/ATTACH\]/i", '[attachment=' . $attach_id . ':name]', $post );
}
if( $update )
{
\IPS\Db::i()->update( 'forums_posts', array( 'post' => $post ), array( "pid=?", $pid ) );
}
}
@@ -20,11 +20,53 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
class _Xenforo extends \IPS\convert\Software
{
/**
* @brief The similarities between XF1 and XF2 are close enough that we can use the same converter
*/
public static $isLegacy = NULL;
/**
* @brief Flag to indicate the post data has been fixed during conversion, and we only need to use Legacy Parser
*/
public static $contentFixed = TRUE;
/**
* Constructor
*
* @param \IPS\convert\App The application to reference for database and other information.
* @param bool Establish a DB connection
* @return void
* @throws \InvalidArgumentException
*/
public function __construct( \IPS\convert\App $app, $needDB=TRUE )
{
$return = parent::__construct( $app, $needDB );
if ( $needDB )
{
try
{
/* Is this XF1 or XF2 */
if ( static::$isLegacy === NULL )
{
$version = $this->db->select( 'MAX(version_id)', 'xf_template', array( "addon_id=?", 'XF' ) )->first();
if ( $version < 2000010 )
{
static::$isLegacy = TRUE;
}
else
{
static::$isLegacy = FALSE;
}
}
}
catch( \Exception $e ) {} # If we can't query, we won't be able to do anything anyway
}
return $return;
}
/**
* Software Name
*
@@ -33,7 +75,7 @@ class _Xenforo extends \IPS\convert\Software
public static function softwareName()
{
/* Child classes must override this method */
return "XenForo";
return "XenForo (1.5.x/2.0.x)";
}
/**
@@ -187,17 +229,19 @@ class _Xenforo extends \IPS\convert\Software
{
return \IPS\convert\Software\Core\Xenforo::fixPostData( $post );
}
/**
* Helper to fetch a xenforo phrase
*
* @param string $title Phrase
* @param string $xfOneTitle XF1 Phrase title
* @param string $xfTwoTitle XF2 Phrase Title
* @return string|null
*/
protected function getPhrase( $title )
protected function getPhrase( $xfOneTitle, $xfTwoTitle )
{
try
{
$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 )
@@ -273,7 +317,6 @@ class _Xenforo extends \IPS\convert\Software
'follow_notify_freq' => ( $follow['send_alert'] OR $follow['send_email'] ) ? 'immediate' : 'none',
'follow_notify_sent' => 0,
'follow_visible' => 1,
'follow_index_id' => NULL
) );
}
@@ -418,14 +461,13 @@ class _Xenforo extends \IPS\convert\Software
'follow_notify_freq' => ( $follow['email_subscribe'] ) ? 'immediate' : 'none',
'follow_notify_sent' => 0,
'follow_visible' => 1,
'follow_index_id' => NULL
) );
}
/* Tag Prefix */
if ( $row['prefix_id'] )
{
$prefix = $this->getPhrase( "thread_prefix_{$row['prefix_id']}" );
$prefix = $this->getPhrase( "thread_prefix_{$row['prefix_id']}", "thread_prefix.{$row['prefix_id']}" );
if ( !is_null( $prefix ) )
{
@@ -519,12 +561,23 @@ class _Xenforo extends \IPS\convert\Software
$queued = 2;
break;
}
$editName = NULL;
try
{
if( $row['last_edit_user_id'] )
{
$editName = $this->db->select( 'username', 'xf_user', array( 'user_id=?', $row['last_edit_user_id'] ) )->first();
}
}
catch( \UnderflowException $e ) {}
$info = array(
'pid' => $row['post_id'],
'topic_id' => $row['thread_id'],
'post' => static::fixPostData( $row['message'] ),
'edit_time' => $row['last_edit_date'],
'edit_name' => $editName,
'author_id' => $row['user_id'],
'author_name' => $row['username'],
'ip_address' => $ip,
@@ -555,7 +608,7 @@ class _Xenforo extends \IPS\convert\Software
/* Warnings */
foreach( $this->db->select( '*', 'xf_warning', array( "content_type=? AND content_id=?", 'post', $row['post_id'] ) ) AS $warn )
{
$libraryClass->convertWarnLog( array(
$warnId = $libraryClass->convertWarnLog( array(
'wl_id' => $warn['warning_id'],
'wl_member' => $warn['user_id'],
'wl_moderator' => $warn['warning_user_id'],
@@ -564,6 +617,17 @@ class _Xenforo extends \IPS\convert\Software
'wl_note_member' => $warn['title'],
'wl_note_mods' => $warn['notes'],
) );
/* Add a member history record for this member */
$libraryClass->convertMemberHistory( array(
'log_id' => 'w' . $warn['warning_id'],
'log_member' => $warn['user_id'],
'log_by' => $warn['warning_user_id'],
'log_type' => 'warning',
'log_data' => array( 'wid' => $warnId ),
'log_date' => $warn['warning_date']
)
);
}
/* Edit History */