cvs diff: Diffing .
? .project
Index: search_restrict.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/search_restrict/search_restrict.module,v
retrieving revision 1.2
diff -u -p -r1.2 search_restrict.module
--- search_restrict.module	25 Jul 2009 23:21:18 -0000	1.2
+++ search_restrict.module	29 Jul 2009 23:05:53 -0000
@@ -104,4 +104,36 @@ function search_restrict_db_rewrite_sql(
       return array('where' => $where);
     }
   }
-}
\ No newline at end of file
+}
+
+/**
+ * Implementation of hook_form_alter().
+ */
+function search_restrict_form_alter(&$form, $form_state, $form_id) {
+  switch ($form_id) {
+    case 'search_form':
+      // If the content type is restricted, don't show it in the content types
+      // list.
+      global $user;
+
+      if ($user->uid == 1) {
+        return;
+      }
+
+      $content_type_restrictions = variable_get('search_restrict_content_type', array());
+
+      foreach ($content_type_restrictions as $type => $roles) {
+        $access = FALSE;
+        foreach ($roles as $role_id => $selected) {
+          if (!empty($selected) && in_array($role_id, $user->roles)) {
+            $access = TRUE;
+            break;
+          }
+        }
+        if (!$access) {
+          unset($form['advanced']['type']['#options'][$type]);
+        }
+      }
+      break;
+  }
+}
