Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Hosting Queue Model
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Nexus
|
||||
* @since 6 Aug 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -122,9 +122,26 @@ class _Queue extends \IPS\Node\Model
|
||||
$where[] = array( 'server_type<>?', 'none' );
|
||||
}
|
||||
|
||||
$serverData = \IPS\Db::i()->select( 'nexus_hosting_servers.*, COUNT(nexus_hosting_accounts.ps_id) AS accounts', 'nexus_hosting_servers', $where, 'accounts ASC', NULL, 'server_id' )->join( 'nexus_hosting_accounts', 'account_server=server_id AND account_exists=1' )->first();
|
||||
unset( $serverData['accounts'] );
|
||||
$serverLimits = iterator_to_array( \IPS\Db::i()->select( array( 'server_id', 'server_max_accounts' ), 'nexus_hosting_servers', $where )->setKeyField('server_id')->setValueField('server_max_accounts') );
|
||||
$serverWithLeastAccounts = NULL;
|
||||
foreach ( \IPS\Db::i()->select( 'nexus_hosting_servers.server_id, COUNT(nexus_hosting_accounts.ps_id) AS accounts', 'nexus_hosting_servers', $where, 'accounts ASC', NULL, 'server_id' )->join( 'nexus_hosting_accounts', 'account_server=server_id AND account_exists=1' ) as $serverData )
|
||||
{
|
||||
if ( !$serverWithLeastAccounts )
|
||||
{
|
||||
$serverWithLeastAccounts = $serverData['server_id'];
|
||||
}
|
||||
|
||||
if ( !isset( $serverLimits[ $serverData['server_id'] ] ) or !$serverLimits[ $serverData['server_id'] ] or $serverLimits[ $serverData['server_id'] ] > $serverData['accounts'] )
|
||||
{
|
||||
return \IPS\nexus\Hosting\Server::load( $serverData['server_id'] );
|
||||
}
|
||||
}
|
||||
|
||||
return \IPS\nexus\Hosting\Server::constructFromData( $serverData );
|
||||
if ( $serverWithLeastAccounts )
|
||||
{
|
||||
return \IPS\nexus\Hosting\Server::load( $serverWithLeastAccounts );
|
||||
}
|
||||
|
||||
throw new \UnderflowException;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user