Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -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'];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user