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

@@ -11,50 +11,72 @@
namespace IPS\core\modules\setup\upgrade;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use Exception;
use IPS\Application;
use IPS\core\Setup\Upgrade;
use IPS\Data\Store;
use IPS\Db;
use IPS\Dispatcher\Controller;
use IPS\Http\Url;
use IPS\IPS;
use IPS\Member;
use IPS\Output;
use IPS\Request;
use IPS\Theme;
use IPS\Xml\XMLReader;
use OutOfRangeException;
use function count;
use function defined;
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;
}
/**
* Upgrader: Applications
*/
class _applications extends \IPS\Dispatcher\Controller
class applications extends Controller
{
/**
* Show Form
*
* @return void
*/
public function manage()
public function manage() : void
{
$apps = array();
/* Update old app keys or everything gets confused */
\IPS\Db::i()->update( 'core_applications', array( 'app_directory' => 'cms' ), array( 'app_directory=?', 'ccs' ) );
\IPS\Db::i()->update( 'core_applications', array( 'app_directory' => 'chat' ), array( 'app_directory=?', 'ipchat' ) );
/* We had a bug in an earlier beta where the version may not have updated properly, so we need to account for that but it has to happen before we load version files */
/* @todo We may want to remove those down the road as it should only affect users who have upgraded to early betas */
if( \IPS\Db::i()->checkForTable( 'core_widgets' ) AND !\IPS\Db::i()->checkForColumn( 'core_widgets', 'embeddable' ) )
/* Stop here if we are trying to upgrade from a version older than 4.5 */
if( Application::load( 'core' )->long_version < 105100 )
{
\IPS\Db::i()->update( 'core_applications', array( 'app_version' => '4.0.0 Beta 1', 'app_long_version' => '100001' ) );
Upgrade::setUpgradingFlag( FALSE );
Output::i()->title = Member::loggedIn()->language()->addToStack('applications');
Output::i()->output = Theme::i()->getTemplate( 'global' )->block( 'applications', Theme::i()->getTemplate( 'forms' )->minversioncheck() );
return;
}
/* If we are upgrading from a version older than v5, disable all 3rd party apps */
if( Application::load( 'core' )->long_version < 200000 )
{
Db::i()->update( 'core_applications', array( 'app_enabled' => 0, 'app_requires_manual_intervention' => 1 ), Db::i()->in( 'app_directory', IPS::$ipsApps, true ) );
}
/* Clear any caches or else we might not see new versions */
if ( isset( \IPS\Data\Store::i()->applications ) )
if ( isset( Store::i()->applications ) )
{
unset( \IPS\Data\Store::i()->applications );
unset( Store::i()->applications );
}
if ( isset( \IPS\Data\Store::i()->modules ) )
if ( isset( Store::i()->modules ) )
{
unset( \IPS\Data\Store::i()->modules );
unset( Store::i()->modules );
}
foreach( \IPS\Application::applications() as $app => $data )
foreach( Application::applications() as $app => $data )
{
$path = \IPS\Application::getRootPath( $app ) . '/applications/' . $app;
$path = Application::getRootPath( $app ) . '/applications/' . $app;
if ( $app == 'chat' )
{
@@ -76,15 +98,15 @@ class _applications extends \IPS\Dispatcher\Controller
}
/* Figure out of an upgrade is even available */
$currentVersion = \IPS\Application::load( $app )->long_version;
$availableVersion = \IPS\Application::getAvailableVersion( $app );
$currentVersion = Application::load( $app )->long_version;
$availableVersion = Application::getAvailableVersion( $app );
$name = $data->_title;
/* Get app name */
if ( file_exists( $path . '/data/lang.xml' ) )
{
$xml = \IPS\Xml\XMLReader::safeOpen( $path . '/data/lang.xml' );
$xml = XMLReader::safeOpen( $path . '/data/lang.xml' );
$xml->read();
$xml->read();
@@ -104,14 +126,14 @@ class _applications extends \IPS\Dispatcher\Controller
'name' => $name,
'disabled' => ( !empty( $errors ) OR $availableVersion <= $currentVersion ),
'errors' => $errors,
'current' => \IPS\Application::load( $app )->version,
'available' => \IPS\Application::getAvailableVersion( $app, TRUE )
'current' => Application::load( $app )->version,
'available' => Application::getAvailableVersion( $app, TRUE )
);
}
}
if( \count( $apps ) )
if( count( $apps ) )
{
/* Make sure the core app is the first index */
if( isset( $apps['core'] ) )
@@ -122,8 +144,8 @@ class _applications extends \IPS\Dispatcher\Controller
$_SESSION['apps'] = $apps;
$warnings = array();
$coreVersion = array_key_exists( 'core', $_SESSION['apps'] ) ? \IPS\Application::getAvailableVersion( 'core' ) : \IPS\Application::load( 'core' )->long_version;
foreach ( \IPS\IPS::$ipsApps as $key )
$coreVersion = array_key_exists( 'core', $_SESSION['apps'] ) ? Application::getAvailableVersion( 'core' ) : Application::load( 'core' )->long_version;
foreach ( IPS::$ipsApps as $key )
{
if ( $key == 'chat' )
{
@@ -132,35 +154,35 @@ class _applications extends \IPS\Dispatcher\Controller
try
{
$appVersion = array_key_exists( $key, $_SESSION['apps'] ) ? \IPS\Application::getAvailableVersion( $key ) : \IPS\Application::load( $key )->long_version;
$appVersion = array_key_exists( $key, $_SESSION['apps'] ) ? Application::getAvailableVersion( $key ) : Application::load( $key )->long_version;
if ( $appVersion != $coreVersion )
{
$warnings[] = $key;
}
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException $e )
{
/* The application is not installed */
continue;
}
}
if ( \count( $warnings ) )
if ( count( $warnings ) )
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "controller=applications&do=warning" )->setQueryString( array( 'key' => $_SESSION['uniqueKey'], 'warnings' => implode( ',', $warnings ) ) ) );
Output::i()->redirect( Url::internal( "controller=applications&do=warning" )->setQueryString( array( 'key' => $_SESSION['uniqueKey'], 'warnings' => implode( ',', $warnings ) ) ) );
}
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "controller=customoptions" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
Output::i()->redirect( Url::internal( "controller=customoptions" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
}
else
{
$form = \IPS\Theme::i()->getTemplate( 'forms' )->noapps();
$form = Theme::i()->getTemplate( 'forms' )->noapps();
\IPS\core\Setup\Upgrade::setUpgradingFlag( FALSE );
Upgrade::setUpgradingFlag( FALSE );
}
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('applications');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'applications', $form );
Output::i()->title = Member::loggedIn()->language()->addToStack('applications');
Output::i()->output = Theme::i()->getTemplate( 'global' )->block( 'applications', $form );
}
/**
@@ -168,18 +190,18 @@ class _applications extends \IPS\Dispatcher\Controller
*
* @return void
*/
public function warning()
public function warning() : void
{
$apps = array();
foreach ( explode( ',', \IPS\Request::i()->warnings ) as $key )
foreach ( explode( ',', Request::i()->warnings ) as $key )
{
try
{
$name = \IPS\Application::load( $key )->_title;
$name = Application::load( $key )->_title;
$path = \IPS\ROOT_PATH . '/applications/' . $key;
if ( file_exists( $path . '/data/lang.xml' ) )
{
$xml = \IPS\Xml\XMLReader::safeOpen( $path . '/data/lang.xml' );
$xml = XMLReader::safeOpen( $path . '/data/lang.xml' );
$xml->read();
$xml->read();
@@ -194,10 +216,10 @@ class _applications extends \IPS\Dispatcher\Controller
}
$apps[] = $name;
}
catch ( \Exception $e ) { }
catch ( Exception $e ) { }
}
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('applications');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'applications', \IPS\Theme::i()->getTemplate( 'global' )->appWarnings( $apps ) );
Output::i()->title = Member::loggedIn()->language()->addToStack('applications');
Output::i()->output = Theme::i()->getTemplate( 'global' )->block( 'applications', Theme::i()->getTemplate( 'global' )->appWarnings( $apps ) );
}
}