Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -36,7 +36,6 @@ class _Blog extends Core
|
||||
public function menuRows()
|
||||
{
|
||||
$return = array();
|
||||
$classname = get_class( $this->software );
|
||||
|
||||
foreach( $this->getConvertableItems() as $k => $v )
|
||||
{
|
||||
@@ -110,7 +109,8 @@ class _Blog extends Core
|
||||
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 1000,
|
||||
'dependencies' => array( 'convertClubBlogs' ),
|
||||
'link_type' => 'core_club_blogs_entries'
|
||||
'link_type' => 'core_club_blogs_entries',
|
||||
'requires_rebuild' => TRUE
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -122,7 +122,8 @@ class _Blog extends Core
|
||||
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 1000,
|
||||
'dependencies' => array( 'convertClubBlogEntries' ),
|
||||
'link_type' => 'core_club_blogs_comments'
|
||||
'link_type' => 'core_club_blogs_comments',
|
||||
'requires_rebuild' => TRUE
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -140,6 +141,8 @@ class _Blog extends Core
|
||||
}
|
||||
}
|
||||
|
||||
$return = $this->software->extraMenuRows( $return );
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
@@ -181,7 +184,7 @@ class _Blog extends Core
|
||||
|
||||
case 'convertAttachments':
|
||||
$return['convertAttachments'] = array(
|
||||
'core_attachments' => \IPS\Db::i()->in( \IPS\Db::i()->select( 'attachment_id', 'core_attachments_map', array( "location_key=?", 'blog_Entries' ) ) ),
|
||||
'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_map' => array( "location_key=?", 'blog_Entries' )
|
||||
);
|
||||
break;
|
||||
@@ -985,7 +988,7 @@ class _Blog extends Core
|
||||
* @param string|NULL $filedata If $filepath is NULL, this should contain the raw contents of the attachment
|
||||
* @return integer|boolean The ID of the inserted attachment, or FALSE on failure.
|
||||
*/
|
||||
public function convertAttachment( $info=array(), $map=array(), $filepath = NULL, $filedata = NULL )
|
||||
public function convertAttachment( $info=array(), $map=array(), $filepath = NULL, $filedata = NULL, $thumbnailpath = NULL )
|
||||
{
|
||||
$map['id1_type'] = 'blog_entries';
|
||||
$map['id1_from_parent'] = FALSE;
|
||||
@@ -1000,7 +1003,7 @@ class _Blog extends Core
|
||||
$map['id2_from_parent'] = FALSE;
|
||||
}
|
||||
|
||||
return parent::convertAttachment( $info, $map, $filepath, $filedata );
|
||||
return parent::convertAttachment( $info, $map, $filepath, $filedata, $thumbnailpath );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,7 +33,6 @@ class _Calendar extends Core
|
||||
public function menuRows()
|
||||
{
|
||||
$return = array();
|
||||
$classname = get_class( $this->software );
|
||||
|
||||
foreach( $this->getConvertableItems() as $k => $v )
|
||||
{
|
||||
@@ -72,6 +71,7 @@ class _Calendar extends Core
|
||||
'per_cycle' => 1500,
|
||||
'dependencies' => array( 'convertCalendarCalendars' ),
|
||||
'link_type' => 'calendar_events',
|
||||
'requires_rebuild' => TRUE
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -84,6 +84,7 @@ class _Calendar extends Core
|
||||
'per_cycle' => 2000,
|
||||
'dependencies' => array( 'convertCalendarEvents' ),
|
||||
'link_type' => 'calendar_event_comments',
|
||||
'requires_rebuild' => TRUE
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -96,6 +97,7 @@ class _Calendar extends Core
|
||||
'per_cycle' => 2000,
|
||||
'dependencies' => array( 'convertCalendarEvents' ),
|
||||
'link_type' => 'calendar_event_reviews',
|
||||
'requires_rebuild' => TRUE
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -148,6 +150,8 @@ class _Calendar extends Core
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$return = $this->software->extraMenuRows( $return );
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -172,7 +176,11 @@ class _Calendar extends Core
|
||||
switch( $k )
|
||||
{
|
||||
case 'convertCalendarCalendars':
|
||||
$return['convertCalendarCalendars'] = array( 'calendar_calendars' => NULL, 'core_clubs_node_map' => array( "node_class=?", "IPS\\calendar\\Calendar" ) );
|
||||
$return['convertCalendarCalendars'] = array(
|
||||
'calendar_calendars' => NULL,
|
||||
'core_clubs_node_map' => array( "node_class=?", "IPS\\calendar\\Calendar" ),
|
||||
'core_permission_index' => array( 'app=? AND perm_type=?', 'calendar', 'calendar' )
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertCalendarEvents':
|
||||
@@ -279,7 +287,7 @@ class _Calendar extends Core
|
||||
|
||||
if ( !isset( $info['cal_position'] ) )
|
||||
{
|
||||
$position = \IPS\Db::i()->select( 'MAX(position)', 'calendar_calendars' )->first();
|
||||
$position = \IPS\Db::i()->select( 'MAX(cal_position)', 'calendar_calendars' )->first();
|
||||
$info['cal_position'] = $position + 1;
|
||||
}
|
||||
|
||||
@@ -1304,7 +1312,7 @@ class _Calendar extends Core
|
||||
* @param string|NULL $filedata Binary data for the file, or NULL.
|
||||
* @return integer|boolean The ID of the newly inserted attachment, or FALSE on failure.
|
||||
*/
|
||||
public function convertAttachment( $info=array(), $map=array(), $filepath=NULL, $filedata=NULL )
|
||||
public function convertAttachment( $info=array(), $map=array(), $filepath=NULL, $filedata=NULL, $thumbnailpath=NULL )
|
||||
{
|
||||
$map['location_key'] = 'calendar_Calendar';
|
||||
$map['id1_type'] = 'calendar_events';
|
||||
@@ -1325,6 +1333,6 @@ class _Calendar extends Core
|
||||
$map['id2_type'] = 'calendar_event_reviews';
|
||||
}
|
||||
|
||||
return parent::convertAttachment( $info, $map, $filepath, $filedata );
|
||||
return parent::convertAttachment( $info, $map, $filepath, $filedata, $thumbnailpath );
|
||||
}
|
||||
}
|
||||
@@ -117,39 +117,48 @@ class _Cms extends Core
|
||||
$count += \IPS\Db::i()->select( 'COUNT(*)', "cms_custom_database_{$database}" )->first();
|
||||
$links[] = "cms_custom_database_{$database}";
|
||||
}
|
||||
|
||||
$dependencies = array();
|
||||
if ( array_key_exists( 'convertCmsDatabaseCategories', $this->getConvertableItems() ) )
|
||||
{
|
||||
$dependencies[] = 'convertCmsDatabaseCategories';
|
||||
}
|
||||
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_cms_database_records',
|
||||
'step_method' => 'convertCmsDatabaseRecords',
|
||||
'ips_rows' => $count,
|
||||
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 100,
|
||||
'dependencies' => array( 'convertCmsDatabases', 'convertCmsDatabaseCategories' ),
|
||||
'link_type' => $links,
|
||||
'step_title' => 'convert_cms_database_records',
|
||||
'step_method' => 'convertCmsDatabaseRecords',
|
||||
'ips_rows' => $count,
|
||||
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 100,
|
||||
'dependencies' => array( 'convertCmsDatabases' ),
|
||||
'link_type' => $links,
|
||||
'requires_rebuild' => TRUE
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertCmsDatabaseComments':
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_cms_database_comments',
|
||||
'step_method' => 'convertCmsDatabaseComments',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'cms_database_comments' )->first(),
|
||||
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 2000,
|
||||
'dependencies' => array( 'convertCmsDatabaseRecords' ),
|
||||
'link_type' => 'cms_database_comments',
|
||||
'step_title' => 'convert_cms_database_comments',
|
||||
'step_method' => 'convertCmsDatabaseComments',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'cms_database_comments' )->first(),
|
||||
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 2000,
|
||||
'dependencies' => array( 'convertCmsDatabaseRecords' ),
|
||||
'link_type' => 'cms_database_comments',
|
||||
'requires_rebuild' => TRUE
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertCmsDatabaseReviews':
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_cms_database_reviews',
|
||||
'step_method' => 'convertCmsDatabaseReviews',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'cms_database_reviews' )->first(),
|
||||
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 2000,
|
||||
'dependencies' => array( 'convertCmsDatabaseRecords' ),
|
||||
'link_type' => 'cms_database_reviews',
|
||||
'step_title' => 'convert_cms_database_reviews',
|
||||
'step_method' => 'convertCmsDatabaseReviews',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'cms_database_reviews' )->first(),
|
||||
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 2000,
|
||||
'dependencies' => array( 'convertCmsDatabaseRecords' ),
|
||||
'link_type' => 'cms_database_reviews',
|
||||
'requires_rebuild' => TRUE
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -234,6 +243,8 @@ class _Cms extends Core
|
||||
}
|
||||
}
|
||||
|
||||
$return = $this->software->extraMenuRows( $return );
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
@@ -283,7 +294,7 @@ class _Cms extends Core
|
||||
break;
|
||||
|
||||
case 'convertCmsDatabaseCategories':
|
||||
$return['convertCmsDatabaseDategories'] = array( 'cms_database_categories' => NULL );
|
||||
$return['convertCmsDatabaseCategories'] = array( 'cms_database_categories' => NULL );
|
||||
break;
|
||||
|
||||
case 'convertCmsDatabaseRecords':
|
||||
@@ -296,6 +307,8 @@ class _Cms extends Core
|
||||
}
|
||||
$return['convertCmsDatabaseRecords'] = $toReturn;
|
||||
}
|
||||
|
||||
$return['convertCmsDatabaseRecords']['core_tags'] = array( 'tag_meta_app=?', 'cms' );
|
||||
break;
|
||||
|
||||
case 'convertCmsDatabaseComments':
|
||||
@@ -322,7 +335,7 @@ class _Cms extends Core
|
||||
}
|
||||
}
|
||||
|
||||
return $return[ $method ];
|
||||
return isset( $return[ $method ] ) ? $return[ $method ] : array();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -426,12 +439,12 @@ class _Cms extends Core
|
||||
$info['page_js_css_ids'] = '';
|
||||
$info['page_js_css_objects'] = json_encode( array( 'css' => NULL, 'js' => NULL ) );
|
||||
|
||||
if ( !isset( $info['page_name'] ) )
|
||||
if ( !isset( $info['page_name'] ) OR empty( $info['page_name'] ) )
|
||||
{
|
||||
$info['page_name'] = "Untitled Page {$info['page_id']}";
|
||||
}
|
||||
|
||||
if ( !isset( $info['page_seo_name'] ) )
|
||||
if ( !isset( $info['page_seo_name'] ) OR empty( $info['page_seo_name'] ) )
|
||||
{
|
||||
$info['page_seo_name'] = \IPS\Http\Url::seoTitle( $info['page_name'] );
|
||||
}
|
||||
@@ -483,6 +496,23 @@ class _Cms extends Core
|
||||
{
|
||||
$info['page_folder_id'] = 0;
|
||||
}
|
||||
|
||||
/* We cannot have a page name the same as a folder name in this folder */
|
||||
try
|
||||
{
|
||||
/* Check folder */
|
||||
if ( intval( $info['page_folder_id'] ) == \IPS\cms\Pages\Folder::load( $info['page_seo_name'], 'folder_name' )->parent_id )
|
||||
{
|
||||
$info['page_seo_name'] = \IPS\Http\Url::seoTitle( $info['page_name'] . '-' . $info['page_id'] );
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) {}
|
||||
|
||||
/* Check that we don't have the same FURL as an app */
|
||||
if ( \IPS\cms\Pages\Page::isFurlCollision( $info['page_seo_name'] ) )
|
||||
{
|
||||
$info['page_seo_name'] = \IPS\Http\Url::seoTitle( $info['page_name'] . '-page' );
|
||||
}
|
||||
|
||||
if ( !isset( $info['page_full_path'] ) )
|
||||
{
|
||||
@@ -1060,7 +1090,7 @@ class _Cms extends Core
|
||||
}
|
||||
else
|
||||
{
|
||||
$fieldName = ucfirst( $field['field_type'] );
|
||||
$fieldName = mb_ucfirst( $field['field_type'] );
|
||||
}
|
||||
|
||||
if ( isset( $field['field_desc'] ) )
|
||||
@@ -1104,6 +1134,32 @@ class _Cms extends Core
|
||||
{
|
||||
$field['field_extra'] = '';
|
||||
}
|
||||
|
||||
/* An Item Field needs extra data set */
|
||||
if( $field['field_type'] == 'Item' )
|
||||
{
|
||||
$fieldExtra = !empty( $field['field_extra'] ) ? $field['field_extra'] : array();
|
||||
|
||||
if( isset( $fieldExtra['database'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$fieldExtra['database'] = $this->software->app->getLink( $fieldExtra['database'], 'cms_databases' );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
/* Can't convert this if we don't know what it's referencing */
|
||||
$this->software->app->log( 'cms_database_field_item_no_reference', __METHOD__, \IPS\convert\APP::LOG_NOTICE, $field['field_id'] );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$fieldExtra['database'] = $inserted_id;
|
||||
}
|
||||
|
||||
$field['field_extra'] = json_encode( $fieldExtra );
|
||||
}
|
||||
|
||||
if ( !isset( $field['field_html'] ) )
|
||||
{
|
||||
@@ -1345,6 +1401,7 @@ class _Cms extends Core
|
||||
case 'Youtube':
|
||||
case 'Spotify':
|
||||
case 'Soundcloud':
|
||||
case 'Item':
|
||||
$columnDefinition['type'] = 'TEXT';
|
||||
break;
|
||||
|
||||
@@ -1452,7 +1509,7 @@ class _Cms extends Core
|
||||
|
||||
if ( array_key_exists( 'category_desc', $info ) )
|
||||
{
|
||||
$desc = $info['category_desc'];
|
||||
$desc = !empty( $info['category_desc'] ) ? $info['category_desc'] : '';
|
||||
unset( $info['category_desc'] );
|
||||
}
|
||||
else
|
||||
@@ -1567,6 +1624,25 @@ class _Cms extends Core
|
||||
{
|
||||
$info['category_meta_description'] = NULL;
|
||||
}
|
||||
|
||||
if ( isset( $info['category_parent_id'] ) )
|
||||
{
|
||||
if ( $info['category_parent_id'] !== 0 )
|
||||
{
|
||||
try
|
||||
{
|
||||
$info['category_parent_id'] = $this->software->app->getLink( $info['category_parent_id'], 'cms_database_categories' );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
/* Does the ID exist in the source? */
|
||||
$info['category_conv_parent'] = $info['category_parent_id'];
|
||||
|
||||
/* Default to a category unless a later converted forum updates the parent_id */
|
||||
$info['category_parent_id'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Forum Integration */
|
||||
try
|
||||
@@ -1699,6 +1775,8 @@ class _Cms extends Core
|
||||
|
||||
$inserted_id = \IPS\Db::i()->insert( 'cms_database_categories', $info );
|
||||
$this->software->app->addLink( $inserted_id, $id, 'cms_database_categories' );
|
||||
|
||||
\IPS\Db::i()->update( 'cms_database_categories', array( "category_parent_id" => $inserted_id ), array( "category_conv_parent=? AND category_conv_parent<>?", $id, 0 ) );
|
||||
|
||||
\IPS\Lang::saveCustom( 'cms', "content_cat_name_{$inserted_id}", $info['category_name'] );
|
||||
\IPS\Lang::saveCustom( 'cms', "content_cat_name_{$inserted_id}_desc", $desc );
|
||||
@@ -1709,8 +1787,10 @@ class _Cms extends Core
|
||||
/**
|
||||
* Convert a Record
|
||||
*
|
||||
* @param array $info The data to insert.
|
||||
* @param array $fields Custom Field Data.
|
||||
* @param array $info The data to insert.
|
||||
* @param array $fields Custom Field Data.
|
||||
* @param string|NULL $imagepath Path to record image
|
||||
* @param string|NULL $imagedata Image data
|
||||
* @return integer|boolean The ID of the newly inserted record, or FALSE on failure.
|
||||
*/
|
||||
public function convertCmsDatabaseRecord( $info=array(), $fields=array(), $imagepath=NULL, $imagedata=NULL )
|
||||
@@ -1918,6 +1998,12 @@ class _Cms extends Core
|
||||
|
||||
if ( isset( $info['record_image'] ) AND ( !is_null( $imagepath ) OR !is_null( $imagedata ) ) )
|
||||
{
|
||||
$container = NULL;
|
||||
if( $info['record_saved'] )
|
||||
{
|
||||
$container = 'monthly_' . date( 'Y', $info['record_saved'] ) . '_' . date( 'm', $info['record_saved'] );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if ( is_null( $imagedata ) AND !is_null( $imagepath ) )
|
||||
@@ -1925,10 +2011,10 @@ class _Cms extends Core
|
||||
$imagedata = @file_get_contents( $imagepath );
|
||||
$imagepath = NULL;
|
||||
}
|
||||
|
||||
$file = \IPS\File::create( 'cms_Records', $info['record_image'], $imagedata );
|
||||
|
||||
$file = \IPS\File::create( 'cms_Records', $info['record_image'], $imagedata, $container, TRUE );
|
||||
$info['record_image'] = (string) $file;
|
||||
$info['record_image_thumb'] = (string) $file->thumbnail();
|
||||
$info['record_image_thumb'] = (string) $file->thumbnail( 'cms_Records' );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
@@ -2174,10 +2260,6 @@ class _Cms extends Core
|
||||
$info['comment_author'] = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['comment_author'] = NULL;
|
||||
}
|
||||
|
||||
if ( isset( $info['comment_edit_date'] ) )
|
||||
{
|
||||
@@ -2322,7 +2404,7 @@ class _Cms extends Core
|
||||
/* This seems silly, but we really do need a rating */
|
||||
if ( !isset( $info['review_rating'] ) OR $info['review_rating'] < 1 )
|
||||
{
|
||||
$this->software->app->log( 'calendar_event_review_invalid_rating', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['review_id'] );
|
||||
$this->software->app->log( 'cms_database_review_invalid_rating', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['review_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -2648,7 +2730,7 @@ class _Cms extends Core
|
||||
* @param string|NULL $filedata Binary data for the file, or NULL.
|
||||
* @return integer|boolean The ID of the newly inserted attachment, or FALSE on failure.
|
||||
*/
|
||||
public function convertAttachment( $info=array(), $map=array(), $filepath=NULL, $filedata=NULL )
|
||||
public function convertAttachment( $info=array(), $map=array(), $filepath=NULL, $filedata=NULL, $thumbnailpath = NULL )
|
||||
{
|
||||
$database = $this->software->app->getLink( str_replace( '-review', '', $map['id3'] ), 'cms_databases' );
|
||||
|
||||
@@ -2669,6 +2751,6 @@ class _Cms extends Core
|
||||
|
||||
$map['id3'] = $database;
|
||||
|
||||
return parent::convertAttachment( $info, $map, $filepath, $filedata );
|
||||
return parent::convertAttachment( $info, $map, $filepath, $filedata, $thumbnailpath );
|
||||
}
|
||||
}
|
||||
@@ -230,6 +230,18 @@ class _Core extends \IPS\convert\Library
|
||||
'link_type' => 'core_member_ranks',
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertReactions':
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_reactions',
|
||||
'step_method' => 'convertReactions',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'core_reactions' )->first(),
|
||||
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 100,
|
||||
'dependencies' => array(),
|
||||
'link_type' => 'core_reactions',
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertStatuses':
|
||||
$return[ $k ] = array(
|
||||
@@ -252,6 +264,7 @@ class _Core extends \IPS\convert\Library
|
||||
'per_cycle' => 2000,
|
||||
'dependencies' => array( 'convertMembers', 'convertStatuses' ),
|
||||
'link_type' => 'core_member_status_replies',
|
||||
'requires_rebuild' => TRUE
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -335,7 +348,8 @@ class _Core extends \IPS\convert\Library
|
||||
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 1000,
|
||||
'dependencies' => array( 'convertPrivateMessages' ),
|
||||
'link_type' => array( 'core_message_posts' )
|
||||
'link_type' => array( 'core_message_posts' ),
|
||||
'requires_rebuild' => TRUE
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -455,6 +469,8 @@ class _Core extends \IPS\convert\Library
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$return = $this->software->extraMenuRows( $return );
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -517,7 +533,13 @@ class _Core extends \IPS\convert\Library
|
||||
break;
|
||||
|
||||
case 'convertGroups':
|
||||
$return['convertGroups'] = array( 'core_groups' => array( \IPS\Db::i()->in( 'g_id', array( \IPS\Settings::i()->member_group, \IPS\Settings::i()->guest_group, \IPS\Settings::i()->admin_group ), TRUE ) ), 'core_group_promotions' => NULL );
|
||||
$return['convertGroups'] = array(
|
||||
'core_admin_permission_rows' => array( 'row_id_type=? AND ' . \IPS\Db::i()->in( 'row_id', array( \IPS\Settings::i()->member_group, \IPS\Settings::i()->guest_group, \IPS\Settings::i()->admin_group ), TRUE ), 'group' ),
|
||||
'core_groups' => array( \IPS\Db::i()->in( 'g_id', array( \IPS\Settings::i()->member_group, \IPS\Settings::i()->guest_group, \IPS\Settings::i()->admin_group ), TRUE ) ),
|
||||
'core_group_promotions' => NULL,
|
||||
'core_leaders' => array( 'leader_type=? AND ' . \IPS\Db::i()->in( 'leader_type_id', array( \IPS\Settings::i()->member_group, \IPS\Settings::i()->guest_group, \IPS\Settings::i()->admin_group ), TRUE ), 'g' ),
|
||||
'core_moderators' => array( 'type=? AND ' . \IPS\Db::i()->in( 'id', array( \IPS\Settings::i()->member_group, \IPS\Settings::i()->guest_group, \IPS\Settings::i()->admin_group ), TRUE ), 'g' )
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertIgnoredUsers':
|
||||
@@ -529,7 +551,10 @@ class _Core extends \IPS\convert\Library
|
||||
break;
|
||||
|
||||
case 'convertLeaderGroups':
|
||||
$return['convertLeaderGroups'] = array( 'core_leaders_groups' => NULL );
|
||||
$return['convertLeaderGroups'] = array(
|
||||
'core_leaders_groups' => NULL,
|
||||
'core_leaders' => NULL
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertRanks':
|
||||
@@ -546,10 +571,14 @@ class _Core extends \IPS\convert\Library
|
||||
|
||||
case 'convertMembers':
|
||||
$return['convertMembers'] = array(
|
||||
'core_members' => array( "member_id<>?", \IPS\Member::loggedIn()->member_id ),
|
||||
'core_pfields_content' => array( "member_id<>?", \IPS\Member::loggedIn()->member_id ),
|
||||
'core_admin_permission_rows' => array( 'row_id_type=? AND row_id<>?', 'member', \IPS\Member::loggedIn()->member_id ),
|
||||
'core_leaders' => array( 'leader_type=? AND leader_type_id<>?', 'm', \IPS\Member::loggedIn()->member_id ),
|
||||
'core_login_links' => array( "token_member<>?", \IPS\Member::loggedIn()->member_id ),
|
||||
'core_member_history' => NULL,
|
||||
'core_members_warn_actions' => NULL
|
||||
'core_members' => array( "member_id<>?", \IPS\Member::loggedIn()->member_id ),
|
||||
'core_members_warn_actions' => NULL,
|
||||
'core_moderators' => array( 'type=? AND id<>?', 'm', \IPS\Member::loggedIn()->member_id ),
|
||||
'core_pfields_content' => array( "member_id<>?", \IPS\Member::loggedIn()->member_id )
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -584,10 +613,21 @@ class _Core extends \IPS\convert\Library
|
||||
case 'convertProfileFields':
|
||||
if ( $method == $k )
|
||||
{
|
||||
$columns = array();
|
||||
foreach( \IPS\Db::i()->select( 'pf_id', 'core_pfields_data' ) AS $field )
|
||||
{
|
||||
\IPS\Db::i()->dropIndex( 'core_pfields_content', 'field_' . $field );
|
||||
\IPS\Db::i()->dropColumn( 'core_pfields_content', 'field_' . $field );
|
||||
$field = 'field_' . $field;
|
||||
/* Check the column exists before listing it for removal */
|
||||
if( \IPS\Db::i()->checkForColumn( 'core_pfields_content', $field ) )
|
||||
{
|
||||
$columns[] = $field;
|
||||
}
|
||||
}
|
||||
|
||||
if( count( $columns ) )
|
||||
{
|
||||
/* Drop all columns at once */
|
||||
\IPS\Db::i()->dropColumn( 'core_pfields_content', $columns );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -617,6 +657,10 @@ class _Core extends \IPS\convert\Library
|
||||
case 'convertClubMembers':
|
||||
$return['convertClubMembers'] = array( 'core_clubs_memberships' => NULL );
|
||||
break;
|
||||
|
||||
case 'convertReactions':
|
||||
$return['convertReactions'] = array( 'core_reactions' => NULL );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -785,6 +829,11 @@ class _Core extends \IPS\convert\Library
|
||||
$this->software->app->log( 'announcement_missing_content', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$softwareClass = $this->software;
|
||||
$info['announce_content'] = $softwareClass::fixPostData( $info['announce_content'] );
|
||||
}
|
||||
|
||||
if ( !isset( $info['announce_member_id'] ) )
|
||||
{
|
||||
@@ -792,6 +841,16 @@ class _Core extends \IPS\convert\Library
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$info['announce_member_id'] = $this->software->app->getLink( $info['announce_member_id'], 'core_members' );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
$this->software->app->log( 'announcement_missing_member', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( !isset( $info['announce_views'] ) )
|
||||
{
|
||||
$info['announce_views'] = 0;
|
||||
@@ -832,6 +891,15 @@ class _Core extends \IPS\convert\Library
|
||||
$info['announce_location'] = '*';
|
||||
}
|
||||
|
||||
if ( !isset( $info['announce_page_location'] ) )
|
||||
{
|
||||
$info['announce_page_location'] = 'sidebar';
|
||||
}
|
||||
elseif( !is_array( $info['announce_page_location'] ) )
|
||||
{
|
||||
$info['announce_page_location'] = array( $info['announce_page_location'] );
|
||||
}
|
||||
|
||||
$obj = new \IPS\core\Announcements\Announcement;
|
||||
foreach ( $info AS $field => $value)
|
||||
{
|
||||
@@ -852,13 +920,14 @@ class _Core extends \IPS\convert\Library
|
||||
/**
|
||||
* Convert an Attachment
|
||||
*
|
||||
* @param array $info Data to insert
|
||||
* @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 array $info Data to insert
|
||||
* @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
|
||||
* @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 )
|
||||
public function convertAttachment( $info=array(), $map=array(), $filepath=NULL, $filedata=NULL, $thumbnailpath=NULL )
|
||||
{
|
||||
if ( !isset( $info['attach_id'] ) )
|
||||
{
|
||||
@@ -953,18 +1022,27 @@ class _Core extends \IPS\convert\Library
|
||||
{
|
||||
$info['attach_hits'] = 0;
|
||||
}
|
||||
|
||||
/* Figure out the container */
|
||||
$container = 'monthly_' . date( 'Y', $info['attach_date'] ) . '_' . date( 'm', $info['attach_date'] );
|
||||
if( isset( $info['attach_container'] ) )
|
||||
{
|
||||
$container = $info['attach_container'];
|
||||
}
|
||||
|
||||
/* Create the file */
|
||||
$file = NULL;
|
||||
|
||||
try
|
||||
{
|
||||
/* We need the file storage to copy the file rather than move it */
|
||||
\IPS\File\FileSystem::$converterCopy = TRUE;
|
||||
\IPS\File::$copyFiles = TRUE;
|
||||
|
||||
/* Create the file */
|
||||
$file = \IPS\File::create( 'core_Attachments', $info['attach_file'], $filedata, 'monthly_' . date( 'Y', $info['attach_date'] ) . '_' . date( 'm', $info['attach_date'] ), TRUE, $filepath );
|
||||
$file = \IPS\File::create( 'core_Attachment', $info['attach_file'], $filedata, $container, TRUE, $filepath, static::$obscureFilenames );
|
||||
|
||||
/* Revert file system to default functionality */
|
||||
\IPS\File\FileSystem::$converterCopy = FALSE;
|
||||
\IPS\File::$copyFiles = FALSE;
|
||||
unset( $filedata );
|
||||
|
||||
$info['attach_location'] = (string) $file;
|
||||
@@ -979,6 +1057,55 @@ class _Core extends \IPS\convert\Library
|
||||
$this->software->app->log( $e->getMessage(), __METHOD__, \IPS\convert\App::LOG_WARNING, $info['attach_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if( $file === NULL )
|
||||
{
|
||||
$this->software->app->log( 'attachment_creation_fail', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['attach_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if( $thumbnailpath AND isset( $info['attach_thumb_location'] ) AND $info['attach_thumb_location'] )
|
||||
{
|
||||
$thumbFilename = explode( '/', $info['attach_thumb_location'] );
|
||||
$thumbFilename = array_pop( $thumbFilename );
|
||||
|
||||
/* Figure out the container */
|
||||
$thumbnailContainer = 'monthly_' . date( 'Y', $info['attach_date'] ) . '_' . date( 'm', $info['attach_date'] );
|
||||
if( isset( $info['attach_thumb_container'] ) )
|
||||
{
|
||||
$thumbnailContainer = $info['attach_thumb_container'];
|
||||
}
|
||||
|
||||
/* Create the file */
|
||||
try
|
||||
{
|
||||
/* We need the file storage to copy the file rather than move it */
|
||||
\IPS\File::$copyFiles = TRUE;
|
||||
|
||||
/* Create the file */
|
||||
$thumbnail = \IPS\File::create( 'core_Attachment', $thumbFilename, NULL, $thumbnailContainer, TRUE, $thumbnailpath, static::$obscureFilenames );
|
||||
|
||||
/* Revert file system to default functionality */
|
||||
\IPS\File::$copyFiles = FALSE;
|
||||
|
||||
$info['attach_thumb_location'] = (string) $thumbnail;
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
$this->software->app->log( 'attachment_thumb_creation_fail', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['attach_id'] );
|
||||
}
|
||||
catch( \ErrorException $e )
|
||||
{
|
||||
$this->software->app->log( $e->getMessage(), __METHOD__, \IPS\convert\App::LOG_WARNING, $info['attach_id'] );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $info['attach_thumb_location'] );
|
||||
}
|
||||
|
||||
/* Unset container settings */
|
||||
unset( $info['attach_container'], $info['attach_thumb_container'] );
|
||||
|
||||
if ( !isset( $info['attach_filesize'] ) )
|
||||
{
|
||||
@@ -1378,12 +1505,22 @@ class _Core extends \IPS\convert\Library
|
||||
$this->software->app->log( 'edit_history_missing_old', __METHOD__, \IPS\convert\App::LOG_NOTICE, $info['id'] );
|
||||
$info['old'] = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$softwareClass = $this->software;
|
||||
$info['old'] = $softwareClass::fixPostData( $info['old'] );
|
||||
}
|
||||
|
||||
if ( !isset( $info['new'] ) )
|
||||
{
|
||||
$this->software->app->log( 'edit_history_missing_new', __METHOD__, \IPS\convert\App::LOG_NOTICE, $info['id'] );
|
||||
$info['new'] = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$softwareClass = $this->software;
|
||||
$info['new'] = $softwareClass::fixPostData( $info['new'] );
|
||||
}
|
||||
|
||||
if ( isset( $info['public'] ) )
|
||||
{
|
||||
@@ -1506,7 +1643,7 @@ class _Core extends \IPS\convert\Library
|
||||
|
||||
try
|
||||
{
|
||||
$file = \IPS\File::create( 'core_Emoticons', $info['filename'], $filedata, 'emoticons', FALSE, NULL, FALSE );
|
||||
$file = \IPS\File::create( 'core_Emoticons', $info['filename'], $filedata, 'emoticons', FALSE, NULL, static::$obscureFilenames );
|
||||
unset( $info['filename'] );
|
||||
$info['image'] = (string) $file;
|
||||
$dims = $file->getImageDimensions();
|
||||
@@ -1536,7 +1673,7 @@ class _Core extends \IPS\convert\Library
|
||||
$filedatax2 = file_get_contents( rtrim( $filepathx2, '/' ) . '/' . $info['filenamex2'] );
|
||||
$filepathx2 = NULL;
|
||||
}
|
||||
$filex2 = \IPS\File::create( 'core_Emoticons', $info['filenamex2'], $filedatax2, 'emoticons', FALSE, NULL, FALSE );
|
||||
$filex2 = \IPS\File::create( 'core_Emoticons', $info['filenamex2'], $filedatax2, 'emoticons', FALSE, NULL, static::$obscureFilenames );
|
||||
unset( $info['filenamex2'] );
|
||||
$info['image_2x'] = (string) $filex2;
|
||||
}
|
||||
@@ -1635,7 +1772,6 @@ class _Core extends \IPS\convert\Library
|
||||
$info['follow_notify_meta'] = ( isset( $info['follow_notify_meta'] ) ) ? ( is_array( $info['follow_notify_meta'] ) ? json_encode( $info['follow_notify_meta'] ) : $info['follow_notify_meta'] ) : '';
|
||||
$info['follow_notify_freq'] = ( isset( $info['follow_notify_freq'] ) AND in_array( $info['follow_notify_freq'], array( 'none', 'immediate', 'daily', 'weekly' ) ) ) ? $info['follow_notify_freq'] : 'none';
|
||||
$info['follow_visible'] = ( isset( $info['follow_visible'] ) ) ? $info['follow_visible'] : 1;
|
||||
$info['follow_index_id'] = ( isset( $info['follow_index_id'] ) ) ? $info['follow_index_id'] : NULL;
|
||||
|
||||
/* DateTime Stuff */
|
||||
if ( isset( $info['follow_added'] ) )
|
||||
@@ -2407,6 +2543,11 @@ class _Core extends \IPS\convert\Library
|
||||
$this->software->app->log( 'status_reply_no_content', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['reply_id'] );
|
||||
return FALSe;
|
||||
}
|
||||
else
|
||||
{
|
||||
$softwareClass = $this->software;
|
||||
$info['reply_content'] = $softwareClass::fixPostData( $info['reply_content'] );
|
||||
}
|
||||
|
||||
if ( !isset( $info['reply_approved'] ) )
|
||||
{
|
||||
@@ -2475,6 +2616,11 @@ class _Core extends \IPS\convert\Library
|
||||
$this->software->app->log( 'status_update_no_content', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['status_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$softwareClass = $this->software;
|
||||
$info['status_content'] = $softwareClass::fixPostData( $info['status_content'] );
|
||||
}
|
||||
|
||||
if ( !isset( $info['status_replies'] ) )
|
||||
{
|
||||
@@ -2532,6 +2678,11 @@ class _Core extends \IPS\convert\Library
|
||||
$this->software->app->addLink( $inserted_id, $id, 'core_member_status_updates' );
|
||||
return $inserted_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Cache login handlers
|
||||
*/
|
||||
protected static $_loginMethods = NULL;
|
||||
|
||||
/**
|
||||
* Convert a Member
|
||||
@@ -2592,7 +2743,7 @@ class _Core extends \IPS\convert\Library
|
||||
}
|
||||
|
||||
/* Is it using any blocked characters? */
|
||||
if ( \IPS\Settings::i()->username_characters AND !preg_match( '/^[' . str_replace( '\-', '-', preg_quote( \IPS\Settings::i()->username_characters, '/' ) ) . ']*$/i', $info['name'] ) )
|
||||
if ( \IPS\Settings::i()->username_characters AND !preg_match( '/^[' . str_replace( '\-', '-', preg_quote( \IPS\Settings::i()->username_characters, '/' ) ) . ']*$/iu', $info['name'] ) )
|
||||
{
|
||||
$newName = preg_replace( '/^[' . str_replace( '\-', '-', preg_quote( \IPS\Settings::i()->username_characters, '/' ) ) . ']*$/iu', '', $info['name'] );
|
||||
$this->software->app->log( sprintf( \IPS\Member::loggedIn()->language()->get( 'member_name_invalid_chars' ), $info['name'], $newName ), __METHOD__, \IPS\convert\App::LOG_NOTICE, $info['member_id'] );
|
||||
@@ -2676,7 +2827,7 @@ class _Core extends \IPS\convert\Library
|
||||
|
||||
$group = \IPS\Settings::i()->member_group;
|
||||
|
||||
if ( isset( $info['ips_group_id'] ) )
|
||||
if ( array_key_exists( 'ips_group_id', $info ) )
|
||||
{
|
||||
/* Make sure that the user group is actually valid */
|
||||
try
|
||||
@@ -2693,12 +2844,14 @@ class _Core extends \IPS\convert\Library
|
||||
{
|
||||
$groupLink = $this->software->app->getLink( $info['member_group_id'], 'core_groups' );
|
||||
|
||||
/* Make sure that the user group is actually valid */
|
||||
try
|
||||
/* Don't put any users in the guest group, regardless of configuration */
|
||||
if( $groupLink == \IPS\Settings::i()->guest_group )
|
||||
{
|
||||
$group = \IPS\Member\Group::load( $groupLink )->g_id;
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
catch( \ OutOfRangeException $ex ) {}
|
||||
|
||||
/* Make sure that the user group is actually valid */
|
||||
$group = \IPS\Member\Group::load( $groupLink )->g_id;
|
||||
}
|
||||
catch( \OutOfRangeException $e ) {}
|
||||
}
|
||||
@@ -2759,17 +2912,17 @@ class _Core extends \IPS\convert\Library
|
||||
$info['restrict_post'] = 0;
|
||||
}
|
||||
|
||||
if ( !isset( $info['bday_day'] ) )
|
||||
if ( !isset( $info['bday_day'] ) OR !$info['bday_day'] )
|
||||
{
|
||||
$info['bday_day'] = NULL;
|
||||
}
|
||||
|
||||
if ( !isset( $info['bday_month'] ) )
|
||||
if ( !isset( $info['bday_month'] ) OR !$info['bday_month'] )
|
||||
{
|
||||
$info['bday_month'] = NULL;
|
||||
}
|
||||
|
||||
if ( !isset( $info['bday_year'] ) )
|
||||
if ( !isset( $info['bday_year'] ) OR !$info['bday_year'] )
|
||||
{
|
||||
$info['bday_year'] = NULL;
|
||||
}
|
||||
@@ -2949,6 +3102,16 @@ class _Core extends \IPS\convert\Library
|
||||
$info['members_profile_views'] = 0;
|
||||
}
|
||||
|
||||
/* Enable 'view_sigs' for everyone, unless otherwise defined */
|
||||
if( !isset( $info['members_bitoptions']['view_sigs'] ) )
|
||||
{
|
||||
if( !isset( $info['members_bitoptions'] ) )
|
||||
{
|
||||
$info['members_bitoptions'] = array();
|
||||
}
|
||||
$info['members_bitoptions']['view_sigs'] = TRUE;
|
||||
}
|
||||
|
||||
$bitoptions = 0;
|
||||
if ( isset( $info['members_bitoptions'] ) AND is_array( $info['members_bitoptions'] ) )
|
||||
{
|
||||
@@ -2975,14 +3138,9 @@ class _Core extends \IPS\convert\Library
|
||||
}
|
||||
$info['members_bitoptions2'] = $bitoptions2;
|
||||
|
||||
/* These are no longer used */
|
||||
$info['fb_bwoptions'] = 0;
|
||||
$info['tc_bwoptions'] = 0;
|
||||
|
||||
/* We won't know these */
|
||||
$info['members_day_posts'] = '0,0';
|
||||
$info['notification_cnt'] = 0;
|
||||
$info['ipsconnect_id'] = 0;
|
||||
|
||||
if ( isset( $info['pp_last_visitors'] ) )
|
||||
{
|
||||
@@ -3003,7 +3161,7 @@ class _Core extends \IPS\convert\Library
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
$newVisitorId = $this->software->app->getLink( $memberId, 'core_members' )->first();
|
||||
$newVisitorId = $this->software->app->getLink( $memberId, 'core_members' );
|
||||
|
||||
if ( $date instanceof \IPS\DateTime )
|
||||
{
|
||||
@@ -3036,7 +3194,7 @@ class _Core extends \IPS\convert\Library
|
||||
}
|
||||
|
||||
/* We need to make sure this is not set as we need it to be something specific later */
|
||||
unset( $info['pp_photo_type'], $info['pp_main_photo'], $info['pp_thumb_photo'] );
|
||||
unset( $info['pp_photo_type'], $info['pp_main_photo'], $info['pp_thumb_photo'], $info['pp_cover_photo'] );
|
||||
|
||||
/* Profile Photos! */
|
||||
if ( !is_null( $profilePhotoName ) AND ( !is_null( $profilePhotoPath ) OR !is_null( $profileFileData ) ) )
|
||||
@@ -3084,7 +3242,8 @@ class _Core extends \IPS\convert\Library
|
||||
}
|
||||
$cover = \IPS\File::create( 'core_Profile', $coverPhotoName, $coverFileData );
|
||||
$info['pp_cover_photo'] = (string) $cover;
|
||||
$info['pp_cover_offset'] = 0; /* Designs are different so this will never likely be correct */
|
||||
/* Designs are different so this will never likely be correct, we'll try it if one is supplied though */
|
||||
$info['pp_cover_offset'] = isset( $info['pp_cover_offset'] ) ? $info['pp_cover_offset'] : 0;
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
@@ -3130,6 +3289,11 @@ class _Core extends \IPS\convert\Library
|
||||
{
|
||||
$info['signature'] = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
$softwareClass = $this->software;
|
||||
$info['signature'] = $softwareClass::fixPostData( $info['signature'] );
|
||||
}
|
||||
|
||||
if ( isset( $info['pconversation_filters'] ) )
|
||||
{
|
||||
@@ -3174,9 +3338,7 @@ class _Core extends \IPS\convert\Library
|
||||
{
|
||||
$info['allow_admin_mails'] = FALSE;
|
||||
}
|
||||
|
||||
$info['ipsconnect_revalidate_url'] = NULL;
|
||||
|
||||
|
||||
if ( !isset( $info['members_disable_pm'] ) )
|
||||
{
|
||||
$info['members_disable_pm'] = 0;
|
||||
@@ -3215,15 +3377,22 @@ class _Core extends \IPS\convert\Library
|
||||
$info['member_last_post'] = NULL;
|
||||
}
|
||||
|
||||
if( isset( $info['fb_uid'] ) )
|
||||
if( isset( $info['fb_uid'] ) AND !empty( $info['fb_uid'] ) )
|
||||
{
|
||||
$info['fb_uid'] = (int) $info['fb_uid'];
|
||||
$fbUid = $info['fb_uid'];
|
||||
|
||||
/* Load, since there's an ID, cache. */
|
||||
if( static::$_loginMethods === NULL )
|
||||
{
|
||||
static::$_loginMethods = iterator_to_array( \IPS\Db::i()->select( '*', 'core_login_methods' )->setKeyField('login_classname') );
|
||||
}
|
||||
}
|
||||
|
||||
if( isset( $info['fb_token'] ) and empty( $info['fb_token'] ) )
|
||||
if( isset( $info['fb_token'] ) and !empty( $info['fb_token'] ) )
|
||||
{
|
||||
$info['fb_token'] = null;
|
||||
$fbToken = $info['fb_token'];
|
||||
}
|
||||
unset( $info['fb_uid'], $info['fb_token'] );
|
||||
|
||||
$info['member_streams'] = NULL;
|
||||
$info['create_menu'] = NULL;
|
||||
@@ -3234,6 +3403,19 @@ class _Core extends \IPS\convert\Library
|
||||
$inserted_id = \IPS\Db::i()->insert( 'core_members', $info );
|
||||
$this->software->app->addLink( $inserted_id, $id, 'core_members' );
|
||||
\IPS\Db::i()->replace( 'core_pfields_content', $this->_formatMemberProfileFieldContent( $inserted_id, $profileFields ), TRUE );
|
||||
|
||||
/* Social Logins */
|
||||
if ( isset( $fbUid ) and isset( $fbToken ) and $fbUid and isset( static::$_loginMethods['IPS\\Login\\Handler\\OAuth2\\Facebook'] ) )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_login_links', array(
|
||||
'token_login_method' => static::$_loginMethods['IPS\\Login\\Handler\\OAuth2\\Facebook']['login_id'],
|
||||
'token_member' => $inserted_id,
|
||||
'token_identifier' => $fbUid,
|
||||
'token_linked' => TRUE,
|
||||
'token_access_token' => $fbToken,
|
||||
) );
|
||||
}
|
||||
|
||||
return $inserted_id;
|
||||
}
|
||||
|
||||
@@ -3258,10 +3440,40 @@ class _Core extends \IPS\convert\Library
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if( is_array( $info['log_data'] ) )
|
||||
if( !is_array( $info['log_data'] ) )
|
||||
{
|
||||
$info['log_data'] = json_encode( $info['log_data'] );
|
||||
$info['log_data'] = json_decode( $info['log_data'], TRUE );
|
||||
}
|
||||
|
||||
/* Convert IDs in log data */
|
||||
switch( $info['log_type'] )
|
||||
{
|
||||
case 'group_promotion':
|
||||
case 'member_group_id':
|
||||
try
|
||||
{
|
||||
$info['log_data']['new'] = $this->software->app->getLink( $info['log_data']['new'], 'core_groups' );
|
||||
}
|
||||
catch( \Exception $e ) {}
|
||||
break;
|
||||
case 'mgroup_others':
|
||||
case 'group_promotion_o':
|
||||
$groups = array();
|
||||
foreach( explode( ',', $info['log_data']['new'] ) as $groupId )
|
||||
{
|
||||
try
|
||||
{
|
||||
$groups[] = $this->software->app->getLink( $groupId, 'core_groups' );
|
||||
}
|
||||
catch( \Exception $e ) {}
|
||||
}
|
||||
$info['log_data']['new'] = implode( ',', array_unique( $groups ) );
|
||||
break;
|
||||
// We purposefully don't re-map warnings, wid should be the result from the convertWarnLog() method call
|
||||
}
|
||||
|
||||
/* JSON Encode history data */
|
||||
$info['log_data'] = json_encode( $info['log_data'] );
|
||||
|
||||
if ( !isset( $info['log_member'] ) )
|
||||
{
|
||||
@@ -3683,6 +3895,11 @@ class _Core extends \IPS\convert\Library
|
||||
$topic['mt_title'] = "Untitled Conversation {$topic['mt_id']}";
|
||||
$this->software->app->log( 'private_message_topic_title_missing', __METHOD__, \IPS\convert\App::LOG_NOTICE, $topic['mt_id'] );
|
||||
}
|
||||
elseif( mb_strlen( $topic['mt_title'] ) > 255 )
|
||||
{
|
||||
$topic['mt_title'] = mb_substr( $topic['mt_title'], 0, 255 );
|
||||
$this->software->app->log( 'private_message_topic_title_truncated', __METHOD__, \IPS\convert\App::LOG_NOTICE, $topic['mt_id'] );
|
||||
}
|
||||
|
||||
/* No Longer Used */
|
||||
$topic['mt_hasattach'] = 0;
|
||||
@@ -3782,7 +3999,7 @@ class _Core extends \IPS\convert\Library
|
||||
/* We already know this */
|
||||
$map['map_topic_id'] = $topicInsertedId;
|
||||
|
||||
if ( !isset( $map['map_folder_id'] ) )
|
||||
if ( !isset( $map['map_folder_id'] ) OR ( isset( $map['map_folder_id'] ) AND empty( $map['map_folder_id'] ) ) )
|
||||
{
|
||||
$map['map_folder_id'] = 'myconvo';
|
||||
}
|
||||
@@ -4023,8 +4240,24 @@ class _Core extends \IPS\convert\Library
|
||||
$info['id'] = $this->software->app->getLink( $info['id'], 'core_groups' );
|
||||
break;
|
||||
}
|
||||
|
||||
\IPS\Db::i()->insert( 'core_moderators', $info );
|
||||
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_moderators', $info );
|
||||
}
|
||||
catch( \IPS\Db\Exception $e )
|
||||
{
|
||||
/* duplicate entry */
|
||||
if( $e->getCode() == 1062 )
|
||||
{
|
||||
$this->software->app->log( 'moderator_data_duplicate', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -4401,6 +4634,18 @@ class _Core extends \IPS\convert\Library
|
||||
try
|
||||
{
|
||||
$info['pf_group_id'] = $this->software->app->getLink( '__orphaned__', 'core_pfields_groups' );
|
||||
|
||||
/* Make sure it exists */
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->select( 'pf_group_id', 'core_pfields_groups', array( 'pf_group_id=?', $info['pf_group_id'] ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
/* Delete the relation if it no longer exists */
|
||||
$this->software->app->deleteLink( '__orphaned__', 'core_pfields_groups' );
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
@@ -4454,7 +4699,36 @@ class _Core extends \IPS\convert\Library
|
||||
|
||||
return $inserted_id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief All local custom fields
|
||||
*/
|
||||
protected $cachedFields = NULL;
|
||||
|
||||
/**
|
||||
* Get profile fields using cache
|
||||
*
|
||||
* @param int $fieldId Custom field id (local)
|
||||
* @return array
|
||||
* @throws UnderflowException
|
||||
*/
|
||||
protected function _getField( $fieldId )
|
||||
{
|
||||
if( $this->cachedFields === NULL )
|
||||
{
|
||||
$fields = iterator_to_array( \IPS\Db::i()->select( '*', 'core_pfields_data' )->setKeyField('pf_id') );
|
||||
|
||||
$this->cachedFields = ( is_array( $fields ) ) ? $fields : array();
|
||||
}
|
||||
|
||||
if( !isset( $this->cachedFields[ $fieldId ] ) )
|
||||
{
|
||||
throw new \UnderflowException;
|
||||
}
|
||||
|
||||
return $this->cachedFields[ $fieldId ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Format Member Profile Field Content
|
||||
*
|
||||
@@ -4484,7 +4758,7 @@ class _Core extends \IPS\convert\Library
|
||||
$link = $this->software->app->getLink( $id, 'core_pfields_data' );
|
||||
|
||||
/* Make sure the field itself was not removed. */
|
||||
$field = \IPS\Db::i()->select( '*', 'core_pfields_data', array( "pf_id=?", $link ) )->first();
|
||||
$field = $this->_getField( $link );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
@@ -4594,7 +4868,19 @@ class _Core extends \IPS\convert\Library
|
||||
{
|
||||
$info['starter_id'] = 0;
|
||||
}
|
||||
|
||||
|
||||
if ( isset( $info['poll_close_date'] ) )
|
||||
{
|
||||
if ( $info['poll_close_date'] instanceof \IPS\DateTime )
|
||||
{
|
||||
$info['poll_close_date'] = $info['poll_close_date']->getTimestamp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['poll_close_date'] = -1;
|
||||
}
|
||||
|
||||
if ( !isset( $info['votes'] ) )
|
||||
{
|
||||
$voteCount = 0;
|
||||
@@ -4623,7 +4909,18 @@ class _Core extends \IPS\convert\Library
|
||||
$info['poll_view_voters'] = 0;
|
||||
}
|
||||
|
||||
/* Encode our choices... there isn't really a whole lot of checking we can do here */
|
||||
/* Parse the choices to make sure they don't have any HTML in it we don't allow */
|
||||
foreach( $info['choices'] as $key => $choice )
|
||||
{
|
||||
foreach( $choice['choice'] as $k => $c )
|
||||
{
|
||||
$tempParsed = \IPS\Text\LegacyParser::parseStatic( $c, NULL, TRUE );
|
||||
$info['choices'][ $key ]['choice'][ $k ] = strip_tags( \IPS\Text\Parser::parseStatic( $tempParsed, true, null, null, true, true, true, function( $config ) {
|
||||
$config->set( 'HTML.AllowedElements', 'a,img' );
|
||||
} ), '<a><img>' );
|
||||
}
|
||||
}
|
||||
|
||||
$info['choices'] = json_encode( $info['choices'] );
|
||||
|
||||
if ( $hasId )
|
||||
@@ -4677,7 +4974,7 @@ class _Core extends \IPS\convert\Library
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !isset( $vote['ip_address'] ) OR filter_var( $info['ip_address'], FILTER_VALIDATE_IP ) === FALSE )
|
||||
if ( !isset( $vote['ip_address'] ) OR filter_var( $vote['ip_address'], FILTER_VALIDATE_IP ) === FALSE )
|
||||
{
|
||||
$vote['ip_address'] = '127.0.0.1';
|
||||
}
|
||||
@@ -4732,7 +5029,12 @@ class _Core extends \IPS\convert\Library
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( !isset( $info['swop'] ) )
|
||||
if( !isset( $info['action'] ) OR $info['action'] != 'moderate' )
|
||||
{
|
||||
$info['action'] = 'swap';
|
||||
}
|
||||
|
||||
if ( $info['action'] == 'swap' AND !isset( $info['swop'] ) )
|
||||
{
|
||||
$this->software->app->log( 'profanity_filter_no_swop', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
return FALSE;
|
||||
@@ -5007,6 +5309,101 @@ class _Core extends \IPS\convert\Library
|
||||
|
||||
return $inserted_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert reaction
|
||||
*
|
||||
* @param array $info Data to insert
|
||||
* @param NULL|string $filePath Path to files, or NULL if loading from the database.
|
||||
* @param NULL|string $fileData If loading from the database, the content of the Binary column.
|
||||
* @return bool|int ID of new record on success, FALSE on failure
|
||||
*/
|
||||
public function convertReaction( $info=array(), $filePath=NULL, $fileData=NULL )
|
||||
{
|
||||
if ( !isset( $info['reaction_id'] ) )
|
||||
{
|
||||
$this->software->app->log( 'reaction_missing_ids', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( !isset( $info['reaction_value'] ) )
|
||||
{
|
||||
$this->software->app->log( 'reaction_missing_value', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['reaction_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( !isset( $info['filename'] ) )
|
||||
{
|
||||
$this->software->app->log( 'reaction_no_filename', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['reaction_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( is_null( $filePath ) AND is_null( $fileData ) )
|
||||
{
|
||||
$this->software->app->log( 'reaction_no_file', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['reaction_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( is_null( $fileData ) AND !is_null( $filePath ) )
|
||||
{
|
||||
if ( file_exists( rtrim( $filePath, '/' ) . '/' . $info['filename'] ) )
|
||||
{
|
||||
$fileData = @file_get_contents( rtrim( $filePath, '/' ) . '/' . $info['filename'] );
|
||||
$filePath = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->software->app->log( 'reaction_no_file', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['reaction_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !isset( $info['reaction_title'] ) )
|
||||
{
|
||||
$name = "Unnamed Reaction";
|
||||
$this->software->app->log( 'reaction_missing_title', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
}
|
||||
else
|
||||
{
|
||||
$name = $info['reaction_title'];
|
||||
unset( $info['reaction_title'] );
|
||||
}
|
||||
|
||||
if( !isset( $info['reaction_position'] ) )
|
||||
{
|
||||
$newPosition = (int) \IPS\Db::i()->select( 'MAX(reaction_position) + 1', 'core_reactions' )->first();
|
||||
$info['reaction_position'] = $newPosition;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$file = \IPS\File::create( 'core_Reaction', $info['filename'], $fileData, 'emoticons', FALSE, NULL );
|
||||
unset( $info['filename'] );
|
||||
$info['reaction_icon'] = (string) $file;
|
||||
$file->getImageDimensions();
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
$this->software->app->log( 'reaction_file_corrupt', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['reaction_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if( !isset( $info['reaction_enabled'] ) )
|
||||
{
|
||||
$info['reaction_enabled'] = 1;
|
||||
}
|
||||
|
||||
$id = $info['reaction_id'];
|
||||
|
||||
unset( $info['reaction_id'] );
|
||||
|
||||
$insertedId = \IPS\Db::i()->insert( 'core_reactions', $info );
|
||||
$this->software->app->addLink( $insertedId, $id, 'core_reactions' );
|
||||
|
||||
\IPS\Lang::saveCustom( 'core', "reactionTitle_{$insertedId}", $name );
|
||||
|
||||
return $insertedId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a Report
|
||||
@@ -5241,6 +5638,13 @@ class _Core extends \IPS\convert\Library
|
||||
{
|
||||
try
|
||||
{
|
||||
/* Try to lookup a reaction ID link */
|
||||
try
|
||||
{
|
||||
$info['reaction'] = $this->software->app->getLink( $info['reaction'], 'core_reactions' );
|
||||
}
|
||||
catch( \OutOfRangeException $e ) {}
|
||||
|
||||
$reaction = \IPS\Content\Reaction::load( $info['reaction'] );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
@@ -5490,7 +5894,7 @@ class _Core extends \IPS\convert\Library
|
||||
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => $setting['value'] ), array( "conf_key=?", $setting['key'] ) );
|
||||
}
|
||||
|
||||
unset( \IPS\Data\Store::i()->settings );
|
||||
\IPS\Settings::i()->clearCache();
|
||||
|
||||
return $settings;
|
||||
}
|
||||
@@ -5748,9 +6152,11 @@ class _Core extends \IPS\convert\Library
|
||||
$info['cover_photo'] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* We won't know this */
|
||||
$info['cover_offset'] = NULL;
|
||||
|
||||
if ( !isset( $info['cover_offset'] ) )
|
||||
{
|
||||
$info['cover_offset'] = NULL;
|
||||
}
|
||||
|
||||
if ( !isset( $info['featured'] ) )
|
||||
{
|
||||
@@ -5879,8 +6285,22 @@ class _Core extends \IPS\convert\Library
|
||||
{
|
||||
$info['invited_by'] = NULL;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_clubs_memberships', $info );
|
||||
}
|
||||
catch( \IPS\Db\Exception $e )
|
||||
{
|
||||
/* Duplicate row */
|
||||
if( $e->getCode() == 1062 )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
\IPS\Db::i()->insert( 'core_clubs_memberships', $info );
|
||||
return $info['member_id'];
|
||||
}
|
||||
}
|
||||
@@ -90,6 +90,7 @@ class _Downloads extends Core
|
||||
'per_cycle' => 250,
|
||||
'dependencies' => $dependencies,
|
||||
'link_type' => 'downloads_files',
|
||||
'requires_rebuild' => TRUE
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -102,6 +103,7 @@ class _Downloads extends Core
|
||||
'per_cycle' => 1500,
|
||||
'dependencies' => array( 'convertDownloadsFiles' ),
|
||||
'link_type' => 'downloads_comments',
|
||||
'requires_rebuild' => TRUE
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -114,6 +116,7 @@ class _Downloads extends Core
|
||||
'per_cycle' => 1500,
|
||||
'dependencies' => array( 'convertDownloadsFiles' ),
|
||||
'link_type' => 'downloads_reviews',
|
||||
'requires_rebuild' => TRUE
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -178,6 +181,8 @@ class _Downloads extends Core
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$return = $this->software->extraMenuRows( $return );
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -202,7 +207,7 @@ class _Downloads extends Core
|
||||
switch( $k )
|
||||
{
|
||||
case 'convertDownloadsCategories':
|
||||
$return['convertDownloadsCategories'] = array( 'downloads_categories' => NULL );
|
||||
$return['convertDownloadsCategories'] = array( 'downloads_categories' => NULL, 'core_permission_index' => array( 'app=? AND perm_type=?', 'downloads', 'category' ) );
|
||||
break;
|
||||
|
||||
case 'convertDownloadsCfields':
|
||||
@@ -1010,13 +1015,11 @@ class _Downloads extends Core
|
||||
}
|
||||
|
||||
/* We need the file storage to copy the file rather than move it */
|
||||
\IPS\File\FileSystem::$converterCopy = TRUE;
|
||||
\IPS\File::$copyFiles = TRUE;
|
||||
|
||||
if ( $record['record_type'] == 'link' )
|
||||
{
|
||||
$record['record_location'] = $record['file_path'];
|
||||
unset( $record['file_path'] );
|
||||
|
||||
$record['record_size'] = 0;
|
||||
}
|
||||
else if ( $record['record_type'] == 'upload' )
|
||||
@@ -1034,7 +1037,7 @@ class _Downloads extends Core
|
||||
{
|
||||
$file = \IPS\File::create( 'downloads_Screenshots', $record['record_realname'], $record['file_data'], NULL, TRUE, $record['file_path'] );
|
||||
$record['record_location'] = (string) $file;
|
||||
$record['record_thumb'] = (string) $file->thumbnail( 'downloads_Files' );
|
||||
$record['record_thumb'] = (string) $file->thumbnail( 'downloads_Screenshots' );
|
||||
$record['record_size'] = $file->filesize();
|
||||
}
|
||||
}
|
||||
@@ -1050,8 +1053,8 @@ class _Downloads extends Core
|
||||
}
|
||||
|
||||
/* Revert file system to default functionality */
|
||||
\IPS\File\FileSystem::$converterCopy = FALSE;
|
||||
unset( $record['file_data'], $file );
|
||||
\IPS\File::$copyFiles = FALSE;
|
||||
unset( $record['file_data'], $file, $record['file_path'] );
|
||||
|
||||
if ( isset( $record['record_time'] ) )
|
||||
{
|
||||
@@ -1239,11 +1242,11 @@ class _Downloads extends Core
|
||||
$this->software->app->log( 'download_review_missing_ids', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( empty( $info['review_text'] ) )
|
||||
|
||||
/* We'll allow reviews to be posted without text, since they may just be a rating - we allow for this for upgrades from 3.x. */
|
||||
if ( !isset( $info['review_text'] ) )
|
||||
{
|
||||
$this->software->app->log( 'download_review_missing_content', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['review_id'] );
|
||||
return FALSE;
|
||||
$info['review_text'] = '';
|
||||
}
|
||||
|
||||
if ( !isset( $info['review_rating'] ) OR $info['review_rating'] < 1 )
|
||||
@@ -1428,7 +1431,7 @@ class _Downloads extends Core
|
||||
* @param string|NULL $filedata Binary data for the file, or NULL.
|
||||
* @return integer|boolean The ID of the newly inserted attachment, or FALSE on failure.
|
||||
*/
|
||||
public function convertAttachment( $info=array(), $map=array(), $filepath=NULL, $filedata=NULL )
|
||||
public function convertAttachment( $info=array(), $map=array(), $filepath=NULL, $filedata=NULL, $thumbnailpath = NULL )
|
||||
{
|
||||
$map['location_key'] = 'downloads_Downloads';
|
||||
$map['id1_type'] = 'downloads_files';
|
||||
@@ -1449,7 +1452,7 @@ class _Downloads extends Core
|
||||
$map['id2_type'] = 'downloads_reviews';
|
||||
}
|
||||
|
||||
return parent::convertAttachment( $info, $map, $filepath, $filedata );
|
||||
return parent::convertAttachment( $info, $map, $filepath, $filedata, $thumbnailpath );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -68,13 +68,14 @@ class _Forums extends Core
|
||||
|
||||
case 'convertForumsPosts':
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_forums_posts',
|
||||
'step_method' => 'convertForumsPosts',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'forums_posts' )->first(),
|
||||
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 1000,
|
||||
'dependencies' => array( 'convertForumsTopics' ),
|
||||
'link_type' => 'forums_posts',
|
||||
'step_title' => 'convert_forums_posts',
|
||||
'step_method' => 'convertForumsPosts',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'forums_posts' )->first(),
|
||||
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 1000,
|
||||
'dependencies' => array( 'convertForumsTopics' ),
|
||||
'link_type' => 'forums_posts',
|
||||
'requires_rebuild' => TRUE
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -201,6 +202,8 @@ class _Forums extends Core
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$return = $this->software->extraMenuRows( $return );
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -244,7 +247,8 @@ class _Forums extends Core
|
||||
$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
|
||||
'forums_forums' => NULL,
|
||||
'core_permission_index' => array( 'app=? AND perm_type=?', 'forums', 'forum' )
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -800,6 +804,8 @@ class _Forums extends Core
|
||||
'parent_id' => -1
|
||||
) );
|
||||
}
|
||||
|
||||
$info['club_id'] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -985,7 +991,11 @@ class _Forums extends Core
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['last_poster_name'] = $info['starter_name'];
|
||||
/*
|
||||
* We want to make sure that we're not setting NULL here, although allowed in some places it can
|
||||
* cause issues with setting the last comment during the post-conversion topic deletion task.
|
||||
*/
|
||||
$info['last_poster_name'] = $info['starter_name'] ?: '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2050,13 +2060,14 @@ class _Forums extends Core
|
||||
/**
|
||||
* Convert an Attachment
|
||||
*
|
||||
* @param array $info Data to insert
|
||||
* @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 array $info Data to insert
|
||||
* @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
|
||||
* @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 )
|
||||
public function convertAttachment( $info=array(), $map=array(), $filepath=NULL, $filedata=NULL, $thumbnailpath=NULL )
|
||||
{
|
||||
/* The Core Library handles most of this. We just need to make sure forum specific data is set. */
|
||||
$map['id1_type'] = 'forums_topics';
|
||||
@@ -2065,7 +2076,7 @@ class _Forums extends Core
|
||||
$map['id2_from_parent'] = FALSE;
|
||||
$map['location_key'] = 'forums_Forums';
|
||||
|
||||
return parent::convertAttachment( $info, $map, $filepath, $filedata );
|
||||
return parent::convertAttachment( $info, $map, $filepath, $filedata, $thumbnailpath );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -70,6 +70,32 @@ class _Gallery extends Core
|
||||
'link_type' => 'gallery_albums',
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertGalleryAlbumComments':
|
||||
$return[ $k ] = array(
|
||||
'step_method' => 'convertGalleryAlbumComments',
|
||||
'step_title' => 'convert_gallery_album_comments',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'gallery_album_comments' )->first(),
|
||||
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 1500,
|
||||
'dependencies' => array( 'convertGalleryAlbums' ),
|
||||
'link_type' => 'gallery_album_comments',
|
||||
'requires_rebuild' => TRUE
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertGalleryAlbumReviews':
|
||||
$return[ $k ] = array(
|
||||
'step_method' => 'convertGalleryAlbumReviews',
|
||||
'step_title' => 'convert_gallery_album_reviews',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'gallery_album_reviews' )->first(),
|
||||
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 1500,
|
||||
'dependencies' => array( 'convertGalleryAlbums' ),
|
||||
'link_type' => 'gallery_album_reviews',
|
||||
'requires_rebuild' => TRUE
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertGalleryImages':
|
||||
$dependencies = array();
|
||||
@@ -93,6 +119,7 @@ class _Gallery extends Core
|
||||
'per_cycle' => 100,
|
||||
'dependencies' => $dependencies,
|
||||
'link_type' => 'gallery_images',
|
||||
'requires_rebuild' => TRUE
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -105,6 +132,7 @@ class _Gallery extends Core
|
||||
'per_cycle' => 1500,
|
||||
'dependencies' => array( 'convertGalleryImages' ),
|
||||
'link_type' => 'gallery_comments',
|
||||
'requires_rebuild' => TRUE
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -117,6 +145,7 @@ class _Gallery extends Core
|
||||
'per_cycle' => 1500,
|
||||
'dependencies' => array( 'convertGalleryImages' ),
|
||||
'link_type' => 'gallery_reviews',
|
||||
'requires_rebuild' => TRUE
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -193,6 +222,8 @@ class _Gallery extends Core
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$return = $this->software->extraMenuRows( $return );
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -217,12 +248,24 @@ class _Gallery extends Core
|
||||
switch( $k )
|
||||
{
|
||||
case 'convertGalleryCategories':
|
||||
$return['convertGalleryCategories'] = array( 'gallery_categories' => NULL, 'core_clubs_node_map' => array( "node_class=?", "IPS\\gallery\\Category" ) );
|
||||
$return['convertGalleryCategories'] = array(
|
||||
'gallery_categories' => NULL,
|
||||
'core_clubs_node_map' => array( "node_class=?", "IPS\\gallery\\Category" ),
|
||||
'core_permission_index' => array( 'app=? AND perm_type=?', 'gallery', 'category' )
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertGalleryAlbums':
|
||||
$return['convertGalleryAlbums'] = array( 'gallery_albums' => NULL );
|
||||
break;
|
||||
|
||||
case 'convertGalleryAlbumComments':
|
||||
$return['convertGalleryAlbumComments'] = array( 'gallery_album_comments' => NULL );
|
||||
break;
|
||||
|
||||
case 'convertGalleryAlbumReviews':
|
||||
$return['convertGalleryAlbumReviews'] = array( 'gallery_album_reviews' => NULL );
|
||||
break;
|
||||
|
||||
case 'convertGalleryImages':
|
||||
$return['convertGalleryImages'] = array( 'gallery_images' => NULL );
|
||||
@@ -520,6 +563,11 @@ class _Gallery extends Core
|
||||
{
|
||||
$info['album_allow_rating'] = 1;
|
||||
}
|
||||
|
||||
if ( !isset( $info['album_submit_type'] ) )
|
||||
{
|
||||
$info['album_submit_type'] = 0;
|
||||
}
|
||||
|
||||
if ( !isset( $info['album_position'] ) )
|
||||
{
|
||||
@@ -573,7 +621,21 @@ class _Gallery extends Core
|
||||
{
|
||||
try
|
||||
{
|
||||
return $this->software->app->getLink( '__orphaned__', 'gallery_categories' );
|
||||
$id = $this->software->app->getLink( '__orphaned__', 'gallery_categories' );
|
||||
|
||||
/* Check the category exists */
|
||||
try
|
||||
{
|
||||
\IPS\gallery\Category::load( $id );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
/* Delete the relation if it no longer exists */
|
||||
$this->software->app->deleteLink( '__orphaned__', 'gallery_categories' );
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
@@ -612,7 +674,7 @@ class _Gallery extends Core
|
||||
if ( isset( $info['image_album_id'] ) )
|
||||
{
|
||||
/* We only want to do this if the Album ID is explicitly not 0, as that means it has no album, which is okay */
|
||||
if ( $info['image_album_id'] > 0 )
|
||||
if ( !empty( $info['image_album_id'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -683,26 +745,6 @@ class _Gallery extends Core
|
||||
}
|
||||
}
|
||||
|
||||
if ( !isset( $info['image_caption'] ) )
|
||||
{
|
||||
if ( !is_null( $filepath ) )
|
||||
{
|
||||
$caption = explode( '/', $info['image_caption'] );
|
||||
$caption = array_pop( $caption );
|
||||
}
|
||||
else
|
||||
{
|
||||
$caption = "Untitled Image {$info['image_id']}";
|
||||
}
|
||||
|
||||
$info['image_caption'] = $caption;
|
||||
}
|
||||
|
||||
if ( mb_strlen( $info['image_caption'] ) > 255 )
|
||||
{
|
||||
$info['image_caption'] = mb_substr( $info['image_caption'], 0, 200 );
|
||||
}
|
||||
|
||||
if ( !isset( $info['image_description'] ) )
|
||||
{
|
||||
$info['image_description'] = NULL;
|
||||
@@ -710,9 +752,7 @@ class _Gallery extends Core
|
||||
|
||||
/* We will build these later */
|
||||
$info['image_masked_file_name'] = NULL;
|
||||
$info['image_medium_file_name'] = NULL;
|
||||
$info['image_small_file_name'] = NULL;
|
||||
$info['image_thumb_file_name'] = NULL;
|
||||
|
||||
/* Figure this out before we bother creating the image */
|
||||
if ( !isset( $info['image_file_type'] ) )
|
||||
@@ -735,7 +775,7 @@ class _Gallery extends Core
|
||||
{
|
||||
$file_name = explode( '/', $filepath );
|
||||
$file_name = array_pop( $file_name );
|
||||
$info['image_file_name'] = $file_name;
|
||||
$info['image_file_name'] = mb_substr( $file_name, 0, 255 );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -744,6 +784,54 @@ class _Gallery extends Core
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['image_file_name'] = mb_substr( $info['image_file_name'], 0, 255 );
|
||||
}
|
||||
|
||||
/* Image Caption */
|
||||
if ( !isset( $info['image_caption'] ) )
|
||||
{
|
||||
if ( !is_null( $filepath ) )
|
||||
{
|
||||
$caption = explode( '/', $info['image_file_name'] );
|
||||
$caption = array_pop( $caption );
|
||||
}
|
||||
else
|
||||
{
|
||||
$caption = "Untitled Image {$info['image_id']}";
|
||||
}
|
||||
|
||||
$info['image_caption'] = $caption;
|
||||
}
|
||||
|
||||
if ( mb_strlen( $info['image_caption'] ) > 255 )
|
||||
{
|
||||
$info['image_caption'] = mb_substr( $info['image_caption'], 0, 200 );
|
||||
}
|
||||
|
||||
/* Dates */
|
||||
foreach( array( 'image_date', 'image_last_comment', 'image_updated' ) AS $date )
|
||||
{
|
||||
if ( isset( $info[ $date ] ) )
|
||||
{
|
||||
if ( $info[ $date ] instanceof \IPS\DateTime )
|
||||
{
|
||||
$info[ $date ] = $info[ $date ]->getTimestamp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info[ $date ] = time();
|
||||
}
|
||||
}
|
||||
|
||||
/* Figure out the container */
|
||||
$container = 'monthly_' . date( 'Y', $info['image_date'] ) . '_' . date( 'm', $info['image_date'] );
|
||||
if( isset( $info['image_container'] ) )
|
||||
{
|
||||
$container = $info['image_container'];
|
||||
}
|
||||
|
||||
/* Okay, let's create our image. We can use data returned from this later if it's missing. */
|
||||
try
|
||||
@@ -758,7 +846,7 @@ class _Gallery extends Core
|
||||
|
||||
$filedata = file_get_contents( $filepath );
|
||||
}
|
||||
$image = \IPS\File::create( 'gallery_Images', $info['image_file_name'], $filedata );
|
||||
$image = \IPS\File::create( 'gallery_Images', $info['image_file_name'], $filedata, $container );
|
||||
$info['image_original_file_name'] = (string) $image;
|
||||
|
||||
if ( !isset( $info['image_file_size'] ) )
|
||||
@@ -790,23 +878,7 @@ class _Gallery extends Core
|
||||
$info[ $count ] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Dates */
|
||||
foreach( array( 'image_date', 'image_last_comment', 'image_updated' ) AS $date )
|
||||
{
|
||||
if ( isset( $info[ $date ] ) )
|
||||
{
|
||||
if ( $info[ $date ] instanceof \IPS\DateTime )
|
||||
{
|
||||
$info[ $date ] = $info[ $date ]->getTimestamp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info[ $date ] = time();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( !isset( $info['image_pinned'] ) )
|
||||
{
|
||||
$info['image_pinned'] = 0;
|
||||
@@ -935,6 +1007,314 @@ class _Gallery extends Core
|
||||
|
||||
return $inserted_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an album comment
|
||||
*
|
||||
* @param array $info Data to insert
|
||||
* @return integer|boolean The ID of the newly inserted comment, or FALSE on failure.
|
||||
*/
|
||||
public function convertGalleryAlbumComment( $info=array() )
|
||||
{
|
||||
if ( !isset( $info['comment_id'] ) )
|
||||
{
|
||||
$this->software->app->log( 'gallery_album_comment_missing_ids', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( empty( $info['comment_text'] ) )
|
||||
{
|
||||
$this->software->app->log( 'gallery_album_comment_missing_content', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['comment_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( isset( $info['comment_album_id'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$info['comment_album_id'] = $this->software->app->getLink( $info['comment_album_id'], 'gallery_albums' );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
$this->software->app->log( 'gallery_album_comment_missing_image', __METHOD__, \IPS\convert\ApP::LOG_WARNING, $info['comment_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->software->app->log( 'gallery_album_omment_missing_image', __METHOD__, \IPS\convert\ApP::LOG_WARNING, $info['comment_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( isset( $info['comment_edit_time'] ) )
|
||||
{
|
||||
if ( $info['comment_edit_time'] instanceof \IPS\DateTime )
|
||||
{
|
||||
$info['comment_edit_time'] = $info['comment_edit_time']->getTimestamp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['comment_edit_time'] = 0;
|
||||
}
|
||||
|
||||
if ( isset( $info['comment_author_id'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$info['comment_author_id'] = $this->software->app->getLink( $info['comment_author_id'], 'core_members', TRUE );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
$info['comment_author_id'] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['comment_author_id'] = 0;
|
||||
}
|
||||
|
||||
if ( !isset( $info['comment_author_name'] ) )
|
||||
{
|
||||
$author = \IPS\Member::load( $info['comment_author_id'] );
|
||||
|
||||
if ( $author->member_id )
|
||||
{
|
||||
$info['comment_author_name'] = $author->name;
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['comment_author_name'] = "Guest";
|
||||
}
|
||||
}
|
||||
|
||||
if ( !isset( $info['comment_ip_address'] ) OR filter_var( $info['comment_ip_address'], FILTER_VALIDATE_IP ) === FALSE )
|
||||
{
|
||||
$info['comment_ip_address'] = '127.0.0.1';
|
||||
}
|
||||
|
||||
if ( isset( $info['comment_post_date'] ) )
|
||||
{
|
||||
if ( $info['comment_post_date'] instanceof \IPS\DateTime )
|
||||
{
|
||||
$info['comment_post_date'] = $info['comment_post_date']->getTimestamp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['comment_post_date'] = time();
|
||||
}
|
||||
|
||||
if ( !isset( $info['comment_approved'] ) )
|
||||
{
|
||||
$info['comment_approved'] = 1;
|
||||
}
|
||||
|
||||
if ( !isset( $info['comment_append_edit'] ) )
|
||||
{
|
||||
$info['comment_append_edit'] = 0;
|
||||
}
|
||||
|
||||
if ( !isset( $info['comment_edit_name'] ) )
|
||||
{
|
||||
$info['comment_edit_name'] = NULL;
|
||||
}
|
||||
|
||||
$id = $info['comment_id'];
|
||||
unset( $info['comment_id'] );
|
||||
|
||||
$inserted_id = \IPS\Db::i()->insert( 'gallery_album_comments', $info );
|
||||
$this->software->app->addLink( $inserted_id, $id, 'gallery_album_comments' );
|
||||
|
||||
return $inserted_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an album review
|
||||
*
|
||||
* @param array $info Data to insert
|
||||
* @return integer|boolean The ID of the newly inserted reiew, or FALSE on failure.
|
||||
*/
|
||||
public function convertGalleryAlbumReview( $info=array() )
|
||||
{
|
||||
if ( !isset( $info['review_id'] ) )
|
||||
{
|
||||
$this->software->app->log( 'gallery_album_review_missing_ids', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( empty( $info['review_content'] ) )
|
||||
{
|
||||
$this->software->app->log( 'gallery_album_review_missing_content', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['review_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( !isset( $info['review_rating'] ) OR $info['review_rating'] < 1 )
|
||||
{
|
||||
$this->software->app->log( 'gallery_album_review_missing_rating', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['review_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( isset( $info['review_author'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$info['review_author'] = $this->software->app->getLink( $info['review_author'], 'core_members', TRUE );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
$this->software->app->log( 'gallery_album_review_missing_author', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['review_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->software->app->log( 'gallery_album_review_missing_author', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['review_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( isset( $info['review_album_id'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$info['review_album_id'] = $this->software->app->getLink( $info['review_album_id'], 'gallery_albums' );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
$this->software->app->log( 'gallery_album_review_missing_album', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['review_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !isset( $info['review_author_name'] ) )
|
||||
{
|
||||
$info['review_author_name'] = \IPS\Member::load( $info['review_author'] )->name;
|
||||
}
|
||||
|
||||
if ( isset( $info['review_date'] ) )
|
||||
{
|
||||
if ( $info['review_date'] instanceof \IPS\DateTime )
|
||||
{
|
||||
$info['review_date'] = $info['review_date']->getTimestamp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['review_date'] = time();
|
||||
}
|
||||
|
||||
if ( !isset( $info['review_ip_address'] ) OR filter_var( $info['review_ip_address'], FILTER_VALIDATE_IP ) === FALSE )
|
||||
{
|
||||
$info['review_ip_address'] = '127.0.0.1';
|
||||
}
|
||||
|
||||
if ( isset( $info['review_edit_time'] ) )
|
||||
{
|
||||
if ( $info['review_edit_time'] instanceof \IPS\DateTime )
|
||||
{
|
||||
$info['review_edit_time'] = $info['review_edit_time']->getTimestamp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['review_edit_time'] = 0;
|
||||
}
|
||||
|
||||
if ( !isset( $info['review_edit_member_name'] ) )
|
||||
{
|
||||
$info['review_edit_member_name'] = '';
|
||||
}
|
||||
|
||||
if ( !isset( $info['review_edit_show'] ) )
|
||||
{
|
||||
$info['review_edit_show'] = 0;
|
||||
}
|
||||
|
||||
if ( isset( $info['review_votes_data'] ) )
|
||||
{
|
||||
if ( !is_array( $info['review_votes_data'] ) )
|
||||
{
|
||||
$info['review_votes_data'] = json_decode( $info['review_votes_data'], TRUE );
|
||||
}
|
||||
|
||||
$newVoters = array();
|
||||
if ( !is_null( $info['review_votes_data'] ) AND count( $info['review_votes_data'] ) )
|
||||
{
|
||||
foreach( $info['review_votes_data'] AS $member => $vote )
|
||||
{
|
||||
try
|
||||
{
|
||||
$memberId = $this->software->app->getLink( $member, 'core_members', TRUE );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$newVoters[ $memberId ] = $vote;
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $newVoters ) )
|
||||
{
|
||||
$info['review_votes_data'] = json_encode( $newVoters );
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['review_votes_data'] = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['review_votes_data'] = NULL;
|
||||
}
|
||||
|
||||
if ( !isset( $info['review_votes'] ) )
|
||||
{
|
||||
if ( is_null( $info['review_votes_data'] ) )
|
||||
{
|
||||
$info['review_votes'] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['review_votes'] = count( json_decode( $info['review_votes_data'], TRUE ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !isset( $info['review_votes_helpful'] ) )
|
||||
{
|
||||
if ( is_null( $info['review_votes_data'] ) )
|
||||
{
|
||||
$info['review_votes_helpful'] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$helpful = 0;
|
||||
foreach( json_decode( $info['review_votes_data'], TRUE ) AS $member => $vote )
|
||||
{
|
||||
if ( $vote == 1 )
|
||||
{
|
||||
$helpful += 1;
|
||||
}
|
||||
}
|
||||
|
||||
$info['review_votes_helpful'] = $helpful;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !isset( $info['review_approved'] ) )
|
||||
{
|
||||
$info['review_approved'] = 1;
|
||||
}
|
||||
|
||||
$id = $info['review_id'];
|
||||
unset( $info['review_id'] );
|
||||
|
||||
$inserted_id = \IPS\Db::i()->insert( 'gallery_album_reviews', $info );
|
||||
$this->software->app->addLink( $inserted_id, $id, 'gallery_album_reviews' );
|
||||
|
||||
return $inserted_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a comment
|
||||
@@ -1253,7 +1633,7 @@ class _Gallery extends Core
|
||||
* @param string|NULL $filedata The binary data of the attachment, or NULL.
|
||||
* @return integer|boolean The ID of the newly inserted attachment, or FALSE on failure.
|
||||
*/
|
||||
public function convertAttachment( $info=array(), $map=array(), $filepath=NULL, $filedata=NULL )
|
||||
public function convertAttachment( $info=array(), $map=array(), $filepath=NULL, $filedata=NULL, $thumbnailpath = NULL )
|
||||
{
|
||||
$map['location_key'] = 'gallery_Gallery';
|
||||
$map['id1_type'] = 'gallery_images';
|
||||
@@ -1274,7 +1654,7 @@ class _Gallery extends Core
|
||||
$map['id2_type'] = 'gallery_reviews';
|
||||
}
|
||||
|
||||
return parent::convertAttachment( $info, $map, $filepath, $filedata );
|
||||
return parent::convertAttachment( $info, $map, $filepath, $filedata, $thumbnailpath );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -153,25 +153,27 @@ class _Nexus extends \IPS\convert\Library
|
||||
}
|
||||
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_nexus_packages',
|
||||
'step_method' => 'convertNexusPackages',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'nexus_packages' )->first(),
|
||||
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 100,
|
||||
'dependencies' => $dependencies,
|
||||
'link_type' => 'nexus_packages',
|
||||
'step_title' => 'convert_nexus_packages',
|
||||
'step_method' => 'convertNexusPackages',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'nexus_packages' )->first(),
|
||||
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 100,
|
||||
'dependencies' => $dependencies,
|
||||
'link_type' => 'nexus_packages',
|
||||
'requires_rebuild' => TRUE
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertNexusReviews':
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_nexus_reviews',
|
||||
'step_method' => 'convertNexusReviews',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'nexus_reviews' )->first(),
|
||||
'source_rows' => $this->software->sourceRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 1500,
|
||||
'dependencies' => array( 'convertNexusPackages' ),
|
||||
'link_type' => 'nexus_reviews',
|
||||
'step_title' => 'convert_nexus_reviews',
|
||||
'step_method' => 'convertNexusReviews',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'nexus_reviews' )->first(),
|
||||
'source_rows' => $this->software->sourceRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 1500,
|
||||
'dependencies' => array( 'convertNexusPackages' ),
|
||||
'link_type' => 'nexus_reviews',
|
||||
'requires_rebuild' => TRUE
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -296,30 +298,34 @@ class _Nexus extends \IPS\convert\Library
|
||||
|
||||
case 'convertNexusSupportRequests':
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_nexus_support_requests',
|
||||
'step_method' => 'convertNexusSupportRequests',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'nexus_support_requests' )->first(),
|
||||
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 1500,
|
||||
'dependencies' => array( 'convertNexusCustomers', 'convertNexusSupportDepartments', 'convertNexusSupportFields' ),
|
||||
'link_type' => 'nexus_support_requests',
|
||||
'step_title' => 'convert_nexus_support_requests',
|
||||
'step_method' => 'convertNexusSupportRequests',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'nexus_support_requests' )->first(),
|
||||
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 1500,
|
||||
'dependencies' => array( 'convertNexusCustomers', 'convertNexusSupportDepartments', 'convertNexusSupportFields' ),
|
||||
'link_type' => 'nexus_support_requests',
|
||||
'requires_rebuild' => TRUE
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertNexusSupportReplies':
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_nexus_support_replies',
|
||||
'step_method' => 'convertNexusSupportReplies',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'nexus_support_replies' )->first(),
|
||||
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 2000,
|
||||
'dependencies' => array( 'convertNexusSupportRequests' ),
|
||||
'link_type' => 'nexus_support_replies'
|
||||
'step_title' => 'convert_nexus_support_replies',
|
||||
'step_method' => 'convertNexusSupportReplies',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'nexus_support_replies' )->first(),
|
||||
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
|
||||
'per_cycle' => 2000,
|
||||
'dependencies' => array( 'convertNexusSupportRequests' ),
|
||||
'link_type' => 'nexus_support_replies',
|
||||
'requires_rebuild' => TRUE
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$return = $this->software->extraMenuRows( $return );
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user