class Messaging_Simple in Messaging 7
Simple message instance
Hierarchy
- class \Messaging_Object
- class \Messaging_Simple
Expanded class hierarchy of Messaging_Simple
File
- messaging_simple/
messaging_simple.inc, line 10 - Drupal Messaging Framework - Send_Method class file
View source
class Messaging_Simple extends Messaging_Object {
public $mgid;
public $msid;
public $uid;
public $sender;
public $subject;
public $body;
public $language;
// Timestamps
public $sent;
public $timeread = 0;
/**
* Build from db object
*/
public static function build_object($template) {
return new Messaging_Simple($template);
}
/**
* Build from user account and Messaging_Message
*/
public static function build($user, $message) {
$store = new Messaging_Simple();
$store->uid = $user->uid;
$store->msid = $message->msid;
$store->sender = $message
->get_sender('uid');
$store->language = $message
->get_language()->language;
// Build message subject and content, may do token replacement
$template = $message
->get_template();
// As this is to be displayed on site we don't need greetings nor footer
$store->subject = $template
->render('subject');
$store->body = $template
->render('content');
return $store;
}
/**
* Save to db
*/
public function save() {
$this->sent = time();
return drupal_write_record('messaging_simple', $this);
}
/**
* Mark when read
*/
public function read() {
$this->timeread = time();
db_update('messaging_simple')
->fields(array(
'timeread' => $this->timeread,
))
->condition('mgid', $this->mgid)
->execute();
return $this->timeread;
}
/**
* Load from db
*/
public static function load($mgid) {
if ($message = db_query("SELECT * FROM {messaging_simple} WHERE mgid = :mgid", array(
':mgid' => $mgid,
))
->fetchObject()) {
return self::build_object($message);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Messaging_Object:: |
public | function | Constructor | |
Messaging_Simple:: |
public | property | ||
Messaging_Simple:: |
public | property | ||
Messaging_Simple:: |
public | property | ||
Messaging_Simple:: |
public | property | ||
Messaging_Simple:: |
public | property | ||
Messaging_Simple:: |
public | property | ||
Messaging_Simple:: |
public | property | ||
Messaging_Simple:: |
public | property | ||
Messaging_Simple:: |
public | property | ||
Messaging_Simple:: |
public static | function | Build from user account and Messaging_Message | |
Messaging_Simple:: |
public static | function |
Build from db object Overrides Messaging_Object:: |
|
Messaging_Simple:: |
public static | function | Load from db | |
Messaging_Simple:: |
public | function | Mark when read | |
Messaging_Simple:: |
public | function | Save to db |