Browse Source

Merge branch '7.x' of github.com:Islandora/islandora into 7.x

pull/122/head
Danny Joris 13 years ago
parent
commit
b04a0a0aad
  1. 7
      admin/islandora.admin.inc
  2. 1
      includes/breadcrumb.inc
  3. 12
      includes/datastream.inc
  4. 4
      includes/islandora.ingest.inc
  5. 13
      includes/purge.form.inc
  6. 2
      includes/tuque.inc
  7. 16
      islandora.module
  8. 17
      islandora_basic_collection/includes/change_content_models.inc
  9. 12
      islandora_basic_collection/includes/child_collection.inc
  10. 53
      islandora_basic_collection/includes/collection_management.inc
  11. 16
      islandora_basic_collection/includes/collection_manager_table.inc
  12. 28
      islandora_basic_collection/includes/delete_collection.inc
  13. 32
      islandora_basic_collection/includes/manage_policies.inc
  14. 14
      islandora_basic_collection/includes/move_collection.inc
  15. 10
      islandora_basic_collection/islandora_basic_collection.install
  16. 41
      islandora_basic_collection/islandora_basic_collection.module
  17. 9
      islandora_basic_image/islandora_basic_image.install
  18. 28
      islandora_basic_image/islandora_basic_image.module

7
admin/islandora.admin.inc

