diff --git a/CollectionClass.inc b/CollectionClass.inc
index bd44bbe8..fe5528eb 100644
--- a/CollectionClass.inc
+++ b/CollectionClass.inc
@@ -102,7 +102,7 @@ class CollectionClass {
function getRelatedItems($pid, $query_string = NULL, $limit = NULL, $offset = NULL) {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
- if (!fedora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid)) {
+ if (!fedora_repository_check_perm(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid)) {
drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied."), 'error');
return ' ';
}
@@ -321,7 +321,7 @@ class CollectionClass {
* @return type
*/
function getAndDoRules($file, $mimetype, $pid, $dsid) {
- if (!user_access('ingest new fedora objects')) {
+ if (!fedora_repository_check_perm('ingest new fedora objects', $pid)) {
drupal_set_message(t('You do not have permission to ingest objects.'));
return FALSE;
}
@@ -586,7 +586,7 @@ class CollectionClass {
function getIngestInterface() {
module_load_include('inc', 'fedora_repository', 'CollectionPolicy');
$collectionPolicyExists = $this->collectionObject->getMimeType($this->pid, CollectionPolicy::getDefaultDSID());
- if (user_access(ObjectHelper :: $INGEST_FEDORA_OBJECTS) && $collectionPolicyExists) {
+ if (fedora_repository_check_perm(ObjectHelper :: $INGEST_FEDORA_OBJECTS, $this->pid) && $collectionPolicyExists) {
if (!empty($collectionPolicyExists)) {
$allow = TRUE;
if (module_exists('fedora_fesl')) {
@@ -604,66 +604,6 @@ class CollectionClass {
return $ingestObject;
}
- /**
- * Unfortunate function, I know...
- *
- * Does just what it says: Hacks the default Drupal pager such that it might
- * be rendered, likely with: theme('pager', array(), $per_page, $pager_name)
- * (I reccomend seeing the real documentation for more detail, but the first
- * array can be a list of the tags to use for first, previous, next and last
- * (text in the pager), I don't believe per_page is actually used in the theme
- * function, and $pager_name is an integer used to identify the pager (such
- * that there can be more than one--that is, tracking different lists of
- * content on a single page. You can render the exact same pager multiple
- * times, say if you want one at the top and bottom of a list, using the same
- * ID/pager_name.
- *
- * @global $pager_total array
- * Numerically indexed array, where keys are the $pager_names and values
- * are the number of pages in the given set, based on: ceil($total_items/$per_page);
- * @global $pager_page_array array
- * Numerically indexed array, where keys are the $pager_names and values
- * are the page selected in the relevant set.
- * @param $pager_name int
- * An integer to identify the pager to affect. Do note that paging in using
- * this function will add the 'page' HTTP GET parameter to the URL, with
- * the value containing a comma-separated list with max($pager_name + 1)
- * values--that is, if you create a single pager named '10', the 'next'
- * link will look something like: 0,0,0,0,0,0,0,0,0,0,1
- * @param $per_page int
- * An integer representing the number of items per page.
- * @param $total_items int
- * An integer representing the total number of items in the set.
- * @return int
- * An integer representing what the current page should be.
- */
- protected static function hackPager($pager_name, $per_page = NULL, $total_items = NULL) {
- global $pager_total, $pager_page_array;
-
- if ($per_page !== NULL && $total_items !== NULL) {
- $pager_total[$pager_name] = ceil($total_items / $per_page);
- }
-
- //XXX: Don't know that this is neccessary, to try to load all the time, or
- // whether Drupal will load it automatically somewhere... Docs seems a
- // a little sparse.
- $page_info = explode(',', isset($_GET['page']) ? $_GET['page'] : '');
- $page = $page_info[$pager_name];
- if ($page < 0) {
- $page = 0;
- }
-
- if (!isset($pager_page_array)) {
- $pager_page_array = pager_load_array($page, $pager_name, $page_info);
- }
- else {
- $pager_page_array = pager_load_array($page, $pager_name, $pager_page_array);
- }
-
- $page = $pager_page_array[$pager_name];
- return $page;
- }
-
/**
* Assemble results in a somewhat more logical manner...
*
@@ -683,10 +623,11 @@ class CollectionClass {
* list of items, and another pager.
*/
public static function assembleCollectionView($sparql_results) {
+ module_load_include('inc', 'fedora_repository', 'PagerSetup');
$per_page = 20; //XXX: Make this configurable.
$pager_name = 0;
$total = count($sparql_results);
- $pager_page = self::hackPager($pager_name, $per_page, $total);
+ $pager_page = fedora_repository_setup_pager($pager_name, $per_page, $total);
$max_title_length = 60;
$results = array();
diff --git a/ObjectDetails.inc b/ObjectDetails.inc
index 38409615..30121080 100644
--- a/ObjectDetails.inc
+++ b/ObjectDetails.inc
@@ -72,6 +72,11 @@ function fedora_repository_object_details_XSLT($item) {
}
$xmlstr = $item->get_datastream_dissemination($dsid);
+ $default_to_dc = FALSE;
+ if (empty($xmlstr) && variable_get('islandora_object_details_xslt_default_dc', FALSE) && $dsid != 'DC' && $dsid != 'QDC') {
+ $xmlstr = $item->get_datastream_dissemination('DC');
+ $default_to_dc = TRUE;
+ }
if (empty($xmlstr)) {
return t('Error - could not find datastream @dsid on object @pid
Please contact the site administrator.',
array('@dsid' => $dsid, '@pid' => $item->pid));
@@ -88,7 +93,13 @@ function fedora_repository_object_details_XSLT($item) {
$proc->setParameter('', 'path', $path);
$input = NULL;
- $xsl_file = variable_get('islandora_object_details_xslt_sheet', 'sites/all/modules/islandora/object_details_xslts/convertQDC.xsl');
+ if (!$default_to_dc) {
+ $xsl_file = variable_get('islandora_object_details_xslt_sheet', 'sites/all/modules/islandora/object_details_xslts/convertQDC.xsl');
+ }
+ else {
+ $xsl_file = 'sites/all/modules/islandora/object_details_xslts/convertQDC.xsl';
+ }
+
// set an error message in case xslt parsing fails
$output = t("Failed to parse xslt file at @xsltFile", array('@xsltFile' => $xsl_file));
if (is_readable($xsl_file)) {
@@ -126,7 +137,11 @@ function fedora_repository_object_details_table($item) {
$dsid = array_key_exists('QDC', $item->get_datastreams_list_as_array()) ? 'QDC' : 'DC';
}
$xmlstr = $item->get_datastream_dissemination($dsid);
-
+
+ if (empty($xmlstr) && variable_get('islandora_object_details_table_default_dc', FALSE) && $dsid != 'DC' && $dsid != 'QDC') {
+ $dsid = 'DC';
+ $xmlstr = $item->get_datastream_dissemination($dsid);
+ }
if (empty($xmlstr)) {
return t('Error - could not find datastream @dsid on object @pid
Please contact the site administrator.',
array('@dsid' => $dsid, '@pid' => $item->pid));
@@ -136,7 +151,7 @@ function fedora_repository_object_details_table($item) {
$headers = array(
array(
- 'data' => t('Metadata'),
+ 'data' => t('Metadata (@dsid)', array('@dsid' => $dsid)),
'colspan' => 2,
),
);
@@ -191,6 +206,11 @@ function fedora_repository_object_details_XSLT_config() {
'#default_value' => variable_get('islandora_object_details_xslt_datastream', 'DC'),
'#required' => TRUE,
);
+ $form['config']['default_dc'] = array(
+ '#type' => 'checkbox',
+ '#title' => t("If the datastream to transform is unavailable, attempt to transform using the DC datastream"),
+ '#default_value' => variable_get('islandora_object_details_xslt_default_dc', FALSE),
+ );
$form['submit'] = array(
'#type' => 'submit',
'#value' => t("Submit"),
@@ -210,6 +230,7 @@ function fedora_repository_object_details_XSLT_config_submit($form, &$form_state
variable_set('islandora_object_details_display_table', 'xslt');
variable_set('islandora_object_details_xslt_sheet', $form_state['values']['xslt']);
variable_set('islandora_object_details_xslt_datastream', $form_state['values']['dsid']);
+ variable_set('islandora_object_details_xslt_default_dc', $form_state['values']['default_dc']);
drupal_set_message('Object Details view has been set to XSLT and your configuration has been saved');
}
@@ -253,6 +274,11 @@ function fedora_repository_object_details_table_config() {
'#default_value' => variable_get('islandora_object_details_table_datastream', 'DC'),
'#required' => TRUE,
);
+ $form['config']['default_dc'] = array(
+ '#type' => 'checkbox',
+ '#title' => t("If the datastream to transform is unavailable, attempt to transform using the DC datastream"),
+ '#default_value' => variable_get('islandora_object_details_table_default_dc', FALSE),
+ );
$form['submit'] = array(
'#type' => 'submit',
'#value' => t("Submit"),
@@ -272,5 +298,6 @@ function fedora_repository_object_details_table_config() {
function fedora_repository_object_details_table_config_submit($form, &$form_state) {
variable_set('islandora_object_details_display_table', 'table');
variable_set('islandora_object_details_table_datastream', $form_state['values']['dsid']);
+ variable_set('islandora_object_details_table_default_dc', $form_state['values']['default_dc']);
drupal_set_message('Object Details view has been set to Table and your configuration has been saved');
}
diff --git a/ObjectHelper.inc b/ObjectHelper.inc
index 698e5d42..ad196f81 100644
--- a/ObjectHelper.inc
+++ b/ObjectHelper.inc
@@ -93,7 +93,7 @@ class ObjectHelper {
return ' ';
}
- if (!fedora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) {
+ if (!fedora_repository_check_perm(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) {
drupal_set_message(t("You do not have access Fedora objects within the attempted namespace."), 'error');
drupal_access_denied();
return ' ';
@@ -298,7 +298,7 @@ class ObjectHelper {
drupal_set_message(t('You must specify an object pid and datastream ID.'), 'error');
return '';
}
- if (!fedora_repository_access(ObjectHelper :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) {
+ if (!fedora_repository_check_perm(ObjectHelper :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) {
drupal_set_message(t('You do not have the appropriate permissions'), 'error');
return;
}
@@ -333,7 +333,7 @@ class ObjectHelper {
drupal_set_message(t('You must specify an object pid and datastream ID.'), 'error');
return '';
}
- if (!fedora_repository_access(ObjectHelper :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) {
+ if (!fedora_repository_check_perm(ObjectHelper :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) {
drupal_set_message(t('You do not have the appropriate permissions'), 'error');
return;
}
@@ -368,7 +368,7 @@ class ObjectHelper {
$item = new Fedora_Item($pid);
$purge_image = ' ';
- if (user_access(ObjectHelper :: $PURGE_FEDORA_OBJECTSANDSTREAMS)) {
+ if (fedora_repository_check_perm(ObjectHelper :: $PURGE_FEDORA_OBJECTSANDSTREAMS, $pid)) {
$allow = TRUE;
if (module_exists('fedora_fesl')) {
$allow = fedora_fesl_check_roles($pid, 'write');
@@ -388,7 +388,7 @@ class ObjectHelper {
// Add an icon to replace a datastream
// @TODO Note: using l(theme_image(..), ...); for these image links (and other links) may remove the need to have clean urls enabled.
$replace_image = ' ';
- if (user_access(ObjectHelper :: $ADD_FEDORA_STREAMS)) {
+ if (fedora_repository_check_perm(ObjectHelper :: $ADD_FEDORA_STREAMS, $pid)) {
$allow = TRUE;
if (module_exists('fedora_fesl')) {
$allow = fedora_fesl_check_roles($pid, 'write');
@@ -533,7 +533,7 @@ class ObjectHelper {
$dsid = array_key_exists('QDC', $ds_list) ? 'QDC' : 'DC';
$path = drupal_get_path('module', 'fedora_repository');
- if (user_access(ObjectHelper :: $EDIT_FEDORA_METADATA)) {
+ if (fedora_repository_check_perm(ObjectHelper :: $EDIT_FEDORA_METADATA, $pid)) {
$allow = TRUE;
if (module_exists('fedora_fesl')) {
$allow = fedora_fesl_check_roles($pid, 'write');
@@ -573,7 +573,7 @@ class ObjectHelper {
$dataStreamBody = '';
$fedoraItem = new Fedora_Item($object_pid);
- if (user_access(ObjectHelper :: $VIEW_DETAILED_CONTENT_LIST)) {
+ if (fedora_repository_check_perm(ObjectHelper :: $VIEW_DETAILED_CONTENT_LIST, $object_pid)) {
$availableDataStreamsText = 'Detailed List of Content';
$mainStreamLabel = NULL;
@@ -606,7 +606,7 @@ class ObjectHelper {
$dataStreamBody = theme('table', $headers, $DSs);
//if they have access let them add a datastream
- if (user_access(ObjectHelper::$ADD_FEDORA_STREAMS) && //If allowed throw Drupal
+ if (fedora_repository_check_perm(ObjectHelper::$ADD_FEDORA_STREAMS, $object_pid) && //If allowed throw Drupal
((module_exists('fedora_fesl') && fedora_fesl_check_roles($object_pid, 'write')) || //And allowed throw FESL
!module_exists('fedora_fesl'))) { //Or not using FESL, draw the add datastream form.
$dataStreamBody .= drupal_get_form('add_stream_form', $object_pid);
@@ -673,36 +673,6 @@ class ObjectHelper {
return $cmodels;
}
- /**
- * 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($op, $pid = NULL, $as_user = NULL) {
- $returnValue = FALSE;
-
- if ($pid == NULL) {
- $pid = variable_get('fedora_repository_pid', 'islandora:root');
- }
-
- $isRestricted = variable_get('fedora_namespace_restriction_enforced', TRUE);
- $namespace_access = NULL;
- if (!$isRestricted) {
- $namespace_access = TRUE;
- }
- else {
- $pid_namespace = substr($pid, 0, strpos($pid, ':') + 1); //Get the namespace (with colon)
- $allowed_namespaces = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: '));
-
- $namespace_access = in_array($pid_namespace, $allowed_namespaces);
- }
-
- return ($namespace_access && user_access($op, $as_user));
- }
-
/**
* Get the query to find parent objects.
*
@@ -795,7 +765,7 @@ class ObjectHelper {
* @return boolean
*/
function get_and_do_datastream_rules($pid, $dsid, $file = '') {
- if (!user_access('ingest new fedora objects')) {
+ if (!fedora_repository_check_perm('ingest new fedora objects', $pid)) {
drupal_set_message(t('You do not have permission to add datastreams.'));
return FALSE;
}
@@ -810,6 +780,7 @@ class ObjectHelper {
* Get a tree of related pids - for the basket functionality
*
* FIXME: This doesn't actually get a tree...
+ * XXX: Is this still required, without basket being in?
*
* @param type $pid
* @return type
diff --git a/PagerSetup.inc b/PagerSetup.inc
new file mode 100644
index 00000000..c4fb7c32
--- /dev/null
+++ b/PagerSetup.inc
@@ -0,0 +1,62 @@
+get_datastream_dissemination('RELS-EXT');
- if ($literal_value == RELS_TYPE_URI && strpos($object, $f_prefix) !== 0) {
- $object = $f_prefix . $object;
- }
-
$relsextxml->loadXML($relsext);
$description = $relsextxml->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'Description');
if ($description->length == 0) {
@@ -333,18 +329,26 @@ RDF;
}
$description = $description->item(0);
- // Create the new relationship node.
- $newrel = $relsextxml->createElementNS($namespaceURI, $relationship);
+ // Casting a string to an array gives an array containing the string, and
+ // casting an array to an array does nothing.
+ foreach ((array)$object as $obj) {
+ if ($literal_value == RELS_TYPE_URI && strpos($obj, $f_prefix) !== 0) {
+ $obj = $f_prefix . $obj;
+ }
+
+ // Create the new relationship node.
+ $newrel = $relsextxml->createElementNS($namespaceURI, $relationship);
- $this->buildRelsStatement($newrel, $object, $literal_value);
+ $this->buildRelsStatement($newrel, $obj, $literal_value);
- $description->appendChild($newrel);
+ $description->appendChild($newrel);
+ }
return $this->modify_datastream($relsextxml->saveXML(), 'RELS-EXT', "Fedora Object-to-Object Relationship Metadata", 'application/rdf+xml');
}
/**
- * Extension of add_relationship, which acts on RELS-INT.
+ * Extension of add_relationship(), which acts on RELS-INT.
*
* @param $dsid
* A string containing either the base dsid (EXAMPLE)
@@ -367,9 +371,6 @@ RDF;
$rels_text = $this->get_datastream_dissemination('RELS-INT');
- if ($literal_value == RELS_TYPE_URI && strpos($object, $f_prefix) !== 0) {
- $object = $f_prefix . $object;
- }
if (strpos($dsid, $f_prefix) !== 0) {
$dsid = $f_prefix . $this->pid . '/' . $dsid;
}
@@ -391,12 +392,18 @@ RDF;
$relsxml->documentElement->appendChild($description);
}
- // Create the new relationship node.
- $newrel = $relsxml->createElementNS($namespaceURI, $relationship);
+ foreach ((array)$object as $obj) {
+ if ($literal_value == RELS_TYPE_URI && strpos($obj, $f_prefix) !== 0) {
+ $obj = $f_prefix . $object;
+ }
- $this->buildRelsStatement($newrel, $object, $literal_value);
+ // Create the new relationship node.
+ $newrel = $relsxml->createElementNS($namespaceURI, $relationship);
- $description->appendChild($newrel);
+ $this->buildRelsStatement($newrel, $obj, $literal_value);
+
+ $description->appendChild($newrel);
+ }
return $this->modify_datastream($relsxml->saveXML(), 'RELS-INT', "Fedora Datastream Relationship Metadata", 'application/rdf+xml');
}
diff --git a/fedora_repository.api.php b/fedora_repository.api.php
index 724078b2..190c9ec1 100644
--- a/fedora_repository.api.php
+++ b/fedora_repository.api.php
@@ -95,6 +95,8 @@ function hook_required_fedora_objects() {
* Override ingest permissions.
* (from islandora_workflow)
*
+ * @deprecated
+ * Deprecated in favour of hook_fedora_repository_check_perm().
* @param string $collection_pid
* The PID of the collection
*
@@ -107,3 +109,29 @@ function hook_fedora_repository_can_ingest($collection_pid) {
return (islandora_workflow_user_collection_permission_check($collection_pid) !== FALSE);
}
+
+/**
+ * Implements hook_fedora_repository_check_perm().
+ *
+ * Hook to allow other modules to allow or deny operations on conditions other
+ * than the explicit Drupal permissions.
+ *
+ * @param string $op
+ * A string representing the operation to be performed.
+ * @param string|null $pid
+ * A string containing the Fedora PID on which the operation is to be
+ * performed. The (default) value of NULL will use the PID indicated by the
+ * fedora_repository_pid Drupal variable.
+ * @param object|null $as_user
+ * An object representing the user for whom to check the permissions (as
+ * given by user_load or the $user global). The (default) value of NULL will
+ * cause permissions to be evaluated for the current user (from the $user
+ * global).
+ *
+ * @return boolean|null
+ * Either a boolean permitting (TRUE) or forbidding (FALSE) an operation, or
+ * NULL to make no assertion.
+ */
+function hook_fedora_repository_check_perm($op, $pid = NULL, $as_user = NULL) {
+ return NULL;
+}
diff --git a/fedora_repository.module b/fedora_repository.module
index d5ca00e6..b1f104c0 100644
--- a/fedora_repository.module
+++ b/fedora_repository.module
@@ -54,15 +54,11 @@ function fedora_repository_help($path, $arg) {
*
* @return type
*/
-function fedora_repository_purge_object($pid = NULL, $name = NULL) {
- if (!user_access('purge objects and datastreams')) {
+function fedora_repository_purge_object($pid, $name = NULL) {
+ if (!fedora_repository_check_perm('purge objects and datastreams', $pid)) {
drupal_set_message(t('You do not have access to add a datastream to this object.'), 'error');
return '';
}
- if ($pid == NULL) {
- drupal_set_message(t('You must specify an object pid to purge an object.'), 'error');
- return '';
- }
$output = t('Are you sure you wish to purge object %name %pid!
This cannot be undone
', array(
'%name' => $name,
'%pid' => $pid)
@@ -75,16 +71,18 @@ function fedora_repository_purge_object($pid = NULL, $name = NULL) {
/**
* fedora repository ingest object
*
+ * XXX: Is this even used?
+ *
* @param type $collection_pid
* @param type $collection_label
* @param type $content_model
*
* @return type
*/
-function fedora_repository_ingest_object($collection_pid=NULL, $collection_label = NULL, $content_model = NULL) {
+function fedora_repository_ingest_object($collection_pid, $collection_label = NULL, $content_model = NULL) {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
- if (!user_access('ingest new fedora objects')) {
+ if (!fedora_repository_check_perm('ingest new fedora objects', $collection_pid)) {
drupal_set_message(t('You do not have permission to ingest.'), 'error');
return '';
}
@@ -123,11 +121,12 @@ function fedora_repository_ingest_object($collection_pid=NULL, $collection_label
*/
function fedora_repository_ingest_form_submit(array $form, array &$form_state) {
// Only validate the form if the submit button was pressed (other buttons may be used for AHAH.
- if ($form_state['ahah_submission']) {
+ if (array_key_exists('ahah_submission', $form_state) && $form_state['ahah_submission']) {
$form_state['submitted'] = FALSE;
return;
}
+
if ($form_state['storage']['xml'] && module_exists('islandora_content_model_forms')) {
module_load_include('inc', 'islandora_content_model_forms', 'IngestObjectMetadataForm');
$xml_form = new IngestObjectMetadataForm();
@@ -183,11 +182,12 @@ function fedora_repository_ingest_form_submit(array $form, array &$form_state) {
*/
function fedora_repository_ingest_form_validate($form, &$form_state) {
// Only validate the form if the submit button was pressed (other buttons may be used for AHAH.
- if ($form_state['ahah_submission']) {
+ $is_ahah_submission = (array_key_exists('ahah_submission', $form_state) && $form_state['ahah_submission']);
+ if ($is_ahah_submission) {
$form_state['submitted'] = FALSE;
return;
}
- if (strpos($form_state['clicked_button']['#id'], 'edit-submit') === 0 && $form_state['ahah_submission'] != 1) {
+ if (strpos($form_state['clicked_button']['#id'], 'edit-submit') === 0 && !$is_ahah_submission) {
switch ($form_state['storage']['step']) {
case 1:
$form_state['storage']['step']++;
@@ -296,10 +296,7 @@ function fedora_repository_ingest_form(&$form_state, $collection_pid, $collectio
*/
function fedora_repository_purge_object_form(&$form_state, $pid, $referrer = NULL) {
global $base_url;
- if (!user_access('purge objects and datastreams')) {
- return NULL;
- }
- if ($pid == NULL) {
+ if (!fedora_repository_check_perm('purge objects and datastreams', $pid)) {
return NULL;
}
$form['pid'] = array(
@@ -339,25 +336,21 @@ function fedora_repository_purge_object_form(&$form_state, $pid, $referrer = NUL
/**
* add stream
*
- * @param type $collection_pid
+ * @param type $pid
* @param type $collectionName
*
* @return type
*/
-function add_stream($collection_pid=NULL, $collectionName=NULL) {
+function add_stream($pid, $collectionName=NULL) {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
if (!valid_pid($collection_pid)) {
drupal_set_message(t("This PID is not valid!"), 'error');
return ' ';
}
- if (!user_access('ingest new fedora objects')) {
+ if (!fedora_repository_check_perm('add fedora datastreams', $pid)) {
drupal_set_message(t('You do not have permission to ingest.'), 'error');
return '';
}
- if ($collection_pid == NULL) {
- drupal_set_message(t('You must specify an collection object pid to ingest an object.'), 'error');
- return '';
- }
$output .= drupal_get_form('fedora_repository_add_stream_form', $pid);
return $output;
@@ -506,7 +499,7 @@ function fedora_repository_purge_stream($pid = NULL, $dsId = NULL, $name = NULL)
drupal_set_message(t('You must specify an object pid and DataStream ID to purge a datastream'), 'error');
return ' ';
}
- if (!fedora_repository_access(OBJECTHELPER :: $PURGE_FEDORA_OBJECTSANDSTREAMS, $pid, $user)) {
+ if (!fedora_repository_check_perm(OBJECTHELPER :: $PURGE_FEDORA_OBJECTSANDSTREAMS, $pid, $user)) {
drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or you do not have permission to purge objects."), 'error');
return ' ';
}
@@ -658,7 +651,7 @@ function fedora_repository_download_datastream_form(&$form_state, $pid, $dsid, $
),
);
- if (user_access(ObjectHelper::$EDIT_FEDORA_METADATA)) {
+ if (fedora_repository_check_perm(ObjectHelper::$EDIT_FEDORA_METADATA, $pid)) {
$item = new Fedora_Item($pid);
$versions = $item->get_datastream_history($dsid);
$version_array = array();
@@ -809,7 +802,7 @@ function fedora_repository_edit_qdc_page($pid = NULL, $dsId = NULL) {
drupal_set_message(t('You must specify an object pid and a Dublin Core DataStream ID to edit metadata'), 'error');
return ' ';
}
- if (!fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $pid, $user)) {
+ if (!fedora_repository_check_perm(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $pid, $user)) {
drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or you do not have permission to edit meta data for this object."), 'error');
return ' ';
}
@@ -833,7 +826,7 @@ function fedora_repository_edit_qdc_form(&$form_state, $pid, $dsId = NULL) {
drupal_set_message(t('You must specify an object pid!'), 'error');
}
global $user;
- if (!fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $pid, $user)) {
+ if (!fedora_repository_check_perm(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $pid, $user)) {
drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or you do not have permission to edit meta data for this object."), 'error');
return ' ';
}
@@ -936,21 +929,6 @@ function fedora_repository_perm() {
);
}
-/**
- * drupal hook
- * determines if a user has access to what they are asking for
- *
- * @param type $op
- * @param type $node
- * @param type $account
- * @return type
- */
-function fedora_repository_access($op, $node = NULL, $account = NULL) {
- module_load_include('inc', 'fedora_repository', 'ObjectHelper');
- $objectHelper = new ObjectHelper();
- return $objectHelper->fedora_repository_access($op, $node, $account);
-}
-
/**
* Grabs a stream from fedora sets the mimetype and returns it. $dsID is the
* datastream id.
@@ -975,7 +953,7 @@ function makeObject($pid, $dsID) {
return ' ';
}
global $user, $conf;
- if (!fedora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) {
+ if (!fedora_repository_check_perm(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) {
drupal_access_denied();
return;
drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace."), 'error');
@@ -1118,7 +1096,7 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU
drupal_set_message(t("Invalid dsID!"), 'error');
return ' ';
}
- if (!fedora_repository_access(OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) {
+ if (!fedora_repository_check_perm(OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) {
if (user_access('access administration pages')) {
drupal_set_message(t("PIDs may be added to allowed namespaces, or all namespace restrictions removed !here", array('!here' => l('here', 'admin/settings/fedora_repository'))), 'warning');
}
@@ -1185,7 +1163,7 @@ function fedora_repository_urlencode_string($str) {
* Uses makeobject to get a stream. Sets the Content Disposition in the header so it suggests a filename
* and sends it as an attachment. This should prompt for a download of the object.
*
- * @global type $user
+ * @global type $conf
* @param type $pid
* @param type $dsId
* @param type $label
@@ -1209,6 +1187,7 @@ function fedora_object_as_attachment($pid, $dsId, $label=NULL, $version=NULL) {
/**
* repository page
+ *
* @param type $pid
* @param type $dsId
* @param type $collection
@@ -1223,6 +1202,9 @@ function repository_page($pid = NULL, $dsId = NULL, $collection = NULL, $pageNum
/**
* repository service
+ *
+ * XXX: Is this even used?
+ *
* @global type $user
* @param type $pid
* @param type $servicePid
@@ -1234,7 +1216,7 @@ function repository_service($pid = NULL, $servicePid = NULL, $serviceMethod = NU
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
global $user;
- if (!fedora_repository_access(OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) {
+ if (!fedora_repository_check_perm(OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) {
//drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied"), 'error');
drupal_access_denied();
if (user_access('access administration pages')) {
@@ -1280,238 +1262,6 @@ function fedora_repository_theme() {
);
}
-/**
- * fedora repository install demo page
- * @return type
- */
-function fedora_repository_install_demos_page() {
- $output = drupal_get_form('fedora_repository_demo_objects_form');
- return $output;
-}
-
-/**
- * fedora repository demo objects form
- * @return string
- */
-function fedora_repository_demo_objects_form() {
- module_load_include('inc', 'fedora_repository', 'ObjectHelper');
- module_load_include('inc', 'fedora_repository', 'api/fedora_item');
- $form = array();
- $existing_demos = array();
-
- $form['install_demos'] = array(
- '#title' => t('Islandora Demo Collections'),
- '#type' => 'fieldset',
- '#description' => t('Install demo image and document collections and content models.'),
- );
- $demo_objects = array();
-// Check if the top-level islandora collection exists. If not, display a button to ingest.
-
- $form['install_demos']['demo_collections'] = array(
- '#type' => 'checkboxes',
- '#title' => t('Collections to ingest'),
- '#options' => array(),
- '#description' => t('Choose which demo collections you would like ingested into the repository.'),
- );
-
- foreach (array(
-'islandora:collectionCModel' => 'Islandora default content models',
- 'islandora:root' => 'Islandora top-level collection',
- 'islandora:demos' => 'Islandora demos collection',
- 'islandora:largeimages' => 'Sample large image content model (requires Djatoka and Kakadu.)',
- )
- as $available_demo => $available_demo_desc) {
- try {
- $demo_objects[$available_demo] = new Fedora_Item($available_demo);
- } catch (exception $e) {
-
- }
-
- if (empty($demo_objects[$available_demo]->objectProfile)) {
-//The demo objects collection does not exist in the repository, display a button to ingest them.
- $form['install_demos']['demo_collections']['#options'][$available_demo] = $available_demo_desc;
- }
- else {
- array_push($existing_demos, $demo_objects[$available_demo]);
- }
- }
-
-// Check if the SmileyStuff collectoin exists, and if it has a COLLECTION_VIEW datastream. If it doesn't then we can add it.
-
- $smiley_stuff = new Fedora_Item('demo:SmileyStuff');
- if (!empty($smiley_stuff->objectProfile)) {
- $datastreams_list = $smiley_stuff->get_datastreams_list_as_array();
- if (empty($datastreams_list['COLLECTION_VIEW'])) {
- $form['install_demos']['demo_collections']['#options']['demo:SmileyStuff'] = 'Add Islandora Collection View to Fedora Smiley Stuff Collection';
- }
- else {
- $demo_objects['demo:SmileyStuff'] = $smiley_stuff;
- }
- }
- else {
- $form['install_demos']['smileynote'] = array(
- '#value' => '
If you install the ' . l('fedora demo objects', 'https://wiki.duraspace.org/display/FCR30/Demonstration+Objects') . ' Islandora can display them as a collection.
' - ); - } - - $form['install_demos']['ingest'] = array( - '#type' => 'submit', - '#name' => 'install_demos', - '#value' => 'Install Selected Demos', - '#disabled' => (empty($form['install_demos']['demo_collections']['#options'])) ? TRUE : FALSE, - ); - - $form['existing_demos'] = array( - '#prefix' => 'Demo collections already installed in this repository:
MetaData | ||
---|---|---|
Metadata (DC) |
Metadata (MODS) |
---|