Version 5.0.0 release
This commit is contained in:
1 parent
90e8c7e903
commit
a3a4a9ccbd
651 files changed
+7275
-9481
No files matched your search
@@ -16,6 +16,9 @@ namespace IPS\Content;
|
||||
|
||||
use DomainException;
|
||||
use IPS\core\Assignments\Assignment;
|
||||
use IPS\Data\Cache;
|
||||
use IPS\Data\Store;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Helpers\Form\FormAbstract;
|
||||
use IPS\Helpers\Form\Text;
|
||||
@@ -27,6 +30,7 @@ use IPS\Platform\Bridge;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use function count;
|
||||
use function get_class;
|
||||
use function is_string;
|
||||
use function strpos;
|
||||
use function substr;
|
||||
@@ -337,6 +341,38 @@ trait Assignable
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the member IDs for this container
|
||||
*
|
||||
* @param Model|null $container
|
||||
* @return array
|
||||
*/
|
||||
public static function getMemberAssignmentOptions( ?Model $container=null ) : array
|
||||
{
|
||||
try
|
||||
{
|
||||
$cache = Store::i()->assignmentOptions;
|
||||
}
|
||||
catch( OutOfRangeException )
|
||||
{
|
||||
$cache = [];
|
||||
}
|
||||
|
||||
$cacheKey = $container ? get_class( $container ) . '__' . $container->_id : '__GLOBAL__';
|
||||
if( !isset( $cache[ $cacheKey ] ) )
|
||||
{
|
||||
$containerModerators = static::getModerators( $container );
|
||||
$cache[ $cacheKey ] = iterator_to_array(
|
||||
Db::i()->select( 'member_id', 'core_members', ( count( $containerModerators['m'] ) ? Db::i()->in( 'member_id', $containerModerators['m'] ) . ' OR ' : '' ) . Db::i()->in( 'member_group_id', $containerModerators['g'] ) . ' OR ' . Db::i()->findInSet( 'mgroup_others', $containerModerators['g'] ) )
|
||||
);
|
||||
|
||||
Store::i()->assignmentOptions = $cache;
|
||||
}
|
||||
|
||||
return $cache[ $cacheKey ];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate a field for the assignment options
|
||||
*
|
||||
@@ -379,11 +415,8 @@ trait Assignable
|
||||
];
|
||||
|
||||
/* Do we have a very large list of options? */
|
||||
$containerModerators = static::getModerators( $container );
|
||||
|
||||
$total = (int) Db::i()->select( 'count(member_id)', 'core_members', ( count( $containerModerators['m'] ) ? Db::i()->in( 'member_id', $containerModerators['m'] ) . ' OR ' : '' ) . Db::i()->in( 'member_group_id', $containerModerators['g'] ) . ' OR ' . Db::i()->findInSet( 'mgroup_others', $containerModerators['g'] ) )->first();
|
||||
$total += count( Team::teams() );
|
||||
|
||||
$assignmentOptions = static::getMemberAssignmentOptions( $container );
|
||||
$total = count( $assignmentOptions ) + count( Team::teams() );
|
||||
if( $total >= 100 )
|
||||
{
|
||||
$source = 'app=cloud&module=assignments&controller=assignments&do=findAssignmentOptions&class=' . get_called_class();
|
||||
@@ -399,10 +432,12 @@ trait Assignable
|
||||
else
|
||||
{
|
||||
$source = [];
|
||||
foreach( Db::i()->select( '*', 'core_members', ( count( $containerModerators['m'] ) ? Db::i()->in( 'member_id', $containerModerators['m'] ) . ' OR ' : '' ) . Db::i()->in( 'member_group_id', $containerModerators['g'] ) . ' OR ' . Db::i()->findInSet( 'mgroup_others', $containerModerators['g'] ) ) as $mem )
|
||||
foreach( new ActiveRecordIterator(
|
||||
Db::i()->select( '*', 'core_members', Db::i()->in( 'member_id', $assignmentOptions ) ),
|
||||
Member::class
|
||||
) as $member )
|
||||
{
|
||||
$member = Member::constructFromData( $mem );
|
||||
if( $container !== null and $container->can( 'reply', $member, false ) )
|
||||
if( $container === null or $container->can( 'reply', $member, false ) )
|
||||
{
|
||||
$source[ $member->name ] = Theme::i()->getTemplate( 'global', 'core', 'front' )->memberAssignment( $member );
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user