Index: admin_message.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/admin_message/admin_message.js,v
retrieving revision 1.1
diff -u -r1.1 admin_message.js
--- admin_message.js	21 Jul 2007 12:38:29 -0000	1.1
+++ admin_message.js	20 Nov 2008 17:46:35 -0000
@@ -1,10 +1,10 @@
-// $Id: admin_message.js,v 1.1 2007/07/21 12:38:29 fajerstarter Exp $
+// $Id$
 
 // Global Killswitch
 if (Drupal.jsEnabled) {
   $(document).ready(function() {  
     // Close
-    $("#block-admin_message-admin_message a.close").click(function() {
+    $("#block-admin_message-admin_message a.admin-message-close").click(function() {
       var href = $(this).attr("href");
       $.get(href);
       $(this).parent().slideUp('fast');
Index: admin_message.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/admin_message/admin_message.install,v
retrieving revision 1.1
diff -u -r1.1 admin_message.install
--- admin_message.install	21 Jul 2007 12:38:29 -0000	1.1
+++ admin_message.install	20 Nov 2008 17:46:35 -0000
@@ -1,52 +1,102 @@
 <?php
-// $Id: admin_message.install,v 1.1 2007/07/21 12:38:29 fajerstarter Exp $
+// $Id$
+/**
+ * @file
+ * Database Schema for admin_menu.module
+ */
+
+/**
+ * Implementation of hook_schema().
+ */
+function admin_message_schema() {
+  $schema['admin_message'] = array(
+    'description' => t('TODO'),
+    'fields' => array(
+      'nid' => array(
+        'description' => t('TODO'),
+        'type' => 'int',
+        'size' => 'small',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'keep_new' => array(
+        'description' => t('TODO'),
+        'type' => 'int',
+        'size' => 'tiny',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'php_visibility' => array(
+        'description' => t('TODO'),
+        'type' => 'text',
+        'size' => 'small',
+        'not null' => TRUE,
+        'default' => '',
+      ),
+    ),
+    'primary key' => array('nid'),
+  );
+  $schema['admin_message_close'] = array(
+    'description' => t('TODO'),
+    'fields' => array(
+      'nid' => array(
+        'description' => t('TODO'),
+        'type' => 'int',
+        'size' => 'small',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'uid' => array(
+        'description' => t('TODO'),
+        'type' => 'int',
+        'size' => 'small',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+    ),
+    'primary key' => array('nid, uid'),
+  );
+  return $schema;
+}
 
 function admin_message_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      db_query("CREATE TABLE {admin_message} (
-        nid int(10) NOT NULL,
-        keep_new int(2) NOT NULL default '0',
-        php_visibility text NOT NULL,
-        PRIMARY KEY (nid)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-      
-      db_query("CREATE TABLE {admin_message_close} (
-        nid int(10) NOT NULL,
-        uid int(10) NOT NULL,
-        PRIMARY KEY (nid, uid)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-      break;
-    }  
+
+  drupal_install_schema('admin_message');
+
   
   // Create default content type
   $type = array(
     'type' => 'admin_message',
     'name' => t('Admin message'),
     'module' => 'node',
-    'description' => t('Use admin messages to display messages, usually status messages or similair to logged in users.'),
-    'has_title' => FALSE,
+    'description' => t('Use admin messages to display messages, usually status messages or similar to logged in users.'),
     'body_label' => t('Message'),
     'custom' => TRUE,
     'modified' => TRUE,
     'locked' => FALSE,
     );
   $type = (object) _node_type_set_defaults($type);
-  node_type_save($type);
+  $status = node_type_save($type);
   // Set to published and sticky as default for content type.
   variable_set('node_options_'. $type->type , array('status', 'sticky'));
-  // Disable comments for content type.
+  // Disable comments for this content type.
   variable_set('comment_'. $type->type, '0');
 
   drupal_set_message(t('<em>Admin message</em> was installed. Enable the block "Admin messages" to display messages to users.'));
-  drupal_set_message('Content type "Admin message" was created - use it to create messages.');
+
+  if ($status == SAVED_UPDATED) {
+    drupal_set_message(t('The content type %name has been updated.', array('%name' => $type->name)));
+  }
+  elseif ($status == SAVED_NEW) {
+    drupal_set_message(t('The content type %name has been added - use it to create messages.', array('%name' => $type->name)));
+  }  
+
 }
 
 /**
  * Implementation of hook_uninstall().
  */
 function admin_message_uninstall() {
-  db_query('DROP TABLE {admin_message}');
-  db_query('DROP TABLE {admin_message_close}');
+  drupal_uninstall_schema('admin_message');
+
 }
Index: INSTALL.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/admin_message/INSTALL.txt,v
retrieving revision 1.1
diff -u -r1.1 INSTALL.txt
--- INSTALL.txt	21 Jul 2007 12:38:29 -0000	1.1
+++ INSTALL.txt	20 Nov 2008 17:46:35 -0000
@@ -1,4 +1,4 @@
-// $Id: INSTALL.txt,v 1.1 2007/07/21 12:38:29 fajerstarter Exp $
+// $Id$
 
 INSTALLATION
 ------------
@@ -17,6 +17,9 @@
    anonymous users: configure the block and check "authenticated user" at
    "Show block for specific roles".
    
+   You will also have to grant the "close admin messages" permission to roles
+   you would like to be able to close your admin messages.
+   
 4. CREATE A MESSAGE
     
    Go to "Create content" -> "Admin message" and enter a message.
@@ -26,3 +29,30 @@
    NOTE: There is no access control included, just the standard access provided 
    by Drupal, which means that all users with "access content" permission can 
    view messages. So don't provide any sensitive information.
+
+ 5. THEMING
+ 
+   Admin messages are themed via a single theme fuction. Copy this function to
+   your theme's template.php, replace 'theme' with your theme's name, and configure
+   as needed.
+   
+   /*
+    * Theme the admin message's output
+    * 
+    * @param $node
+    *   The entire admin message node object
+    * @param $close_link
+    *   A boolean value of whether or not user has access to close the message
+    * @return
+    *   The themed output for display within the admin message block
+    */
+   function theme_admin_message_message($node, $close_link) {
+     $output  = '<div class="admin-message sticky">';
+     if($close_link) {
+       // Changing the class on the link will make the javascript no longer function.
+       $output .= l(t('Close'), 'admin_message/close/'. $node->nid, array('attributes'=>array('class' => 'admin-message-close', 'title' => t('Close this message'))));
+     }
+     $output .= node_view($node);
+     $output .= '</div>';
+     return $output;
+   }
\ No newline at end of file
Index: admin_message.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/admin_message/admin_message.module,v
retrieving revision 1.1
diff -u -r1.1 admin_message.module
--- admin_message.module	21 Jul 2007 12:38:29 -0000	1.1
+++ admin_message.module	20 Nov 2008 17:46:35 -0000
@@ -1,33 +1,35 @@
 <?php
-// $Id: admin_message.module,v 1.1 2007/07/21 12:38:29 fajerstarter Exp $
+// $Id$
 
 /**
- * @file 
+ * @file
  * Module to display messages that can be individually closed by logged in users.
- * 
  */
 
 /**
  * Implementation of hook_menu().
  */
-function admin_message_menu($may_cache) {
+function admin_message_menu() {
  $items = array();
- 
- if ($may_cache) {
-   global $user;
-   $items[] = array(
-      'path' => 'admin_message/close',
-      'callback' => 'admin_message_close',
-      // Only access checking for now is that only authenticated user can close messages.
-      'access' => ($user->uid > 0),
-      'type' => MENU_CALLBACK,
-    );
- }
- 
+
+ $items['admin_message/close/%'] = array(
+    'page callback' => 'admin_message_close',
+    'page arguments' => array(2),
+    'access arguments' => array('close admin messages'),
+    'type' => MENU_CALLBACK,
+  );
+  
   return $items;
 }
 
 /**
+ * Implementation of hook_perm().
+ */
+function admin_message_perm() {
+  return array('close admin messages');
+}
+
+/**
  * Implementation of hook_nodeapi().
  */
 function admin_message_nodeapi(&$node, $op, $teaser, $page) {
@@ -59,8 +61,8 @@
       }
       break;
 
-     case 'view':
-       break;
+    case 'view':
+      break;
   }
 }
 
@@ -68,6 +70,7 @@
   global $user;
   db_query('DELETE FROM {admin_message_close} WHERE nid = %d AND uid = %d', $nid, $user->uid);
   db_query('INSERT INTO {admin_message_close} (nid, uid) VALUES (%d, %d)', $nid, $user->uid);
+  drupal_goto();
 }
 
 /**
@@ -87,7 +90,7 @@
     case 'list':
       $blocks['admin_message']['info'] = t('Admin messages');
       return $blocks;
-      
+
     case 'view':
       switch ($delta) {
         case 'admin_message':
@@ -100,60 +103,48 @@
 
 function admin_message_list_messages() {
   global $user;
-  
+  $output = '';
   $result = db_query(db_rewrite_sql("SELECT n.nid, n.created, a.keep_new, a.php_visibility FROM {node} n LEFT JOIN {admin_message} a ON n.nid = a.nid WHERE n.sticky = 1 AND n.status = 1 AND n.type = 'admin_message' ORDER BY n.created DESC"));
-  $message_displayed = false;
-
-  if (db_num_rows($result)) {
-    while ($item = db_fetch_object($result)) {
-      $php_visibility = empty($item->php_visibility) ? true : drupal_eval($item->php_visibility);
-      $closed_by_user = db_fetch_object(db_query("SELECT a.nid FROM {admin_message_close} a WHERE a.nid = %d AND a.uid = %d", $item->nid, $user->uid));
-
-      if (empty($closed_by_user) && ($item->created >= $user->created || $item->keep_new) && $php_visibility) {
-        $node = node_build_content(node_load($item->nid));
-        $output .= theme('admin_message_message', $node, admin_message_close_link($node->nid));
-        $message_displayed = true;
-      }
-    }
-    if ($message_displayed) {
-      // Insert JavaScript and CSS if messages are displayed.s 
-      drupal_add_js(drupal_get_path('module', 'admin_message') .'/admin_message.js', 'module');
-      drupal_add_css(drupal_get_path('module', 'admin_message') .'/admin_message.css', 'module');
+  $message_displayed = FALSE;
+  $num_rows = FALSE;
+  while ($item = db_fetch_object($result)) {
+    $php_visibility = empty($item->php_visibility) ? TRUE : drupal_eval($item->php_visibility);
+    $closed_by_user = db_fetch_object(db_query("SELECT a.nid FROM {admin_message_close} a WHERE a.nid = %d AND a.uid = %d", $item->nid, $user->uid));
+
+    if (empty($closed_by_user) && ($item->created >= $user->created || $item->keep_new) && $php_visibility) {
+      $node = node_build_content(node_load($item->nid));
+      $output .= theme('admin_message_message', $node, user_access("close admin messages"));
     }
-  }
-  return $output;
-}
 
-function theme_admin_message_message($node, $close_link) {
-  $output = '<div class="admin-message sticky">';
-  $output .= $close_link;
-  $output .= drupal_render($node->content);
-  $output .= '</div>';
-  return $output;
-}
+    $message_displayed = TRUE;
+    $num_rows = TRUE;
+  }
 
-function admin_message_close_link($nid) {
-  $output = l(t('Close'), 'admin_message/close/'. $nid, array('class' => 'close'));
+  if ($message_displayed && $num_rows) {
+    // Insert JavaScript and CSS if messages are displayed.
+    drupal_add_js(drupal_get_path('module', 'admin_message') .'/admin_message.js', 'module');
+    drupal_add_css(drupal_get_path('module', 'admin_message') .'/admin_message.css', 'module');
+  }
   return $output;
 }
 
 /**
  * Implementation of hook_form_alter().
  */
-function admin_message_form_alter($form_id, &$form) {
+function admin_message_form_alter(&$form, &$form_state, $form_id) {
   if ('admin_message_node_form' == $form_id) {
     $form['admin_message'] = array(
       '#type' => 'fieldset',
       '#title' => t('Message visibility'),
-      '#collapsible' => true,
-      '#collapsed' => false,
+      '#collapsible' => TRUE,
+      '#collapsed' => FALSE,
     );
     // "Hijack" the sticky option.
     $sticky_field = $form['options']['sticky'];
     unset($form['options']['sticky']);
     $form['admin_message']['sticky'] =  $sticky_field;
     $form['admin_message']['sticky']['#title'] = t('Show message (sticky)');
-    
+
     // Keep new.
     $form['admin_message']['admin_message_keep_new'] = array(
       '#type' => 'checkbox',
@@ -161,7 +152,7 @@
       '#default_value' => isset($form['#node']->admin_message_keep_new) ? $form['#node']->admin_message_keep_new : variable_get('admin_message_keep_new_'. $type, 0),
       '#prefix' => '<div id="admin-message-toggle">',
     );
-    
+
     // PHP visibility form.
     $result = db_fetch_object(db_query('SELECT php_visibility FROM {admin_message} WHERE nid = %d', $form['nid']['#value']));
     $php_visibility_code = $result->php_visibility;
@@ -177,8 +168,36 @@
     else {
       $form['admin_message']['admin_message_keep_new']['#suffix'] = '</div>';
     }
-    
-    drupal_add_js(drupal_get_path('module', 'admin_message') .'/admin_message_form.js', 'module');
 
+    drupal_add_js(drupal_get_path('module', 'admin_message') .'/admin_message_form.js', 'module');
   }
 }
+
+function admin_message_theme() {
+  return array(
+    'admin_message_message' => array(
+      'arguments' => array('node' => NULL, 'close_link' => FALSE),
+    ),
+  );
+}
+
+/*
+ * Theme the admin message's output
+ * 
+ * @param $node
+ *   The entire admin message node object
+ * @param $close_link
+ *   A boolean value of whether or not user has access to close the message
+ * @return
+ *   The themed output for display within the admin message block
+ */
+function theme_admin_message_message($node, $close_link) {
+  $output  = '<div class="admin-message sticky">';
+  if($close_link) {
+    // Changing the class on the link will make the javascript no longer function.
+    $output .= l(t('Close'), 'admin_message/close/'. $node->nid, array('attributes'=>array('class' => 'admin-message-close', 'title' => t('Close this message'))));
+  }
+  $output .= node_view($node);
+  $output .= '</div>';
+  return $output;
+}
\ No newline at end of file
Index: admin_message_form.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/admin_message/admin_message_form.js,v
retrieving revision 1.1
diff -u -r1.1 admin_message_form.js
--- admin_message_form.js	21 Jul 2007 12:38:29 -0000	1.1
+++ admin_message_form.js	20 Nov 2008 17:46:35 -0000
@@ -1,13 +1,13 @@
-// $Id: admin_message_form.js,v 1.1 2007/07/21 12:38:29 fajerstarter Exp $
+// $Id$
 
 // Global Killswitch
 if (Drupal.jsEnabled) {
   $(document).ready(function() {  
     // Hide the other options if "Show message (sticky)" is not checked.    
-    $("#admin-message-toggle")[['hide', 'show'][Number($("#edit-sticky")[0].checked)]]()
+    $("#admin-message-toggle")[['hide', 'show'][Number($("#edit-sticky")[0].checked)]]();
     
     $("#edit-sticky").click(function() {
       $("#admin-message-toggle")[['hide', 'show'][Number(this.checked)]]();
-    })
+    });
   });
 }
Index: admin_message.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/admin_message/admin_message.info,v
retrieving revision 1.1
diff -u -r1.1 admin_message.info
--- admin_message.info	21 Jul 2007 12:38:29 -0000	1.1
+++ admin_message.info	20 Nov 2008 17:46:35 -0000
@@ -1,4 +1,5 @@
-; $Id: admin_message.info,v 1.1 2007/07/21 12:38:29 fajerstarter Exp $
+; $Id$
 
 name = Admin message
 description = Display messages that can be individually closed by logged in users.
+core = 6.x
\ No newline at end of file
Index: admin_message.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/admin_message/admin_message.css,v
retrieving revision 1.1
diff -u -r1.1 admin_message.css
--- admin_message.css	21 Jul 2007 12:38:29 -0000	1.1
+++ admin_message.css	20 Nov 2008 17:46:35 -0000
@@ -1,4 +1,4 @@
-/* $Id: admin_message.css,v 1.1 2007/07/21 12:38:29 fajerstarter Exp $ */
+/* $Id$ */
 
 .admin-message .close {
   float: right;