本文整理匯總了PHP中Notify::notifyNewInbox方法的典型用法代碼示例。如果您正苦於以下問題:PHP Notify::notifyNewInbox方法的具體用法?PHP Notify::notifyNewInbox怎麽用?PHP Notify::notifyNewInbox使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Notify
的用法示例。
在下文中一共展示了Notify::notifyNewInbox方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: sendMessage
function sendMessage($id_author, $to_users, $subject, $body, $time, $thread_id = false, $type = 0)
{
global $current_user;
if (!is_array($to_users)) {
throw new Exception('$to_users must be an array');
}
Database::query('START TRANSACTION');
$query = 'INSERT INTO `users_messages` SET
`id_author`=' . (int) $id_author . ',
`time`=' . $time . ',
`subject`=' . Database::escape($subject) . ',
`html`=' . Database::escape($body);
Database::query($query);
// если есть тред - пишем в тот же тред
$lastId = Database::lastInsertId();
$thread_id = $thread_id ? $thread_id : $lastId;
if ($thread_id) {
$q = array();
foreach ($to_users as $receiver_id) {
if (!(int) $receiver_id) {
continue;
}
$to_user = new User($receiver_id);
$to_user->reloadNewMessagesCount();
$is_new = $receiver_id == $id_author ? 0 : 1;
$q[] = '(' . (int) $lastId . ',' . (int) $thread_id . ',' . (int) $receiver_id . ',' . (int) $is_new . ',0,' . (int) $type . ')';
}
if (count($q)) {
$query = 'INSERT INTO `users_messages_index`(message_id,thread_id,id_recipient,is_new,is_deleted,type) VALUES ' . implode(',', $q);
Database::query($query);
}
}
// increase counters
$receivers = Users::getByIdsLoaded($to_users);
foreach ($receivers as $receiver) {
/* @var $receiver User */
if ($type == 0) {
$receiver->setCounter('new_messages', $receiver->getCounter('new_messages') + 1);
} else {
$receiver->setCounter('new_notifications', $receiver->getCounter('new_notifications') + 1);
}
$receiver->save();
}
if ($type == 0 && $current_user) {
// не нотифай
Notify::notifyNewInbox($to_users, $id_author);
}
Database::query('COMMIT');
}