Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -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\Blog;
|
||||
|
||||
/* 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 Blog Converter
|
||||
*/
|
||||
class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
/**
|
||||
@@ -33,8 +36,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
|
||||
*/
|
||||
@@ -61,7 +64,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
|
||||
|
||||
/* If this is vB4, what is the content type ID for posts? */
|
||||
if ( static::$entryContentType === NULL AND ( static::$isLegacy === FALSE OR is_null( static::$isLegacy ) ) AND $needDB )
|
||||
if ( static::$entryContentType === NULL AND ( static::$isLegacy === FALSE OR \is_null( static::$isLegacy ) ) AND $needDB )
|
||||
{
|
||||
static::$entryContentType = $this->db->select( 'contenttypeid', 'contenttype', array( "class=?", 'BlogEntry' ) )->first();
|
||||
}
|
||||
@@ -102,7 +105,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
$attachmentTable = 'blog_attachment';
|
||||
$attachmentWhere = NULL;
|
||||
if ( static::$isLegacy === FALSE OR is_null( static::$isLegacy ) )
|
||||
if ( static::$isLegacy === FALSE OR \is_null( static::$isLegacy ) )
|
||||
{
|
||||
$attachmentTable = 'attachment';
|
||||
$attachmentWhere = array( "contenttypeid=?", static::$entryContentType );
|
||||
@@ -113,6 +116,10 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
'table' => 'blog_user',
|
||||
'where' => NULL,
|
||||
),
|
||||
'convertBlogEntryCategories' => array(
|
||||
'table' => 'blog_category',
|
||||
'where' => NULL
|
||||
),
|
||||
'convertBlogEntries' => array(
|
||||
'table' => 'blog',
|
||||
'where' => NULL
|
||||
@@ -146,7 +153,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
break;
|
||||
|
||||
case 'blog_text':
|
||||
return parent::countRows( 'blog_text' ) - parent::countRows( 'blog' );
|
||||
return $this->db->select( 'COUNT(*)', 'blog_text', array( 'blogtextid NOT IN (' . (string) $this->db->select( 'firstblogtextid', 'blog' ) . ')' ) )->first();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -179,6 +186,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
public function finish()
|
||||
{
|
||||
/* Content Rebuilds */
|
||||
\IPS\Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\blog\Entry\Category', 'count' => 0 ), 4, array( 'class' ) );
|
||||
\IPS\Task::queue( 'convert', 'RebuildContent', array( 'app' => $this->app->app_id, 'link' => 'blog_entries', 'class' => 'IPS\blog\Entry' ), 2, array( 'app', 'link', 'class' ) );
|
||||
\IPS\Task::queue( 'convert', 'RebuildContent', array( 'app' => $this->app->app_id, 'link' => 'blog_comments', 'class' => 'IPS\blog\Entry\Comment' ), 2, array( 'app', 'link', 'class' ) );
|
||||
\IPS\Task::queue( 'convert', 'RebuildTagCache', array( 'app' => $this->app->app_id, 'link' => 'blog_entries', 'class' => 'IPS\blog\Entry' ), 3, array( 'app', 'link', 'class' ) );
|
||||
@@ -189,7 +197,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 )
|
||||
@@ -226,8 +234,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',
|
||||
),
|
||||
@@ -314,7 +322,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
'follow_rel_id_type' => 'blog_blogs',
|
||||
'follow_member_id' => $follow['userid'],
|
||||
'follow_is_anon' => 0,
|
||||
'follow_added' => time(),
|
||||
'follow_added' => $follow['dateline'] ?: time(),
|
||||
'follow_notify_do' => 1,
|
||||
'follow_notify_meta' => '',
|
||||
'follow_notify_freq' => $frequency,
|
||||
@@ -327,6 +335,30 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert blog entries
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertBlogEntryCategories()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
$libraryClass::setKey( 'blogcategoryid' );
|
||||
|
||||
foreach( $this->fetch( 'blog_category', 'blogcategoryid' ) AS $category )
|
||||
{
|
||||
$libraryClass->convertBlogEntryCategory( array(
|
||||
'entry_category_id' => $category['blogcategoryid'],
|
||||
'entry_category_blog_id' => $category['userid'],
|
||||
'entry_category_name' => $category['title'],
|
||||
'entry_category_position' => $category['displayorder'],
|
||||
'entry_category_count' => $category['entrycount']
|
||||
) );
|
||||
|
||||
$libraryClass->setLastKeyValue( $category['blogcategoryid'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert blog entries
|
||||
*
|
||||
@@ -364,14 +396,18 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
$status = 'draft';
|
||||
}
|
||||
|
||||
$edittime = $editname = NULL;
|
||||
$edittime = $editname = $editReason = NULL;
|
||||
try
|
||||
{
|
||||
$editlog = $this->db->select( 'dateline, username', 'blog_editlog', array( "blogtextid=?", $entry['firstblogtextid'] ), "dateline DESC" )->first();
|
||||
$editlog = $this->db->select( 'dateline, username, reason', 'blog_editlog', array( "blogtextid=?", $entry['firstblogtextid'] ), "dateline DESC" )->first();
|
||||
$edittime = $editlog['dateline'];
|
||||
$editname = $editlog['username'];
|
||||
$editReason = $editlog['reason'];
|
||||
}
|
||||
catch( \UnderflowException $e ) {}
|
||||
|
||||
$categories = explode( ',', $entry['categories'] );
|
||||
$mainCategory = array_pop( $categories );
|
||||
|
||||
$info = array(
|
||||
'entry_id' => $entry['blogid'],
|
||||
@@ -389,7 +425,10 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
'entry_last_comment_mid' => $lastcommenterid,
|
||||
'entry_edit_time' => $edittime,
|
||||
'entry_edit_name' => $editname,
|
||||
'entry_ip_address' => $text['ipaddress']
|
||||
'entry_edit_reason' => $editReason,
|
||||
'entry_append_edit' => $edittime ? TRUE : FALSE,
|
||||
'entry_ip_address' => long2ip( (int) $text['ipaddress'] ),
|
||||
'entry_category_id' => $mainCategory
|
||||
);
|
||||
|
||||
$libraryClass->convertBlogEntry( $info );
|
||||
@@ -407,8 +446,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
) );
|
||||
}
|
||||
|
||||
$categories = explode( ',', $entry['categories'] );
|
||||
if ( count( $categories ) )
|
||||
if ( \count( $categories ) )
|
||||
{
|
||||
foreach( $categories as $category )
|
||||
{
|
||||
@@ -448,7 +486,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
'follow_rel_id_type' => 'blog_entries',
|
||||
'follow_member_id' => $follow['userid'],
|
||||
'follow_is_anon' => 0,
|
||||
'follow_added' => time(),
|
||||
'follow_added' => $follow['dateline'] ?: time(),
|
||||
'follow_notify_do' => 1,
|
||||
'follow_notify_meta' => '',
|
||||
'follow_notify_freq' => $frequency,
|
||||
@@ -471,20 +509,10 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
$libraryClass = $this->getLibrary();
|
||||
|
||||
$libraryClass::setKey( 'blogtextid' );
|
||||
|
||||
foreach( $this->fetch( 'blog_text', 'blogtextid' ) AS $comment )
|
||||
|
||||
// Exclude text of blog entry from iterator
|
||||
foreach( $this->fetch( 'blog_text', 'blogtextid', array( 'blogtextid NOT IN (' . (string) $this->db->select( 'firstblogtextid', 'blog' ) . ')' ) ) AS $comment )
|
||||
{
|
||||
/* Is this actually the entry? */
|
||||
try
|
||||
{
|
||||
$entry = $this->db->select( '*', 'blog', array( "firstblogtextid=?", $comment['blogtextid'] ) )->first();
|
||||
|
||||
/* If that didn't throw an exception, then yes this is - skip */
|
||||
$libraryClass->setLastKeyValue( $comment['blogtextid'] );
|
||||
continue;
|
||||
}
|
||||
catch( \UnderflowException $e ) {} # nope, carry on
|
||||
|
||||
$edittime = $editname = NULL;
|
||||
try
|
||||
{
|
||||
@@ -516,7 +544,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
'comment_text' => $comment['pagetext'],
|
||||
'comment_member_id' => $comment['userid'],
|
||||
'comment_member_name' => $comment['username'],
|
||||
'comment_ip_address' => $comment['ipaddress'],
|
||||
'comment_ip_address' => long2ip( (int) $comment['ipaddress'] ),
|
||||
'comment_date' => $comment['dateline'],
|
||||
'comment_edit_time' => $edittime,
|
||||
'comment_edit_member_name' => $editname,
|
||||
@@ -542,7 +570,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::$entryContentType );
|
||||
$column = 'contentid';
|
||||
@@ -556,7 +584,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
|
||||
foreach( $this->fetch( $table, 'attachmentid', $where ) as $attachment )
|
||||
{
|
||||
if ( static::$isLegacy === FALSE OR is_null( static::$isLegacy ) )
|
||||
if ( static::$isLegacy === FALSE OR \is_null( static::$isLegacy ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -601,7 +629,15 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
$data = NULL;
|
||||
$path = implode( '/', preg_split( '//', $filedata['userid'], -1, PREG_SPLIT_NO_EMPTY ) );
|
||||
$path = rtrim( $this->app->_session['more_info']['convertAttachments']['file_location'], '/' ) . '/' . $path . '/' . $attachment['filedataid'] . '.attach';
|
||||
if ( static::$isLegacy === FALSE )
|
||||
{
|
||||
$file = $attachment['filedataid'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$file = $attachment['attachmentid'];
|
||||
}
|
||||
$path = rtrim( $this->app->_session['more_info']['convertAttachments']['file_location'], '/' ) . '/' . $path . '/' . $file . '.attach';
|
||||
}
|
||||
|
||||
$attach_id = $libraryClass->convertAttachment( $info, $map, $path, $data );
|
||||
@@ -615,9 +651,9 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
|
||||
$post = \IPS\Db::i()->select( 'entry_content', 'blog_entries', array( "entry_id=?", $entry_id ) )->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( 'blog_entries', array( 'entry_content' => $post ), array( "entry_id=?", $entry_id ) );
|
||||
}
|
||||
}
|
||||
@@ -628,4 +664,31 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
$libraryClass->setLastKeyValue( $attachment['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( '#/entries/([0-9]+)#i', $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$data = (string) $this->app->getLink( (int) $matches[1], array( 'blog_entries' ) );
|
||||
$item = \IPS\blog\Entry::load( $data );
|
||||
|
||||
if( $item->can( 'view' ) )
|
||||
{
|
||||
return $item->url();
|
||||
}
|
||||
}
|
||||
catch( \Exception $e ) {}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user