From cc6f5a956af54500e7e5cffd646eb10d076a70dd Mon Sep 17 00:00:00 2001 From: rwincewicz Date: Thu, 31 May 2012 11:29:20 -0300 Subject: [PATCH] Fixed collection policy for create child collection function --- islandora.module | 33 +++++++++++++++++-- .../includes/ChildCollection.inc | 3 +- .../includes/MoveCollection.inc | 6 +++- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/islandora.module b/islandora.module index 50cb36ba..035bae28 100644 --- a/islandora.module +++ b/islandora.module @@ -191,8 +191,8 @@ function islandora_menu() { $items['islandora/object/%/datastream/%/delete'] = array( 'title' => 'Purge data stream', - 'page callback' => 'islandora_purge_datastream', - 'page arguments' => array(2, 4), + 'page callback' => 'drupal_get_form', + 'page arguments' => array('islandora_purge_datastream', 2, 4), 'type' => MENU_CALLBACK, 'access arguments' => array(FEDORA_PURGE), ); @@ -412,6 +412,31 @@ function islandora_islandora_edit_object($fedora_object) { return array('Default Edit output' => $output); } + +function islandora_purge_datastream($form, &$form_state, $object_id, $datastream_id) { + module_load_include('inc', 'islandora', 'RestConnection'); + module_load_include('inc', 'islandora', 'includes/datastream'); + + $connection = new RestConnection(); + $object = $connection->repository->getObject($object_id); + $datastream = $object->getDatastream($datastream_id); + + $redirect = "islandora/object/$object_id"; + + // Always provide entity id in the same form key as in the entity edit form. + $form['pid'] = array('#type' => 'value', '#value' => $object_id); + $form['dsid'] = array('#type' => 'value', '#value' => $datastream_id); + $form['col'] = array('#type' => 'value', '#value' => $redirect); + + return confirm_form($form, + t('Are you sure you want to delete the %dsid datastream?', array('%dsid' => $datastream->id)), + "islandora/object/$object_id", + t('This action cannot be undone.'), + t('Delete'), + t('Cancel') + ); +} + /** * Gives the option of purging or deleting a datastream. * @@ -427,8 +452,10 @@ function islandora_islandora_edit_object($fedora_object) { * ID of the datastream * */ -function islandora_purge_datastream($object_id, $datastream_id) { +function islandora_purge_datastream_submit($form, &$form_state) { module_load_include('inc', 'islandora', 'RestConnection'); + $object_id = $form_state['values']['pid']; + $datastream_id = $form_state['values']['dsid']; global $user; if (!isset($datastream_id)) { drupal_set_message(t('Cannot remove datastream, datastream id not set')); diff --git a/islandora_basic_collection/includes/ChildCollection.inc b/islandora_basic_collection/includes/ChildCollection.inc index 757fb491..278d0dc0 100644 --- a/islandora_basic_collection/includes/ChildCollection.inc +++ b/islandora_basic_collection/includes/ChildCollection.inc @@ -134,7 +134,6 @@ function islandora_create_child_collection_form_submit($form, &$form_state) { $content_models_element->item(0)->appendChild($content_model_element); } } - drupal_set_message($collection_policy_xml->saveXML()); $fedora_object = islandora_ingest_get_object($collection_content_models, $form_state['values']['current'], $relationship, $new_collection_pid); $fedora_object->label = $new_collection_label; $thumbnail_datastream = $fedora_object->constructDatastream('TN'); @@ -142,7 +141,7 @@ function islandora_create_child_collection_form_submit($form, &$form_state) { $thumbnail_datastream->label = 'Thumbnail'; $thumbnail_datastream->mimetype = 'image/png'; $fedora_object->ingestDatastream($thumbnail_datastream); - $policy_datastream = $fedora_object->constructDatastream(variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY'), 'M'); + $policy_datastream = $fedora_object->constructDatastream(variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY'), 'X'); $policy_datastream->setContentFromString($collection_policy_xml->saveXML()); $policy_datastream->label = 'Collection policy'; $fedora_object->ingestDatastream($policy_datastream); diff --git a/islandora_basic_collection/includes/MoveCollection.inc b/islandora_basic_collection/includes/MoveCollection.inc index 26ff05d1..868b9892 100644 --- a/islandora_basic_collection/includes/MoveCollection.inc +++ b/islandora_basic_collection/includes/MoveCollection.inc @@ -17,7 +17,11 @@ function islandora_collection_migrate_form($form, &$form_state, $pid) { $potential_collections = get_collections_as_option_array(); $table = islandora_collection_table($pid); if (!$table) { - return; + $form['no_objects'] = array( + '#type' => 'item', + '#title' => t('No objects found in this collection'), + ); + return $form; } $form = array();