本文整理汇总了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');
}