|
|
|
@ -67,7 +67,6 @@ function islandora_collections_get_collection_from_pid($pid) {
|
|
|
|
|
return $object_pids; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Returns an array of pids that match the query contained in the collection |
|
|
|
|
* object's QUERY datastream or in the suppled $query parameter. |
|
|
|
@ -124,79 +123,78 @@ function get_related_items_as_array($collection_pid, $relationship = array('isMe
|
|
|
|
|
return $results; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* determines whether we can see the object or not |
|
|
|
|
* checks PID namespace permissions, and user permissions |
|
|
|
|
* @global type $user |
|
|
|
|
* @param type $op |
|
|
|
|
* @param type $pid |
|
|
|
|
* @return type |
|
|
|
|
*/ |
|
|
|
|
function fedora_repository_access($permission, $pid) { |
|
|
|
|
global $user; |
|
|
|
|
$name_space_access = FALSE; |
|
|
|
|
$is_restricted = variable_get('islandora_namespace_restriction_enforced', TRUE); |
|
|
|
|
if (!$is_restricted) { |
|
|
|
|
/** |
|
|
|
|
* determines whether we can see the object or not |
|
|
|
|
* checks PID namespace permissions, and user permissions |
|
|
|
|
* @global type $user |
|
|
|
|
* @param type $op |
|
|
|
|
* @param type $pid |
|
|
|
|
* @return type |
|
|
|
|
*/ |
|
|
|
|
function fedora_repository_access($permission, $pid) { |
|
|
|
|
global $user; |
|
|
|
|
$name_space_access = FALSE; |
|
|
|
|
$is_restricted = variable_get('islandora_namespace_restriction_enforced', TRUE); |
|
|
|
|
if (!$is_restricted) { |
|
|
|
|
$name_space_access = TRUE; |
|
|
|
|
} |
|
|
|
|
if ($pid == NULL) { |
|
|
|
|
$pid = variable_get('islandora_repository_pid', 'islandora:root'); |
|
|
|
|
} |
|
|
|
|
$name_space_allowed = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); |
|
|
|
|
$pos = NULL; |
|
|
|
|
foreach ($name_space_allowed as $name_space) { |
|
|
|
|
$pos = stripos($pid, $name_space); |
|
|
|
|
if ($pos === 0) { |
|
|
|
|
$name_space_access = TRUE; |
|
|
|
|
} |
|
|
|
|
if ($pid == NULL) { |
|
|
|
|
$pid = variable_get('islandora_repository_pid', 'islandora:root'); |
|
|
|
|
} |
|
|
|
|
$name_space_allowed = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); |
|
|
|
|
$pos = NULL; |
|
|
|
|
foreach ($name_space_allowed as $name_space) { |
|
|
|
|
$pos = stripos($pid, $name_space); |
|
|
|
|
if ($pos === 0) { |
|
|
|
|
$name_space_access = TRUE; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if ($name_space_access) { |
|
|
|
|
$user_access = user_access($permission); |
|
|
|
|
if ($user_access == NULL) { |
|
|
|
|
return FALSE; |
|
|
|
|
} |
|
|
|
|
return $user_access; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
} |
|
|
|
|
if ($name_space_access) { |
|
|
|
|
$user_access = user_access($permission); |
|
|
|
|
if ($user_access == NULL) { |
|
|
|
|
return FALSE; |
|
|
|
|
} |
|
|
|
|
return $user_access; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
return FALSE; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* gets the name of the content models for the specified object |
|
|
|
|
* this now returns an array of pids as in Fedora 3 we can have more then one Cmodel for an object |
|
|
|
|
* @param type $pid |
|
|
|
|
* @param type $include_fedora_system_content_models |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
|
function get_content_models_list($pid, $include_fedora_system_content_models = FALSE) { |
|
|
|
|
/** |
|
|
|
|
* gets the name of the content models for the specified object |
|
|
|
|
* this now returns an array of pids as in Fedora 3 we can have more then one Cmodel for an object |
|
|
|
|
* @param type $pid |
|
|
|
|
* @param type $include_fedora_system_content_models |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
|
function get_content_models_list($pid, $include_fedora_system_content_models = FALSE) { |
|
|
|
|
|
|
|
|
|
module_load_include('inc', 'islandora', 'RestConnection'); |
|
|
|
|
require_once 'sites/all/libraries/tuque/RepositoryQuery.php'; |
|
|
|
|
$rest_connection = new RestConnection(); |
|
|
|
|
$pids = array(); |
|
|
|
|
$query = 'select $object from <#ri> |
|
|
|
|
$pids = array(); |
|
|
|
|
$query = 'select $object from <#ri> |
|
|
|
|
where <info:fedora/' . $pid . '> <fedora-model:hasModel> $object |
|
|
|
|
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>'; |
|
|
|
|
$content_models = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0'); |
|
|
|
|
$content_models = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0'); |
|
|
|
|
|
|
|
|
|
if (empty($content_models)) { |
|
|
|
|
return $pids; |
|
|
|
|
} |
|
|
|
|
if (empty($content_models)) { |
|
|
|
|
return $pids; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$cmodels = array(); |
|
|
|
|
foreach ($content_models as $content_model) { |
|
|
|
|
if (strpos($content_model['object']['uri'], 'fedora-system:FedoraObject-3.0') != FALSE && $include_fedora_system_content_models == FALSE) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
$cmodels[] = substr(strstr($content_model['object']['uri'], '/'), 1); |
|
|
|
|
$cmodels = array(); |
|
|
|
|
foreach ($content_models as $content_model) { |
|
|
|
|
if (strpos($content_model['object']['uri'], 'fedora-system:FedoraObject-3.0') != FALSE && $include_fedora_system_content_models == FALSE) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $cmodels; |
|
|
|
|
$cmodels[] = substr(strstr($content_model['object']['uri'], '/'), 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
return $cmodels; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Function: get_content_models_as_option_array |
|
|
|
|
* |
|
|
|
|
* Description: Returns an associative array of all available content models in Fedora instance |
|
|
|
@ -206,36 +204,36 @@ function get_related_items_as_array($collection_pid, $relationship = array('isMe
|
|
|
|
|
function get_content_models_as_option_array() { |
|
|
|
|
module_load_include('inc', 'islandora', 'RestConnection'); |
|
|
|
|
$rest_connection = new RestConnection(); |
|
|
|
|
require_once 'sites/all/libraries/tuque/RepositoryQuery.php'; |
|
|
|
|
|
|
|
|
|
$restricted = variable_get('fedora_namespace_restriction_enforced', TRUE); |
|
|
|
|
$allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); |
|
|
|
|
$namespaces = explode(':', $allowed_string); |
|
|
|
|
foreach ($namespaces as $namespace) { |
|
|
|
|
if ($namespace) { |
|
|
|
|
$allowed[] = trim($namespace); |
|
|
|
|
} |
|
|
|
|
require_once 'sites/all/libraries/tuque/RepositoryQuery.php'; |
|
|
|
|
|
|
|
|
|
$restricted = variable_get('fedora_namespace_restriction_enforced', TRUE); |
|
|
|
|
$allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); |
|
|
|
|
$namespaces = explode(':', $allowed_string); |
|
|
|
|
foreach ($namespaces as $namespace) { |
|
|
|
|
if ($namespace) { |
|
|
|
|
$allowed[] = trim($namespace); |
|
|
|
|
} |
|
|
|
|
$query = 'select $object $title from <#ri> |
|
|
|
|
} |
|
|
|
|
$query = 'select $object $title from <#ri> |
|
|
|
|
where ($object <fedora-model:label> $title |
|
|
|
|
and ($object <fedora-model:hasModel> <info:fedora/fedora-system:ContentModel-3.0> |
|
|
|
|
or $object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:ContentModelsCollection>) |
|
|
|
|
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) |
|
|
|
|
order by $title'; |
|
|
|
|
|
|
|
|
|
$list = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0'); |
|
|
|
|
$options = array(); |
|
|
|
|
foreach ($list as $item) { //removes blanks |
|
|
|
|
if ($item) { |
|
|
|
|
$item_namespace = explode(':', $item['object']['value']); |
|
|
|
|
if (!$restricted || in_array($item_namespace[0], $allowed)) { |
|
|
|
|
|
|
|
|
|
if (!preg_match('/fedora-system/', $item['object']['value'])) { |
|
|
|
|
$options[$item['object']['value']] = $item['title']['value'] . ' ~ ' . $item['object']['value']; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$list = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0'); |
|
|
|
|
$options = array(); |
|
|
|
|
foreach ($list as $item) { //removes blanks |
|
|
|
|
if ($item) { |
|
|
|
|
$item_namespace = explode(':', $item['object']['value']); |
|
|
|
|
if (!$restricted || in_array($item_namespace[0], $allowed)) { |
|
|
|
|
|
|
|
|
|
if (!preg_match('/fedora-system/', $item['object']['value'])) { |
|
|
|
|
$options[$item['object']['value']] = $item['title']['value'] . ' ~ ' . $item['object']['value']; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $options; |
|
|
|
|
return $options; |
|
|
|
|
} |