From 90c60eda0ede3616922e5d4dfd9854efc81884fd Mon Sep 17 00:00:00 2001 From: willtp87 Date: Wed, 2 Apr 2014 15:30:06 -0300 Subject: [PATCH 01/12] rules integration during ingest --- includes/tuque_wrapper.inc | 4 ++++ islandora.rules.inc | 23 ++++++++++++++++++++--- islandora.rules_defaults.inc | 26 ++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 islandora.rules_defaults.inc diff --git a/includes/tuque_wrapper.inc b/includes/tuque_wrapper.inc index d30af147..573d7c62 100644 --- a/includes/tuque_wrapper.inc +++ b/includes/tuque_wrapper.inc @@ -115,6 +115,10 @@ class IslandoraFedoraRepository extends FedoraRepository { foreach ($object as $dsid => $datastream) { islandora_invoke_datastream_hooks(ISLANDORA_DATASTREAM_INGESTED_HOOK, $object->models, $dsid, $object, $datastream); } + // Fire of event if rules is enabled. + if (module_exists('rules')) { + rules_invoke_event('islandora_object_ingested', $object); + } return $ret; } catch (Exception $e) { diff --git a/islandora.rules.inc b/islandora.rules.inc index 4045b1b9..02f5c822 100644 --- a/islandora.rules.inc +++ b/islandora.rules.inc @@ -5,11 +5,30 @@ * Does rule type stuff, */ +/** + * Implements hook_rules_event_info(). + */ +function islandora_rules_event_info() { + return array( + 'islandora_object_ingested' => array( + 'group' => t('Islandora'), + 'label' => t('Object ingested'), + 'variables' => array( + 'object' => array( + 'type' => 'islandora_object', + 'label' => t('The ingested object'), + 'description' => t('A Tuque object for the ingested Fedora object, as an entity.'), + ), + ), + ), + ); +} + /** * Helper function to get reused "parameter" array. */ function islandora_rules_relationship_parameter_array() { - $to_return = array( + return array( 'subject' => array( 'type' => 'islandora_object', 'label' => t('Subject'), @@ -39,8 +58,6 @@ function islandora_rules_relationship_parameter_array() { 'default value' => 0, ), ); - - return $to_return; } /** diff --git a/islandora.rules_defaults.inc b/islandora.rules_defaults.inc new file mode 100644 index 00000000..17f83b63 --- /dev/null +++ b/islandora.rules_defaults.inc @@ -0,0 +1,26 @@ +label = 'E-mail admin'; + $rule->active = FALSE; + $rule + ->event('islandora_object_ingested') + ->action( + 'mail', + array( + 'to' => '[site:mail]', + 'subject' => '[[site:name]] "[object:label]" has been ingested', + 'message' => '[object:label] has been ingested as [object:id].', + ) + ); + return array('islandora_object_ingested_notify_admin' => $rule); +} From 4507d5b39c63b9fec103505c8cde52551c2251bf Mon Sep 17 00:00:00 2001 From: Jordan Dukart Date: Wed, 2 Apr 2014 19:50:39 +0000 Subject: [PATCH 02/12] Use redirect set in form state before defaulting to the object. --- 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 89376f7d..8fd1c6ea 100644 --- a/includes/ingest.form.inc +++ b/includes/ingest.form.inc @@ -769,7 +769,7 @@ function islandora_ingest_form_submit(array $form, array &$form_state) { islandora_ingest_form_execute_consecutive_callback_steps($form, $form_state, $step); } // Ingest the objects. - $set_redirect = TRUE; + $set_redirect = isset($form_state['redirect']) ? FALSE : TRUE; foreach ($form_state['islandora']['objects'] as &$object) { try { islandora_add_object($object); From bbc6cec2298ae9ecd4f812ca414d5693a95c69b7 Mon Sep 17 00:00:00 2001 From: willtp87 Date: Thu, 3 Apr 2014 11:09:25 -0300 Subject: [PATCH 03/12] date time available --- islandora.module | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/islandora.module b/islandora.module index 9e7809eb..fd71bb3c 100644 --- a/islandora.module +++ b/islandora.module @@ -1531,6 +1531,11 @@ function islandora_entity_property_info() { 'label' => t('Content Models'), 'description' => t('The list of content models which the object has.'), ); + $p['createdDate'] = array( + 'type' => 'text', + 'label' => t('Created Date'), + 'description' => t('When the object was created.'), + ); return $info; } From 785eedcc8397ff4d432570fc0d4e95429dcac64a Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Fri, 4 Apr 2014 13:42:22 +0000 Subject: [PATCH 04/12] Make the "undo_function" bit optional. The "undo_function" part of callbacks was required, even though it might not be required for functionality... Make it optional, so we don't end up making/using no-op functions to avoid doing anything. --- includes/ingest.form.inc | 12 +++++++----- islandora.api.php | 6 +++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/includes/ingest.form.inc b/includes/ingest.form.inc index 8fd1c6ea..f7979063 100644 --- a/includes/ingest.form.inc +++ b/includes/ingest.form.inc @@ -467,12 +467,14 @@ function islandora_ingest_form_undo_consecutive_callback_steps(array $form, arra * The step which the undo callback is being called on. */ function islandora_ingest_form_undo_callback_step(array $form, array &$form_state, array $step) { - $args = array(&$form_state); - $args = isset($step['undo_function']['args']) ? array_merge($args, $step['undo_function']['args']) : $args; - if (isset($step['undo_function']['file'])) { - require_once drupal_get_path('module', $step['module']) . "/" . $step['undo_function']['file']; + if (isset($step['undo_function'])) { + $args = array(&$form_state); + $args = isset($step['undo_function']['args']) ? array_merge($args, $step['undo_function']['args']) : $args; + if (isset($step['undo_function']['file'])) { + require_once drupal_get_path('module', $step['module']) . "/" . $step['undo_function']['file']; + } + call_user_func_array($step['undo_function']['function'], $args); } - call_user_func_array($step['undo_function']['function'], $args); } /** diff --git a/islandora.api.php b/islandora.api.php index e8b45ba7..d32b7fdf 100644 --- a/islandora.api.php +++ b/islandora.api.php @@ -423,13 +423,13 @@ function hook_islandora_undeletable_datastreams(array $models) { * - form_id: The form building function to call to get the form structure * for this step. * - args: An array of arguments to pass to the form building function. - * Required "callback" type specific parameters: - * - do_function: An associate array including: + * "Callback" type specific parameters: + * - do_function: A required associative array including: * - 'function': The callback function to be called. * - 'args': An array of arguments to pass to the callback function. * - 'file': A file to include (relative to the module's path, including * the file's extension). - * - undo_function: An associate array including: + * - undo_function: An optional associative array including: * - 'function': The callback function to be called to reverse the * executed action in the ingest steps. * - 'args': An array of arguments to pass to the callback function. From e9faa1810d4f2b9631c112c91ac3a818e5fa5c30 Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Fri, 4 Apr 2014 16:02:19 +0000 Subject: [PATCH 05/12] Try getting rid of the "upgrade-all" shenanigans. --- tests/scripts/travis_setup.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/scripts/travis_setup.sh b/tests/scripts/travis_setup.sh index c1bd7751..4079d3b6 100755 --- a/tests/scripts/travis_setup.sh +++ b/tests/scripts/travis_setup.sh @@ -14,7 +14,6 @@ export JAVA_OPTS="-Xms1024m -Xmx1024m -XX:MaxPermSize=512m -XX:+CMSClassUnloadin cd $HOME pear upgrade --force Console_Getopt pear upgrade --force pear -pear upgrade-all pear channel-discover pear.drush.org pear channel-discover pear.drush.org pear channel-discover pear.phpqatools.org From 254ee5d60be9b3e169d4483778b350f9c23ed3c8 Mon Sep 17 00:00:00 2001 From: willtp87 Date: Tue, 8 Apr 2014 13:32:59 -0300 Subject: [PATCH 06/12] passing derivative deffinition to callback (usefull for single callback handling many derivatives) --- includes/derivatives.inc | 16 ++++++++++------ islandora.api.php | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/includes/derivatives.inc b/includes/derivatives.inc index d25789cc..2f4adc51 100644 --- a/includes/derivatives.inc +++ b/includes/derivatives.inc @@ -49,7 +49,7 @@ function islandora_do_derivatives(AbstractObject $object, array $options) { } foreach ($hook['function'] as $function) { if (function_exists($function)) { - $logging = call_user_func($function, $object, $options['force']); + $logging = call_user_func($function, $object, $options['force'], $hook); if (!empty($logging)) { $results[] = $logging; } @@ -142,11 +142,15 @@ function islandora_do_batch_derivatives(AbstractObject $object, array $options) $file = $hook['file']; } foreach ($hook['function'] as $function) { - $operations[] = array('islandora_derivative_perform_batch_operation', array( - $function, - $file, - $object->id, - $options['force']), + $operations[] = array( + 'islandora_derivative_perform_batch_operation', + array( + $function, + $file, + $object->id, + $options['force'], + $hook + ), ); } } diff --git a/islandora.api.php b/islandora.api.php index d32b7fdf..eeeeae1c 100644 --- a/islandora.api.php +++ b/islandora.api.php @@ -635,7 +635,7 @@ function hook_CMODEL_PID_islandora_overview_object_alter(AbstractObject &$object * - function: An array of function(s) to be ran when constructing * derivatives. Functions that are defined to be called for derivation * creation must have the following structure: - * module_name_derivative_creation_function($object, $force = FALSE) + * module_name_derivative_creation_function($object, $force = FALSE, $hook) * These functions must return an array in the structure of: * - success: Bool denoting whether the operation was successful. * - messages: An array structure containing zero or more array's with the From 7be2653ba646af812fdfaa7c3ef7996265c4d208 Mon Sep 17 00:00:00 2001 From: willtp87 Date: Tue, 8 Apr 2014 13:47:51 -0300 Subject: [PATCH 07/12] forgot comma --- includes/derivatives.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/derivatives.inc b/includes/derivatives.inc index 2f4adc51..635c1c54 100644 --- a/includes/derivatives.inc +++ b/includes/derivatives.inc @@ -149,7 +149,7 @@ function islandora_do_batch_derivatives(AbstractObject $object, array $options) $file, $object->id, $options['force'], - $hook + $hook, ), ); } From 91c7103f50922fc4d20e70ff1250d3eae5b4b232 Mon Sep 17 00:00:00 2001 From: Jordan Dukart Date: Wed, 9 Apr 2014 16:13:19 +0000 Subject: [PATCH 08/12] Don't render unneeded markup when there is no thumbnail. --- theme/islandora-object.tpl.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/theme/islandora-object.tpl.php b/theme/islandora-object.tpl.php index fdd09607..f91c3272 100644 --- a/theme/islandora-object.tpl.php +++ b/theme/islandora-object.tpl.php @@ -61,13 +61,13 @@

-
-
- -
- -
-
+ +
+
+ +
+
+