@ -4,7 +4,7 @@
* @file
* Defines all the hooks this module implements.
*
* i slandora.module: defines paths (drupal menu items) as entry points and acts
* I slandora.module: defines paths (drupal menu items) as entry points and acts
* as a hub for dispatching tasks to other modules.
*
* This file is part of Islandora.
@ -76,7 +76,7 @@ const ISLANDORA_BREADCRUMB_LEGACY_BACKEND = 'islandora_breadcrumbs_legacy_sparql
* Implements hook_menu().
*
* We need some standard entry points so we can have consistent urls for
* different Object actions
* different Object actions.
*/
function islandora_menu() {
$items = array();
@ -190,7 +190,8 @@ function islandora_menu() {
ISLANDORA_ADD_DS,
ISLANDORA_PURGE,
ISLANDORA_INGEST,
), 2),
), 2,
),
);
$items['islandora/object/%islandora_object/manage/overview'] = array(
'title' => 'Overview',
@ -208,7 +209,8 @@ function islandora_menu() {
ISLANDORA_METADATA_EDIT,
ISLANDORA_ADD_DS,
ISLANDORA_PURGE,
), 2),
), 2,
),
'weight' => -10,
);
$items['islandora/object/%islandora_object/manage/properties'] = array(
@ -437,7 +439,7 @@ function islandora_admin_paths() {
* The theme entries 'islandora_objects' and 'islandora_objects_subset'
* utilize the same template file. When theming, be sure to utilize the theme
* name, and not the template file names. Similar situation found here:
* @link https://jira.duraspace.org/browse/ISLANDORA-934. @endlink
* @link https://jira.duraspace.org/browse/ISLANDORA-934. @endlink.
*/
function islandora_theme() {
return array(
@ -722,7 +724,7 @@ function islandora_print_object(AbstractObject $object) {
* FALSE if 'islandora_show_print_option' is not selected in islandora
* configuraton.
*/
function islandora_print_object_access($op, $object) {
function islandora_print_object_access($op, AbstractObject $object) {
if (!variable_get('islandora_show_print_option', FALSE)) {
return FALSE;
}
@ -750,8 +752,6 @@ function islandora_forms($form_id) {
* Will check the given user or the user repersented by the GET token parameter,
* failing that it will use the global user.
*
* @global $user
*
* @param mixed $object_or_datastream
* The AbstractObject or AbstractDatastream to test for accessibility, if NULL
* is given the object is assumed to not exist or be inaccessible.
@ -768,11 +768,13 @@ function islandora_forms($form_id) {
* a token to restore the user. If no GET parameter is present use currently
* logged in user.
*
* @global $user
*
* @return bool
* TRUE if the user is allowed to access this object/datastream, FALSE
* otherwise.
*/
function islandora_user_access($object_or_datastream, array $permissions, $content_models = array(), $access_any = TRUE, $user = NULL) {
function islandora_user_access($object_or_datastream, array $permissions, array $content_models = array(), $access_any = TRUE, $user = NULL) {
module_load_include('inc', 'islandora', 'includes/utilities');
$is_repository_accessible = &drupal_static(__FUNCTION__);
@ -860,11 +862,11 @@ function islandora_user_access($object_or_datastream, array $permissions, $conte
* Checks whether the user can access the given object.
*
* Checks for object existance, accessiblitly, namespace permissions,
* and user permissions
* and user permissions.
*
* @param string $perm
* User permission to test for.
* @param AbstractObject $object
* @param AbstractObject|string $object
* The object to test, if NULL given the object doesn't exist or is
* inaccessible.
*
@ -914,7 +916,7 @@ function islandora_object_datastream_tokened_access_callback($perm, $object = NU
* Checks whether the user can access the given object's manage tab.
*
* Checks for object existance, accessiblitly, namespace permissions,
* and user permissions
* and user permissions.
*
* @param array $perms
* Array of user permission to test for.
@ -925,7 +927,7 @@ function islandora_object_datastream_tokened_access_callback($perm, $object = NU
* @return bool
* TRUE if the user is allowed to access this object, FALSE otherwise.
*/
function islandora_object_manage_access_callback($perms, $object = NULL) {
function islandora_object_manage_access_callback(array $perms, AbstractObject $object = NULL) {
module_load_include('inc', 'islandora', 'includes/utilities');
if (!$object && !islandora_describe_repository()) {
@ -1140,7 +1142,7 @@ function islandora_drupal_title(AbstractObject $object) {
* @return array
* The default rendering of the object view page, indexed at 'Default output'.
*/
function islandora_default_islandora_view_object($object) {
function islandora_default_islandora_view_object(AbstractObject $object) {
$output = theme('islandora_default', array('islandora_object' => $object));
return array('Default output' => array('#markup' => $output));
}
@ -1156,7 +1158,7 @@ function islandora_default_islandora_view_object($object) {
* @return array
* A renderable array
*/
function islandora_default_islandora_printer_object($object, $alter) {
function islandora_default_islandora_printer_object(AbstractObject $object, $alter) {
module_load_include('inc', 'islandora', 'includes/utilities');
module_load_include('inc', 'islandora', 'includes/datastream');
module_load_include('inc', 'islandora', 'includes/metadata');
@ -1165,11 +1167,10 @@ function islandora_default_islandora_printer_object($object, $alter) {
drupal_add_css($path . '/css/islandora.print.css');
$islandora_object = islandora_object_load($object->id);
$repository = $islandora_object->repository;
try {
$dc = $islandora_object['DC']->content;
$dc_object = DublinCore::importFromXML String($dc);
$dc_object = DublinCore::importFromXml String($dc);
}
catch (Exception $e) {
drupal_set_message(t('Error retrieving object %s %t', array('%s' => $islandora_object->id, '%t' => $e->getMessage())), 'error', FALSE);
@ -1180,7 +1181,8 @@ function islandora_default_islandora_printer_object($object, $alter) {
'object' => $object,
'dc_array' => $variables,
'metadata' => $metadata,
'islandora_content' => $alter));
'islandora_content' => $alter,
));
return array('Default output' => array('#markup' => $output));
}
@ -1277,7 +1279,7 @@ function islandora_object_load($object_id) {
* @return FedoraObject
* A token authenticated object. @see islandora_object_load
*/
function islandora_tokened_object_load($object_id, $map) {
function islandora_tokened_object_load($object_id, array $map) {
if (array_key_exists('token', $_GET)) {
$token = filter_input(INPUT_GET, 'token', FILTER_SANITIZE_STRING);
if ($token) {
@ -1304,7 +1306,7 @@ function islandora_tokened_object_load($object_id, $map) {
* islandora_tokened_datastream_load(DSID, DSID, PID)
*
* @param mixed $datastream_id
* %islandora_tokened_datastream @see islandora_datastream_load
* Load datastream from %islandora_tokened_datastream.
* @param array $map
* Used to extract the Fedora object's PID at $map[2].
*
@ -1313,7 +1315,7 @@ function islandora_tokened_object_load($object_id, $map) {
*
* @see islandora_datastream_load
*/
function islandora_tokened_datastream_load($datastream_id, $map) {
function islandora_tokened_datastream_load($datastream_id, array $map) {
return islandora_datastream_load($datastream_id, $map[2]);
}
@ -1329,8 +1331,7 @@ function islandora_tokened_datastream_load($datastream_id, $map) {
* @param string $datastream_id
* The DSID of the datastream specified as '%islandora_datastream' to fetch
* from the given object in the menu path identified by '%islandora_object'.
*
* @param mixed $object_id
* @param AbstractObject|string $object_id
* The object to load the datastream from. This can be a Fedora PID or
* an instantiated IslandoraAbstractObject as it implements __toString()
* returning the PID.
@ -1365,7 +1366,7 @@ function islandora_datastream_load($datastream_id, $object_id) {
* @return int
* The datastreams version if found, NULL otherwise.
*/
function islandora_get_islandora_datastream_version($object = NULL, $dsid = NULL, $datastream_file = NULL) {
function islandora_get_islandora_datastream_version(AbstractObject $object = NULL, $dsid = NULL, $datastream_file = NULL) {
$return = NULL;
// @TODO, need better check for $object
if ($object && $object[$dsid]) {
@ -1500,15 +1501,15 @@ function islandora_delete_object(AbstractObject &$object) {
/**
* Delete's or purges the given datastream.
*
* @throws Exception
* Which types are undefined, but more than likely because of the hooks
* there will be several kinds.
*
* @param AbstractDatastream $datastream
* The datastream to delete.
*
* @return bool
* TRUE if successful, FALSE otherwise.
*
* @throws Exception
* Which types are undefined, but more than likely because of the hooks
* there will be several kinds.
*/
function islandora_delete_datastream(AbstractDatastream &$datastream) {
$object = $datastream->parent;
@ -1641,7 +1642,7 @@ function islandora_entity_property_info() {
* Implements hook_file_mimetype_mapping_alter().
*
* Grab custom Islandora mime type list
* and add any missing ext/mimes to the Drupal mapping
* and add any missing ext/mimes to the Drupal mapping.
*/
function islandora_file_mimetype_mapping_alter(&$mapping) {
module_load_include('inc', 'islandora', 'includes/mimetype.utils');
@ -1668,7 +1669,7 @@ function islandora_file_mimetype_mapping_alter(&$mapping) {
* @param string $op
* String identifying an operation to check. Should correspond to a
* permission declared via hook_permission().
* @param AbstractObject $object
* @param AbstractObject|string $object
* An object to check for permissions.
* @param object $user
* An optional loaded user object. Defaults to the global $user.
@ -1712,7 +1713,7 @@ function islandora_object_access($op, $object, $user = NULL) {
* Denies according to PID namespace restrictions, then passes or denies
* according to core Drupal permissions according to user_access().
*/
function islandora_islandora_object_access($op, $object, $user) {
function islandora_islandora_object_access($op, AbstractObject $object, $user) {
module_load_include('inc', 'islandora', 'includes/utilities');
$access = (islandora_namespace_accessible($object->id) && user_access($op, $user));
if (($object->state != 'A') && variable_get('islandora_deny_inactive_and_deleted', FALSE)) {
@ -2003,7 +2004,7 @@ function islandora_islandora_datastream_access($op, AbstractDatastream $datastre
* Access for submenu items.
*
* @param string $package_name
* Name of the package
* Name of the package.
*
* @return bool
* Access granted
@ -2217,7 +2218,7 @@ function islandora_islandora_breadcrumbs_backends() {
}
/**
* Implements hook_islandora_solution_pack_child_relationships
* Implements hook_islandora_solution_pack_child_relationships().
*/
function islandora_islandora_solution_pack_child_relationships($cmodels) {
// Return empty arrays from core implementation so that these keys always