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,20 +5,21 @@
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invision Blog Converter
|
||||
* @note We must extend the Core Library here so we can access methods like convertAttachment, convertFollow, etc
|
||||
*/
|
||||
class _Blog extends Core
|
||||
@@ -37,19 +38,32 @@ class _Blog extends Core
|
||||
public function menuRows( $rowCounts=FALSE )
|
||||
{
|
||||
$return = array();
|
||||
$extraRows = $this->software->extraMenuRows();
|
||||
|
||||
foreach( $this->getConvertableItems() as $k => $v )
|
||||
{
|
||||
switch( $k )
|
||||
{
|
||||
case 'convertBlogCategories':
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_blog_categories',
|
||||
'step_method' => 'convertBlogCategories',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'blog_categories' ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array(),
|
||||
'link_type' => 'blog_categories',
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertBlogs':
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_blogs',
|
||||
'step_method' => 'convertBlogs',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'blog_blogs' ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 1000,
|
||||
'dependencies' => array(),
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertBlogCategories' ),
|
||||
'link_type' => 'blog_blogs',
|
||||
);
|
||||
break;
|
||||
@@ -60,11 +74,23 @@ class _Blog extends Core
|
||||
'step_method' => 'convertBlogEntries',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'blog_entries' ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 1500,
|
||||
'dependencies' => array( 'convertBlogs' ),
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertBlogs', 'convertBlogEntryCategories' ),
|
||||
'link_type' => 'blog_entries',
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertBlogEntryCategories':
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_blog_entry_categories',
|
||||
'step_method' => 'convertBlogEntryCategories',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'blog_entry_categories' ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array(),
|
||||
'link_type' => 'blog_entry_categories',
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertBlogComments':
|
||||
$return[ $k ] = array(
|
||||
@@ -72,7 +98,7 @@ class _Blog extends Core
|
||||
'step_method' => 'convertBlogComments',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'blog_comments' ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 1500,
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertBlogEntries' ),
|
||||
'link_type' => 'bog_comments',
|
||||
);
|
||||
@@ -84,7 +110,7 @@ class _Blog extends Core
|
||||
'step_method' => 'convertBlogRssImport',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'blog_rss_import' ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 2000,
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertBlogs' ),
|
||||
'link_type' => 'blog_rss_import',
|
||||
);
|
||||
@@ -96,7 +122,7 @@ class _Blog extends Core
|
||||
'step_method' => 'convertClubBlogs',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'blog_blogs', array( "blog_club_id IS NOT NULL" ) ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 2000,
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertClubs' ),
|
||||
'link_type' => 'core_club_blogs'
|
||||
);
|
||||
@@ -108,7 +134,7 @@ class _Blog extends Core
|
||||
'step_method' => 'convertClubBlogEntries',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'SUM(blog_entries)', 'blog_blogs', array( "blog_club_id IS NOT NULL" ) ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 1000,
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertClubBlogs' ),
|
||||
'link_type' => 'core_club_blogs_entries',
|
||||
'requires_rebuild' => TRUE
|
||||
@@ -121,7 +147,7 @@ class _Blog extends Core
|
||||
'step_method' => 'convertClubBlogComments',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'SUM(blog_comments)', 'blog_blogs', array( "blog_club_id IS NOT NULL" ) ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 1000,
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertClubBlogEntries' ),
|
||||
'link_type' => 'core_club_blogs_comments',
|
||||
'requires_rebuild' => TRUE
|
||||
@@ -134,15 +160,22 @@ class _Blog extends Core
|
||||
'step_method' => 'convertAttachments',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'core_attachments_map', array( 'location_key=? AND id1<>? AND id2 IS NULL', 'blog_Entries', 0 ) ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 250,
|
||||
'per_cycle' => 10,
|
||||
'dependencies' => array( 'convertBlogEntries', 'convertBlogComments' ),
|
||||
'link_type' => 'core_attachments',
|
||||
);
|
||||
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 )
|
||||
@@ -156,12 +189,13 @@ class _Blog extends Core
|
||||
/**
|
||||
* Returns an array of tables that need to be truncated when Empty Local Data is used
|
||||
*
|
||||
* @param string $method Method we are truncating
|
||||
* @return array
|
||||
*/
|
||||
protected function truncate( $method )
|
||||
{
|
||||
$return = array();
|
||||
$classname = get_class( $this->software );
|
||||
$classname = \get_class( $this->software );
|
||||
|
||||
if( $classname::canConvert() === NULL )
|
||||
{
|
||||
@@ -176,10 +210,18 @@ class _Blog extends Core
|
||||
case 'convertBlogs':
|
||||
$return['convertBlogs'] = array( 'blog_blogs' => NULL, 'core_clubs_node_map' => array( "node_class=?", "IPS\\blog\\Blog" ) );
|
||||
break;
|
||||
|
||||
case 'convertBlogCategories':
|
||||
$return['convertBlogCategories'] = array( 'blog_categories' => NULL );
|
||||
break;
|
||||
|
||||
case 'convertBlogEntries':
|
||||
$return['convertBlogEntries'] = array( 'blog_entries' => NULL );
|
||||
break;
|
||||
|
||||
case 'convertBlogEntryCategories':
|
||||
$return['convertBlogEntryCategories'] = array( 'blog_entry_categories' => NULL );
|
||||
break;
|
||||
|
||||
case 'convertBlogComments':
|
||||
$return['convertBlogComments'] = array( 'blog_comments' => NULL );
|
||||
@@ -292,12 +334,12 @@ class _Blog extends Core
|
||||
|
||||
if ( isset( $info['blog_settings'] ) )
|
||||
{
|
||||
if ( !is_array( $info['blog_settings'] ) )
|
||||
if ( !\is_array( $info['blog_settings'] ) )
|
||||
{
|
||||
$info['blog_settings'] = json_decode( $info['blog_settings'], TRUE );
|
||||
}
|
||||
|
||||
if ( !is_null( $info['blog_settings'] ) )
|
||||
if ( !\is_null( $info['blog_settings'] ) )
|
||||
{
|
||||
$newSettings = array();
|
||||
|
||||
@@ -369,13 +411,13 @@ class _Blog extends Core
|
||||
|
||||
if ( isset( $info['blog_groupblog_ids'] ) )
|
||||
{
|
||||
if ( !is_array( $info['blog_groupblog_ids'] ) )
|
||||
if ( !\is_array( $info['blog_groupblog_ids'] ) )
|
||||
{
|
||||
$info['blog_groupblog_ids'] = explode( ',', $info['blog_groupblog_ids'] );
|
||||
}
|
||||
|
||||
$newGroups = array();
|
||||
if ( count( $info['blog_groupblog_ids'] ) )
|
||||
if ( \count( $info['blog_groupblog_ids'] ) )
|
||||
{
|
||||
foreach( $info['blog_groupblog_ids'] AS $group )
|
||||
{
|
||||
@@ -390,7 +432,7 @@ class _Blog extends Core
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $newGroups ) )
|
||||
if ( \count( $newGroups ) )
|
||||
{
|
||||
$info['blog_groupblog_ids'] = implode( ',', $newGroups );
|
||||
}
|
||||
@@ -434,7 +476,7 @@ class _Blog extends Core
|
||||
/* Well update this later if we need too */
|
||||
$info['blog_social_group'] = NULL;
|
||||
|
||||
if ( !is_null( $socialgroup ) AND is_array( $socialgroup ) )
|
||||
if ( !\is_null( $socialgroup ) AND \is_array( $socialgroup ) )
|
||||
{
|
||||
$socialGroupId = \IPS\Db::i()->insert( 'core_sys_social_groups', array( 'owner_id' => $info['blog_member_id'] ) );
|
||||
$members = array();
|
||||
@@ -445,7 +487,7 @@ class _Blog extends Core
|
||||
{
|
||||
$members[] = array( 'group_id' => $socialGroupId, 'member_id' => $this->software->app->getLink( $member, 'core_members', TRUE ) );
|
||||
}
|
||||
catch( \OutOfRangeExceptin $e )
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -456,11 +498,11 @@ class _Blog extends Core
|
||||
}
|
||||
|
||||
/* And now cover photo */
|
||||
if ( isset( $info['blog_cover_photo'] ) AND ( !is_null( $filedata ) OR !is_null( $filepath ) ) )
|
||||
if ( isset( $info['blog_cover_photo'] ) AND ( !\is_null( $filedata ) OR !\is_null( $filepath ) ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( is_null( $filedata ) AND !is_null( $filepath ) )
|
||||
if ( \is_null( $filedata ) AND !\is_null( $filepath ) )
|
||||
{
|
||||
$filedata = file_get_contents( $filepath );
|
||||
}
|
||||
@@ -501,6 +543,22 @@ class _Blog extends Core
|
||||
{
|
||||
$info['blog_club_id'] = NULL;
|
||||
}
|
||||
|
||||
if( !empty( $info['blog_category_id'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$info['blog_category_id'] = $this->software->app->getLink( $info['blog_category_id'], 'blog_categories' );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
$info['blog_category_id'] = $this->_getOrphanedBlogCategory();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['blog_category_id'] = $this->_getOrphanedBlogCategory();
|
||||
}
|
||||
|
||||
$id = $info['blog_id'];
|
||||
unset( $info['blog_id'] );
|
||||
@@ -525,6 +583,88 @@ class _Blog extends Core
|
||||
|
||||
return $inserted_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a Blog Category
|
||||
*
|
||||
* @param array $info Array of blog information
|
||||
* @return integer|boolean The ID of the inserted category, or FALSE on failure.
|
||||
*/
|
||||
public function convertBlogCategory( array $info )
|
||||
{
|
||||
if ( !isset( $info['category_id'] ) )
|
||||
{
|
||||
$this->software->app->log( 'blog_category_missing_ids', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( !isset( $info['category_name'] ) )
|
||||
{
|
||||
$name = "Converted Category {$info['category_id']}";
|
||||
$this->software->app->log( 'blog_category_missing_name', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['category_id'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$name = $info['category_name'];
|
||||
unset( $info['category_name'] );
|
||||
}
|
||||
|
||||
$info['category_seo_name'] = \IPS\Http\Url::seoTitle( $name );
|
||||
|
||||
if ( !array_key_exists( 'category_description', $info ) )
|
||||
{
|
||||
$desc = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Make sure the description isn't empty/null */
|
||||
$desc = $info['category_description'] ?: '';
|
||||
unset( $info['category_description'] );
|
||||
}
|
||||
|
||||
if ( !isset( $info['category_position'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$position = \IPS\Db::i()->select( 'MAX(category_position)', 'blog_categories' )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
$position = 0;
|
||||
}
|
||||
|
||||
$info['category_position'] = $position + 1;
|
||||
}
|
||||
|
||||
if ( isset( $info['category_parent'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$info['category_parent'] = $this->software->app->getLink( $info['category_parent'], 'blog_categories' );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
$info['category_conv_parent'] = $info['category_parent'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['category_parent'] = 0;
|
||||
}
|
||||
|
||||
$id = $info['category_id'];
|
||||
unset( $info['category_id'] );
|
||||
|
||||
$insertedId = \IPS\Db::i()->insert( 'blog_categories', $info );
|
||||
$this->software->app->addLink( $insertedId, $id, 'blog_categories' );
|
||||
|
||||
\IPS\Lang::saveCustom( 'blogs', "blog_category_{$insertedId}", $name );
|
||||
\IPS\Lang::saveCustom( 'blogs', "blog_category_{$insertedId}_desc", $desc );
|
||||
|
||||
\IPS\Db::i()->update( 'blog_categories', array( "category_parent" => $insertedId ), array( "category_conv_parent=?", $id ) );
|
||||
|
||||
return $insertedId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a blog entry
|
||||
@@ -611,7 +751,7 @@ class _Blog extends Core
|
||||
$info['entry_date'] = time();
|
||||
}
|
||||
|
||||
if ( !isset( $info['entry_status'] ) OR !in_array( $info['entry_status'], array( 'published', 'draft' ) ) )
|
||||
if ( !isset( $info['entry_status'] ) OR !\in_array( $info['entry_status'], array( 'published', 'draft' ) ) )
|
||||
{
|
||||
$info['entry_status'] = 'published';
|
||||
}
|
||||
@@ -664,6 +804,16 @@ class _Blog extends Core
|
||||
{
|
||||
$info['entry_edit_name'] = NULL;
|
||||
}
|
||||
|
||||
if ( !isset( $info['entry_edit_reason'] ) )
|
||||
{
|
||||
$info['entry_edit_reason'] = '';
|
||||
}
|
||||
|
||||
if ( !isset( $info['entry_append_edit'] ) )
|
||||
{
|
||||
$info['entry_append_edit'] = 0;
|
||||
}
|
||||
|
||||
if ( isset( $info['entry_last_update'] ) )
|
||||
{
|
||||
@@ -693,7 +843,7 @@ class _Blog extends Core
|
||||
$info['entry_gallery_album'] = NULL;
|
||||
}
|
||||
|
||||
if ( isset( $info['entry_poll_state'] ) AND is_array( $info['entry_poll_state'] ) )
|
||||
if ( isset( $info['entry_poll_state'] ) AND \is_array( $info['entry_poll_state'] ) )
|
||||
{
|
||||
if ( $poll = $this->convertPoll( $info['entry_poll_state']['poll_data'], $info['entry_poll_state']['vote_data'] ) )
|
||||
{
|
||||
@@ -728,11 +878,11 @@ class _Blog extends Core
|
||||
$info['entry_ip_address'] = '127.0.0.1';
|
||||
}
|
||||
|
||||
if ( isset( $info['entry_cover_photo'] ) AND ( !is_null( $filepath ) OR !is_null( $filedata ) ) )
|
||||
if ( isset( $info['entry_cover_photo'] ) AND ( !\is_null( $filepath ) OR !\is_null( $filedata ) ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( is_null( $filedata ) AND !is_null( $filepath ) )
|
||||
if ( \is_null( $filedata ) AND !\is_null( $filepath ) )
|
||||
{
|
||||
$filedata = file_get_contents( $filepath );
|
||||
}
|
||||
@@ -752,6 +902,22 @@ class _Blog extends Core
|
||||
$info['entry_cover_photo'] = NULL;
|
||||
$info['entry_cover_photo_offset'] = NULL;
|
||||
}
|
||||
|
||||
if( !empty( $info['entry_category_id'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$info['entry_category_id'] = $this->software->app->getLink( $info['entry_category_id'], 'blog_entry_categories' );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
$info['entry_category_id'] = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['entry_category_id'] = NULL;
|
||||
}
|
||||
|
||||
$id = $info['entry_id'];
|
||||
unset( $info['entry_id'] );
|
||||
@@ -761,6 +927,80 @@ class _Blog extends Core
|
||||
|
||||
return $inserted_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a Blog Entry Category
|
||||
*
|
||||
* @param array $info Array of blog information
|
||||
* @return integer|boolean The ID of the inserted category, or FALSE on failure.
|
||||
*/
|
||||
public function convertBlogEntryCategory( array $info )
|
||||
{
|
||||
if ( !isset( $info['entry_category_id'] ) )
|
||||
{
|
||||
$this->software->app->log( 'blog_entry_category_missing_ids', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( !isset( $info['entry_category_blog_id'] ) )
|
||||
{
|
||||
$this->software->app->log( 'blog_entry_category_blog_missing_ids', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( isset( $info['entry_category_blog_id'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$info['entry_category_blog_id'] = $this->software->app->getLink( $info['entry_category_blog_id'], 'blog_blogs' );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
$this->software->app->log( 'blog_entry_category_missing_blog_id', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['entry_category_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->software->app->log( 'blog_entry_category_missing_blog_id', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['entry_category_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( !isset( $info['entry_category_name'] ) )
|
||||
{
|
||||
$info['entry_category_name'] = "Converted Category {$info['entry_category_id']}";
|
||||
$this->software->app->log( 'blog_entry_category_missing_name', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['entry_category_id'] );
|
||||
}
|
||||
|
||||
$info['entry_category_seo_name'] = \IPS\Http\Url::seoTitle( $info['entry_category_name'] );
|
||||
|
||||
if ( !isset( $info['entry_category_position'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$position = \IPS\Db::i()->select( 'MAX(entry_category_position)', 'blog_entry_categories', array( 'entry_category_blog_id=?', $info['entry_category_blog_id'] ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
$position = 0;
|
||||
}
|
||||
|
||||
$info['entry_category_position'] = $position + 1;
|
||||
}
|
||||
|
||||
if ( !isset( $info['entry_category_count'] ) )
|
||||
{
|
||||
$info['entry_category_count'] = 0;
|
||||
}
|
||||
|
||||
$id = $info['entry_category_id'];
|
||||
unset( $info['entry_category_id'] );
|
||||
|
||||
$insertedId = \IPS\Db::i()->insert( 'blog_entry_categories', $info );
|
||||
$this->software->app->addLink( $insertedId, $id, 'blog_entry_categories' );
|
||||
|
||||
return $insertedId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a blog comment
|
||||
@@ -891,115 +1131,26 @@ class _Blog extends Core
|
||||
*/
|
||||
public function convertBlogRssImport( array $info )
|
||||
{
|
||||
if ( !isset( $info['rss_id'] ) )
|
||||
{
|
||||
$this->software->app->log( 'blog_rss_import_missing_ids', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( isset( $info['rss_blog_id'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$info['rss_blog_id'] = $this->software->app->getLink( $info['rss_blog_id'], 'blog_blogs' );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
$this->software->app->log( 'blog_rss_import_missing_blog', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['rss_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->software->app->log( 'blog_rss_import_missing_blog', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['rss_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( !isset( $info['rss_url'] ) OR filter_var( $info['rss_url'], FILTER_VALIDATE_URL ) === FALSE )
|
||||
{
|
||||
$this->software->app->log( 'blog_rss_import_missing_url', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['rss_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( !isset( $info['rss_auth_user'] ) OR !isset( $info['rss_auth_pass'] ) )
|
||||
{
|
||||
$info['rss_auth_user'] = '';
|
||||
$info['rss_auth_pass'] = '';
|
||||
}
|
||||
|
||||
if ( isset( $info['rss_last_import'] ) )
|
||||
{
|
||||
if ( $info['rss_last_import'] instanceof \IPS\DateTime )
|
||||
{
|
||||
$info['rss_last_import'] = $info['rss_last_import']->getTimestamp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['rss_last_import'] = time();
|
||||
}
|
||||
|
||||
if ( isset( $info['rss_tags'] ) )
|
||||
{
|
||||
if ( is_array( $info['rss_tags'] ) )
|
||||
{
|
||||
$info['rss_tags'] = json_encode( $info['rss_tags'] );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['rss_tags'] = NULL;
|
||||
}
|
||||
|
||||
if ( isset( $info['rss_member'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$info['rss_member'] = $this->software->app->getLink( $info['rss_member'], 'core_members', TRUE );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
$info['rss_member'] = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['rss_member'] = NULL;
|
||||
}
|
||||
|
||||
if ( is_null( $info['rss_member'] ) )
|
||||
{
|
||||
$blogOwner = \IPS\Db::i()->select( 'blog_member_id', 'blog_blogs', array( "blog_id=?", $info['rss_blog_id'] ) )->first();
|
||||
$info['rss_member'] = $blogOwner;
|
||||
}
|
||||
|
||||
if ( !isset( $info['rss_import_show_link'] ) )
|
||||
{
|
||||
$info['rss_import_show_link'] = "View the full article";
|
||||
}
|
||||
|
||||
$id = $info['rss_id'];
|
||||
unset( $info['rss_id'] );
|
||||
|
||||
$inserted_id = \IPS\Db::i()->insert( 'blog_rss_import', $info );
|
||||
$this->software->app->addLinK( $inserted_id, $id, 'blog_rss_import' );
|
||||
|
||||
return $inserted_id;
|
||||
$info['rss_import_class'] = 'IPS\\blogs\\Entry';
|
||||
|
||||
return parent::convertRssImport( $info, 'blog_blogs', 'blog_rss_import' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a blog entry attachment
|
||||
*
|
||||
* @param array $info Array of entry attachment information
|
||||
* @param array $map Array of attachment map data
|
||||
* @param string|NULL $filepath URL/Path to attachment or NULL to use raw file data
|
||||
* @param string|NULL $filedata If $filepath is NULL, this should contain the raw contents of the attachment
|
||||
* @param string|NULL $thumbnailpath Path to thumbnail, or NULL
|
||||
* @return integer|boolean The ID of the inserted attachment, or FALSE on failure.
|
||||
*/
|
||||
public function convertAttachment( $info=array(), $map=array(), $filepath = NULL, $filedata = NULL, $thumbnailpath = NULL )
|
||||
{
|
||||
$map['id1_type'] = 'blog_entries';
|
||||
$map['id1_from_parent'] = FALSE;
|
||||
if ( !isset( $info['id2'] ) OR is_null( $info['id2'] ) )
|
||||
if ( !isset( $info['id2'] ) OR \is_null( $info['id2'] ) )
|
||||
{
|
||||
$map['location_key'] = 'blog_Entries';
|
||||
}
|
||||
@@ -1060,4 +1211,27 @@ class _Blog extends Core
|
||||
}
|
||||
return $insertedId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Parent ID for Orphaned Blogs
|
||||
*
|
||||
* @return integer The ID of the forum created for forums that do not have a parent forum.
|
||||
*/
|
||||
protected function _getOrphanedBlogCategory()
|
||||
{
|
||||
try
|
||||
{
|
||||
$id = $this->software->app->getLink( '__orphaned__', 'blog_categories' );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
$id = $this->convertBlogCategory( array(
|
||||
'category_id' => '__orphaned__',
|
||||
'category_name' => "Converted Blogs",
|
||||
'category_parent' => 0,
|
||||
) );
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user