diff -urp contact2/contact.install contact/contact.install
--- contact2/contact.install	2007-08-30 13:39:56.000000000 -0300
+++ contact/contact.install	2007-09-25 14:10:43.000000000 -0300
@@ -43,3 +43,18 @@ function contact_uninstall() {
   variable_del('contact_form_information');
   variable_del('contact_hourly_threshold');
 }
+
+/**
+ * Implementation of hook_update_x().
+ */
+function contact_update_1() {
+  $item = array();
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':    
+    case 'pgsql':
+      $item[] = update_sql("ALTER TABLE {contact} ADD COLUMN roles VARCHAR(255) NOT NULL");
+      break;
+  }
+  return $item;
+}
Only in contact: contact.install~
diff -urp contact2/contact.module contact/contact.module
--- contact2/contact.module	2007-08-30 13:39:56.000000000 -0300
+++ contact/contact.module	2007-09-25 14:17:50.000000000 -0300
@@ -59,7 +59,7 @@ function contact_menu($may_cache) {
       'title' => t('Add category'),
       'callback' => 'drupal_get_form',
       'callback arguments' => array('contact_admin_edit'),
-      'access' => user_access('administer site configuration'),
+      'access' => user_access('administer site configuration'), 
       'type' => MENU_LOCAL_TASK,
       'weight' => 1,
     );
@@ -188,6 +188,21 @@ function contact_admin_edit($cid = NULL)
     '#default_value' => $edit['selected'],
     '#description' => t('Set this to <em>Yes</em> if you would like this category to be selected by default.'),
   );
+  
+  $rs = db_query("SELECT * FROM {role}");
+  $roles = array();
+  while ($row = db_fetch_object($rs)) {
+    $roles[$row->rid] = $row->name;    
+  }
+  
+  $form['roles'] = array(
+    '#title' => t('Roles'),
+    '#type'  => 'select',
+    '#multiple' => true,
+    '#options' => $roles,
+    '#default_value' => empty($edit['roles']) ? 1 : explode(',', $edit['roles']),
+    '#description' => t('Choose the roles that can view this category.')
+  );
   $form['cid'] = array('#type' => 'value',
     '#value' => $edit['cid'],
   );
@@ -232,14 +247,14 @@ function contact_admin_edit_submit($form
     $recipients[$key] = trim($recipient);
   }
   $form_values['recipients'] = implode(',', $recipients);
+  $form_values['roles'] = implode(',', $form_values['roles']);  
   if (arg(3) == 'add') {
-    db_query("INSERT INTO {contact} (category, recipients, reply, weight, selected) VALUES ('%s', '%s', '%s', %d, %d)", $form_values['category'], $form_values['recipients'], $form_values['reply'], $form_values['weight'], $form_values['selected']);
+    db_query("INSERT INTO {contact} (category, recipients, reply, weight, selected, roles) VALUES ('%s', '%s', '%s', %d, %d, '%s')", $form_values['category'], $form_values['recipients'], $form_values['reply'], $form_values['weight'], $form_values['selected'], $form_values['roles']);
     drupal_set_message(t('Category %category has been added.', array('%category' => $form_values['category'])));
     watchdog('mail', t('Contact form: category %category added.', array('%category' => $form_values['category'])), WATCHDOG_NOTICE, l(t('view'), 'admin/build/contact'));
-
   }
   else {
-    db_query("UPDATE {contact} SET category = '%s', recipients = '%s', reply = '%s', weight = %d, selected = %d WHERE cid = %d", $form_values['category'], $form_values['recipients'], $form_values['reply'], $form_values['weight'], $form_values['selected'], $form_values['cid']);
+    db_query("UPDATE {contact} SET category = '%s', recipients = '%s', reply = '%s', weight = %d, selected = %d, roles = '%s' WHERE cid = %d", $form_values['category'], $form_values['recipients'], $form_values['reply'], $form_values['weight'], $form_values['selected'], $form_values['roles'], $form_values['cid']);
     drupal_set_message(t('Category %category has been updated.', array('%category' => $form_values['category'])));
     watchdog('mail', t('Contact form: category %category updated.', array('%category' => $form_values['category'])), WATCHDOG_NOTICE, l(t('view'), 'admin/build/contact'));
   }
@@ -276,6 +291,10 @@ function contact_admin_delete_submit($fo
 }
 
 function contact_admin_settings() {
+  $form['contact_form_category_title'] = array('#type' => 'textfield',
+    '#title' => t('Category title field'),
+    '#default_value' => variable_get('contact_form_category_title', t('Category')),
+  );    
   $form['contact_form_information'] = array('#type' => 'textarea',
     '#title' => t('Additional information'),
     '#default_value' => variable_get('contact_form_information', t('You can leave a message using the contact form below.')),
@@ -417,12 +436,15 @@ function contact_site_page() {
 
 function contact_mail_page() {
   global $user;
-
-  $result = db_query('SELECT cid, category, selected FROM {contact} ORDER BY weight, category');
+  $user_roles = array_keys($user->roles);
+  $result = db_query('SELECT cid, category, selected, roles FROM {contact} ORDER BY weight, category');
   while ($category = db_fetch_object($result)) {
-    $categories[$category->cid] = $category->category;
-    if ($category->selected) {
-      $default_category = $category->cid;
+    $roles = explode(',', $category->roles);
+    if (count(array_intersect($user_roles, $roles))) {
+      $categories[$category->cid] = $category->category;
+      if ($category->selected) {
+        $default_category = $category->cid;
+      }
     }
   }
 
@@ -453,7 +475,7 @@ function contact_mail_page() {
         $categories = array(t('--')) + $categories;
       }
       $form['cid'] = array('#type' => 'select',
-        '#title' => t('Category'),
+        '#title' => variable_get('contact_form_category_title', t('Category')),
         '#default_value' => $default_category,
         '#options' => $categories,
         '#required' => TRUE,
Only in contact: contact.module~
