Browse Source

Merge branch '7.x' of github.com:Islandora/islandora into 7.x

pull/109/merge
Paul Pound 13 years ago
parent
commit
d733fef8c5
  1. 49
      islandora.module

49
islandora.module

@ -124,6 +124,7 @@ function islandora_menu() {
$items['islandora/object/%/delete'] = array(
'title' => 'Purge object',
'page callback' => 'islandora_purge_object',
'page arguments' => array(2),
'type' => MENU_CALLBACK,
'access arguments' => array(FEDORA_PURGE),
);
@ -206,22 +207,58 @@ function islandora_node_access($op, $pid = NULL, $as_user = NULL) {
}
/**
*
* @param type $object_id
* Gives the option of deleting or purging and object.
*
* The default behaviour is to purge the object to reduce maintenance.
* If a solution pack wants to change this behaviour and have the object set to deleted then
* it can respond to the 'islandora_pre_purge_object' hook with an array containing the pair
* 'delete' => TRUE.
* Once the object has been deleted/purged then a second call lets the solution packs know that
* the object has been dealt with. In this call the object id and content models are sent out so
* that the solution packs can act on this news. There is no guarantee that the object still exists
* and so the object object isn't sent.
*
* @param string $object_id
* ID of the object
* @return type
*/
function islandora_purge_object($object_id) {
module_load_include('inc', 'islandora', 'RestConnection');
global $user;
if (!isset($object_id)) {
drupal_set_message(t('Cannot remove object, object id not set'));
return;
}
$object = new Object($object_id);
if (!isset($object)) {
try {
$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'));
return;
}
module_invoke_all('islandora_purge_object', $object); //notify modules of pending deletion
$object->delete();
$content_models = $fedora_object->models;
$arr = module_invoke_all('islandora_pre_purge_object', $fedora_object); //notify modules of pending deletion
if ($arr['delete']) {
try {
$fedora_object->delete();
} catch (Exception $e) {
drupal_set_message(t('Error deleting Islandora object %s', array('%s' => $object_id)), 'error');
return "";
}
}
else {
try {
$restConnection->repository->purgeObject($object_id);
} catch (Exception $e) {
drupal_set_message(t('Error purging Islandora object %s', array('%s' => $object_id)), 'error');
return "";
}
}
module_invoke_all('islandora_post_purge_object', $object_id, $content_models); //notify modules post deletion
}
/**

Loading…
Cancel
Save