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 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];
|
||||
|
||||
|
||||
Reference in new issue
Block a user