Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
@@ -43,6 +43,30 @@ class _Core extends \IPS\convert\Library
|
||||
{
|
||||
switch( $k )
|
||||
{
|
||||
case 'convertAchievementBadges':
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_achievement_badges',
|
||||
'step_method' => 'convertAchievementBadges',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'core_badges' ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 100,
|
||||
'dependencies' => array(),
|
||||
'link_type' => 'core_achievement_badges',
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertAchievementRanks':
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_achievement_ranks',
|
||||
'step_method' => 'convertAchievementRanks',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'core_member_ranks' ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array(),
|
||||
'link_type' => 'core_achievement_ranks',
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertAcronyms':
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_acronyms',
|
||||
@@ -89,13 +113,22 @@ class _Core extends \IPS\convert\Library
|
||||
break;
|
||||
|
||||
case 'convertAttachments':
|
||||
$dependencies = array();
|
||||
|
||||
if ( array_key_exists( 'convertPrivateMessageReplies', $this->getConvertableItems() ) )
|
||||
{
|
||||
$dependencies[] = 'convertPrivateMessageReplies';
|
||||
}
|
||||
|
||||
$dependencies[] = 'convertMembers';
|
||||
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_attachments',
|
||||
'step_method' => 'convertAttachments',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'core_attachments' ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 10,
|
||||
'dependencies' => array( 'convertMembers' ),
|
||||
'dependencies' => $dependencies,
|
||||
'link_type' => 'core_attachments',
|
||||
);
|
||||
break;
|
||||
@@ -525,6 +558,14 @@ class _Core extends \IPS\convert\Library
|
||||
switch( $k )
|
||||
{
|
||||
/* Should return multiple array members for each table that needs to be truncated. The key should be the table, while the value should be a WHERE clause, or NULL to completely empty the table */
|
||||
case 'convertAchievementBadges':
|
||||
$return['convertAchievementBadges'] = array( 'core_badges' => NULL );
|
||||
break;
|
||||
|
||||
case 'convertAchievementRanks':
|
||||
$return['convertAchievementRanks'] = array( 'core_member_ranks' => NULL );
|
||||
break;
|
||||
|
||||
case 'convertAcronyms':
|
||||
$return['convertAcronyms'] = array( 'core_acronyms' => NULL );
|
||||
break;
|
||||
@@ -719,6 +760,130 @@ class _Core extends \IPS\convert\Library
|
||||
* If the data is missing and it is required to convert the item, we should log a WARNING and return FALSE.
|
||||
* If the conversion absolutely cannot proceed at all (filestorage locations not writable, for example), then we should log an ERROR and throw an \IPS\convert\Exception to completely halt the process and redirect to an error screen showing the last logged error.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Convert a Badge
|
||||
*
|
||||
* @param array $info Data to insert
|
||||
* @param string|NULL $imagePath Path to image file, or NULL.
|
||||
* @param string|NULL $imageData Binary image data, or NULL.
|
||||
* @return bool|int The ID of the newly inserted badge, or FALSE on failure
|
||||
*/
|
||||
public function convertAchievementBadge( array $info=[], string $imagePath=NULL, string $imageData=NULL )
|
||||
{
|
||||
if ( !isset( $info['id'] ) )
|
||||
{
|
||||
$this->software->app->log( 'badge_missing_id', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( !isset( $info['title'] ) )
|
||||
{
|
||||
$this->software->app->log( 'badge_missing_title', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$name = $info['title'];
|
||||
unset( $info['title'] );
|
||||
}
|
||||
|
||||
if( !isset( $info['manually_awarded'] ) )
|
||||
{
|
||||
$info['manually_awarded'] = 0;
|
||||
}
|
||||
|
||||
if ( isset( $info['image'] ) AND ( !\is_null( $imagePath ) OR !\is_null( $imageData ) ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( \is_null( $imageData ) AND !\is_null( $imagePath ) )
|
||||
{
|
||||
$imageData = file_get_contents( $imagePath );
|
||||
}
|
||||
$file = \IPS\File::create( 'core_Badges', $info['image'], $imageData, NULL, FALSE, NULL, FALSE );
|
||||
$info['image'] = (string) $file;
|
||||
}
|
||||
catch( \ErrorException | \Exception $e )
|
||||
{
|
||||
$info['image'] = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['image'] = NULL;
|
||||
}
|
||||
|
||||
$oldId = $info['id'];
|
||||
unset( $info['id'] );
|
||||
$insertedId = \IPS\Db::i()->insert( 'core_badges', $info );
|
||||
$this->software->app->addLink( $insertedId, $oldId, 'core_achievement_badges' );
|
||||
\IPS\Lang::saveCustom( 'core', "core_badges_{$insertedId}", $name );
|
||||
|
||||
return $insertedId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an Achievement Rank
|
||||
*
|
||||
* @param array $info Data to insert
|
||||
* @param string|NULL $imagePath Path to image file, or NULL.
|
||||
* @param string|NULL $imageData Binary image data, or NULL.
|
||||
* @return bool|int The ID of the newly inserted badge, or FALSE on failure
|
||||
*/
|
||||
public function convertAchievementRank( array $info=[], string $imagePath=NULL, string $imageData=NULL )
|
||||
{
|
||||
/* We don't really need an ID for these, so if one isn't specified, then that's okay. */
|
||||
$hasId = TRUE;
|
||||
if ( !isset( $info['id'] ) )
|
||||
{
|
||||
$hasId = FALSE;
|
||||
$this->software->app->log( 'rank_missing_ids', __METHOD__, \IPS\convert\App::LOG_NOTICE );
|
||||
}
|
||||
|
||||
/* We do need this, though. */
|
||||
if ( !isset( $info['title'] ) )
|
||||
{
|
||||
$this->software->app->log( 'rank_missing_title', __METHOD__, \IPS\convert\App::LOG_NOTICE );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( isset( $info['icon'] ) AND ( !\is_null( $imagePath ) OR !\is_null( $imageData ) ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( \is_null( $imageData ) AND !\is_null( $imagePath ) )
|
||||
{
|
||||
$imageData = file_get_contents( $imagePath );
|
||||
}
|
||||
$file = \IPS\File::create( 'core_Badges', $info['icon'], $imageData, NULL, FALSE, NULL, FALSE );
|
||||
$info['icon'] = (string) $file;
|
||||
}
|
||||
catch( \ErrorException | \Exception $e )
|
||||
{
|
||||
$info['icon'] = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['icon'] = NULL;
|
||||
}
|
||||
|
||||
if ( $hasId )
|
||||
{
|
||||
$oldId = $info['id'];
|
||||
unset( $info['id'] );
|
||||
}
|
||||
|
||||
$insertedId = \IPS\Db::i()->insert( 'core_member_ranks', $info );
|
||||
if( $hasId )
|
||||
{
|
||||
$this->software->app->addLink( $insertedId, $oldId, 'core_achievement_ranks' );
|
||||
}
|
||||
\IPS\Lang::saveCustom( 'core', "core_member_rank_{$insertedId}", $info['title'] );
|
||||
|
||||
return $insertedId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an Acronym
|
||||
@@ -1233,7 +1398,7 @@ class _Core extends \IPS\convert\Library
|
||||
{
|
||||
\IPS\Db::i()->delete( 'core_attachments', array( "attach_id=?", $id ) );
|
||||
$this->software->app->log( 'attachment_missing_parent', __METHOD__, \IPS\convert\App::LOG_WARNING, $id );
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( isset( $map['id2'] ) )
|
||||
@@ -2436,6 +2601,9 @@ class _Core extends \IPS\convert\Library
|
||||
/**
|
||||
* Convert a Member Rank
|
||||
*
|
||||
* @deprecated
|
||||
* @todo - remove 4.7
|
||||
*
|
||||
* @param array $info Data to insert
|
||||
* @param string|NULL $iconpath Icon File Path, or NULL
|
||||
* @param string|NULL $icondata Icon File Data, or NULL
|
||||
@@ -2443,80 +2611,8 @@ class _Core extends \IPS\convert\Library
|
||||
*/
|
||||
public function convertRank( $info=array(), $iconpath=NULL, $icondata=NULL )
|
||||
{
|
||||
/* We don't really need an ID for these, so if one isn't specified, then that's okay. */
|
||||
$hasId = TRUE;
|
||||
if ( !isset( $info['id'] ) )
|
||||
{
|
||||
$hasId = FALSE;
|
||||
$this->software->app->log( 'rank_missing_ids', __METHOD__, \IPS\convert\App::LOG_NOTICE );
|
||||
}
|
||||
|
||||
/* We do need this, though. */
|
||||
if ( !isset( $info['title'] ) )
|
||||
{
|
||||
$this->software->app->log( 'rank_missing_title', __METHOD__, \IPS\convert\App::LOG_NOTICE );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( !isset( $info['posts'] ) )
|
||||
{
|
||||
$info['posts'] = 0;
|
||||
}
|
||||
|
||||
if ( !isset( $info['pips'] ) )
|
||||
{
|
||||
$info['pips'] = 0;
|
||||
}
|
||||
else if ( $info['pips'] > 100 )
|
||||
{
|
||||
/* set pips to 100, this is the max. value which we support */
|
||||
$info['pips'] = 100;
|
||||
}
|
||||
|
||||
if ( isset( $info['icon'] ) AND ( !\is_null( $iconpath ) OR !\is_null( $icondata ) ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( \is_null( $icondata ) AND !\is_null( $iconpath ) )
|
||||
{
|
||||
$icondata = file_get_contents( $iconpath );
|
||||
}
|
||||
$file = \IPS\File::create( 'core_Theme', $info['icon'], $icondata );
|
||||
$info['icon'] = (string) $file;
|
||||
$info['use_icon'] = 1;
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
$info['icon'] = '';
|
||||
$info['use_icon'] = 0;
|
||||
}
|
||||
catch( \ErrorException $e )
|
||||
{
|
||||
$info['icon'] = '';
|
||||
$info['use_icon'] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['icon'] = '';
|
||||
$info['use_icon'] = 0;
|
||||
}
|
||||
|
||||
if ( $hasId )
|
||||
{
|
||||
$id = $info['id'];
|
||||
unset( $info['id'] );
|
||||
}
|
||||
|
||||
$inserted_id = \IPS\Db::i()->insert( 'core_member_ranks', $info );
|
||||
\IPS\Lang::saveCustom( 'core', "core_member_rank_{$inserted_id}", $info['title'] );
|
||||
|
||||
if ( $hasId )
|
||||
{
|
||||
$this->software->app->addLink( $inserted_id, $id, 'core_member_ranks' );
|
||||
}
|
||||
|
||||
return $inserted_id;
|
||||
$this->software->app->log( 'method_deprecated', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2752,7 +2848,7 @@ class _Core extends \IPS\convert\Library
|
||||
if ( !isset( $info['email'] ) OR !$info['email'] OR filter_var( $info['email'], FILTER_VALIDATE_EMAIL ) === FALSE )
|
||||
{
|
||||
/* No email, or it is invalid */
|
||||
$newEmail = time() . '@example.com';
|
||||
$newEmail = microtime( TRUE ) . '@example.com';
|
||||
$this->software->app->log( sprintf( \IPS\Member::loggedIn()->language()->get( 'member_email_invalid' ), $info['email'], $newEmail ), __METHOD__, \IPS\convert\App::LOG_NOTICE, $info['member_id'] );
|
||||
$info['email'] = $newEmail;
|
||||
}
|
||||
@@ -3384,22 +3480,6 @@ class _Core extends \IPS\convert\Library
|
||||
$info['marked_site_read'] = time();
|
||||
$info['acp_language'] = \IPS\Lang::defaultLanguage();
|
||||
|
||||
if ( !isset( $info['member_title'] ) )
|
||||
{
|
||||
$info['member_title'] = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['member_title'] = strip_tags( $info['member_title'] );
|
||||
}
|
||||
|
||||
/* Check length of supplied title */
|
||||
if( $info['member_title'] AND ( mb_strlen( $info['member_title'] ) > 64 ) )
|
||||
{
|
||||
$this->software->app->log( 'members_title_truncated', __METHOD__, \IPS\convert\App::LOG_NOTICE, $info['member_id'] );
|
||||
$info['member_title'] = mb_substr( $info['member_title'], 0, 64 );
|
||||
}
|
||||
|
||||
if ( !isset( $info['member_posts'] ) )
|
||||
{
|
||||
$info['member_posts'] = 0;
|
||||
@@ -3505,7 +3585,8 @@ class _Core extends \IPS\convert\Library
|
||||
break;
|
||||
case 'secondary':
|
||||
$groups = array();
|
||||
foreach ( explode( ',', $info['log_data']['old'] ) as $groupId )
|
||||
$groupData = \is_array( $info['log_data']['old'] ) ? $info['log_data']['old'] : explode( ',', $info['log_data']['old'] );
|
||||
foreach ( $groupData as $groupId )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -3516,7 +3597,8 @@ class _Core extends \IPS\convert\Library
|
||||
|
||||
$info['log_data']['old'] = implode( ',', array_unique( $groups ) );
|
||||
$groups = array();
|
||||
foreach ( explode( ',', $info['log_data']['new'] ) as $groupId )
|
||||
$newGroupData = \is_array( $info['log_data']['new'] ) ? $info['log_data']['new'] : explode( ',', $info['log_data']['new'] );
|
||||
foreach ( $newGroupData as $groupId )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user