Browse Source

added path to admin page for admin users only on page denied error.

pull/105/head
Alan Stanley 14 years ago
parent
commit
38833546e3
  1. 70
      fedora_repository.module

70
fedora_repository.module

@ -105,7 +105,6 @@ function fedora_repository_ingest_object($collection_pid=NULL, $collection_label
drupal_set_message(t("This collection PID $collection_pid is not valid"), 'error'); drupal_set_message(t("This collection PID $collection_pid is not valid"), 'error');
return ' '; return ' ';
} }
} }
if ($collection_pid == NULL) { if ($collection_pid == NULL) {
@ -145,7 +144,7 @@ function fedora_repository_ingest_form_submit($form, &$form_state) {
$form_state['values']['content_model_pid'] = $contentModelPid; $form_state['values']['content_model_pid'] = $contentModelPid;
$form_state['values']['relationship'] = $relationship; $form_state['values']['relationship'] = $relationship;
$err = (!$cm->execFormHandler($form_state['values'],$form_state)); $err = (!$cm->execFormHandler($form_state['values'], $form_state));
$_SESSION['fedora_ingest_files'] = ''; //empty this variable $_SESSION['fedora_ingest_files'] = ''; //empty this variable
@ -241,19 +240,19 @@ function fedora_repository_purge_object_form(&$form_state, $pid, $referrer) {
'#type' => 'hidden', '#type' => 'hidden',
'#value' => "$pid" '#value' => "$pid"
); );
if (!strstr( drupal_get_destination(), urlencode('fedora/repository'))) { if (!strstr(drupal_get_destination(), urlencode('fedora/repository'))) {
$form['referrer'] = array( $form['referrer'] = array(
'#type' => 'hidden', '#type' => 'hidden',
'#value' => $referrer, '#value' => $referrer,
); );
} }
if(!isset($form_state['storage']['confirm'])) { if (!isset($form_state['storage']['confirm'])) {
// do your normal $form definition here // do your normal $form definition here
$form['submit'] = array( $form['submit'] = array(
'#type' => 'image_button', '#type' => 'image_button',
'#src' => drupal_get_path('module', 'fedora_repository').'/images/purge_big.png', '#src' => drupal_get_path('module', 'fedora_repository') . '/images/purge_big.png',
'#value' => t('Purge'), '#value' => t('Purge'),
'#suffix' => 'Purge this object', '#suffix' => 'Purge this object',
); );
@ -261,10 +260,9 @@ function fedora_repository_purge_object_form(&$form_state, $pid, $referrer) {
$collectionPid = $_SESSION['fedora_collection']; $collectionPid = $_SESSION['fedora_collection'];
} }
//$form['#redirect'] = $referrer; //$form['#redirect'] = $referrer;
return $form; return $form;
} } else {
else {
// ALSO do $form definition here. Your final submit handler (after user clicks Yes, I Confirm) will only see $form_state info defined here. Form you create here passed as param1 to confirm_form // ALSO do $form definition here. Your final submit handler (after user clicks Yes, I Confirm) will only see $form_state info defined here. Form you create here passed as param1 to confirm_form
return confirm_form($form, 'Confirm Purge Object', $referrer, 'Are you sure you want to delete this object? This action cannot be undone.', 'Delete', 'Cancel'); //Had better luck leaving off last param 'name' return confirm_form($form, 'Confirm Purge Object', $referrer, 'Are you sure you want to delete this object? This action cannot be undone.', 'Delete', 'Cancel'); //Had better luck leaving off last param 'name'
@ -409,8 +407,7 @@ function fedora_repository_purge_object_form_submit($form, &$form_state) {
if (!isset($form_state['storage']['confirm'])) { if (!isset($form_state['storage']['confirm'])) {
$form_state['storage']['confirm'] = TRUE; // this will cause the form to be rebuilt, entering the confirm part of the form $form_state['storage']['confirm'] = TRUE; // this will cause the form to be rebuilt, entering the confirm part of the form
$form_state['rebuild'] = TRUE; // along with this $form_state['rebuild'] = TRUE; // along with this
} } else {
else {
// this is where you do your processing after they have pressed the confirm button // this is where you do your processing after they have pressed the confirm button
$params = array( $params = array(
"pid" => $pid, "pid" => $pid,
@ -435,8 +432,7 @@ function fedora_repository_purge_object_form_submit($form, &$form_state) {
} }
if (!empty($form_state['values']['referrer'])) { if (!empty($form_state['values']['referrer'])) {
$form_state['redirect'] = $form_state['values']['referrer']; $form_state['redirect'] = $form_state['values']['referrer'];
} } else {
else {
$form_state['redirect'] = "fedora/repository/$collectionPid/"; $form_state['redirect'] = "fedora/repository/$collectionPid/";
} }
} }
@ -757,17 +753,23 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
global $user; global $user;
if ($pid &!validPid($pid)) { if ($pid & !validPid($pid)) {
drupal_set_message(t("Invalid PID!"), 'error'); drupal_set_message(t("Invalid PID!"), 'error');
return ' '; return ' ';
} }
if ($dsId &!validDsid($dsId)) { if ($dsId & !validDsid($dsId)) {
drupal_set_message(t("Invalid dsID!"), 'error'); drupal_set_message(t("Invalid dsID!"), 'error');
return ' '; return ' ';
} }
if (!fedora_repository_access(OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { if (!fedora_repository_access(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_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied"), 'error');
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');
}
drupal_access_denied();
exit;
return ' '; return ' ';
} }
@ -841,11 +843,16 @@ function repository_page($pid = NULL, $dsId = NULL, $collection = NULL, $pageNum
} }
function repository_service($pid = NULL, $servicePid = NULL, $serviceMethod = NULL) { function repository_service($pid = NULL, $servicePid = NULL, $serviceMethod = NULL) {
module_load_include('inc','fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc','fedora_repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper');
global $user; global $user;
if (!fedora_repository_access(OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { if (!fedora_repository_access(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_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')) {
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'))), 'error');
}
return ' '; return ' ';
} }
if ($pid == NULL) { if ($pid == NULL) {
@ -858,15 +865,13 @@ function repository_service($pid = NULL, $servicePid = NULL, $serviceMethod = NU
return ' '; return ' ';
} }
$item = new Fedora_Item($pid); $item = new Fedora_Item($pid);
if ($item !== false) if ($item !== false) {
{ echo $item->get_dissemination($servicePid, $serviceMethod);
echo $item->get_dissemination($servicePid,$serviceMethod);
} }
exit(); exit();
} }
//Search Stuff ******************************************************************** //Search Stuff ********************************************************************
@ -961,7 +966,7 @@ function fedora_repository_search($op = 'search', $keys = NULL) {
*/ */
function fedora_repository_search_page($resultData) { function fedora_repository_search_page($resultData) {
$path = drupal_get_path('module', 'fedora_repository'); $path = drupal_get_path('module', 'fedora_repository');
$isRestricted = variable_get('fedora_namespace_restriction_enforced',TRUE); $isRestricted = variable_get('fedora_namespace_restriction_enforced', TRUE);
$proc = NULL; $proc = NULL;
if (!$resultData[0][0]['data']) { if (!$resultData[0][0]['data']) {
return ''; //no results return ''; //no results
@ -987,13 +992,12 @@ function fedora_repository_search_page($resultData) {
$proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: Islandora: ilives: ')); $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: Islandora: ilives: '));
$proc->registerPHPFunctions(); $proc->registerPHPFunctions();
$xsl = new DomDocument(); $xsl = new DomDocument();
if($isRestricted){ if ($isRestricted) {
$xsl->load($path . '/xsl/results.xsl'); $xsl->load($path . '/xsl/results.xsl');
} } else {
else{
$xsl->load($path . '/xsl/unfilteredresults.xsl'); $xsl->load($path . '/xsl/unfilteredresults.xsl');
} }
$input = new DomDocument(); $input = new DomDocument();
$didLoadOk = $input->loadXML(utf8_encode($resultData[0][0]['data'])); $didLoadOk = $input->loadXML(utf8_encode($resultData[0][0]['data']));
@ -1280,7 +1284,7 @@ function fedora_repository_demo_objects_form() {
} }
} else { } else {
$form['install_demos']['smileynote'] = array( $form['install_demos']['smileynote'] = array(
'#value' => '<p>If you install the '.l('fedora demo objects', 'https://wiki.duraspace.org/display/FCR30/Demonstration+Objects').' Islandora can display them as a collection.</p>' '#value' => '<p>If you install the ' . l('fedora demo objects', 'https://wiki.duraspace.org/display/FCR30/Demonstration+Objects') . ' Islandora can display them as a collection.</p>'
); );
} }
@ -1295,11 +1299,11 @@ function fedora_repository_demo_objects_form() {
'#prefix' => '<p>Demo collections already installed in this repository:</p><ul>', '#prefix' => '<p>Demo collections already installed in this repository:</p><ul>',
'#suffix' => '</ul>', '#suffix' => '</ul>',
); );
if (!empty($existing_demos)) { if (!empty($existing_demos)) {
foreach ($existing_demos as $pid => $demo_object) { foreach ($existing_demos as $pid => $demo_object) {
$form['existing_demos'][$demo_object->pid] = array ( $form['existing_demos'][$demo_object->pid] = array(
'#prefix' => '<li>', '#prefix' => '<li>',
'#value' => l($demo_object->pid, $demo_object->url()), '#value' => l($demo_object->pid, $demo_object->url()),
'#suffix' => '</li>', '#suffix' => '</li>',

Loading…
Cancel
Save