From 33b3b4453f4134d3c701225bdeff85b880656226 Mon Sep 17 00:00:00 2001 From: Alan Stanley Date: Mon, 13 Feb 2012 16:15:49 -0400 Subject: [PATCH] added permission filtering to get_collections_as_option_array() --- api/fedora_utils.inc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/api/fedora_utils.inc b/api/fedora_utils.inc index 89545191..c2665fc7 100644 --- a/api/fedora_utils.inc +++ b/api/fedora_utils.inc @@ -236,6 +236,8 @@ function fix_dsid($dsid) { function get_collections_as_option_array() { module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); $restricted = variable_get('fedora_namespace_restriction_enforced', TRUE); + $allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); + $namespaces = explode(':', $allowed_string); $query = 'select $object $title from <#ri> where ($object $title and $object @@ -247,13 +249,22 @@ function get_collections_as_option_array() { $list = explode("\n", $content); array_shift($list); $list = preg_replace('/info:fedora\//', '', $list); + foreach ($namespaces as $namespace) { + $trimmed_names[] = trim($namespace); + } $options = array(); foreach ($list as $item) { //removes blanks if ($item) { $parts = explode(',', $item); - $options[$parts[0]] = $parts[1]; + $namespace = explode(':', $parts[0]); + $namespace = trim($namespace[0]); + $bool = in_array($namespace, $trimmed_names); + if (!$restricted || in_array($namespace, $trimmed_names)) { + $options[$parts[0]] = $parts[1]; + } } } + unset($options['islandora:ContentModelCollection']); return $options; }