diff --git a/admin/islandora.admin.inc b/admin/islandora.admin.inc index 5aaac13c..a9e4ffaa 100644 --- a/admin/islandora.admin.inc +++ b/admin/islandora.admin.inc @@ -74,11 +74,6 @@ function islandora_repository_admin($form, &$form_state) { ), ); - $form['islandora_tabs']['islandora_namespace'] = array( - '#type' => 'fieldset', - '#title' => t('Namespaces'), - ); - $form['islandora_tabs']['islandora_general']['islandora_repository_pid'] = array( '#type' => 'textfield', '#title' => t('Root Collection PID'), @@ -87,21 +82,48 @@ function islandora_repository_admin($form, &$form_state) { '#required' => TRUE, ); - $form['islandora_tabs']['islandora_namespace']['islandora_namespace_restriction_enforced'] = array( + $form['islandora_tabs']['islandora_namespace'] = array( + '#type' => 'fieldset', + '#title' => t('Namespaces'), + ); + + $form['islandora_tabs']['islandora_namespace']['wrapper'] = array( + '#type' => 'markup', + '#prefix' => '
', + '#suffix' => '
', + ); + + $form['islandora_tabs']['islandora_namespace']['wrapper']['islandora_namespace_restriction_enforced'] = array( '#weight' => -1, '#type' => 'checkbox', '#title' => t('Enforce namespace restrictions'), '#description' => t('Allow administrator to restrict user\'s access to the PID namepaces listed below'), '#default_value' => variable_get('islandora_namespace_restriction_enforced', FALSE), + '#ajax' => array( + 'callback' => 'islandora_update_namespace_div', + 'wrapper' => 'islandora-namespace', + 'effect' => 'fade', + 'event' => 'change', + 'progress' => array('type' => 'throbber'), + ), ); + + if(isset($form_state['values']['islandora_namespace_restriction_enforced'])) { + $namespaces = $form_state['values']['islandora_namespace_restriction_enforced']; + } + else { + $namespaces = variable_get('islandora_namespace_restriction_enforced', FALSE); + } - $form['islandora_tabs']['islandora_namespace']['islandora_pids_allowed'] = array( - '#type' => 'textfield', - '#title' => t('PID namespaces allowed in this Drupal install'), - '#default_value' => variable_get('islandora_pids_allowed', 'default: demo: changeme: ilives: islandora-book: books: newspapers: '), - '#description' => t('A space separated list of PID namespaces that users are permitted to access from this Drupal installation.
This could be more than a simple namespace ie demo:mydemos.
islandora: is reserved and is always allowed.'), - '#weight' => 0, - ); + if($namespaces) { + $form['islandora_tabs']['islandora_namespace']['wrapper']['islandora_pids_allowed'] = array( + '#type' => 'textfield', + '#title' => t('PID namespaces allowed in this Drupal install'), + '#default_value' => variable_get('islandora_pids_allowed', 'default: demo: changeme: ilives: islandora-book: books: newspapers: '), + '#description' => t('A space separated list of PID namespaces that users are permitted to access from this Drupal installation.
This could be more than a simple namespace ie demo:mydemos.
islandora: is reserved and is always allowed.'), + '#weight' => 0, + ); + } return system_settings_form($form); } @@ -114,4 +136,14 @@ function islandora_update_url_div($form, $form_state) { $form_state['rebuild'] = TRUE; return $form['islandora_tabs']['islandora_general']['wrapper']; +} + +/** + * Checks url validity and refreshes requestHandler dropdown list + */ +function islandora_update_namespace_div($form, $form_state) { + unset($form_state['submit_handlers']); + $form_state['rebuild'] = TRUE; + + return $form['islandora_tabs']['islandora_namespace']['wrapper']; } \ No newline at end of file diff --git a/islandora.module b/islandora.module index c2126ee2..98451502 100644 --- a/islandora.module +++ b/islandora.module @@ -56,7 +56,7 @@ function islandora_menu() { 'file' => 'admin/islandora.admin.inc', 'access arguments' => array('administer site configuration'), 'type' => MENU_NORMAL_ITEM, - 'weight' => 0, + 'weight' => -1, ); $items['islandora/ingest/%'] = array( @@ -238,14 +238,14 @@ function islandora_node_access($op, $pid = NULL, $as_user = NULL) { $pid = variable_get('fedora_repository_pid', 'islandora:root'); } - $isRestricted = variable_get('fedora_namespace_restriction_enforced', TRUE); + $isRestricted = variable_get('islandora_namespace_restriction_enforced', FALSE); $namespace_access = NULL; if (!$isRestricted) { $namespace_access = TRUE; } else { $pid_namespace = substr($pid, 0, strpos($pid, ':') + 1); //Get the namespace (with colon) - $allowed_namespaces = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); + $allowed_namespaces = explode(" ", variable_get('islandora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); $namespace_access = in_array($pid_namespace, $allowed_namespaces); } diff --git a/islandora_basic_collection/includes/ChildCollection.inc b/islandora_basic_collection/includes/ChildCollection.inc index 492d7ff1..ec8f18a6 100644 --- a/islandora_basic_collection/includes/ChildCollection.inc +++ b/islandora_basic_collection/includes/ChildCollection.inc @@ -18,9 +18,9 @@ function islandora_create_child_collection_form($form, &$form_state, $this_colle $rest_connection = new RestConnection(); $restricted = FALSE; - if (variable_get('fedora_namespace_restriction_enforced', TRUE)) { + if (variable_get('islandora_namespace_restriction_enforced', FALSE)) { $restricted = TRUE; - $allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); + $allowed_string = variable_get('islandora_pids_allowed', 'default: demo: changeme: islandora:'); $namespaces = explode(':', $allowed_string); foreach ($namespaces as $namespace) { if ($namespace) { diff --git a/islandora_basic_collection/includes/CollectionManagement.inc b/islandora_basic_collection/includes/CollectionManagement.inc index 1df57e28..cffbf238 100644 --- a/islandora_basic_collection/includes/CollectionManagement.inc +++ b/islandora_basic_collection/includes/CollectionManagement.inc @@ -136,14 +136,14 @@ function get_related_items_as_array($collection_pid, $relationship = array('isMe function fedora_repository_access($permission, $pid) { global $user; $name_space_access = FALSE; - $is_restricted = variable_get('islandora_namespace_restriction_enforced', TRUE); + $is_restricted = variable_get('islandora_namespace_restriction_enforced', FALSE); if (!$is_restricted) { $name_space_access = TRUE; } if ($pid == NULL) { $pid = variable_get('islandora_repository_pid', 'islandora:root'); } - $name_space_allowed = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); + $name_space_allowed = explode(" ", variable_get('islandora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); $pos = NULL; foreach ($name_space_allowed as $name_space) { $pos = stripos($pid, $name_space); @@ -208,8 +208,8 @@ function get_content_models_as_option_array() { $rest_connection = new RestConnection(); require_once 'sites/all/libraries/tuque/RepositoryQuery.php'; - $restricted = variable_get('fedora_namespace_restriction_enforced', TRUE); - $allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); + $restricted = variable_get('islandora_namespace_restriction_enforced', FALSE); + $allowed_string = variable_get('islandora_pids_allowed', 'default: demo: changeme: islandora:'); $namespaces = explode(':', $allowed_string); foreach ($namespaces as $namespace) { if ($namespace) { diff --git a/islandora_basic_collection/includes/CollectionManagerTable.inc b/islandora_basic_collection/includes/CollectionManagerTable.inc index 7172652c..c8c071c3 100644 --- a/islandora_basic_collection/includes/CollectionManagerTable.inc +++ b/islandora_basic_collection/includes/CollectionManagerTable.inc @@ -90,8 +90,8 @@ function get_collections_as_option_array() { module_load_include('inc', 'islandora', 'RestConnection'); require_once 'sites/all/libraries/tuque/RepositoryQuery.php'; - $restricted = variable_get('fedora_namespace_restriction_enforced', TRUE); - $allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); + $restricted = variable_get('islandora_namespace_restriction_enforced', FALSE); + $allowed_string = variable_get('islandora_pids_allowed', 'default: demo: changeme: islandora:'); $namespaces = explode(':', $allowed_string); $rest_connection = new RestConnection();