|
|
|
@ -41,7 +41,7 @@ class ObjectHelper {
|
|
|
|
|
*/ |
|
|
|
|
function makeObject($pid, $dsID, $asAttachment = FALSE, $label = NULL, $filePath=FALSE, $version=NULL, $forceSoap = FALSE) { |
|
|
|
|
global $user; |
|
|
|
|
module_load_include('inc','fedora_repository','ContentModel'); |
|
|
|
|
module_load_include('inc', 'fedora_repository', 'ContentModel'); |
|
|
|
|
if ($pid == NULL || $dsID == NULL) { |
|
|
|
|
drupal_set_message(t("no pid or dsid given to create an object with"), 'error'); |
|
|
|
|
return ' '; |
|
|
|
@ -61,7 +61,7 @@ class ObjectHelper {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (variable_get('fedora_object_restrict_datastreams', FALSE) == TRUE ) { |
|
|
|
|
if (variable_get('fedora_object_restrict_datastreams', FALSE) == TRUE) { |
|
|
|
|
if (($cm = ContentModel::loadFromObject($pid)) == FALSE) { |
|
|
|
|
drupal_set_message(t("You do not have access to objects without an Islandora Content Model."), 'error'); |
|
|
|
|
drupal_access_denied(); |
|
|
|
@ -69,7 +69,7 @@ class ObjectHelper {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$cmDatastreams = $cm->listDatastreams(); |
|
|
|
|
if ( !((isset($user) && in_array('administrator',$user->roles)) || in_array($dsID,$cmDatastreams))) { |
|
|
|
|
if (!((isset($user) && in_array('administrator', $user->roles)) || in_array($dsID, $cmDatastreams))) { |
|
|
|
|
drupal_set_message(t("You do not have access to the specified datastream."), 'error'); |
|
|
|
|
drupal_access_denied(); |
|
|
|
|
return ' '; |
|
|
|
@ -81,7 +81,7 @@ class ObjectHelper {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($item->datastreams[$dsID])) { |
|
|
|
|
$mimeType=$item->datastreams[$dsID]['MIMEType']; |
|
|
|
|
$mimeType = $item->datastreams[$dsID]['MIMEType']; |
|
|
|
|
if ($label == NULL) { |
|
|
|
|
$label = $item->datastreams[$dsID]['label']; |
|
|
|
|
} |
|
|
|
@ -94,7 +94,7 @@ class ObjectHelper {
|
|
|
|
|
if ((!isset($user)) || $user->uid == 0) { |
|
|
|
|
$fedoraUser = 'anonymous'; |
|
|
|
|
$fedoraPass = 'anonymous'; |
|
|
|
|
$contentSize= 0; |
|
|
|
|
$contentSize = 0; |
|
|
|
|
} else { |
|
|
|
|
$fedoraUser = $user->name; |
|
|
|
|
$fedoraPass = $user->pass; |
|
|
|
@ -166,10 +166,10 @@ class ObjectHelper {
|
|
|
|
|
header('Content-Disposition: attachment; filename="' . $suggestedFileName . '"'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ( (isset($user) && $user->uid != 0) || $forceSoap || isset($_SERVER['HTTPS'])) { |
|
|
|
|
if ((isset($user) && $user->uid != 0) || $forceSoap || isset($_SERVER['HTTPS'])) { |
|
|
|
|
curl_exec($ch); |
|
|
|
|
} else { |
|
|
|
|
header('Location: '.$url); |
|
|
|
|
header('Location: ' . $url); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
curl_close($ch); |
|
|
|
@ -258,9 +258,9 @@ class ObjectHelper {
|
|
|
|
|
$item = new Fedora_Item($pid); |
|
|
|
|
|
|
|
|
|
if (user_access(ObjectHelper :: $PURGE_FEDORA_OBJECTSANDSTREAMS)) { |
|
|
|
|
$allow=TRUE; |
|
|
|
|
$allow = TRUE; |
|
|
|
|
if (module_exists('fedora_fesl')) { |
|
|
|
|
$allow= fedora_fesl_check_roles($pid,'write'); |
|
|
|
|
$allow = fedora_fesl_check_roles($pid, 'write'); |
|
|
|
|
} |
|
|
|
|
if ($allow) { |
|
|
|
|
$purgeImage = '<a title="purge datastream ' . $dataStreamValue->label . '" href="' . $base_url . '/fedora/repository/purgeStream/' . |
|
|
|
@ -274,11 +274,11 @@ class ObjectHelper {
|
|
|
|
|
|
|
|
|
|
// Add an icon to replace a datastream |
|
|
|
|
// @TODO Note: using l(theme_image(..), ...); for these image links (and other links) may remove the need to have clean urls enabled. |
|
|
|
|
$replaceImage= ' '; |
|
|
|
|
$replaceImage = ' '; |
|
|
|
|
if (user_access(ObjectHelper :: $ADD_FEDORA_STREAMS)) { |
|
|
|
|
$allow=TRUE; |
|
|
|
|
$allow = TRUE; |
|
|
|
|
if (module_exists('fedora_fesl')) { |
|
|
|
|
$allow= fedora_fesl_check_roles($pid,'write'); |
|
|
|
|
$allow = fedora_fesl_check_roles($pid, 'write'); |
|
|
|
|
} |
|
|
|
|
if ($allow) { |
|
|
|
|
$replaceImage = '<a title="' . t("Replace datastream") . " " . $dataStreamValue->label . '" href="' . $base_url . '/fedora/repository/replaceStream/' . $pid . '/' . $dataStreamValue->ID . '/' . $dataStreamValue->label . '"><img src="' . $base_url . '/' . $path . '/images/replace.png" alt="replace datastream" /></a>'; |
|
|
|
@ -380,9 +380,9 @@ class ObjectHelper {
|
|
|
|
|
$baseUrl = base_path(); |
|
|
|
|
//$baseUrl=substr($baseUrl, 0, (strpos($baseUrl, "/")-1)); |
|
|
|
|
if (user_access(ObjectHelper :: $EDIT_FEDORA_METADATA)) { |
|
|
|
|
$allow=TRUE; |
|
|
|
|
$allow = TRUE; |
|
|
|
|
if (module_exists('fedora_fesl')) { |
|
|
|
|
$allow= fedora_fesl_check_roles($pid,'write'); |
|
|
|
|
$allow = fedora_fesl_check_roles($pid, 'write'); |
|
|
|
|
} |
|
|
|
|
if ($allow) { |
|
|
|
|
$output .= '<br /><a title = "' . t('Edit Meta Data') . '" href="' . $base_url . '/fedora/repository/' . 'editmetadata/' . $pid . '/' . |
|
|
|
@ -439,7 +439,7 @@ class ObjectHelper {
|
|
|
|
|
foreach ($object as $datastream) { |
|
|
|
|
foreach ($datastream as $datastreamValue) { |
|
|
|
|
|
|
|
|
|
if (variable_get('fedora_object_restrict_datastreams', FALSE) == FALSE || ((isset($user) && in_array('administrator',$user->roles)) || in_array($datastreamValue->ID,$cmDatastreams))) { |
|
|
|
|
if (variable_get('fedora_object_restrict_datastreams', FALSE) == FALSE || ((isset($user) && in_array('administrator', $user->roles)) || in_array($datastreamValue->ID, $cmDatastreams))) { |
|
|
|
|
if ($datastreamValue->ID == 'OBJ') { |
|
|
|
|
$hasOBJStream = '1'; |
|
|
|
|
$mainStreamLabel = $datastreamValue->label; |
|
|
|
@ -456,9 +456,9 @@ class ObjectHelper {
|
|
|
|
|
$dataStreamBody .= "</table>\n"; |
|
|
|
|
//if they have access let them add a datastream |
|
|
|
|
if (user_access(ObjectHelper :: $ADD_FEDORA_STREAMS)) { |
|
|
|
|
$allow=TRUE; |
|
|
|
|
$allow = TRUE; |
|
|
|
|
if (module_exists('fedora_fesl')) { |
|
|
|
|
$allow= fedora_fesl_check_roles($object_pid,'write'); |
|
|
|
|
$allow = fedora_fesl_check_roles($object_pid, 'write'); |
|
|
|
|
} |
|
|
|
|
if ($allow) { |
|
|
|
|
$dataStreamBody .= drupal_get_form('add_stream_form', $object_pid); |
|
|
|
@ -493,9 +493,9 @@ class ObjectHelper {
|
|
|
|
|
$content .= $dataStreamBody; |
|
|
|
|
|
|
|
|
|
if (user_access(ObjectHelper :: $PURGE_FEDORA_OBJECTSANDSTREAMS)) { |
|
|
|
|
$allow=TRUE; |
|
|
|
|
$allow = TRUE; |
|
|
|
|
if (module_exists('fedora_fesl')) { |
|
|
|
|
$allow= fedora_fesl_check_roles($object_pid,'write'); |
|
|
|
|
$allow = fedora_fesl_check_roles($object_pid, 'write'); |
|
|
|
|
} |
|
|
|
|
if ($allow) { |
|
|
|
|
//$purgeObject = '<a title="' . t('Purge Object ') . $object_pid . '" href="' . base_path() . 'fedora/repository/purgeObject/' . |
|
|
|
@ -602,20 +602,21 @@ class ObjectHelper {
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
* determines whether we can see the object or not |
|
|
|
|
* checks PID namespace permissions, and user permissions |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
function fedora_repository_access($op, $pid) { |
|
|
|
|
global $user; |
|
|
|
|
|
|
|
|
|
$returnValue = FALSE; |
|
|
|
|
$isRestricted = variable_get('fedora_namespace_restriction_enforced',TRUE); |
|
|
|
|
if(!$isRestricted){ |
|
|
|
|
return TRUE; |
|
|
|
|
$isRestricted = variable_get('fedora_namespace_restriction_enforced', TRUE); |
|
|
|
|
if (!$isRestricted) { |
|
|
|
|
$returnValue = TRUE; |
|
|
|
|
} |
|
|
|
|
if ($pid == NULL) { |
|
|
|
|
$pid = variable_get('fedora_repository_pid', 'islandora:top'); |
|
|
|
|
} |
|
|
|
|
$nameSpaceAllowed = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: Islandora: ilives: ')); |
|
|
|
|
$nameSpaceAllowed = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: ')); |
|
|
|
|
$pos = NULL; |
|
|
|
|
foreach ($nameSpaceAllowed as $nameSpace) { |
|
|
|
|
$pos = stripos($pid, $nameSpace); |
|
|
|
@ -729,9 +730,9 @@ class ObjectHelper {
|
|
|
|
|
$collectionPolicyExists = $objectHelper->getMimeType($pid, CollectionPolicy::getDefaultDSID()); |
|
|
|
|
if (user_access(ObjectHelper :: $INGEST_FEDORA_OBJECTS) && $collectionPolicyExists) { |
|
|
|
|
if (!empty($collectionPolicyExists)) { |
|
|
|
|
$allow=TRUE; |
|
|
|
|
$allow = TRUE; |
|
|
|
|
if (module_exists('fedora_fesl')) { |
|
|
|
|
$allow= fedora_fesl_check_roles($pid,'write'); |
|
|
|
|
$allow = fedora_fesl_check_roles($pid, 'write'); |
|
|
|
|
} |
|
|
|
|
if ($allow) { |
|
|
|
|
// $ingestObject = '<a title="'. t('Ingest a New object into ') . $collectionName . ' '. $collection_pid . '" href="'. base_path() . |
|
|
|
@ -740,8 +741,7 @@ class ObjectHelper {
|
|
|
|
|
'/images/ingest.png" alt="' . t('Add a New Object') . '" class="icon"></a>' . t(' Add to this Collection'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
} else { |
|
|
|
|
$ingestObject = ' '; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1017,11 +1017,11 @@ class ObjectHelper {
|
|
|
|
|
|
|
|
|
|
$url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); |
|
|
|
|
$url .= "?type=tuples&flush=TRUE&format=CSV&limit=1&offset=0&lang=itql&stream=on&query=" . $query_string; |
|
|
|
|
$result = preg_split('/[\r\n]+/',do_curl($url)); |
|
|
|
|
$result = preg_split('/[\r\n]+/', do_curl($url)); |
|
|
|
|
array_shift($result); // throw away first line |
|
|
|
|
$matches =str_getcsv(join("\n",$result)); |
|
|
|
|
$matches = str_getcsv(join("\n", $result)); |
|
|
|
|
if ($matches !== NULL) { |
|
|
|
|
$parent = preg_replace('/^info:fedora\//','',$matches[0]); |
|
|
|
|
$parent = preg_replace('/^info:fedora\//', '', $matches[0]); |
|
|
|
|
$breadcrumbs[] = l($matches[1], 'fedora/repository/' . $pid); |
|
|
|
|
if ($parent == variable_get('fedora_repository_pid', 'islandora:top')) { |
|
|
|
|
$breadcrumbs[] = l(t('Home'), ''); // l(t('Digital repository'), 'fedora/repository'); |
|
|
|
|