Can I make it for searches only (disable replace)

steve02476 - March 22, 2009 - 18:20
Project:Search and Replace Scanner
Version:6.x-1.0
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

Hi, this seems like a wonderful module for batch replacements, but right now I only need the search portion of it so my staff can search for usage of photographs in the text (html img strings). Those don't show up using the regular Drupal search, but they are found perfectly by this module. But, I want my staff to deal with what they find manually, not be automated replacement. Is there a good way for me to disable the Replace button on this module. (Best of all would be to have the Replace button only active for certain roles and not active for other roles.) Thanks!!!!

#1

aasarava - March 25, 2009 - 19:13
Category:support request» feature request

Hi Steve,

Thanks for the idea, I'll consider it for a future version.

In the meantime, are you familiar with the hook_form_alter() function? The best option would be for you to write your own module that does nothing more than implements hook_form_alter() to hide the "replace" field and button on the Search form. You could add role-checking in your hook_form_alter() function to only hide the field and button for certain roles.

Barring that, the other option -- which I'm not supposed to advocate -- is for you to edit scanner.module and comment out the following lines in the scanner_form() function:

<?php
  $form
['replace'] = array(
   
'#type' => 'textfield',
   
'#default_value' => $replace,
   
'#title' => t('Step 2: Replace with'),
   
'#maxlength' => 256,
  );
 
$form['submit_replace'] = array(
   
'#type' => 'submit',
   
'#value' => t('Replace'),
  );
?>

The reason this is usually frowned up on is that your changes will get overwritten if you ever upgrade to a newer version of the Scanner module.

#2

steve02476 - March 26, 2009 - 00:24

Thanks for the tips! I think writing my own module is beyond my abilities, but if I ever get a yearning to try module development out maybe that would be a good first try? Also, thanks for the module editing tip - I could do that, but I think I'll just restrict permissions to use Scanner for now.

 
 

Drupal is a registered trademark of Dries Buytaert.