Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

+89 -208
View File
@@ -5,21 +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\Library;
/* 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;
}
/**
* Inherit from the Core Library so we can access or overload methods as needed (for example, we do not need to redeclare convertAttachments again here, but we can overload to do extra things if needed).
* Invision Forums Converter
* @note We must extend the Core Library here so we can access methods like convertAttachment, convertFollow, etc
*/
class _Forums extends Core
{
@@ -37,7 +38,8 @@ class _Forums extends Core
public function menuRows( $rowCounts=FALSE )
{
$return = array();
$classname = get_class( $this->software );
$classname = \get_class( $this->software );
$extraRows = $this->software->extraMenuRows();
foreach( $this->getConvertableItems() as $k => $v )
{
@@ -49,7 +51,7 @@ class _Forums extends Core
'step_method' => 'convertForumsForums',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'forums_forums' ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 100,
'per_cycle' => 200,
'dependencies' => array(),
'link_type' => 'forums_forums',
);
@@ -61,7 +63,7 @@ class _Forums extends Core
'step_method' => 'convertForumsTopics',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'forums_topics' ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 1000,
'per_cycle' => 200,
'dependencies' => array( 'convertForumsForums' ),
'link_type' => 'forums_topics',
);
@@ -73,7 +75,7 @@ class _Forums extends Core
'step_method' => 'convertForumsPosts',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'forums_posts' ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 1000,
'per_cycle' => 200,
'dependencies' => array( 'convertForumsTopics' ),
'link_type' => 'forums_posts',
'requires_rebuild' => TRUE
@@ -86,7 +88,7 @@ class _Forums extends Core
'step_method' => 'convertForumsArchivePosts',
'ips_rows' => \IPS\forums\Topic\ArchivedPost::db()->select( 'COUNT(*)', 'forums_archive_posts' ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 1000,
'per_cycle' => 200,
'dependencies' => array( 'convertForumsTopics' ),
'link_type' => 'forums_posts',
);
@@ -98,7 +100,7 @@ class _Forums extends Core
'step_method' => 'convertForumsTopicMultimods',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'forums_topic_mmod' ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 100,
'per_cycle' => 200,
'dependencies' => array( 'convertForumsForums' ),
'link_type' => 'forums_topic_mmod',
);
@@ -110,7 +112,7 @@ class _Forums extends Core
'step_method' => 'convertForumsRssImports',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'forums_rss_import' ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 100,
'per_cycle' => 200,
'dependencies' => array( 'convertForumsForums' ),
'link_type' => 'forums_rss_import',
);
@@ -122,7 +124,7 @@ class _Forums extends Core
'step_method' => 'convertForumsRssImported',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'forums_rss_imported' ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 2000,
'per_cycle' => 200,
'dependencies' => array( 'convertForumsTopics', 'convertForumsRssImports' ),
'link_type' => 'forums_rss_imported',
);
@@ -134,7 +136,7 @@ class _Forums extends Core
'step_method' => 'convertForumsQuestionRatings',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'forums_question_ratings' ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 2000,
'per_cycle' => 200,
'dependencies' => array( 'convertForumsTopics' ),
'link_type' => 'forums_question_ratings',
);
@@ -146,7 +148,7 @@ class _Forums extends Core
'step_method' => 'convertForumsAnswerRatings',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'forums_answer_ratings' ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 2000,
'per_cycle' => 200,
'dependencies' => array( 'convertForumsPosts' ),
'link_type' => 'forums_answer_ratings',
);
@@ -158,7 +160,7 @@ class _Forums extends Core
'step_method' => 'convertAttachments',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'core_attachments_map', array( "location_key=?", 'forums_Forums' ) ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 50,
'per_cycle' => 10,
'dependencies' => array( 'convertForumsPosts' ),
'link_type' => 'core_attachments',
);
@@ -170,7 +172,7 @@ class _Forums extends Core
'step_method' => 'convertClubForums',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'forums_forums', array( "club_id IS NOT NULL" ) ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 2000,
'per_cycle' => 200,
'dependencies' => array( 'convertForumsForums' ),
'link_type' => 'core_club_forums'
);
@@ -182,7 +184,7 @@ class _Forums extends Core
'step_method' => 'convertClubTopics',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(tid)', 'forums_topics', array( 'forum_id IN ( ' . (string) \IPS\Db::i()->select( 'id', 'forums_forums', array( "club_id IS NOT NULL" ) ) . ')' ) ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 1000,
'per_cycle' => 200,
'dependencies' => array( 'convertClubForums' ),
'link_type' => 'core_club_topics'
);
@@ -196,15 +198,22 @@ class _Forums extends Core
->join( 'forums_topics', 'forums_topics.forum_id=forums_forums.id')
->join( 'forums_posts', 'forums_posts.topic_id=forums_topics.tid'),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 1000,
'per_cycle' => 200,
'dependencies' => array( 'convertClubTopics' ),
'link_type' => 'core_club_posts'
);
break;
}
}
$return = $this->software->extraMenuRows( $return );
/* Append any extra steps immediately to retain ordering */
if( isset( $v['extra_steps'] ) )
{
foreach( $v['extra_steps'] as $extra )
{
$return[ $extra ] = $extraRows[ $extra ];
}
}
}
/* Run the queries if we want row counts */
if( $rowCounts )
@@ -235,12 +244,13 @@ class _Forums extends Core
/**
* Returns an array of tables that need to be truncated when Empty Local Data is used
*
* @param string $method Method to truncate
* @return array
*/
protected function truncate( $method )
{
$return = array();
$classname = get_class( $this->software );
$classname = \get_class( $this->software );
if( $classname::canConvert() === NULL )
{
@@ -457,7 +467,13 @@ class _Forums extends Core
{
try
{
$position = \IPS\Db::i()->select( 'MAX(position)', 'forums_forums', array( "parent_id=?", $info['parent_id'] ) )->first();
$where = array();
if ( isset( $info['parent_id'] ) )
{
/* Clubs may not have a parent */
$where = array( "parent_id=?", $info['parent_id'] );
}
$position = \IPS\Db::i()->select( 'MAX(position)', 'forums_forums', $where )->first();
}
catch( \UnderflowException $e )
{
@@ -475,7 +491,7 @@ class _Forums extends Core
if ( isset( $info['password_override'] ) )
{
/* Array? */
if ( !is_array( $info['password_override'] ) )
if ( !\is_array( $info['password_override'] ) )
{
$info['password_override'] = explode( ',', $info['password_override'] );
}
@@ -542,7 +558,7 @@ class _Forums extends Core
if ( !isset( $info['redirect_on'] ) )
{
if ( !is_null( $info['redirect_url'] ) )
if ( !\is_null( $info['redirect_url'] ) )
{
$info['redirect_on'] = 1;
}
@@ -559,7 +575,7 @@ class _Forums extends Core
if ( !isset( $info['sub_can_post'] ) )
{
if ( $info['parent_id'] == -1 )
if ( isset( $info['parent_id'] ) AND $info['parent_id'] == -1 )
{
$info['sub_can_post'] = 0;
}
@@ -609,7 +625,7 @@ class _Forums extends Core
if ( !isset( $info['seo_last_title'] ) )
{
if ( !is_null( $info['last_title'] ) )
if ( !\is_null( $info['last_title'] ) )
{
$info['seo_last_title'] = \IPS\Http\Url::seoTitle( $info['last_title'] );
}
@@ -621,7 +637,7 @@ class _Forums extends Core
if ( !isset( $info['seo_last_name'] ) )
{
if ( !is_null( $info['last_poster_name'] ) )
if ( !\is_null( $info['last_poster_name'] ) )
{
$info['seo_last_name'] = \IPS\Http\Url::seoTitle( $info['last_poster_name'] );
}
@@ -646,6 +662,11 @@ class _Forums extends Core
}
$info['forums_bitoptions'] = $bitoptions;
}
elseif( isset( $info['ips_forums_bitoptions'] ) )
{
$info['forums_bitoptions'] = $info['ips_forums_bitoptions'];
unset( $info['ips_forums_bitoptions'] );
}
if ( !isset( $info['disable_sharelinks'] ) )
{
@@ -681,12 +702,12 @@ class _Forums extends Core
{
if ( $info['qa_rate_questions'] != '*' )
{
if ( !is_array( $info['qa_rate_questions'] ) )
if ( !\is_array( $info['qa_rate_questions'] ) )
{
$info['qa_rate_questions'] = explode( ',', $info['qa_rate_questions'] );
}
if ( count( $info['qa_rate_questions'] ) )
if ( \count( $info['qa_rate_questions'] ) )
{
$qaQuestionGroups = array();
foreach( $info['qa_rate_questions'] AS $group )
@@ -701,7 +722,7 @@ class _Forums extends Core
}
}
if ( count( $qaQuestionGroups ) )
if ( \count( $qaQuestionGroups ) )
{
$info['qa_rate_questions'] = implode( ',', $qaQuestionGroups );
}
@@ -725,12 +746,12 @@ class _Forums extends Core
{
if ( $info['qa_rate_answers'] != '*' )
{
if ( !is_array( $info['qa_rate_answers'] ) )
if ( !\is_array( $info['qa_rate_answers'] ) )
{
$info['qa_rate_answers'] = explode( ',', $info['qa_rate_answers'] );
}
if ( count( $info['qa_rate_anwsers'] ) )
if ( \count( $info['qa_rate_anwsers'] ) )
{
$qaAnswerGroups = array();
foreach( $info['qa_rate_answers'] AS $group )
@@ -745,7 +766,7 @@ class _Forums extends Core
}
}
if ( count( $qaAnswerGroups ) )
if ( \count( $qaAnswerGroups ) )
{
$info['qa_rate_answers'] = implode( ',', $qaAnswerGroups );
}
@@ -767,9 +788,9 @@ class _Forums extends Core
try
{
if ( isset( $info['icon'] ) AND ( !is_null( $iconpath ) OR !is_null( $icondata ) ) )
if ( isset( $info['icon'] ) AND ( !\is_null( $iconpath ) OR !\is_null( $icondata ) ) )
{
if ( is_null( $icondata ) AND !is_null( $iconpath ) )
if ( \is_null( $icondata ) AND !\is_null( $iconpath ) )
{
$icondata = file_get_contents( $iconpath );
}
@@ -831,7 +852,7 @@ class _Forums extends Core
\IPS\Lang::saveCustom( 'forums', "forums_forum_{$inserted_id}", $name );
\IPS\Lang::saveCustom( 'forums', "forums_forum_{$inserted_id}_desc", $desc );
\IPS\Db::i()->update( 'forums_forums', array( "parent_id" => $inserted_id ), array( "conv_parent=? AND conv_parent<>?", $id, 0 ) );
\IPS\Db::i()->update( 'forums_forums', array( "parent_id" => $inserted_id ), array( "conv_parent=?", $id ) );
\IPS\Db::i()->insert( 'core_permission_index', array( 'app' => 'forums', 'perm_type' => 'forum', 'perm_type_id' => $inserted_id, 'perm_view' => '' ) );
if ( $info['club_id'] )
@@ -910,7 +931,7 @@ class _Forums extends Core
return FALSE;
}
if ( !isset( $info['state'] ) OR !in_array( $info['state'], array( 'open', 'closed' ) ) )
if ( !isset( $info['state'] ) OR !\in_array( $info['state'], array( 'open', 'closed' ) ) )
{
$info['state'] = 'open';
}
@@ -1009,7 +1030,7 @@ class _Forums extends Core
}
/* Polls - pass off to the core library. Unlike ratings and follows, we need to do this here as we need to know the Poll ID. */
if ( isset( $info['poll_state'] ) AND is_array( $info['poll_state'] ) )
if ( isset( $info['poll_state'] ) AND \is_array( $info['poll_state'] ) )
{
if ( $info['poll_state'] = $this->convertPoll( $info['poll_state']['poll_data'], $info['poll_state']['vote_data'] ) )
{
@@ -1026,6 +1047,13 @@ class _Forums extends Core
$info['last_vote'] = $lastVote;
}
else
{
if ( $info['last_vote'] instanceof \IPS\DateTime )
{
$info['last_vote'] = $info['last_vote']->getTimestamp();
}
}
}
else
{
@@ -1059,7 +1087,7 @@ class _Forums extends Core
if ( isset( $info['moved_to'] ) )
{
if ( !is_array( $info['moved_to'] ) )
if ( !\is_array( $info['moved_to'] ) )
{
list( $topic, $forum ) = explode( '&', $info['moved_to'] );
}
@@ -1086,7 +1114,7 @@ class _Forums extends Core
$forum = NULL;
}
if ( is_null( $topic ) OR is_null( $forum ) )
if ( \is_null( $topic ) OR \is_null( $forum ) )
{
$info['moved_to'] = NULL;
}
@@ -1353,6 +1381,11 @@ class _Forums extends Core
}
$info['post_bwoptions'] = $bitoptions;
}
elseif( isset( $info['ips_post_bwoptions'] ) )
{
$info['post_bwoptions'] = $info['ips_post_bwoptions'];
unset( $info['ips_post_bwoptions'] );
}
if ( isset( $info['pdelete_time'] ) )
{
@@ -1400,7 +1433,7 @@ class _Forums extends Core
$topicUpdate['topic_answered_pid'] = $inserted_id;
}
if ( count( $topicUpdate ) )
if ( \count( $topicUpdate ) )
{
\IPS\Db::i()->update( 'forums_topics', $topicUpdate, array( "tid=?", $info['topic_id'] ) );
}
@@ -1509,12 +1542,12 @@ class _Forums extends Core
$info['mm_enabled'] = 1;
}
if ( !isset( $info['topic_state'] ) OR !in_array( $info['topic_state'], array( 'leave', 'open', 'close' ) ) )
if ( !isset( $info['topic_state'] ) OR !\in_array( $info['topic_state'], array( 'leave', 'open', 'close' ) ) )
{
$info['topic_state'] = 'leave';
}
if ( !isset( $info['topic_pin'] ) OR !in_array( $info['topic_pin'], array( 'leave', 'pin', 'unpin' ) ) )
if ( !isset( $info['topic_pin'] ) OR !\in_array( $info['topic_pin'], array( 'leave', 'pin', 'unpin' ) ) )
{
$info['topic_pin'] = 'leave';
}
@@ -1579,13 +1612,13 @@ class _Forums extends Core
{
if ( $info['mm_forums'] != '*' )
{
if ( !is_array( $info['mm_forums'] ) )
if ( !\is_array( $info['mm_forums'] ) )
{
$info['mm_forums'] = explode( ',', $info['mm_forums'] );
}
$forums = array();
if ( count( $info['mm_forums'] ) )
if ( \count( $info['mm_forums'] ) )
{
foreach( $info['mm_forums'] AS $forum )
{
@@ -1600,7 +1633,7 @@ class _Forums extends Core
}
}
if ( count( $forums ) )
if ( \count( $forums ) )
{
$info['mm_forums'] = implode( ',', $forums );
}
@@ -1615,7 +1648,7 @@ class _Forums extends Core
$info['mm_forums'] = '*';
}
if ( !isset( $info['topic_approve'] ) OR !in_array( $info['topic_approve'], array( 0, 1, 2 ) ) )
if ( !isset( $info['topic_approve'] ) OR !\in_array( $info['topic_approve'], array( 0, 1, 2 ) ) )
{
$info['topic_approve'] = 0;
}
@@ -1645,130 +1678,22 @@ class _Forums extends Core
*/
public function convertForumsRssImport( $info=array() )
{
if ( !isset( $info['rss_import_id'] ) )
{
$this->software->app->log( 'rss_import_missing_ids', __METHOD__, \IPS\convert\App::LOG_WARNING );
return FALSE;
}
/* Required Stuff */
if ( !isset( $info['rss_import_url'] ) OR filter_var( $info['rss_import_url'], FILTER_VALIDATE_URL ) === FALSE )
{
$this->software->app->log( 'rss_import_invalid_url', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['rss_import_id'] );
return FALSE;
}
if ( isset( $info['rss_import_forum_id'] ) )
{
try
{
$info['rss_import_forum_id'] = $this->software->app->getLink( $info['rss_import_forum_id'], 'forums_forums' );
}
catch( \OutOfRangeException $e )
{
$this->software->app->log( 'rss_import_missing_forum', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['rss_import_id'] );
return FALSE;
}
}
else
{
$this->software->app->log( 'rss_import_missing_forum', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['rss_import_id'] );
return FALSE;
}
if ( isset( $info['rss_import_mid'] ) )
{
try
{
$info['rss_import_mid'] = $this->software->app->getLink( $info['rss_import_mid'], 'core_members', TRUE );
}
catch( \OutOfRangeException $e )
{
$this->software->app->log( 'rss_import_missing_member', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['rss_import_id'] );
return FALSE;
}
}
else
{
$this->software->app->log( 'rss_import_missing_member', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['rss_import_id'] );
return FALSE;
}
/* Stuff we can use defaults for */
if ( !isset( $info['rss_import_title'] ) )
{
$info['rss_import_title'] = "Untitled Feed {$info['rss_import_id']}";
}
if ( !isset( $info['rss_import_pergo'] ) )
{
$info['rss_import_pergo'] = 10;
}
if ( !isset( $info['rss_import_time'] ) )
{
$info['rss_import_time'] = 30;
}
if ( isset( $info['rss_import_last_import'] ) )
{
if ( $info['rss_import_last_import'] instanceof \IPS\DateTime )
{
$info['rss_import_last_import'] = $info['rss_import_last_import']->getTimestamp();
}
}
else
{
$info['rss_import_last_import'] = time();
}
if ( !isset( $info['rss_import_showlink'] ) )
{
$info['rss_import_showlink'] = "View the full article";
}
$info['rss_import_class'] = 'IPS\\forums\\Topic';
if ( !isset( $info['rss_import_topic_open'] ) )
{
$info['rss_import_topic_open'] = 1;
}
if ( !isset( $info['rss_import_topic_hide'] ) )
{
$info['rss_import_topic_hide'] = 0;
}
if ( !isset( $info['rss_import_topic_pre'] ) )
{
$info['rss_import_topic_pre'] = '';
}
if ( !isset( $info['rss_import_allow_html'] ) )
{
$info['rss_import_allow_html'] = 0;
}
if ( isset( $info['rss_import_auth'] ) AND isset( $info['rss_import_auth_user'] ) AND isset( $info['rss_import_auth_pass'] ) )
{
if ( $info['rss_import_auth'] == 0 )
{
$info['rss_import_auth_user'] = NULL;
$info['rss_import_auth_pass'] = NULL;
}
}
else
{
$info['rss_import_auth'] = 0;
$info['rss_import_auth_user'] = NULL;
$info['rss_import_auth_pass'] = NULL;
}
$id = $info['rss_import_id'];
unset( $info['rss_import_id'] );
$inserted_id = \IPS\Db::i()->insert( 'forums_rss_import', $info );
$this->software->app->addLink( $inserted_id, $id, 'forums_rss_import' );
return $inserted_id;
$info['rss_import_settings'] = array( 'rss_import_topic_open' => $info['rss_import_topic_open'], 'rss_import_topic_hide' => $info['rss_import_topic_hide'] );
unset( $info['rss_import_topic_open'], $info['rss_import_topic_hide'] );
return parent::convertRssImport( $info, 'forums_forums', 'forums_rss_import' );
}
/**
@@ -1779,51 +1704,7 @@ class _Forums extends Core
*/
public function convertForumsRssImported( $info=array() )
{
/* Godspeed */
if ( isset( $info['rss_imported_impid'] ) )
{
try
{
$info['rss_imported_impid'] = $this->software->app->getLink( $info['rss_imported_impid'], 'forums_rss_import' );
}
catch( \OutOfRangeException $e )
{
$this->software->app->log( 'rss_imported_missing_feed', __METHOD__, \IPS\convert\App::LOG_WARNING );
return FALSE;
}
}
else
{
$this->software->app->log( 'rss_imported_missing_feed', __METHOD__, \IPS\convert\App::LOG_WARNING );
return FALSE;
}
if ( isset( $info['rss_imported_tid'] ) )
{
try
{
$info['rss_imported_tid'] = $this->software->app->getLink( $info['rss_imported_tid'], 'forums_topics' );
}
catch( \OutOfRangeException $e )
{
$this->software->app->log( 'rss_imported_missing_topic', __METHOD__, \IPS\convert\App::LOG_WARNING );
return FALSE;
}
}
else
{
$this->software->app->log( 'rss_imported_missing_topic', __METHOD__, \IPS\convert\App::LOG_WARNING );
return FALSE;
}
if ( !isset( $info['rss_imported_guid'] ) )
{
$this->software->app->log( 'rss_imported_missing_guid', __METHOD__, \IPS\convert\App::LOG_WARNING );
return FALSE;
}
\IPS\Db::i()->insert( 'forums_rss_imported', $info );
return TRUE;
return parent::convertRssImported( $info, 'forums_topics', 'forums_rss_import' );
}
/**
@@ -2073,7 +1954,7 @@ class _Forums extends Core
* @param array $map Array of Map data
* @param NULL|string $filepath The path to the attachment files or NULL if loading from the database.
* @param NULL|string $filedata If loading from the database, the content of the Binary column.
* @param NULL|string $thumnailpath Path to thumbnail image
* @param NULL|string $thumbnailpath Path to thumbnail image
* @return boolean|integer The ID of the newly inserted attachment, or FALSE on failure.
*/
public function convertAttachment( $info=array(), $map=array(), $filepath=NULL, $filedata=NULL, $thumbnailpath=NULL )