From acc142b8d93f39ae918dcc2b929d107a0d1370d8 Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Thu, 20 Jun 2013 09:23:15 -0300 Subject: [PATCH 1/3] Implement basic collection filter hook for namespaces. --- islandora.module | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/islandora.module b/islandora.module index 7e1936c3..ea4050f7 100644 --- a/islandora.module +++ b/islandora.module @@ -1319,3 +1319,17 @@ function islandora_datastream_access($op, $datastream, $user = NULL) { return $cache[$op][$datastream->parent->id][$datastream->id][$user->uid]; } + +/* + * Implements hook_islandora_basic_collection_get_filters(). + */ +function islandora_islandora_basic_collection_get_filters() { + $enforced = variable_get('islandora_namespace_restriction_enforced', FALSE); + if ($enforced) { + $namespace_array = islandora_get_allowed_namespaces(); + $namespace_sparql = implode('|', $namespace_array); + return format_string('regex(str(?object), "info:fedora/(!namespaces):")', array( + '!namespaces' => $namespace_sparql, + )); + } +} From 0f00f43f9910c443d1f740daa511706e90b50d08 Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Thu, 20 Jun 2013 09:33:42 -0300 Subject: [PATCH 2/3] Fix function comment (parsing)... --- islandora.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/islandora.module b/islandora.module index ea4050f7..2324af5d 100644 --- a/islandora.module +++ b/islandora.module @@ -1320,7 +1320,7 @@ function islandora_datastream_access($op, $datastream, $user = NULL) { return $cache[$op][$datastream->parent->id][$datastream->id][$user->uid]; } -/* +/** * Implements hook_islandora_basic_collection_get_filters(). */ function islandora_islandora_basic_collection_get_filters() { From 5884812486522804cbd588315190e37801efa820 Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Thu, 20 Jun 2013 14:38:41 -0300 Subject: [PATCH 3/3] Fix hook implementation. ... Function was name inappropriately... Herp derp. --- islandora.module | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/islandora.module b/islandora.module index 2324af5d..174ba5fa 100644 --- a/islandora.module +++ b/islandora.module @@ -1321,9 +1321,9 @@ function islandora_datastream_access($op, $datastream, $user = NULL) { } /** - * Implements hook_islandora_basic_collection_get_filters(). + * Implements hook_islandora_basic_collection_get_query_filters(). */ -function islandora_islandora_basic_collection_get_filters() { +function islandora_islandora_basic_collection_get_query_filters() { $enforced = variable_get('islandora_namespace_restriction_enforced', FALSE); if ($enforced) { $namespace_array = islandora_get_allowed_namespaces();