diff --git a/README.md b/README.md index 90d935cf..371797b2 100644 --- a/README.md +++ b/README.md @@ -42,11 +42,16 @@ INSTALLATION Before installing Islandora the XACML policies located in the policies folder should be copied into the Fedora global XACML policies folder. This will allow -"authenticated users" in Drupal to access Fedora API-M functions. +"authenticated users" in Drupal to access Fedora API-M functions. It is to be +noted that the permit-upload-to-anonymous-user.xml and +permit-apim-to-anonymous-user.xml files do not need to be present unless +requirements for anonymous ingesting are present. -You will also have to remove some default policies if you want full functionality as well. +You will also have to remove some default policies if you want full +functionality as well. -Remove deny-purge-datastream-if-active-or-inactive.xml to allow for purging of datastream versions. +Remove deny-purge-datastream-if-active-or-inactive.xml to allow for purging of +datastream versions. CONFIGURATION ------------- diff --git a/includes/admin.form.inc b/includes/admin.form.inc index b0bb0642..3dc97091 100644 --- a/includes/admin.form.inc +++ b/includes/admin.form.inc @@ -27,7 +27,7 @@ function islandora_repository_admin(array $form, array &$form_state) { '#type' => 'vertical_tabs', 'islandora_general' => array( '#type' => 'fieldset', - '#title' => t('General Configuarion'), + '#title' => t('General Configuration'), 'wrapper' => array( '#prefix' => '
', '#suffix' => '
', diff --git a/includes/datastream.version.inc b/includes/datastream.version.inc index 8c02aaad..ecef019d 100644 --- a/includes/datastream.version.inc +++ b/includes/datastream.version.inc @@ -234,7 +234,7 @@ function islandora_revert_datastream_version_form_submit(array $form, array &$fo /** * Gets Audit datastream values from foxml. * - * @param String $pid + * @param string $pid * PID of parent object * * @return array diff --git a/includes/derivatives.inc b/includes/derivatives.inc index d25789cc..635c1c54 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/includes/ingest.form.inc b/includes/ingest.form.inc index 89376f7d..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); } /** @@ -769,7 +771,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); diff --git a/includes/manage_deleted_objects.inc b/includes/manage_deleted_objects.inc index 2708efe3..a6b5e96e 100644 --- a/includes/manage_deleted_objects.inc +++ b/includes/manage_deleted_objects.inc @@ -287,7 +287,7 @@ function islandora_get_contentmodels_with_deleted_members() { /** * Restores deleted object. * - * @param String $pid + * @param string $pid * PID of object to be restored */ function islandora_restore_object_by_pid($pid) { @@ -298,7 +298,7 @@ function islandora_restore_object_by_pid($pid) { /** * Purges deleted object. * - * @param String $pid + * @param string $pid * PID of object to be restored */ function islandora_purge_object_by_pid($pid) { @@ -314,7 +314,7 @@ function islandora_purge_object_by_pid($pid) { * @param int $offset * offset to be added to search * - * @return String + * @return string * Sparql query */ function islandora_get_deleted_query($content_models, $offset = 0) { @@ -332,7 +332,7 @@ function islandora_get_deleted_query($content_models, $offset = 0) { $unions .= "UNION {?subject fm:hasModel ; fm:state fm:Deleted; fm:hasModel ?object; - } + } "; } $optional = "OPTIONAL{?subject fm:label ?label}"; diff --git a/includes/regenerate_derivatives.form.inc b/includes/regenerate_derivatives.form.inc index 7fd8d059..9a7a097e 100644 --- a/includes/regenerate_derivatives.form.inc +++ b/includes/regenerate_derivatives.form.inc @@ -142,15 +142,17 @@ function islandora_regenerate_datastream_derivative_batch(AbstractDatastream $da * The pid of the object we are performing. * @param bool $force * Whether we are forcing derivative regeneration or not. + * @param array $hook + * The derivative definition. * @param array $context * The context of the current batch operation. */ -function islandora_derivative_perform_batch_operation($function, $file, $pid, $force, &$context) { +function islandora_derivative_perform_batch_operation($function, $file, $pid, $force, $hook, &$context) { if ($file) { require_once $file; } if (function_exists($function)) { - $logging = call_user_func($function, islandora_object_load($pid), $force); + $logging = call_user_func($function, islandora_object_load($pid), $force, $hook); if (!empty($logging)) { $context['results']['logging'][] = $logging; } 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.api.php b/islandora.api.php index 0534ffe7..eeeeae1c 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. @@ -472,7 +472,7 @@ function hook_islandora_ingest_steps(array $form_state) { * * @param array $steps * An array of steps as generated by hook_islandora_ingest_steps(). - * + * * @param array $form_state * An array containing the Drupal form_state. */ @@ -497,7 +497,7 @@ function hook_CMODEL_PID_islandora_ingest_steps(array $form_state) { * * @param array $steps * An array of steps as generated by hook_islandora_ingest_steps(). - * + * * @param array $form_state * An array containing the Drupal form_state. */ @@ -635,10 +635,11 @@ 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: + * - messages: An array structure containing zero or more array's with the + * following fields: * - message: A string passed through t() describing the * outcome of the operation. * - message_sub: (Optional) Substitutions to be passed along to t() or @@ -704,7 +705,7 @@ function hook_CMODEL_PID_islandora_derivative() { function hook_islandora_update_related_objects_properties(AbstractObject $object) { $related_objects = get_all_children_siblings_and_friends($object); $pids_to_return = array(); - foreach($related_objects as $related_object) { + foreach ($related_objects as $related_object) { $pids_to_return[] = $related_object->id; } return $pids_to_return; diff --git a/islandora.module b/islandora.module index 9e7809eb..f979a4e5 100644 --- a/islandora.module +++ b/islandora.module @@ -109,13 +109,35 @@ function islandora_menu() { 'file' => 'includes/metadata.inc', 'access arguments' => array('administer site configuration'), ); - $items['admin/islandora/solution_packs'] = array( - 'title' => 'Solution packs', + $items['admin/islandora/solution_pack_config'] = array( + 'title' => 'Solution pack configuration', + 'description' => 'Configure Islandora solution packs.', + 'access callback' => 'islandora_find_package', + 'access arguments' => array('Islandora Solution Packs'), + 'type' => MENU_NORMAL_ITEM, + ); + $items['admin/islandora/islandora_viewers'] = array( + 'title' => 'Islandora Viewers', + 'description' => 'Configure custom viewers.', + 'access callback' => 'islandora_find_package', + 'access arguments' => array('Islandora Viewers'), + 'type' => MENU_NORMAL_ITEM, + ); + $items['admin/islandora/islandora_utilities'] = array( + 'title' => 'Islandora Utility Modules', + 'description' => 'Configure Islandora utility modules.', + 'access callback' => 'islandora_find_package', + 'access arguments' => array('Islandora Utilities'), + 'type' => MENU_NORMAL_ITEM, + ); + $items['admin/islandora/solution_pack_config/solution_packs'] = array( + 'title' => 'Solution packs required objects', 'description' => 'Install content models and collections required by installed solution packs.', 'page callback' => 'islandora_solution_packs_admin', 'access arguments' => array(ISLANDORA_ADD_DS), 'file' => 'includes/solution_packs.inc', 'type' => MENU_NORMAL_ITEM, + 'weight' => -1, ); $items['islandora'] = array( 'title' => 'Islandora Repository', @@ -1531,6 +1553,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; } @@ -1825,9 +1852,9 @@ function islandora_repair_drupal_filter() { } } - /** - * Implements hook_islandora_metadata_display_info(). - */ +/** + * Implements hook_islandora_metadata_display_info(). + */ function islandora_islandora_metadata_display_info() { return array( 'dublin_core' => array( @@ -1864,3 +1891,24 @@ function islandora_islandora_datastream_access($op, AbstractDatastream $datastre } return $result; } + +/** + * Access for submenu items. + * + * @param string $package_name + * Name of the package + * + * @return bool + * Access granted + */ +function islandora_find_package($package_name) { + $results = system_get_info('module'); + $found = FALSE; + foreach ($results as $name => $values) { + if ($values['package'] == $package_name) { + $found = TRUE; + break; + } + } + return $found && user_access('administer site configuration'); +} 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); +} diff --git a/policies/permit-apim-to-anonymous-user.xml b/policies/permit-apim-to-anonymous-user.xml new file mode 100644 index 00000000..4fc711f5 --- /dev/null +++ b/policies/permit-apim-to-anonymous-user.xml @@ -0,0 +1,31 @@ + + + note that other policies may provide exceptions to this broad policy. This policy assumes api-m users have to be authenticated + + + + + anonymous user + + + + + + + + + + + urn:fedora:names:fedora:2.1:action:api-m + + + + + + + diff --git a/policies/permit-upload-to-anonymous-user.xml b/policies/permit-upload-to-anonymous-user.xml new file mode 100644 index 00000000..bebcd37b --- /dev/null +++ b/policies/permit-upload-to-anonymous-user.xml @@ -0,0 +1,31 @@ + + + + + + + + anonymous user + + + + + + + + + + + urn:fedora:names:fedora:2.1:action:id-upload + + + + + + + diff --git a/tests/scripts/travis_setup.sh b/tests/scripts/travis_setup.sh index c1bd7751..4e9a3563 100755 --- a/tests/scripts/travis_setup.sh +++ b/tests/scripts/travis_setup.sh @@ -14,12 +14,11 @@ 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 pear channel-discover pear.netpirates.net -pear install pear/PHP_CodeSniffer-1.4.8 +pear install pear/PHP_CodeSniffer pear install pear.phpunit.de/phpcpd # Install Drush diff --git a/theme/islandora-dublin-core-display.tpl.php b/theme/islandora-dublin-core-display.tpl.php index 2c2a02ee..52c80607 100644 --- a/theme/islandora-dublin-core-display.tpl.php +++ b/theme/islandora-dublin-core-display.tpl.php @@ -17,7 +17,7 @@
>
-
+ +
+

+ +
+ diff --git a/theme/theme.inc b/theme/theme.inc index b783cfa8..feac06b2 100644 --- a/theme/theme.inc +++ b/theme/theme.inc @@ -109,6 +109,7 @@ function islandora_preprocess_islandora_default(&$variables) { $islandora_object = $variables['islandora_object']; module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/datastream'); + module_load_include('inc', 'islandora', 'includes/metadata'); $variables['parent_collections'] = islandora_get_parents_from_rels_ext($islandora_object); @@ -140,8 +141,13 @@ function islandora_preprocess_islandora_default(&$variables) { $dc_object = DublinCore::importFromXMLString($islandora_object['DC']->content); $dc_array = $dc_object->asArray(); } + // We should eventually remove the DC object and dc_array code as it only + // exists to not break legacy implementations. $variables['dc_array'] = isset($dc_array) ? $dc_array : array(); $variables['islandora_dublin_core'] = isset($dc_object) ? $dc_object : NULL; + + $variables['metadata'] = islandora_retrieve_metadata_markup($islandora_object, TRUE); + $variables['description'] = islandora_retrieve_description_markup($islandora_object); $variables['islandora_object_label'] = $islandora_object->label; if (isset($islandora_object['TN']) && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $islandora_object['TN'])) { $variables['islandora_thumbnail_url'] = url("islandora/object/{$islandora_object->id}/datastream/TN/view");