diff --git a/islandora_basic_collection/includes/ChildCollection.inc b/islandora_basic_collection/includes/ChildCollection.inc index 40955402..492d7ff1 100644 --- a/islandora_basic_collection/includes/ChildCollection.inc +++ b/islandora_basic_collection/includes/ChildCollection.inc @@ -6,11 +6,12 @@ */ /** - * - * @param type $form - * @param type $form_state - * @param type $this_collection_pid - * @return string + * Create the child collection creation form + * + * @param array $form + * @param array $form_state + * @param string $this_collection_pid + * @return array */ function islandora_create_child_collection_form($form, &$form_state, $this_collection_pid) { 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( - '#title' => "Collection Name", + '#title' => "Collection name", '#type' => 'textfield', '#size' => 25, '#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) { $form['child_creation']['collection_namespace'] = array( - '#title' => "Collection Namespace", + '#title' => "Collection namespace", '#type' => 'textfield', '#size' => 15, '#default_value' => $collection_namespace, @@ -63,7 +64,7 @@ function islandora_create_child_collection_form($form, &$form_state, $this_colle } else { $form['child_creation']['collection_namespace'] = array( - '#title' => "Collection Namespace", + '#title' => "Collection namespace", '#type' => 'select', '#options' => $allowed, '#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) { global $base_url; module_load_include('inc', 'islandora', '/includes/islandora.ingest'); diff --git a/islandora_basic_collection/includes/CollectionManagement.inc b/islandora_basic_collection/includes/CollectionManagement.inc index 8cfcc046..1df57e28 100644 --- a/islandora_basic_collection/includes/CollectionManagement.inc +++ b/islandora_basic_collection/includes/CollectionManagement.inc @@ -3,30 +3,9 @@ /** * @file * 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 * @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'; 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'); // return array(); // } @@ -143,6 +124,45 @@ 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) { + $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 * 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; -} - - 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; - } \ No newline at end of file +} \ No newline at end of file diff --git a/islandora_basic_collection/includes/DeleteCollection.inc b/islandora_basic_collection/includes/DeleteCollection.inc index 42821e37..990f84fd 100644 --- a/islandora_basic_collection/includes/DeleteCollection.inc +++ b/islandora_basic_collection/includes/DeleteCollection.inc @@ -56,6 +56,13 @@ function islandora_collection_deletion_form($form, &$form_state, $pid) { 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) { global $user; 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); } +/** + * Deletes the collection object + * + * @param string $pid + */ function delete_root_collection($pid) { module_load_include('inc', 'islandora', 'RestConnection'); try { diff --git a/islandora_basic_collection/includes/ManagePolicies.inc b/islandora_basic_collection/includes/ManagePolicies.inc index 60f4d0ce..413e6fa8 100644 --- a/islandora_basic_collection/includes/ManagePolicies.inc +++ b/islandora_basic_collection/includes/ManagePolicies.inc @@ -6,10 +6,11 @@ */ /** - * - * @param type $form - * @param type $form_state - * @param type $collection_pid + * Create form to collection policy management feature + * + * @param array $form + * @param array $form_state + * @param string $collection_pid * @return type */ 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) { module_load_include('inc', 'islandora', 'RestConnection'); $rest_connection = new RestConnection(); diff --git a/islandora_basic_collection/includes/MoveCollection.inc b/islandora_basic_collection/includes/MoveCollection.inc index e5e3aa7a..e429d3a5 100644 --- a/islandora_basic_collection/includes/MoveCollection.inc +++ b/islandora_basic_collection/includes/MoveCollection.inc @@ -6,7 +6,8 @@ */ /** - * + * Create object migration form for the collection manager + * * @param array $form_state * @param string $pid * @@ -56,6 +57,12 @@ function islandora_collection_migrate_form($form, &$form_state, $pid) { return $form; } +/** + * Submit handler for object migration form + * + * @param array $form + * @param array $form_state + */ function islandora_collection_migrate_form_submit($form, &$form_state) { module_load_include('inc', 'islandora', 'RestConnection'); $rest_connection = new RestConnection(); diff --git a/islandora_basic_image/islandora_basic_image.install b/islandora_basic_image/islandora_basic_image.install index f900d247..739d9074 100644 --- a/islandora_basic_image/islandora_basic_image.install +++ b/islandora_basic_image/islandora_basic_image.install @@ -1,7 +1,8 @@