From b0942ee4d874ac037249f6c4ffc11607593a0dd3 Mon Sep 17 00:00:00 2001 From: William Panting Date: Wed, 10 Oct 2012 15:18:53 -0300 Subject: [PATCH] adding in the can_ingest hook --- fedora_repository.api.php | 16 ++++++++++++++++ formClass.inc | 8 ++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/fedora_repository.api.php b/fedora_repository.api.php index 19f62e05..af310b28 100644 --- a/fedora_repository.api.php +++ b/fedora_repository.api.php @@ -89,3 +89,19 @@ function hook_required_fedora_objects() { ), ); } + +/** + * Override ingest permissions. + * (from islandora_workflow) + * + * @param string $collection_pid + * The PID of the collection + * @return boolean + * TRUE if the user can ingest into the specified collection, FALSE otherwise. + */ +function islandora_can_ingest($collection_pid) { + + module_load_include('inc', 'islandora_workflow', 'islandora_workflow.permissions'); + return (islandora_workflow_user_collection_permission_check($collection_pid) !== FALSE); + +} diff --git a/formClass.inc b/formClass.inc index 908f3bc3..fc6dab8e 100644 --- a/formClass.inc +++ b/formClass.inc @@ -501,8 +501,12 @@ class formClass { */ function canShowIngestForm($collection_pid) { if (!user_access('ingest new fedora objects')) { - drupal_set_message(t('You do not have permission to ingest.'), 'error'); - return FALSE; + $ingest_override_array = module_invoke_all('can_ingest', $collection_pid); + $overrides = array_filter($ingest_override_array); + if (empty($overrides)) { + drupal_set_message(t('You do not have permission to ingest.'), 'error'); + return FALSE; + } } module_load_include('inc', 'fedora_repository', 'SecurityClass'); $security_class = new SecurityClass();