Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -12,9 +12,30 @@
|
||||
namespace IPS\convert\Library;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use ErrorException;
|
||||
use Exception;
|
||||
use IPS\blog\Blog as BlogClass;
|
||||
use IPS\convert\App;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\File;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Lang;
|
||||
use IPS\Member;
|
||||
use IPS\Member\Club;
|
||||
use OutOfRangeException;
|
||||
use UnderflowException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function get_class;
|
||||
use function in_array;
|
||||
use function is_array;
|
||||
use function is_null;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -22,7 +43,7 @@ if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
* Invision Blog Converter
|
||||
* @note We must extend the Core Library here so we can access methods like convertAttachment, convertFollow, etc
|
||||
*/
|
||||
class _Blog extends Core
|
||||
class Blog extends Core
|
||||
{
|
||||
/**
|
||||
* @brief Application
|
||||
@@ -48,7 +69,7 @@ class _Blog extends Core
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_blog_categories',
|
||||
'step_method' => 'convertBlogCategories',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'blog_categories' ),
|
||||
'ips_rows' => Db::i()->select( 'COUNT(*)', 'blog_categories' ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array(),
|
||||
@@ -60,7 +81,7 @@ class _Blog extends Core
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_blogs',
|
||||
'step_method' => 'convertBlogs',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'blog_blogs' ),
|
||||
'ips_rows' => Db::i()->select( 'COUNT(*)', 'blog_blogs' ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertBlogCategories' ),
|
||||
@@ -72,7 +93,7 @@ class _Blog extends Core
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_blog_entries',
|
||||
'step_method' => 'convertBlogEntries',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'blog_entries' ),
|
||||
'ips_rows' => Db::i()->select( 'COUNT(*)', 'blog_entries' ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertBlogs', 'convertBlogEntryCategories' ),
|
||||
@@ -84,7 +105,7 @@ class _Blog extends Core
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_blog_entry_categories',
|
||||
'step_method' => 'convertBlogEntryCategories',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'blog_entry_categories' ),
|
||||
'ips_rows' => Db::i()->select( 'COUNT(*)', 'blog_entry_categories' ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array(),
|
||||
@@ -96,7 +117,7 @@ class _Blog extends Core
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_blog_comments',
|
||||
'step_method' => 'convertBlogComments',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'blog_comments' ),
|
||||
'ips_rows' => Db::i()->select( 'COUNT(*)', 'blog_comments' ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertBlogEntries' ),
|
||||
@@ -108,7 +129,7 @@ class _Blog extends Core
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_blog_rss_import',
|
||||
'step_method' => 'convertBlogRssImport',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'blog_rss_import' ),
|
||||
'ips_rows' => Db::i()->select( 'COUNT(*)', 'blog_rss_import' ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertBlogs' ),
|
||||
@@ -120,7 +141,7 @@ class _Blog extends Core
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_club_blogs',
|
||||
'step_method' => 'convertClubBlogs',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'blog_blogs', array( "blog_club_id IS NOT NULL" ) ),
|
||||
'ips_rows' => Db::i()->select( 'COUNT(*)', 'blog_blogs', array( "blog_club_id IS NOT NULL" ) ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertClubs' ),
|
||||
@@ -132,7 +153,7 @@ class _Blog extends Core
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_club_blog_entries',
|
||||
'step_method' => 'convertClubBlogEntries',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'SUM(blog_entries)', 'blog_blogs', array( "blog_club_id IS NOT NULL" ) ),
|
||||
'ips_rows' => 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' => 200,
|
||||
'dependencies' => array( 'convertClubBlogs' ),
|
||||
@@ -145,7 +166,7 @@ class _Blog extends Core
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_club_blog_comments',
|
||||
'step_method' => 'convertClubBlogComments',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'SUM(blog_comments)', 'blog_blogs', array( "blog_club_id IS NOT NULL" ) ),
|
||||
'ips_rows' => 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' => 200,
|
||||
'dependencies' => array( 'convertClubBlogEntries' ),
|
||||
@@ -158,7 +179,7 @@ class _Blog extends Core
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_blog_attachments',
|
||||
'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 ) ),
|
||||
'ips_rows' => 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' => 10,
|
||||
'dependencies' => array( 'convertBlogEntries', 'convertBlogComments' ),
|
||||
@@ -195,7 +216,7 @@ class _Blog extends Core
|
||||
protected function truncate( $method )
|
||||
{
|
||||
$return = array();
|
||||
$classname = \get_class( $this->software );
|
||||
$classname = get_class( $this->software );
|
||||
|
||||
if( $classname::canConvert() === NULL )
|
||||
{
|
||||
@@ -233,7 +254,7 @@ class _Blog extends Core
|
||||
|
||||
case 'convertAttachments':
|
||||
$return['convertAttachments'] = array(
|
||||
'core_attachments' => \IPS\Db::i()->in( 'attach_id', (string) \IPS\Db::i()->select( 'attachment_id', 'core_attachments_map', array( "location_key=?", 'blog_Entries' ) ) ),
|
||||
'core_attachments' => Db::i()->in( 'attach_id', (string) Db::i()->select( 'attachment_id', 'core_attachments_map', array( "location_key=?", 'blog_Entries' ) ) ),
|
||||
'core_attachments_map' => array( "location_key=?", 'blog_Entries' )
|
||||
);
|
||||
break;
|
||||
@@ -243,11 +264,11 @@ class _Blog extends Core
|
||||
break;
|
||||
|
||||
case 'convertClubBlogEntries':
|
||||
$return['convertClubBlogEntries'] = array( 'blog_entries' => array( 'entry_id IN ( ' . (string) \IPS\Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_blog_entries' AND app={$this->software->app->app_id}" ) ) . ')' ) );
|
||||
$return['convertClubBlogEntries'] = array( 'blog_entries' => array( 'entry_id IN ( ' . (string) Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_blog_entries' AND app={$this->software->app->app_id}" ) ) . ')' ) );
|
||||
break;
|
||||
|
||||
case 'convertClubBlogComments':
|
||||
$return['convertClubBlogComments'] = array( 'blog_comments' => array( 'comment_id IN ( ' . (string) \IPS\Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_blog_comments' AND app={$this->software->app->app_id}" ) ) . ')' ) );
|
||||
$return['convertClubBlogComments'] = array( 'blog_comments' => array( 'comment_id IN ( ' . (string) Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_blog_comments' AND app={$this->software->app->app_id}" ) ) . ')' ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -282,7 +303,7 @@ class _Blog extends Core
|
||||
{
|
||||
if ( !isset( $info['blog_id'] ) )
|
||||
{
|
||||
$this->software->app->log( 'blog_missing_ids', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
$this->software->app->log( 'blog_missing_ids', __METHOD__, App::LOG_WARNING );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -292,7 +313,7 @@ class _Blog extends Core
|
||||
{
|
||||
$info['blog_member_id'] = $this->software->app->getLink( $info['blog_member_id'], 'core_members', TRUE );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$info['blog_member_id'] = 0;
|
||||
}
|
||||
@@ -334,12 +355,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();
|
||||
|
||||
@@ -380,7 +401,7 @@ class _Blog extends Core
|
||||
/* Name and Description */
|
||||
if ( !isset( $info['blog_name'] ) )
|
||||
{
|
||||
$owner = \IPS\Member::load( $info['blog_member_id'] );
|
||||
$owner = Member::load( $info['blog_member_id'] );
|
||||
|
||||
if ( $owner->member_id )
|
||||
{
|
||||
@@ -397,7 +418,7 @@ class _Blog extends Core
|
||||
unset( $info['blog_name'] );
|
||||
}
|
||||
|
||||
$info['blog_seo_name'] = \IPS\Http\Url::seoTitle( $name );
|
||||
$info['blog_seo_name'] = Url::seoTitle( $name );
|
||||
|
||||
if ( isset( $info['blog_description'] ) )
|
||||
{
|
||||
@@ -411,13 +432,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 )
|
||||
{
|
||||
@@ -425,14 +446,14 @@ class _Blog extends Core
|
||||
{
|
||||
$newGroups[] = $this->software->app->getLink( $group, 'core_groups', TRUE );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( \count( $newGroups ) )
|
||||
if ( count( $newGroups ) )
|
||||
{
|
||||
$info['blog_groupblog_ids'] = implode( ',', $newGroups );
|
||||
}
|
||||
@@ -448,7 +469,7 @@ class _Blog extends Core
|
||||
|
||||
if ( isset( $info['blog_last_edate'] ) )
|
||||
{
|
||||
if ( $info['blog_last_edate'] instanceof \IPS\DateTime )
|
||||
if ( $info['blog_last_edate'] instanceof DateTime )
|
||||
{
|
||||
$info['blog_last_edate'] = $info['blog_last_edate']->getTimestamp();
|
||||
}
|
||||
@@ -476,9 +497,9 @@ 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'] ) );
|
||||
$socialGroupId = Db::i()->insert( 'core_sys_social_groups', array( 'owner_id' => $info['blog_member_id'] ) );
|
||||
$members = array();
|
||||
$members[] = array( 'group_id' => $socialGroupId, 'member_id' => $info['blog_member_id'] );
|
||||
foreach( $socialgroup['members'] AS $member )
|
||||
@@ -487,36 +508,36 @@ class _Blog extends Core
|
||||
{
|
||||
$members[] = array( 'group_id' => $socialGroupId, 'member_id' => $this->software->app->getLink( $member, 'core_members', TRUE ) );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
\IPS\Db::i()->insert( 'core_sys_social_group_members', $members );
|
||||
Db::i()->insert( 'core_sys_social_group_members', $members );
|
||||
|
||||
$info['blog_social_group'] = $socialGroupId;
|
||||
}
|
||||
|
||||
/* 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 );
|
||||
}
|
||||
|
||||
$file = \IPS\File::create( 'blog_Blogs', $info['blog_cover_photo'], $filedata );
|
||||
$file = File::create( 'blog_Blogs', $info['blog_cover_photo'], $filedata );
|
||||
$info['blog_cover_photo'] = (string) $file;
|
||||
$info['blog_cover_photo_offset'] = 0;
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
$info['blog_cover_photo'] = NULL;
|
||||
$info['blog_cover_photo_offset'] = NULL;
|
||||
}
|
||||
catch( \ErrorException $e )
|
||||
catch( ErrorException $e )
|
||||
{
|
||||
$info['blog_cover_photo'] = NULL;
|
||||
$info['blog_cover_photo_offset'] = NULL;
|
||||
@@ -534,7 +555,7 @@ class _Blog extends Core
|
||||
{
|
||||
$info['blog_club_id'] = $this->software->app->getLink( $info['blog_club_id'], 'core_clubs', TRUE );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$info['blog_club_id'] = NULL;
|
||||
}
|
||||
@@ -550,7 +571,7 @@ class _Blog extends Core
|
||||
{
|
||||
$info['blog_category_id'] = $this->software->app->getLink( $info['blog_category_id'], 'blog_categories' );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$info['blog_category_id'] = $this->_getOrphanedBlogCategory();
|
||||
}
|
||||
@@ -563,22 +584,22 @@ class _Blog extends Core
|
||||
$id = $info['blog_id'];
|
||||
unset( $info['blog_id'] );
|
||||
|
||||
$inserted_id = \IPS\Db::i()->insert( 'blog_blogs', $info );
|
||||
$inserted_id = Db::i()->insert( 'blog_blogs', $info );
|
||||
$this->software->app->addLink( $inserted_id, $id, 'blog_blogs' );
|
||||
|
||||
\IPS\Lang::saveCustom( 'blog', "blogs_blog_{$inserted_id}", $name );
|
||||
\IPS\Lang::saveCustom( 'blog', "blogs_blog_{$inserted_id}_desc", $desc );
|
||||
Lang::saveCustom( 'blog', "blogs_blog_{$inserted_id}", $name );
|
||||
Lang::saveCustom( 'blog', "blogs_blog_{$inserted_id}_desc", $desc );
|
||||
|
||||
if ( $info['blog_club_id'] )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_clubs_node_map', array(
|
||||
Db::i()->insert( 'core_clubs_node_map', array(
|
||||
'club_id' => $info['blog_club_id'],
|
||||
'node_class' => "IPS\\blog\\Blog",
|
||||
'node_id' => $inserted_id,
|
||||
'name' => $name
|
||||
) );
|
||||
|
||||
\IPS\blog\Blog::load( $inserted_id )->setPermissionsToClub( \IPS\Member\Club::load( $info['blog_club_id'] ) );
|
||||
|
||||
BlogClass::load( $inserted_id )->setPermissionsToClub( Club::load( $info['blog_club_id'] ) );
|
||||
}
|
||||
|
||||
return $inserted_id;
|
||||
@@ -594,14 +615,14 @@ class _Blog extends Core
|
||||
{
|
||||
if ( !isset( $info['category_id'] ) )
|
||||
{
|
||||
$this->software->app->log( 'blog_category_missing_ids', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
$this->software->app->log( 'blog_category_missing_ids', __METHOD__, 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'] );
|
||||
$this->software->app->log( 'blog_category_missing_name', __METHOD__, App::LOG_WARNING, $info['category_id'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -609,7 +630,7 @@ class _Blog extends Core
|
||||
unset( $info['category_name'] );
|
||||
}
|
||||
|
||||
$info['category_seo_name'] = \IPS\Http\Url::seoTitle( $name );
|
||||
$info['category_seo_name'] = Url::seoTitle( $name );
|
||||
|
||||
if ( !array_key_exists( 'category_description', $info ) )
|
||||
{
|
||||
@@ -626,9 +647,9 @@ class _Blog extends Core
|
||||
{
|
||||
try
|
||||
{
|
||||
$position = \IPS\Db::i()->select( 'MAX(category_position)', 'blog_categories' )->first();
|
||||
$position = Db::i()->select( 'MAX(category_position)', 'blog_categories' )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
$position = 0;
|
||||
}
|
||||
@@ -642,7 +663,7 @@ class _Blog extends Core
|
||||
{
|
||||
$info['category_parent'] = $this->software->app->getLink( $info['category_parent'], 'blog_categories' );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$info['category_conv_parent'] = $info['category_parent'];
|
||||
}
|
||||
@@ -655,13 +676,13 @@ class _Blog extends Core
|
||||
$id = $info['category_id'];
|
||||
unset( $info['category_id'] );
|
||||
|
||||
$insertedId = \IPS\Db::i()->insert( 'blog_categories', $info );
|
||||
$insertedId = 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 );
|
||||
Lang::saveCustom( 'blogs', "blog_category_{$insertedId}", $name );
|
||||
Lang::saveCustom( 'blogs', "blog_category_{$insertedId}_desc", $desc );
|
||||
|
||||
\IPS\Db::i()->update( 'blog_categories', array( "category_parent" => $insertedId ), array( "category_conv_parent=?", $id ) );
|
||||
Db::i()->update( 'blog_categories', array( "category_parent" => $insertedId ), array( "category_conv_parent=?", $id ) );
|
||||
|
||||
return $insertedId;
|
||||
}
|
||||
@@ -678,7 +699,7 @@ class _Blog extends Core
|
||||
{
|
||||
if ( !isset( $info['entry_id'] ) )
|
||||
{
|
||||
$this->software->app->log( 'blog_entry_missing_ids', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
$this->software->app->log( 'blog_entry_missing_ids', __METHOD__, App::LOG_WARNING );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -688,9 +709,9 @@ class _Blog extends Core
|
||||
{
|
||||
$info['entry_blog_id'] = $this->software->app->getLink( $info['entry_blog_id'], 'blog_blogs' );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$this->software->app->log( 'blog_entry_missing_blog', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['entry_id'] );
|
||||
$this->software->app->log( 'blog_entry_missing_blog', __METHOD__, App::LOG_WARNING, $info['entry_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -698,14 +719,14 @@ class _Blog extends Core
|
||||
if ( !isset( $info['entry_name'] ) )
|
||||
{
|
||||
$info['entry_name'] = "Untitled Blog Entry {$info['entry_id']}";
|
||||
$this->software->app->log( 'blog_entry_missing_name', __METHOD__, \IPS\convert\App::LOG_NOTICE, $info['entry_id'] );
|
||||
$this->software->app->log( 'blog_entry_missing_name', __METHOD__, App::LOG_NOTICE, $info['entry_id'] );
|
||||
}
|
||||
|
||||
$info['entry_name_seo'] = \IPS\Http\Url::seoTitle( $info['entry_name'] );
|
||||
$info['entry_name_seo'] = Url::seoTitle( $info['entry_name'] );
|
||||
|
||||
if ( empty( $info['entry_content'] ) )
|
||||
{
|
||||
$this->software->app->log( 'blog_entry_missing_content', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['entry_content'] );
|
||||
$this->software->app->log( 'blog_entry_missing_content', __METHOD__, App::LOG_WARNING, $info['entry_content'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -715,7 +736,7 @@ class _Blog extends Core
|
||||
{
|
||||
$info['entry_author_id'] = $this->software->app->getLink( $info['entry_author_id'], 'core_members', TRUE );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$info['entry_author_id'] = 0;
|
||||
}
|
||||
@@ -727,7 +748,7 @@ class _Blog extends Core
|
||||
|
||||
if ( !isset( $info['entry_author_name'] ) )
|
||||
{
|
||||
$author = \IPS\Member::load( $info['entry_author_id'] );
|
||||
$author = Member::load( $info['entry_author_id'] );
|
||||
|
||||
if ( $author->member_id )
|
||||
{
|
||||
@@ -741,7 +762,7 @@ class _Blog extends Core
|
||||
|
||||
if ( isset( $info['entry_date'] ) )
|
||||
{
|
||||
if ( $info['entry_date'] instanceof \IPS\DateTime )
|
||||
if ( $info['entry_date'] instanceof DateTime )
|
||||
{
|
||||
$info['entry_date'] = $info['entry_date']->getTimestamp();
|
||||
}
|
||||
@@ -751,7 +772,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';
|
||||
}
|
||||
@@ -771,7 +792,7 @@ class _Blog extends Core
|
||||
{
|
||||
$info['entry_last_comment_mid'] = $this->software->app->getLink( $info['entry_last_comment_mid'], 'core_members', TRUE );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$info['entry_last_comment_mid'] = 0;
|
||||
}
|
||||
@@ -790,7 +811,7 @@ class _Blog extends Core
|
||||
|
||||
if ( isset( $info['entry_edit_time'] ) )
|
||||
{
|
||||
if ( $info['entry_edit_time'] instanceof \IPS\DateTime )
|
||||
if ( $info['entry_edit_time'] instanceof DateTime )
|
||||
{
|
||||
$info['entry_edit_time'] = $info['entry_edit_time']->getTimestamp();
|
||||
}
|
||||
@@ -817,7 +838,7 @@ class _Blog extends Core
|
||||
|
||||
if ( isset( $info['entry_last_update'] ) )
|
||||
{
|
||||
if ( $info['entry_last_update'] instanceof \IPS\DateTime )
|
||||
if ( $info['entry_last_update'] instanceof DateTime )
|
||||
{
|
||||
$info['entry_last_update'] = $info['entry_last_update']->getTimestamp();
|
||||
}
|
||||
@@ -833,7 +854,7 @@ class _Blog extends Core
|
||||
{
|
||||
$info['entry_gallery_album'] = $this->software->app->getSiblingLink( $info['entry_gallery_album'], 'gallery_albums', 'gallery' );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$info['entry_gallery_album'] = NULL;
|
||||
}
|
||||
@@ -843,7 +864,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'] ) )
|
||||
{
|
||||
@@ -861,7 +882,7 @@ class _Blog extends Core
|
||||
|
||||
if ( isset( $info['entry_publish_date'] ) )
|
||||
{
|
||||
if ( $info['entry_publish_date'] instanceof \IPS\DateTime )
|
||||
if ( $info['entry_publish_date'] instanceof DateTime )
|
||||
{
|
||||
$info['entry_publish_date'] = $info['entry_publish_date']->getTimestamp();
|
||||
}
|
||||
@@ -878,20 +899,20 @@ 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 );
|
||||
}
|
||||
|
||||
$file = \IPS\File::create( 'blog_Entries', $info['entry_cover_photo'], $filedata );
|
||||
$file = File::create( 'blog_Entries', $info['entry_cover_photo'], $filedata );
|
||||
$info['entry_cover_photo'] = (string) $file;
|
||||
$info['entry_cover_photo_offset'] = 0;
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
$info['entry_cover_photo'] = NULL;
|
||||
$info['entry_cover_photo_offset'] = NULL;
|
||||
@@ -909,7 +930,7 @@ class _Blog extends Core
|
||||
{
|
||||
$info['entry_category_id'] = $this->software->app->getLink( $info['entry_category_id'], 'blog_entry_categories' );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$info['entry_category_id'] = NULL;
|
||||
}
|
||||
@@ -922,7 +943,7 @@ class _Blog extends Core
|
||||
$id = $info['entry_id'];
|
||||
unset( $info['entry_id'] );
|
||||
|
||||
$inserted_id = \IPS\Db::i()->insert( 'blog_entries', $info );
|
||||
$inserted_id = Db::i()->insert( 'blog_entries', $info );
|
||||
$this->software->app->addLink( $inserted_id, $id, 'blog_entries' );
|
||||
|
||||
return $inserted_id;
|
||||
@@ -938,13 +959,13 @@ class _Blog extends Core
|
||||
{
|
||||
if ( !isset( $info['entry_category_id'] ) )
|
||||
{
|
||||
$this->software->app->log( 'blog_entry_category_missing_ids', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
$this->software->app->log( 'blog_entry_category_missing_ids', __METHOD__, 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 );
|
||||
$this->software->app->log( 'blog_entry_category_blog_missing_ids', __METHOD__, App::LOG_WARNING );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -954,33 +975,33 @@ class _Blog extends Core
|
||||
{
|
||||
$info['entry_category_blog_id'] = $this->software->app->getLink( $info['entry_category_blog_id'], 'blog_blogs' );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$this->software->app->log( 'blog_entry_category_missing_blog_id', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['entry_category_id'] );
|
||||
$this->software->app->log( 'blog_entry_category_missing_blog_id', __METHOD__, 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'] );
|
||||
$this->software->app->log( 'blog_entry_category_missing_blog_id', __METHOD__, 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'] );
|
||||
$this->software->app->log( 'blog_entry_category_missing_name', __METHOD__, App::LOG_WARNING, $info['entry_category_id'] );
|
||||
}
|
||||
|
||||
$info['entry_category_seo_name'] = \IPS\Http\Url::seoTitle( $info['entry_category_name'] );
|
||||
$info['entry_category_seo_name'] = 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();
|
||||
$position = Db::i()->select( 'MAX(entry_category_position)', 'blog_entry_categories', array( 'entry_category_blog_id=?', $info['entry_category_blog_id'] ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
$position = 0;
|
||||
}
|
||||
@@ -996,7 +1017,7 @@ class _Blog extends Core
|
||||
$id = $info['entry_category_id'];
|
||||
unset( $info['entry_category_id'] );
|
||||
|
||||
$insertedId = \IPS\Db::i()->insert( 'blog_entry_categories', $info );
|
||||
$insertedId = Db::i()->insert( 'blog_entry_categories', $info );
|
||||
$this->software->app->addLink( $insertedId, $id, 'blog_entry_categories' );
|
||||
|
||||
return $insertedId;
|
||||
@@ -1012,7 +1033,7 @@ class _Blog extends Core
|
||||
{
|
||||
if ( !isset( $info['comment_id'] ) )
|
||||
{
|
||||
$this->software->app->log( 'blog_comment_missing_ids', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
$this->software->app->log( 'blog_comment_missing_ids', __METHOD__, App::LOG_WARNING );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1022,21 +1043,21 @@ class _Blog extends Core
|
||||
{
|
||||
$info['comment_entry_id'] = $this->software->app->getLink( $info['comment_entry_id'], 'blog_entries' );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$this->software->app->log( 'blog_comment_missing_entry', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['comment_id'] );
|
||||
$this->software->app->log( 'blog_comment_missing_entry', __METHOD__, App::LOG_WARNING, $info['comment_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->software->app->log( 'blog_comment_missing_entry', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['comment_id'] );
|
||||
$this->software->app->log( 'blog_comment_missing_entry', __METHOD__, App::LOG_WARNING, $info['comment_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( empty( $info['comment_text'] ) )
|
||||
{
|
||||
$this->software->app->log( 'blog_comment_missing_content', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['comment_id'] );
|
||||
$this->software->app->log( 'blog_comment_missing_content', __METHOD__, App::LOG_WARNING, $info['comment_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1046,7 +1067,7 @@ class _Blog extends Core
|
||||
{
|
||||
$info['comment_member_id'] = $this->software->app->getLink( $info['comment_member_id'], 'core_members', TRUE );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$info['comment_member_id'] = 0;
|
||||
}
|
||||
@@ -1058,7 +1079,7 @@ class _Blog extends Core
|
||||
|
||||
if ( !isset( $info['comment_member_name'] ) )
|
||||
{
|
||||
$author = \IPS\Member::load( $info['comment_member_id'] );
|
||||
$author = Member::load( $info['comment_member_id'] );
|
||||
|
||||
if ( $author->member_id )
|
||||
{
|
||||
@@ -1077,7 +1098,7 @@ class _Blog extends Core
|
||||
|
||||
if ( isset( $info['comment_date'] ) )
|
||||
{
|
||||
if ( $info['comment_date'] instanceof \IPS\DateTime )
|
||||
if ( $info['comment_date'] instanceof DateTime )
|
||||
{
|
||||
$info['comment_date'] = $info['comment_date']->getTimestamp();
|
||||
}
|
||||
@@ -1089,7 +1110,7 @@ class _Blog extends Core
|
||||
|
||||
if ( isset( $info['comment_edit_time'] ) )
|
||||
{
|
||||
if ( $info['comment_edit_time'] instanceof \IPS\DateTime )
|
||||
if ( $info['comment_edit_time'] instanceof DateTime )
|
||||
{
|
||||
$info['comment_edit_time'] = $info['comment_edit_time']->getTimestamp();
|
||||
}
|
||||
@@ -1117,7 +1138,7 @@ class _Blog extends Core
|
||||
$id = $info['comment_id'];
|
||||
unset( $info['comment_id'] );
|
||||
|
||||
$inserted_id = \IPS\Db::i()->insert( 'blog_comments', $info );
|
||||
$inserted_id = Db::i()->insert( 'blog_comments', $info );
|
||||
$this->software->app->addLink( $inserted_id, $id, 'blog_comments' );
|
||||
|
||||
return $inserted_id;
|
||||
@@ -1150,7 +1171,7 @@ class _Blog extends Core
|
||||
{
|
||||
$map['id1_type'] = 'blog_entries';
|
||||
$map['id1_from_parent'] = FALSE;
|
||||
if ( !isset( $map['id2'] ) OR \is_null( $map['id2'] ) )
|
||||
if ( !isset( $map['id2'] ) OR is_null( $map['id2'] ) )
|
||||
{
|
||||
$map['location_key'] = 'blog_Entries';
|
||||
}
|
||||
@@ -1165,7 +1186,7 @@ class _Blog extends Core
|
||||
{
|
||||
$map['id3_skip_link'] = true;
|
||||
}
|
||||
|
||||
|
||||
return parent::convertAttachment( $info, $map, $filepath, $filedata, $thumbnailpath );
|
||||
}
|
||||
|
||||
@@ -1228,7 +1249,7 @@ class _Blog extends Core
|
||||
{
|
||||
$id = $this->software->app->getLink( '__orphaned__', 'blog_categories' );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$id = $this->convertBlogCategory( array(
|
||||
'category_id' => '__orphaned__',
|
||||
|
||||
Reference in new issue
Block a user