Now all modules are in core modules folder
This commit is contained in:
parent
5ba1cdfa0b
commit
05b6a91b0c
1907 changed files with 0 additions and 0 deletions
|
@ -0,0 +1,60 @@
|
|||
********************************************************************
|
||||
D R U P A L M O D U L E
|
||||
********************************************************************
|
||||
Name: Search Restrict Apache Solr
|
||||
Author: Robert Castelo <www.codepositive.com>
|
||||
Drupal: 6.x
|
||||
********************************************************************
|
||||
DESCRIPTION:
|
||||
|
||||
Restrict by role who can search for each content type when Apache Solr is being used.
|
||||
|
||||
|
||||
|
||||
********************************************************************
|
||||
PREREQUISITES:
|
||||
|
||||
Apache Solr Integration module (Drupal core).
|
||||
|
||||
|
||||
|
||||
********************************************************************
|
||||
INSTALLATION:
|
||||
|
||||
Note: It is assumed that you have Drupal up and running. Be sure to
|
||||
check the Drupal web site if you need assistance. If you run into
|
||||
problems, you should always read the INSTALL.txt that comes with the
|
||||
Drupal package and read the online documentation.
|
||||
|
||||
1. Place the entire module directory into your Drupal directory:
|
||||
sites/all/modules/
|
||||
|
||||
|
||||
2. Enable the module modules by navigating to:
|
||||
|
||||
administer > build > modules
|
||||
|
||||
Click the 'Save configuration' button at the bottom to commit your
|
||||
changes.
|
||||
|
||||
|
||||
|
||||
********************************************************************
|
||||
USAGE:
|
||||
|
||||
On the configuration form of each each content type set the role(s)
|
||||
that can search for nodes of that content type.
|
||||
|
||||
|
||||
********************************************************************
|
||||
TO DO
|
||||
|
||||
Write tests
|
||||
|
||||
|
||||
********************************************************************
|
||||
ACKNOWLEDGEMENT
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
name = Search Restrict Apache Solr
|
||||
description = "Exclude specific content from Apache Solr search results if user doesn't have privileges."
|
||||
package = Core - extended
|
||||
dependencies[] = apachesolr
|
||||
dependencies[] = search_restrict
|
||||
core = 6.x
|
||||
|
||||
; Information added by drupal.org packaging script on 2012-08-29
|
||||
version = "6.x-1.5"
|
||||
core = "6.x"
|
||||
project = "search_restrict"
|
||||
datestamp = "1346261003"
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Implementation of hook_apachesolr_modify_query()
|
||||
*/
|
||||
function search_restrict_apache_solr_apachesolr_modify_query(&$query, &$params, $caller) {
|
||||
global $user;
|
||||
// User 1 can search everything.
|
||||
if ($user->uid == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
$excluded_types = search_restrict_apache_solr_excluded($user->roles);
|
||||
|
||||
if (!empty($excluded_types)) {
|
||||
|
||||
foreach ($excluded_types as $excluded_type) {
|
||||
$query->add_filter('type', $excluded_type, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of content types to exclude.
|
||||
*/
|
||||
function search_restrict_apache_solr_excluded($user_roles) {
|
||||
|
||||
$excluded_types = array();
|
||||
$types = node_get_types();
|
||||
|
||||
foreach ($types as $type => $type_info) {
|
||||
$roles = variable_get('search_restrict_type_'. $type, array());
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
return $excluded_types;
|
||||
}
|
Reference in a new issue