当前位置: 首页>>代码示例>>PHP>>正文


PHP Notify::notifyNewInbox方法代码示例

本文整理汇总了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');
    }
开发者ID:rasstroen,项目名称:metro,代码行数:49,代码来源:MessagesWriteModule.php


注:本文中的Notify::notifyNewInbox方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。