本文整理汇总了PHP中Message::getMessages方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::getMessages方法的具体用法?PHP Message::getMessages怎么用?PHP Message::getMessages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message
的用法示例。
在下文中一共展示了Message::getMessages方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _index
public function _index()
{
// Deny access if not logged in
new Protect('ajax');
$post = Input::post();
$token = Token::ajaxCheck($post['token']);
$data['success'] = FALSE;
$data['errors'] = NULL;
if (!empty($post['username'] && $token === TRUE)) {
$msgs = Message::getMessages($post['username']);
$data['success'] = TRUE;
foreach ($msgs as $key => $value) {
$msgs[$key]['time'] = date("d-M h:i A", $value['time']);
}
$data['msgs'] = $msgs;
Message::read(User::getPublicUserId($post['username']));
//TODO: Replace with function
DB::updateIf('msg_notif', array('status' => 1), array('user_id' => User::getPublicUserId($post['username']), 'to_id' => Session::get('user_id')));
} else {
if (!$token) {
$data['errors'][] = 'Security Token Missing';
} else {
$data['errors'][] = 'Username Required';
}
}
if (!empty($data)) {
return $data;
} else {
return FALSE;
}
}
示例2: sendSysMessageAction
public function sendSysMessageAction()
{
if ($this->request->isPost() == true) {
$ans = [];
$acceptIds = $this->request->getPost("auth-group");
$messageContent = $this->request->getPost("data");
$messageTilte = $this->request->getPost("title");
$messageType = 1;
//系统消息
$successCount = 0;
$curUserId = $this->session->get('userId');
if ($curUserId != null) {
foreach ($acceptIds as $userId) {
$existUser = User::find(array("conditions" => "id=?1", "bind" => array(1 => $userId)));
if (count($existUser) == 0) {
$ans['error'] = 701;
} else {
$InsertMessage = new Message();
$InsertMessage->to_id = $userId;
$InsertMessage->from_id = $curUserId;
$InsertMessage->type = $messageType;
$InsertMessage->data = $messageContent;
if ($InsertMessage->save == true) {
$successCount++;
} else {
foreach ($InsertMessage->getMessages() as $message) {
throw new BaseException($message, 100);
}
}
}
}
if ($successCount == count($acceptIds)) {
$ans['ret'] = -1;
} else {
$ans['ret'] = $successCount;
}
} else {
$ans['error'] = 103;
$ans['ret'] = 0;
}
echo json_encode($ans);
}
}
示例3: __construct
public function __construct($url)
{
$user_data = User::getUserData(['username', 'first_name', 'last_name', 'user_id', 'email', 'profile_pic'])[0];
$this->data['first_name'] = ucwords($user_data['first_name']);
$this->data['last_name'] = ucwords($user_data['last_name']);
$this->data['side_active']['messages'] = ' active';
$this->data['profile_pic'] = User::getProfilePic($user_data['profile_pic']);
require_once 'include/header.php';
$this->data['title'] = 'Messages - Ncube';
$this->data['token'] = Token::generate();
$this->data['active_username'] = $url[0];
$this->data['list_data'] = User::getAcceptedUsersData();
if (!empty($url[0])) {
$data = Message::getMessages($url[0]);
foreach ($data as $key => $value) {
$data[$key]['time'] = date("h:i A", $value['time']);
}
$this->data['msgs'] = $data;
}
$this->data['recipient'] = $url[0];
}
示例4: extract
extract($data);
}
include $file;
}
// Load todo class
$todo = new Todo();
// Add todo
if (isset($_POST['addTodo'])) {
if ($_POST['description'] !== '') {
$description = $_POST['description'];
$todo->add($description);
} else {
Message::setMessage('Ahh, damn. Lege todos zijn niet toegestaan...', 'error');
}
}
// Check activation
if (isset($_POST['toggleTodo'])) {
$id = $_POST['toggleTodo'];
$todo->toggle($id);
}
// Delete todo
if (isset($_POST['deleteTodo'])) {
$id = $_POST['deleteTodo'];
$todo->delete($id);
}
// Load todos
$todoItems = $todo->getActiveItems(false);
$doneItems = $todo->getActiveItems(true);
view('header.view.php', array('title' => 'Todo App', 'messages' => Message::getMessages()));
view('body.view.php', array('todoItems' => $todoItems, 'doneItems' => $doneItems));
view('footer.view.php');
示例5: addAction
public function addAction()
{
$this->view->disable();
function valid_form_offer()
{
$sub_mess = '';
//if ($this->security->checkToken()) {}
if (isset($_POST['text_answer']) && strlen($_POST['text_answer']) < 2) {
$sub_mess['text_offer'] = 'Введите текст сообщения';
}
if (is_array($sub_mess)) {
echo json_encode($sub_mess);
return false;
} else {
return true;
}
}
if (valid_form_offer()) {
$dialog_id = $this->request->getPost('dialog');
$text_answer = $this->request->getPost('text_answer');
$user_id = $this->session->get('user_id');
// Если НЕТ: создать диалог -> связь -> сообщение привязанное к диалогу
// Если ЕСТЬ: создать сообщение привязанное к диалогу
$dialog = Dialogs::findFirst($dialog_id);
if (isset($dialog->id)) {
$message = new Message();
$message->dialogs_id = $dialog_id;
$message->text = $text_answer;
$message->creation_date = date("Y-m-d-H-i-s");
$message->author_id = $user_id;
$message->save();
if ($message->save() == false) {
foreach ($message->getMessages() as $message) {
echo $message;
exit;
}
}
} else {
$dialog = new Dialogs();
$dialog->creation_date;
$dialog->save();
if ($dialog->save() == false) {
foreach ($dialog->getMessages() as $message) {
echo $message;
exit;
}
}
$dialogsHasUser = new DialogsHasUser();
$dialogsHasUser->dialogs_id = $dialog->id;
$dialogsHasUser->user_id = $user_id;
$dialogsHasUser->save();
if ($dialogsHasUser->save() == false) {
foreach ($dialogsHasUser->getMessages() as $message) {
echo $message;
exit;
}
}
$message = new Message();
$message->dialogs_id = $dialog_id;
$message->text = $text_answer;
$message->creation_date = date("Y-m-d-H-i-s");
$message->author_id = $user_id;
$message->save();
if ($message->save() == false) {
foreach ($message->getMessages() as $message) {
echo $message;
exit;
}
}
}
echo '1';
}
}
示例6: getMainBoardMessages
public static function getMainBoardMessages($n, $lid = false, $get_tnews = true, $get_summaries = true)
{
global $settings;
$board = array();
// First we add all commissioner messages to the board structure.
foreach (Message::getMessages($n, $lid) as $m) {
$o = (object) array();
// Specific fields:
$o->msg_id = $m->msg_id;
$o->author_id = $m->f_coach_id;
// General fields:
$o->cssidx = T_HTMLBOX_ADMIN;
// CSS box index
$o->type = T_TEXT_MSG;
$o->author = get_alt_col('coaches', 'coach_id', $m->f_coach_id, 'name');
$o->title = $m->title;
$o->message = $m->message;
$o->date = $m->date_posted;
$o->pinned = $m->pinned;
array_push($board, $o);
}
// Now we add all game summaries.
if ($get_summaries) {
foreach (MatchSummary::getSummaries($n, $lid) as $r) {
$o = (object) array();
$m = new Match($r->match_id);
// Specific fields:
$o->date_mod = $m->date_modified;
$o->match_id = $m->match_id;
// General fields:
$o->cssidx = T_HTMLBOX_MATCH;
// CSS box index
$o->type = T_TEXT_MATCH_SUMMARY;
$o->author = get_alt_col('coaches', 'coach_id', $m->submitter_id, 'name');
$o->title = "Match: {$m->team1_name} {$m->team1_score}—{$m->team2_score} {$m->team2_name}";
$o->message = $m->getText();
$o->date = $m->date_played;
$o->pinned = 0;
// Not allowed for other types than board messages
array_push($board, $o);
}
}
// And finally team news.
if ($get_tnews) {
foreach (TeamNews::getNews(false, $n, $lid) as $t) {
$o = (object) array();
// Specific fields:
# none
// General fields:
$o->cssidx = T_HTMLBOX_INFO;
// CSS box index
$o->type = T_TEXT_TNEWS;
$o->author = get_alt_col('teams', 'team_id', $t->f_id, 'name');
$o->title = "Team news: {$o->author}";
$o->message = $t->txt;
$o->date = $t->date;
$o->pinned = 0;
// Not allowed for other types than board messages
array_push($board, $o);
}
}
// Last touch on the board.
if (!empty($board)) {
objsort($board, array('-pinned', '-date'));
if ($n) {
$board = array_slice($board, 0, $n);
}
}
return $board;
}
示例7: generateNewsRssFeed
/**
* Generates the newsfeed and writes it to disc.
*
*/
public function generateNewsRssFeed()
{
$dom = new DOMDocument();
$dom->formatOutput = true;
$el_root = $dom->appendChild($dom->createElement('rss'));
$el_root->setAttribute('version', '2.0');
$el_channel = $el_root->appendChild($dom->createElement('channel'));
$el_channel->appendChild($dom->createElement('title', $this->title));
$el_channel->appendChild($dom->createElement('link', $this->link));
$el_channel->appendChild($dom->createElement('description', $this->desc));
if ($this->lang != '') {
$el_channel->appendChild($dom->createElement('language', $this->lang));
}
$el_channel->appendChild($dom->createElement('docs', $this->docs));
$el_channel->appendChild($dom->createElement('lastBuildDate', date(DATE_RSS)));
$el_channel->appendChild($dom->createElement('generator', 'OBBLM ' . OBBLM_VERSION));
$entries = array();
foreach ($this->type as $t) {
$obj = (object) null;
switch ($t) {
case T_TEXT_MSG:
foreach (Message::getMessages(RSS_SIZE) as $item) {
$entries[] = (object) array('title' => "Announcement by " . get_alt_col('coaches', 'coach_id', $item->f_coach_id, 'name') . ": {$item->title}", 'desc' => $item->message, 'date' => $item->date);
}
break;
case 'HOF':
if (Module::isRegistered('HOF')) {
foreach (Module::run('HOF', array('getHOF', false, RSS_SIZE)) as $item) {
$item = $item['hof'];
$entries[] = (object) array('title' => "HOF entry for " . get_alt_col('players', 'player_id', $item->pid, 'name') . ": {$item->title}", 'desc' => $item->about, 'date' => $item->date);
}
}
break;
case 'Wanted':
if (Module::isRegistered('Wanted')) {
foreach (Module::run('Wanted', array('getWanted', false, RSS_SIZE)) as $item) {
$item = $item['wanted'];
$entries[] = (object) array('title' => "Wanted entry for " . get_alt_col('players', 'player_id', $item->pid, 'name') . ": {$item->bounty}", 'desc' => $item->why, 'date' => $item->date);
}
}
break;
case T_TEXT_MATCH_SUMMARY:
foreach (MatchSummary::getSummaries(RSS_SIZE) as $item) {
$m = new Match($item->match_id);
$entries[] = (object) array('title' => "Match: {$m->team1_name} ({$m->team1_score}) vs. {$m->team2_name} ({$m->team2_score})", 'desc' => $m->getText(), 'date' => $m->date_played);
}
break;
case T_TEXT_TNEWS:
foreach (TeamNews::getNews(false, RSS_SIZE) as $item) {
$entries[] = (object) array('title' => "Team news by " . get_alt_col('teams', 'team_id', $item->f_id, 'name'), 'desc' => $item->txt, 'date' => $item->date);
}
break;
}
}
objsort($entries, array('-date'));
foreach (array_slice($entries, 0, RSS_SIZE) as $item) {
$el_item = $dom->createElement('item');
$el_item->appendChild($dom->createElement('title', htmlspecialchars($item->title, ENT_NOQUOTES, "UTF-8")));
$el_item->appendChild($dom->createElement('description', htmlspecialchars($item->desc, ENT_NOQUOTES, "UTF-8")));
$el_item->appendChild($dom->createElement('link', $this->link));
# $el_item->appendChild($dom->createElement('pubDate', $item->date));
$el_item->appendChild($dom->createElement('pubDate', date('r', strtotime($item->date))));
$el_item->appendChild($dom->createElement('guid', $this->link . 'index.php?' . date('U', strtotime($item->date))));
# RSS 2.0 dirty workaround.
$el_channel->appendChild($el_item);
}
// Write the file
$handle = fopen("rss.xml", "w");
fwrite($handle, $dom->saveXML());
fclose($handle);
return $dom->saveXML();
}
示例8: 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');
}