Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
+79
-6
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Group 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
|
||||
* @since 13 Mar 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -48,7 +48,7 @@ class _Group extends \IPS\Patterns\ActiveRecord
|
||||
'gbw_ppd_unit_type' => 2, // Lift post-per-day limit after x. 1 is days, 0 is posts. Corresponds to g_ppd_unit
|
||||
'gbw_displayname_unit_type' => 4, // Username change restrictions. 1 is days, 0 is posts. Corresponds to g_displayname_unit
|
||||
'gbw_sig_unit_type' => 8, // Signature edit restrictions. 1 is days, 0 is posts. Corresponds to g_sig_unit
|
||||
'gbw_promote_unit_type' => 16, // Type of group promotion to use. 1 is days since joining, 0 is content count. Corresponds to g_promotion
|
||||
'gbw_promote_unit_type' => 16, // 16 is deprecated (previously gbw_promote_unit_type). Remove in 4.1.19.
|
||||
'gbw_no_status_update' => 32, // Can NOT post status updates
|
||||
// 64 is deprecated (previously gbw_soft_delete)
|
||||
'gbw_soft_delete_own' => 128, // Allow users of this group to hide their own submitted content
|
||||
@@ -75,6 +75,11 @@ class _Group extends \IPS\Patterns\ActiveRecord
|
||||
'gbw_no_report' => 268435456, // 1 means they CAN'T report content. 0 means they can.
|
||||
'gbw_cannot_be_ignored' => 536870912, // 1 means they cannot be ignored. 0 means they can
|
||||
'gbw_delete_attachments' => 1073741824, // 1 means they can delete attachments from the "My Attachments" screen
|
||||
),
|
||||
'g_bitoptions2' => array(
|
||||
'gbw_post_highlight' => 1, // 1 means on, 0 means off
|
||||
'gbw_hide_group' => 2, // Hide this group on the front end in search and similar areas: 1 is on, 0 is off
|
||||
'gbw_lock_unlock_own' => 4, // Allow users in this group to lock and unlock their own content
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -128,9 +133,10 @@ class _Group extends \IPS\Patterns\ActiveRecord
|
||||
*
|
||||
* @param bool $showAdminGroups Show admin groups. Used to restrict admin groups from being available when you cannot add/edit members in them.
|
||||
* @param bool $showGuestGroups Show guest groups. Used to remove the guest group from the available groups returned.
|
||||
* @param bool $hideGroups If the group is set not to not be available to filter by, should we hide them?
|
||||
* @return array
|
||||
*/
|
||||
public static function groups( $showAdminGroups=TRUE, $showGuestGroups=TRUE )
|
||||
public static function groups( $showAdminGroups=TRUE, $showGuestGroups=TRUE, $hideForFiltering=FALSE )
|
||||
{
|
||||
if ( !static::$allGroups )
|
||||
{
|
||||
@@ -145,15 +151,27 @@ class _Group extends \IPS\Patterns\ActiveRecord
|
||||
|
||||
if( !$showAdminGroups )
|
||||
{
|
||||
$administrators = \IPS\Member::administrators();
|
||||
foreach( $groups as $k => $_group )
|
||||
{
|
||||
if( $_group->g_access_cp )
|
||||
if ( isset( $administrators['g'][ $_group->g_id ] ) )
|
||||
{
|
||||
unset( $groups[ $k ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( $hideForFiltering )
|
||||
{
|
||||
foreach( $groups as $groupId => $group )
|
||||
{
|
||||
if( $group->g_bitoptions['gbw_hide_group'] )
|
||||
{
|
||||
unset( $groups[ $groupId ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
@@ -191,6 +209,10 @@ class _Group extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
|
||||
\IPS\Lang::saveCustom( 'core', "core_group_{$this->g_id}", iterator_to_array( \IPS\Db::i()->select( '*', 'core_sys_lang_words', array( 'word_key=?', "core_group_{$oldId}" ) )->setKeyField('lang_id')->setValueField('word_custom') ) );
|
||||
|
||||
/* Clear application and module store so that permissions are correctly rebuilt */
|
||||
unset( \IPS\Data\Store::i()->applications );
|
||||
unset( \IPS\Data\Store::i()->modules );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,6 +255,28 @@ class _Group extends \IPS\Patterns\ActiveRecord
|
||||
{
|
||||
return $this->formatName( $this->name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of members in this group
|
||||
*
|
||||
* @note Includes count of members with this group as a secondary group
|
||||
* @note The count is cached for 10 minutes as the query can be resource intensive
|
||||
* @return int
|
||||
*/
|
||||
public function getCount()
|
||||
{
|
||||
try
|
||||
{
|
||||
$count = \IPS\Data\Cache::i()->getWithExpire( 'groupMembersCount_' . $this->g_id, TRUE );
|
||||
}
|
||||
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 );
|
||||
}
|
||||
|
||||
return (int) $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format Name
|
||||
@@ -241,7 +285,7 @@ class _Group extends \IPS\Patterns\ActiveRecord
|
||||
*/
|
||||
public function formatName( $name )
|
||||
{
|
||||
return ( $this->prefix . htmlspecialchars( $name, \IPS\HTMLENTITIES, 'UTF-8', FALSE ) . $this->suffix );
|
||||
return ( $this->prefix . htmlspecialchars( $name, \IPS\HTMLENTITIES | ENT_QUOTES, 'UTF-8', FALSE ) . $this->suffix );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,9 +327,38 @@ class _Group extends \IPS\Patterns\ActiveRecord
|
||||
\IPS\Db::i()->delete( 'core_leaders', array( 'leader_type=? AND leader_type_id = ?', 'g', $this->g_id ) );
|
||||
\IPS\Db::i()->delete( 'core_moderators', array( 'type=? AND id = ?', 'g', $this->g_id ) );
|
||||
\IPS\Db::i()->delete( 'core_admin_permission_rows', array( 'row_id=? and row_id_type=?', $this->g_id, 'group' ) );
|
||||
|
||||
/* Make sure no other groups have this group ID set to promote to */
|
||||
foreach( static::groups() as $group )
|
||||
{
|
||||
$promote = explode( '&', $group->g_promotion );
|
||||
|
||||
if( $promote[0] == $this->g_id )
|
||||
{
|
||||
$group->g_promotion = '-1&' . $promote[1];
|
||||
$group->save();
|
||||
}
|
||||
}
|
||||
|
||||
parent::delete();
|
||||
\IPS\Lang::deleteCustom( 'core', 'core_group_' . $this->g_id );
|
||||
unset( \IPS\Data\Store::i()->groups );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get output for API
|
||||
*
|
||||
* @return array
|
||||
* @apiresponse int id ID number
|
||||
* @apiresponse string name Name
|
||||
* @apiresponse string formattedName Name with formatting
|
||||
*/
|
||||
public function apiOutput()
|
||||
{
|
||||
return array(
|
||||
'id' => $this->g_id,
|
||||
'name' => $this->name,
|
||||
'formattedName' => $this->formattedName,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user