Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -12,16 +12,39 @@
|
||||
namespace IPS\convert\Software\Core;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DomainException;
|
||||
use Exception;
|
||||
use IPS\Application\Module;
|
||||
use IPS\Content\Search\Index;
|
||||
use IPS\convert\Software;
|
||||
use IPS\Data\Cache;
|
||||
use IPS\Data\Store;
|
||||
use IPS\Db;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Login;
|
||||
use IPS\Member;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use IPS\Request;
|
||||
use IPS\Task;
|
||||
use OutOfRangeException;
|
||||
use UnderflowException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
use function strlen;
|
||||
use function strtolower;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* ExpressionEngine Core Converter
|
||||
*/
|
||||
class _Expressionengine extends \IPS\convert\Software
|
||||
class Expressionengine extends Software
|
||||
{
|
||||
/**
|
||||
* Software Name
|
||||
@@ -94,7 +117,7 @@ class _Expressionengine extends \IPS\convert\Software
|
||||
$rows['convertPmAttachments'] = array(
|
||||
'step_method' => 'convertPmAttachments',
|
||||
'step_title' => 'convert_attachments',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'core_attachments' ),
|
||||
'ips_rows' => Db::i()->select( 'COUNT(*)', 'core_attachments' ),
|
||||
'source_rows' => array( 'table' => static::canConvert()['convertPmAttachments']['table'], 'where' => static::canConvert()['convertPmAttachments']['where'] ),
|
||||
'per_cycle' => 10,
|
||||
'dependencies' => array( 'convertPrivateMessageReplies' ),
|
||||
@@ -141,12 +164,14 @@ class _Expressionengine extends \IPS\convert\Software
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix post data
|
||||
* Pre-process content for the Invision Community text parser
|
||||
*
|
||||
* @param string $post Raw post data
|
||||
* @return string Parsed post data
|
||||
* @param string The post
|
||||
* @param string|null Content Classname passed by post-conversion rebuild
|
||||
* @param int|null Content ID passed by post-conversion rebuild
|
||||
* @return string The converted post
|
||||
*/
|
||||
public static function fixPostData( $post )
|
||||
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
|
||||
{
|
||||
return nl2br( $post );
|
||||
}
|
||||
@@ -170,8 +195,8 @@ class _Expressionengine extends \IPS\convert\Software
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(),
|
||||
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack('convert_ee_sig_attach_path'),
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
|
||||
'field_hint' => Member::loggedIn()->language()->addToStack('convert_ee_sig_attach_path'),
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new DomainException( 'path_invalid' ); } },
|
||||
)
|
||||
);
|
||||
break;
|
||||
@@ -179,16 +204,16 @@ class _Expressionengine extends \IPS\convert\Software
|
||||
$return['convertProfileFields'] = array();
|
||||
|
||||
$options = array();
|
||||
$options['none'] = \IPS\Member::loggedIn()->language()->addToStack( 'none' );
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_pfields_data' ), 'IPS\core\ProfileFields\Field' ) AS $field )
|
||||
$options['none'] = Member::loggedIn()->language()->addToStack( 'none' );
|
||||
foreach( new ActiveRecordIterator( Db::i()->select( '*', 'core_pfields_data' ), 'IPS\core\ProfileFields\Field' ) AS $field )
|
||||
{
|
||||
$options[$field->_id] = $field->_title;
|
||||
}
|
||||
|
||||
foreach( $this->db->select( '*', 'exp_member_fields' ) AS $field )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words["map_pfield_{$field['m_field_id']}"] = $field['m_field_label'];
|
||||
\IPS\Member::loggedIn()->language()->words["map_pfield_{$field['m_field_id']}_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'map_pfield_desc' );
|
||||
Member::loggedIn()->language()->words["map_pfield_{$field['m_field_id']}"] = $field['m_field_label'];
|
||||
Member::loggedIn()->language()->words["map_pfield_{$field['m_field_id']}_desc"] = Member::loggedIn()->language()->addToStack( 'map_pfield_desc' );
|
||||
|
||||
$return['convertProfileFields']["map_pfield_{$field['m_field_id']}"] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Select',
|
||||
@@ -205,15 +230,15 @@ class _Expressionengine extends \IPS\convert\Software
|
||||
|
||||
$options = array();
|
||||
$options['none'] = 'None';
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_groups' ), 'IPS\Member\Group' ) AS $group )
|
||||
foreach( new ActiveRecordIterator( Db::i()->select( '*', 'core_groups' ), 'IPS\Member\Group' ) AS $group )
|
||||
{
|
||||
$options[$group->g_id] = $group->name;
|
||||
}
|
||||
|
||||
foreach( $this->db->select( '*', 'exp_member_groups' ) AS $group )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words["map_group_{$group['group_id']}"] = $group['group_title'];
|
||||
\IPS\Member::loggedIn()->language()->words["map_group_{$group['group_id']}_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'map_group_desc' );
|
||||
Member::loggedIn()->language()->words["map_group_{$group['group_id']}"] = $group['group_title'];
|
||||
Member::loggedIn()->language()->words["map_group_{$group['group_id']}_desc"] = Member::loggedIn()->language()->addToStack( 'map_group_desc' );
|
||||
|
||||
$return['convertGroups']["map_group_{$group['group_id']}"] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Select',
|
||||
@@ -232,33 +257,33 @@ class _Expressionengine extends \IPS\convert\Software
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Radio',
|
||||
'field_default' => 'avatars',
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array( 'options' => array( 'avatars' => \IPS\Member::loggedIn()->language()->addToStack( 'avatars' ), 'profile_photos' => \IPS\Member::loggedIn()->language()->addToStack( 'profile_photos' ) ) ),
|
||||
'field_extra' => array( 'options' => array( 'avatars' => Member::loggedIn()->language()->addToStack( 'avatars' ), 'profile_photos' => Member::loggedIn()->language()->addToStack( 'profile_photos' ) ) ),
|
||||
'field_hint' => NULL,
|
||||
);
|
||||
|
||||
/* Find out where the photos live */
|
||||
\IPS\Member::loggedIn()->language()->words['photo_location_desc'] = \IPS\Member::loggedIn()->language()->addToStack( 'photo_location_nodb_desc' );
|
||||
Member::loggedIn()->language()->words['photo_location_desc'] = Member::loggedIn()->language()->addToStack( 'photo_location_nodb_desc' );
|
||||
$return['convertMembers']['photo_location'] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Text',
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(),
|
||||
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack('convert_ee_avatar_path'),
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
|
||||
'field_hint' => Member::loggedIn()->language()->addToStack('convert_ee_avatar_path'),
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new DomainException( 'path_invalid' ); } },
|
||||
);
|
||||
|
||||
foreach( array( 'url', 'location', 'occupation', 'bio' ) AS $field )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words["field_{$field}"] = \IPS\Member::loggedIn()->language()->addToStack( 'pseudo_field', FALSE, array( 'sprintf' => $field ) );
|
||||
\IPS\Member::loggedIn()->language()->words["field_{$field}_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'pseudo_field_desc' );
|
||||
Member::loggedIn()->language()->words["field_{$field}"] = Member::loggedIn()->language()->addToStack( 'pseudo_field', FALSE, array( 'sprintf' => $field ) );
|
||||
Member::loggedIn()->language()->words["field_{$field}_desc"] = Member::loggedIn()->language()->addToStack( 'pseudo_field_desc' );
|
||||
$return['convertMembers']["field_{$field}"] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Radio',
|
||||
'field_default' => 'no_convert',
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(
|
||||
'options' => array(
|
||||
'no_convert' => \IPS\Member::loggedIn()->language()->addToStack( 'no_convert' ),
|
||||
'create_field' => \IPS\Member::loggedIn()->language()->addToStack( 'create_field' ),
|
||||
'no_convert' => Member::loggedIn()->language()->addToStack( 'no_convert' ),
|
||||
'create_field' => Member::loggedIn()->language()->addToStack( 'create_field' ),
|
||||
),
|
||||
'userSuppliedInput' => 'create_field'
|
||||
),
|
||||
@@ -273,8 +298,8 @@ class _Expressionengine extends \IPS\convert\Software
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(),
|
||||
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack('convert_ee_pm_attach_path'),
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
|
||||
'field_hint' => Member::loggedIn()->language()->addToStack('convert_ee_pm_attach_path'),
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new DomainException( 'path_invalid' ); } },
|
||||
)
|
||||
);
|
||||
break;
|
||||
@@ -291,25 +316,25 @@ class _Expressionengine extends \IPS\convert\Software
|
||||
public function finish()
|
||||
{
|
||||
/* Search Index Rebuild */
|
||||
\IPS\Content\Search\Index::i()->rebuild();
|
||||
Index::i()->rebuild();
|
||||
|
||||
/* Clear Cache and Store */
|
||||
\IPS\Data\Store::i()->clearAll();
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
Store::i()->clearAll();
|
||||
Cache::i()->clearAll();
|
||||
|
||||
/* Non-Content Rebuilds */
|
||||
\IPS\Task::queue( 'convert', 'RebuildProfilePhotos', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
|
||||
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_message_posts', 'extension' => 'core_Messaging' ), 2, array( 'app', 'link', 'extension' ) );
|
||||
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_members', 'extension' => 'core_Signatures' ), 2, array( 'app', 'link', 'extension' ) );
|
||||
Task::queue( 'convert', 'RebuildProfilePhotos', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
|
||||
Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_message_posts', 'extension' => 'core_Messaging' ), 2, array( 'app', 'link', 'extension' ) );
|
||||
Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_members', 'extension' => 'core_Signatures' ), 2, array( 'app', 'link', 'extension' ) );
|
||||
|
||||
/* Content Counts */
|
||||
\IPS\Task::queue( 'core', 'RecountMemberContent', array( 'app' => $this->app->app_id ), 4, array( 'app' ) );
|
||||
Task::queue( 'core', 'RecountMemberContent', array( 'app' => $this->app->app_id ), 4, array( 'app' ) );
|
||||
|
||||
/* First Post Data */
|
||||
\IPS\Task::queue( 'convert', 'RebuildConversationFirstIds', array( 'app' => $this->app->app_id ), 2, array( 'app' ) );
|
||||
Task::queue( 'convert', 'RebuildConversationFirstIds', array( 'app' => $this->app->app_id ), 2, array( 'app' ) );
|
||||
|
||||
/* Attachments */
|
||||
\IPS\Task::queue( 'core', 'RebuildAttachmentThumbnails', array( 'app' => $this->app->app_id ), 1, array( 'app' ) );
|
||||
Task::queue( 'core', 'RebuildAttachmentThumbnails', array( 'app' => $this->app->app_id ), 1, array( 'app' ) );
|
||||
|
||||
return array( "f_search_index_rebuild", "f_clear_caches", "f_rebuild_pms", "f_signatures_rebuild", "f_rebuild_attachments" );
|
||||
}
|
||||
@@ -357,15 +382,15 @@ class _Expressionengine extends \IPS\convert\Software
|
||||
{
|
||||
$memberId = $this->app->getLink( $row['member_id'], 'core_members' );
|
||||
|
||||
$signature = \IPS\Db::i()->select( 'signature', 'core_members', array( "member_id=?", $memberId ) )->first();
|
||||
$signature = Db::i()->select( 'signature', 'core_members', array( "member_id=?", $memberId ) )->first();
|
||||
|
||||
$signature .= '[attachment=' . $attachId . ':name]';
|
||||
|
||||
\IPS\Db::i()->update( 'core_members', array( 'signature' => $signature ), array( "member_id=?", $memberId ) );
|
||||
Db::i()->update( 'core_members', array( 'signature' => $signature ), array( "member_id=?", $memberId ) );
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException $e ) {}
|
||||
catch( \OutOfRangeException $e ) {}
|
||||
catch( UnderflowException $e ) {}
|
||||
catch( OutOfRangeException $e ) {}
|
||||
|
||||
$libraryClass->setLastKeyValue( $row['member_id'] );
|
||||
}
|
||||
@@ -388,11 +413,11 @@ class _Expressionengine extends \IPS\convert\Software
|
||||
$info['pf_type'] = ucwords( $row['m_field_type'] );
|
||||
$info['pf_name'] = $row['m_field_label'];
|
||||
$info['pf_desc'] = $row['m_field_description'];
|
||||
$info['pf_content'] = ( !\in_array( $row['m_field_type'], array( 'textbox', 'textarea' ) ) ) ? explode( "\r", $row['field_choices'] ) : NULL;
|
||||
$info['pf_content'] = ( !in_array( $row['m_field_type'], array( 'textbox', 'textarea' ) ) ) ? explode( "\r", $row['field_choices'] ) : NULL;
|
||||
$info['pf_not_null'] = $row['m_field_required'] == 'y' ? 1 : 0;
|
||||
$info['pf_member_hide'] = $row['m_field_public'] == 'n' ? 'hide' : 'all';
|
||||
$info['pf_max_input'] = $row['m_field_maxl'];
|
||||
$info['pf_member_edit'] = ( \in_array( $row['user_editable'], array( 'yes', 'once' ) ) ) ? 0 : 1;
|
||||
$info['pf_member_edit'] = ( in_array( $row['user_editable'], array( 'yes', 'once' ) ) ) ? 0 : 1;
|
||||
$info['pf_position'] = $row['m_field_order'];
|
||||
$info['pf_show_on_reg'] = $row['m_field_reg'] == 'y' ? 1 : 0;
|
||||
$info['pf_input_format'] = NULL;
|
||||
@@ -434,7 +459,7 @@ class _Expressionengine extends \IPS\convert\Software
|
||||
}
|
||||
|
||||
/* Now check for group promotions */
|
||||
if( \count( $libraryClass->groupPromotions ) )
|
||||
if( count( $libraryClass->groupPromotions ) )
|
||||
{
|
||||
foreach( $libraryClass->groupPromotions as $groupPromotion )
|
||||
{
|
||||
@@ -495,7 +520,7 @@ class _Expressionengine extends \IPS\convert\Software
|
||||
$profileFields[ str_replace( 'm_field_id_', '', $key ) ] = $value;
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
$profileFields = array();
|
||||
}
|
||||
@@ -515,7 +540,7 @@ class _Expressionengine extends \IPS\convert\Software
|
||||
/* We don't actually need this, but we need to make sure the field was created */
|
||||
$fieldId = $this->app->getLink( $pseudo, 'core_pfields_data' );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$libraryClass->convertProfileField( array(
|
||||
'pf_id' => $pseudo,
|
||||
@@ -661,7 +686,7 @@ class _Expressionengine extends \IPS\convert\Software
|
||||
'attach_file' => $row['attachment_name'],
|
||||
'attach_date' => $row['attachment_date'],
|
||||
'attach_member_id' => $row['sender_id'],
|
||||
'attach_ext' => \strtolower( trim( $row['attachment_extension'], '.' ) ),
|
||||
'attach_ext' => strtolower( trim( $row['attachment_extension'], '.' ) ),
|
||||
'attach_filesize' => ( $row['attachment_size'] * 1000 ), //convert to kb
|
||||
);
|
||||
|
||||
@@ -676,15 +701,15 @@ class _Expressionengine extends \IPS\convert\Software
|
||||
{
|
||||
$pmId = $this->app->getLink( $row['message_id'], 'core_message_posts' );
|
||||
|
||||
$message = \IPS\Db::i()->select( 'msg_post', 'core_message_posts', array( "msg_id=?", $pmId ) )->first();
|
||||
$message = Db::i()->select( 'msg_post', 'core_message_posts', array( "msg_id=?", $pmId ) )->first();
|
||||
|
||||
$message .= '[attachment=' . $attachId . ':name]';
|
||||
|
||||
\IPS\Db::i()->update( 'core_message_posts', array( 'msg_post' => $message ), array( "msg_id=?", $pmId ) );
|
||||
Db::i()->update( 'core_message_posts', array( 'msg_post' => $message ), array( "msg_id=?", $pmId ) );
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException $e ) {}
|
||||
catch( \OutOfRangeException $e ) {}
|
||||
catch( UnderflowException $e ) {}
|
||||
catch( OutOfRangeException $e ) {}
|
||||
|
||||
$libraryClass->setLastKeyValue( $row['attachment_id'] );
|
||||
}
|
||||
@@ -693,26 +718,26 @@ class _Expressionengine extends \IPS\convert\Software
|
||||
/**
|
||||
* Check if we can redirect the legacy URLs from this software to the new locations
|
||||
*
|
||||
* @return NULL|\IPS\Http\Url
|
||||
* @return NULL|Url
|
||||
*/
|
||||
public function checkRedirects()
|
||||
{
|
||||
/* If we can't access profiles, don't bother trying to redirect */
|
||||
if( !\IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'members' ) ) )
|
||||
if( !Member::loggedIn()->canAccessModule( Module::get( 'core', 'members' ) ) )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$url = \IPS\Request::i()->url();
|
||||
$url = Request::i()->url();
|
||||
|
||||
if( preg_match( '#/member/([0-9]+)#i', $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
|
||||
if( preg_match( '#/member/([0-9]+)#i', $url->data[ Url::COMPONENT_PATH ], $matches ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$data = (string) $this->app->getLink( (int) $matches[1], array( 'members', 'core_members' ) );
|
||||
return \IPS\Member::load( $data )->url();
|
||||
return Member::load( $data )->url();
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -724,13 +749,13 @@ class _Expressionengine extends \IPS\convert\Software
|
||||
/**
|
||||
* Process a login
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param Member $member The member
|
||||
* @param string $password Password from form
|
||||
* @return bool
|
||||
*/
|
||||
public static function login( $member, $password )
|
||||
{
|
||||
$length = \strlen( $member->conv_password );
|
||||
$length = strlen( $member->conv_password );
|
||||
$providedHash = FALSE;
|
||||
|
||||
switch( $length )
|
||||
@@ -753,6 +778,6 @@ class _Expressionengine extends \IPS\convert\Software
|
||||
break;
|
||||
}
|
||||
|
||||
return ( \IPS\Login::compareHashes( $member->conv_password, $providedHash ) ) ? TRUE : FALSE;
|
||||
return ( Login::compareHashes( $member->conv_password, $providedHash ) ) ? TRUE : FALSE;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user