From 5d5cd0024e7493ff8e39644d754a67e9a665d151 Mon Sep 17 00:00:00 2001 From: Ben Woodhead Date: Thu, 15 Sep 2011 16:03:48 -0300 Subject: [PATCH 1/2] added namespances --- ObjectHelper.inc | 2 +- SearchClass.inc | 4 ++-- api/fedora_item.inc | 2 +- fedora_repository.module | 2 +- formClass.inc | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ObjectHelper.inc b/ObjectHelper.inc index 4bf1c31d..e575fb7d 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -601,7 +601,7 @@ class ObjectHelper { if ($pid == NULL) { $pid = variable_get('fedora_repository_pid', 'islandora:top'); } - $nameSpaceAllowed = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: ')); + $nameSpaceAllowed = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); $pos = NULL; foreach ($nameSpaceAllowed as $nameSpace) { $pos = stripos($pid, $nameSpace); diff --git a/SearchClass.inc b/SearchClass.inc index 043a5e02..3f1c78d5 100644 --- a/SearchClass.inc +++ b/SearchClass.inc @@ -393,7 +393,7 @@ class SearchClass { $proc->setParameter('', 'searchToken', drupal_get_token('fedora_repository_advanced_search')); //token generated by Drupal, keeps tack of what tab etc we are on $proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl $proc->setParameter('', 'objectsPage', base_path()); - $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: ')); + $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); $proc->setParameter('', 'hitPageStart', $startPage); $proc->registerPHPFunctions(); $xsl = new DomDocument(); @@ -443,7 +443,7 @@ class SearchClass { $proc->setParameter('', 'userID', $user->uid); $proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl $proc->setParameter('', 'objectsPage', base_path()); - $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: ')); + $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); $proc->setParameter('', 'orderBy', $orderBy); $xsl = new DomDocument(); diff --git a/api/fedora_item.inc b/api/fedora_item.inc index 06f65698..836e5b53 100644 --- a/api/fedora_item.inc +++ b/api/fedora_item.inc @@ -652,7 +652,7 @@ class Fedora_Item { if (empty($pid_namespace)) { // Just get the first one in the config settings. - $allowed_namespaces = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: ')); + $allowed_namespaces = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); $pid_namespace = $allowed_namespaces[0]; if (!empty($pid_namespace)) { $pid_namespace = substr($pid_namespace, 0, strpos($pid_namespace, ":")); diff --git a/fedora_repository.module b/fedora_repository.module index 40d6fc74..4b6470c5 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -1194,7 +1194,7 @@ function fedora_repository_search_page($resultData) { $proc->setParameter('', 'searchToken', drupal_get_token('search_form')); //token generated by Drupal, keeps tack of what tab etc we are on $proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl $proc->setParameter('', 'objectsPage', base_path()); - $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: Islandora: ilives: ')); + $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); $proc->registerPHPFunctions(); $xsl = new DomDocument(); if ($isRestricted) { diff --git a/formClass.inc b/formClass.inc index 866e2e5f..c28a4a53 100644 --- a/formClass.inc +++ b/formClass.inc @@ -281,7 +281,7 @@ class formClass { $form['fedora_namespace']['fedora_pids_allowed'] = array( '#type' => 'textfield', '#title' => t('PID namespaces allowed in this Drupal install'), - '#default_value' => variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: '), + '#default_value' => variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: '), '#description' => t('A space separated list of PID namespaces that users are permitted to access from this Drupal installation.
This could be more than a simple namespace ie demo:mydemos.'), '#weight' => 0 ); @@ -290,7 +290,7 @@ class formClass { $form['fedora_pids_allowed'] = array( '#type' => 'textfield', '#title' => t('PID namespaces allowed in this Drupal install'), - '#default_value' => variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: '), + '#default_value' => variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: '), '#description' => t('A space separated list of PID namespaces that users are permitted to access from this Drupal installation.
This could be more than a simple namespace ie demo:mydemos.'), '#weight' => 0 ); From 4ec17434659e70e3a299a33b9d318b7454e4454e Mon Sep 17 00:00:00 2001 From: Ben Woodhead Date: Thu, 15 Sep 2011 17:27:58 -0300 Subject: [PATCH 2/2] Fixed child collection --- .CollectionClass.inc.swp | Bin 40960 -> 40960 bytes CollectionClass.inc | 11 +++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.CollectionClass.inc.swp b/.CollectionClass.inc.swp index 4672c0ca8df7d485e2e91c61f6282cda6530a653..123bc8be17bb1a4e9c734830c761c06d0e4902ad 100644 GIT binary patch delta 664 zcmY+=O=uHA6bJCPNn^WRlcp+uRK+m_l9ej0p;&DirRc$f7D^FH(Pi76;7XcJC%b}3 zNEM`>gmi?UqK2a2K@aI7c+5ehH$h6li`O2C2%aod^uH~NKKQ|#nfK-mGuH~uwL)yF z@5;qX?9_>qgoqP)hPeDG-bPD3M8a|0S~J-^KNwdg{YrfPNOTcZiO_cGr0nj?R4Xx} zF6aamI^b)RXa(MZ4@=O520VkO@CXE4g%Rk7<=TrOT>#QbkENFi8 z^h&781b01A9KuzIyd!3eGItFwgd@_aR4;SWiDb#Pm|bQ?$7LqFX%>Q|#fz?;x4B5@ zdeCj>S^DVKnSt_j(4*_OaS*(X{Ws>HDeB)b^4HJ>MVF)5H}Xqem5qAN-^@0YZoy|g STW~AIhI7mn9`_&S3g&M$j+wRq delta 567 zcma*jPfJu`6vy#1*KssQb0XJu8z=4rnK}jyGa-Uz7}mmWEh@M?cE>+7Nl<>gcA{2H{5$il|eBBBCg})r;tzh|Bi@B&M8>%E zz(x#J*eny7#BKaOBQlK+RAQ@?LaddD_?X9Q6ky^4O0W?U8H0%wc8VDQ1tbxI6gP+* z21RCZ3;XP53Qu6*WLGPi$T%J#g&*F_`bS+%T{^SpLa7VXLSx)1(hAh z#AEi;nnu-cy~t(bSFY;Du;{w&4m?*`tJ}#t@n~&V#&%p)>t=|mNAe`nIAx?CO|)yi ybA6%6zn|RHyjSURZ?XBj_deYcrrV%$`+EDj4eucR!D~;I`nxx00{&d1t&Rb0cz@Oa diff --git a/CollectionClass.inc b/CollectionClass.inc index 964cd457..f9d906e8 100644 --- a/CollectionClass.inc +++ b/CollectionClass.inc @@ -715,6 +715,7 @@ function collection_creation_form(&$form_state, $parent_collection_pid) { '#title' => "Choose allowable content models for this collection", '#type' => 'checkboxes', '#options' => $content_models, + '#required' => true, '#description' => t("Content models describe the behaviours of objects with which they are associated."), ); @@ -736,12 +737,17 @@ function collection_creation_form(&$form_state, $parent_collection_pid) { */ function collection_creation_form_validate($form, &$form_state) { module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); $pid = $form_state['values']['collection_pid']; $item = new fedora_item($pid); if ($item->exists()) { - drupal_set_message("$pid already exists within your repository. the PID must be unique", 'warning'); + form_set_error('', t("$pid already exists within your repository. the PID must be unique")); return; } + if (!valid_pid($pid)){ + form_set_error('', t("$pid is not a valid identifier")); + return; + } } /** @@ -759,6 +765,7 @@ function collection_creation_form_submit($form, &$form_state) { $collection_pid = $form_state['values']['collection_pid']; $new_collection_label = $form_state['values']['collection_name']; $parent_collection = $form_state['values']['parent_collection']; + $pid_namespace = $form_state['values']['collection_namespace']; $all_cModels = get_content_models_as_option_array(); $collection_policy = ' @@ -776,7 +783,7 @@ function collection_creation_form_submit($form, &$form_state) { $node = $collection_policy_xml->content_models->addChild('content_model'); $node->addAttribute('dsid', 'ISLANDORACM'); $node->addAttribute('name', $all_cModels[$content_model]); - $node->addAttribute('namespace', $pid_namespace . '1'); + $node->addAttribute('namespace', $pid_namespace . ':1'); $node->addAttribute('pid', $content_model); } }