本文整理汇总了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") {
示例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);
}