Browse Source

Allows namespace lockdown from settings.php

pull/105/head
Alan Stanley 14 years ago
parent
commit
026d16222a
  1. 6
      ObjectHelper.inc
  2. 116
      api/fedora_item.inc
  3. 54
      fedora_repository.module
  4. 143
      formClass.inc

6
ObjectHelper.inc

@ -611,7 +611,7 @@ class ObjectHelper {
$returnValue = FALSE;
$isRestricted = variable_get('fedora_namespace_restriction_enforced', TRUE);
if (!$isRestricted) {
$returnValue = TRUE;
$namespaceAccess = TRUE;
}
if ($pid == NULL) {
$pid = variable_get('fedora_repository_pid', 'islandora:top');
@ -621,10 +621,10 @@ class ObjectHelper {
foreach ($nameSpaceAllowed as $nameSpace) {
$pos = stripos($pid, $nameSpace);
if ($pos === 0) {
$returnValue = TRUE;
$namespaceAccess = TRUE;
}
}
if ($returnValue) {
if ($namespaceAccess) {
$user_access = user_access($op);
if ($user_access == NULL) {
return FALSE;

116
api/fedora_item.inc

@ -2,19 +2,18 @@
// $Id$
define ('RELS_EXT_URI', 'info:fedora/fedora-system:def/relations-external#');
define ("FEDORA_MODEL_URI", 'info:fedora/fedora-system:def/model#');
define('RELS_EXT_URI', 'info:fedora/fedora-system:def/relations-external#');
define("FEDORA_MODEL_URI", 'info:fedora/fedora-system:def/model#');
class Fedora_Item {
public $pid = NULL; // The $pid of the fedora object represented by an instance of this class.
public $objectProfile = NULL;
private $datastreams_list = NULL; // A SimpleXML object to store a list of this item's datastreams
public $datastreams = NULL;
private static $connection_helper = NULL;
private static $instantiated_pids = array();
/**
* Create an object to represent an item in the Fedora repository.
* Throws a SOAPException if the PID is not in the repository.
@ -29,10 +28,11 @@ class Fedora_Item {
$this->pid = $pid;
if (isset(Fedora_Item::$instantiated_pids[$pid])) {
$this->objectProfile =& Fedora_Item::$instantiated_pids[$pid]->objectProfile;
$this->datastreams =& Fedora_Item::$instantiated_pids[$pid]->datastreams;
$this->datastreams_list =& Fedora_Item::$instantiated_pids[$pid]->datastreams_list;
} else {
$this->objectProfile = & Fedora_Item::$instantiated_pids[$pid]->objectProfile;
$this->datastreams = & Fedora_Item::$instantiated_pids[$pid]->datastreams;
$this->datastreams_list = & Fedora_Item::$instantiated_pids[$pid]->datastreams_list;
}
else {
if (empty(self::$connection_helper)) {
self::$connection_helper = new ConnectionHelper();
}
@ -42,11 +42,12 @@ class Fedora_Item {
if (!empty($raw_objprofile)) {
$this->objectProfile = $raw_objprofile->objectProfile;
$this->datastreams = $this->get_datastreams_list_as_array();
} else {
}
else {
$this->objectProfile = '';
$this->datastreams = array();
}
Fedora_Item::$instantiated_pids[$pid]=&$this;
Fedora_Item::$instantiated_pids[$pid] = &$this;
}
}
@ -54,7 +55,7 @@ class Fedora_Item {
return (!empty($this->objectProfile));
}
function add_datastream_from_file($datastream_file, $datastream_id, $datastream_label = NULL, $datastream_mimetype = '', $controlGroup = 'M',$logMessage = null) {
function add_datastream_from_file($datastream_file, $datastream_id, $datastream_label = NULL, $datastream_mimetype = '', $controlGroup = 'M', $logMessage = null) {
module_load_include('inc', 'fedora_repository', 'MimeClass');
if (empty($datastream_mimetype)) {
// Get mime type from the file extension.
@ -67,7 +68,7 @@ class Fedora_Item {
$datastream_url = drupal_urlencode($datastream_file);
$url = file_create_url($datastream_url);
$return_value = $this->add_datastream_from_url($url, $datastream_id, $datastream_label, $datastream_mimetype, $controlGroup,$logMessage);
$return_value = $this->add_datastream_from_url($url, $datastream_id, $datastream_label, $datastream_mimetype, $controlGroup, $logMessage);
if ($original_path != $datastream_file) {
file_delete($datastream_file);
@ -75,8 +76,8 @@ class Fedora_Item {
return $return_value;
}
function add_datastream_from_url($datastream_url, $datastream_id, $datastream_label = NULL, $datastream_mimetype = '', $controlGroup = 'M',$logMessage = null) {
if (empty( $datastream_label)) {
function add_datastream_from_url($datastream_url, $datastream_id, $datastream_label = NULL, $datastream_mimetype = '', $controlGroup = 'M', $logMessage = null) {
if (empty($datastream_label)) {
$datastream_label = $datastream_id;
}
@ -93,19 +94,19 @@ class Fedora_Item {
'dsState' => 'A',
'checksumType' => 'DISABLED',
'checksum' => 'none',
'logMessage' => ($logMessage != null)?$logMessage: 'Ingested object '. $datastream_id
'logMessage' => ($logMessage != null) ? $logMessage : 'Ingested object ' . $datastream_id
);
return $this->soap_call( 'addDataStream', $params )->datastreamID;
return $this->soap_call('addDataStream', $params)->datastreamID;
}
function add_datastream_from_string($str, $datastream_id, $datastream_label = NULL, $datastream_mimetype = 'text/xml', $controlGroup = 'M',$logMessage = null) {
function add_datastream_from_string($str, $datastream_id, $datastream_label = NULL, $datastream_mimetype = 'text/xml', $controlGroup = 'M', $logMessage = null) {
$dir = sys_get_temp_dir();
$tmpfilename = tempnam($dir, 'fedoratmp');
$tmpfile = fopen($tmpfilename, 'w');
fwrite($tmpfile, $str, strlen($str));
fclose($tmpfile);
$returnvalue = $this->add_datastream_from_file($tmpfilename, $datastream_id, $datastream_label, $datastream_mimetype, $controlGroup,$logMessage);
$returnvalue = $this->add_datastream_from_file($tmpfilename, $datastream_id, $datastream_label, $datastream_mimetype, $controlGroup, $logMessage);
unlink($tmpfilename);
return $returnvalue;
}
@ -121,7 +122,7 @@ class Fedora_Item {
if (empty($ds_list['RELS-EXT'])) {
$this->add_datastream_from_string(' <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="info:fedora/'. $this->pid . '">
<rdf:Description rdf:about="info:fedora/' . $this->pid . '">
</rdf:Description>
</rdf:RDF>', 'RELS-EXT', 'Fedora object-to-object relationship metadata', 'text/xml', 'X');
}
@ -139,7 +140,7 @@ class Fedora_Item {
if ($description->length == 0) {
$description = $relsextxml->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'description');
}
$description=$description->item(0);
$description = $description->item(0);
// Create the new relationship node.
$newrel = $relsextxml->createElementNS($namespaceURI, $relationship);
@ -147,7 +148,7 @@ class Fedora_Item {
$newrel->setAttribute('rdf:resource', $object);
$description->appendChild($newrel);
$this->modify_datastream_by_value( $relsextxml->saveXML(), 'RELS-EXT', "Fedora Object-to-Object Relationship Metadata", 'text/xml');
$this->modify_datastream_by_value($relsextxml->saveXML(), 'RELS-EXT', "Fedora Object-to-Object Relationship Metadata", 'text/xml');
//print ($description->dump_node());
/*
$params = array( 'pid' => $this->pid,
@ -205,7 +206,7 @@ class Fedora_Item {
}
}
if ($modified) {
$this->modify_datastream_by_value( $relsextxml->saveXML(), 'RELS-EXT', "Fedora Object-to-Object Relationship Metadata", 'text/xml');
$this->modify_datastream_by_value($relsextxml->saveXML(), 'RELS-EXT', "Fedora Object-to-Object Relationship Metadata", 'text/xml');
}
return $modified;
//print ($description->dump_node());
@ -249,7 +250,7 @@ class Fedora_Item {
}
if (count($resultFields) > 0) {
$url .= '&'.join('=true&',$resultFields).'=true';
$url .= '&' . join('=true&', $resultFields) . '=true';
}
$resultxml = do_curl($url);
@ -267,14 +268,14 @@ class Fedora_Item {
}
foreach ($resultelements->resultList->objectFields as $obj) {
$ret = (string)$obj->title;
$ret = (string) $obj->title;
if (count($resultFields) > 0) {
$ret = array('title' => $ret);
foreach ($resultFields as $field) {
$ret[$field]=(string)$obj->$field;
$ret[$field] = (string) $obj->$field;
}
}
$results[(string)$obj->pid] = $ret;
$results[(string) $obj->pid] = $ret;
$cursor++;
if ($cursor >= $max_results) {
$done = TRUE;
@ -365,6 +366,7 @@ class Fedora_Item {
//}
return $this->datastreams_list;
}
/**
* * DatastreamControlGroup controlGroup - String restricted to the values of "X", "M", "R", or "E" (InlineXML,Managed Content,Redirect, or External Referenced).
* String ID - The datastream ID (64 characters max).
@ -386,7 +388,7 @@ class Fedora_Item {
* @return datastream object
* get the mimetype size etc. in one shot. instead of iterating throught the datastream list for what we need
*/
function get_datastream_info($dsid,$as_of_date_time = ""){
function get_datastream_info($dsid, $as_of_date_time = "") {
$params = array(
'pid' => $this->pid,
'dsID' => $dsid,
@ -394,7 +396,6 @@ class Fedora_Item {
);
return $this->soap_call('getDatastream', $params);
}
/**
@ -427,14 +428,14 @@ class Fedora_Item {
}
$ds_list[$ds->ID]['label'] = $ds->label;
$ds_list[$ds->ID]['MIMEType'] = $ds->MIMEType;
$ds_list[$ds->ID]['URL'] = $this->url() . '/'. $ds->ID . '/'. drupal_urlencode($ds->label);
$ds_list[$ds->ID]['URL'] = $this->url() . '/' . $ds->ID . '/' . drupal_urlencode($ds->label);
}
}
else {
$ds = $this->datastreams_list->datastreamDef;
$ds_list[$ds->ID]['label'] = $ds->label;
$ds_list[$ds->ID]['MIMEType'] = $ds->MIMEType;
$ds_list[$ds->ID]['URL'] = $this->url().'/'.$ds->ID.'/'.drupal_urlencode($ds->label);
$ds_list[$ds->ID]['URL'] = $this->url() . '/' . $ds->ID . '/' . drupal_urlencode($ds->label);
}
}
@ -472,8 +473,7 @@ class Fedora_Item {
$relationships = array();
try {
$relsext = $this->get_datastream_dissemination('RELS-EXT');
}
catch (exception $e) {
} catch (exception $e) {
drupal_set_message("Error retrieving RELS-EXT of object $pid", 'error');
return $relationships;
}
@ -510,12 +510,12 @@ class Fedora_Item {
// Verify the array format and that it isn't empty.
if (!empty($relationships)) {
$relsextxml = '<rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:fedora="info:fedora/fedora-system:def/relations-external#" xmlns:fedora-model="info:fedora/fedora-system:def/model#" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">'
. '<rdf:description rdf:about="'. $this->pid . '">';
. '<rdf:description rdf:about="' . $this->pid . '">';
foreach ($relationships as $rel) {
if (empty($rel['subject']) || empty($rel['predicate']) || empty($rel['object']) || $rel['subject'] != 'info:fedora/'. $this->pid) {
if (empty($rel['subject']) || empty($rel['predicate']) || empty($rel['object']) || $rel['subject'] != 'info:fedora/' . $this->pid) {
// drupal_set_message should use parameterized variables, not interpolated.
drupal_set_message("Error with relationship format: ". $rel['subject'] . " - ". $rel['predicate'] . ' - '. $rel['object'], "error");
drupal_set_message("Error with relationship format: " . $rel['subject'] . " - " . $rel['predicate'] . ' - ' . $rel['object'], "error");
return FALSE;
}
}
@ -539,7 +539,7 @@ class Fedora_Item {
return $this->soap_call('purgeObject', $params);
}
function purge_datastream( $dsID, $start_date = NULL, $end_date = NULL, $log_message = 'Purged datastream using Islandora API', $force = FALSE) {
function purge_datastream($dsID, $start_date = NULL, $end_date = NULL, $log_message = 'Purged datastream using Islandora API', $force = FALSE) {
$params = array(
'pid' => $this->pid,
'dsID' => $dsID,
@ -553,10 +553,10 @@ class Fedora_Item {
function url() {
global $base_url;
return $base_url . '/fedora/repository/'. $this->pid . (!empty($this->objectProfile) ? '/-/'. drupal_urlencode($this->objectProfile->objLabel) : '');
return $base_url . '/fedora/repository/' . $this->pid . (!empty($this->objectProfile) ? '/-/' . drupal_urlencode($this->objectProfile->objLabel) : '');
}
static function get_next_PID_in_namespace( $pid_namespace = '') {
static function get_next_PID_in_namespace($pid_namespace = '') {
if (empty($pid_namespace)) {
// Just get the first one in the config settings.
@ -587,7 +587,7 @@ class Fedora_Item {
static function ingest_from_FOXML_file($foxml_file) {
$foxml = new DOMDocument();
$foxml->load( $foxml_file );
$foxml->load($foxml_file);
return self::ingest_from_FOXML($foxml);
}
@ -601,9 +601,9 @@ class Fedora_Item {
}
try {
self::ingest_from_FOXML_file( $path . '/'. $file );
}
catch (exception $e) {
self::ingest_from_FOXML_file($path . '/' . $file);
} catch (exception $e) {
}
}
// Close
@ -623,7 +623,7 @@ class Fedora_Item {
return self::soap_call('modifyObject', $params, $quiet);
}
function modify_datastream_by_reference($external_url, $dsid, $label, $mime_type, $force = FALSE, $logMessage = 'Modified by Islandora API',$quiet=FALSE) {
function modify_datastream_by_reference($external_url, $dsid, $label, $mime_type, $force = FALSE, $logMessage = 'Modified by Islandora API', $quiet=FALSE) {
$params = array(
'pid' => $this->pid,
'dsID' => $dsid,
@ -640,7 +640,7 @@ class Fedora_Item {
return self::soap_call('modifyDatastreamByReference', $params, $quiet);
}
function modify_datastream_by_value($content, $dsid, $label, $mime_type, $force = FALSE, $logMessage = 'Modified by Islandora API',$quiet=FALSE) {
function modify_datastream_by_value($content, $dsid, $label, $mime_type, $force = FALSE, $logMessage = 'Modified by Islandora API', $quiet=FALSE) {
$params = array(
'pid' => $this->pid,
'dsID' => $dsid,
@ -654,10 +654,10 @@ class Fedora_Item {
'logMessage' => $logMessage,
'force' => $force
);
return self::soap_call('modifyDatastreamByValue', $params,$quiet);
return self::soap_call('modifyDatastreamByValue', $params, $quiet);
}
static function soap_call( $function_name, $params_array, $quiet = FALSE ) {
static function soap_call($function_name, $params_array, $quiet = FALSE) {
if (!self::$connection_helper) {
module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
self::$connection_helper = new ConnectionHelper();
@ -685,13 +685,13 @@ class Fedora_Item {
watchdog(t("FEDORA_REPOSITORY"), t("Error trying to get SOAP client connection."));
return NULL;
}
}
catch (exception $e) {
} catch (exception $e) {
if (!$quiet) {
if (preg_match('/org\.fcrepo\.server\.security\.xacml\.pep\.AuthzDeniedException/',$e->getMessage())) {
drupal_set_message(t('Error: Insufficient permissions to call SOAP function !fn.', array('!fn' => $function_name) ), 'error');
} else {
if (preg_match('/org\.fcrepo\.server\.security\.xacml\.pep\.AuthzDeniedException/', $e->getMessage())) {
drupal_set_message(t('Error: Insufficient permissions to call SOAP function !fn.', array('!fn' => $function_name)), 'error');
}
else {
drupal_set_message(t("Error trying to call SOAP function $function_name. Check watchdog logs for more information."), 'error');
}
@ -703,7 +703,7 @@ class Fedora_Item {
default:
try {
$soap_client = self::$connection_helper->getSoapClient( variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'));
$soap_client = self::$connection_helper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'));
if (!empty($soap_client)) {
$result = $soap_client->__soapCall($function_name, array('parameters' => $params_array));
}
@ -711,8 +711,7 @@ class Fedora_Item {
watchdog(t("FEDORA_REPOSITORY"), t("Error trying to get SOAP client connection."));
return NULL;
}
}
catch (exception $e) {
} catch (exception $e) {
if (!$quiet) {
watchdog(t("FEDORA_REPOSITORY"), t("Error trying to call SOAP function !fn: !e", array('!fn' => $function_name, '!e' => $e)), NULL, WATCHDOG_ERROR);
@ -723,7 +722,6 @@ class Fedora_Item {
return $result;
}
/**
* Creates the minimal FOXML for a new Fedora object, which is then passed to
* ingest_from_FOXML to be added to the repository.
@ -767,7 +765,7 @@ class Fedora_Item {
$owner_property = $foxml->createElement("foxml:property");
$owner_property->setAttribute("NAME", "info:fedora/fedora-system:def/model#ownerId");
$owner_property->setAttribute("VALUE", $owner );
$owner_property->setAttribute("VALUE", $owner);
$object_properties->appendChild($state_property);
$object_properties->appendChild($label_property);
@ -779,7 +777,7 @@ class Fedora_Item {
}
static function ingest_new_item($pid = '', $state = 'A', $label = '', $owner = '') {
return self::ingest_from_FOXML(self::create_object_FOXML( $pid, $state, $label, $owner));
return self::ingest_from_FOXML(self::create_object_FOXML($pid, $state, $label, $owner));
}
static function fedora_item_exists($pid) {
@ -787,9 +785,9 @@ class Fedora_Item {
return $item->exists();
}
/********************************************************
/* * ******************************************************
* Relationship Functions
********************************************************/
* ****************************************************** */
/**
* Returns an associative array of relationships that this item has

54
fedora_repository.module

@ -101,7 +101,8 @@ function fedora_repository_ingest_object($collection_pid=NULL, $collection_label
if (!validPid($collection_pid)) {
if (validPid(urldecode($collection_pid))) {
$collection_pid = urldecode($collection_pid);
} else {
}
else {
drupal_set_message(t("This collection PID $collection_pid is not valid"), 'error');
return ' ';
}
@ -205,7 +206,8 @@ function fedora_repository_ingest_form_validate($form, &$form_state) {
implode(' ', $allowedMimeTypes)));
file_delete($file);
return;
} elseif (!$cm->execIngestRules($file, $dformat)) {
}
elseif (!$cm->execIngestRules($file, $dformat)) {
drupal_set_message(t('Error following Content Model Rules'), 'error');
foreach (ContentModel::$errors as $err) {
drupal_set_message($err, 'error');
@ -262,7 +264,8 @@ function fedora_repository_purge_object_form(&$form_state, $pid, $referrer) {
//$form['#redirect'] = $referrer;
return $form;
} else {
}
else {
// ALSO do $form definition here. Your final submit handler (after user clicks Yes, I Confirm) will only see $form_state info defined here. Form you create here passed as param1 to confirm_form
return confirm_form($form, 'Confirm Purge Object', $referrer, 'Are you sure you want to delete this object? This action cannot be undone.', 'Delete', 'Cancel'); //Had better luck leaving off last param 'name'
@ -407,7 +410,8 @@ function fedora_repository_purge_object_form_submit($form, &$form_state) {
if (!isset($form_state['storage']['confirm'])) {
$form_state['storage']['confirm'] = TRUE; // this will cause the form to be rebuilt, entering the confirm part of the form
$form_state['rebuild'] = TRUE; // along with this
} else {
}
else {
// this is where you do your processing after they have pressed the confirm button
$params = array(
"pid" => $pid,
@ -422,7 +426,8 @@ function fedora_repository_purge_object_form_submit($form, &$form_state) {
} catch (exception $e) {
if (preg_match('/org\.fcrepo\.server\.security\.xacml\.pep\.AuthzDeniedException/', $e->getMessage())) {
drupal_set_message(t('Error: Insufficient permissions to purge object.'), 'error');
} else {
}
else {
drupal_set_message(t($e->getMessage()), 'error');
}
return;
@ -432,7 +437,8 @@ function fedora_repository_purge_object_form_submit($form, &$form_state) {
}
if (!empty($form_state['values']['referrer'])) {
$form_state['redirect'] = $form_state['values']['referrer'];
} else {
}
else {
$form_state['redirect'] = "fedora/repository/$collectionPid/";
}
}
@ -936,7 +942,8 @@ function fedora_repository_search($op = 'search', $keys = NULL) {
$searchQuery = NULL;
if (isset($type) && strcmp($type, ':')) {
$searchQuery = $type . ':' . $keys;
} else {
}
else {
$searchQuery = $keys;
}
//$searchQuery.=" AND (PID:vre OR PID:vre:ref OR PID:demo OR PID:changeme)";
@ -994,7 +1001,8 @@ function fedora_repository_search_page($resultData) {
$xsl = new DomDocument();
if ($isRestricted) {
$xsl->load($path . '/xsl/results.xsl');
} else {
}
else {
$xsl->load($path . '/xsl/unfilteredresults.xsl');
}
@ -1008,7 +1016,8 @@ function fedora_repository_search_page($resultData) {
'colspan' => 2
)
);
} else {
}
else {
$xsl = $proc->importStylesheet($xsl);
$newdom = $proc->transformToDoc($input);
@ -1267,7 +1276,8 @@ function fedora_repository_demo_objects_form() {
if (empty($demo_objects[$available_demo]->objectProfile)) {
//The demo objects collection does not exist in the repository, display a button to ingest them.
$form['install_demos']['demo_collections']['#options'][$available_demo] = $available_demo_desc;
} else {
}
else {
array_push($existing_demos, $demo_objects[$available_demo]);
}
}
@ -1279,10 +1289,12 @@ function fedora_repository_demo_objects_form() {
$datastreams_list = $smiley_stuff->get_datastreams_list_as_array();
if (empty($datastreams_list['COLLECTION_VIEW'])) {
$form['install_demos']['demo_collections']['#options']['demo:SmileyStuff'] = 'Add Islandora Collection View to Fedora Smiley Stuff Collection';
} else {
}
else {
$demo_objects['demo:SmileyStuff'] = $smiley_stuff;
}
} else {
}
else {
$form['install_demos']['smileynote'] = array(
'#value' => '<p>If you install the ' . l('fedora demo objects', 'https://wiki.duraspace.org/display/FCR30/Demonstration+Objects') . ' Islandora can display them as a collection.</p>'
);
@ -1531,7 +1543,8 @@ function fedora_repository_basket_form($form_state, $pids) {
$form['pid'] = array();
$form['title'] = array();
$form['desc'] = array();
} else {
}
else {
return;
}
@ -1589,7 +1602,8 @@ function theme_fedora_repository_basket_form($form) {
drupal_render($form['desc'][$key]),
);
}
} else {
}
else {
$rows[] = array(array('data' => t('Your basket is empty.'), 'colspan' => '4'));
}
@ -1627,7 +1641,8 @@ function fedora_repository_basket_form_submit($form, &$form_state) {
if ($form_state['values']['op'] == $form_state['values']['submit_all']) {
$msg = t("All objects exported to staging area");
$pids = _fedora_repository_get_basket_pids();
} elseif ($form_state['values']['op'] == $form_state['values']['submit']) {
}
elseif ($form_state['values']['op'] == $form_state['values']['submit']) {
$msg = t("Selected objects exported to staging area");
$pids = array_filter($form_state['values']['remove']);
}
@ -1662,7 +1677,8 @@ function fedora_repository_basket_form_submit($form, &$form_state) {
drupal_set_message($msg, $success ? 'info' : 'error');
//_fedora_repository_empty_basket();
} else {
}
else {
drupal_set_message(t("No objects selected or basket empty"), 'error');
}
@ -1712,7 +1728,8 @@ function fedora_repository_add_to_basket($pid, $warn = TRUE, $searchResultsFlag
if (!isset($_SESSION['basket'])) {
$_SESSION['basket'] = array();
$_SESSION['basket']['unprocessed'] = array($pid => $pid);
} else {
}
else {
$_SESSION['basket']['unprocessed'][$pid] = $pid;
}
@ -1764,7 +1781,8 @@ function fedora_repository_display_schema($file) {
$path = drupal_get_path('module', 'fedora_repository');
if (strtolower(substr($file, -3)) == 'xsd' && file_exists($path . '/' . $file)) {
drupal_goto($path . '/' . $file);
} else {
}
else {
drupal_goto();
}
return;

143
formClass.inc

@ -4,9 +4,6 @@
/*
* Created on Jan 22, 2008
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
class formClass {
@ -28,10 +25,8 @@ class formClass {
'description' => t('Enter the Fedora Collection information here'),
'page callback' => 'drupal_get_form',
'page arguments' => array('fedora_repository_admin'),
//'access' => user_access('access administration pages'),
'access arguments' => array('administer site configuration'),
'type' => MENU_NORMAL_ITEM,
// 'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/settings/fedora_repository/collection'] = array(
'title' => t('Collection list'),
@ -54,9 +49,7 @@ class formClass {
'page callback' => 'fedora_repository_display_schema',
'page arguments' => array('islandoracm.xsd'),
'type' => MENU_CALLBACK,
// 'page arguments'=>array(1),
'access arguments' => array('view fedora collection'),
// 'access' => TRUE
);
$items['collection_policy.xsd'] = array(
@ -64,30 +57,25 @@ class formClass {
'page callback' => 'fedora_repository_display_schema',
'page arguments' => array('collection_policy.xsd'),
'type' => MENU_CALLBACK,
// 'page arguments'=>array(1),
'access arguments' => array('view fedora collection'),
// 'access' => TRUE
);
$items['fedora'] = array(
// 'title' => t('Digital repository'),
'page callback' => 'repository_page',
'type' => MENU_CALLBACK,
// 'page arguments'=>array(1),
'access arguments' => array('view fedora collection'),
// 'access' => TRUE
);
$repository_title = variable_get('fedora_repository_title','Digital repository');
if (trim($repository_title)!= '') {
$respository_title=t($repository_title);
} else {
$repository_title= NULL;
$repository_title = variable_get('fedora_repository_title', 'Digital repository');
if (trim($repository_title) != '') {
$respository_title = t($repository_title);
}
else {
$repository_title = NULL;
}
$items['fedora/repository'] = array(
'title' => $repository_title,
'page callback' => 'repository_page',
'type' => MENU_NORMAL_ITEM,
// 'page arguments'=>array(1),
'access arguments' => array('view fedora collection'),
// 'access' => TRUE
);
@ -202,23 +190,6 @@ class formClass {
'access arguments' => array('view fedora collection'),
);
/*
$items['fedora/item'] = array (
'title' => t('Repository Item'),
'access arguments' => array('view fedora collection'),
'page callback' => 'fedora_repository_item',
'type' => MENU_NORMAL_ITEM,
);
$item['feodra/item/view'] = array (
'title' => t('View Repository Item'),
'access arguments' => array('view fedora collection'),
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 0,
);
*/
// $items = array_merge($items,$irItems);
return $items;
}
@ -297,7 +268,6 @@ class formClass {
'#description' => t('The URL to use for SOAP connections'),
'#required' => TRUE,
'#weight' => 0,
// '#suffix' => '<p>'. (fedora_available() ? '<img src="'. url('misc/watchdog-ok.png') . '"/>'. t('Successfully connected to Fedora server at ') : '<img src="'. url('misc/watchdog-error.png') . '"/> '. t('Unable to connect to Fedora server at ')) . variable_get('fedora_soap_url', '') . '</p>',
'#suffix' => '<p>' . (fedora_available() ? '<img src="' . url('misc/watchdog-ok.png') . '"/>' . t('Successfully connected to Fedora server at !fedora_soap_url', array('!fedora_soap_url' => variable_get('fedora_soap_url', ''))) : '<img src="' . url('misc/watchdog-error.png') . '"/> ' . t('Unable to connect to Fedora server at !fedora_soap_url</p>', array('!fedora_soap_url' => variable_get('fedora_soap_url', '')))),
);
$form['fedora_base_url'] = array(
@ -325,12 +295,12 @@ class formClass {
'#weight' => 0
);
// will allow admin user to remove namepsace restrictions if not explicitly disallowed in settings.php
if (variable_get('allow_open_namespace', TRUE)) {
$form['fedora_namespace'] = array(
'#type' => 'fieldset',
);
$form['fedora_namespace']['fedora_namespace_restriction_enforced'] = array(
'#weight' => -1,
'#type' => 'radios',
@ -339,8 +309,8 @@ class formClass {
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('fedora_namespace_restriction_enforced',TRUE)
'#description' => t('Allow administrator to restrict user\'s access to the PID namepaces listed below'),
'#default_value' => variable_get('fedora_namespace_restriction_enforced', TRUE)
);
$form['fedora_namespace']['fedora_pids_allowed'] = array(
@ -348,66 +318,56 @@ class formClass {
'#title' => t('PID namespaces allowed in this Drupal install'),
'#default_value' => variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: '),
'#description' => t('A space separated list PID namespaces that users are permitted to access from this Drupal installation. <br /> This could be more than a simple namespace ie demo:mydemos.'),
'#weight' => 0
);
/*
$form['fedora_admin_user'] = array(
}
else {
$form['fedora_pids_allowed'] = array(
'#type' => 'textfield',
'#title' => t('A user with the Drupal role administrator'),
'#default_value' => variable_get('fedora_admin_user', 'admin'),
'#description' => t('A user with the administrator role. This is the user the Islandora module will use when admin access is needed for a task, such as creating a collection object for a new user.'),
'#required' => TRUE, '#weight' => 0
);
$form['fedora_searchterms_location'] = array(
'#type' => 'file',
'#title' => 'SearchTerms.xml file location',
'#title' => t('PID namespaces allowed in this Drupal install'),
'#default_value' => variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: '),
'#description' => t('A space separated list PID namespaces that users are permitted to access from this Drupal installation. <br /> This could be more than a simple namespace ie demo:mydemos.'),
'#weight' => 0
);
*/
}
$form['fedora_repository_title'] = array(
'#type' => 'textfield',
'#title' => t('Fedora Repository Title'),
'#default_value'=> variable_get('fedora_repository_title', 'Digital Repository'),
'#default_value' => variable_get('fedora_repository_title', 'Digital Repository'),
'#description' => t('The title displayed when viewing collections and objects in /fedora/repository. Leave blank to display no title. Note that the menus must be rebuilt after changing this variable.'),
);
$form['fedora_object_display_title'] = array(
'#type' => 'select',
'#title' => t('Display Object Title Behaviour'),
'#default_value'=> variable_get('fedora_object_display_title', ObjectHelper::$DISPLAY_ALWAYS),
'#options' => array(ObjectHelper::$DISPLAY_ALWAYS=>t('Always'),ObjectHelper::$DISPLAY_NEVER=>t('Never'),ObjectHelper::$DISPLAY_NO_MODEL_OUTPUT=>t('Only if no Content Model display output.')),
'#default_value' => variable_get('fedora_object_display_title', ObjectHelper::$DISPLAY_ALWAYS),
'#options' => array(ObjectHelper::$DISPLAY_ALWAYS => t('Always'), ObjectHelper::$DISPLAY_NEVER => t('Never'), ObjectHelper::$DISPLAY_NO_MODEL_OUTPUT => t('Only if no Content Model display output.')),
'#description' => t('Determines when to display the object (or collection) title when viewing an object/collection page.'),
);
$form['fedora_object_display_description'] = array(
'#type' => 'select',
'#title' => t('Display Object Description Behaviour'),
'#default_value'=> variable_get('fedora_object_display_description', ObjectHelper::$DISPLAY_ALWAYS),
'#options' => array(ObjectHelper::$DISPLAY_ALWAYS=>t('Always'),ObjectHelper::$DISPLAY_NEVER=>t('Never'),ObjectHelper::$DISPLAY_NO_MODEL_OUTPUT=>t('Only if no Content Model display output.')),
'#default_value' => variable_get('fedora_object_display_description', ObjectHelper::$DISPLAY_ALWAYS),
'#options' => array(ObjectHelper::$DISPLAY_ALWAYS => t('Always'), ObjectHelper::$DISPLAY_NEVER => t('Never'), ObjectHelper::$DISPLAY_NO_MODEL_OUTPUT => t('Only if no Content Model display output.')),
'#description' => t('Determines when to display the default object (or collection) description fieldset when viewing an object/collection page.'),
);
$form['fedora_object_restrict_datastreams'] = array(
'#type' => 'checkbox',
'#title' => t('Restrict Access to Fedora Object Datastreams'),
'#default_value'=> variable_get('fedora_object_restrict_datastreams', FALSE),
'#default_value' => variable_get('fedora_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['fedora_collection_display_list'] = array(
'#type' => 'select',
'#title' => t('Display Collection List Behaviour'),
'#default_value'=> variable_get('fedora_collection_display_list', ObjectHelper::$DISPLAY_ALWAYS),
'#options' => array(ObjectHelper::$DISPLAY_ALWAYS=>t('Always'),ObjectHelper::$DISPLAY_NEVER=>t('Never'),ObjectHelper::$DISPLAY_NO_MODEL_OUTPUT=>t('Only if no Content Model display output.')),
'#default_value' => variable_get('fedora_collection_display_list', ObjectHelper::$DISPLAY_ALWAYS),
'#options' => array(ObjectHelper::$DISPLAY_ALWAYS => t('Always'), ObjectHelper::$DISPLAY_NEVER => t('Never'), ObjectHelper::$DISPLAY_NO_MODEL_OUTPUT => t('Only if no Content Model display output.')),
'#description' => t('Determines when to display the list of objects when viewing a collection page.'),
);
//Export functionality
$form['module']['export_area'] = array(
'#type' => 'textfield',
@ -553,7 +513,6 @@ class formClass {
'#options' => $modelsForForm,
//'#description' => t('Content models available in this collection. A content model defines what is allowed in a collection and what to do with a file when it is uploaded (An example may creating a thumbnail from an image.).')
'#description' => t('Content models define datastream composition, relationships between this and other content models, and the mandatory behaviors associated with each digital object.<br /> Additional information may be found <a href="https://wiki.duraspace.org/display/FEDORACREATE/Content+Models+Overview">here.</a> ')
);
break;
@ -658,15 +617,6 @@ class formClass {
'#type' => 'hidden',
'#value' => "$pid"
);
/*
$form['stream_location'] = array (
'#title' => 'File Location',
'#required' => 'TRUE',
'#description' => 'The path to the file for the new datastream',
//'#prefix' => '<a onclick="window.open(\'?q=imce/browse\', \'_imce_fedora_\', \'width=640, height=600, resizable=1\')" href="#">Upload File</a>',
'#type' => 'hidden'
);
*/
$form['stream_label'] = array(
'#title' => 'Datastream Label',
@ -674,13 +624,7 @@ class formClass {
'#description' => t('A Human readable label'),
'#type' => 'textfield'
);
// $form['delete_file'] = array (
// '#title' => 'Remove File After Ingest',
// '#description' => 'Remove the file from the drupal file system after ingest into the Digital Repository.',
// '#type' => 'hidden',
// '#default_value' => 'remove_file',
// '#options' => $options
// );
$form['#attributes']['enctype'] = 'multipart/form-data';
$form['add-stream-file-location'] = array(
'#type' => 'file',
@ -792,7 +736,7 @@ class formClass {
}
}
}
// $form['#redirect'] = "fedora/repository/$pid/";
$form['pid'] = array(
'#type' => 'hidden',
'#value' => "$pid"
@ -845,34 +789,5 @@ class formClass {
return $form;
}
/*
function createReplaceDataStreamForm($pid, $dsId, &$form_state) {
$form = array();
$form['#attributes']['enctype'] = 'multipart/form-data';
$form['file'] = array(
'#type' => 'file',
'#title' => t('Upload Document'),
'#description' => t('The file to upload.')
);
$form['pid'] = array(
'#type' => 'value',
'#value' => $pid,
);
$form['dsId'] = array(
'#type' => 'value',
'#value' => $dsId,
);
$form['submit']=array(
'#type' => 'submit',
'#value'=>t('Replace Datastream')
);
return $form;
}
*/
}

Loading…
Cancel
Save