Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

+47 -31
View File
@@ -12,26 +12,42 @@
namespace IPS\convert;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use InvalidArgumentException;
use IPS\Application as SystemApplication;
use IPS\Db;
use IPS\Http\Url;
use IPS\Lang;
use IPS\Login;
use IPS\Member;
use IPS\Member\Group;
use IPS\Output;
use IPS\Request;
use UnderflowException;
use function defined;
use function is_null;
use const IPS\DEMO_MODE;
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;
}
/**
* Converter Application Class
*/
class _Application extends \IPS\Application
class Application extends SystemApplication
{
/**
* Can the user access this application?
*
* @param \IPS\Member|\IPS\Member\Group|NULL $memberOrGroup Member/group we are checking against or NULL for currently logged on user
* @param Member|Group|NULL $memberOrGroup Member/group we are checking against or NULL for currently logged on user
* @return bool
*/
public function canAccess( $memberOrGroup=NULL )
public function canAccess( $memberOrGroup=NULL ): bool
{
if ( \IPS\DEMO_MODE === TRUE )
if ( DEMO_MODE === TRUE )
{
return FALSE;
}
@@ -44,7 +60,7 @@ class _Application extends \IPS\Application
*
* @return string|null
*/
protected function get__description()
protected function get__description(): ?string
{
return NULL;
}
@@ -53,9 +69,9 @@ class _Application extends \IPS\Application
* [Node] Get Icon for tree
*
* @note Return the class for the icon (e.g. 'globe')
* @return string|null
* @return string
*/
protected function get__icon()
protected function get__icon(): string
{
return 'random';
}
@@ -66,7 +82,7 @@ class _Application extends \IPS\Application
* @note Return value NULL indicates the node cannot be enabled/disabled
* @return bool|null
*/
protected function get__locked()
protected function get__locked(): ?bool
{
/* We don't allow the application to be disabled since its hooks are required for redirects */
return TRUE;
@@ -76,19 +92,19 @@ class _Application extends \IPS\Application
* [Node] Get buttons to display in tree
* Example code explains return value
*
* @param string $url Base URL
* @param bool $subnode Is this a subnode?
* @return array
* @param Url $url Base URL
* @param bool $subnode Is this a subnode?
* @return array
*/
public function getButtons( $url, $subnode=FALSE )
public function getButtons( Url $url, bool $subnode=FALSE ): array
{
$buttons = parent::getButtons( $url, $subnode );
if( isset( $buttons['delete'] ) )
{
$buttons['delete']['title'] = 'uninstall';
$buttons['delete']['data']['delete-message'] = \IPS\Member::loggedIn()->language()->addToStack('converter_uninstall');
$buttons['delete']['data']['delete-warning'] = \IPS\Member::loggedIn()->language()->addToStack('converter_uninstall_warning');
$buttons['delete']['data']['delete-message'] = Member::loggedIn()->language()->addToStack('converter_uninstall');
$buttons['delete']['data']['delete-warning'] = Member::loggedIn()->language()->addToStack('converter_uninstall_warning');
}
return $buttons;
@@ -105,22 +121,22 @@ class _Application extends \IPS\Application
try
{
\IPS\Db::i()->select( '*', 'core_login_methods', array( "login_classname=?", 'IPS\\convert\\Login' ) )->first();
Db::i()->select( '*', 'core_login_methods', array( "login_classname=?", 'IPS\\convert\\Login' ) )->first();
}
catch( \UnderflowException $e )
catch( UnderflowException $e )
{
$position = \IPS\Db::i()->select( 'MAX(login_order)', 'core_login_methods' )->first();
$position = Db::i()->select( 'MAX(login_order)', 'core_login_methods' )->first();
$handler = new \IPS\convert\Login;
$handler->classname = 'IPS\\convert\\Login';
$handler->order = $position + 1;
$handler->acp = TRUE;
$handler->settings = array( 'auth_types' => \IPS\Login::AUTH_TYPE_EMAIL );
$handler->settings = array( 'auth_types' => Login::AUTH_TYPE_EMAIL );
$handler->enabled = TRUE;
$handler->register = FALSE;
$handler->save();
\IPS\Lang::saveCustom( 'core', "login_method_{$handler->id}", 'Converter' );
Lang::saveCustom( 'core', "login_method_{$handler->id}", 'Converter' );
}
}
@@ -205,7 +221,7 @@ class _Application extends \IPS\Application
foreach( $parents AS $app => $tables )
{
if ( !\is_null( $application ) AND $application != $app )
if ( !is_null( $application ) AND $application != $app )
{
continue;
}
@@ -214,12 +230,12 @@ class _Application extends \IPS\Application
{
foreach( $tables['tables'] AS $table => $data )
{
if ( \IPS\Db::i()->checkForTable( $table ) )
if ( Db::i()->checkForTable( $table ) )
{
$column = $data['prefix'] . $data['column'];
if ( \IPS\Db::i()->checkForColumn( $table, $column ) === FALSE )
if ( Db::i()->checkForColumn( $table, $column ) === FALSE )
{
\IPS\Db::i()->addColumn( $table, array(
Db::i()->addColumn( $table, array(
'name' => $column,
'type' => 'VARCHAR',
'length' => 255,
@@ -228,10 +244,10 @@ class _Application extends \IPS\Application
}
else
{
$localDefinition = \IPS\Db::i()->getTableDefinition( $table, TRUE );
$localDefinition = Db::i()->getTableDefinition( $table, TRUE );
if( $localDefinition['columns'][ $column ]['type'] !== 'VARCHAR' )
{
\IPS\Db::i()->changeColumn( $table, $column, array(
Db::i()->changeColumn( $table, $column, array(
'name' => $column,
'type' => 'VARCHAR',
'length' => 255,
@@ -293,7 +309,7 @@ class _Application extends \IPS\Application
}
/* SMF */
if( \IPS\Request::i()->board OR \IPS\Request::i()->topic OR \IPS\Request::i()->action )
if( Request::i()->board OR Request::i()->topic OR Request::i()->action )
{
static::checkRedirects();
}
@@ -307,13 +323,13 @@ class _Application extends \IPS\Application
public static function checkRedirects()
{
/* Try each of our converted applications. We will assume the most important conversions were done first */
foreach( \IPS\convert\App::apps() as $app )
foreach(App::apps() as $app )
{
try
{
$redirect = $app->getSource( TRUE, FALSE )->checkRedirects();
}
catch( \InvalidArgumentException $e )
catch( InvalidArgumentException $e )
{
/* This converter app doesn't exist on disk, this is expected for sites upgraded from 3.x where there isn't a 4.x version of the converter app */
continue;
@@ -323,7 +339,7 @@ class _Application extends \IPS\Application
if( $redirect !== NULL )
{
/* We got a valid redirect, so send the user there */
\IPS\Output::i()->redirect( $redirect, NULL, 301 );
Output::i()->redirect( $redirect, NULL, 301 );
}
}
}