Index: search_restrict.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/search_restrict/Attic/search_restrict.info,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 search_restrict.info
--- search_restrict.info	21 Aug 2008 09:08:29 -0000	1.1.2.1
+++ search_restrict.info	16 Feb 2009 18:14:30 -0000
@@ -1,8 +1,4 @@
 ; $Id: search_restrict.info,v 1.1.2.1 2008/08/21 09:08:29 MegaGrunt Exp $
 name = Search Restrict
 description =  "Exclude specific content from search results if user doesn't have privileges."
-
-
-
-
-
+core = 6.x
Index: search_restrict.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/search_restrict/Attic/search_restrict.install,v
retrieving revision 1.1.2.2
diff -u -p -r1.1.2.2 search_restrict.install
--- search_restrict.install	26 Sep 2008 10:49:02 -0000	1.1.2.2
+++ search_restrict.install	16 Feb 2009 18:15:30 -0000
@@ -7,6 +7,18 @@
 function search_restrict_install() {
   // Set a low weight so the module is called before node module.
   db_query("UPDATE {system} SET weight = -10 WHERE name = 'search_restrict'");
+
+  $types = node_get_types('names', NULL, FALSE);
+
+  $var_types = array();
+  foreach ($types as $key => $type) {
+    $var_types[$key] = array();
+  }
+
+  variable_set('search_restrict_content_type', $var_types);
+  foreach ($types as $key => $type) {
+    variable_set('search_restrict_roles_' . $key, array());
+  }
 }
 
 /**
@@ -14,4 +26,9 @@ function search_restrict_install() {
  */
 function search_restrict_uninstall() {
   variable_del('search_restrict_content_type');
-}
\ No newline at end of file
+
+  $types = node_get_types('names', NULL, FALSE);
+  foreach ($types as $key => $type) {
+    variable_del('search_restrict_roles_' . $key);
+  }
+}
Index: search_restrict.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/search_restrict/Attic/search_restrict.module,v
retrieving revision 1.1.2.4
diff -u -p -r1.1.2.4 search_restrict.module
--- search_restrict.module	26 Sep 2008 10:49:02 -0000	1.1.2.4
+++ search_restrict.module	16 Feb 2009 18:19:32 -0000
@@ -1,105 +1,107 @@
-<?php  
-// $Id: search_restrict.module,v 1.1.2.4 2008/09/26 10:49:02 MegaGrunt Exp $    
-
-/**
- * Implementation of hook_perm().
- */
-function search_restrict_perm() {
-  return array('administer search_restrict');
-}
- 
-/**
- * Implementation of hook_form_alter().
- */
-function search_restrict_form_alter($form_id, &$form) {
-  switch ($form_id) {
-    case 'node_type_form':
-      search_restrict_content_type_form($form);
-      break;
-  }
-}
-
-/**
- *  Alter content type forms to include search restrict options
- */
-function search_restrict_content_type_form(&$form) {
-  $roles = user_roles();
-  ksort($roles);
-  $content_type_restrictions = variable_get('search_restrict_content_type', array());
-
-  $form['search_restrict'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Search Restrict'),
-    '#description' => t('Select which user roles can search for this content type. By default all roles can search.'),
-    '#collapsible' => TRUE,
-    '#collapsed' => TRUE,
-    '#access' => user_access('administer search_restrict'),
-  );
-  
-  $form['search_restrict']['search_restrict_roles'] = array(
-    '#type' => 'checkboxes',
-    '#title' => t('Roles'),
-    '#description' => t('If all checkboxes are unselected then everyone can search.'),
-    '#options' => $roles,
-    '#default_value' => $content_type_restrictions[$form['#node_type']->type],
-  );
-  // use custom submit function to avoid a query at time of search to get the list of content types
-  $form['#submit']['search_restrict_content_type_form_submit'] = array();
-}
-
-/**
- *  use custom submit function to avoid a query at time of search to get the list of content types
- */
-function search_restrict_content_type_form_submit($form_id, $form_values) {
-  $content_type_restrictions = variable_get('search_restrict_content_type', array());
-  $content_type_restrictions[$form_values['type']] = $form_values['search_restrict_roles'];
-  variable_set('search_restrict_content_type', $content_type_restrictions);
-} 
-
-
-function search_restrict_db_rewrite_sql($query, $primary_table, $primary_field, $args) {
-  global $user;
-  if ($user->uid == 1) return;
-
-  $user_roles = $user->roles;
-  $excluded_types = array();
-
-  if ($query == '' && $primary_table == 'n' && $primary_field = 'nid' && empty($args)) {
-
-    $content_type_restrictions = variable_get('search_restrict_content_type', array());
-    
-    foreach ($content_type_restrictions as $type => $roles) {
-       
-      $access = FALSE;
-      $access_false = array();
-      $access_true = array();
-      
-      // list included and excluded roles
-      foreach ($roles as $role_id => $selected) {
-        if (empty($selected)) { 
-          $access_false[] = $role_id;
-        }
-        else {
-          $access_true[] = $role_id;  
-        } 
-      }
-    
-      // if no roles or all roles have been selected then everyone has access skip this content type 
-      if (!empty($access_true) && !empty($access_false)) {
-        // if user has role in include list skip this content type
-        foreach ($access_true as $role_selected) {
-          if (!empty($user_roles[$role_selected])) $access = TRUE;
-        } 
-      
-        // user doesn't have any roles that are allowed to search this content type
-        if (empty($access)) $excluded_types[] =  $type; 
-      }
-    }
-
-    if (!empty($excluded_types)) {
-      $where = " n.type NOT IN ('". join("','", $excluded_types) ."') ";
-
-      return array('where' => $where);
-    }
-  }
+<?php  
+// $Id: search_restrict.module,v 1.1.2.4 2008/09/26 10:49:02 MegaGrunt Exp $    
+
+/**
+ * Implementation of hook_perm().
+ */
+function search_restrict_perm() {
+  return array('administer search_restrict');
+}
+ 
+/**
+ * Implementation of hook_form_FORM_alter().
+ */
+function search_restrict_form_node_type_form_alter(&$form, &$form_state) {
+  search_restrict_content_type_form($form);
+}
+
+/**
+ * Alter content type forms to include search restrict options.
+ */
+function search_restrict_content_type_form(&$form) {
+  $roles = user_roles();
+  ksort($roles);
+  $content_type_restrictions = variable_get('search_restrict_content_type', array());
+
+  $form['search_restrict'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Search Restrict'),
+    '#description' => t('Select which user roles can search for this content type. By default all roles can search.'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+    '#access' => user_access('administer search_restrict'),
+  );
+  
+  $form['search_restrict']['search_restrict_roles'] = array(
+    '#type' => 'checkboxes',
+    '#title' => t('Roles'),
+    '#description' => t('If all checkboxes are unselected then everyone can search.'),
+    '#options' => $roles,
+    '#default_value' => $content_type_restrictions[$form['#node_type']->type],
+  );
+  // Use custom submit function to avoid a query at time of search to get the
+  // list of content types.
+  $form['#submit'][] = 'search_restrict_content_type_form_submit';
+}
+
+/**
+ *  use custom submit function to avoid a query at time of search to get the list of content types
+ */
+function search_restrict_content_type_form_submit($form, &$form_state) {
+  $content_type_restrictions = variable_get('search_restrict_content_type', array());
+  $content_type_restrictions[$form_state['values']['type']] = $form_state['values']['search_restrict_roles'];
+  variable_set('search_restrict_content_type', $content_type_restrictions);
+}
+
+/**
+ * Implementation of hook_db_rewrite_sql().
+ */
+function search_restrict_db_rewrite_sql($query, $primary_table, $primary_field, $args) {
+  global $user;
+
+  if ($user->uid == 1) {
+    return;
+  }
+
+  $user_roles = $user->roles;
+  $excluded_types = array();
+
+  if ($query == '' && $primary_table == 'n' && $primary_field = 'nid' && empty($args)) {
+    $content_type_restrictions = variable_get('search_restrict_content_type', array());
+
+    foreach ($content_type_restrictions as $type => $roles) {
+      $access = FALSE;
+      $access_false = array();
+      $access_true = array();
+
+      // List included and excluded roles.
+      foreach ($roles as $role_id => $selected) {
+        if (empty($selected)) {
+          $access_false[] = $role_id;
+        }
+        else {
+          $access_true[] = $role_id;
+        }
+      }
+
+      // If no roles or all roles have been selected then everyone has access
+      // skip this content type.
+      if (!empty($access_true) && !empty($access_false)) {
+        // If user has role in include list skip this content type.
+        foreach ($access_true as $role_selected) {
+          if (!empty($user_roles[$role_selected])) $access = TRUE;
+        }
+
+        // User doesn't have any roles that are allowed to search this
+        // content-type.
+        if (empty($access)) $excluded_types[] =  $type;
+      }
+    }
+
+    if (!empty($excluded_types)) {
+      $where = " n.type NOT IN ('". join("','", $excluded_types) ."') ";
+
+      return array('where' => $where);
+    }
+  }
 }
\ No newline at end of file
