From 9ca282d521e9c81af31e0dcced75c96b8f5ea4f0 Mon Sep 17 00:00:00 2001 From: Alan Stanley Date: Tue, 22 Nov 2011 12:01:49 -0400 Subject: [PATCH 1/2] Added validity check for Collection Policy class --- CollectionClass.inc | 9 +++++---- fedora_repository.module | 13 +++++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CollectionClass.inc b/CollectionClass.inc index 2af37522..bee0c495 100644 --- a/CollectionClass.inc +++ b/CollectionClass.inc @@ -519,14 +519,16 @@ class CollectionClass { $show_batch_tab = FALSE; $policy = CollectionPolicy::loadFromCollection($this->pid, TRUE); - $content_models = $policy->getContentModels(); + if ($policy) { + $content_models = $policy->getContentModels(); + } if (count($content_models) == 1 && $content_models[0]->pid == "islandora:collectionCModel") { $show_batch_tab = FALSE; } if (!$show_ingest_tab) { $view_selected = TRUE; } - if(!$collection_items){ + if (!$collection_items) { $view_selected = FALSE; $add_selected = TRUE; } @@ -538,7 +540,6 @@ class CollectionClass { '#title' => 'View', '#selected' => $view_selected, '#content' => $collection_items, - ); $tabset['add_tab'] = array( '#type' => 'tabpage', @@ -614,7 +615,7 @@ class CollectionClass { $collectionName = $collection; - + if (!$pageNumber) { $pageNumber = 1; } diff --git a/fedora_repository.module b/fedora_repository.module index 27060dda..600e3bcb 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -142,6 +142,10 @@ function fedora_repository_ingest_object($collection_pid=NULL, $collection_label */ function fedora_repository_ingest_form_submit(array $form, array &$form_state) { //only validate the form if the submit button was pressed (other buttons may be used for AHAH + if ($form_state['ahah_submission']) { + $form_state['submitted'] = false; + return; + } if ($form_state['storage']['xml']) { if (module_exists('islandora_content_model_forms')) { module_load_include('inc', 'islandora_content_model_forms', 'IngestObjectMetadataForm'); @@ -197,7 +201,11 @@ function fedora_repository_ingest_form_submit(array $form, array &$form_state) { */ function fedora_repository_ingest_form_validate($form, &$form_state) { //only validate the form if the submit button was pressed (other buttons may be used for AHAH - if ($form_state['clicked_button']['#id'] == 'edit-submit') { + if ($form_state['ahah_submission']) { + $form_state['submitted'] = false; + return; + } + if ($form_state['clicked_button']['#id'] == 'edit-submit' && $form_state['ahah_submission'] != 1) { switch ($form_state['storage']['step']) { case 1: $form_state['storage']['step']++; @@ -828,9 +836,6 @@ function fedora_repository_perm() { OBJECTHELPER::$INGEST_FEDORA_OBJECTS, OBJECTHELPER::$EDIT_TAGS_DATASTREAM, OBJECTHELPER::$VIEW_DETAILED_CONTENT_LIST, - OBJECTHELPER::$MANAGE_COLLECTIONS, - OBJECTHELPER::$DELETE_ENTIRE_COLLECTIONS, - OBJECTHELPER::$CREATE_BATCH_PROCESS, ); } From 33bc8c922e1527633692b0b223c7a7e4afbd19ab Mon Sep 17 00:00:00 2001 From: Alan Stanley Date: Thu, 24 Nov 2011 13:54:44 -0400 Subject: [PATCH 2/2] Added additional functionality to CollectionPolicy::getNextPid --- CollectionPolicy.inc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CollectionPolicy.inc b/CollectionPolicy.inc index be9e7a92..5a3daf21 100644 --- a/CollectionPolicy.inc +++ b/CollectionPolicy.inc @@ -360,13 +360,14 @@ class CollectionPolicy extends XMLDatastream { * @param string $dsid * @return string $nextPid */ - public function getNextPid($dsid) { + public function getNextPid($dsid, $content_model = null) { $ret = FALSE; + if (self::valid_dsid($dsid) && $this->validate()) { $content_models = $this->xml->getElementsByTagName('content_models')->item(0)->getElementsByTagName('content_model'); $namespace = FALSE; for ($i = 0; $namespace === FALSE && $i < $content_models->length; $i++) { - if (strtolower($content_models->item($i)->getAttribute('dsid')) == strtolower($dsid)) { + if (strtolower($content_models->item($i)->getAttribute('dsid')) == strtolower($dsid) && (strtolower($content_models->item($i)->getAttribute('pid') == $content_model) || $content_model == null)) { $namespace = $content_models->item($i)->getAttribute('namespace'); } }