From d06288a2927db5afc0bb872d85badf28d138fbdb Mon Sep 17 00:00:00 2001 From: rwincewicz Date: Fri, 1 Jun 2012 13:35:42 -0300 Subject: [PATCH 1/2] Fixed error when deleting emtpy collections. PID is now displayed properly --- islandora_basic_collection/includes/delete_collection.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/islandora_basic_collection/includes/delete_collection.inc b/islandora_basic_collection/includes/delete_collection.inc index 6e4a4bb8..f7f26a03 100644 --- a/islandora_basic_collection/includes/delete_collection.inc +++ b/islandora_basic_collection/includes/delete_collection.inc @@ -21,7 +21,7 @@ function islandora_collection_deletion_form($form, &$form_state, $object) { $submit_text_message = ($table) ? "Delete selected objects" : "Delete collection"; $form = array(); - + $form['collection_delete']['titlebox'] = array( '#type' => 'item', '#title' => t("Delete objects from @collection_pid", array('@collection_pid' => $pid)), @@ -113,7 +113,7 @@ function islandora_collection_deletion_form_submit($form, &$form_state) { * @param string $pid */ function delete_root_collection($object) { - + $pid = $object->id; try { $object->repository->purgeObject($object->id); } catch (RepositoryException $e) { From b71b7a2d925fc798bbdd241239b5a5a5b1e2228e Mon Sep 17 00:00:00 2001 From: rwincewicz Date: Fri, 1 Jun 2012 13:46:24 -0300 Subject: [PATCH 2/2] Added meaningful message to manage collection policy when no content models exist --- .../includes/manage_policies.inc | 64 +++++++++++-------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/islandora_basic_collection/includes/manage_policies.inc b/islandora_basic_collection/includes/manage_policies.inc index 1fa3e68f..c5742303 100644 --- a/islandora_basic_collection/includes/manage_policies.inc +++ b/islandora_basic_collection/includes/manage_policies.inc @@ -27,8 +27,9 @@ function islandora_manage_policies_form($form, &$form_state, $collection_object) $item = $repository->getObject($content_model); $cm_name = $item->Label; $cm_options[$content_model] = $cm_name; + } catch (RepositoryException $e) { + } - catch(RepositoryException $e) {} } } @@ -71,36 +72,43 @@ function islandora_manage_policies_form($form, &$form_state, $collection_object) '#title' => t("Manage collection policy for @collection_title", array('@collection_title' => $collection_object->label)), ); - $form ['manage_collection_policy']['add']['content_model_to_add'] = array( - '#title' => "Choose content model", - '#type' => 'select', - '#options' => $new_options, - '#description' => t("Choose content model to add to this collection policy."), - ); + if (count($new_content_models) > 0) { + $form ['manage_collection_policy']['add']['content_model_to_add'] = array( + '#title' => "Choose content model", + '#type' => 'select', + '#options' => $new_options, + '#description' => t("Choose content model to add to this collection policy."), + ); - $form ['manage_collection_policy']['add']['new_cp_namespace'] = array( - '#title' => "Choose namespace", - '#type' => 'textfield', - '#size' => 15, - '#default_value' => $namespace, - '#description' => t("Choose namespace for objects in this collection associated with this content model"), - ); + $form['manage_collection_policy']['add']['new_cp_namespace'] = array( + '#title' => "Choose namespace", + '#type' => 'textfield', + '#size' => 15, + '#default_value' => $namespace, + '#description' => t("Choose namespace for objects in this collection associated with this content model"), + ); - $form['parent_collection'] = array( - '#type' => 'hidden', - '#value' => $collection_object->id, - ); + $form['parent_collection'] = array( + '#type' => 'hidden', + '#value' => $collection_object->id, + ); - $form['collection_pid'] = array( - '#type' => 'hidden', - '#value' => $collection_object->id, - ); + $form['collection_pid'] = array( + '#type' => 'hidden', + '#value' => $collection_object->id, + ); - $form['manage_collection_policy']['add']['submit'] = array( - '#type' => 'submit', - '#value' => t('Add content model to collection policy'), - '#id' => 'add_cm' - ); + $form['manage_collection_policy']['add']['submit'] = array( + '#type' => 'submit', + '#value' => t('Add content model to collection policy'), + '#id' => 'add_cm' + ); + } + else { + $form['manage_collection_policy']['no_content_models'] = array( + '#markup' => t('No content models available to add!'), + ); + } if (count($current_models_in_policy) > 0) { $form['manage_collection_policy']['remove'] = array( @@ -140,7 +148,7 @@ function islandora_manage_policies_form_submit($form, &$form_state) { module_load_include('module', 'islandora', 'islandora'); $collection_pid = $form_state['values']['parent_collection']; $collection_object = islandora_object_load($collection_pid); - + $policy = $collection_object->getDatastream(variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY')); $collection_policy = '