Browse Source

Merge pull request #443 from jordandukart/7.x-smarter-links

Only render the regenerate under certain conditions.
pull/445/merge
Adam 11 years ago
parent
commit
a5b3fc280a
  1. 24
      islandora.module
  2. 22
      theme/theme.inc

24
islandora.module

@ -1829,3 +1829,27 @@ function islandora_islandora_metadata_display_info() {
),
);
}
/**
* Implements hook_islandora_datastream_access().
*/
function islandora_islandora_datastream_access($op, AbstractDatastream $datastream, $user) {
module_load_include('inc', 'islandora', 'includes/utilities');
$result = islandora_namespace_accessible($datastream->parent->id) && user_access($op, $user);
if ($result && $op == ISLANDORA_REGENERATE_DERIVATIVES) {
$applicable_hook = FALSE;
$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))) {
$applicable_hook = TRUE;
break;
}
}
if (!$applicable_hook) {
$result = FALSE;
}
}
return $result;
}

22
theme/theme.inc

@ -79,14 +79,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,
)),
);
}
$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,12 +442,8 @@ 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 ($hook['destination_dsid'] == $datastream->id) {
return l(t('regenerate'), "islandora/object/{$datastream->parent->id}/datastream/{$datastream->id}/regenerate");
}
if (islandora_datastream_access(ISLANDORA_REGENERATE_DERIVATIVES, $datastream)) {
return l(t('regenerate'), "islandora/object/{$datastream->parent->id}/datastream/{$datastream->id}/regenerate");
}
}

Loading…
Cancel
Save