diff --git a/ObjectHelper.inc b/ObjectHelper.inc index 80d354df..c22d39b9 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -60,20 +60,6 @@ class ObjectHelper { drupal_access_denied(); return ' '; } - - if (($cm = ContentModel::loadFromObject($pid)) == FALSE) { - drupal_set_message(t("You do not have access to objects without an Islandora Content Model."), 'error'); - drupal_access_denied(); - return ' '; - } - - $cmDatastreams = $cm->listDatastreams(); - - if ( !((isset($user) && in_array('administrator',$user->roles)) || in_array($dsID,$cmDatastreams))) { - drupal_set_message(t("You do not have access to the specified datastream."), 'error'); - drupal_access_denied(); - return ' '; - } module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $item = new Fedora_Item($pid); @@ -488,8 +474,9 @@ class ObjectHelper { $allow= fedora_fesl_check_roles($object_pid,'write'); } if ($allow) { - $purgeObject = '' . t('Purge Object') . '' . t('Purge Object') . ''; + //$purgeObject = '' . t('Purge Object') . '' . t('Purge Object') . ''; + $purgeObject = drupal_get_form('fedora_repository_purge_object_form', $object_pid, check_plain(request_uri())); } } else { $purgeObject = ' '; diff --git a/content_models/islandora_largeimages.xml b/content_models/islandora_largeimages.xml index 6a152ad4..a0bbfe9b 100644 --- a/content_models/islandora_largeimages.xml +++ b/content_models/islandora_largeimages.xml @@ -1,298 +1,358 @@ - - - - - - - - - - - - - - -ingest - -fedoraAdmin -2010-01-26T21:29:20.416Z -Created with Admin GUI "New Object" command - - - -addDatastream -COLLECTION_POLICY -fedoraAdmin -2010-01-26T21:30:55.607Z -DatastreamsPane generated this logMessage. - - - -addDatastream -RELS-EXT -fedoraAdmin -2010-01-26T21:33:14.125Z - - - - -modifyDatastreamByValue -COLLECTION_POLICY -fedoraAdmin -2010-03-04T12:50:05.983Z - - - - -modifyDatastreamByValue -COLLECTION_POLICY -fedoraAdmin -2010-03-11T21:01:44.921Z - - - - - - - - - - - Large Image Collection - islandora:largeimages - - - - - - - - - - - islandora:slide - islandora:slideCModel - ISLANDORACM - - - - isMemberOfCollection - - dc.description - - dc.title - dc.title - - - dc.creator - dc.creator - - - dc.description - dc.description - - - dc.date - dc.date - - - dc.identifier - dc.identifier - - - dc.language - dc.language - - - dc.publisher - dc.publisher - - - dc.rights - dc.rights - - - dc.subject - dc.subject - - - dc.relation - dc.relation - - - dcterms.temporal - dcterms.temporal - - - dcterms.spatial - dcterms.spatial - - - fgs.DS.first.text - Full Text - - - - - - - - - - - islandora:slide - islandora:slideCModel - ISLANDORACM - - - islandora:herb - islandora:herbCModel - ISLANDORACM - - - isMemberOfCollection - - dc.description - - dc.title - dc.title - - - dc.creator - dc.creator - - - dc.description - dc.description - - - dc.date - dc.date - - - dc.identifier - dc.identifier - - - dc.language - dc.language - - - dc.publisher - dc.publisher - - - dc.rights - dc.rights - - - dc.subject - dc.subject - - - dc.relation - dc.relation - - - dcterms.temporal - dcterms.temporal - - - dcterms.spatial - dcterms.spatial - - - fgs.DS.first.text - Full Text - - - - - - - - - - - islandora:slide - islandora:slideCModel - ISLANDORACM - - - isMemberOfCollection - - dc.description - - dc.title - dc.title - - - dc.creator - dc.creator - - - dc.description - dc.description - - - dc.date - dc.date - - - dc.identifier - dc.identifier - - - dc.language - dc.language - - - dc.publisher - dc.publisher - - - dc.rights - dc.rights - - - dc.subject - dc.subject - - - dc.relation - dc.relation - - - dcterms.temporal - dcterms.temporal - - - dcterms.spatial - dcterms.spatial - - - fgs.DS.first.text - Full Text - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + ingest + + fedoraAdmin + 2010-01-26T21:29:20.416Z + Created with Admin GUI "New Object" command + + + + addDatastream + COLLECTION_POLICY + fedoraAdmin + 2010-01-26T21:30:55.607Z + DatastreamsPane generated this logMessage. + + + + addDatastream + RELS-EXT + fedoraAdmin + 2010-01-26T21:33:14.125Z + + + + + modifyDatastreamByValue + COLLECTION_POLICY + fedoraAdmin + 2010-03-04T12:50:05.983Z + + + + + modifyDatastreamByValue + COLLECTION_POLICY + fedoraAdmin + 2010-03-11T21:01:44.921Z + + + + + ingest + + admin + 2010-12-10T17:29:47.073Z + Fedora Object Ingested + + + + addDatastream + TN + admin + 2010-12-10T17:29:47.200Z + Ingested object TN + + + + modifyDatastreamByValue + COLLECTION_POLICY + fedoraAdmin + 2010-12-10T17:32:17.345Z + + + + + + + + + + + Large Image Collection + islandora:largeimages + + + + + + + + + + + islandora:slide + islandora:slideCModel + ISLANDORACM + + + isMemberOfCollection + + dc.description + + dc.title + dc.title + + + dc.creator + dc.creator + + + dc.description + dc.description + + + dc.date + dc.date + + + dc.identifier + dc.identifier + + + dc.language + dc.language + + + dc.publisher + dc.publisher + + + dc.rights + dc.rights + + + dc.subject + dc.subject + + + dc.relation + dc.relation + + + dcterms.temporal + dcterms.temporal + + + dcterms.spatial + dcterms.spatial + + + fgs.DS.first.text + Full Text + + + + + + + + + + + islandora:slide + islandora:slideCModel + ISLANDORACM + + + islandora:herb + islandora:herbCModel + ISLANDORACM + + + isMemberOfCollection + + dc.description + + dc.title + dc.title + + + dc.creator + dc.creator + + + dc.description + dc.description + + + dc.date + dc.date + + + dc.identifier + dc.identifier + + + dc.language + dc.language + + + dc.publisher + dc.publisher + + + dc.rights + dc.rights + + + dc.subject + dc.subject + + + dc.relation + dc.relation + + + dcterms.temporal + dcterms.temporal + + + dcterms.spatial + dcterms.spatial + + + fgs.DS.first.text + Full Text + + + + + + + + + + + islandora:slide + islandora:slideCModel + ISLANDORACM + + + isMemberOfCollection + + dc.description + + dc.title + dc.title + + + dc.creator + dc.creator + + + dc.description + dc.description + + + dc.date + dc.date + + + dc.identifier + dc.identifier + + + dc.language + dc.language + + + dc.publisher + dc.publisher + + + dc.rights + dc.rights + + + dc.subject + dc.subject + + + dc.relation + dc.relation + + + dcterms.temporal + dcterms.temporal + + + dcterms.spatial + dcterms.spatial + + + fgs.DS.first.text + Full Text + + + + + + + + + + + + + dc.title + dc.creator + dc.description + dc.date + dc.identifier + dc.language + dc.publisher + dc.rights + dc.subject + dc.relation + dcterms.temporal + dcterms.spatial + Full Text + + isMemberOfCollection + + + + + + + + + + + + + + + + + + + + + + diff --git a/fedora_repository.module b/fedora_repository.module index f1035519..c4012e69 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -62,6 +62,7 @@ function fedora_repository_purge_object($pid = NULL, $name = NULL) { '%name' => $name, '%pid' => $pid) ); + $output .= drupal_get_form('fedora_repository_purge_object_form', $pid); return $output; } @@ -233,20 +234,40 @@ function fedora_repository_ingest_form(&$form_state, $collection_pid, $collectio 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( '#type' => 'hidden', '#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( - '#type' => 'submit', - '#value' => t('Purge') - ); - if ($collectionPid == NULL) { - $collectionPid = $_SESSION['fedora_collection']; + + $form['submit'] = array( + '#type' => 'image_button', + '#src' => drupal_get_path('module', 'fedora_repository').'/images/purge_big.png', + '#value' => t('Purge') + ); + if ($collectionPid == NULL) { + $collectionPid = $_SESSION['fedora_collection']; + } + //$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,'You Sure?', $base_url.$referrer, 'Description text','Yes, nuke it','Cancel'); //Had better luck leaving off last param 'name' } - // $form['#redirect'] = "fedora/repository/$collectionPid/"; return $form; } @@ -384,31 +405,40 @@ function fedora_repository_purge_object_form_submit($form, &$form_state) { module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); //$client = getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); $pid = $form_state['values']['pid']; - - $params = array( - "pid" => $pid, - "logMessage" => "Purged", - "force" => "" - ); - try { - $soapHelper = new ConnectionHelper(); - $client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); - $object = $client->__soapCall('purgeObject', array( - $params - ) + 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( + "pid" => $pid, + "logMessage" => "Purged", + "force" => "" ); - } catch (exception $e) { - if (preg_match('/org\.fcrepo\.server\.security\.xacml\.pep\.AuthzDeniedException/',$e->getMessage())) { - drupal_set_message(t('Error: Insufficient permissions to purge object.'), 'error'); - } else { - drupal_set_message(t($e->getMessage()), 'error'); + try { + $soapHelper = new ConnectionHelper(); + $client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); + $object = $client->__soapCall('purgeObject', array($params)); + unset($form_state['storage']['confirm']); + } catch (exception $e) { + if (preg_match('/org\.fcrepo\.server\.security\.xacml\.pep\.AuthzDeniedException/', $e->getMessage())) { + drupal_set_message(t('Error: Insufficient permissions to purge object.'), 'error'); + } else { + drupal_set_message(t($e->getMessage()), 'error'); + } + return; + } + if (empty($collectionPid)) { + $collectionPid = $_SESSION['fedora_collection']; + } + if (!empty($form_state['values']['referrer'])) { + $form_state['redirect'] = substr($form_state['values']['referrer'], 1); + } + else { + $form_state['redirect'] = "fedora/repository/$collectionPid/"; } - return; - } - if (empty($collectionPid)) { - $collectionPid = $_SESSION['fedora_collection']; } - $form_state['redirect'] = "fedora/repository/$collectionPid/"; } function fedora_repository_purge_stream_form(&$form_state, $pid, $dsId) { diff --git a/formClass.inc b/formClass.inc index 8505f402..6e0161fd 100644 --- a/formClass.inc +++ b/formClass.inc @@ -78,7 +78,7 @@ class formClass { // 'access' => TRUE ); $items['fedora/repository'] = array( -// 'title' => t('Digital repository'), + 'title' => t('Digital repository'), 'page callback' => 'repository_page', 'type' => MENU_NORMAL_ITEM, // 'page arguments'=>array(1), diff --git a/plugins/pidfield/pidfield.module b/plugins/pidfield/pidfield.module index 53e176a2..d9c475fc 100644 --- a/plugins/pidfield/pidfield.module +++ b/plugins/pidfield/pidfield.module @@ -281,7 +281,7 @@ function theme_pidfield_formatter_default($element) { $item = new Fedora_Item($pid); return fedora_repository_get_items($pid); - //return $item->objectProfile->objLabel; + } return null; } diff --git a/workflow_client/plugins/exif.inc b/workflow_client/plugins/exif.inc new file mode 100644 index 00000000..5a1ba414 --- /dev/null +++ b/workflow_client/plugins/exif.inc @@ -0,0 +1,72 @@ + 0) { + $this->setMessage(t('Missing parameter(s) "%params" for exif process on "%pid"', array('%params' => join(',', $missing_params), '%pid' => $pid))); + return FALSE; + } + + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + + $item = new fedora_item($pid); + $dslist = $item->get_datastreams_list_as_array(); + if (!isset($dslist[$parameters['dsid']])) { + $this->setMessage(t('Datastream "%dsid" could not be found for exif process on "%pid"', array('%dsid' => $parameters['dsid'], '%pid' => $pid))); + return FALSE; + } + + $ds = $dslist[$parameters['dsid']]; + $file = '/tmp/'. $ds['label']; + $dest_ds = isset($parameters['dest_ds']) ? $parameters['dest_ds'] : 'EXIF'; + + $objectHelper = new ObjectHelper(); + $objectHelper->makeObject($pid, $parameters['dsid'], FALSE, NULL, $file); + + if (!file_exists($file)) { + $this->setMessage('couldnt get datastream '. $parameters['dsid'] .' as '. $file); + return FALSE; + } + + $system = getenv('System'); + $returnValue=TRUE; + $output=array(); + + $command = '/usr/local/exif/exiftool -X '. $file; + exec($command, $output, $returnValue); + + if (!file_exists($file . $file_suffix)) { + $this->setMessage('command failed: '. htmlentities($command ."\n" . join("\n", $output) ."\n return value: $returnValue")); + @unlink($file); + return FALSE; + } + + if ($returnValue == '0') { + if (isset($dslist[$dest_ds])) { + $item->purge_datastream($dest_ds); + } + + $ret = $item->add_datastream_from_string(join("\n",$output), $dest_ds, $ds['label'] . $file_suffix, 'text/xml', 'X','Added by workflow process EXIF.'); + @unlink($file); + @unlink($file . $file_suffix); + + if (!$ret) { + $this->setMessage(t('Unable to add datastream "%dsid" to "%pid".', array('%dsid' => $dest_ds, '%pid' => $pid))); + return FALSE; + } + + return TRUE; + + } + } +}