/** * Validates a message from SNS to ensure that it was delivered by AWS * * @param Message $message The message to validate * * @throws CannotGetPublicKeyFromCertificateException If the certificate cannot be retrieved * @throws CertificateFromUnrecognizedSourceException If the certificate's source cannot be verified * @throws InvalidMessageSignatureException If the message's signature is invalid */ public function validate($message) { // Get the cert's URL and ensure it is from AWS $certUrl = $message->get('SigningCertURL'); $host = parse_url($certUrl, PHP_URL_HOST); if ('.amazonaws.com' != substr($host, -14)) { throw new CertificateFromUnrecognizedSourceException($host . ' did not match .amazonaws.com'); } // Get the cert itself and extract the public key $response = wp_remote_get($certUrl); if (is_wp_error($response)) { throw new CannotGetPublicKeyFromCertificateException('Could not retrieve certificate from ' . $certUrl); } $certificate = wp_remote_retrieve_body($response); $publicKey = openssl_get_publickey($certificate); if (!$publicKey) { throw new CannotGetPublicKeyFromCertificateException('Could not extract public key from ' . $certUrl); } // Verify the signature of the message $stringToSign = $message->getStringToSign(); $incomingSignature = base64_decode($message->get('Signature')); if (!openssl_verify($stringToSign, $incomingSignature, $publicKey, OPENSSL_ALGO_SHA1)) { throw new InvalidMessageSignatureException('The message did not match the signature ' . "\n" . $stringToSign); } }
/** * Confirms subscription * * @param Message $message * @throws Exception */ private function _subscription_confirmation($message) { $topic_arn = $this->_config->get_string('cluster.messagebus.sns.topic_arn'); if ($topic_arn != $message->get('TopicArn')) { throw new Exception('Not my Topic. My is ' . $this->_topic_arn . ' while request came from ' . $message->get('TopicArn')); } $this->_log('Issuing confirm_subscription'); $response = $this->_get_api()->confirm_subscription($topic_arn, $message->get('Token')); $this->_log('Subscription confirmed: ' . ($response->isOK() ? 'OK' : 'Error')); }
/** * Transforms an array of elastica objects into an array of * model objects fetched from the doctrine repository * * @param array $elasticaObjects of elastica objects * @throws \RuntimeException * @return array **/ public function transform(array $elasticaObjects) { $objects = array(); foreach ($elasticaObjects as $elasticaObject) { $objects[] = \Message::get($elasticaObject->getId()); } return $objects; }
public function get_json() { $o = new stdClass(); $o->friends = Friendship::pending($this->session->user->id); $o->notifications = Notification::from_user($this->session->user->id, 15); $o->messages = Message::get($this->session->user->id, 10); header("Content-type: text/html; charset=utf-8"); die('(' . json_encode($o) . ');'); }
public function renderGuest($roomId) { $messages = new Message(); $this->bag->messages = $messages->get($roomId); $this->bag->room = $this->room->getDescription($roomId); // glitch fix I can haz? if ($this->guestUser instanceof User) { $this->bag->userId = $this->guestUser->getId(); $this->bag->shortName = $this->guestUser->getShortName(); } }
public function before() { //$this->redirect('http://ehistory.kz/manage'); parent::before(); $this->response->headers('cache-control', 'private'); // creating and attaching page metadata $this->metadata = new Model_Metadata(); $this->metadata->title(__(Application::instance()->get('title')), false); $this->set('_metadata', $this->metadata); Auth::instance()->auto_login(); if (!Auth::instance()->logged_in()) { $this->redirect('manage/auth/login'); } else { $id = Auth::instance()->get_user()->id; $user = ORM::factory('user', $id); $input = $user->has('roles', ORM::factory('role', array('name' => 'admin'))) || $user->has('roles', ORM::factory('Role', array('name' => 'moderator'))); $input_redactor = $user->has('roles', ORM::factory('Role', array('name' => 'redactor'))); if (!$input && !$input_redactor) { $this->redirect('/manage/auth/logout'); } if (!$input && (strtolower($this->request->controller()) != 'ehistory' && strtolower($this->request->controller()) != 'language')) { $this->redirect('manage/ehistory'); } } $this->user = Auth::instance()->get_user(); if (Request::$initial === Request::$current) { $messages = Notify::instance()->get_all_once(); $this->set('_notifications', $messages); } $language = Session::instance()->get('_language', 'ru'); $this->language = in_array($language, array('ru', 'en', 'kz')) ? $language : 'ru'; I18n::lang($this->language); $rr = Request::initial()->uri() . urlencode(URL::query(null, true)); $rr = trim($rr, '/'); //$this->metadata->title('Sharua.kz', false); $countcomm = ORM::factory('Comment')->where('status', '=', '0')->count_all(); //смотрим сколько новых коментов $this->set('_user', $this->user)->set('_language', $this->language)->set('_return_url', $rr)->set('_countcomm', $countcomm); //вносим в переменную количество новых коментов $knigi = ORM::factory('Book')->where('category_id', '=', '0')->find_all(); //смотрим сколько книг без категории if ($knigi) { if (count($knigi) > 0) { $this->set('_uncatcount', count($knigi)); //вносим в переменную количество книг без категории } } $this->referrer = Request::initial()->referrer(); if (Message::get()) { $this->set('basic_message', Message::display('/message/basic')); } }
public function actionYourPosts() { if ($this->session->get('author_id')) { $post = new Post(); $records = $post->GetAllPostByAuthor($this->session->get('author_id')); if (empty($records)) { $message = new Message('У вас пока нет постов!'); $this->html->add('content', $message->get()); $layout = new Layout($this->html->getArray()); $layout->get(); } else { $this->view = new View($records, PATH_VIEW_POSTS, 'index_tpl.php', false); $this->html->add('content', $this->view->render()); $layout = new Layout($this->html->getArray()); $layout->get(); } } }
public function getMessages() { $messages = Message::get(); $id = Auth::user()->id; $query = 'SELECT m.addressee_id, m.sender_id, m.message, m.isread, us.name as sender_name, ua.name as addressee_name from messages m LEFT JOIN users us ON m.sender_id = us.id LEFT JOIN users ua ON m.addressee_id = ua.id WHERE m.id IN ( SELECT MAX(id) FROM messages WHERE ' . $id . ' IN(sender_id, addressee_id) GROUP by CASE WHEN sender_id>addressee_id THEN addressee_id ELSE sender_id END, CASE WHEN sender_id>addressee_id THEN sender_id ELSE addressee_id END ) ORDER BY m.created_at DESC '; $messages = DB::select($query); $view = array('messages' => $messages); return View::make('user.msg.messages', $view); }
/** * Renders the message(s), and by default clears them too. * * @param mixed string of the view to use, or a Kohana_View object * @param boolean set to FALSE to not clear messages * @return string message output (HTML) */ public static function render($view = NULL, $clear = TRUE) { // Nothing to render if (($messages = Message::get()) === NULL) { return ''; } // Clear all messages if ($clear) { Message::clear(); } if ($view === NULL) { // Use the default view $view = 'message/basic'; } if (!$view instanceof Kohana_View) { // Load the view file $view = View::factory($view); } // Return the rendered view return $view->set('messages', $messages)->render(); }
public function before() { parent::before(); // detecting language, setting it // $this->detect_language(); // $this->set('_language', $this->language); $this->set('device', $this->detect_device()); //var_dump($_COOKIE); // creating and attaching page metadata $this->metadata = new Model_Metadata(); $this->metadata->title(__(Application::instance()->get('title')), false); $this->set('_metadata', $this->metadata); $this->set('_token', Security::token()); // Handles return urls, cropping language out of it (will be appended by url.site at redirect time) // $rr = Request::initial()->uri(); // $rr = trim($rr, '/'); // $rr = explode('/', $rr); // if (in_array($rr[0], Application::instance()->get('language.list'))) { // array_shift($rr); // } // $rr = implode('/', $rr); // $this->set('_return', $rr . Url::query()); View::bind_global('_breadcumbs', $this->breadcumbs); // detecting if user is logged in if (method_exists(Auth::instance(), 'auto_login')) { Auth::instance()->auto_login(); } // if (Auth::instance()->logged_in()) { $id = Auth::instance()->get_user()->id; $user = ORM::factory('user', $id); $input = $user->has('roles', ORM::factory('role', array('name' => 'admin'))); $this->set("admin_mode", $input); } else { $this->set("admin_mode", false); } // $this->user = Auth::instance()->get_user(); $this->set('_user', $this->user); if (Auth::instance()->logged_in() && $this->user->profile->is_visited != 1 && strtolower($this->request->controller()) == 'profile') { $this->redirect('profile/information', 301); } $sliders = ORM::factory('Slider')->where('is_active', '=', 1)->and_where('type', '=', 'slider')->order_by('order', 'asc')->find_all(); $this->set('sliders', $sliders); $banner = ORM::factory('Slider')->where('is_active', '=', 1)->and_where('type', '=', 'banner')->find_all(); $this->set('menu_banner', $banner); $menu = ORM::factory('Page')->where('key', '=', 'menu')->find(); //Для SEO (сортировка) if ($this->request->controller() == 'Auth' or $this->request->controller() == 'Search' or $this->request->controller() == 'Profile') { $this->set('sort', 1); } //end SEO $page_roots = ORM::factory('Page', $menu->id)->children(); $page_main = array(); $children_pages = array(); $children_pages_last = array(); $children_pages_last_last = array(); foreach ($page_roots as $p) { $page_main[$p->key] = array('id' => $p->id, 'name' => $p->name, 'description' => $p->description); $children_pages[$p->key] = $p->children(); //ORM::factory('Page')->where('parent_id','=',$p->id)->find_all();//только первый уровень детей //второй уровень детей. foreach ($children_pages[$p->key] as $ch_p) { if ($ch_p->id == 232 or $ch_p->id == 159) { continue; } $children_pages_last[$ch_p->id] = $ch_p->children(); //третий уровень детей foreach ($children_pages_last[$ch_p->id] as $ch_p_l) { $children_pages_last_last[$ch_p_l->id] = $ch_p_l->children(); } } } $page_halyk_kaharmany = ORM::factory('Page', 319); $this->set('page_halyk_kaharmany', $page_halyk_kaharmany); $this->set('_pages', $page_main)->set('_children_pages', $children_pages)->set('_children_pages_last', $children_pages_last)->set('_children_pages_last_last', $children_pages_last_last)->set('_return_url', URL::media(Request::initial()->uri())); //для вывода сообщения о регистрации восстановления пароля и прочих действий //само сообщение выводится в модальном окне, находится в шаблоне footer if (Message::get()) { $this->set('basic_message', Message::display('/message/basic')); } $nofollowlink = url::media(Request::initial()->uri()); $controller = strtolower(Request::initial()->controller()); $action = strtolower(Request::initial()->action()); if ($controller == 'books' and $action == 'index') { $params = explode('books/', $_SERVER['REQUEST_URI']); if (isset($params[1]) and isset($params[0])) { $params = explode('?', $params[1]); $razdel = $params[0]; } else { $razdel = ''; } if (isset($params[1])) { $params = explode('=', $params[1]); $idbook = $params[1]; } else { $idbook = ''; } $wherestring = 'books_' . $razdel . '_' . $idbook; $page = ORM::factory('Page')->where('key', '=', $wherestring)->find(); $linkid = $page->id; $nofollowlink = URL::site('contents/list/' . $linkid); } if ($controller == 'biography' and $action == 'index') { $params = explode('biography/', $_SERVER['REQUEST_URI']); if (isset($params[1])) { $idbiography = $params[1]; } else { $idbiography = ''; } $wherestring = 'biography' . '_' . $idbiography; $page = ORM::factory('Page')->where('key', 'LIKE', $wherestring . '%')->find(); $linkid = $page->id; $nofollowlink = URL::site('contents/list/' . $linkid); } if ($controller == 'organization' and $action == 'show') { $params = explode('organization/show/', $_SERVER['REQUEST_URI']); if (isset($params[1])) { $idorganization = $params[1]; } else { $idorganization = ''; } $wherestring = 'organization' . '_' . $idorganization; $page = ORM::factory('Page')->where('key', 'LIKE', $wherestring . '%')->find(); $linkid = $page->id; $nofollowlink = URL::site('contents/list/' . $linkid); } if ($controller == 'expert' and $action == 'index') { $nofollowlink = URL::site('contents/list/301'); } //в базе дублируется запись 4 и 301 if ($controller == 'publications' and $action == 'index') { $nofollowlink = URL::site('contents/list/231'); } if ($controller == 'debate' and $action == 'index') { $nofollowlink = URL::site('contents/list/335'); } if ($controller == 'debate' and $action == 'index') { $nofollowlink = URL::site('contents/list/335'); } $this->set('nofollowlink', $nofollowlink); //потому-что SEO. }
<?php $feedback_success = Message::get('success'); $feedback_error = Message::get('error'); $feedback_info = Message::get('info'); $feedback_warning = Message::get('warning'); // echo out positive messages if (!empty($feedback_success)) { foreach ($feedback_success as $feedback) { echo '<div class="alert alert-success"><button class="close" data-dismiss="alert" type="button">×</button>' . $feedback . '</div>'; } } // echo out negative messages if (!empty($feedback_error)) { foreach ($feedback_error as $feedback) { echo '<div class="alert alert-danger"><button class="close" data-dismiss="alert" type="button">×</button>' . $feedback . '</div>'; } } // echo out notice messages if (!empty($feedback_info)) { foreach ($feedback_info as $feedback) { echo '<div class="alert alert-info"><button class="close" data-dismiss="alert" type="button">×</button>' . $feedback . '</div>'; } } // echo out notice messages if (!empty($feedback_warning)) { foreach ($feedback_warning as $feedback) { echo '<div class="alert alert-warning"><button class="close" data-dismiss="alert" type="button">×</button>' . $feedback . '</div>'; } } Message::clear();
/** * @covers Phossa\Di\Message\Message::get */ public function testGet() { $this->assertEquals('Service "one" method "two" error', Message::get(Message::SERVICE_METHOD_ERROR, 'one', 'two')); }
/* Deletando arquivo em "../components/img" */ header("Location: index.php?msg=" . $banner->photo[Dbcommand::get('del') - 1]->delete()); /* Deletando registro do banco */ } /* ============= Adicionar imagem =============== */ if (@$_POST) { header("Location: index.php?msg=" . $banner->addPhoto($user->getId())); } ?> <!-- Banner --> <div class="col-xs-12 col-sm-10"> <div class="jumbotron"> <a href="./"><h1>Banners</h1></a> <br/> <?php echo Message::get(); ?> <form enctype="multipart/form-data" action="index.php" method="post"> <fieldset> <div> <h4>Nome:</h4> <input type='text' name='name_photo' class="form-control" placeholder="Digite o Nome do Banner" pattern="^[^<>]{0,255}$" required/> </div> <div> <h4>Imagem (.png, .jpeg, .jpg):</h4> <input name="photo" id="photo" type="file" required/> <br/> *Tamanho recomendado: 1280x720 </div> <br/>
if (!$ADK_MESSAGE->isValid()) { $con->close(); header('Location: ../messages?e=' . $ADK_MESSAGE->err); exit; } $ADK_MESSAGE->sanitize(); if ($ADK_MESSAGE->wasdraft && !$ADK_MESSAGE->isdraft) { $ADK_MESSAGE->sendDraft($con); } else { if ($ADK_MESSAGE->wasdraft && $ADK_MESSAGE->isdraft) { $ADK_MESSAGE->updateDraft($con); } else { $ADK_MESSAGE->save($con); } } $ADK_MESSAGE->get($con); if (!$ADK_MESSAGE->isdraft) { $notification = '?m=s'; $ADK_USER = new User(); $ADK_USER->id = $ADK_MESSAGE->toid; $ADK_USER->get($con); sendPMNotifyEmail($ADK_MESSAGE, $ADK_USER); } //$replyFileIDs = explode(',', $_POST['replyfileids']); //if(count($replyFileIDs) > 0 && $replyFileIDs[0] != '') // addMessageFileJcts($con, $ADK_MESSAGE['ADK_MESSAGE_ID'], $replyFileIDs); if (count($ADK_FILES->files) > 0) { $ADK_FILES->save($con); $ADK_MESSAGE->addFiles($con, $ADK_FILES->fileIDs); } if ($_SESSION['ADK_USERGROUP_CDE'] === 'HIK') {
$t->searchUsers = array(); $t->toArray = ''; $t->quote = ''; $t->alliance = isset($filtered['alliance']); $t->officers = isset($filtered['officers']); $t->msgId = $msgId; try { if (!strlen($subject)) { $subject = _('(No Subject)'); } if ($msgId and !($subject and $text)) { $msg = new Message(); $msg->get($msgId); if (me($msg->targetId) or me($msg->senderId)) { $t->quote = $msg; $t->quote->subject = 'RE: ' . $msg->subject; $t->quote->text = "[quote]$msg->text[/quote]\n\n"; } } else if ($subject or $text) { $t->quote->subject = $subject; $t->quote->text = $text; } if (count($to)) { foreach ($to as $toId) { if (!$t->targets[$toId]) { $u = new User();
public function renderRoom($roomId) { $time = mktime(); // is the user already in the room? if (!$this->user->inRoom($roomId)) { // enter them into the room $this->user->enterRoom($roomId, $time); // say that the user has entered $message = new MessageSpeak($roomId, $time); $message->enter($roomId, $time, $this->user->getShortName()); } $messages = new Message(); $this->bag->messages = $messages->get($roomId); // do we have some messages in the history? $this->bag->history = $messages->haveMore($roomId); $this->bag->earlier = true; $this->bag->tabs = $this->user->inRooms(); $this->bag->isAdmin = $this->user->isAdmin(); $this->bag->host = $this->host; $room = new Room(); $this->bag->room = $room->getDescription($roomId); }
public static function getUserBookmarks() { if (!($fileInfo = FileModel::getBookmarks(Session::get('user_id')))) { return array('error_message' => Message::get('DB_ERROR')); } return $fileInfo; }
public function showAction(Conversation $conversation, Player $me, Request $request) { $this->assertCanParticipate($me, $conversation); $conversation->markReadBy($me->getId()); $form = $this->showMessageForm($conversation, $me); $inviteForm = $this->showInviteForm($conversation, $me); $renameForm = $this->showRenameForm($conversation, $me); $messages = $this->getQueryBuilder('AbstractMessage')->where('conversation')->is($conversation)->sortBy('time')->reverse()->limit(10)->fromPage($request->query->get('page', 1))->startAt($request->query->get('end'))->endAt($request->query->get('start'))->getModels(); // Hide the details (author, timestamp) of the first message if they're // already shown in the previous message (useful for AJAX calls) if ($request->query->getBoolean('hideFirstDetails')) { $previousMessage = Message::get($request->query->get('end')); } else { $previousMessage = null; } $params = array("form" => $form->createView(), "inviteForm" => $inviteForm->createView(), "renameForm" => $renameForm->createView(), "conversation" => $conversation, "messages" => $messages, "previousMessage" => $previousMessage); if ($request->query->has('nolayout')) { if ($request->query->getBoolean('reviewLastDetails')) { // An AJAX call has asked us to check if details (author, // timestamp) will need to be shown for the next message $nextMessage = Message::get($request->query->get('start')); $lastMessage = reset($messages); if ($lastMessage !== false && $lastMessage->isMessage() && $nextMessage->isMessage() && $lastMessage->getTimestamp()->isSameDay($nextMessage->getTimestamp()) && $lastMessage->getAuthor()->isSameAs($nextMessage->getAuthor())) { $hideLastDetails = true; } else { $hideLastDetails = false; } // Add $hideLastDetails to the list of JSON parameters $this->attributes->set('hideLastDetails', $hideLastDetails); } // Don't show the layout so that ajax can just load the messages return $this->render('Message/messages.html.twig', $params); } else { return $params; } }
public function __get($key) { return Message::get($key); }
/** * Pushes or emails a new private message to the user * * @param array $event The event data we received from the web server */ private function onMessageServerEvent($event) { // A list of players who received a message so that we can e-mail the // ones who didn't $received = array(); $conversation = \Conversation::get($event->data->conversation); $conversationMembers = $conversation->getPlayerIds(); foreach ($this->clients as $client) { $player = $client->Player; if (!in_array($player->getId(), $conversationMembers)) { // Don't notify that player, he doesn't belong in the conversation continue; } $event->notification_count = $player->countUnreadNotifications(); $event->message_count = $player->countUnreadMessages(); $this->send($client, $event); $received[] = $player->getId(); } // Send e-mails foreach ($event->data->recipients as $recipient) { // Only send an email to users who aren't currently logged in if (!in_array($recipient, $received)) { $this->log("<fg=green>E-mailing player {$recipient->getId()} ({$recipient->getUsername()})</>"); $this->subscriber->sendEmails('New message received', array($recipient), 'message', array('message' => \Message::get($event->data->message))); } } }
/** * @since 2.4 * * @param string $label * @param string $languageCode * * @return mixed string property ID or false */ public function findPropertyIdFromLabelByLanguageCode($label, $languageCode = '') { $languageCode = mb_strtolower(trim($languageCode)); // Match the canonical form if ($languageCode === '') { return $this->findPropertyIdByLabel($label); } $extraneousLanguage = Localizer::getInstance()->getExtraneousLanguage($languageCode); // Language dep. stored as aliases $aliases = $extraneousLanguage->getPropertyLabels() + $extraneousLanguage->getDatatypeLabels(); if (($id = array_search($label, $aliases)) !== false && !isset($this->dataTypePropertyExemptionList[$label])) { return $id; } // Those are mostly from extension that register a msgKey as no dedicated // lang. file exists; maybe this should be cached somehow? foreach ($this->propertyAliasFinder->getKnownPropertyAliasesWithMsgKey() as $key => $id) { if ($label === Message::get($key, Message::TEXT, $languageCode)) { return $id; } } return false; }
/** * Confirms subscription * * @param Message $message * @throws Exception */ private function _subscription_confirmation($message) { $this->_log('Issuing confirm_subscription'); $response = $this->_get_api()->confirm_subscription($topic_arn, $message->get('Token')); $this->_log('Subscription confirmed: ' . ($response->isOK() ? 'OK' : 'Error')); }
public static function getMessages($msg_id, $timestamp_last_update = null) { $msg = new Message(array()); $options = array('first_id' => $msg_id, 'since' => $timestamp_last_update, 'limit_paging' => 20); $messages = $msg->get($options); return $messages; }
<div class="grid_12"> <!-- <a href="#">Cookie</a><span class="splitter">→</span> <a href="#">Crumb</a><span class="splitter">→</span> Trail --> </div> <div class="clear"> </div> </div> </div> </div> <!-- end header --> <!-- start messages --> <? if($messages = Message::get()): ?> <div class="container_12"> <div class="grid_12 messages"> <? foreach($messages as $type => $typeMessages): ?> <? foreach($typeMessages as $message): ?> <p class="<?php echo $type; ?> "><?php echo $message; ?> </p> <? endforeach; ?> <? endforeach; ?> </div> </div>
public function actionDelete($msgId) { $message = Message::get($msgId); if (Rays::isAjax() && $message != null) { if (Rays::user()->id != $message->receiverId) { echo "Sorry. You don't have the right to delete the message."; exit; } $message->delete(); echo 'success'; exit; } RAssert::not_null($message); $user = Rays::user(); if ($message->receiverId == $user->id || $user->isAdmin()) { $message->delete(); } $this->redirect(Rays::referrerUri()); }
<?php require 'model/message.php'; $openid = $_GET['openid']; //$openid = '123'; $message = new Message(); $good = $message->get($openid); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0"> <title>报名成功</title> <link rel="stylesheet" href="style/weui.css"/> <style> .container{ width: 100%; height: 100%; overflow: hidden; } .weui_cell{ border-top: 1px solid #eee; border-bottom: 1px solid #eee; } h1{ text-align: center; } h3{ margin-top: 5px; }
} ?> <div id="content-cart-top" style="margin-top: 15px"> <?php echo View::factory('shop/frontend/cart/v_cart_top'); ?> </div> </div> <div class="col-md-9"> <?php echo Breadcrumb::run($breadcrumbs); ?> <?php echo Message::get(false); ?> <?php echo $content; ?> </div> </div> </div> </div> <?php echo $v_footer; ?> <?php
/** * Process the response as JSON with some extra information about the * (success status of the form) so that jQuery knows what to do with the result. */ protected function process_ajax() { if ($this->request->method() == HTTP_Request::POST) { // Allow for override. Set the form saved true for ajax request, if no errors if (empty($this->_errors)) { $this->SetFormSaved(TRUE); } else { $this->SetFormSaved(FALSE); } if ($this->_response_format === 'application/json') { $this->SetJson('Body', FALSE); } } else { if ($this->_response_format === 'application/json') { $this->SetJson('Body', base64_encode($this->response->body())); } } if ($this->_response_format === 'application/json') { if ($this->request->query('draw') !== NULL) { return; } $scripts = Assets::js(FALSE, NULL, NULL, FALSE, NULL, Assets::FORMAT_AJAX); $styles = Assets::css(FALSE, NULL, NULL, FALSE, Assets::FORMAT_AJAX); $this->SetJson('FormSaved', $this->_formsaved); $this->SetJson('messages', Message::get(NULL, NULL, TRUE)); $this->SetJson('errors', $this->_errors); $this->SetJson('redirect', Request::$redirect_url); $this->SetJson('title', $this->title); $this->SetJson('subtitle', $this->subtitle); $this->SetJson('css', $styles); $this->SetJson('js', $scripts); if (!Valid::utf8($this->_json['Body'])) { $this->_json['Body'] = utf8_encode($this->_json['Body']); } $this->_json['Data'] = JSON::encode($this->_json); } }
/** * Get the last message of the conversation * * @return Message */ public function getLastMessage() { $ids = self::fetchIdsFrom('conversation_to', array($this->id), false, 'AND event_type IS null ORDER BY id DESC LIMIT 0,1', 'messages'); if (!isset($ids[0])) { return Message::invalid(); } return Message::get($ids[0]); }
function messages($reference_object, $reference_id) { //todo:does this really belong on the controller? $model = new $reference_object($reference_id); //make sure the user owns the object that we are requesting messages for $this->check_authorization($model); $message = new Message(); $messages = $message->get($reference_object, $reference_id); Response($messages); }