From ae151e6bd0b7727301c50eaa13dcaac7f5914810 Mon Sep 17 00:00:00 2001 From: jonathangreen Date: Thu, 31 May 2012 13:47:11 -0300 Subject: [PATCH 1/4] Updated some things. --- admin/islandora.admin.inc | 121 ++-------- admin/islandora.solutionpacks.inc | 210 ------------------ islandora.module | 4 +- .../includes/image_process.inc | 14 +- 4 files changed, 31 insertions(+), 318 deletions(-) delete mode 100644 admin/islandora.solutionpacks.inc diff --git a/admin/islandora.admin.inc b/admin/islandora.admin.inc index 691f7b61..7018efa1 100644 --- a/admin/islandora.admin.inc +++ b/admin/islandora.admin.inc @@ -26,118 +26,35 @@ '#type' => 'textfield', '#title' => t('Fedora base URL'), '#default_value' => variable_get('islandora_base_url', 'http://localhost:8080/fedora'), - '#description' => t('The URL to use for REST-type connections'), + '#description' => t('The URL to use for REST connections'), '#required' => TRUE, '#weight' => -16, ); - - - $form['islandora_repository_url'] = array( - '#type' => 'textfield', - '#title' => t('Fedora RISearch URL'), - '#default_value' => variable_get('islandora_repository_url', 'http://localhost:8080/fedora/risearch'), - '#description' => t('The url of the Fedora server'), '#required' => TRUE, - '#weight' => -14 - ); - - $form['islandora_soap_url'] = array( - '#type' => 'textfield', - '#title' => t('Fedora SOAP Url'), - '#default_value' => variable_get('islandora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'), - '#description' => t('The URL to use for SOAP connections'), - '#required' => TRUE, - '#weight' => -12, - ); - - $form['islandora_soap_manage_url'] = array( - '#type' => 'textfield', - '#title' => t('Fedora SOAP management URL'), - '#default_value' => variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/wsdl?api=API-M'), '#description' => t('The URL to use for SOAP API-M connections'), - '#required' => TRUE, - '#weight' => -10 - ); // will allow admin user to remove namepsace restrictions if not explicitly disallowed in settings.php - if (variable_get('allow_open_namespace', TRUE)) { - $form['islandora_namespace'] = array( - '#type' => 'fieldset', - ); - - $form['islandora_namespace']['islandora_namespace_restriction_enforced'] = array( - '#weight' => -1, - '#type' => 'radios', - '#title' => t('Enforce namespace restrictions'), - '#options' => array( - TRUE => t('Enabled'), - FALSE => t('Disabled') - ), - '#description' => t('Allow administrator to restrict user\'s access to the PID namepaces listed below'), - '#default_value' => variable_get('islandora_namespace_restriction_enforced', TRUE) - ); - - $form['islandora_namespace']['fedora_pids_allowed'] = array( - '#type' => 'textfield', - '#title' => t('PID namespaces allowed in this Drupal install'), - '#default_value' => variable_get('islandora_pids_allowed', 'default: demo: changeme: islandora: 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.'), - '#weight' => 0 - ); - } - else { - $form['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: islandora: 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.'), - '#weight' => 0 - ); - } - - //have tabs options (like disable) - $form['tabs'] = array( - '#type' => 'fieldset', - '#title' => t('Tabs Configuration'), - '#description' => t('Configure the tabs avaialble when viewing Fedora objects.'), - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - //when checked show object details tab - $form['tabs']['islandora_repository_show_object_details_tab'] = array( - '#type' => 'checkbox', - '#title' => t('Show Object Details Tab'), - '#default_value' => variable_get('islandora_repository_show_object_details_tab', TRUE), - '#description' => t("When enabled, the 'Object Details' tab will be visible to users with the correct permissions when viewing an object in the repository"), - ); - - $form['advanced'] = array( + $form['islandora_namespace'] = array( '#type' => 'fieldset', - '#title' => t('Advanced configuration options'), - '#description' => t('Advanced configuration. Under normal circumstances these will not be touched'), - '#collapsible' => TRUE, - '#collapsed' => TRUE, ); - - - $form['advanced']['islandora_object_restrict_datastreams'] = array( - '#type' => 'checkbox', - '#title' => t('Restrict Access to Fedora Object Datastreams'), - '#default_value' => variable_get('islandora_object_restrict_datastreams', FALSE), - '#description' => t('When enabled, restricts access to fedora object datastreams that are not listed in the Islandora Content Model for the object (unless the user is an administrator).'), + $form['islandora_namespace']['islandora_namespace_restriction_enforced'] = array( + '#weight' => -1, + '#type' => 'radios', + '#title' => t('Enforce namespace restrictions'), + '#options' => array( + TRUE => t('Enabled'), + FALSE => t('Disabled') + ), + '#description' => t('Allow administrator to restrict user\'s access to the PID namepaces listed below'), + '#default_value' => variable_get('islandora_namespace_restriction_enforced', FALSE), ); - - - //Export functionality - //$form['advanced']['module']['islandora_export_area'] = array( - // '#type' => 'textfield', - // '#title' => t('Export area'), - // '#default_value' => variable_get('islandora_export_area', file_directory_path() . '/fedora_export_area'), - // '#description' => t("Path to the export area. It must be accessible by druapl (i.e. apache user)."), - // '#required' => TRUE, - //); - - $form['#attributes'] = array('enctype' => "multipart/form-data"); + $form['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, + ); return system_settings_form($form); diff --git a/admin/islandora.solutionpacks.inc b/admin/islandora.solutionpacks.inc deleted file mode 100644 index b6c40412..00000000 --- a/admin/islandora.solutionpacks.inc +++ /dev/null @@ -1,210 +0,0 @@ - $solution_pack_info) { - $objects = array(); - foreach ($solution_pack_info as $field => $value) { - switch ($field) { - case 'title': - $solution_pack_name = $value; - break; - case 'objects': - $objects = $value; - break; - } - } - $output .= drupal_get_form('fedora_repository_solution_pack_form_' . $solution_pack_module, $solution_pack_module, $solution_pack_name, $objects); - } - - return $output; -} - -/** - * Check for installed objects and add a 'Update' or 'Install' button if some objects are missing. - * @param array $solution_pack - */ -function fedora_repository_solution_pack_form(&$form_state, $solution_pack_module, $solution_pack_name, $objects = array()) { - - // Check each object to see if it is in the repository. - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - global $base_path; - $needs_update = FALSE; - $needs_install = FALSE; - $form = array(); - - $form['solution_pack_module'] = array( - '#type' => 'hidden', - '#value' => $solution_pack_module, - ); - - if (!$form_state['submitted']) { - $form['solution_pack_name'] = array( - '#type' => 'markup', - '#value' => t($solution_pack_name), - '#prefix' => '

', - '#suffix' => '

', - ); - $form['objects'] = array( - '#type' => 'fieldset', - '#title' => "Objects", - '#weight' => 10, - '#attributes' => array('class' => 'collapsed'), - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - $table_header = array('PID', 'Status'); - $table_rows = array(); - - foreach ($objects as $object) { - $datastreams = NULL; - if (isset($object['pid'])) { - $pid = $object['pid']; - - $item = new Fedora_Item($pid); - $table_row = array($object['pid']); - $object_status = t('Up-to-date'); - if (!$item->exists()) { - $object_status = 'Missing'; - $needs_install = TRUE; - } - else { - if (isset($object['dsid']) && isset($object['datastream_file']) && isset($object['dsversion'])) { - $datastreams = array( - array( - 'dsid' => $object['dsid'], - 'datastream_file' => $object['datastream_file'], - 'dsversion' => $object['dsversion'], - ), - ); - } - elseif (!empty($object['datastreams'])) { - $datastreams = $object['datastreams']; - } - if (!empty($datastreams) && is_array($datastreams)) { - foreach ($datastreams as $ds) { - $ds_list = $item->get_datastreams_list_as_array(); - if (!array_key_exists($ds['dsid'], $ds_list)) { - $needs_update = TRUE; - $object_status = 'Missing datastream'; - break; - } - elseif (isset($ds['dsversion'])) { - // Check if the datastream is versioned and needs updating. - $installed_version = fedora_repository_get_islandora_datastream_version($item, $ds['dsid']); - $available_version = fedora_repository_get_islandora_datastream_version(NULL, NULL, $ds['datastream_file']); - - if ($available_version > $installed_version) { - $needs_update = TRUE; - $object_status = 'Out of date'; - break; - } - } - } - } - } - array_push($table_row, $object_status); - $table_rows[] = $table_row; - } - } - $form['objects']['table'] = array( - '#type' => 'markup', - '#value' => theme_table($table_header, $table_rows), - ); - } - - $form['install_status'] = array( - '#type' => 'markup', - '#prefix' => '' . t('Object status:') . ' ', - '#suffix' => ' ', - ); - if (!$needs_install && !$needs_update) { - $form['install_status']['#value'] = theme_image('misc/watchdog-ok.png') . t('All required objects are installed and up-to-date.'); - $submit_button_text = t("Force Reinstallation of Fedora Objects"); - - } - else { - $form['install_status']['#value'] = theme_image('misc/watchdog-warning.png') . t('Some objects must be re-ingested. See Objects list for details.'); - $submit_button_text = t("Install Fedora Objects"); - - } - $form['submit'] = array( - '#value' => $submit_button_text, - '#type' => 'submit', - '#name' => $solution_pack_module, - ); - - $form['#submit'] = array( - 'fedora_repository_solution_pack_form_submit', - ); - return $form; -} - -function fedora_repository_solution_pack_form_submit($form, &$form_state) { - $what = $form_state; - $module_name = $form_state['values']['solution_pack_module']; - - // This should be replaced with module_invoke - //$solution_pack_info = call_user_func($module_name . '_required_fedora_objects'); - $solution_pack_info = module_invoke($module_name, 'required_fedora_objects'); - - $batch = array( - 'title' => t('Installing / updating solution pack objects'), - 'file' => drupal_get_path('module', 'fedora_repository') . '/fedora_repository.module', - 'operations' => array(), - ); - - - foreach ($solution_pack_info[$module_name]['objects'] as $object) { - // Add this object to the batch job queue. - $batch['operations'][] = array('fedora_repository_batch_reingest_object', array($object)); - } - batch_set($batch); -} - -function solution_pack_add_form($form_name, $form_xml) { - $result = db_result(db_query('Select name from {xml_forms} where name = "%s"', $form_name)); - if (!$result) { - $object = new stdClass(); - $object->name = $form_name; - $object->form = $form_xml; - $result = drupal_write_record('xml_forms', $object); - drupal_set_message(t("Added @name", array("@name" => $form_name))); - } -} - -function solution_pack_add_form_association($content_model, $form_name) { - $result = db_result(db_query('Select content_model from {islandora_content_model_forms} where content_model = "%s" and form_name = "%s"', - $content_model, $form_name)); - if (!$result) { - $object = new stdClass(); - $object->content_model = $content_model; - $object->form_name = $form_name; - $object->dsid = 'MODS'; - $object->title_field = "['titleInfo']['title']"; - $object->transform = 'mods_to_dc.xsl'; - $result = drupal_write_record('islandora_content_model_forms', $object); - drupal_set_message(t("Added association between @cm and @name", array("@cm" => $content_model, "@name"=>$form_name))); - } -} diff --git a/islandora.module b/islandora.module index 50cb36ba..ac1aaa14 100644 --- a/islandora.module +++ b/islandora.module @@ -322,7 +322,7 @@ function islandora_purge_object($form, &$form_state, $pid) { $parent = islandora_datastream_get_parents($object); $key = array_keys($parent); - if(count($key) > 0) { + if (count($key) > 0) { $redirect = "islandora/object/$key[0]"; } else { @@ -516,7 +516,7 @@ function islandora_view_object($object_id = NULL) { drupal_set_message(t('there was an error loading the view for islandora object %s', array('%s' => $object_id)), 'error'); return ""; } - drupal_alter('islandora_display',$arr); + drupal_alter('islandora_display', $arr); $output = ""; foreach ($arr as $key => $value) { $output .= $value; //if we have multiple modules handle one cmodel we need to iterate over multiple diff --git a/islandora_basic_image/includes/image_process.inc b/islandora_basic_image/includes/image_process.inc index bcf729df..3435f26c 100644 --- a/islandora_basic_image/includes/image_process.inc +++ b/islandora_basic_image/includes/image_process.inc @@ -1,11 +1,17 @@ $object->id)),'error'); + if (!isset($object['OBJ'])) { + drupal_set_message(t('Could not create image derivatives for %s. No image file was uploaded.', array('%s' => $object->id)),'error'); return ""; } $ext = $mime_class->getExtension($object['OBJ']->mimeType); @@ -32,7 +38,7 @@ function islandora_basic_image_create_derivative($file, $width, $height) { $image = image_load($real_path); if (!empty($image)) { $scale = image_scale($image, $width, $height, TRUE); - if($scale){ + if ($scale) { return image_save($image); } } From a2d2121ffbac979062d0e7e794c7dd7431302140 Mon Sep 17 00:00:00 2001 From: jonathangreen Date: Thu, 31 May 2012 14:23:34 -0300 Subject: [PATCH 2/4] Updated islandora admin form. --- RestConnection.inc | 3 +++ admin/islandora.admin.inc | 35 ++++++++++++++++++++++------------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/RestConnection.inc b/RestConnection.inc index f4671e92..1a43a9d3 100644 --- a/RestConnection.inc +++ b/RestConnection.inc @@ -61,5 +61,8 @@ class RestConnection { $this->repository = new FedoraRepository($this->api, $this->cache); } + static function exists() { + return class_exists('RepositoryConnection'); + } } diff --git a/admin/islandora.admin.inc b/admin/islandora.admin.inc index 7018efa1..1e8b5e51 100644 --- a/admin/islandora.admin.inc +++ b/admin/islandora.admin.inc @@ -7,13 +7,26 @@ */ function islandora_repository_admin() { - if (!user_access('administer site configuration')) { - drupal_set_message(t('You must be a site administrator to edit the Fedora collections list.'), 'error'); + module_load_include('inc', 'islandora', 'RestConnection'); + + if (!RestConnection::exists()) { + $message = t('This module requires the !url. Please install sites all libraries folder before continuing.', array('!url' => l(t('Tuque Fedora API'), 'http://github.com/islandora/tuque'))); + drupal_set_message(check_plain($message)); return; } $form = array(); - $form['islandora_repository_pid'] = array( + + $form['islandora_tabs'] = array( + '#type' => 'vertical_tabs', + ); + + $form['islandora_tabs']['islandora_general'] = array( + '#type' => 'fieldset', + '#title' => t('General Configuarion'), + ); + + $form['islandora_tabs']['islandora_general']['islandora_repository_pid'] = array( '#type' => 'textfield', '#title' => t('Root Collection PID'), '#default_value' => variable_get('islandora_repository_pid', 'islandora:root'), @@ -22,7 +35,7 @@ '#weight' => -18 ); - $form['islandora_base_url'] = array( + $form['islandora_tabs']['islandora_general']['islandora_base_url'] = array( '#type' => 'textfield', '#title' => t('Fedora base URL'), '#default_value' => variable_get('islandora_base_url', 'http://localhost:8080/fedora'), @@ -32,23 +45,20 @@ ); // will allow admin user to remove namepsace restrictions if not explicitly disallowed in settings.php - $form['islandora_namespace'] = array( + $form['islandora_tabs']['islandora_namespace'] = array( '#type' => 'fieldset', + '#title' => t('Namespaces'), ); - $form['islandora_namespace']['islandora_namespace_restriction_enforced'] = array( + $form['islandora_tabs']['islandora_namespace']['islandora_namespace_restriction_enforced'] = array( '#weight' => -1, - '#type' => 'radios', + '#type' => 'checkbox', '#title' => t('Enforce namespace restrictions'), - '#options' => array( - TRUE => t('Enabled'), - FALSE => t('Disabled') - ), '#description' => t('Allow administrator to restrict user\'s access to the PID namepaces listed below'), '#default_value' => variable_get('islandora_namespace_restriction_enforced', FALSE), ); - $form['islandora_namespace']['islandora_pids_allowed'] = array( + $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: '), @@ -56,6 +66,5 @@ '#weight' => 0, ); - return system_settings_form($form); } \ No newline at end of file From 34d27d4d5eb6196353580bf0d6292ca12b7674d5 Mon Sep 17 00:00:00 2001 From: jonathangreen Date: Thu, 31 May 2012 15:15:37 -0300 Subject: [PATCH 3/4] Updated Admin --- RestConnection.inc | 8 +- admin/islandora.admin.inc | 171 ++++++++++++++++++++++++-------------- 2 files changed, 115 insertions(+), 64 deletions(-) diff --git a/RestConnection.inc b/RestConnection.inc index 1a43a9d3..55c68d7a 100644 --- a/RestConnection.inc +++ b/RestConnection.inc @@ -41,7 +41,7 @@ class RestConnection { */ public $repository = NULL; - function RestConnection($user = NULL) { + function __construct($user = NULL, $url = NULL) { if(!isset($user)) { global $user; } @@ -53,7 +53,11 @@ class RestConnection { $user_string = $user->name; $pass_string = $user->pass; } - $url = variable_get('islandora_base_url', 'http://localhost:8080/fedora'); + + if (!isset($url)) { + $url = variable_get('islandora_base_url', 'http://localhost:8080/fedora'); + } + $this->connection = new RepositoryConnection($url, $user_string, $pass_string); $this->connection->reuseConnection = TRUE; $this->api = new FedoraApi($this->connection); diff --git a/admin/islandora.admin.inc b/admin/islandora.admin.inc index 1e8b5e51..5aaac13c 100644 --- a/admin/islandora.admin.inc +++ b/admin/islandora.admin.inc @@ -6,65 +6,112 @@ * @return array */ - function islandora_repository_admin() { - module_load_include('inc', 'islandora', 'RestConnection'); - - if (!RestConnection::exists()) { - $message = t('This module requires the !url. Please install sites all libraries folder before continuing.', array('!url' => l(t('Tuque Fedora API'), 'http://github.com/islandora/tuque'))); - drupal_set_message(check_plain($message)); - return; - } - - $form = array(); - - $form['islandora_tabs'] = array( - '#type' => 'vertical_tabs', - ); - - $form['islandora_tabs']['islandora_general'] = array( - '#type' => 'fieldset', - '#title' => t('General Configuarion'), - ); - - $form['islandora_tabs']['islandora_general']['islandora_repository_pid'] = array( - '#type' => 'textfield', - '#title' => t('Root Collection PID'), - '#default_value' => variable_get('islandora_repository_pid', 'islandora:root'), - '#description' => t('The PID of the Root Collection Object'), - '#required' => TRUE, - '#weight' => -18 - ); - - $form['islandora_tabs']['islandora_general']['islandora_base_url'] = array( - '#type' => 'textfield', - '#title' => t('Fedora base URL'), - '#default_value' => variable_get('islandora_base_url', 'http://localhost:8080/fedora'), - '#description' => t('The URL to use for REST connections'), - '#required' => TRUE, - '#weight' => -16, - ); - -// will allow admin user to remove namepsace restrictions if not explicitly disallowed in settings.php - $form['islandora_tabs']['islandora_namespace'] = array( - '#type' => 'fieldset', - '#title' => t('Namespaces'), - ); - - $form['islandora_tabs']['islandora_namespace']['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), - ); - - $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, - ); - - return system_settings_form($form); - } \ No newline at end of file +function islandora_repository_admin($form, &$form_state) { + module_load_include('inc', 'islandora', 'RestConnection'); + + if (!RestConnection::exists()) { + $message = t('This module requires the !url. Please install sites all libraries folder before continuing.', array('!url' => l(t('Tuque Fedora API'), 'http://github.com/islandora/tuque'))); + drupal_set_message(check_plain($message)); + return; + } + + $form = array(); + + if(isset($form_state['values']['islandora_base_url'])) { + $url = $form_state['values']['islandora_base_url']; + } + else { + $url = variable_get('islandora_base_url', 'http://localhost:8080/fedora'); + } + + module_load_include('inc', 'islandora', 'RestConnection'); + $connection = new RestConnection(NULL, $url); + try { + $info = $connection->api->a->describeRepository(); + $connected = TRUE; + } + catch (RepositoryException $e) { + $connected = FALSE; + } + + if($connected) { + $confirmation_message = '' + . t('Successfully connected to Fedora Server (Version !version).', array('!version' => $info['repositoryVersion'])); + } + else { + $confirmation_message = ' ' + . t('Unable to connect to Fedora server at !islandora_url', array('!islandora_url' => $url)); + } + + $form['islandora_tabs'] = array( + '#type' => 'vertical_tabs', + ); + + $form['islandora_tabs']['islandora_general'] = array( + '#type' => 'fieldset', + '#title' => t('General Configuarion'), + ); + + // ajax wrapper for url checking + $form['islandora_tabs']['islandora_general']['wrapper'] = array( + '#prefix' => '
', + '#suffix' => '
', + '#type' => 'markup', + ); + + $form['islandora_tabs']['islandora_general']['wrapper']['islandora_base_url'] = array( + '#type' => 'textfield', + '#title' => t('Fedora base URL'), + '#default_value' => variable_get('islandora_base_url', 'http://localhost:8080/fedora'), + '#description' => t('The URL to use for REST connections
' . $confirmation_message), + '#required' => TRUE, + '#ajax' => array( + 'callback' => 'islandora_update_url_div', + 'wrapper' => 'islandora-url', + 'effect' => 'fade', + 'event' => 'blur', + 'progress' => array('type' => 'throbber'), + ), + ); + + $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'), + '#default_value' => variable_get('islandora_repository_pid', 'islandora:root'), + '#description' => t('The PID of the Root Collection Object'), + '#required' => TRUE, + ); + + $form['islandora_tabs']['islandora_namespace']['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), + ); + + $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, + ); + + return system_settings_form($form); +} + +/** + * Checks url validity and refreshes requestHandler dropdown list + */ +function islandora_update_url_div($form, $form_state) { + unset($form_state['submit_handlers']); + $form_state['rebuild'] = TRUE; + + return $form['islandora_tabs']['islandora_general']['wrapper']; +} \ No newline at end of file From 63300908afb92e6beea96db998003e348ad45aa5 Mon Sep 17 00:00:00 2001 From: jonathangreen Date: Thu, 31 May 2012 15:42:19 -0300 Subject: [PATCH 4/4] Updated the admin screen more. --- admin/islandora.admin.inc | 58 ++++++++++++++----- islandora.module | 6 +- .../includes/ChildCollection.inc | 4 +- .../includes/CollectionManagement.inc | 8 +-- .../includes/CollectionManagerTable.inc | 4 +- 5 files changed, 56 insertions(+), 24 deletions(-) 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();