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

+164 -20
View File
@@ -2,9 +2,9 @@
/**
* @brief Converter Library 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
*/
@@ -161,6 +161,44 @@ class _Forums extends Core
'link_type' => 'core_attachments',
);
break;
case 'convertClubForums':
$return[ $k ] = array(
'step_title' => 'convert_club_forums',
'step_method' => 'convertClubForums',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'forums_forums', array( "club_id IS NOT NULL" ) )->first(),
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
'per_cycle' => 2000,
'dependencies' => array( 'convertForumsForums' ),
'link_type' => 'core_club_forums'
);
break;
case 'convertClubTopics':
$return[ $k ] = array(
'step_title' => 'convert_club_topics',
'step_method' => 'convertClubTopics',
'ips_rows' => (int) \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" ) ) . ')' ) )->first(),
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
'per_cycle' => 1000,
'dependencies' => array( 'convertClubForums' ),
'link_type' => 'core_club_topics'
);
break;
case 'convertClubPosts':
$return[ $k ] = array(
'step_title' => 'convert_club_posts',
'step_method' => 'convertClubPosts',
'ips_rows' => (int) \IPS\Db::i()->select( 'COUNT(pid)', 'forums_forums', array( "club_id IS NOT NULL" ) )
->join( 'forums_topics', 'forums_topics.forum_id=forums_forums.id')
->join( 'forums_posts', 'forums_posts.topic_id=forums_topics.tid')->first(),
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
'per_cycle' => 1000,
'dependencies' => array( 'convertClubTopics' ),
'link_type' => 'core_club_posts'
);
break;
}
}
@@ -205,6 +243,7 @@ class _Forums extends Core
case 'convertForumsForums':
$return['convertForumsForums'] = array(
'core_follow' => array( 'follow_app=? AND follow_area=?', 'forums', 'forum' ),
'core_clubs_node_map' => array( "node_class=?", "IPS\\forums\\Forum" ),
'forums_forums' => NULL
);
break;
@@ -262,6 +301,18 @@ class _Forums extends Core
}
$return['convertAttachments'] = array( 'core_attachments' => \IPS\Db::i()->in( 'attach_id', $attachIds ), 'core_attachments_map' => array( "location_key=?", 'forums_Forums' ) );
break;
case 'convertClubForums':
$return['convertClubForums'] = array( 'forums_forums' => array( "club_id IS NOT NULL" ), 'core_clubs_node_map' => array( 'node_class=?', 'IPS\\forums\\Forum' ) );
break;
case 'convertClubTopics':
$return['convertClubTopics'] = array( 'forums_topics' => array( 'tid IN ( ' . (string) \IPS\Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_topics' AND app={$this->software->app->app_id}" ) ) . ')' ) );
break;
case 'convertClubPosts':
$return['convertClubPosts'] = array( 'forums_posts' => array( 'pid IN ( ' . (string) \IPS\Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_posts' AND app={$this->software->app->app_id}" ) ) . ')' ) );
break;
}
}
return $return[$method];
@@ -364,27 +415,30 @@ class _Forums extends Core
}
/* Do parent_id now - we'll need it later */
if ( isset( $info['parent_id'] ) )
if ( !isset( $info['club_id'] ) )
{
if ( $info['parent_id'] != -1 )
if ( isset( $info['parent_id'] ) )
{
try
if ( $info['parent_id'] != -1 )
{
$info['parent_id'] = $this->software->app->getLink( $info['parent_id'], 'forums_forums' );
}
catch( \OutOfRangeException $e )
{
/* Does the ID exist in the source? */
$info['conv_parent'] = $info['parent_id'];
/* Default to a category unless a later converted forum updates the parent_id */
$info['parent_id'] = -1;
try
{
$info['parent_id'] = $this->software->app->getLink( $info['parent_id'], 'forums_forums' );
}
catch( \OutOfRangeException $e )
{
/* Does the ID exist in the source? */
$info['conv_parent'] = $info['parent_id'];
/* Default to a category unless a later converted forum updates the parent_id */
$info['parent_id'] = -1;
}
}
}
}
else
{
$info['parent_id'] = $this->_getOrphanedForumCategory();
else
{
$info['parent_id'] = $this->_getOrphanedForumCategory();
}
}
if ( !isset( $info['position'] ) )
@@ -707,7 +761,7 @@ class _Forums extends Core
{
$icondata = file_get_contents( $iconpath );
}
$file = \IPS\File::create( 'forums_Icons', $info['icon'], $filedata );
$file = \IPS\File::create( 'forums_Icons', $info['icon'], $icondata );
$info['icon'] = (string) $file;
}
else
@@ -724,6 +778,36 @@ class _Forums extends Core
$info['icon'] = NULL;
}
if ( isset( $info['club_id'] ) )
{
try
{
$info['club_id'] = $this->software->app->getLink( $info['club_id'], 'core_clubs', TRUE );
}
catch( \OutOfRangeException $e )
{
if ( $info['club_id'] )
{
try
{
$info['parent_id'] = $this->software->app->getLink( '__orphan_club_forum__', 'core_clubs', TRUE );
}
catch( \OutOfRangeException $e )
{
$info['parent_id'] = $this->convertForumsForum( array(
'id' => '__orphan_club_forum__',
'name' => 'Orphaned Club Forums',
'parent_id' => -1
) );
}
}
}
}
else
{
$info['club_id'] = NULL;
}
$id = $info['id'];
unset( $info['id'] );
@@ -735,6 +819,18 @@ class _Forums extends Core
\IPS\Db::i()->update( 'forums_forums', array( "parent_id" => $inserted_id ), array( "conv_parent=? AND conv_parent<>?", $id, 0 ) );
if ( $info['club_id'] )
{
\IPS\Db::i()->insert( 'core_clubs_node_map', array(
'club_id' => $info['club_id'],
'node_class' => "IPS\\forums\\Forum",
'node_id' => $inserted_id,
'name' => $name
) );
\IPS\forums\Forum::load( $inserted_id )->setPermissionsToClub( \IPS\Member\Club::load( $info['club_id'] ) );
}
return $inserted_id;
}
@@ -1971,4 +2067,52 @@ class _Forums extends Core
return parent::convertAttachment( $info, $map, $filepath, $filedata );
}
/**
* Convert a Club Forum
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted forum, or FALSE on failure.
*/
public function convertClubForum( $info=array() )
{
$insertedId = $this->convertForumsForum( $info );
if ( $insertedId )
{
$this->software->app->addLink( $insertedId, $info['id'], 'core_clubs_forums' );
}
return $insertedId;
}
/**
* Convert a Club Topic
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted topic, or FALSE on failure.
*/
public function convertClubTopic( $info=array() )
{
$insertedId = $this->convertForumsTopic( $info );
if ( $insertedId )
{
$this->software->app->addLink( $insertedId, $info['tid'], 'core_clubs_topics' );
}
return $insertedId;
}
/**
* Convert a Club Post
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted post, or FALSE on failure.
*/
public function convertClubPost( $info=array() )
{
$insertedId = $this->convertForumsPost( $info );
if ( $insertedId )
{
$this->software->app->addLink( $insertedId, $info['pid'], 'core_clubs_posts' );
}
return $insertedId;
}
}