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


PHP Chat::getID方法代码示例

本文整理汇总了PHP中Chat::getID方法的典型用法代码示例。如果您正苦于以下问题:PHP Chat::getID方法的具体用法?PHP Chat::getID怎么用?PHP Chat::getID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Chat的用法示例。


在下文中一共展示了Chat::getID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: User

$new_message = null;
$notif_alert = null;
$end_product = null;
if (Tools::isUserLogged()) {
    $user = new User($_SESSION['id']);
    if (Tools::valuePost("chat_id")) {
        $chat = new Chat(Tools::valuePost("chat_id"));
        if (Tools::valuePost("action") == "check_chat") {
            /*GET NEW CHAT MESSAGES FROM THE SERVER*/
            $lastChat = Tools::valuePost("lastChat");
            //echo ($_POST['lastChat']);
            if (Tools::valuePost("lastChat") == 'undefined') {
                $lastChat = 0;
            }
            if ($messages = $chat->getMessagesFrom($lastChat, $user->getID())) {
                $user->clearChatNotification($chat->getID());
                foreach ($messages as $id) {
                    $message = new Message($id);
                    $sender = new User($message->getSenderID());
                    $time = strtotime($message->getTime());
                    $new_message .= "\n                        <div id=\"{$id}\" class=\"animated fadeIn chatbox-user right\">\n                            <a href=\"javascript:;\" class=\"chat-avatar pull-right\"> \n                                <img src=\"img/faceless.jpg\" class=\"img-circle\" title=\"user name\" alt=\"\">\n                            </a>\n\n                            <div class=\"message\">\n                                <div class=\"panel\">\n                                    <div class=\"panel-heading\">\n                                        {$sender->getFullName()}\n                                    </div>\n\n                                    <div class=\"panel-body\">\n                                        <p>{$message->getMessage()}</p>\n                                    </div>\n                                </div>\n\n                                <small class=\"chat-time\">\n                                <i class=\"ti-time mr5\"></i>\n                                <span data-livestamp=\"{$time}\"></span>\n                                <i class=\"ti-check text-success\"></i>\n                                </small>\n\n                            </div>\n                        </div>";
                }
                echo $new_message;
            }
        } elseif (Tools::valuePost("action") == "send_chat") {
            /*SEND NEW CHAT MESSAGE TO THE SERVER*/
            if (!empty(Tools::valuePost("message"))) {
                echo $chat->sendMessage($user->getID(), Tools::valuePost("message"));
            }
        }
    } elseif (Tools::valuePost("action") == "notification") {
开发者ID:sheyooo,项目名称:gradeaccess,代码行数:31,代码来源:ajax_chat.php

示例2: sendChat

function sendChat($pageId)
{
    $from = $_SESSION['username'];
    $to = Filter::text($_POST['to']);
    $message = $_POST['message'];
    $_SESSION['openChatBoxes'][$to] = date('Y-m-d H:i:s', time());
    $fromUsername = User::load($from)->getUsername();
    $messagesan = sanitize($message);
    if (!isset($_SESSION['chatHistory'][$to])) {
        $_SESSION['chatHistory'][$to] = '';
    }
    $_SESSION['chatHistory'][$to] .= <<<EOD
\t\t\t\t\t   {
\t\t\t"s": "1",
\t\t\t"f": "{$fromUsername}",
\t\t\t"m": "{$messagesan}"
\t   },
EOD;
    unset($_SESSION['tsChatBoxes'][$to]);
    $chat = new Chat(array('sender' => mysql_real_escape_string($from), 'recipient' => mysql_real_escape_string($to), 'message' => mysql_real_escape_string($messagesan), 'sent' => '2013-05-03 12:02:48'));
    $chat->save();
    $newId = $chat->getID();
    if (empty($_SESSION['openChatBoxes']["{$pageId}"])) {
        $_SESSION['openChatBoxes']["{$pageId}"] = $newId;
    } else {
        if ($newId - 1 == $_SESSION['openChatBoxes']["{$pageId}"]) {
            $_SESSION['openChatBoxes']["{$pageId}"] = $newId;
        }
    }
    echo formatParagraphs($messagesan, true);
    exit(0);
}
开发者ID:malimu,项目名称:Pipeline,代码行数:32,代码来源:chat.php


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