Browse Source

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

pull/120/merge
Paul Pound 13 years ago
parent
commit
a07117b248
  1. 24
      islandora_basic_collection/includes/ChildCollection.inc
  2. 93
      islandora_basic_collection/includes/CollectionManagement.inc
  3. 12
      islandora_basic_collection/includes/DeleteCollection.inc
  4. 15
      islandora_basic_collection/includes/ManagePolicies.inc
  5. 9
      islandora_basic_collection/includes/MoveCollection.inc
  6. 7
      islandora_basic_image/islandora_basic_image.install

24
islandora_basic_collection/includes/ChildCollection.inc

@ -6,11 +6,12 @@
*/ */
/** /**
* * Create the child collection creation form
* @param type $form *
* @param type $form_state * @param array $form
* @param type $this_collection_pid * @param array $form_state
* @return string * @param string $this_collection_pid
* @return array
*/ */
function islandora_create_child_collection_form($form, &$form_state, $this_collection_pid) { function islandora_create_child_collection_form($form, &$form_state, $this_collection_pid) {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
@ -38,7 +39,7 @@ function islandora_create_child_collection_form($form, &$form_state, $this_colle
); );
$form['child_creation']['collection_name'] = array( $form['child_creation']['collection_name'] = array(
'#title' => "Collection Name", '#title' => "Collection name",
'#type' => 'textfield', '#type' => 'textfield',
'#size' => 25, '#size' => 25,
'#description' => t("Human readable name for this collection"), '#description' => t("Human readable name for this collection"),
@ -54,7 +55,7 @@ function islandora_create_child_collection_form($form, &$form_state, $this_colle
if (!$restricted) { if (!$restricted) {
$form['child_creation']['collection_namespace'] = array( $form['child_creation']['collection_namespace'] = array(
'#title' => "Collection Namespace", '#title' => "Collection namespace",
'#type' => 'textfield', '#type' => 'textfield',
'#size' => 15, '#size' => 15,
'#default_value' => $collection_namespace, '#default_value' => $collection_namespace,
@ -63,7 +64,7 @@ function islandora_create_child_collection_form($form, &$form_state, $this_colle
} }
else { else {
$form['child_creation']['collection_namespace'] = array( $form['child_creation']['collection_namespace'] = array(
'#title' => "Collection Namespace", '#title' => "Collection namespace",
'#type' => 'select', '#type' => 'select',
'#options' => $allowed, '#options' => $allowed,
'#default_value' => 'default', '#default_value' => 'default',
@ -95,6 +96,13 @@ function islandora_create_child_collection_form_validate($form, &$form_state) {
} }
/**
* Submit handler for child collection creation form
*
* @global type $base_url
* @param array $form
* @param array $form_state
*/
function islandora_create_child_collection_form_submit($form, &$form_state) { function islandora_create_child_collection_form_submit($form, &$form_state) {
global $base_url; global $base_url;
module_load_include('inc', 'islandora', '/includes/islandora.ingest'); module_load_include('inc', 'islandora', '/includes/islandora.ingest');

93
islandora_basic_collection/includes/CollectionManagement.inc

@ -3,30 +3,9 @@
/** /**
* @file * @file
* CollectionManagement.inc * CollectionManagement.inc
* A set of useful functions to help with collection management
*/ */
/**
* deletes PID
* @param string $pid
*/
function delete_objects_as_batch($pid) {
module_load_include('inc', 'islandora', 'RestConnection');
$rest_connection = new RestConnection();
$name = $user->name;
$rest_connection->repository->purgeObject($pid);
}
/**
* removes association of this object to this collection
* @param string $pid
*/
function remove_collection_association($pid, $collection_pid) {
module_load_include('inc', 'islandora', 'RestConnection');
$rest_connection = new RestConnection();
$fedora_object = new FedoraObject($pid, $rest_connection->repository);
$fedora_object->relationships->remove(NULL, 'isMemberOfCollection', $collection_pid);
}
/** /**
* returns content models associated with all objects in a collection * returns content models associated with all objects in a collection
* @param string $pid * @param string $pid
@ -102,7 +81,9 @@ function get_related_items_as_array($collection_pid, $relationship = array('isMe
require_once 'sites/all/libraries/tuque/RepositoryQuery.php'; require_once 'sites/all/libraries/tuque/RepositoryQuery.php';
global $user; global $user;
// if (!fedora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) {
// 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'])) {
// drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied."), 'error'); // drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied."), 'error');
// return array(); // return array();
// } // }
@ -143,6 +124,45 @@ function get_related_items_as_array($collection_pid, $relationship = array('isMe
return $results; 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) {
$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 {
return FALSE;
}
}
/** /**
* gets the name of the content models for the specified object * 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 * this now returns an array of pids as in Fedora 3 we can have more then one Cmodel for an object
@ -218,29 +238,4 @@ function get_content_models_as_option_array() {
} }
return $options; return $options;
} }
function get_content_models($collection_pid, $show_error = TRUE) {
module_load_include('inc', 'islandora', 'RestConnection');
$rest_connection = new RestConnection();
$collection_stream = $this->getCollectionPolicyStream($collection_pid);
$collection_object = new FedoraObject($collection_pid, $rest_connection->repository);
$collection_stream = $collection_object->getDatastream('COLLECTION_POLICY');
try {
$xml = new SimpleXMLElement($collection_stream);
} catch (Exception $e) {
if ($show_error) {
drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage()))), 'error');
}
return NULL;
}
foreach ($xml->contentmodels->contentmodel as $content_model) {
$content_model_object = new ContentModel();
$content_model_object->contentModelDsid = $content_model->dsid;
$content_model_object->contentModelPid = $content_model->pid;
$content_model_object->pidNamespace = $content_model->pidNamespace;
$content_model_object->contentModelName = $content_model['name'];
$models[] = $content_model_object;
}
return $models;
}

12
islandora_basic_collection/includes/DeleteCollection.inc

@ -56,6 +56,13 @@ function islandora_collection_deletion_form($form, &$form_state, $pid) {
return $form; return $form;
} }
/**
* Submit handler for object deletion form in the collection manager.
*
* @global type $user
* @param array $form
* @param array $form_state
*/
function islandora_collection_deletion_form_submit($form, &$form_state) { function islandora_collection_deletion_form_submit($form, &$form_state) {
global $user; global $user;
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
@ -101,6 +108,11 @@ function islandora_collection_deletion_form_submit($form, &$form_state) {
drupal_goto("islandora/object/" . $collection_pid); drupal_goto("islandora/object/" . $collection_pid);
} }
/**
* Deletes the collection object
*
* @param string $pid
*/
function delete_root_collection($pid) { function delete_root_collection($pid) {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
try { try {

15
islandora_basic_collection/includes/ManagePolicies.inc

@ -6,10 +6,11 @@
*/ */
/** /**
* * Create form to collection policy management feature
* @param type $form *
* @param type $form_state * @param array $form
* @param type $collection_pid * @param array $form_state
* @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_pid) {
@ -121,6 +122,12 @@ function islandora_manage_policies_form_validate($form, &$form_state) {
} }
/**
* Submit handler for collection policy management form
*
* @param array $form
* @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'); module_load_include('inc', 'islandora', 'RestConnection');
$rest_connection = new RestConnection(); $rest_connection = new RestConnection();

9
islandora_basic_collection/includes/MoveCollection.inc

@ -6,7 +6,8 @@
*/ */
/** /**
* * Create object migration form for the collection manager
*
* @param array $form_state * @param array $form_state
* @param string $pid * @param string $pid
* *
@ -56,6 +57,12 @@ function islandora_collection_migrate_form($form, &$form_state, $pid) {
return $form; return $form;
} }
/**
* Submit handler for object migration form
*
* @param array $form
* @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'); module_load_include('inc', 'islandora', 'RestConnection');
$rest_connection = new RestConnection(); $rest_connection = new RestConnection();

7
islandora_basic_image/islandora_basic_image.install

@ -1,7 +1,8 @@
<?php <?php
/** /**
* @file islandora-basic-image.install * @file
* islandora-basic-image.install
*/ */
/** /**
@ -58,6 +59,10 @@ function islandora_basic_image_install() {
} }
} }
/**
* Implements hook_uninstall
*/
function islandora_basic_image_uninstall() { function islandora_basic_image_uninstall() {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
global $user; global $user;

Loading…
Cancel
Save