Version 4.2.0

This commit is contained in:
Neo committed 2025-12-19 05:44:59 -08:00
1 parent 0dc2aee5ed
commit 96997ddd8e
2074 files changed
+125454 -55780

No files matched your search

@@ -2,9 +2,9 @@
/**
* @brief Converter vBulletin 5.x Forums Class
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @package Invision Community
* @subpackage Converter
* @since 21 Jan 2015
*/
@@ -136,6 +136,10 @@ class _Vbulletin5 extends \IPS\convert\Software
\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' ) );
/* Rebuild Leaderboard */
\IPS\Task::queue( 'core', 'RebuildReputationLeaderboard', array(), 4 );
\IPS\Db::i()->delete('core_reputation_leaderboard_history');
return array( 'f_rebuild_posts', 'f_recounting_forums', 'f_recounting_topics' );
}
@@ -158,7 +162,10 @@ class _Vbulletin5 extends \IPS\convert\Software
*/
public static function checkConf()
{
return array( 'convertAttachments' );
return array(
'convertAttachments',
'convertForumsPosts'
);
}
/**
@@ -172,6 +179,28 @@ class _Vbulletin5 extends \IPS\convert\Software
$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_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':
$return['convertAttachments'] = array(
'file_location' => array(
@@ -205,8 +234,8 @@ class _Vbulletin5 extends \IPS\convert\Software
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'node.nodeid' );
foreach( $this->fetch( 'node', 'nodeid', array( "node.nodeid<>? AND closure.parent=? AND node.contenttypeid=?", 2, 2, $this->fetchType( 'Channel' ) ) )->join( 'closure', "closure.child=node.nodeid" ) AS $forum )
$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 )
{
$self = $this;
$checkpermission = function( $name, $perm ) use ( $forum, $self )
@@ -234,12 +263,13 @@ class _Vbulletin5 extends \IPS\convert\Software
'last_post' => $forum['lastcontent'],
'last_poster_id' => $forum['lastauthorid'],
'last_poster_name' => $forum['lastcontentauthor'],
'parent_id' => $forum['parentid'],
'parent_id' => ( !array_key_exists( $forum['nodeid'], $clubs ) ) ? $forum['parentid'] : -1,
'club_id' => ( array_key_exists( $forum['nodeid'], $clubs ) ) ? $forum['nodeid'] : NULL,
'position' => $forum['displayorder'],
'preview_posts' => $checkpermission( 'forumoptions', 'moderatenewpost' ),
'inc_postcount' => 1,
'forum_allow_rating' => 1,
'sub_can_post' => ( $forum['parentid'] == 2 ) ? 0 : 1,
'sub_can_post' => ( $forum['parentid'] == 2 AND !array_key_exists( $forum['nodeid'], $clubs ) ) ? 0 : 1,
);
$libraryClass->convertForumsForum( $info );
@@ -259,7 +289,8 @@ class _Vbulletin5 extends \IPS\convert\Software
$libraryClass::setKey( 'node.nodeid' );
foreach( $this->fetch( 'node', 'node.nodeid', array( \IPS\Db::i()->in( 'node.parentid', array_keys( $this->fetchForums() ) ) . " 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 )
$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 )
{
/* Pesky Polls */
$poll = NULL;
@@ -445,7 +476,7 @@ class _Vbulletin5 extends \IPS\convert\Software
'member_id' => $rep['whoadded'],
'member_received' => $rep['userid'],
'rep_date' => $rep['dateline'],
'rep_rating' => $rep['reputation']
'reaction' => $this->app->_session['more_info']['convertForumsPosts']['rep_like']
) );
}
@@ -453,6 +484,8 @@ class _Vbulletin5 extends \IPS\convert\Software
$latestedit = 0;
$reason = NULL;
$name = NULL;
$newText = $post['rawtext'];
foreach( $this->db->select( '*', 'postedithistory', array( "nodeid=?", $post['nodeid'] ) ) AS $edit )
{
$libraryClass->convertEditHistory( array(
@@ -461,9 +494,12 @@ class _Vbulletin5 extends \IPS\convert\Software
'comment_id' => $post['nodeid'],
'member' => $edit['userid'],
'time' => $edit['dateline'],
'old' => $edit['pagetext']
'old' => $edit['pagetext'],
'new' => $newText
) );
$newText = $edit['pagetext'];
if ( $edit['dateline'] > $latestedit )
{
$latestedit = $edit['dateline'];
@@ -566,6 +602,19 @@ class _Vbulletin5 extends \IPS\convert\Software
$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 );
@@ -657,8 +706,8 @@ class _Vbulletin5 extends \IPS\convert\Software
protected function fetchForums()
{
$forums = array();
foreach( $this->db->select( '*', 'node', array( "node.nodeid<>2 AND closure.parent=? AND node.contenttypeid=?", $this->fetchType( 'Thread' ), $this->fetchType( 'Channel' ) ) )->join( 'closure', "closure.child = node.nodeid" ) AS $node )
$clubs = $this->fetchClubs();
foreach( $this->db->select( '*', 'node', array( "node.nodeid<>2 AND ( ( closure.parent=? AND node.contenttypeid=? ) OR " . $this->db->in( 'nodeid', array_keys( $clubs ) ) . " )", $this->fetchType( 'Thread' ), $this->fetchType( 'Channel' ) ) )->join( 'closure', "closure.child = node.nodeid" ) AS $node )
{
$forums[$node['nodeid']] = $node;
}
@@ -666,6 +715,37 @@ class _Vbulletin5 extends \IPS\convert\Software
return $forums;
}
/**
* Fetch Clubs
*
* @return array
*/
protected function fetchClubs()
{
$clubs = array();
try
{
/* Get the main social group node ID from the channel GUID. */
$mainNodeId = $this->db->select( 'nodeid', 'channel', array( "guid=?", \IPS\convert\Software\Core\Vbulletin5::$guids['clubs'] ) )->first();
$categories = array();
foreach( $this->db->select( 'nodeid', 'node', array( "parentid=?", $mainNodeId ) ) AS $cat )
{
$categories[] = $cat;
}
/* The actual clubs are all two levels deep from the main channel node, so we need to sub-query the categories. */
foreach( $this->db->select( '*', 'node', array( $this->db->in( 'parentid', $categories ) ) ) AS $row )
{
$clubs[ $row['nodeid'] ] = $row;
}
}
catch( \UnderflowException $e ) { /* Just in case something goofy happened and there is no main channel */ }
return $clubs;
}
/**
* @brief Types Cache
*/
@@ -703,7 +783,7 @@ class _Vbulletin5 extends \IPS\convert\Software
{
$url = \IPS\Request::i()->url();
if( preg_match( '#(?<!topic)/([0-9]+)\-([^/]*?)#', $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
if( preg_match( '#(?<!topic|file|image)/([0-9]+)\-([^/]*?)#', $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
{
try
{