Version 5.0.0 beta 4

This commit is contained in:
Neo committed 2025-12-19 16:57:00 -08:00
1 parent e86153356a
commit 2f24f9de48
276 files changed
+8614 -6044

No files matched your search

@@ -14,10 +14,7 @@ namespace IPS\convert\Software\Core;
use DateTimeZone;
use erusev\Parsedown;
use Exception;
use InvalidArgumentException;
use IPS\Content\Search\Index;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\Data\Cache;
use IPS\Data\Store;
@@ -51,9 +48,9 @@ class Vanilla extends Software
/**
* Software Name
*
* @return string
* @return string
*/
public static function softwareName()
public static function softwareName(): string
{
/* Child classes must override this method */
return "Vanilla (3.x)";
@@ -62,9 +59,9 @@ class Vanilla extends Software
/**
* Software Key
*
* @return string
* @return string
*/
public static function softwareKey()
public static function softwareKey(): string
{
/* Child classes must override this method */
return "vanilla";
@@ -73,9 +70,9 @@ class Vanilla extends Software
/**
* Can we convert settings?
*
* @return boolean
* @return boolean
*/
public static function canConvertSettings()
public static function canConvertSettings(): bool
{
return TRUE;
}
@@ -83,9 +80,9 @@ class Vanilla extends Software
/**
* Settings Map Listing
*
* @return array
* @return array
*/
public function settingsMapList()
public function settingsMapList(): array
{
$settings = array(
'fluid' => array( 'title' => Member::loggedIn()->language()->addToStack( 'use_fluid_view_convert' ), 'value' => true, 'our_key' => 'use_fluid_view_convert', 'our_title' => Member::loggedIn()->language()->addToStack( 'use_fluid_view_convert' ) )
@@ -100,9 +97,9 @@ class Vanilla extends Software
* @param array $settings Settings to convert
* @return void
*/
public function convertSettings( $settings=array() )
public function convertSettings( array $settings=array() ) : void
{
if ( !isset( $settings['use_fluid_view_convert'] ) OR $settings['use_fluid_view_convert'] == FALSE )
if ( !isset( $settings['use_fluid_view_convert'] ) OR !$settings['use_fluid_view_convert'] )
{
return;
}
@@ -116,9 +113,9 @@ class Vanilla extends Software
*
* @param string $location File location retrieved from the database
* @param string $uploadsPath Configured uploads path
* @return Url|string|void
* @return Url|string|null
*/
public static function parseMediaLocation( $location, $uploadsPath )
public static function parseMediaLocation( string $location, string $uploadsPath ) : Url|string|null
{
$uploadsPath = str_replace( '\\', '/', $uploadsPath );
@@ -148,7 +145,7 @@ class Vanilla extends Software
{
if ( !isset( $parts['path'], $parts['host'] ) )
{
return;
return null;
}
// This is a url in the format type:://domain/path.
@@ -173,7 +170,7 @@ class Vanilla extends Software
* @param string $date Date(Time) string
* @return DateTime Timestamp on successful conversion, otherwise NULL
*/
public static function mysqlToDateTime( $date )
public static function mysqlToDateTime( string $date ) : DateTime
{
return DateTime::ts( strtotime( $date ) ?: time() );
}
@@ -181,9 +178,9 @@ class Vanilla extends Software
/**
* Content we can convert from this software.
*
* @return array
* @return array|null
*/
public static function canConvert()
public static function canConvert(): ?array
{
return array(
'convertGroups' => array(
@@ -208,9 +205,9 @@ class Vanilla extends Software
/**
* Can we convert passwords from this software.
*
* @return boolean
* @return boolean
*/
public static function loginEnabled()
public static function loginEnabled(): bool
{
return TRUE;
}
@@ -218,9 +215,9 @@ class Vanilla extends Software
/**
* Returns a block of text, or a language string, that explains what the admin must do to start this conversion
*
* @return string
* @return string|null
*/
public static function getPreConversionInformation()
public static function getPreConversionInformation(): ?string
{
return 'convert_vanilla_preconvert';
}
@@ -228,9 +225,9 @@ class Vanilla extends Software
/**
* List of conversion methods that require additional information
*
* @return array
* @return array
*/
public static function checkConf()
public static function checkConf(): array
{
return array(
'convertGroups',
@@ -241,10 +238,10 @@ class Vanilla extends Software
/**
* Get More Information
*
* @param string $method Conversion method
* @return array
* @param string $method Conversion method
* @return array|null
*/
public function getMoreInfo( $method )
public function getMoreInfo( string $method ): ?array
{
switch( $method )
{
@@ -294,9 +291,9 @@ class Vanilla extends Software
/**
* Finish - Adds everything it needs to the queues and clears data store
*
* @return array Messages to display
* @return array Messages to display
*/
public function finish()
public function finish(): array
{
/* Search Index Rebuild */
Index::i()->rebuild();
@@ -325,14 +322,14 @@ class Vanilla extends Software
/**
* @brief Store parsedown object
*/
protected static $_parseDown = NULL;
protected static ?Parsedown $_parseDown = NULL;
/**
* Pre-process content for the Invision Community text parser
*
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param string $post The post
* @param string|null $className Classname passed by post-conversion rebuild
* @param int|null $contentId ID passed by post-conversion rebuild
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
@@ -419,7 +416,7 @@ class Vanilla extends Software
*
* @return void
*/
public function convertGroups()
public function convertGroups() : void
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'r.RoleID' );
@@ -454,7 +451,7 @@ class Vanilla extends Software
*
* @return void
*/
public function convertMembers()
public function convertMembers() : void
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'u.UserID' );
@@ -542,7 +539,7 @@ class Vanilla extends Software
*
* @return void
*/
public function convertPrivateMessages()
public function convertPrivateMessages() : void
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'ConversationID' );
@@ -569,14 +566,14 @@ class Vanilla extends Software
$maps = array();
$rows = iterator_to_array( $this->db->select( '*', 'UserConversation', array( 'ConversationID=?', $row['ConversationID'] ) ) );
$this->app->preCacheLinks( $rows, [ 'core_members' => 'UserID' ] );
foreach ( $rows as $row )
foreach ( $rows as $r )
{
$maps[ $row['UserID'] ] = array(
'map_user_id' => $row['UserID'],
'map_read_time' => static::mysqlToDateTime( $row['DateLastViewed'] ),
$maps[ $r['UserID'] ] = array(
'map_user_id' => $r['UserID'],
'map_read_time' => static::mysqlToDateTime( $r['DateLastViewed'] ),
//'map_folder_id' => TODO: Create a Bookmarks folder for "Bookmarked" conversations?
'map_user_active' => $row['Deleted'] == 0 ? 1 : 0,
'map_last_topic_reply' => static::mysqlToDateTime( $row['DateConversationUpdated'] )
'map_user_active' => $r['Deleted'] == 0 ? 1 : 0,
'map_last_topic_reply' => static::mysqlToDateTime( $r['DateConversationUpdated'] )
);
}
@@ -590,7 +587,7 @@ class Vanilla extends Software
*
* @return void
*/
public function convertPrivateMessageReplies()
public function convertPrivateMessageReplies() : void
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'MessageID' );
@@ -626,14 +623,14 @@ class Vanilla extends Software
* @param string $password Password from form
* @return bool
*/
public static function login( $member, $password )
public static function login( Member $member, string $password ) : bool
{
/* Vanilla 2.2 */
if( preg_match( '/^\$2[ay]\$(0[4-9]|[1-2][0-9]|3[0-1])\$[a-zA-Z0-9.\/]{53}/', $member->conv_password ) OR mb_substr( $member->conv_password, 0, 3 ) == '$P$' )
{
require_once \IPS\ROOT_PATH . "/applications/convert/sources/Login/PasswordHash.php";
$ph = new PasswordHash( 8, TRUE );
return $ph->CheckPassword( $password, $member->conv_password ) ? TRUE : FALSE;
return $ph->CheckPassword( $password, $member->conv_password );
}
if ( Login::compareHashes( $member->conv_password, md5( md5( str_replace( ''', "'", html_entity_decode( $password ) ) ) . $member->misc ) ) )