I'm using this in a D7 project that I've just starting, so here is the ported version that I done this evening.
I needed the "exclude all" from the search, so I also implemented this feature. #602338: Pls, make it possible to disallow *ALL* roles to search content per (!) content type
The logic behind parsing the roles has been reduced to an array_filter / array_intercept_keys and this reduced the amount of code required.
There has been some minor reformatting, strict PHP warning errors resolved and removed access to the advanced form type element when there is 0 or 1 types avaliable. It didn't make any sense to me to show a single checkbox in a filter form!
Feel free to use or ignore.
Comments
Comment #1
alan d. commentedI've included the patch against 6--1 Branch (You must be working via a tagged version as the branch was not up to date) and a zip since there were significant changes.
Comment #2
johnpitcairn commentedSubscribe. We're considering specifying Drupal 7 for a site that has a fairly long deadline, I'm assessing the D7 status of modules we might need.
Comment #3
mrfelton commentedsubs. Can we get whats here into a new CVS branch?
Comment #4
davemurphy commentedsubscribe
Comment #5
tomcatuk commentedsubbing
Comment #6
danny_joris commentedsubscribing
Comment #7
Niklas Fiekas commentedSubscribe.
Comment #8
Niklas Fiekas commentedAwsome patch, thank you.
Just a small fix.
Comment #9
Leeteq commentedHow about a D7 branch?
Comment #10
jeffschulerRerolled #1 against search_restrict HEAD (from git,) applied change from #8, and corrected all suggestions from Coder module (on "minor" setting.)
Is this module still being maintained?
Comment #11
robert castelo commentedThanks, I'll review again at the weekend.
Comment #12
Niklas Fiekas commentedjeffschuler's patch in #10 looks good, applied and works. Did you have time to review it, yet?
Comment #13
mraichelson commentedsubscribe
Comment #14
sijuwi commentedOn our site: www.freedomfromtorture.org if you type in certain phrases, eg "Body of Evidence" the page crashes for anonymous users:
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ESCAPE '\\') AND .................
Comment #15
alan d. commentedTo assist, actually include the mysql dump otherwise to could be difficult to replicate.
Comment #16
gagarine commentedThanks for the patch in #10. Some point I found:
#search_restrict_content_type_form is useless we can do the job directly in search_restrict_form_node_type_form_alter
Take a look at comment_form_node_type_form_alter function (core comment module).
#add the settings in vertical tab
In function search_restrict_content_type_form(&$form) add the form element in $form['additional_settings']['search_restrict'].
With that you also don't need the ugly array_unshift.EDIT no this one is for adding the additional submit function.# Exclude all roles should not be under the "role" subtitle because is not a role. "$roles = array('-1' => $msg) + $roles;" is also hard to read.
# Long description. "All roles can search unless "%msg" is selected" is enough.
Comment #17
alan d. commentedPS: I've ported / merged features onto search_config project. The core restrictions on search are permission based, and the UI settings are under the main search config page.
Comment #18
jeffschulerHere's Alan D.s' commit to search_config, which started with #1197560: Refactored Drupal 7 port (in the search_config project queue.)
Comment #19
alan d. commentedHi jeff, use the project page, the first release of mine was 7.x-1.0-beta1
Comment #20
WGViana commentedsubscribing
Comment #21
robert castelo commentedD7 version released - thanks for your contributions.
Comment #22
alan d. commentedFor context, I'm recycling this issue.
I'm using the same code in search_config, and hit a nasty bug in the count query (a core Drupal issue), so you may want to investigate / modify this. Here is the change that I had to do there:
The resulting SQL is the same, the change was from not using
type NOT IN(type a, type b)totype != type a AND type != type bComment #23
alan d. commentedThe core bug has been fixed in Drupal 7.8, maybe a message on the project page about this requirement to finish this issue off!
For reference:
#1112854: Subqueries use wrong arguments
#1202416: Search is not working with node access turned on