Browse Source

Merge branch 'ISLANDORA-117'

pull/105/head
Alexander O'Neill 14 years ago
parent
commit
92c0e565b9
  1. 7
      ObjectHelper.inc
  2. 51
      fedora_repository.module
  3. 2
      plugins/pidfield/pidfield.module

7
ObjectHelper.inc

@ -498,8 +498,9 @@ class ObjectHelper {
$allow= fedora_fesl_check_roles($object_pid,'write'); $allow= fedora_fesl_check_roles($object_pid,'write');
} }
if ($allow) { if ($allow) {
$purgeObject = '<a title="' . t('Purge Object ') . $object_pid . '" href="' . base_path() . 'fedora/repository/purgeObject/' . //$purgeObject = '<a title="' . t('Purge Object ') . $object_pid . '" href="' . base_path() . 'fedora/repository/purgeObject/' .
$object_pid . '"><img src="' . $base_url . '/' . $path . '/images/purge_big.png" alt="' . t('Purge Object') . '" class="icon">' . t('Purge Object') . '</a>'; //$object_pid . '"><img src="' . $base_url . '/' . $path . '/images/purge_big.png" alt="' . t('Purge Object') . '" class="icon">' . t('Purge Object') . '</a>';
$purgeObject = drupal_get_form('fedora_repository_purge_object_form', $object_pid, check_plain(substr(request_uri(), strlen(base_path()))));
} }
} else { } else {
$purgeObject = '&nbsp;'; $purgeObject = '&nbsp;';
@ -731,7 +732,7 @@ class ObjectHelper {
// $ingestObject = '<a title="'. t('Ingest a New object into ') . $collectionName . ' '. $collection_pid . '" href="'. base_path() . // $ingestObject = '<a title="'. t('Ingest a New object into ') . $collectionName . ' '. $collection_pid . '" href="'. base_path() .
$ingestObject = '<a title="' . t('Ingest a New object into !collection_name PID !collection_pid', array('!collection_name' => $collectionName, '!collection_pid' => $collection_pid)) . '" href="' . base_path() . $ingestObject = '<a title="' . t('Ingest a New object into !collection_name PID !collection_pid', array('!collection_name' => $collectionName, '!collection_pid' => $collection_pid)) . '" href="' . base_path() .
'fedora/ingestObject/' . $collection_pid . '/' . $collectionName . '"><img src="' . $base_url . '/' . $path . 'fedora/ingestObject/' . $collection_pid . '/' . $collectionName . '"><img src="' . $base_url . '/' . $path .
'/images/ingest.png" alt="' . t('Add a New Object') . '" class="icon">' . t('Add to this Collection') . '</a>'; '/images/ingest.png" alt="' . t('Add a New Object') . '" class="icon"></a>' . t(' Add to this Collection');
} }
} }
} }

51
fedora_repository.module

