/**
  * Display the room from a guest's perspective
  */
 public function actionIndex($guestCode)
 {
     try {
         // get the room
         $room = $this->room->getGuestRoom($guestCode = Fari_Escape::text($guestCode));
         // is user authenticated?
         $this->guestUser = new User();
         // is user authorized?
         $this->guestUser->canEnter($room['id']);
         // the room does not exist
     } catch (RoomNotFoundException $e) {
         $this->renderTemplate('room/invalid');
         // we haven't signed in
     } catch (UserNotAuthenticatedException $e) {
         $this->bag->code = $guestCode;
         // show a form to enter a name for the new guest
         $this->renderTemplate('account/guest');
         // we cannot enter this room
     } catch (UserNotAuthorizedException $e) {
         $this->renderTemplate('room/permissions');
     }
     // we are already in
     $time = mktime();
     // is the user already in the room?
     if (!$this->guestUser->inRoom($room['id'])) {
         // not in the room... is it locked?
         if ($room['locked']) {
             $system = new System();
             $this->renderTemplate('room/locked');
         } else {
             // enter them into the room
             $this->guestUser->enterRoom($room['id'], $time);
             // say that the user has entered
             $message = new MessageSpeak();
             $message->enter($room['id'], $time, $this->guestUser->getShortName());
         }
     }
     // all other fails captured...
     // show a 'guest' view
     $this->renderTemplate('room/guest', $room['id']);
 }
 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);
 }