Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
+81
-38
@@ -81,7 +81,11 @@ class _Group extends \IPS\Patterns\ActiveRecord
|
||||
// 4 is deprecated (previously gbw_lock_unlock_own)
|
||||
'gbw_promote' => 8, // Allow users in this group to promote to facebook/twitter
|
||||
'gbw_immune_auto_mod' => 16, // Users in this group can not be auto moderated
|
||||
'gbw_paid_clubs' => 32 // Users in this group can create paid clubs
|
||||
'gbw_paid_clubs' => 32, // Users in this group can create paid clubs
|
||||
'gbw_can_post_anonymously' => 64, // Users in this group can post anonymously (where allowed)
|
||||
'gbw_hide_inline_modevents' => 128, // Users in this group can see inline moderation events (where supported)
|
||||
'gbw_posted_in' => 256, // Items (topics, articles) will be marked as 'posted in by this group'
|
||||
'gbw_posted_in_secondary' => 512, // Items (topics, articles) will be marked as 'posted in by this group' when the group is set as a secondary group
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -92,17 +96,6 @@ class _Group extends \IPS\Patterns\ActiveRecord
|
||||
*/
|
||||
protected static $loadFromCache = TRUE;
|
||||
|
||||
/**
|
||||
* Group datastore
|
||||
*
|
||||
* @return array
|
||||
* @deprecated
|
||||
*/
|
||||
protected static function groupStore()
|
||||
{
|
||||
return static::getStore();
|
||||
}
|
||||
|
||||
/**
|
||||
* Group datastore
|
||||
*
|
||||
@@ -136,7 +129,32 @@ class _Group extends \IPS\Patterns\ActiveRecord
|
||||
if ( !static::$allGroups )
|
||||
{
|
||||
static::$allGroups = iterator_to_array( new \IPS\Patterns\ActiveRecordIterator( new \ArrayIterator( static::getStore() ), 'IPS\Member\Group' ) );
|
||||
|
||||
/* If we have a dispatcher instance, sort the groups alphabetically */
|
||||
if( \IPS\Dispatcher::hasInstance() )
|
||||
{
|
||||
/* Get all of the group names in one query */
|
||||
$sortedGroupIds = array();
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_sys_lang_words', array( 'word_key LIKE ? AND lang_id=?', 'core_group_%', \IPS\Member::loggedIn()->language()->id ), 'word_custom ASC' ) as $lang )
|
||||
{
|
||||
$sortedGroupIds[] = \str_replace( 'core_group_', '', $lang['word_key'] );
|
||||
}
|
||||
|
||||
$finalGroups = array();
|
||||
|
||||
foreach( $sortedGroupIds as $groupId )
|
||||
{
|
||||
if( isset( static::$allGroups[ $groupId ] ) )
|
||||
{
|
||||
$finalGroups[ $groupId ] = static::$allGroups[ $groupId ];
|
||||
}
|
||||
}
|
||||
|
||||
static::$allGroups = $finalGroups;
|
||||
}
|
||||
}
|
||||
|
||||
$groups = static::$allGroups;
|
||||
|
||||
if ( !$showGuestGroups )
|
||||
@@ -167,30 +185,6 @@ class _Group extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
}
|
||||
|
||||
/* If we have a dispatcher instance, sort the groups alphabetically */
|
||||
if( \IPS\Dispatcher::hasInstance() )
|
||||
{
|
||||
/* Get all of the group names in one query */
|
||||
$sortedGroupIds = array();
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_sys_lang_words', array( 'word_key LIKE ? AND lang_id=?', 'core_group_%', \IPS\Member::loggedIn()->language()->id ), 'word_custom ASC' ) as $lang )
|
||||
{
|
||||
$sortedGroupIds[] = \str_replace( 'core_group_', '', $lang['word_key'] );
|
||||
}
|
||||
|
||||
$finalGroups = array();
|
||||
|
||||
foreach( $sortedGroupIds as $groupId )
|
||||
{
|
||||
if( isset( $groups[ $groupId ] ) )
|
||||
{
|
||||
$finalGroups[ $groupId ] = $groups[ $groupId ];
|
||||
}
|
||||
}
|
||||
|
||||
$groups = $finalGroups;
|
||||
}
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
@@ -296,14 +290,31 @@ class _Group extends \IPS\Patterns\ActiveRecord
|
||||
*/
|
||||
public function getCount()
|
||||
{
|
||||
$key = 'groupMembersCount_' . $this->g_id;
|
||||
|
||||
try
|
||||
{
|
||||
$count = \IPS\Data\Cache::i()->getWithExpire( 'groupMembersCount_' . $this->g_id, TRUE );
|
||||
$count = \IPS\Data\Store::i()->$key;
|
||||
|
||||
if( $values = json_decode( $count, true ) )
|
||||
{
|
||||
if( $values['expire'] < time() )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
return $values['count'];
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
$count = \IPS\Db::i()->select( 'COUNT(*)', 'core_members', array( 'member_group_id=? OR FIND_IN_SET( ?, mgroup_others )', $this->g_id, $this->g_id ) )->first();
|
||||
\IPS\Data\Cache::i()->storeWithExpire( 'groupMembersCount_' . $this->g_id, $count, \IPS\DateTime::create()->add( new \DateInterval( 'PT10M' ) ), TRUE );
|
||||
|
||||
\IPS\Data\Store::i()->$key = json_encode( array( 'count' => $count, 'expire' => \IPS\DateTime::create()->add( new \DateInterval( 'PT10M' ) )->getTimestamp() ) );
|
||||
}
|
||||
|
||||
return (int) $count;
|
||||
@@ -383,6 +394,38 @@ class _Group extends \IPS\Patterns\ActiveRecord
|
||||
/* Update Core Leaders */
|
||||
\IPS\core\StaffDirectory\User::updateEmptySetting();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return group that will show the posted in indicator
|
||||
*
|
||||
* @param array $primary Primary Group IDs
|
||||
* @param array $secondary Array of Secondary Group IDs
|
||||
* @return array|FALSE
|
||||
*/
|
||||
public static function postedIn( array $primary, array $secondary )
|
||||
{
|
||||
if ( !static::$allGroups )
|
||||
{
|
||||
static::groups();
|
||||
}
|
||||
$return = array();
|
||||
|
||||
foreach( array( 'primary', 'secondary' ) as $type )
|
||||
{
|
||||
if ( \is_array( $$type ) and \count( $$type ) )
|
||||
{
|
||||
foreach ( $$type as $id )
|
||||
{
|
||||
if ( isset( static::$allGroups[$id] ) and static::$allGroups[$id]->g_bitoptions[ ( $type == 'primary' ? 'gbw_posted_in' : 'gbw_posted_in_secondary') ] )
|
||||
{
|
||||
$return[ $id ] = static::$allGroups[$id];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ( \count( $return ) ? $return : FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get output for API
|
||||
|
||||
Reference in new issue
Block a user