PHP Class BanModel, vanilla

Since: 2.0.18
Inheritance: extends Gdn_Model
Mostrar archivo Open project: vanilla/vanilla Class Usage Examples

Protected Properties

Property Type Description
$_AllBans * @var array
$instance The singleton instance of this class.

Public Methods

Method Description
_BeforeGet ( ) Add ban data to all Get requests.
__construct ( ) Defines the related database table name.
allBans ( ) Get and store list of current bans.
applyBan ( array $NewBan = null, array $OldBan = null ) Convert bans to new type.
banWhere ( array $Ban ) : array Ban users that meet conditions given.
checkUser ( $User, Gdn_Validation $Validation = null, boolean $UpdateBlocks = false, &$BansFound = null ) : boolean Add ban data to all Get requests.
delete ( array | integer $where = [], array | true $options = [] ) : boolean Remove a ban.
explodeBans ( integer $banned ) : array Explode a banned bit mask into an array of ban constants.
instance ( ) : BanModel Get the singleton instance of the {@link BanModel} class.
isBanned ( integer $banned, integer $reason ) : boolean Check whether or not a banned value is banned for a given reason.
save ( array $FormPostValues, array $Settings = false ) Save data about ban from form.
saveUser ( array $User, boolean $BannedValue, array | false $Ban = false ) Change ban data on a user (ban or unban them).
setBanned ( integer $banned, boolean $value, integer $reason ) : integer Set the banned mask value for a reason and return the new value.
setCounts ( array &$Data ) Set number of banned users in $Data.

Method Details

_BeforeGet() public method

Add ban data to all Get requests.
Since: 2.0.18
public _BeforeGet ( )

__construct() public method

Defines the related database table name.
public __construct ( )

allBans() public static method

Get and store list of current bans.
Since: 2.0.18
public static allBans ( )

applyBan() public method

Convert bans to new type.
Since: 2.0.18
public applyBan ( array $NewBan = null, array $OldBan = null )
$NewBan array Data about the new ban.
$OldBan array Data about the old ban.

banWhere() public method

Ban users that meet conditions given.
Since: 2.0.18
public banWhere ( array $Ban ) : array
$Ban array Data about the ban. Valid keys are BanType and BanValue. BanValue is what is to be banned. Valid values for BanType are email, ipaddress or name.
return array

checkUser() public static method

Add ban data to all Get requests.
Since: 2.0.18
public static checkUser ( $User, Gdn_Validation $Validation = null, boolean $UpdateBlocks = false, &$BansFound = null ) : boolean
$Validation Gdn_Validation
$UpdateBlocks boolean
return boolean Whether user is banned.

delete() public method

Remove a ban.
public delete ( array | integer $where = [], array | true $options = [] ) : boolean
$where array | integer The where clause to delete or an integer value.
$options array | true An array of options to control the delete.
return boolean Returns **true** on success or **false** on failure.

explodeBans() public static method

Explode a banned bit mask into an array of ban constants.
public static explodeBans ( integer $banned ) : array
$banned integer The banned bit mask to explode.
return array Returns an array of the set bits.

instance() public static method

Get the singleton instance of the {@link BanModel} class.
public static instance ( ) : BanModel
return BanModel Returns the singleton instance of this class.

isBanned() public static method

Check whether or not a banned value is banned for a given reason.
public static isBanned ( integer $banned, integer $reason ) : boolean
$banned integer The banned value.
$reason integer The reason for the banning or an empty string to check if banned for any reason. This should be one of the `BanModel::BAN_*` constants.
return boolean Returns true if the value is banned or false otherwise.

save() public method

Save data about ban from form.
Since: 2.0.18
public save ( array $FormPostValues, array $Settings = false )
$FormPostValues array
$Settings array

saveUser() public method

Change ban data on a user (ban or unban them).
Since: 2.0.18
public saveUser ( array $User, boolean $BannedValue, array | false $Ban = false )
$User array
$BannedValue boolean Whether user is banned.
$Ban array | false An array representing the specific auto-ban.

setBanned() public static method

Set the banned mask value for a reason and return the new value.
public static setBanned ( integer $banned, boolean $value, integer $reason ) : integer
$banned integer The current banned value.
$value boolean The new ban value for the given reason.
$reason integer The reason for the banning. This should be one of the `BanModel::BAN_*` constants.
return integer Returns the new banned value.

setCounts() public method

Set number of banned users in $Data.
Since: 2.0.18
public setCounts ( array &$Data )
$Data array

Property Details

$_AllBans protected_oe static_oe property

* @var array
protected static $_AllBans

$instance protected_oe static_oe property

The singleton instance of this class.
protected static $instance