From efd7cc73c20c9e5011936e71bdfd312e20421997 Mon Sep 17 00:00:00 2001 From: nruest Date: Fri, 5 Sep 2014 12:13:22 -0400 Subject: [PATCH 1/7] ISLANDORA-1042 -- DESTROY ALL DEPRECATED CODE! --- includes/ingest.form.inc | 27 ----------------------- includes/utilities.inc | 47 ---------------------------------------- islandora.module | 28 ------------------------ 3 files changed, 102 deletions(-) diff --git a/includes/ingest.form.inc b/includes/ingest.form.inc index b5a4740d..6af93d63 100644 --- a/includes/ingest.form.inc +++ b/includes/ingest.form.inc @@ -136,33 +136,6 @@ function islandora_ingest_form_get_last_step_id(array &$form_state) { return array_pop($keys); } -/** - * Prepares a new object based on the given configuration. - * - * @param array $configuration - * The list of key/value pairs of configuration. - * - * @return NewFedoraObject - * The new object. - */ -function islandora_ingest_form_prepare_new_object(array $configuration) { - module_load_include('inc', 'islandora', 'includes/utilities'); - if (empty($configuration['object'])) { - $message = islandora_deprecated('7.x-1.2', t('Please use "objects" as the default ingest form configuration property.')); - trigger_error(filter_xss($message), E_USER_DEPRECATED); - // ID is more specific than namespace so it will take precedence. - $id = isset($configuration['namespace']) ? $configuration['namespace'] : 'islandora'; - $id = isset($configuration['id']) ? $configuration['id'] : $id; - $label = isset($configuration['label']) ? $configuration['label'] : 'New Object'; - $relationship_map = function($o) { - return array('relationship' => 'isMemberOfCollection', 'pid' => $o); - }; - $relationships = empty($configuration['collections']) ? array() : array_map($relationship_map, $configuration['collections']); - return islandora_prepare_new_object($id, $label, array(), array(), $relationships); - } - return $configuration['object']; -} - /** * Gets the given/current step. * diff --git a/includes/utilities.inc b/includes/utilities.inc index 26633df5..38b229d1 100644 --- a/includes/utilities.inc +++ b/includes/utilities.inc @@ -649,53 +649,6 @@ function islandora_system_settings_form_default_value($name, $default_value, arr return isset($form_state['values'][$name]) ? $form_state['values'][$name] : variable_get($name, $default_value); } -/** - * Checks that the given/current account has all the given permissions. - * - * @param array $perms - * The permissions to check. - * @param mixed $account - * (optional) The account to check, if not given use currently logged in user. - * - * @return bool - * TRUE if the account has all the given permissions, FALSE otherwise. - */ -function islandora_user_access_all(array $perms, $account = NULL) { - $message = islandora_deprecated('7.x-1.2', 'Roll your own code or use islandora_user_access().'); - trigger_error(filter_xss($message), E_USER_DEPRECATED); - - foreach ($perms as $perm) { - if (!user_access($perm, $account)) { - return FALSE; - } - } - return TRUE; -} - -/** - * Checks that the given/current account has at one of the given permissions. - * - * @param array $perms - * The permissions to check. - * @param mixed $account - * (optional) The account to check, if not given use currently logged in user. - * - * @return bool - * TRUE if the account has at least one of the given permissions, FALSE - * otherwise. - */ -function islandora_user_access_any(array $perms, $account = NULL) { - $message = islandora_deprecated('7.x-1.2', 'Roll your own code or use islandora_user_access().'); - trigger_error(filter_xss($message), E_USER_DEPRECATED); - - foreach ($perms as $perm) { - if (user_access($perm, $account)) { - return TRUE; - } - } - return FALSE; -} - /** * Gets the list of allowed namespaces as defined by 'islandora_pids_allowed'. * diff --git a/islandora.module b/islandora.module index f0bf796b..06039a5a 100644 --- a/islandora.module +++ b/islandora.module @@ -815,34 +815,6 @@ function islandora_object_access_callback($perm, $object = NULL) { return islandora_object_access($perm, $object); } -/** - * Checks whether the user can access the given object and datastream. - * - * Checks for object existance, accessiblitly, namespace permissions, - * and user permissions - * - * @param string $perm - * The user permission to test for. - * @param AbstractObject $object - * The object to test, if NULL given the object doesn't exist or is - * inaccessible. - * @param AbstractDatastream $datastream - * The datastream to test, if NULL given the datastream doesn't exist - * or is inaccessible. - * @param StdObject $account - * The account to test permissions as or NULL for current user. - * - * @return bool - * TRUE if the user is allowed to access this object, FALSE otherwise. - */ -function islandora_object_datastream_access_callback($perm, $object = NULL, $datastream = NULL, $account = NULL) { - module_load_include('inc', 'islandora', 'includes/utilities'); - $message = islandora_deprecated('7.x-1.2', 'Use islandora_datastream_access().'); - trigger_error(filter_xss($message), E_USER_DEPRECATED); - - return islandora_datastream_access($perm, $datastream, $account); -} - /** * Checks whether the user can access the given object and datastream. * From 690fb4c70ebd61360d8e95188a71d65487248738 Mon Sep 17 00:00:00 2001 From: nruest Date: Mon, 15 Sep 2014 08:17:50 -0400 Subject: [PATCH 2/7] Put function islandora_ingest_form_prepare_new_object back in. --- includes/ingest.form.inc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/includes/ingest.form.inc b/includes/ingest.form.inc index 6af93d63..1187c55b 100644 --- a/includes/ingest.form.inc +++ b/includes/ingest.form.inc @@ -136,6 +136,33 @@ function islandora_ingest_form_get_last_step_id(array &$form_state) { return array_pop($keys); } +/** + * Prepares a new object based on the given configuration. + * + * @param array $configuration + * The list of key/value pairs of configuration. + * + * @return NewFedoraObject + * The new object. + */ +function islandora_ingest_form_prepare_new_object(array $configuration) { + module_load_include('inc', 'islandora', 'includes/utilities'); + if (empty($configuration['object'])) { + $message = islandora_deprecated('7.x-1.2', t('Please use "objects" as the default ingest form configuration property.')); + trigger_error(filter_xss($message), E_USER_DEPRECATED); + // ID is more specific than namespace so it will take precedence. + $id = isset($configuration['namespace']) ? $configuration['namespace'] : 'islandora'; + $id = isset($configuration['id']) ? $configuration['id'] : $id; + $label = isset($configuration['label']) ? $configuration['label'] : 'New Object'; + $relationship_map = function($o) { + return array('relationship' => 'isMemberOfCollection', 'pid' => $o); + }; + $relationships = empty($configuration['collections']) ? array() : array_map($relationship_map, $configuration['collections']); + return islandora_prepare_new_object($id, $label, array(), array(), $relationships); + } + return $configuration['object']; +} + /** * Gets the given/current step. * From 83f24859add77656fb9764c31a176c223df999fe Mon Sep 17 00:00:00 2001 From: nruest Date: Mon, 15 Sep 2014 11:50:16 -0400 Subject: [PATCH 3/7] Re-remove islandora_ingest_form_prepare_new_object && call to it in function islandora_ingest_form. --- includes/ingest.form.inc | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/includes/ingest.form.inc b/includes/ingest.form.inc index 1187c55b..a95e1b25 100644 --- a/includes/ingest.form.inc +++ b/includes/ingest.form.inc @@ -81,9 +81,6 @@ function islandora_ingest_form(array $form, array &$form_state, array $configura function islandora_ingest_form_init_form_state_storage(array &$form_state, array $configuration) { if (empty($form_state['islandora'])) { $objects = isset($configuration['objects']) ? $configuration['objects'] : array(); - if (empty($objects)) { - $objects[] = islandora_ingest_form_prepare_new_object($configuration); - } $configuration['models'] = isset($configuration['models']) ? $configuration['models'] : array(); // Make sure the models actually exist. foreach ($configuration['models'] as $key => $model) { @@ -136,33 +133,6 @@ function islandora_ingest_form_get_last_step_id(array &$form_state) { return array_pop($keys); } -/** - * Prepares a new object based on the given configuration. - * - * @param array $configuration - * The list of key/value pairs of configuration. - * - * @return NewFedoraObject - * The new object. - */ -function islandora_ingest_form_prepare_new_object(array $configuration) { - module_load_include('inc', 'islandora', 'includes/utilities'); - if (empty($configuration['object'])) { - $message = islandora_deprecated('7.x-1.2', t('Please use "objects" as the default ingest form configuration property.')); - trigger_error(filter_xss($message), E_USER_DEPRECATED); - // ID is more specific than namespace so it will take precedence. - $id = isset($configuration['namespace']) ? $configuration['namespace'] : 'islandora'; - $id = isset($configuration['id']) ? $configuration['id'] : $id; - $label = isset($configuration['label']) ? $configuration['label'] : 'New Object'; - $relationship_map = function($o) { - return array('relationship' => 'isMemberOfCollection', 'pid' => $o); - }; - $relationships = empty($configuration['collections']) ? array() : array_map($relationship_map, $configuration['collections']); - return islandora_prepare_new_object($id, $label, array(), array(), $relationships); - } - return $configuration['object']; -} - /** * Gets the given/current step. * From 9a2ac4c7a1009db88f4ce8cfa56445b2c3e6f3a5 Mon Sep 17 00:00:00 2001 From: nruest Date: Mon, 15 Sep 2014 12:36:06 -0400 Subject: [PATCH 4/7] Remove ternary. --- includes/ingest.form.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/ingest.form.inc b/includes/ingest.form.inc index a95e1b25..9525e410 100644 --- a/includes/ingest.form.inc +++ b/includes/ingest.form.inc @@ -80,7 +80,7 @@ function islandora_ingest_form(array $form, array &$form_state, array $configura */ function islandora_ingest_form_init_form_state_storage(array &$form_state, array $configuration) { if (empty($form_state['islandora'])) { - $objects = isset($configuration['objects']) ? $configuration['objects'] : array(); + $objects = isset($configuration['objects']) : array(); $configuration['models'] = isset($configuration['models']) ? $configuration['models'] : array(); // Make sure the models actually exist. foreach ($configuration['models'] as $key => $model) { From ae64d3e26040c8550f5db4b78ec415ebf9b69435 Mon Sep 17 00:00:00 2001 From: nruest Date: Tue, 27 Jan 2015 10:24:18 -0500 Subject: [PATCH 5/7] Actually remove the ternary. --- includes/ingest.form.inc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/includes/ingest.form.inc b/includes/ingest.form.inc index 7f355148..530c05c9 100644 --- a/includes/ingest.form.inc +++ b/includes/ingest.form.inc @@ -80,7 +80,10 @@ function islandora_ingest_form(array $form, array &$form_state, array $configura */ function islandora_ingest_form_init_form_state_storage(array &$form_state, array $configuration) { if (empty($form_state['islandora'])) { - $objects = isset($configuration['objects']) : array(); + $objects = isset($configuration['objects']); + if (empty($objects)) { + $objects[] = islandora_ingest_form_prepare_new_object($configuration); + } $configuration['models'] = isset($configuration['models']) ? $configuration['models'] : array(); // Make sure the models actually exist. foreach ($configuration['models'] as $key => $model) { From 8618f8e7cd80d5e9735032a237fc27ae1bbbbf2d Mon Sep 17 00:00:00 2001 From: nruest Date: Tue, 27 Jan 2015 10:53:49 -0500 Subject: [PATCH 6/7] Looks like ternary needs to be there, or it blows up solution pack collection ingest downstream. --- includes/ingest.form.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/ingest.form.inc b/includes/ingest.form.inc index 530c05c9..8cda9160 100644 --- a/includes/ingest.form.inc +++ b/includes/ingest.form.inc @@ -80,7 +80,7 @@ function islandora_ingest_form(array $form, array &$form_state, array $configura */ function islandora_ingest_form_init_form_state_storage(array &$form_state, array $configuration) { if (empty($form_state['islandora'])) { - $objects = isset($configuration['objects']); + $objects = isset($configuration['objects']) ? $configuration['objects'] : array(); if (empty($objects)) { $objects[] = islandora_ingest_form_prepare_new_object($configuration); } From 0975818bd0f4a0b8a9c209e0f8f766f259bb573d Mon Sep 17 00:00:00 2001 From: willtp87 Date: Thu, 29 Jan 2015 16:15:09 -0400 Subject: [PATCH 7/7] Simplification as single object entry is deprecated. --- includes/ingest.form.inc | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/includes/ingest.form.inc b/includes/ingest.form.inc index 8cda9160..dc9064f1 100644 --- a/includes/ingest.form.inc +++ b/includes/ingest.form.inc @@ -80,10 +80,6 @@ function islandora_ingest_form(array $form, array &$form_state, array $configura */ function islandora_ingest_form_init_form_state_storage(array &$form_state, array $configuration) { if (empty($form_state['islandora'])) { - $objects = isset($configuration['objects']) ? $configuration['objects'] : array(); - if (empty($objects)) { - $objects[] = islandora_ingest_form_prepare_new_object($configuration); - } $configuration['models'] = isset($configuration['models']) ? $configuration['models'] : array(); // Make sure the models actually exist. foreach ($configuration['models'] as $key => $model) { @@ -91,15 +87,15 @@ function islandora_ingest_form_init_form_state_storage(array &$form_state, array unset($configuration['models'][$key]); } } - // No need to persist the 'objects' within the configuration. - unset($configuration['objects']); // Required for step hooks. $form_state['islandora'] = array( 'step_id' => NULL, - 'objects' => $objects, + 'objects' => $configuration['objects'], 'shared_storage' => $configuration, 'step_storage' => array(), ); + // No need to persist the 'objects' within the configuration. + unset($configuration['objects']); // Must be called after $form_state['islandora'] is initialized, otherwise, // the values in 'islandora' would not be availible to the step hooks. $form_state['islandora']['step_id'] = islandora_ingest_form_get_first_step_id($form_state);