From 0edd813f9a6516172ba2c0343c989f5c6cbae878 Mon Sep 17 00:00:00 2001 From: Alexander O'Neill Date: Tue, 1 Feb 2011 15:59:03 -0400 Subject: [PATCH] ISLANDORA-171 Move access check to inside of 'display datastreams' function --- ObjectHelper.inc | 98 +++++++++++++++++++++--------------------- plugins/map_viewer.inc | 9 ++-- 2 files changed, 54 insertions(+), 53 deletions(-) diff --git a/ObjectHelper.inc b/ObjectHelper.inc index 81e09186..5c70d2cc 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -378,56 +378,59 @@ class ObjectHelper { } function getFormattedDatastreamList($object_pid, $contentModels, &$fedoraItem) { - $availableDataStreamsText = 'Detailed List of Content'; - //$metaDataText='Description'; - $mainStreamLabel = NULL; - $object = $fedoraItem->get_datastreams_list_as_SimpleXML(); - if (!isset($object)) { - drupal_set_message(t("No datastreams available")); - return ' '; - } - $hasOBJStream = NULL; - $hasTNStream = FALSE; - $dataStreamBody = "
\n"; - - $cmDatastreams = array(); - if (variable_get('fedora_object_restrict_datastreams', FALSE) == TRUE && ($cm = ContentModel::loadFromObject($object_pid)) !== FALSE) { - $cmDatastreams = $cm->listDatastreams(); - } - - $dataStreamBody .= $this->get_parent_objects_asHTML($object_pid); - $dataStreamBody .= ''; - 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 ($datastreamValue->ID == 'OBJ') { - $hasOBJStream = '1'; - $mainStreamLabel = $datastreamValue->label; - $mainStreamLabel = str_replace("_", " ", $mainStreamLabel); - } - if ($datastreamValue->ID == 'TN') { - $hasTNStream = TRUE; + if (user_access(ObjectHelper :: $VIEW_DETAILED_CONTENT_LIST)) { + $availableDataStreamsText = 'Detailed List of Content'; + //$metaDataText='Description'; + $mainStreamLabel = NULL; + $object = $fedoraItem->get_datastreams_list_as_SimpleXML(); + if (!isset($object)) { + drupal_set_message(t("No datastreams available")); + return ' '; + } + $hasOBJStream = NULL; + $hasTNStream = FALSE; + $dataStreamBody = "

' . t("!text", array('!text' => $availableDataStreamsText)) . '

\n"; + + $cmDatastreams = array(); + if (variable_get('fedora_object_restrict_datastreams', FALSE) == TRUE && ($cm = ContentModel::loadFromObject($object_pid)) !== FALSE) { + $cmDatastreams = $cm->listDatastreams(); + } + + $dataStreamBody .= $this->get_parent_objects_asHTML($object_pid); + $dataStreamBody .= ''; + 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 ($datastreamValue->ID == 'OBJ') { + $hasOBJStream = '1'; + $mainStreamLabel = $datastreamValue->label; + $mainStreamLabel = str_replace("_", " ", $mainStreamLabel); + } + if ($datastreamValue->ID == 'TN') { + $hasTNStream = TRUE; + } + //create the links to each datastream + $dataStreamBody .= $this->create_link_for_ds($object_pid, $datastreamValue); //"\n"; } - //create the links to each datastream - $dataStreamBody .= $this->create_link_for_ds($object_pid, $datastreamValue); //"\n"; } } - } - $dataStreamBody .= "

' . t("!text", array('!text' => $availableDataStreamsText)) . '

$key :$value
$key :$value
\n"; - //if they have access let them add a datastream - if (user_access(ObjectHelper :: $ADD_FEDORA_STREAMS)) { - $allow=TRUE; - if (module_exists('fedora_fesl')) { - $allow= fedora_fesl_check_roles($object_pid,'write'); - } - if ($allow) { - $dataStreamBody .= drupal_get_form('add_stream_form', $object_pid); + $dataStreamBody .= "\n"; + //if they have access let them add a datastream + if (user_access(ObjectHelper :: $ADD_FEDORA_STREAMS)) { + $allow=TRUE; + if (module_exists('fedora_fesl')) { + $allow= fedora_fesl_check_roles($object_pid,'write'); + } + if ($allow) { + $dataStreamBody .= drupal_get_form('add_stream_form', $object_pid); + } } + + $dataStreamBody = '
' . $dataStreamBody . '
'; + return $dataStreamBody; } - - $dataStreamBody = '
' . $dataStreamBody . '
'; - return $dataStreamBody; + return ''; } /** @@ -454,9 +457,8 @@ class ObjectHelper { $dataStreamBody = ''; $fedoraItem = new Fedora_Item($object_pid); - if (user_access(ObjectHelper :: $VIEW_DETAILED_CONTENT_LIST)) { - $dataStreamBody = $this->getFormattedDatastreamList($object_pid, $contentModels, $fedoraItem); - } + + $dataStreamBody = $this->getFormattedDatastreamList($object_pid, $contentModels, $fedoraItem); $content = ''; if (empty($contentModels)) { diff --git a/plugins/map_viewer.inc b/plugins/map_viewer.inc index acd990ab..2bf5abd8 100644 --- a/plugins/map_viewer.inc +++ b/plugins/map_viewer.inc @@ -38,18 +38,17 @@ class ShowMapStreamsInFieldSets { $tabset['my_tabset']['second_tab'] = array( '#type' => 'tabpage', '#title' => t('Full-size'), - '#content' => $html//'
' + '#content' => $html, ); - + $objectHelper = new ObjectHelper(); $item = new Fedora_Item($this->pid); $tabset['my_tabset']['third_tab'] = array( '#type' => 'tabpage', '#title' => t('Description'), - '#content' => $item->get_dissemination('islandora:mods2htmlSdef', 'mods2html'), + '#content' => $item->get_dissemination('islandora:mods2htmlSdef', 'mods2html') + . $objectHelper->getFormattedDatastreamList($this->pid, NULL, $item), ); // Render the tabset. return tabs_render($tabset); - - return theme('fieldset', $collection_fieldset); } }