From 90c60eda0ede3616922e5d4dfd9854efc81884fd Mon Sep 17 00:00:00 2001 From: willtp87 Date: Wed, 2 Apr 2014 15:30:06 -0300 Subject: [PATCH 1/2] 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 bbc6cec2298ae9ecd4f812ca414d5693a95c69b7 Mon Sep 17 00:00:00 2001 From: willtp87 Date: Thu, 3 Apr 2014 11:09:25 -0300 Subject: [PATCH 2/2] 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; }