Browse Source

Make the rendering of the regenerate link respect things.

pull/443/head
Jordan Dukart 11 years ago
parent
commit
9a76642364
  1. 17
      islandora.module
  2. 10
      theme/theme.inc

17
islandora.module

@ -1829,3 +1829,20 @@ function islandora_islandora_metadata_display_info() {
),
);
}
/**
* Implements hook_islandora_datastream_access().
*/
function islandora_islandora_datastream_access($op, AbstractDatastream $datastream, $user) {
if ($op == ISLANDORA_REGENERATE_DERIVATIVES) {
$object = $datastream->parent;
$hooks = islandora_invoke_hook_list(ISLANDORA_DERVIATIVE_CREATION_HOOK, $object->models, array($object));
foreach ($hooks as $hook) {
if ($hook['destination_dsid'] == $datastream->id && ((isset($hook['source_dsid']) && isset($object[$hook['source_dsid']]) && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $object[$hook['source_dsid']], $user)) || (array_key_exists('source_dsid', $hook) && $hook['source_dsid'] == NULL))) {
return TRUE;
}
}
return FALSE;
}
return NULL;
}

10
theme/theme.inc

@ -53,14 +53,12 @@ function islandora_preprocess_islandora_default_edit(array &$variables) {
'class' => 'datastream-size',
'data' => islandora_datastream_get_human_readable_size($ds),
);
if (islandora_datastream_access(ISLANDORA_VIEW_DATASTREAM_HISTORY, $ds)) {
$row[] = array(
'class' => 'datastream-versions',
'data' => theme('islandora_datastream_version_link', array(
'datastream' => $ds,
)),
);
}
$row[] = array(
'class' => 'datastream-download',
'data' => theme('islandora_datastream_download_link', array(
@ -79,14 +77,12 @@ function islandora_preprocess_islandora_default_edit(array &$variables) {
'datastream' => $ds,
)),
);
if (islandora_datastream_access(ISLANDORA_REGENERATE_DERIVATIVES, $ds)) {
$row[] = array(
'class' => 'datastream-regenerate',
'data' => theme('islandora_datastream_regenerate_link', array(
'datastream' => $ds,
)),
);
}
$rows[] = $row;
}
$caption = filter_xss($islandora_object->label) . ' - ' . $islandora_object->id;
@ -444,14 +440,10 @@ function theme_islandora_datastream_version_link(array $vars) {
*/
function theme_islandora_datastream_regenerate_link(array $vars) {
$datastream = $vars['datastream'];
$object = $datastream->parent;
$hooks = islandora_invoke_hook_list(ISLANDORA_DERVIATIVE_CREATION_HOOK, $object->models, array($object));
foreach ($hooks as $hook) {
if (isset($hook['source_dsid']) && isset($object[$hook['source_dsid']]) && $hook['destination_dsid'] == $datastream->id) {
if (islandora_datastream_access(ISLANDORA_REGENERATE_DERIVATIVES, $datastream)) {
return l(t('regenerate'), "islandora/object/{$datastream->parent->id}/datastream/{$datastream->id}/regenerate");
}
}
}
/**
* Implements hook_preprocess().

Loading…
Cancel
Save