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,36 @@
|
||||
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 IPS\Content\Search\Index;
|
||||
use IPS\convert\Exception;
|
||||
use IPS\convert\Software;
|
||||
use IPS\Data\Cache;
|
||||
use IPS\Data\Store;
|
||||
use IPS\Db;
|
||||
use IPS\Login;
|
||||
use IPS\Member;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use IPS\Task;
|
||||
use OutOfRangeException;
|
||||
use UnderflowException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
use const ENT_HTML5;
|
||||
use const ENT_QUOTES;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Woltlab Suite Core Converter
|
||||
*/
|
||||
class _Woltlab extends \IPS\convert\Software
|
||||
class Woltlab extends Software
|
||||
{
|
||||
/**
|
||||
* @brief The WCF table prefix can change depending on the number of installs
|
||||
@@ -100,7 +120,7 @@ class _Woltlab extends \IPS\convert\Software
|
||||
* @param array|NULL $where WHERE clause to only count specific rows, or NULL to count all.
|
||||
* @param bool $recache Skip cache and pull directly (updating cache)
|
||||
* @return integer
|
||||
* @throws \IPS\convert\Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public function countRows( $table, $where=NULL, $recache=FALSE )
|
||||
{
|
||||
@@ -114,7 +134,7 @@ class _Woltlab extends \IPS\convert\Software
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
throw new \IPS\convert\Exception( sprintf( \IPS\Member::loggedIn()->language()->get( 'could_not_count_rows' ), $table ) );
|
||||
throw new Exception( sprintf( Member::loggedIn()->language()->get( 'could_not_count_rows' ), $table ) );
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -164,16 +184,16 @@ class _Woltlab extends \IPS\convert\Software
|
||||
case 'convertProfileFieldGroups':
|
||||
$return['convertProfileFieldGroups'] = array();
|
||||
$options = array();
|
||||
$options['none'] = \IPS\Member::loggedIn()->language()->addToStack( 'none' );
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_pfields_groups' ), 'IPS\core\ProfileFields\Group' ) AS $group )
|
||||
$options['none'] = Member::loggedIn()->language()->addToStack( 'none' );
|
||||
foreach( new ActiveRecordIterator( Db::i()->select( '*', 'core_pfields_groups' ), 'IPS\core\ProfileFields\Group' ) AS $group )
|
||||
{
|
||||
$options[ $group->_id ] = $group->_title;
|
||||
}
|
||||
|
||||
foreach( $this->db->select( '*', 'wcf' . static::$installId . '_user_option_category', array( 'parentCategoryName=?', 'profile' ) ) AS $group )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words["map_pfgroup_{$group['categoryID']}"] = $this->getLanguage( $group['categoryName'], 'wcf.user.option.category' );
|
||||
\IPS\Member::loggedIn()->language()->words["map_pfgroup_{$group['categoryID']}_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'map_pfgroup_desc' );
|
||||
Member::loggedIn()->language()->words["map_pfgroup_{$group['categoryID']}"] = $this->getLanguage( $group['categoryName'], 'wcf.user.option.category' );
|
||||
Member::loggedIn()->language()->words["map_pfgroup_{$group['categoryID']}_desc"] = Member::loggedIn()->language()->addToStack( 'map_pfgroup_desc' );
|
||||
|
||||
$return['convertProfileFieldGroups']["map_pfgroup_{$group['categoryID']}"] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Select',
|
||||
@@ -189,8 +209,8 @@ class _Woltlab 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;
|
||||
}
|
||||
@@ -198,8 +218,8 @@ class _Woltlab extends \IPS\convert\Software
|
||||
$where = array( "categoryName LIKE 'profile.%' OR " . $this->db->in( 'categoryName', iterator_to_array( $this->db->select( 'categoryName', static::canConvert()['convertProfileFieldGroups']['table'], static::canConvert()['convertProfileFieldGroups']['where'] ) ) ) );
|
||||
foreach( $this->db->select( '*', 'wcf' . static::$installId . '_user_option', $where ) AS $field )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words["map_pfield_{$field['optionID']}"] = $this->getLanguage( $field['optionName'], 'wcf.user.option' );
|
||||
\IPS\Member::loggedIn()->language()->words["map_pfield_{$field['optionID']}_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'map_pfield_desc' );
|
||||
Member::loggedIn()->language()->words["map_pfield_{$field['optionID']}"] = $this->getLanguage( $field['optionName'], 'wcf.user.option' );
|
||||
Member::loggedIn()->language()->words["map_pfield_{$field['optionID']}_desc"] = Member::loggedIn()->language()->addToStack( 'map_pfield_desc' );
|
||||
|
||||
$return['convertProfileFields']["map_pfield_{$field['optionID']}"] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Select',
|
||||
@@ -212,7 +232,7 @@ class _Woltlab extends \IPS\convert\Software
|
||||
break;
|
||||
|
||||
case 'convertEmoticons':
|
||||
\IPS\Member::loggedIn()->language()->words['emoticon_path'] = \IPS\Member::loggedIn()->language()->addToStack( 'source_path', FALSE, array( 'sprintf' => array( 'Woltlab' ) ) );
|
||||
Member::loggedIn()->language()->words['emoticon_path'] = Member::loggedIn()->language()->addToStack( 'source_path', FALSE, array( 'sprintf' => array( 'Woltlab' ) ) );
|
||||
$return['convertEmoticons'] = array(
|
||||
'emoticon_path' => array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Text',
|
||||
@@ -220,7 +240,7 @@ class _Woltlab extends \IPS\convert\Software
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(),
|
||||
'field_hint' => NULL,
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new DomainException( 'path_invalid' ); } },
|
||||
),
|
||||
'keep_existing_emoticons' => array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Checkbox',
|
||||
@@ -236,16 +256,16 @@ class _Woltlab extends \IPS\convert\Software
|
||||
$return['convertGroups'] = array();
|
||||
|
||||
$options = array();
|
||||
$options['none'] = \IPS\Member::loggedIn()->language()->addToStack( 'none' );
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_groups' ), 'IPS\Member\Group' ) AS $group )
|
||||
$options['none'] = Member::loggedIn()->language()->addToStack( 'none' );
|
||||
foreach( new ActiveRecordIterator( Db::i()->select( '*', 'core_groups' ), 'IPS\Member\Group' ) AS $group )
|
||||
{
|
||||
$options[ $group->g_id ] = $group->name;
|
||||
}
|
||||
|
||||
foreach( $this->db->select( '*', 'wcf' . static::$installId . '_user_group' ) AS $group )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words["map_group_{$group['groupID']}"] = $this->getLanguage( $group['groupName'] );
|
||||
\IPS\Member::loggedIn()->language()->words["map_group_{$group['groupID']}_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'map_group_desc' );
|
||||
Member::loggedIn()->language()->words["map_group_{$group['groupID']}"] = $this->getLanguage( $group['groupName'] );
|
||||
Member::loggedIn()->language()->words["map_group_{$group['groupID']}_desc"] = Member::loggedIn()->language()->addToStack( 'map_group_desc' );
|
||||
|
||||
$return['convertGroups']["map_group_{$group['groupID']}"] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Select',
|
||||
@@ -261,39 +281,39 @@ class _Woltlab extends \IPS\convert\Software
|
||||
$return['convertMembers'] = array();
|
||||
|
||||
/* Find out where the photos live */
|
||||
\IPS\Member::loggedIn()->language()->words['photo_location'] = \IPS\Member::loggedIn()->language()->addToStack( 'convert_woltlab_avatar' );
|
||||
\IPS\Member::loggedIn()->language()->words['photo_location_desc'] = \IPS\Member::loggedIn()->language()->addToStack( 'convert_woltlab_avatar_desc' );
|
||||
Member::loggedIn()->language()->words['photo_location'] = Member::loggedIn()->language()->addToStack( 'convert_woltlab_avatar' );
|
||||
Member::loggedIn()->language()->words['photo_location_desc'] = Member::loggedIn()->language()->addToStack( 'convert_woltlab_avatar_desc' );
|
||||
$return['convertMembers']['photo_location'] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Text',
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(),
|
||||
'field_hint' => NULL,
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new DomainException( 'path_invalid' ); } },
|
||||
);
|
||||
\IPS\Member::loggedIn()->language()->words['coverphoto_location'] = \IPS\Member::loggedIn()->language()->addToStack( 'convert_woltlab_cover' );
|
||||
\IPS\Member::loggedIn()->language()->words['coverphoto_location_desc'] = \IPS\Member::loggedIn()->language()->addToStack( 'convert_woltlab_cover_desc' );
|
||||
Member::loggedIn()->language()->words['coverphoto_location'] = Member::loggedIn()->language()->addToStack( 'convert_woltlab_cover' );
|
||||
Member::loggedIn()->language()->words['coverphoto_location_desc'] = Member::loggedIn()->language()->addToStack( 'convert_woltlab_cover_desc' );
|
||||
$return['convertMembers']['coverphoto_location'] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Text',
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(),
|
||||
'field_hint' => NULL,
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new DomainException( 'path_invalid' ); } },
|
||||
);
|
||||
|
||||
foreach( [ 'usertitle' ] AS $field )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words["field_{$field}"] = \IPS\Member::loggedIn()->language()->addToStack( 'pseudo_field', FALSE, [ '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, [ 'sprintf' => $field ] );
|
||||
Member::loggedIn()->language()->words["field_{$field}_desc"] = Member::loggedIn()->language()->addToStack( 'pseudo_field_desc' );
|
||||
$return['convertMembers']["field_{$field}"] = [
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Radio',
|
||||
'field_default' => 'no_convert',
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => [
|
||||
'options' => [
|
||||
'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'
|
||||
],
|
||||
@@ -314,38 +334,40 @@ class _Woltlab 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_announcements', 'extension' => 'core_Announcement' ), 2, array( 'app', 'link', 'extension' ) );
|
||||
\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_announcements', 'extension' => 'core_Announcement' ), 2, array( 'app', 'link', 'extension' ) );
|
||||
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' ) );
|
||||
\IPS\Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\core\Messenger\Message' ), 3, array( 'class' ) );
|
||||
Task::queue( 'core', 'RecountMemberContent', array( 'app' => $this->app->app_id ), 4, array( 'app' ) );
|
||||
Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\core\Messenger\Message' ), 3, array( 'class' ) );
|
||||
|
||||
/* 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" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix Post Data
|
||||
* Pre-process content for the Invision Community text parser
|
||||
*
|
||||
* @param string $post Post
|
||||
* @return string Fixed Post
|
||||
* @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 $post;
|
||||
}
|
||||
@@ -390,7 +412,7 @@ class _Woltlab extends \IPS\convert\Software
|
||||
foreach ( $this->fetch( 'wcf' . static::$installId . '_user_option', 'optionID', $where ) AS $field )
|
||||
{
|
||||
/* Birthday is special */
|
||||
if( \in_array( $field['optionName'], ['birthday', 'birthdayShowYear'] ) )
|
||||
if( in_array( $field['optionName'], ['birthday', 'birthdayShowYear'] ) )
|
||||
{
|
||||
$libraryClass->setLastKeyValue( $field['optionID'] );
|
||||
continue;
|
||||
@@ -529,7 +551,7 @@ class _Woltlab extends \IPS\convert\Software
|
||||
}
|
||||
|
||||
/* Now check for group promotions */
|
||||
if( \count( $libraryClass->groupPromotions ) )
|
||||
if( count( $libraryClass->groupPromotions ) )
|
||||
{
|
||||
foreach( $libraryClass->groupPromotions as $groupPromotion )
|
||||
{
|
||||
@@ -583,7 +605,7 @@ class _Woltlab extends \IPS\convert\Software
|
||||
|
||||
$info = array(
|
||||
'member_id' => $row['userID'],
|
||||
'name' => html_entity_decode( $row['username'], \ENT_QUOTES | \ENT_HTML5, 'UTF-8' ),
|
||||
'name' => html_entity_decode( $row['username'], ENT_QUOTES | ENT_HTML5, 'UTF-8' ),
|
||||
'email' => $row['email'],
|
||||
'password' => $row['password'],
|
||||
'member_group_id' => $row['userOnlineGroupID'],
|
||||
@@ -612,7 +634,7 @@ class _Woltlab extends \IPS\convert\Software
|
||||
$filename = $row['avatarID'] . '-' . $avatar['fileHash'] . '.' . $avatar['avatarExtension'];
|
||||
$filepath = rtrim( $this->app->_session['more_info']['convertMembers']['photo_location'], '/' ) . '/' . mb_substr( $avatar['fileHash'], 0, 2 );
|
||||
}
|
||||
catch( \UnderflowException $e ) {}
|
||||
catch( UnderflowException $e ) {}
|
||||
}
|
||||
|
||||
/* Cover Photo */
|
||||
@@ -645,7 +667,7 @@ class _Woltlab 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( [
|
||||
'pf_id' => $pseudo,
|
||||
@@ -663,7 +685,7 @@ class _Woltlab extends \IPS\convert\Software
|
||||
|
||||
if( $pseudo == 'usertitle' )
|
||||
{
|
||||
$profileFields[ $pseudo ] = \in_array( $row['userTitle'], $userTitles ) OR empty( $row['userTitle'] ) ? NULL : $row['userTitle'];
|
||||
$profileFields[ $pseudo ] = in_array( $row['userTitle'], $userTitles ) OR empty( $row['userTitle'] ) ? NULL : $row['userTitle'];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -798,7 +820,7 @@ class _Woltlab extends \IPS\convert\Software
|
||||
* @param string $itemName WCF Language Name
|
||||
* @param string $itemPrefix WCF Prefix for end-user input
|
||||
* @return string Translated string, or original if no customisation exists
|
||||
* @throws \UnderflowException
|
||||
* @throws UnderflowException
|
||||
*/
|
||||
protected function getLanguage( string $itemName, string $itemPrefix=NULL ): string
|
||||
{
|
||||
@@ -811,13 +833,13 @@ class _Woltlab extends \IPS\convert\Software
|
||||
{
|
||||
return $this->db->select( 'languageItemValue', 'wcf' . static::$installId . '_language_item', array( "languageID=? AND languageItem=?", static::$_defaultLanguage, $itemName ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
try
|
||||
{
|
||||
return $this->db->select( 'languageItemValue', 'wcf' . static::$installId . '_language_item', array( "languageID=? AND languageItem=?", static::$_defaultLanguage, $itemPrefix . '.' . $itemName ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e ) { }
|
||||
catch( UnderflowException $e ) { }
|
||||
|
||||
return $itemName;
|
||||
}
|
||||
@@ -826,7 +848,7 @@ class _Woltlab 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
|
||||
*/
|
||||
@@ -838,7 +860,7 @@ class _Woltlab extends \IPS\convert\Software
|
||||
$salt = mb_substr( $member->conv_password, 0, 29 );
|
||||
$test = crypt( crypt( $password, $salt ), $salt );
|
||||
|
||||
return \IPS\Login::compareHashes( $member->conv_password, $test );
|
||||
return Login::compareHashes( $member->conv_password, $test );
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
||||
Reference in new issue
Block a user