class Messaging_Send_Method in Messaging 7
Same name and namespace in other branches
- 6.4 includes/messaging_method.class.inc \Messaging_Send_Method
- 6.3 classes/messaging_method.class.inc \Messaging_Send_Method
Sending method, implements all specific method functionality
Old callback functions are
- send
- destination
Hierarchy
- class \Messaging_Method
- class \Messaging_Send_Method
Expanded class hierarchy of Messaging_Send_Method
1 string reference to 'Messaging_Send_Method'
- messaging_send_method in ./
messaging.module - Get send method object
File
- ./
messaging.method.inc, line 121 - Drupal Messaging Framework - Send_Method class file
View source
class Messaging_Send_Method extends Messaging_Method {
// Default parameters for send method
public $method = 'send';
public $type = 'web';
public $enabled = TRUE;
// Available for anonymous users
public $anonymous = FALSE;
// Qeueue messages instead of sending
public $queue = FALSE;
// Whether we want all messages logged for this method
public $log = FALSE;
// Default format for message rendering
public $format = MESSAGING_FORMAT_HTML;
/**
* Get address type
*/
public static function address_type() {
return 'none';
}
/**
* Get address info property
*/
public static function address_info($property = NULL, $default = NULL) {
return messaging_address_info(self::address_type(), $property, $default);
}
/**
* Get address name
*/
public static function address_name() {
return self::address_info('name', t('Address'));
}
/**
* Message processing: Decide on queue, log, cron and send options, prepare parameters
*
* At this stage, the message can be still redirected through other sending method, or marked for discard
*/
function message_prepare($message) {
// Set queueing if not message priority
if ($this->queue && $message->priority <= 0) {
$message->queue = 1;
}
$message->log = $message->log || $this->log;
$this
->message_log('Message prepared', $message);
}
/**
* Prepare message for specific user. Check availability, redirect, etc..
*
* Redirecting is only possible when we are sending to a user account, not for anonymous destinations
*/
function message_user($message) {
}
/**
* Prepare template for this method.
*
* Here we can clone and alter the template or just return the same
*/
function message_render($message) {
$message
->get_template()
->set_method($this->method)
->set_format($this->format);
}
/**
* Send message to a single or multiple destination
*/
function message_send($message) {
$this
->message_log('Message send', $message);
$destinations = $message
->get_destinations();
$results = $this
->send_multiple($destinations, $message);
$message
->set_results($results);
return (bool) array_filter($results);
}
/**
* Send message to destination
*/
function send_destination($destination, $message) {
// Set destination to message template
$message
->get_template()
->set_destination($destination);
return $this
->send_address($destination
->get_address(), $message);
}
/**
* Send message to address, to be implemented by send method
*/
function send_address($address, $message) {
return FALSE;
}
/**
* Send message to multiple destinations
*/
function send_multiple($destinations, $message) {
$results = array();
foreach ($destinations as $key => $destination) {
$results[$key] = $this
->send_destination($destination, $message);
}
return $results;
}
/**
* Get message parameters for this method
*/
function message_params($message) {
return $message
->get_params($this->method) + $message
->get_params($this->type) + $this
->default_params();
}
/**
* Queue message for next delivery
*
* By default it is saved to the store, though some sending methods like 'simple' may not consider queueing.
*
* If no queue available we send the message
*/
function message_queue($message) {
if ($queue = messaging_store('queue')) {
$message->queued = time();
$queue
->message_queue($message);
return TRUE;
}
else {
$message->queued = 0;
return $this
->message_send($message);
}
}
/**
* Get destination for user account
*
* @param $account
* User account object or uid
*/
function user_destination($account) {
return Messaging_Destination::build_user($this
->address_type(), $account);
}
/**
* Check user access to this method
*/
function user_access($account) {
if (!$account->uid && !$this->anonymous) {
return FALSE;
}
if ($permission = $this
->method_info('access')) {
return user_access($permission, $account);
}
else {
return TRUE;
}
}
/**
* Make address into destination
*/
public function address_destination($address, $validate = TRUE) {
return Messaging_Destination::build_address($this
->address_type(), $address, $validate);
}
/**
* Validate address
*/
public function address_validate($address) {
return Messaging_Destination::validate_address($address, $this
->address_type());
}
/**
* Format address for display
*/
public function format_address($address, $format = MESSAGING_FORMAT_PLAIN) {
return Messaging_Destination::format_address($address, $format, $this
->address_type());
}
/**
* Check whether it supports anonyous destination
*/
function supports_anonymous() {
return TRUE;
}
/**
* Get default parameters for this method
*/
static function default_params() {
return array();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Messaging_Method:: |
public | property | ||
Messaging_Method:: |
static | function | Returns default messaging method | |
Messaging_Method:: |
function | Get method description, may be overridden by info properties | ||
Messaging_Method:: |
function | Get method name, may be overridden by info properties | ||
Messaging_Method:: |
function | Get method title for administrator list | ||
Messaging_Method:: |
protected | function | Log message action | |
Messaging_Method:: |
static | function | Update messaging method. | |
Messaging_Method:: |
function | Get info property | ||
Messaging_Method:: |
function | Build send method from info array | ||
Messaging_Send_Method:: |
public | property |
Overrides Messaging_Method:: |
|
Messaging_Send_Method:: |
public | property |
Overrides Messaging_Method:: |
|
Messaging_Send_Method:: |
public | property | ||
Messaging_Send_Method:: |
public | property | ||
Messaging_Send_Method:: |
public | property |
Overrides Messaging_Method:: |
|
Messaging_Send_Method:: |
public | property | ||
Messaging_Send_Method:: |
public | property |
Overrides Messaging_Method:: |
|
Messaging_Send_Method:: |
public | function | Make address into destination | |
Messaging_Send_Method:: |
public static | function | Get address info property | |
Messaging_Send_Method:: |
public static | function | Get address name | |
Messaging_Send_Method:: |
public static | function | Get address type | |
Messaging_Send_Method:: |
public | function | Validate address | |
Messaging_Send_Method:: |
static | function | Get default parameters for this method | |
Messaging_Send_Method:: |
public | function | Format address for display | |
Messaging_Send_Method:: |
function | Get message parameters for this method | ||
Messaging_Send_Method:: |
function | Message processing: Decide on queue, log, cron and send options, prepare parameters | ||
Messaging_Send_Method:: |
function | Queue message for next delivery | ||
Messaging_Send_Method:: |
function | Prepare template for this method. | ||
Messaging_Send_Method:: |
function | Send message to a single or multiple destination | ||
Messaging_Send_Method:: |
function | Prepare message for specific user. Check availability, redirect, etc.. | ||
Messaging_Send_Method:: |
function | Send message to address, to be implemented by send method | ||
Messaging_Send_Method:: |
function | Send message to destination | ||
Messaging_Send_Method:: |
function | Send message to multiple destinations | ||
Messaging_Send_Method:: |
function | Check whether it supports anonyous destination | ||
Messaging_Send_Method:: |
function | Check user access to this method | ||
Messaging_Send_Method:: |
function | Get destination for user account |