@ -7,9 +7,9 @@
*/ */
function islandora_repository_admin($form, &$form_state) { function islandora_repository_admin($form, &$form_state) {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'includes/tuque');
if (!RestConnection::exists()) { if (!IslandoraTuque::exists()) {
$message = t('This module requires the !url. Please install sites all libraries folder before continuing.', array('!url' => l(t('Tuque Fedora API'), 'http://github.com/islandora/tuque'))); $message = t('This module requires the !url. Please install sites all libraries folder before continuing.', array('!url' => l(t('Tuque Fedora API'), 'http://github.com/islandora/tuque')));
drupal_set_message(check_plain($message)); drupal_set_message(check_plain($message));
return; return;
@ -24,8 +24,7 @@ function islandora_repository_admin($form, &$form_state) {
$url = variable_get('islandora_base_url', 'http://localhost:8080/fedora'); $url = variable_get('islandora_base_url', 'http://localhost:8080/fedora');
} }
module_load_include('inc', 'islandora', 'RestConnection'); $connection = new IslandoraTuque(NULL, $url);
$connection = new RestConnection(NULL, $url);
try { try {
$info = $connection->api->a->describeRepository(); $info = $connection->api->a->describeRepository();
$connected = TRUE; $connected = TRUE;

1
includes/breadcrumb.inc

@ -3,7 +3,6 @@
function islandora_get_breadcrumbs($object) { function islandora_get_breadcrumbs($object) {
$breadcrumbs = array(); $breadcrumbs = array();
$connection = new RestConnection();
islandora_get_breadcrumbs_recursive($object->id, $breadcrumbs, $object->repository); islandora_get_breadcrumbs_recursive($object->id, $breadcrumbs, $object->repository);
if(isset($breadcrumbs[0])) { if(isset($breadcrumbs[0])) {

12
includes/datastream.inc

@ -136,7 +136,7 @@ function islandora_get_add_datastream_form($object, &$form_state) {
$form['pid'] = array( $form['pid'] = array(
'#type' => 'hidden', '#type' => 'hidden',
'#value' => "$object_id" '#value' => "$object->id"
); );
$form['add_fieldset']['stream_label'] = array( $form['add_fieldset']['stream_label'] = array(
@ -154,7 +154,7 @@ function islandora_get_add_datastream_form($object, &$form_state) {
// '#required'=>'TRUE', // '#required'=>'TRUE',
'#description' => t('The file to upload.') '#description' => t('The file to upload.')
); );
$form['#redirect'] = "islandora/object/$object_id/"; $form['#redirect'] = "islandora/object/$object->id/";
$form['add_fieldset']['submit'] = array( $form['add_fieldset']['submit'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Add Datastream') '#value' => t('Add Datastream')
@ -198,7 +198,6 @@ function islandora_get_add_datastream_form($object, &$form_state) {
*/ */
function islandora_add_datastream_form_submit($form, &$form_state) { function islandora_add_datastream_form_submit($form, &$form_state) {
global $base_url; global $base_url;
module_load_include('inc', 'islandora', 'RestConnection');
if (!empty($form_state['submit']) && $form_state['submit'] == 'OK') { if (!empty($form_state['submit']) && $form_state['submit'] == 'OK') {
$form_state['rebuild'] = TRUE; $form_state['rebuild'] = TRUE;
return; return;
@ -217,8 +216,7 @@ function islandora_add_datastream_form_submit($form, &$form_state) {
$controlGroup = "M"; $controlGroup = "M";
try { try {
$restConnection = new RestConnection(); $fedora_object = islandora_object_load($object_id);
$fedora_object = $restConnection->repository->getObject($object_id);
$ds = $fedora_object->constructDatastream($dsid, $controlGroup); $ds = $fedora_object->constructDatastream($dsid, $controlGroup);
$ds->label = $ds_label; $ds->label = $ds_label;
$ds->mimetype = $dformat; $ds->mimetype = $dformat;
@ -243,7 +241,6 @@ function islandora_add_datastream_form_submit($form, &$form_state) {
*/ */
function islandora_add_datastream_form_validate($form, &$form_state) { function islandora_add_datastream_form_validate($form, &$form_state) {
module_load_include('inc', 'islandora', 'includes/mime.detect'); module_load_include('inc', 'islandora', 'includes/mime.detect');
module_load_include('inc', 'islandora', 'RestConnection');
$mimetype = new MimeDetect(); $mimetype = new MimeDetect();
if ($form_state['clicked_button']['#value'] == 'OK') { if ($form_state['clicked_button']['#value'] == 'OK') {
$form_state['rebuild'] = TRUE; $form_state['rebuild'] = TRUE;
@ -269,8 +266,7 @@ function islandora_add_datastream_form_validate($form, &$form_state) {
} }
$object_id = $form_state['values']['pid']; $object_id = $form_state['values']['pid'];
$restConnection = new RestConnection(); $fedora_object = islandora_object_load($object_id);
$fedora_object = $restConnection->repository->getObject($object_id);
if(isset($fedora_object[$dsid])) { if(isset($fedora_object[$dsid])) {
form_set_error('', t('Data stream ID already exists in object.')); form_set_error('', t('Data stream ID already exists in object.'));

4
includes/islandora.ingest.inc

@ -8,9 +8,9 @@ function islandora_ingest_get_information(AbstractFedoraObject $collection_objec
} }
function islandora_ingest_get_object($content_models, $collection_pid, $relationship, $namespace) { function islandora_ingest_get_object($content_models, $collection_pid, $relationship, $namespace) {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'includes/tuque');
global $user; global $user;
$connection = new RestConnection($user); $connection = new IslandoraTuque($user);
$object = $connection->repository->constructObject($namespace); $object = $connection->repository->constructObject($namespace);
foreach($content_models as $content_model) { foreach($content_models as $content_model) {
$object->relationships->add(FEDORA_MODEL_URI, 'hasModel', $content_model['pid']); $object->relationships->add(FEDORA_MODEL_URI, 'hasModel', $content_model['pid']);

13
includes/purge.form.inc

@ -17,25 +17,26 @@
* @return type * @return type
*/ */
function islandora_purge_object_submit($form, &$form_state) { function islandora_purge_object_submit($form, &$form_state) {
$object_id = $form_state['values']['pid']; $object_id = $form_state['values']['pid'];
$collection = $form_state['values']['col']; $collection = $form_state['values']['col'];
if (!isset($object_id)) { if (!$object_id) {
drupal_set_message(t('Cannot remove object, object id not set')); drupal_set_message(t('Cannot remove object, object id not set'));
return; return;
} }
$object = islandora_object_load($object_id); $object = islandora_object_load($object_id);
if (!isset($fedora_object)) { if (!$object) {
drupal_set_message(t('Could not remove object, object not found')); drupal_set_message(t('Could not remove object, object not found'));
return; return;
} }
$content_models = $fedora_object->models; $content_models = $object->models;
$arr = module_invoke_all('islandora_pre_purge_object', $fedora_object); //notify modules of pending deletion $arr = module_invoke_all('islandora_pre_purge_object', $object); //notify modules of pending deletion
if (isset($arr['delete']) && $arr['delete']) { if (isset($arr['delete']) && $arr['delete']) {
try { try {
$fedora_object->delete(); $object->delete();
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(t('Error deleting Islandora object %s %e', array('%s' => $object_id, '%e' => $e)), 'error'); drupal_set_message(t('Error deleting Islandora object %s %e', array('%s' => $object_id, '%e' => $e)), 'error');
return ""; return "";
@ -43,7 +44,7 @@ function islandora_purge_object_submit($form, &$form_state) {
} }
else { else {
try { try {
$restConnection->repository->purgeObject($object_id); $object->repository->purgeObject($object_id);
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(t('Error purging Islandora object %s %e', array('%s' => $object_id, '%e' => $e)), 'error'); drupal_set_message(t('Error purging Islandora object %s %e', array('%s' => $object_id, '%e' => $e)), 'error');
return ""; return "";

2
RestConnection.inc → includes/tuque.inc

@ -11,7 +11,7 @@ require_once 'sites/all/libraries/tuque/RepositoryException.php';
require_once 'sites/all/libraries/tuque/Repository.php'; require_once 'sites/all/libraries/tuque/Repository.php';
require_once 'sites/all/libraries/tuque/FedoraRelationships.php'; require_once 'sites/all/libraries/tuque/FedoraRelationships.php';
class RestConnection { class IslandoraTuque {
/** /**
* Connection to the repository * Connection to the repository

16
islandora.module

@ -216,8 +216,8 @@ function islandora_admin_paths() {
* *
* @return boolean * @return boolean
*/ */
function islandora_access_callback($pid = NULL, $perm = NULL) { function islandora_access_callback($object = NULL, $perm = NULL) {
if(!$pid || !$perm) { if(!$object || !$perm) {
return FALSE; return FALSE;
} }
@ -227,7 +227,7 @@ function islandora_access_callback($pid = NULL, $perm = NULL) {
$namespace_access = TRUE; $namespace_access = TRUE;
} }
else { else {
$pid_namespace = substr($pid, 0, strpos($pid, ':') + 1); //Get the namespace (with colon) $pid_namespace = substr($object->id, 0, strpos($object->id, ':') + 1); //Get the namespace (with colon)
$allowed_namespaces = explode(" ", variable_get('islandora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); $allowed_namespaces = explode(" ", variable_get('islandora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: '));
$namespace_access = in_array($pid_namespace, $allowed_namespaces); $namespace_access = in_array($pid_namespace, $allowed_namespaces);
} }
@ -427,15 +427,15 @@ function islandora_permission() {
* @return FedoraObject * @return FedoraObject
*/ */
function islandora_object_load($object_id) { function islandora_object_load($object_id) {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'includes/tuque');
static $restConnection = NULL; static $islandora_tuque = NULL;
if(!$restConnection) { if(!$islandora_tuque) {
$restConnection = new RestConnection(); $islandora_tuque = new IslandoraTuque();
} }
try { try {
$fedora_object = $restConnection->repository->getObject($object_id); $fedora_object = $islandora_tuque->repository->getObject($object_id);
} catch (Exception $e) { } catch (Exception $e) {
return NULL; return NULL;
} }

17
islandora_basic_collection/includes/change_content_models.inc

@ -5,12 +5,10 @@
* ChangeContentModels.inc * ChangeContentModels.inc
*/ */
function islandora_change_content_models_form($form, &$form_state, $collection_pid) { function islandora_change_content_models_form($form, &$form_state, $collection_object) {
module_load_include('inc', 'islandora_basic_collection', 'includes/CollectionPolicy'); module_load_include('inc', 'islandora_basic_collection', 'includes/CollectionPolicy');
module_load_include('inc', 'islandora', 'RestConnection'); $collection_pid = $collection_object->id;
$rest_connection = new RestConnection(); $content_models = get_content_models_list($collection_object);
$content_models = get_content_models_list($collection_pid);
$cm_options = array(); $cm_options = array();
$name_mappings = array(); $name_mappings = array();
foreach ($content_models as $content_model) { foreach ($content_models as $content_model) {
@ -24,7 +22,6 @@ function islandora_change_content_models_form($form, &$form_state, $collection_p
$namespace = substr($collection_pid, 0, strpos($collection_pid, ":")); $namespace = substr($collection_pid, 0, strpos($collection_pid, ":"));
$collection_policy_dsid = variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY'); $collection_policy_dsid = variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY');
$collection_object = new FedoraObject($collection_pid, $rest_connection->repository);
$collection_policy_datastream = $collection_object->getDatastream($collection_policy_dsid); $collection_policy_datastream = $collection_object->getDatastream($collection_policy_dsid);
$supported_collection_models = array(); $supported_collection_models = array();
@ -46,7 +43,7 @@ function islandora_change_content_models_form($form, &$form_state, $collection_p
$form['change_cmodel']['titlebox'] = array( $form['change_cmodel']['titlebox'] = array(
'#type' => 'item', '#type' => 'item',
'#title' => t("Change content models within @collection_pid", array('@collection_pid' => $collection_pid)), '#title' => t("Change content models within @collection_name", array('@collection_name' => $collection_object->label)),
); );
$form['change_cmodel']['current_content_model'] = array( $form['change_cmodel']['current_content_model'] = array(
@ -83,16 +80,14 @@ function islandora_change_content_models_form_validate($form, &$form_state) {
function islandora_change_content_models_form_submit($form, &$form_state) { function islandora_change_content_models_form_submit($form, &$form_state) {
module_load_include('inc', 'islandora_basic_collection', 'includes/CollectionPolicy'); module_load_include('inc', 'islandora_basic_collection', 'includes/CollectionPolicy');
module_load_include('inc', 'islandora', 'RestConnection');
$rest_connection = new RestConnection();
$current_content_model = $form_state['values']['current_content_model']; $current_content_model = $form_state['values']['current_content_model'];
$new_content_model = $form_state['values']['new_content_model']; $new_content_model = $form_state['values']['new_content_model'];
$collection_pid = $form_state['values']['collection_pid']; $collection_pid = $form_state['values']['collection_pid'];
$current_content_model_object = new FedoraObject($current_content_model, $rest_connection->repository); $current_content_model_object = islandora_object_load($current_content_model);
$collection_object = islandora_load_object($form_state['values']['collection_pid']);
$collection_object = new FedoraObject($form_state['values']['collection_pid'], $rest_connection->repository);
$collection_policy_datastream = $collection_object->getDatastream(variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY')); $collection_policy_datastream = $collection_object->getDatastream(variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY'));
$policy = new CollectionPolicy($collection_policy_datastream->content); $policy = new CollectionPolicy($collection_policy_datastream->content);

12
islandora_basic_collection/includes/child_collection.inc

@ -13,11 +13,9 @@
* @param string $this_collection_pid * @param string $this_collection_pid
* @return array * @return array
*/ */
function islandora_create_child_collection_form($form, &$form_state, $this_collection_pid) { function islandora_create_child_collection_form($form, &$form_state, $collection_object) {
module_load_include('inc', 'islandora', 'RestConnection');
module_load_include('inc', 'islandora_basic_collection', 'includes/CollectionPolicy'); module_load_include('inc', 'islandora_basic_collection', 'includes/CollectionPolicy');
$rest_connection = new RestConnection();
$collection_object = new FedoraObject($this_collection_pid, $rest_connection->repository);
$policy_datastream = $collection_object->getDatastream(variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY')); $policy_datastream = $collection_object->getDatastream(variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY'));
if (!$policy_datastream) { if (!$policy_datastream) {
$form['no_policy'] = array( $form['no_policy'] = array(
@ -56,14 +54,14 @@ function islandora_create_child_collection_form($form, &$form_state, $this_colle
} }
} }
} }
$collection_namespace = substr($this_collection_pid, 0, strpos($this_collection_pid, ":")); $collection_namespace = substr($collection_object->id, 0, strpos($collection_object->id, ":"));
$content_models = get_content_models_as_option_array(); $content_models = get_content_models_as_option_array();
unset($content_models['islandora:collectionCModel']); unset($content_models['islandora:collectionCModel']);
$form['child_creation']['titlebox'] = array( $form['child_creation']['titlebox'] = array(
'#type' => 'item', '#type' => 'item',
'#title' => t("Create new child collection within @collection", array('@collection' => $this_collection_pid)), '#title' => t("Create new child collection within @collection", array('@collection' => $collection_object->id)),
); );
$form['child_creation']['collection_name'] = array( $form['child_creation']['collection_name'] = array(
@ -102,7 +100,7 @@ function islandora_create_child_collection_form($form, &$form_state, $this_colle
$form['current'] = array( $form['current'] = array(
'#type' => 'hidden', '#type' => 'hidden',
'#value' => $this_collection_pid, '#value' => $collection_object->id,
); );
$form['child_creation']['content_models'] = array( $form['child_creation']['content_models'] = array(

53
islandora_basic_collection/includes/collection_management.inc

@ -11,23 +11,19 @@
* @param string $pid * @param string $pid
* @return array * @return array
*/ */
function get_represented_content_models($pid) { function get_represented_content_models($object) {
module_load_include('inc', 'islandora', 'RestConnection');
$rest_connection = new RestConnection();
require_once 'sites/all/libraries/tuque/RepositoryQuery.php';
$query = "select \$model \$title from <#ri> $query = "select \$model \$title from <#ri>
where (\$object <info:fedora/fedora-system:def/relations-external#isMemberOf> <info:fedora/$pid> where (\$object <info:fedora/fedora-system:def/relations-external#isMemberOf> <info:fedora/$object->id>
or \$object <info:fedora/fedora-system:def/relations-external#isMemberOfCollection> <info:fedora/$pid>) or \$object <info:fedora/fedora-system:def/relations-external#isMemberOfCollection> <info:fedora/$object->id>)
and \$object <info:fedora/fedora-system:def/model#hasModel> \$model and \$object <info:fedora/fedora-system:def/model#hasModel> \$model
and \$object <dc:title> \$title"; and \$object <dc:title> \$title";
$model_pids = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0'); $model_pids = $object->repository->ri->itqlQuery($query, 'unlimited', '0');
$represented_models = array(); $represented_models = array();
foreach ($model_pids as $model_pid) { foreach ($model_pids as $model_pid) {
if ($model_pid['model']['value'] && $model_pid['model']['value'] != 'fedora-system:FedoraObject-3.0') { if ($model_pid['model']['value'] && $model_pid['model']['value'] != 'fedora-system:FedoraObject-3.0') {
try { try {
$fedora_object = new FedoraObject($model_pid['model']['value'], $rest_connection->repository); $fedora_object = $object->repository->getObject($model_pid['model']['value']);
$content_model_title = $fedora_object->label; $content_model_title = $fedora_object->label;
$represented_models[$model_pid['model']['value']] = $model_pid['model']['value'] . ' ~ ' . $content_model_title; $represented_models[$model_pid['model']['value']] = $model_pid['model']['value'] . ' ~ ' . $content_model_title;
} }
@ -37,34 +33,26 @@ where (\$object <info:fedora/fedora-system:def/relations-external#isMemberOf> <i
return $represented_models; return $represented_models;
} }
function get_child_collections($collection_pid) { function get_child_collections($object) {
module_load_include('inc', 'islandora', 'RestConnection');
$rest_connection = new RestConnection();
require_once 'sites/all/libraries/tuque/RepositoryQuery.php';
$query = <<<EOD $query = <<<EOD
select \$object from <#ri> select \$object from <#ri>
where \$object <info:fedora/fedora-system:def/model#hasModel> <info:fedora/islandora:collectionCModel> where \$object <info:fedora/fedora-system:def/model#hasModel> <info:fedora/islandora:collectionCModel>
and \$object <info:fedora/fedora-system:def/relations-external#isMemberOfCollection> <info:fedora/$collection_pid> and \$object <info:fedora/fedora-system:def/relations-external#isMemberOfCollection> <info:fedora/$collection_pid>
EOD; EOD;
$lines = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0'); $lines = $object->repository->ri->itqlQuery($query, 'unlimited', '0');
$collection_pids = array_values(array_filter($lines)); $collection_pids = array_values(array_filter($lines));
return $collection_pids; return $collection_pids;
} }
function islandora_collections_get_collection_from_pid($pid) { function islandora_collections_get_collection_from_pid($object) {
module_load_include('inc', 'islandora', 'RestConnection');
$rest_connection = new RestConnection();
require_once 'sites/all/libraries/tuque/RepositoryQuery.php';
$query = 'select $parent from <#ri> $query = 'select $parent from <#ri>
where ($object <fedora-rels-ext:isMemberOf> $parent where ($object <fedora-rels-ext:isMemberOf> $parent
or $object <fedora-rels-ext:isMemberOfCollection> $parent) or $object <fedora-rels-ext:isMemberOfCollection> $parent)
and $object <dc:identifier> \'' . $pid . '\' and $object <dc:identifier> \'' . $pid . '\'
order by $object'; order by $object';
$object_pids = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0'); $object_pids = $object->repository->ri->itqlQuery($query, 'unlimited', '0');
$object_pids = array_values(array_filter($object_pids)); $object_pids = array_values(array_filter($object_pids));
return $object_pids; return $object_pids;
} }
@ -76,12 +64,9 @@ function islandora_collections_get_collection_from_pid($pid) {
* @param <type> $query * @param <type> $query
* @param <type> $query_format R * @param <type> $query_format R
*/ */
function get_related_items_as_array($collection_pid, $relationship = array('isMemberOfCollection'), $limit = 10000, $offset = 0, $active_objects_only = TRUE, $cmodel = NULL, $orderby = '$title') { function get_related_items_as_array($collection_object, $relationship = array('isMemberOfCollection'), $limit = 10000, $offset = 0, $active_objects_only = TRUE, $cmodel = NULL, $orderby = '$title') {
module_load_include('inc', 'islandora', 'RestConnection');
$rest_connection = new RestConnection();
require_once 'sites/all/libraries/tuque/RepositoryQuery.php';
global $user; $collection_pid = $collection_object->id;
// Not sure if this is necessary given that we should never be able to delete objects in a namespace that we don't have access to. // Not sure if this is necessary given that we should never be able to delete objects in a namespace that we don't have access to.
// if (!fedora_repository_access('view fedora repository', $collection_pid['object']['value'])) { // if (!fedora_repository_access('view fedora repository', $collection_pid['object']['value'])) {
@ -120,7 +105,7 @@ function get_related_items_as_array($collection_pid, $relationship = array('isMe
minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0> minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0>
order by ' . $orderby; order by ' . $orderby;
$results = $rest_connection->repository->ri->itqlQuery($query_string, $limit, $offset); $results = $collection_object->repository->ri->itqlQuery($query_string, $limit, $offset);
return $results; return $results;
} }
@ -170,16 +155,13 @@ function fedora_repository_access($permission, $pid) {
* @param type $include_fedora_system_content_models * @param type $include_fedora_system_content_models
* @return array * @return array
*/ */
function get_content_models_list($pid, $include_fedora_system_content_models = FALSE) { function get_content_models_list($object, $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(); $pids = array();
$query = 'select $object from <#ri> $query = 'select $object from <#ri>
where <info:fedora/' . $pid . '> <fedora-model:hasModel> $object where <info:fedora/' . $object->id . '> <fedora-model:hasModel> $object
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>'; and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>';
$content_models = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0'); $content_models = $object->repository->ri->itqlQuery($query, 'unlimited', '0');
if (empty($content_models)) { if (empty($content_models)) {
return $pids; return $pids;
@ -204,9 +186,8 @@ function get_content_models_list($pid, $include_fedora_system_content_models = F
* @return array * @return array
*/ */
function get_content_models_as_option_array() { function get_content_models_as_option_array() {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'includes/tuque');
$rest_connection = new RestConnection(); $rest_connection = new IslandoraTuque();
require_once 'sites/all/libraries/tuque/RepositoryQuery.php';
$restricted = variable_get('islandora_namespace_restriction_enforced', FALSE); $restricted = variable_get('islandora_namespace_restriction_enforced', FALSE);
$allowed_string = variable_get('islandora_pids_allowed', 'default: demo: changeme: islandora:'); $allowed_string = variable_get('islandora_pids_allowed', 'default: demo: changeme: islandora:');

16
islandora_basic_collection/includes/collection_manager_table.inc

@ -11,15 +11,12 @@
* @param string $collection_pid * @param string $collection_pid
* @return array * @return array
*/ */
function islandora_collection_table($collection_pid) { function islandora_collection_table($object) {
module_load_include('inc', 'islandora', 'RestConnection');
require_once 'sites/all/libraries/tuque/RepositoryQuery.php';
$rest_connection = new RestConnection();
$query = 'select $object $title from <#ri> $query = 'select $object $title from <#ri>
where ($object <info:fedora/fedora-system:def/relations-external#isMemberOf> <info:fedora/' . $collection_pid . '> where ($object <info:fedora/fedora-system:def/relations-external#isMemberOf> <info:fedora/' . $object->id . '>
or $object <info:fedora/fedora-system:def/relations-external#isMemberOfCollection> <info:fedora/' . $collection_pid . '>) or $object <info:fedora/fedora-system:def/relations-external#isMemberOfCollection> <info:fedora/' . $object->id . '>)
and $object <dc:title> $title'; and $object <dc:title> $title';
$results = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0'); $results = $object->repository->ri->itqlQuery($query, 'unlimited', '0');
$keys = array(); $keys = array();
$objects = array(); $objects = array();
foreach ($results as $result) { foreach ($results as $result) {
@ -87,14 +84,13 @@ function theme_islandora_basic_collection_management_form_table(array $element)
} }
function get_collections_as_option_array() { function get_collections_as_option_array() {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'includes/tuque');
require_once 'sites/all/libraries/tuque/RepositoryQuery.php';
$restricted = variable_get('islandora_namespace_restriction_enforced', FALSE); $restricted = variable_get('islandora_namespace_restriction_enforced', FALSE);
$allowed_string = variable_get('islandora_pids_allowed', 'default: demo: changeme: islandora:'); $allowed_string = variable_get('islandora_pids_allowed', 'default: demo: changeme: islandora:');
$namespaces = explode(':', $allowed_string); $namespaces = explode(':', $allowed_string);
$rest_connection = new RestConnection(); $rest_connection = new IslandoraTuque();
$query = 'select $object $title from <#ri> $query = 'select $object $title from <#ri>
where ($object <fedora-model:label> $title where ($object <fedora-model:label> $title
and $object <info:fedora/fedora-system:def/model#hasModel> <info:fedora/islandora:collectionCModel> and $object <info:fedora/fedora-system:def/model#hasModel> <info:fedora/islandora:collectionCModel>

28
islandora_basic_collection/includes/delete_collection.inc

@ -12,10 +12,11 @@
* *
* @return string * @return string
*/ */
function islandora_collection_deletion_form($form, &$form_state, $pid) { function islandora_collection_deletion_form($form, &$form_state, $object) {
module_load_include('inc', 'islandora_basic_collection', 'collection_manager_table'); module_load_include('inc', 'islandora_basic_collection', 'collection_manager_table');
$pid = $object->id;
$potential_collections = get_collections_as_option_array(); $potential_collections = get_collections_as_option_array();
$table = islandora_collection_table($pid); $table = islandora_collection_table($object);
$deletion_message = ($table) ? "Delete Members of this Collection" : "Delete Collection"; $deletion_message = ($table) ? "Delete Members of this Collection" : "Delete Collection";
$submit_text_message = ($table) ? "Delete selected objects" : "Delete collection"; $submit_text_message = ($table) ? "Delete selected objects" : "Delete collection";
@ -64,17 +65,15 @@ function islandora_collection_deletion_form($form, &$form_state, $pid) {
* @param array $form_state * @param array $form_state
*/ */
function islandora_collection_deletion_form_submit($form, &$form_state) { function islandora_collection_deletion_form_submit($form, &$form_state) {
global $user;
module_load_include('inc', 'islandora', 'RestConnection');
$rest_connection = new RestConnection();
$collection_pid = $form_state['values']['current']; $collection_pid = $form_state['values']['current'];
$fedora_object = new FedoraObject($collection_pid, $rest_connection->repository); $fedora_object = islandora_object_load($collection_object);
$parents = $fedora_object->relationships->get(NULL, 'isMemberOfCollection'); $parents = $fedora_object->relationships->get(NULL, 'isMemberOfCollection');
$parents = Islandora_collections_get_collection_from_pid($collection_pid); $parents = islandora_collections_get_collection_from_pid($fedora_object);
$collection_pid = $form_state['values']['current']; $collection_pid = $form_state['values']['current'];
if (isset($form_state['values']['delete_root']) && $form_state['values']['delete_root'] == 1) { if (isset($form_state['values']['delete_root']) && $form_state['values']['delete_root'] == 1) {
delete_root_collection($collection_pid); delete_root_collection($fedora_object);
drupal_goto("islandora/object/" . $parents[0]['parent']['value']); drupal_goto("islandora/object/" . $parents[0]['parent']['value']);
} }
@ -85,7 +84,7 @@ function islandora_collection_deletion_form_submit($form, &$form_state) {
if (!empty($child_collections)) { if (!empty($child_collections)) {
foreach ($child_collections as $child) { foreach ($child_collections as $child) {
$child_pids = get_related_items_as_array($child, 'isMemberOfCollection'); $child_pids = get_related_items_as_array(islandora_object_load($child), 'isMemberOfCollection');
if (!empty($child_pids)) { if (!empty($child_pids)) {
$populated_child_collections[] = $child; $populated_child_collections[] = $child;
} }
@ -103,7 +102,7 @@ function islandora_collection_deletion_form_submit($form, &$form_state) {
$pids_to_delete = array_diff($pids, $populated_child_collections); $pids_to_delete = array_diff($pids, $populated_child_collections);
foreach ($pids_to_delete as $pid_to_delete) { foreach ($pids_to_delete as $pid_to_delete) {
$rest_connection->repository->purgeObject($pid_to_delete); $fedora_object->repository->purgeObject($pid_to_delete);
} }
drupal_goto("islandora/object/" . $collection_pid); drupal_goto("islandora/object/" . $collection_pid);
} }
@ -113,12 +112,11 @@ function islandora_collection_deletion_form_submit($form, &$form_state) {
* *
* @param string $pid * @param string $pid
*/ */
function delete_root_collection($pid) { function delete_root_collection($object) {
module_load_include('inc', 'islandora', 'RestConnection');
try { try {
$rest_connection = new RestConnection(); $object->repository->purgeObject($object->id);
$rest_connection->repository->purgeObject($pid); } catch (RepositoryException $e) {
} catch (Exception $e) {
drupal_set_message(t("Collection '@pid' could not be deleted!", array('@pid' => $pid)), 'error'); drupal_set_message(t("Collection '@pid' could not be deleted!", array('@pid' => $pid)), 'error');
return; return;
} }

32
islandora_basic_collection/includes/manage_policies.inc

@ -13,26 +13,28 @@
* @param string $collection_pid * @param string $collection_pid
* @return type * @return type
*/ */
function islandora_manage_policies_form($form, &$form_state, $collection_pid) { function islandora_manage_policies_form($form, &$form_state, $collection_object) {
module_load_include('inc', 'islandora_basic_collection', 'includes/CollectionPolicy'); module_load_include('inc', 'islandora_basic_collection', 'includes/CollectionPolicy');
module_load_include('inc', 'islandora', 'RestConnection');
$rest_connection = new RestConnection();
$content_models = get_content_models_list($collection_pid); $repository = $collection_object->repository;
$content_models = get_content_models_list($collection_object);
$cm_options = array(); $cm_options = array();
$name_mappings = array(); $name_mappings = array();
foreach ($content_models as $content_model) { foreach ($content_models as $content_model) {
if ($content_model != "islandora:collectionCModel") { if ($content_model != "islandora:collectionCModel") {
$item = new FedoraObject($content_model, $rest_connection->repository); try {
$item = $repository->getObject($content_model);
$cm_name = $item->Label; $cm_name = $item->Label;
$cm_options[$content_model] = $cm_name; $cm_options[$content_model] = $cm_name;
} }
catch(RepositoryException $e) {}
}
} }
$namespace = substr($collection_pid, 0, strpos($collection_pid, ":")); $namespace = substr($collection_object->id, 0, strpos($collection_object->id, ":"));
$collection_policy_dsid = variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY'); $collection_policy_dsid = variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY');
$collection_object = new FedoraObject($collection_pid, $rest_connection->repository);
$collection_policy_string = $collection_object->getDatastream($collection_policy_dsid); $collection_policy_string = $collection_object->getDatastream($collection_policy_dsid);
$supported_collection_models = array(); $supported_collection_models = array();
@ -41,9 +43,9 @@ function islandora_manage_policies_form($form, &$form_state, $collection_pid) {
$supported_collection_models = $collection_policy->getContentModels(); $supported_collection_models = $collection_policy->getContentModels();
} }
$collection_namespace = substr($collection_pid, 0, strpos($collection_pid, ":")); $collection_namespace = substr($collection_object->id, 0, strpos($collection_object->id, ":"));
$represented_content_models = get_represented_content_models($collection_pid); $represented_content_models = get_represented_content_models($collection_object);
$collection_name = $collection_object->label; $collection_name = $collection_object->label;
$new_content_models = get_content_models_as_option_array(); $new_content_models = get_content_models_as_option_array();
$current_models_in_policy = array(); $current_models_in_policy = array();
@ -66,7 +68,7 @@ function islandora_manage_policies_form($form, &$form_state, $collection_pid) {
$form['manage_collection_policy']['titlebox'] = array( $form['manage_collection_policy']['titlebox'] = array(
'#type' => 'item', '#type' => 'item',
'#title' => t("Manage collection policy for @collection_pid", array('@collection_pid' => $collection_pid)), '#title' => t("Manage collection policy for @collection_title", array('@collection_title' => $collection_object->label)),
); );
$form ['manage_collection_policy']['add']['content_model_to_add'] = array( $form ['manage_collection_policy']['add']['content_model_to_add'] = array(
@ -86,12 +88,12 @@ function islandora_manage_policies_form($form, &$form_state, $collection_pid) {
$form['parent_collection'] = array( $form['parent_collection'] = array(
'#type' => 'hidden', '#type' => 'hidden',
'#value' => $collection_pid, '#value' => $collection_object->id,
); );
$form['collection_pid'] = array( $form['collection_pid'] = array(
'#type' => 'hidden', '#type' => 'hidden',
'#value' => $collection_pid, '#value' => $collection_object->id,
); );
$form['manage_collection_policy']['add']['submit'] = array( $form['manage_collection_policy']['add']['submit'] = array(
@ -135,11 +137,9 @@ function islandora_manage_policies_form_validate($form, &$form_state) {
* @param array $form_state * @param array $form_state
*/ */
function islandora_manage_policies_form_submit($form, &$form_state) { function islandora_manage_policies_form_submit($form, &$form_state) {
module_load_include('inc', 'islandora', 'RestConnection');
$rest_connection = new RestConnection();
$collection_pid = $form_state['values']['parent_collection']; $collection_pid = $form_state['values']['parent_collection'];
$collection_object = new FedoraObject($collection_pid, $rest_connection->repository); $collection_object = islandora_object_load($collection_pid);
$policy = $collection_object->getDatastream(variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY')); $policy = $collection_object->getDatastream(variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY'));
$collection_policy = '<?xml version="1.0" encoding="UTF-8"?> $collection_policy = '<?xml version="1.0" encoding="UTF-8"?>
<collection_policy xmlns="http://www.islandora.ca" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="" xsi:schemaLocation="http://www.islandora.ca http://syn.lib.umanitoba.ca/collection_policy.xsd"> <collection_policy xmlns="http://www.islandora.ca" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="" xsi:schemaLocation="http://www.islandora.ca http://syn.lib.umanitoba.ca/collection_policy.xsd">

14
islandora_basic_collection/includes/move_collection.inc

@ -13,10 +13,10 @@
* *
* @return string * @return string
*/ */
function islandora_collection_migrate_form($form, &$form_state, $pid) { function islandora_collection_migrate_form($form, &$form_state, $object) {
module_load_include('inc', 'islandora_basic_collection', 'collection_manager_table'); module_load_include('inc', 'islandora_basic_collection', 'collection_manager_table');
$potential_collections = get_collections_as_option_array(); $potential_collections = get_collections_as_option_array();
$table = islandora_collection_table($pid); $table = islandora_collection_table($object);
if (!$table) { if (!$table) {
$form['no_objects'] = array( $form['no_objects'] = array(
'#type' => 'item', '#type' => 'item',
@ -28,12 +28,12 @@ function islandora_collection_migrate_form($form, &$form_state, $pid) {
$form['migrate']['titlebox'] = array( $form['migrate']['titlebox'] = array(
'#type' => 'item', '#type' => 'item',
'#title' => t("Move objects from @collection_pid", array('@collection_pid' => $pid)), '#title' => t("Move objects from @collection_pid", array('@collection_pid' => $object->id)),
); );
$form['migrate']['new_collection'] = array( $form['migrate']['new_collection'] = array(
'#title' => t('New collection'), '#title' => t('New collection'),
'#description' => t("All content will be migrated from @pid to the selected collection", array('@pid' => $pid)), '#description' => t("All content will be migrated from @pid to the selected collection", array('@pid' => $object->id)),
'#type' => 'select', '#type' => 'select',
'#options' => $potential_collections, '#options' => $potential_collections,
); );
@ -42,7 +42,7 @@ function islandora_collection_migrate_form($form, &$form_state, $pid) {
$form['current'] = array( $form['current'] = array(
'#type' => 'hidden', '#type' => 'hidden',
'#value' => $pid, '#value' => $object->id,
); );
$form['migrate']['message'] = array( $form['migrate']['message'] = array(
@ -64,14 +64,12 @@ function islandora_collection_migrate_form($form, &$form_state, $pid) {
* @param array $form_state * @param array $form_state
*/ */
function islandora_collection_migrate_form_submit($form, &$form_state) { function islandora_collection_migrate_form_submit($form, &$form_state) {
module_load_include('inc', 'islandora', 'RestConnection');
$rest_connection = new RestConnection();
$pids = array_filter($form_state['values']['table']); $pids = array_filter($form_state['values']['table']);
$new_collection = $form_state['values']['new_collection']; $new_collection = $form_state['values']['new_collection'];
$current = $form_state['values']['current']; $current = $form_state['values']['current'];
foreach ($pids as $pid) { foreach ($pids as $pid) {
$fedora_object = new FedoraObject($pid, $rest_connection->repository); $fedora_object = islandora_object_load($pid);
$fedora_object->relationships->remove(FEDORA_RELS_EXT_URI, 'isMemberOfCollection', $current); $fedora_object->relationships->remove(FEDORA_RELS_EXT_URI, 'isMemberOfCollection', $current);
$fedora_object->relationships->add(FEDORA_RELS_EXT_URI, 'isMemberOfCollection', $new_collection); $fedora_object->relationships->add(FEDORA_RELS_EXT_URI, 'isMemberOfCollection', $new_collection);
} }

10
islandora_basic_collection/islandora_basic_collection.install

@ -5,12 +5,11 @@
* islandora_basic_collection.install * islandora_basic_collection.install
*/ */
function islandora_basic_collection_install() { function islandora_basic_collection_install() {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'includes/tuque');
global $user;
global $base_root; global $base_root;
try { try {
$rest_connection = new RestConnection($user); $rest_connection = new IslandoraTuque();
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(st('Unable to connect to the repository %e', array('%e' => $e)), 'error'); drupal_set_message(st('Unable to connect to the repository %e', array('%e' => $e)), 'error');
return; return;
@ -55,10 +54,9 @@ function islandora_basic_collection_install() {
} }
function islandora_basic_collection_uninstall() { function islandora_basic_collection_uninstall() {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'includes/tuque');
global $user;
try { try {
$rest_connection = new RestConnection($user); $rest_connection = new IslandoraTuque();
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(st('Unable to connect to the repository %e', array('%e' => $e)), 'error'); drupal_set_message(st('Unable to connect to the repository %e', array('%e' => $e)), 'error');
return; return;

41
islandora_basic_collection/islandora_basic_collection.module

@ -29,7 +29,7 @@
*/ */
function islandora_basic_collection_menu() { function islandora_basic_collection_menu() {
$items = array(); $items = array();
$items['islandora/object/%/manage/collection'] = array( $items['islandora/object/%islandora_object/manage/collection'] = array(
'title' => 'Collection', 'title' => 'Collection',
'page callback' => 'islandora_basic_collection_manage_object', 'page callback' => 'islandora_basic_collection_manage_object',
'page arguments' => array(2), 'page arguments' => array(2),
@ -72,7 +72,7 @@ function islandora_basic_collection_init() {
* @param type $object_id * @param type $object_id
* @return type * @return type
*/ */
function islandora_basic_collection_manage_object($object_id) { function islandora_basic_collection_manage_object($object) {
module_load_include('inc', 'islandora_basic_collection', 'includes/collection_management'); module_load_include('inc', 'islandora_basic_collection', 'includes/collection_management');
module_load_include('inc', 'islandora_basic_collection', 'includes/collection_manager_table'); module_load_include('inc', 'islandora_basic_collection', 'includes/collection_manager_table');
@ -95,7 +95,7 @@ function islandora_basic_collection_manage_object($object_id) {
'#type' => 'fieldset', '#type' => 'fieldset',
); );
$form['collection_manager']['create_child_collection']['form'] = drupal_get_form('islandora_create_child_collection_form', $object_id); $form['collection_manager']['create_child_collection']['form'] = drupal_get_form('islandora_create_child_collection_form', $object);
$form['collection_manager']['manage_policies'] = array( $form['collection_manager']['manage_policies'] = array(
'#type' => 'fieldset', '#type' => 'fieldset',
@ -104,7 +104,7 @@ function islandora_basic_collection_manage_object($object_id) {
'#collapsed' => TRUE, '#collapsed' => TRUE,
); );
$form['collection_manager']['manage_policies']['form'] = drupal_get_form('islandora_manage_policies_form', $object_id); $form['collection_manager']['manage_policies']['form'] = drupal_get_form('islandora_manage_policies_form', $object);
$form['collection_manager']['change_content_models'] = array( $form['collection_manager']['change_content_models'] = array(
'#type' => 'fieldset', '#type' => 'fieldset',
@ -113,7 +113,7 @@ function islandora_basic_collection_manage_object($object_id) {
'#collapsed' => TRUE, '#collapsed' => TRUE,
); );
$form['collection_manager']['change_content_models']['form'] = drupal_get_form('islandora_change_content_models_form', $object_id); $form['collection_manager']['change_content_models']['form'] = drupal_get_form('islandora_change_content_models_form', $object);
$form['collection_manager']['migrate_members'] = array( $form['collection_manager']['migrate_members'] = array(
'#type' => 'fieldset', '#type' => 'fieldset',
@ -122,7 +122,7 @@ function islandora_basic_collection_manage_object($object_id) {
'#collapsed' => TRUE, '#collapsed' => TRUE,
); );
$form['collection_manager']['migrate_members']['form'] = drupal_get_form('islandora_collection_migrate_form', $object_id); $form['collection_manager']['migrate_members']['form'] = drupal_get_form('islandora_collection_migrate_form', $object);
$form['collection_manager']['delete_members'] = array( $form['collection_manager']['delete_members'] = array(
'#type' => 'fieldset', '#type' => 'fieldset',
@ -131,7 +131,7 @@ function islandora_basic_collection_manage_object($object_id) {
'#collapsed' => TRUE, '#collapsed' => TRUE,
); );
$form['collection_manager']['delete_members']['form'] = drupal_get_form('islandora_collection_deletion_form', $object_id); $form['collection_manager']['delete_members']['form'] = drupal_get_form('islandora_collection_deletion_form', $object);
// Pass the form around any modules that are interested so that they can add their own collection management functions. // Pass the form around any modules that are interested so that they can add their own collection management functions.
module_invoke_all('islandora_collection_manager', $form); module_invoke_all('islandora_collection_manager', $form);
@ -145,15 +145,7 @@ function islandora_basic_collection_manage_object($object_id) {
* @param string $object_id * @param string $object_id
* @return boolean * @return boolean
*/ */
function islandora_basic_collection_access($object_id) { function islandora_basic_collection_access($fedora_object) {
module_load_include('inc', 'islandora', 'RestConnection');
global $user;
try {
$restConnection = new RestConnection($user);
$fedora_object = new FedoraObject($object_id, $restConnection->repository);
} catch (Exception $e) {
return FALSE;
}
if (!isset($fedora_object)) { if (!isset($fedora_object)) {
return FALSE; return FALSE;
} }
@ -250,16 +242,7 @@ function islandora_basic_collection_islandora_view_object($object, $user) {
* @return null|\FedoraObject * @return null|\FedoraObject
*/ */
function islandora_basic_collection_get_object($object_id) { function islandora_basic_collection_get_object($object_id) {
module_load_include('inc', 'islandora', 'RestConnection'); return islandora_object_load($object_id);
global $user;
try {
$restConnection = new RestConnection($user);
$fedora_object = new FedoraObject($object_id, $restConnection->repository);
} catch (Exception $e) {
//drupal_set_message(t('Error getting Islandora object %s', array('%s' => $object_id)), 'error');
return NULL;
}
return $fedora_object;
} }
/** /**
@ -280,14 +263,10 @@ function islandora_basic_collection_get_objects($object, $page_number = 1, $page
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0> minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0>
order by $title'; order by $title';
module_load_include('inc', 'islandora', 'RestConnection');
$query_array = array('query' => $query, 'type' => 'itql', 'pid' => $object->id, 'page_size' => $page_size, 'page_number' => $page_number); $query_array = array('query' => $query, 'type' => 'itql', 'pid' => $object->id, 'page_size' => $page_size, 'page_number' => $page_number);
drupal_alter('islandora_basic_collection_query', $query_array); drupal_alter('islandora_basic_collection_query', $query_array);
global $user;
try { try {
$restConnection = new RestConnection($user); $results = $object->repository->ri->query($query_array['query'], $query_array['type']);
$queryObject = new RepositoryQuery($restConnection->connection);
$results = $queryObject->query($query_array['query'], $query_array['type']);
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(t('Islandora Error getting related objects for %s', array('%s' => $object->id)), 'error'); drupal_set_message(t('Islandora Error getting related objects for %s', array('%s' => $object->id)), 'error');
return""; return"";

9
islandora_basic_image/islandora_basic_image.install

@ -9,12 +9,11 @@
* Implements hook_install * Implements hook_install
*/ */
function islandora_basic_image_install() { function islandora_basic_image_install() {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'includes/tuque');
global $user;
global $base_root; global $base_root;
try { try {
$restConnection = new RestConnection($user); $restConnection = new IslandoraTuque();
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(t('Unable to connect to the repository %e', array('%e' => $e)), 'error'); drupal_set_message(t('Unable to connect to the repository %e', array('%e' => $e)), 'error');
return; return;
@ -64,10 +63,10 @@ function islandora_basic_image_install() {
* Implements hook_uninstall * Implements hook_uninstall
*/ */
function islandora_basic_image_uninstall() { function islandora_basic_image_uninstall() {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'includes/tuque');
global $user; global $user;
try { try {
$restConnection = new RestConnection($user); $restConnection = new IslandoraTuque($user);
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(t('Unable to connect to the repository %e', array('%e' => $e)), 'error'); drupal_set_message(t('Unable to connect to the repository %e', array('%e' => $e)), 'error');
return; return;

28
islandora_basic_image/islandora_basic_image.module

@ -104,34 +104,6 @@ function islandora_basic_image_menu() {
return 'Another view returned by the image cmodel'; return 'Another view returned by the image cmodel';
} */ } */
/**
* determines whether or not to show this modules manage tab
* @global object $user
* @param string $object_id
* @return boolean
*/
function islandora_basic_image_access($object_id) {
module_load_include('inc', 'islandora', 'RestConnection');
global $user;
try {
$restConnection = new RestConnection($user);
$fedora_object = new FedoraObject($object_id, $restConnection->repository);
} catch (Exception $e) {
return FALSE;
}
if (!isset($fedora_object)) {
return FALSE;
}
$models = $fedora_object->models;
$cmodel_list = islandora_basic_image_islandora_get_types();
foreach ($fedora_object->models as $model) {
if (isset($cmodel_list[$model])) {
return user_access(FEDORA_MODIFY_STATE);
}
}
return FALSE;
}
function islandora_basic_image_init() { function islandora_basic_image_init() {
if (path_is_admin(current_path())) { if (path_is_admin(current_path())) {
drupal_add_css(drupal_get_path('module', 'islandora_basic_image') . '/css/islandora_basic_image.admin.css'); drupal_add_css(drupal_get_path('module', 'islandora_basic_image') . '/css/islandora_basic_image.admin.css');

Loading…
Cancel
Save