--- chatroom.module	2006/10/12 01:03:51	1.50.2.5
+++ chatroom.module	2006/10/22 20:51:35	1.50.2.7
@@ -1,5 +1,5 @@
 <?php
-// $Id: chatroom.module,v 1.50.2.5 2006/10/12 01:03:51 darrenoh Exp $
+// $Id: chatroom.module,v 1.50.2.7 2006/10/22 20:51:35 darrenoh Exp $
 
 /**
  * @file
@@ -301,11 +301,11 @@
       );
     }
     if (count($rows['open'])) {
-      $node->body .= '<h2>' . t('Open chats in this room') . '</h2>';
+      $node->body .= '<h2>'. t('Open chats in this room') .'</h2>';
       $node->body .= theme('table', array(t('Chat name'), t('Message count'), t('Last message')), $rows['open']); 
     }
     if (count($rows['archived'])) {
-      $node->body .= '<h2>' . t('Archived chats in this room') . '</h2>';
+      $node->body .= '<h2>'. t('Archived chats in this room') .'</h2>';
       $node->body .= theme('table', array(t('Chat name'), t('Message count'), t('When archived')), $rows['archived']); 
     }
   }
@@ -606,12 +606,14 @@
 
 /**
  * gets the chat cache file path. this function is called when loading the 
- * chatroom UI, and the vaule is stored in the browser. this allows the
+ * chatroom UI, and the value is stored in the browser. this allows the
  * common ajax operations to check the cache before loading up Drupal
  */
 function chatroom_chat_get_cache_file_path($chat_id) {
   $cache_file = chatroom_chat_get_cache_file_name($chat_id);
-  return file_directory_temp() ."/drupal_chat_cache/$cache_file";
+  $cache_directory = file_directory_temp() .'/drupal_chat_cache';
+  file_check_directory($cache_directory, 1);
+  return $cache_directory ."/$cache_file";
 }
 
 /**
@@ -750,8 +752,10 @@
  * get block cache file
  */
 function chatroom_block_get_cache_file($type) {
-  $url  = str_replace('//', '/', dirname($_SERVER['PHP_SELF']) . '/modules/chatroom/chatroomread.php');
-  return file_directory_temp() ."/drupal_chat_cache/{$type}_". md5($_SERVER['HTTP_HOST'] . $url);
+  $url  = str_replace('//', '/', dirname($_SERVER['PHP_SELF']) .'/modules/chatroom/chatroomread.php');
+  $cache_directory = file_directory_temp() .'/drupal_chat_cache';
+  file_check_directory($cache_directory, 1);
+  return $cache_directory ."/{$type}_". md5($_SERVER['HTTP_HOST'] . $url);
 }
 
 /**
@@ -783,7 +787,7 @@
     foreach ($invites as $invite) {
       if ($invite->created_ccid) {
         $invites_js[] = '{ccid:'. $invite->created_ccid.'",user:"'. $invite->invitee_name.'",'
-                      . 'uid:'. $invite->invitee_uid .',url:"#"}';
+                      .'uid:'. $invite->invitee_uid .',url:"#"}';
       }
       else {
         $invites_js[] = '{user:"'. $invite->sender_name.'",uid:'. $invite->sender_uid .',url:"#"}';
@@ -803,7 +807,7 @@
   if ($chats) {
     $chats_js = '';
     foreach ($chats as $chat) {
-      $chat_js .= '{chatName:"'. $chat->chatname . '",chatListId:"chat_'. $chat->ccid .'",';
+      $chat_js .= '{chatName:"'. $chat->chatname .'",chatListId:"chat_'. $chat->ccid .'",';
       $chat_js .= 'ccid:'. $chat->ccid .',roomName:"'. $chat->room_name .'",crid:'. $chat->crid .'},';
     }
     return "{chatList:[$chat_js $timestamp]}";
@@ -820,7 +824,7 @@
   if ($rooms) {
     $room_js = '';
     foreach ($rooms as $room) {
-      $room_js .= '{chatroomName:"'. $room->title . '",chatroomListId:"chatroom_'. $room->nid .'",';
+      $room_js .= '{chatroomName:"'. $room->title .'",chatroomListId:"chatroom_'. $room->nid .'",';
       $room_js .= 'crid:'. $room->nid .'},';
     }
     return "{chatroomList:[$room_js $timestamp]}";
@@ -1000,7 +1004,7 @@
     $content = '<ul class="menu" id="chatroom-sitewide-online">';
     foreach ($users as $ol_user) {
             $content .= '<li id="user-li-'. $ol_user->uid .'"><a href="#user" id="user-'. $ol_user->uid .'">';
-      $content .= check_plain($ol_user->name). '</a></li>';
+      $content .= check_plain($ol_user->name).'</a></li>';
       $users_js[] = '{user:"'. $ol_user->name .'",uid:'. $ol_user->uid .'}';
     }
     $users_js = implode(',', $users_js);
@@ -1044,7 +1048,7 @@
       $content .= '<li id="'. $ol_user->session_id .'"';
       $content .= $ol_user->away ? ' class="chatroom-user-away" ' : '';
       if ($ol_user->uid) {        
-        $content .= '><a href="javascript:chatroomSelectUser(\''. $ol_user->name .'\')">' . check_plain($name). '</a></li>';
+        $content .= '><a href="javascript:chatroomSelectUser(\''. $ol_user->name .'\')">'. check_plain($name).'</a></li>';
       }
       else {
         $content .= ">$name</li>";
@@ -1099,7 +1103,7 @@
   $result = db_query('SELECT     cm.*,
                                  du.name,
                                  col.guest_id
-                      FROM       {' . $table . '} AS cm
+                      FROM       {'. $table .'} AS cm
                       INNER JOIN {chatroom_online_list} AS col
                       ON         col.session_id = cm.session_id AND col.ccid = cm.ccid
                       LEFT JOIN  {users} AS du 
@@ -1169,11 +1173,11 @@
   if ($users = chatroom_chat_get_online_list($chat->ccid)) {
     $users_js = chatroom_chat_get_online_list_js($users);
   }
-  $kick_url       = dirname($_SERVER['PHP_SELF']) . ($clean_urls ? '' : '?q=') . 'chatrooms/kicked/user';
-  $ban_url        = dirname($_SERVER['PHP_SELF']) . ($clean_urls ? '' : '?q=') . 'chatrooms/banned/user';
-  $user_url       = ($clean_urls ? '../../' : '?q=') . 'user/';
+  $kick_url       = dirname($_SERVER['PHP_SELF']) . ($clean_urls ? '' : '?q=') .'chatrooms/kicked/user';
+  $ban_url        = dirname($_SERVER['PHP_SELF']) . ($clean_urls ? '' : '?q=') .'chatrooms/banned/user';
+  $user_url       = ($clean_urls ? '../../' : '?q=') .'user/';
   $chatroom_base  = drupal_get_path('module', 'chatroom');
-  $chat_url       = ($clean_urls ? '../../' : ''   ) . $chatroom_base . '/chatroomread.php';
+  $chat_url       = ($clean_urls ? '../../' : ''   ) . $chatroom_base .'/chatroomread.php';
   $user_base      = drupal_get_path('module', 'user');
   $cache_file     = file_directory_temp() .'/drupal_chat_cache/'. chatroom_chat_get_cache_file_name($chat->ccid);
   $smileys_base   = drupal_get_path('module', 'smileys') ? "'". drupal_get_path('module', 'smileys') ."'" : 'false';
@@ -1230,7 +1234,7 @@
 
   // need some css for the user list display when not in chatroom chat page
   if (substr($_GET['q'], 0, strlen('chatrooms/chat/')) != 'chatrooms/chat/') {
-    $css_path = str_replace('//', '/', dirname($_SERVER['PHP_SELF']) . '/');
+    $css_path = str_replace('//', '/', dirname($_SERVER['PHP_SELF']) .'/');
     drupal_add_link(array("rel" => "stylesheet", "type" => "text/css", 
                           "href" => $css_path . drupal_get_path('module', 'chatroom') .'/chatroom.css'));
   }
@@ -1241,7 +1245,7 @@
   $room_base   = $site_base .'node/';
   $module_base = drupal_get_path('module', 'chatroom');
   $user_base   = drupal_get_path('module', 'user');
-  $block_url   = str_replace('//', '/', dirname($_SERVER['PHP_SELF']) . $module_base . '/chatroomread.php');
+  $block_url   = str_replace('//', '/', dirname($_SERVER['PHP_SELF']) . $module_base .'/chatroomread.php');
 
   // setup the cache file paths
   $chat_cache_file = chatroom_block_get_cache_file('chats');
@@ -1278,19 +1282,19 @@
   $bc[] = l(check_plain($chat->chatroom_name), "node/$chat->nid");
   drupal_set_breadcrumb($bc);
   drupal_set_title(check_plain($chat->chatname));
-  $html = '<p>' . t('This chat was archived on ') . format_date($chat->when_archived, 'medium') .'</p>';
+  $html = '<p>'. t('This chat was archived on ') . format_date($chat->when_archived, 'medium') .'</p>';
   $html .= '<div id="chatroom-container-archive">';
   if ($msgs = chatroom_get_all_msgs($chat->ccid, TRUE)) {
     foreach ($msgs as $msg) {
       $name = $msg->name ? $msg->name : 'guest-'. $msg->guest_id;
       $html .= '<p><span class="chatroom-archive-user">['. format_date($msg->modified, 'custom', 'G:i') .'] ';
-      $html .= $name . ': </span>'. $msg->msg .'</p>';
+      $html .= $name .': </span>'. $msg->msg .'</p>';
     }
   }
   else {
-    $html .= '<p>' . t('This chat contains no messages') .'</p>';
+    $html .= '<p>'. t('This chat contains no messages') .'</p>';
   }
-  return $html . '</div>';
+  return $html .'</div>';
 }
 
 /**
@@ -1362,7 +1366,7 @@
   chatroom_chat_register_user($chat->ccid);
   chatroom_chat_set_cache($chat->ccid);
   $clean_urls = variable_get('clean_url', 0);
-  $css_path = str_replace('//', '/', dirname($_SERVER['PHP_SELF']) . '/');
+  $css_path = str_replace('//', '/', dirname($_SERVER['PHP_SELF']) .'/');
   drupal_add_link(array("rel" => "stylesheet", "type" => "text/css", 
                         "href" => $css_path . drupal_get_path('module', 'chatroom') .'/chatroom.css'));
   drupal_add_js(drupal_get_path('module', 'chatroom') .'/chatroom.js');
@@ -1390,7 +1394,7 @@
   chatroom_chat_register_user($chat->ccid);
   chatroom_chat_set_cache($chat->ccid);
   $clean_urls = variable_get('clean_url', 0);
-  $css_path = str_replace('//', '/', dirname($_SERVER['PHP_SELF']) . '/');
+  $css_path = str_replace('//', '/', dirname($_SERVER['PHP_SELF']) .'/');
   drupal_add_link(array("rel" => "stylesheet", "type" => "text/css", 
                         "href" => $css_path . drupal_get_path('module', 'chatroom') .'/chatroom.css'));
   drupal_add_js(drupal_get_path('module', 'chatroom') .'/chatroom.js');
@@ -1422,7 +1426,7 @@
  * send response to ajax requests
  */
 function chatroom_send_ajax_response($response) {
-  header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
+  header("Last-Modified: ". gmdate("D, d M Y H:i:s") ." GMT");
   header("Cache-Control: no-store, no-cache, must-revalidate");
   header("Cache-Control: post-check=0, pre-check=0", false);
   header("Pragma: no-cache");
@@ -1458,7 +1462,7 @@
  */
 function chatroom_get_msg_info($msg) {
   $user = $msg->uid ? l(check_plain($msg->name), "user/$msg->uid") : t('Anonymous');
-  return check_plain($msg->msg) . "<br />Posted by <b>$user</b>, ". format_date($msg->modified, 'medium'); 
+  return check_plain($msg->msg) ."<br />Posted by <b>$user</b>, ". format_date($msg->modified, 'medium'); 
 }
 
 /**
@@ -1698,7 +1702,7 @@
     $header = array(t('Chatroom'), t('Chats'), t('Messages'), t('Last message'));
     foreach ($tree as $room) {
       $description  = "<div>\n";
-      $description .= ' <div class="name">'. l($room->title, "node/$room->nid"). '</div>';
+      $description .= ' <div class="name">'. l($room->title, "node/$room->nid").'</div>';
 
       if ($room->body) {
         $description .= ' <div class="description">'. filter_xss_admin($room->body) ."</div>\n";
