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
Exibir arquivo Open project: rainlab/user-plugin Class Usage Examples

Public Properties

Property Type Description
$belongsTo Relations
$table The database table used by the model.

Protected Properties

Property Type Description
$guarded Guarded fields
$safeTemplates Templates names that cannot be blocked.

Public Methods

Method 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 method

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
return boolean

blockAll() public static method

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

checkAllForUser() public static method

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

checkForEmail() public static method

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
return array

filterMessage() public static method

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
return boolean | null

isBlockAll() public static method

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

removeBlock() public static method

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
return boolean

setPreferences() public static method

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
return void

syncUser() public static method

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

unblockAll() public static method

Removes block on all mail messages for a user.
public static unblockAll ( RainLab\User\Models\User $user ) : boolean
$user RainLab\User\Models\User
return 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