PHP Class RainLab\User\Models\MailBlocker

A utility model that allows a user to block specific mail views/templates from being sent to their address.
Inheritance: extends Mode\Model
Afficher le fichier Open project: rainlab/user-plugin Class Usage Examples

Méthodes publiques

Свойство Type Description
$belongsTo Relations
$table The database table used by the model.

Protected Properties

Свойство Type Description
$guarded Guarded fields
$safeTemplates Templates names that cannot be blocked.

Méthodes publiques

Méthode Description
addBlock ( string $template, RainLab\User\Models\User $user ) : boolean Adds a block for a user and a mail view/template code.
blockAll ( RainLab\User\Models\User $user ) : boolean Blocks all mail messages for a user.
checkAllForUser ( Model $user ) : array Returns a list of mail templates blocked by the user.
checkForEmail ( string $template, string $email ) : array Checks if an email address has blocked a given template, returns an array of blocked emails.
filterMessage ( string $template, Illuminate\Mail\Message $message ) : boolean | null Filters a Illuminate\Mail\Message and removes blocked recipients.
isBlockAll ( RainLab\User\Models\User $user ) : boolean Checks if a user is blocking all templates.
removeBlock ( string $template, RainLab\User\Models\User $user ) : boolean Removes a block for a user and a mail view/template code.
setPreferences ( RainLab\User\Models\User $user, array $templates, array $options = [] ) : void Sets mail blocking preferences for a user. Eg:
syncUser ( Model $user ) : mixed Updates mail blockers for a user if they change their email address
unblockAll ( RainLab\User\Models\User $user ) : boolean Removes block on all mail messages for a user.

Method Details

addBlock() public static méthode

Adds a block for a user and a mail view/template code.
public static addBlock ( string $template, RainLab\User\Models\User $user ) : boolean
$template string
$user RainLab\User\Models\User
Résultat boolean

blockAll() public static méthode

Blocks all mail messages for a user.
public static blockAll ( RainLab\User\Models\User $user ) : boolean
$user RainLab\User\Models\User
Résultat boolean

checkAllForUser() public static méthode

Returns a list of mail templates blocked by the user.
public static checkAllForUser ( Model $user ) : array
$user Model
Résultat array

checkForEmail() public static méthode

Checks if an email address has blocked a given template, returns an array of blocked emails.
public static checkForEmail ( string $template, string $email ) : array
$template string
$email string
Résultat array

filterMessage() public static méthode

If no recipients remain, false is returned. Returns null if mailing should proceed.
public static filterMessage ( string $template, Illuminate\Mail\Message $message ) : boolean | null
$template string
$message Illuminate\Mail\Message
Résultat boolean | null

isBlockAll() public static méthode

Checks if a user is blocking all templates.
public static isBlockAll ( RainLab\User\Models\User $user ) : boolean
$user RainLab\User\Models\User
Résultat boolean

removeBlock() public static méthode

Removes a block for a user and a mail view/template code.
public static removeBlock ( string $template, RainLab\User\Models\User $user ) : boolean
$template string
$user RainLab\User\Models\User
Résultat boolean

setPreferences() public static méthode

MailBlocker::setPreferences($user, [acme.blog::post.new_reply => 0]) MailBlocker::setPreferences($user, [acme.blog::post.new_reply => 0], [fillable => [acme.blog::post.new_reply]]) MailBlocker::setPreferences($user, [template_alias => 0], [aliases => [template_alias => acme.blog::post.new_reply]]) Supported options: - aliases: Alias definitions, with alias as key and template as value. - fillable: An array of expected templates, undefined templates are ignored. - verify: Only allow mail templates that are registered in the system.
public static setPreferences ( RainLab\User\Models\User $user, array $templates, array $options = [] ) : void
$user RainLab\User\Models\User
$templates array Template name as key and boolean as value. If false, template is blocked.
$options array
Résultat void

syncUser() public static méthode

Updates mail blockers for a user if they change their email address
public static syncUser ( Model $user ) : mixed
$user Model
Résultat mixed

unblockAll() public static méthode

Removes block on all mail messages for a user.
public static unblockAll ( RainLab\User\Models\User $user ) : boolean
$user RainLab\User\Models\User
Résultat boolean

Property Details

$belongsTo public_oe property

Relations
public $belongsTo

$guarded protected_oe property

Guarded fields
protected $guarded

$safeTemplates protected_oe static_oe property

Templates names that cannot be blocked.
protected static $safeTemplates

$table public_oe property

The database table used by the model.
public $table