Browse Source

Updated Admin

pull/122/merge
jonathangreen 13 years ago
parent
commit
34d27d4d5e
  1. 8
      RestConnection.inc
  2. 171
      admin/islandora.admin.inc

8
RestConnection.inc

@ -41,7 +41,7 @@ class RestConnection {
*/ */
public $repository = NULL; public $repository = NULL;
function RestConnection($user = NULL) { function __construct($user = NULL, $url = NULL) {
if(!isset($user)) { if(!isset($user)) {
global $user; global $user;
} }
@ -53,7 +53,11 @@ class RestConnection {
$user_string = $user->name; $user_string = $user->name;
$pass_string = $user->pass; $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 = new RepositoryConnection($url, $user_string, $pass_string);
$this->connection->reuseConnection = TRUE; $this->connection->reuseConnection = TRUE;
$this->api = new FedoraApi($this->connection); $this->api = new FedoraApi($this->connection);

171
admin/islandora.admin.inc

@ -6,65 +6,112 @@
* @return array * @return array
*/ */
function islandora_repository_admin() { function islandora_repository_admin($form, &$form_state) {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
if (!RestConnection::exists()) { 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'))); $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)); drupal_set_message(check_plain($message));
return; return;
} }
$form = array(); $form = array();
$form['islandora_tabs'] = array( if(isset($form_state['values']['islandora_base_url'])) {
'#type' => 'vertical_tabs', $url = $form_state['values']['islandora_base_url'];
); }
else {
$form['islandora_tabs']['islandora_general'] = array( $url = variable_get('islandora_base_url', 'http://localhost:8080/fedora');
'#type' => 'fieldset', }
'#title' => t('General Configuarion'),
); module_load_include('inc', 'islandora', 'RestConnection');
$connection = new RestConnection(NULL, $url);
$form['islandora_tabs']['islandora_general']['islandora_repository_pid'] = array( try {
'#type' => 'textfield', $info = $connection->api->a->describeRepository();
'#title' => t('Root Collection PID'), $connected = TRUE;
'#default_value' => variable_get('islandora_repository_pid', 'islandora:root'), }
'#description' => t('The PID of the Root Collection Object'), catch (RepositoryException $e) {
'#required' => TRUE, $connected = FALSE;
'#weight' => -18 }
);
if($connected) {
$form['islandora_tabs']['islandora_general']['islandora_base_url'] = array( $confirmation_message = '<img src="' . url('misc/watchdog-ok.png') . '"/>'
'#type' => 'textfield', . t('Successfully connected to Fedora Server (Version !version).', array('!version' => $info['repositoryVersion']));
'#title' => t('Fedora base URL'), }
'#default_value' => variable_get('islandora_base_url', 'http://localhost:8080/fedora'), else {
'#description' => t('The URL to use for REST connections'), $confirmation_message = '<img src="' . url('misc/watchdog-error.png') . '"/> '
'#required' => TRUE, . t('Unable to connect to Fedora server at !islandora_url', array('!islandora_url' => $url));
'#weight' => -16, }
);
$form['islandora_tabs'] = array(
// will allow admin user to remove namepsace restrictions if not explicitly disallowed in settings.php '#type' => 'vertical_tabs',
$form['islandora_tabs']['islandora_namespace'] = array( );
'#type' => 'fieldset',
'#title' => t('Namespaces'), $form['islandora_tabs']['islandora_general'] = array(
); '#type' => 'fieldset',
'#title' => t('General Configuarion'),
$form['islandora_tabs']['islandora_namespace']['islandora_namespace_restriction_enforced'] = array( );
'#weight' => -1,
'#type' => 'checkbox', // ajax wrapper for url checking
'#title' => t('Enforce namespace restrictions'), $form['islandora_tabs']['islandora_general']['wrapper'] = array(
'#description' => t('Allow administrator to restrict user\'s access to the PID namepaces listed below'), '#prefix' => '<div id="islandora-url">',
'#default_value' => variable_get('islandora_namespace_restriction_enforced', FALSE), '#suffix' => '</div>',
); '#type' => 'markup',
);
$form['islandora_tabs']['islandora_namespace']['islandora_pids_allowed'] = array(
'#type' => 'textfield', $form['islandora_tabs']['islandora_general']['wrapper']['islandora_base_url'] = array(
'#title' => t('PID namespaces allowed in this Drupal install'), '#type' => 'textfield',
'#default_value' => variable_get('islandora_pids_allowed', 'default: demo: changeme: ilives: islandora-book: books: newspapers: '), '#title' => t('Fedora base URL'),
'#description' => t('A space separated list of PID namespaces that users are permitted to access from this Drupal installation. <br /> This could be more than a simple namespace ie demo:mydemos. <br> islandora: is reserved and is always allowed.'), '#default_value' => variable_get('islandora_base_url', 'http://localhost:8080/fedora'),
'#weight' => 0, '#description' => t('The URL to use for REST connections <br>' . $confirmation_message),
); '#required' => TRUE,
'#ajax' => array(
return system_settings_form($form); '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. <br /> This could be more than a simple namespace ie demo:mydemos. <br> 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'];
}
Loading…
Cancel
Save