function message_create in Message 7
Helper to easily create messages.
Parameters
$type: The message type name.
$values: Array with the following keys:
- "arguments" - Array with arguments that should be replaced on run time in the message type.
- "timestamp" - The unix timestamp of the creation time of the message. If empty the current time will be used.
- "uid" - The user->uid to associate the message with, this will overwrite $account param, and it's useful when you don't have the full user object loaded into memory.
$account: Optional; The user object to associate the message with. If empty, the current user will be used.
Return value
18 calls to message_create()
- MessageArgumentsTestCase::testCtoolsArguments in tests/
MessageArgumentsTestCase.test - Testing ctools message arguments plugin.
- MessageCron::testPurge in tests/
message.test - Test purging of messages upon message_cron according to message type purge settings.
- MessageCron::testPurgeGlobalSettings in tests/
message.test - Test global purge settings and overriding them.
- MessageCron::testPurgeRequestLimit in tests/
message.test - Test compliance with MESSAGE_DELETE_PER_PURGE.
- MessageCrud::testMessageCrud in tests/
message.test - Test CRUD of message entity.
File
- ./
message.module, line 887 - API functions to manipulate messages.
Code
function message_create($type, $values = array(), $account = NULL) {
global $language;
if (empty($account)) {
global $user;
$account = clone $user;
}
$values['type'] = $type;
$values['user'] = $account;
$values += array(
'language' => $language->language,
);
return entity_create('message', $values);
}