@ -156,7 +156,7 @@ function islandora_menu() {
$items['islandora/object/%/datastream/%/edit'] = array(
$items['islandora/object/%/datastream/%/edit'] = array(
'title' => 'Edit datastream',
'title' => 'Edit datastream',
'page callback' => 'islandora_edit_stream',
'page callback' => 'islandora_edit_data stream',
'page arguments' => array(2, 4),
'page arguments' => array(2, 4),
'type' => MENU_CALLBACK,
'type' => MENU_CALLBACK,
'access arguments' => array(FEDORA_METADATA_EDIT),
'access arguments' => array(FEDORA_METADATA_EDIT),
@ -164,7 +164,7 @@ function islandora_menu() {
$items['islandora/object/%/datastream/%/delete'] = array(
$items['islandora/object/%/datastream/%/delete'] = array(
'title' => 'Purge data stream',
'title' => 'Purge data stream',
'page callback' => 'islandora_purge_stream',
'page callback' => 'islandora_purge_data stream',
'page arguments' => array(2, 4),
'page arguments' => array(2, 4),
'type' => MENU_CALLBACK,
'type' => MENU_CALLBACK,
'access arguments' => array(FEDORA_PURGE),
'access arguments' => array(FEDORA_PURGE),
@ -240,7 +240,7 @@ function islandora_purge_object($object_id) {
}
}
$content_models = $fedora_object->models;
$content_models = $fedora_object->models;
$arr = module_invoke_all('islandora_pre_purge_object', $fedora_object); //notify modules of pending deletion
$arr = module_invoke_all('islandora_pre_purge_object', $fedora_object); //notify modules of pending deletion
if ($arr['delete']) {
if (isset($arr['delete']) && $arr['delete']) {
try {
try {
$fedora_object->delete();
$fedora_object->delete();
} catch (Exception $e) {
} catch (Exception $e) {
@ -291,39 +291,82 @@ function islandora_edit_object($object_id) {
$output .= $key . '<br />' . $value; //if we have multiple modules handle one cmodel we need to iterate over multiple
$output .= $key . '<br />' . $value; //if we have multiple modules handle one cmodel we need to iterate over multiple
}
}
//we could do another module invoke all here to build the edit tab with a default implemented in this module?
//we could do another module invoke all here to build the edit tab with a default implemented in this module?
return $output;
return $output;
}
}
/**
/**
* builds a default page for the edit tab
* builds a default page for the edit tab
* @param object $fedora_object
* @param object $fedora_object
* A tuque Fedora Object
* A tuque Fedora Object
*/
*/
function islandora_islandora_edit_object($fedora_object){
function islandora_islandora_edit_object($fedora_object) {
$output = theme('islandora_default_edit', array('islandora_object' => $fedora_object));
$output = theme('islandora_default_edit', array('islandora_object' => $fedora_object));
return array ('Default Edit output' => $output);
return array('Default Edit output' => $output);
}
}
/**
/**
* Gives the option of purging or deleting a datastream.
*
*
* @paramstring $datastream_id
* The default behaviour is to purge the datastream but this can be overridden using the
* @return type
* 'islandora_pre_purge_datastream' hook. The returned array can include a 'block' => TRUE
* pair which will prevent the datastream from being deleted if it particularly needed for
* a certain function. Returning 'delete' => TRUE will cause the datastream to be put into
* a deleted state.
*
* @param string $object_id
* ID of the object
* @param string $datastream_id
* ID of the datastream
*
*/
*/
function islandora_purge_datastream($object_id, $datastream_id) {
function islandora_purge_datastream($object_id, $datastream_id) {
module_load_include('inc', 'islandora', 'RestConnection');
global $user;
if (!isset($datastream_id)) {
if (!isset($datastream_id)) {
drupal_set_message(t('Cannot remove datastream, datastream id not set'));
drupal_set_message(t('Cannot remove datastream, datastream id not set'));
return;
return;
}
}
$object = new Object($object_id);
try {
if (!isset($object)) {
$restConnection = new RestConnection($user);
$fedora_object = new FedoraObject($object_id, $restConnection->repository);
} catch (Exception $e) {
drupal_set_message(t('Error getting Islandora object %s', array('%s' => $object_id)), 'error');
return "";
}
if (!isset($fedora_object)) {
drupal_set_message(t('Could not remove object, object not found'));
drupal_set_message(t('Could not remove object, object not found'));
return;
return;
}
}
module_invoke_all('islandora_purge_datastream', $datastream); //notify modules of pending deletion so we can update rels etc
if (!isset($fedora_object)) {
$object->deleteDatastream();
drupal_set_message(t('Could not remove object, object not found'));
return;
}
$arr = module_invoke_all('islandora_pre_purge_datastream', $fedora_object, $datastream_id); //notify modules of pending deletion so we can update rels etc
if (isset($arr['block']) && $arr['block']) {
drupal_set_message(t('Purging of the %d datastream was blocked', array('%d' => $datastream_id)), 'warning');
return;
}
if (isset($arr['delete']) && $arr['delete']) {
try {
$datastream = new FedoraDatastream($datastream_id, $fedora_object, $restConnection->repository);
$datastream->state = 'D';
} catch (Exception $e) {
drupal_set_message(t('Error deleting %s datastream from Islandora object %o', array('%s' => $datastream_id, '%o' => $object_id)), 'error');
return;
}
}
else {
try {
$fedora_object->purgeDatastream($datastream_id);
} catch (Exception $e) {
drupal_set_message(t('Error purging %s datastream from Islandora object %o', array('%s' => $datastream_id, '%o' => $object_id)), 'error');
return;
}
}
module_invoke_all('islandora_post_purge_datastream', $fedora_object, $datastream_id); //notify modules post deletion
}
}
/**
/**
* The view entry point. modules should implement hook_islandora_view_object for the Fedora Content models that
* The view entry point. modules should implement hook_islandora_view_object for the Fedora Content models that
* there modules want to provide a view for.
* there modules want to provide a view for.
@ -471,7 +514,6 @@ function islandora_preprocess_islandora_default(&$variables) {
}
}
}
}
function islandora_preprocess_islandora_default_edit(&$variables){
function islandora_preprocess_islandora_default_edit(&$variables) {
//$islandora_object = $variables['islandora_object'];
//$islandora_object = $variables['islandora_object'];
}
}