Browse Source

ISLANDORA-171 Move access check to inside of 'display datastreams' function

pull/105/head
Alexander O'Neill 14 years ago
parent
commit
0edd813f9a
  1. 98
      ObjectHelper.inc
  2. 9
      plugins/map_viewer.inc

98
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 = "<br /><table>\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 .= '<tr><th colspan="4"><h3>' . t("!text", array('!text' => $availableDataStreamsText)) . '</h3></th></tr>';
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 = "<br /><table>\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 .= '<tr><th colspan="4"><h3>' . t("!text", array('!text' => $availableDataStreamsText)) . '</h3></th></tr>';
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); //"<tr><td><b>$key :</b></td><td>$value</td></tr>\n";
}
//create the links to each datastream
$dataStreamBody .= $this->create_link_for_ds($object_pid, $datastreamValue); //"<tr><td><b>$key :</b></td><td>$value</td></tr>\n";
}
}
}
$dataStreamBody .= "</table>\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 .= "</table>\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 = '<div class = "fedora_detailed_list">' . $dataStreamBody . '</div>';
return $dataStreamBody;
}
$dataStreamBody = '<div class = "fedora_detailed_list">' . $dataStreamBody . '</div>';
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)) {

9
plugins/map_viewer.inc

@ -38,18 +38,17 @@ class ShowMapStreamsInFieldSets {
$tabset['my_tabset']['second_tab'] = array(
'#type' => 'tabpage',
'#title' => t('Full-size'),
'#content' => $html//'<div class="iiv"></div>'
'#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);
}
}

Loading…
Cancel
Save