/**
  * Send a message from a room
  *
  * @uses Ajax
  */
 public function actionSpeak($roomId)
 {
     $text = Fari_Escape::text(Fari_Decode::javascript($this->request->getRawPost('text')));
     if (!empty($text)) {
         $time = mktime();
         // a text message
         $message = new MessageSpeak($roomId, $time);
         $message->text($roomId, $time, $this->user->getShortName(), $this->user->getId(), $text);
         // the message might be saved under wrong room id, but activity updater will kick us...
         try {
             $this->room->updateUserActivity($roomId, $time, $this->user->getId());
         } catch (UserNotFoundException $e) {
             $this->renderJson('bye');
         }
     }
 }
 public function renderUpload($roomId)
 {
     // message about it
     $time = mktime();
     $message = new MessageSpeak($roomId, $time);
     $text = '<a class="file ' . $this->file->type . '"></a><a class="blue" href="' . WWW_DIR . '/file/get/' . $this->file->code . '"/>' . $this->file->name . '</a>';
     // live preview image thumbnail
     if ($this->file->thumbnail === TRUE) {
         $text .= '<div class="image"><img src="' . WWW_DIR . '/file/thumb/' . $this->file->code . '" alt="thumb" /></div>';
     } else {
         switch ($this->file->mime) {
             case 'image/jpeg':
             case 'image/jpg':
             case 'image/png':
             case 'image/gif':
                 $text .= '<div class="image"><img src="' . WWW_DIR . '/file/get/' . $this->file->code . '" alt="image" /></div>';
         }
     }
     $message->text($roomId, $time, $this->user->getShortName(), $this->user->getId(), $text);
     die($this->file->name);
 }