Index: custom_search.module
=========================================================
--- custom_search.module	(revision 1.1.2.2)
+++ custom_search.module	Wed Mar 10 13:36:19 CET 2010
@@ -22,13 +22,13 @@
     'description'       => 'Customize the default search, change labels, default texts, ordering, and display content types and taxonomy selectors.',
     'page callback'     => 'drupal_get_form',
     'page arguments'    => array('custom_search_admin'),
-    'access arguments'  => array('administer custom search settings'),
+    'access arguments'  => array('administer custom search'),
     'file'              => 'custom_search.admin.inc',
   );
   $items['admin/settings/custom_search/settings'] = array(
     'title'             => 'Settings',
     'description'       => 'Change the labels, the default texts and the ordering of elements.',
-    'access arguments'  => array('administer custom search settings'),
+    'access arguments'  => array('administer custom search'),
     'type'              => MENU_DEFAULT_LOCAL_TASK,
     'weight'            => 0,
   );
@@ -36,7 +36,7 @@
     'title'             => 'Content',
     'description'       => 'Select the search types to present as search options in the search block.',
     'page arguments'    => array('custom_search_content_admin'),
-    'access arguments'  => array('administer custom search settings'),
+    'access arguments'  => array('administer custom search'),
     'file'              => 'custom_search.admin.inc',
     'type'              => MENU_LOCAL_TASK,
     'weight'            => 1,
@@ -45,7 +45,7 @@
     'title'             => 'Taxonomy',
     'description'       => 'Select the vocabularies to present as search options in the search block.',
     'page arguments'    => array('custom_search_taxonomy_admin'),
-    'access arguments'  => array('administer custom search settings'),
+    'access arguments'  => array('administer custom search'),
     'file'              => 'custom_search.admin.inc',
     'type'              => MENU_LOCAL_TASK,
     'weight'            => 2,
@@ -54,11 +54,18 @@
 }
 
 /**
+ * Implementation of hook_perm().
+ */
+function custom_search_perm() {
+  return array('administer custom search', 'use custom search');
+}
+
+/**
  * Implementation of hook_form_alter().
  */
 function custom_search_form_alter(&$form, $form_state, $form_id) {
 
-  if ($form_id == 'search_theme_form' || $form_id == 'search_block_form') {
+  if (user_access('use custom search') && ($form_id == 'search_theme_form' || $form_id == 'search_block_form')) {
 
     // Get values.
     if (module_exists('i18nstrings')) {
@@ -263,17 +270,21 @@
  * Implementation of hook_init().
  */
 function custom_search_init() {
-  drupal_add_js(drupal_get_path('module', 'custom_search') . '/custom_search.js');
+  if(user_access('use custom search')) {
+    drupal_add_js(drupal_get_path('module', 'custom_search') . '/custom_search.js');
+  }
 }
 
 /**
  * Implementation of hook_theme().
  */
 function custom_search_theme() {
-  return array(
-    'custom_search_javascript'  => array('arguments' => array()),
-    'custom_search_sort_form'   => array('arguments' => array('form' => NULL)),
-  );
+  if(user_access('use custom search')) {
+    return array(
+      'custom_search_javascript'  => array('arguments' => array()),
+      'custom_search_sort_form'   => array('arguments' => array('form' => NULL)),
+    );
+  }
 }
 
 /**
