Browse Source

changed fedora_repository_check_perm to set the PID if it is empty

rather than ===NULL
pull/189/head
William Panting 12 years ago
parent
commit
b82d329ad4
  1. 20
      fedora_repository.module

20
fedora_repository.module

@ -814,9 +814,11 @@ function fedora_repository_edit_qdc_page($pid = NULL, $dsId = NULL) {
/** /**
* fedora repository edit qdc form * fedora repository edit qdc form
* @global type $user * @global type $user
*
* @param type $form_state * @param type $form_state
* @param type $pid * @param type $pid
* @param type $dsId * @param type $dsId
*
* @return type * @return type
*/ */
function fedora_repository_edit_qdc_form(&$form_state, $pid, $dsId = NULL) { function fedora_repository_edit_qdc_form(&$form_state, $pid, $dsId = NULL) {
@ -836,7 +838,7 @@ function fedora_repository_edit_qdc_form(&$form_state, $pid, $dsId = NULL) {
$soapHelper = new ConnectionHelper(); $soapHelper = new ConnectionHelper();
$client = $soapHelper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl')); $client = $soapHelper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'));
// Check if there is a custom edit metadata function defined in the content model. // Check if there's a custom edit metadata function in the content model.
$output = ''; $output = '';
if (($cm = ContentModel::loadFromObject($pid)) !== FALSE) { if (($cm = ContentModel::loadFromObject($pid)) !== FALSE) {
$output = $cm->buildEditMetadataForm($pid, $dsId); $output = $cm->buildEditMetadataForm($pid, $dsId);
@ -845,15 +847,16 @@ function fedora_repository_edit_qdc_form(&$form_state, $pid, $dsId = NULL) {
if (empty($output)) { if (empty($output)) {
// There is no custom function, so just load the standard QDC form. // There is no custom function, so just load the standard QDC form.
$metaDataForm = new formClass(); $metaDataForm = new formClass();
//currently we only edit the dc metadata. If you defined a custom form with a custom handler you are sol for now. // Currently we only edit the dc metadata.
// If you defined a custom form with a custom handler you are sol for now.
$output = $metaDataForm->createMetaDataForm($pid, $dsId, $client, $form_state); $output = $metaDataForm->createMetaDataForm($pid, $dsId, $client, $form_state);
} }
return $output; return $output;
} }
/** /**
* fedora repository edit qdc form validate * fedora repository edit qdc form validate
*
* @param type $form * @param type $form
* @param boolean $form_state * @param boolean $form_state
*/ */
@ -1136,7 +1139,7 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU
); );
$cmodels_tabs += $hook_tabs; $cmodels_tabs += $hook_tabs;
//Assemble parameters, to pass during alter // Assemble parameters, to pass during alter.
$params = array( $params = array(
'content_models' => $content_models, 'content_models' => $content_models,
'pid' => $pid, 'pid' => $pid,
@ -1637,7 +1640,7 @@ function fedora_repository_render_image($pid, $dsid, $imagecache_preset = 'fedor
/** /**
* Convenience function used in XSLT callback... * Convenience function used in XSLT callback...
* *
* @param $string string * @param string $string
* A string containing some markup to convert to a domnode. * A string containing some markup to convert to a domnode.
*/ */
function fedora_repository_string_to_domnode($string) { function fedora_repository_string_to_domnode($string) {
@ -1662,6 +1665,7 @@ function fedora_repository_access() {
* *
* @global $user * @global $user
* @see hook_fedora_repository_check_perm() * @see hook_fedora_repository_check_perm()
*
* @param string $op * @param string $op
* The operation to be performed. * The operation to be performed.
* @param string|null $pid * @param string|null $pid
@ -1681,8 +1685,8 @@ function fedora_repository_check_perm($op, $pid = NULL, $as_user = NULL, $reset_
if ($reset_cache) { if ($reset_cache) {
$cache = array(); $cache = array();
} }
// The PID can be empty for the root object.
if ($pid === NULL) { if (empty($pid)) {
$pid = variable_get('fedora_repository_pid', 'islandora:root'); $pid = variable_get('fedora_repository_pid', 'islandora:root');
} }
if ($as_user === NULL) { if ($as_user === NULL) {
@ -1693,7 +1697,6 @@ function fedora_repository_check_perm($op, $pid = NULL, $as_user = NULL, $reset_
// Populate the cache on a miss. // Populate the cache on a miss.
if (!isset($cache[$op][$pid][$as_user->uid])) { if (!isset($cache[$op][$pid][$as_user->uid])) {
$results = module_invoke_all('fedora_repository_check_perm', $op, $pid, $as_user); $results = module_invoke_all('fedora_repository_check_perm', $op, $pid, $as_user);
// Nothing returned FALSE, and something returned TRUE. // Nothing returned FALSE, and something returned TRUE.
$cache[$op][$pid][$as_user->uid] = (!in_array(FALSE, $results, TRUE) && in_array(TRUE, $results, TRUE)); $cache[$op][$pid][$as_user->uid] = (!in_array(FALSE, $results, TRUE) && in_array(TRUE, $results, TRUE));
} }
@ -1730,4 +1733,3 @@ function fedora_repository_fedora_repository_check_perm($op, $pid, $user) {
return NULL; return NULL;
} }
} }

Loading…
Cancel
Save