本文整理汇总了PHP中Message::sendMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::sendMessage方法的具体用法?PHP Message::sendMessage怎么用?PHP Message::sendMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message
的用法示例。
在下文中一共展示了Message::sendMessage方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionSend
public function actionSend($type = 'private', $toUserId = null)
{
$types = array('system', 'user', 'private', 'group');
RAssert::is_true(in_array($type, $types));
$data = array('type' => $type);
if ($toUserId != null) {
$data['toUser'] = User::get($toUserId);
}
if (Rays::isPost()) {
if (isset($_POST['new'])) {
if (isset($_POST['receiverName'])) {
$data['sendForm'] = array('receiver' => $_POST['receiverName']);
}
$this->render('send', $data, false);
return;
}
$form = $_POST;
$config = array(array('field' => 'title', 'label' => 'Title', 'rules' => 'trim|required'), array('field' => 'msg-content', 'label' => 'Content', 'rules' => 'trim|required'), array('field' => 'receiver', 'label' => 'Receiver', 'rules' => 'required'), array('field' => 'type', 'label' => 'Message type', 'rules' => 'trim|required'));
$validation = new RValidation($config);
if ($validation->run()) {
$receiver = User::find("name", $_POST['receiver'])->first();
if ($receiver == null) {
$this->flash("error", "No such user.");
} else {
$senderId = 0;
if (isset($_POST['sender'])) {
//mainly for group and system message
$senderId = $_POST['sender'];
} else {
$senderId = Rays::user()->id;
}
$title = isset($_POST['title']) ? trim($_POST['title']) : "";
$msgContent = RHtml::encode($_POST['msg-content']);
$message = Message::sendMessage($_POST['type'], $senderId, $receiver->id, $title, $msgContent, null, 1);
if (isset($message->id) && $message->id != '') {
$this->flash("message", "Send message successfully.");
$this->redirectAction('message', 'view');
return;
} else {
$this->flash("message", "Send message failed.");
}
}
}
$data['sendForm'] = $form;
if ($validation->getErrors() != '') {
$data['validation_errors'] = $validation->getErrors();
}
}
$this->render('send', $data, false);
}
示例2: send
public function send()
{
new Protect('ajax');
if (Input::exists()) {
if (Token::ajaxCheck(Input::post('token'))) {
// TODO: Check for empty messages, Validate messages
$username = Input::post('username');
$msg = Input::post('msg');
if (!empty($username)) {
Message::sendMessage($username, $msg);
Notif::raiseMsgNotif(User::getPublicUserId($username));
} else {
return 'Username Required';
}
} else {
return 'Security Token Missing';
}
}
return FALSE;
}
示例3: composeAction
public function composeAction()
{
global $mySession;
$db = new Db();
$userId = $this->getRequest()->getParam("rId");
$myform = new Form_Compose(0, $userId != "" ? $userId : "");
$this->view->myform = $myform;
$this->view->pageHeading = "Compose Message";
if ($this->getRequest()->isPost()) {
$request = $this->getRequest();
if ($myform->isValid($request->getPost())) {
$dataForm = $myform->getValues();
$myObj = new Message();
$Result = $myObj->sendMessage($dataForm);
if ($Result == 1) {
$mySession->sucessMsg = "Message Sucessfully sent";
$this->_redirect("msgs/sent");
} else {
$mySession->errorMsg = "Error in sending message";
}
}
}
}
示例4: sendMessage
/**
* Send a new message to the conversation's members
* @param Player $from The sender
* @param string $message The body of the message
* @param string $status The status of the message - can be 'visible', 'hidden', 'deleted' or 'reported'
* @return Message An object that represents the sent message
*/
public function sendMessage($from, $message, $status = 'visible')
{
$message = Message::sendMessage($this->getId(), $from->getId(), $message, $status);
$this->updateLastActivity();
return $message;
}
示例5: Template
require 'core/init.php';
$template = new Template();
$user = new User();
$message = new Message();
if (isset($_POST['login'])) {
$data = array();
$data['username'] = $_POST['username'];
$data['password'] = $_POST['password'];
if ($user->login($data)) {
$_SESSION['username'] = $data['username'];
} else {
$template->wrongpassword = "Wrong password!";
}
}
if (isset($_POST['logout'])) {
$user->logout($_SESSION['username']);
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['message'])) {
$data['username'] = $_SESSION['username'];
$data['message'] = $_POST['message'];
$data['time'] = date('h:i:s a', time());
$message->sendMessage($data);
}
$template->messages = $message->getMessages();
if (!empty($_SESSION['username'])) {
$template->title = "Messenger";
$template->render('welcome.php');
} else {
$template->title = "Login";
$template->render('index.php');
}
示例6: trim
require_once "../../common.php";
require_once "../classes/class.Message.php";
$log = new System\Login(1);
if (isset($_GET['a']) && isset($_GET['u'])) {
$backlink = trim(htmlentities($_GET['a'], ENT_QUOTES, "UTF-8"));
$backlink = $GLOBALS['DB']->escapeString($backlink);
$toUser = trim(htmlentities($_GET['u'], ENT_QUOTES, "UTF-8"));
$toUser = $GLOBALS['DB']->escapeString($toUser);
$fromUser = trim(htmlentities($_SESSION['userID'], ENT_QUOTES, "UTF-8"));
$fromUser = $GLOBALS['DB']->escapeString($fromUser);
if ($toUser == $fromUser) {
die;
}
$message = new Message();
$message->sendMessage($fromUser, "../article/showarticle.php?a={$backlink}");
System\HTML::printHead();
System\HTML::printHeader();
?>
<div role="main" class="main">
<section class="page-top">
<div class="container">
<div class="row">
<div class="span12">
<ul class="breadcrumb">
<li><a href="../../index.php">Startseite</a> <span class="divider">/</span></li>
<li class="active">Nachricht senden</li>
</ul>
</div>
示例7: actionDecline
public function actionDecline($userId = null)
{
$uid = Rays::user()->id;
$userName = Rays::user()->name;
//only request exist can friendship be declined
$censor = (new Censor())->addFriendExist($userId, $uid);
if ($censor === null) {
$this->flash('warning', 'Request already processed');
} else {
$censor->fail();
$content = RHtml::linkAction('user', $userName, 'view', $uid) . " has declined your friend request.";
Message::sendMessage("system", $uid, $userId, "Friend request declined", $content, '');
$this->flash('message', 'Friend request declined.');
}
$this->redirectAction('message', 'view', null);
}
示例8: actionDecline
public function actionDecline($censorId = null)
{
$censor = Censor::get($censorId);
if ($censor !== null) {
$groupUser = new GroupUser();
$groupUser->groupId = $censor->secondId;
$groupUser->userId = $censor->firstId;
$groupUser->joinTime = date('Y-m-d H:i:s');
$groupUser->status = 1;
if (!GroupUser::isUserInGroup($groupUser->userId, $groupUser->groupId)) {
$this->flash("message", "The request is processed.");
$group = Group::get($groupUser->groupId);
$title = "Join group request declined";
$content = 'Group creator have declined your request of joining in group ' . RHtml::linkAction('group', $group->name, 'detail', $group->id);
$content = RHtml::encode($content);
Message::sendMessage("group", $group->id, $groupUser->userId, $title, $content);
} else {
$this->flash("warning", "TA is already a member of this group.");
}
$censor->fail();
$this->redirectAction('message', 'view');
}
}
示例9: actionProcessVIP
/**
* Process VIP
* by songrenchu
*/
public function actionProcessVIP()
{
$this->setHeaderTitle('Censor VIP');
$this->layout = 'admin';
$data = array();
if (isset($_GET['censorId']) && isset($_GET['op'])) {
$censor = Censor::get($_GET['censorId']);
if ($censor !== null) {
if ((int) $_GET['op'] === 0) {
$user = User::get($censor->firstId);
$user->roleId = Role::VIP_ID;
$user->save();
$censor->pass();
$content = "Congratulations, " . RHtml::linkAction('user', $user->name, 'view', $user->id) . "!<br/> Your VIP application is accepted by Administrator.";
Message::sendMessage("system", 0, $user->id, "VIP application accepted", RHtml::encode($content), '');
} else {
$censor->fail();
$user = User::get($censor->firstId);
$content = "Sorry, " . RHtml::linkAction('user', $user->name, 'view', $user->id) . "!<br/> Your VIP application is declined by Administrator.";
Message::sendMessage("system", 0, $user->id, "VIP application declined", RHtml::encode($content), '');
}
}
$this->redirectAction('user', 'processVIP');
}
$curPage = $this->getPage("page");
$pageSize = $this->getPageSize("pagesize", 5);
$query = Censor::find(['status', Censor::UNPROCESS, 'typeId', (new Censor())->getTypeId("apply_vip")]);
$count = $data['count'] = $query->count();
$applications = $query->order_desc("id")->range(($curPage - 1) * $pageSize, $pageSize);
$data['applications'] = $applications;
$users = [];
foreach ($applications as $apply) {
$user = User::get($apply->firstId);
$users[] = $user;
}
$data['users'] = $users;
$url = RHtml::siteUrl('user/processVIP');
$pager = new RPager('page', $count, $pageSize, $url, $curPage);
$pager = $pager->showPager();
$data['pager'] = $pager;
$this->render('process_vip', $data, false);
}
示例10: dirname
<?php
/**
* To send a reply message to user
*
* @file /lib/weixin/admin/message/send_reply.php
* @author KavMors(kavmors@163.com)
* @version 2015-3-12
*/
//POST: reply, user, time
if (!isset($_POST['reply']) || !isset($_POST['user']) || !isset($_POST['time'])) {
exit;
}
include_once dirname(__FILE__) . '/message.php';
include_once dirname(__FILE__) . '/../../user/custom.php';
$message = new Message();
if ($message->sendMessage($_POST['user'], $_POST['time'], $_POST['reply']) === false) {
exit;
}
$json = (new Custom($_POST['user']))->send($_POST['reply']);
$json_obj = json_decode($json);
if ($json_obj->errcode == 0) {
echo $_POST['user'];
} else {
echo $json;
}
示例11: Message
<?php
require_once "../../common.php";
require_once "../classes/class.Message.php";
$log = new System\Login(1);
$message = new Message();
if (isset($_GET['m'])) {
$messageID = trim(htmlentities($_GET['m'], ENT_QUOTES, "UTF-8"));
$messageID = $GLOBALS['DB']->escapeString($messageID);
} else {
header("Location: ../../404.php");
exit;
}
$message->sendMessage($_SESSION['userID'], "showallmessages.php");
System\HTML::printHead();
System\HTML::printHeader();
?>
<div role="main" class="main">
<section class="page-top">
<div class="container">
<div class="row">
<div class="span12">
<ul class="breadcrumb">
<li><a href="../../index.php">Startseite</a> <span class="divider">/</span></li>
<li class="active">Nachricht</li>
</ul>
</div>
</div>
<div class="row">
示例12: actionComment
public function actionComment($topicId)
{
$topic = Topic::get($topicId);
if (Rays::isPost()) {
$validation = new RValidation(array(array('field' => 'content', 'label' => 'Content', 'rules' => 'trim|required')));
if (!$validation->run()) {
$this->flash("error", "Comment content cannot be empty!");
$this->redirectAction('post', 'view', $topicId);
}
$form = $_POST;
$topic->commentCount++;
$topic->lastCommentTime = date('Y-m-d H:i:s');
$topic->save();
$user = Rays::user();
$comment = new Comment();
$comment->topicId = $topicId;
$comment->userId = $user->id;
$comment->createdTime = date('Y-m-d H:i:s');
$comment->content = $form["content"];
if (isset($form['replyTo'])) {
$comment->pid = (int) $form['replyTo'];
} else {
$comment->pid = 0;
}
$comment->save();
$cid = $comment->id;
if (isset($form['replyTo'])) {
$exactComment = Comment::get($form['exactReplyTo']);
Message::sendMessage('user', $user->id, $exactComment->userId, 'New reply', $user->name . ' has replied to your comment ' . RHtml::linkAction('post', $topic->title, 'view', $topic->id . '?reply=' . $cid));
} else {
if ($topic->userId !== $user->id) {
//send message to topic author
Message::sendMessage('user', $user->id, $topic->userId, 'New Comment', $user->name . ' has replied to your topic ' . RHtml::linkAction('post', $topic->title, 'view', $topic->id . '?reply=' . $cid));
}
}
}
$this->redirectAction('post', 'view', $topicId);
}
示例13: recommendGroups
/**
* Recommend all selected groups to every selected users
* @param $groups
* @param $users
*/
public static function recommendGroups($groups, $users, $words = '')
{
foreach ($users as $userId) {
$html = '<div class="row recommend-groups">';
$count = 0;
if (!empty($groups)) {
foreach ($groups as $groupId) {
if ($count % 4 == 0) {
if ($count > 0) {
$html .= '</div><div class="clearfix" style="margin-top: 15px;"></div>';
}
$html .= '<div class="row">';
}
$group = Group::get($groupId);
if (null != $group) {
$censor = new Censor();
$censor = $censor->joinGroupApplication($userId, $group->id);
$html .= '<div class="col-lg-3 recommend-group-item" style="padding: 5px;overflow: hidden;">';
$picture = isset($group->picture) && $group->picture != '' ? $group->picture : Group::$defaults['picture'];
$src = RImage::styleSrc($picture, Group::getPicOptions());
$html .= RHtml::image($src, $group->name);
$html .= '<br/>' . RHtml::linkAction('group', $group->name, 'detail', $group->id);
$html .= '<br/>' . RHtml::linkAction('group', 'Accept', 'accept', $censor->id, array('class' => 'btn btn-xs btn-success'));
$html .= '</div>';
$count++;
}
}
$html .= '</div>';
}
$html .= '</div>';
$html .= '<div class="recommend-content">' . RHtml::encode($words) . '</div>';
Message::sendMessage('system', 0, $userId, 'Groups recommendation', $html, date('Y-m-d H:i:s'));
}
}
示例14: foreach
<input type="hidden" name="tweet_id" value="' . $tweet['id'] . '">
<input type="submit" value="Dodaj komentarz">
</form>
';
$comment_counter = 0;
//licznik komentarzy zawsze zaczyna od zera
foreach (Comment::loadAllComments($tweet['id']) as $comment) {
$comment_counter++;
//zliczanie ilosci komentarzy
}
echo '<div class="comment">Ilość komentarzy: ' . $comment_counter . '<a href="show_post.php?tweetId=' . $tweet['id'] . '&userName=' . $userToShow->getName() . '"> POKAŻ WIĘCEJ</a></div>';
echo '<div style=" margin: 60px 0px"></div>';
}
if ($_SERVER['REQUEST_METHOD'] === 'POST' && $_POST['forms'] == 'sending_message') {
if ($_POST['message'] != null) {
Message::sendMessage($currentlyLoggedUser->getId(), $_POST['receiver'], $_POST['message'], date('Y-m-d G:i:s'));
header('Location: showUser.php?userId=' . $_POST['receiver']);
}
}
if ($_SERVER['REQUEST_METHOD'] === 'POST' && $_POST['forms'] == 'adding_comment') {
Comment::addComment($_POST['tweet_id'], $currentlyLoggedUser->getId(), $_POST['comment'], date('Y-m-d G:i:s'));
}
if ($_SERVER['REQUEST_METHOD'] === 'POST' && $_POST['forms'] == 'adding_tweet') {
if ($_POST['tweet_text'] != null) {
Tweet::create($currentlyLoggedUser->getId(), $_POST['tweet_text'], date('Y-m-d G:i:s'));
header('Location: showUser.php');
} else {
echo 'Twoj tweet jest pusty, jeżeli chcesz go wysłać to wprowadź do niego tekst';
}
}
}