@ -62,6 +62,7 @@ function fedora_repository_purge_object($pid = NULL, $name = NULL) {
'%name' => $name, '%name' => $name,
'%pid' => $pid) '%pid' => $pid)
); );
$output .= drupal_get_form('fedora_repository_purge_object_form', $pid); $output .= drupal_get_form('fedora_repository_purge_object_form', $pid);
return $output; return $output;
} }
@ -233,20 +234,41 @@ function fedora_repository_ingest_form(&$form_state, $collection_pid, $collectio
return $ingestForm->createIngestForm($collection_pid, $collection_label, $form_state); return $ingestForm->createIngestForm($collection_pid, $collection_label, $form_state);
} }
function fedora_repository_purge_object_form(&$form_state, $pid, $collectionPid = NULL) { function fedora_repository_purge_object_form(&$form_state, $pid, $referrer) {
global $base_url;
// $form['#redirect'] = "fedora/repository/$collectionPid/";
$form['pid'] = array( $form['pid'] = array(
'#type' => 'hidden', '#type' => 'hidden',
'#value' => "$pid" '#value' => "$pid"
); );
if (!strstr( drupal_get_destination(), urlencode('fedora/repository'))) {
$form['referrer'] = array(
'#type' => 'hidden',
'#value' => $referrer,
);
}
if(!isset($form_state['storage']['confirm'])) {
// do your normal $form definition here
$form['submit'] = array( $form['submit'] = array(
'#type' => 'submit', '#type' => 'image_button',
'#value' => t('Purge') '#src' => drupal_get_path('module', 'fedora_repository').'/images/purge_big.png',
'#value' => t('Purge'),
'#suffix' => 'Purge this object',
); );
if ($collectionPid == NULL) { if ($collectionPid == NULL) {
$collectionPid = $_SESSION['fedora_collection']; $collectionPid = $_SESSION['fedora_collection'];
} }
// $form['#redirect'] = "fedora/repository/$collectionPid/"; //$form['#redirect'] = $referrer;
return $form;
}
else {
// ALSO do $form definition here. Your final submit handler (after user clicks Yes, I Confirm) will only see $form_state info defined here. Form you create here passed as param1 to confirm_form
return confirm_form($form, 'Confirm Purge Object', $referrer, 'Are you sure you want to delete this object? This action cannot be undone.', 'Delete', 'Cancel'); //Had better luck leaving off last param 'name'
}
return $form; return $form;
} }
@ -384,7 +406,12 @@ function fedora_repository_purge_object_form_submit($form, &$form_state) {
module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
//$client = getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); //$client = getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
$pid = $form_state['values']['pid']; $pid = $form_state['values']['pid'];
if (!isset($form_state['storage']['confirm'])) {
$form_state['storage']['confirm'] = TRUE; // this will cause the form to be rebuilt, entering the confirm part of the form
$form_state['rebuild'] = TRUE; // along with this
}
else {
// this is where you do your processing after they have pressed the confirm button
$params = array( $params = array(
"pid" => $pid, "pid" => $pid,
"logMessage" => "Purged", "logMessage" => "Purged",
@ -393,12 +420,10 @@ function fedora_repository_purge_object_form_submit($form, &$form_state) {
try { try {
$soapHelper = new ConnectionHelper(); $soapHelper = new ConnectionHelper();
$client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); $client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
$object = $client->__soapCall('purgeObject', array( $object = $client->__soapCall('purgeObject', array($params));
$params unset($form_state['storage']['confirm']);
)
);
} catch (exception $e) { } catch (exception $e) {
if (preg_match('/org\.fcrepo\.server\.security\.xacml\.pep\.AuthzDeniedException/',$e->getMessage())) { if (preg_match('/org\.fcrepo\.server\.security\.xacml\.pep\.AuthzDeniedException/', $e->getMessage())) {
drupal_set_message(t('Error: Insufficient permissions to purge object.'), 'error'); drupal_set_message(t('Error: Insufficient permissions to purge object.'), 'error');
} else { } else {
drupal_set_message(t($e->getMessage()), 'error'); drupal_set_message(t($e->getMessage()), 'error');
@ -408,7 +433,13 @@ function fedora_repository_purge_object_form_submit($form, &$form_state) {
if (empty($collectionPid)) { if (empty($collectionPid)) {
$collectionPid = $_SESSION['fedora_collection']; $collectionPid = $_SESSION['fedora_collection'];
} }
if (!empty($form_state['values']['referrer'])) {
$form_state['redirect'] = $form_state['values']['referrer'];
}
else {
$form_state['redirect'] = "fedora/repository/$collectionPid/"; $form_state['redirect'] = "fedora/repository/$collectionPid/";
}
}
} }
function fedora_repository_purge_stream_form(&$form_state, $pid, $dsId) { function fedora_repository_purge_stream_form(&$form_state, $pid, $dsId) {

2
plugins/pidfield/pidfield.module

@ -281,7 +281,7 @@ function theme_pidfield_formatter_default($element) {
$item = new Fedora_Item($pid); $item = new Fedora_Item($pid);
return fedora_repository_get_items($pid); return fedora_repository_get_items($pid);
//return $item->objectProfile->objLabel;
} }
return null; return null;
} }

Loading…
Cancel
Save