/** * Renders form for sending messages. * Sends message content to selected user. * If message is sent, user is notified. */ public function action() { checkUnauthorizedAccess(); $main = new Main(); $body = new \templates\SendMessage(); echo $main->setPageTitle("Send Message")->setBody($body); if (post('send')) { $senderID = UserRepository::getIdByUsername($_SESSION['username']); $recipientID = getIdFromURL(); $content = htmlentities(trim(post('content'))); //stvaranje poruke $message = new Message(); $message->setSenderID($senderID); $message->setRecipientID($recipientID); $message->setContent($content); $message->setCreated(date('Y-m-d H:i:s')); try { //slanje poruke MessageRepository::sendMessage($message); ?> <script src="/TwitterApp/assets/js/messageSent.js"></script> <?php } catch (\PDOException $e) { $e->getMessage(); } } }