Browse Source

updated properties form

pull/117/merge
Paul Pound 13 years ago
parent
commit
9cca7a3ce1
  1. 37
      includes/object_properties.inc

37
includes/object_properties.inc

@ -1,5 +1,14 @@
<?php
/**
* may want more validation here the only restrictions i see on
* the object label and owner is the foxml schema says they should be
* an xsd:string there maybe further restrictions such as length but they aren't
* defined in the schema.
* @param array $form
* @param array $form_state
* @return boolean
*/
function islandora_edit_properties_form_validate($form, &$form_state) {
$islandora_object = islandora_get_object($form_state['values']['pid']);
if (!isset($islandora_object)) {
@ -18,22 +27,29 @@ function islandora_edit_properties_form_submit($form, &$form_state){
$owner = $form_state['values']['object_owner'];
$state = $form_state['values']['object_state'];
$label = $form_state['values']['object_label'];
$submit = FALSE;
$params = array();
if (isset($owner) && $owner != $islandora_object->owner) {
$params['ownerId'] = check_plain($owner);
$submit = TRUE;
try {
$islandora_object->owner = $owner;
drupal_set_message(t('Successfully updated owner %s', array('%s' => $owner)));
} catch (Exception $e) {
form_set_error('object_owner',t('Error updating owner %s', array('%s'=> $e->getMessage())));
}
}
if (isset($state) && $state != $islandora_object->state) {
$params['state'] = check_plain($state);
$submit = TRUE;
try {
$islandora_object->state = $state;
drupal_set_message(t('Successfully updated state %s', array('%s' => $state)));
} catch (Exception $e) {
form_set_error('object_state',t('Error updating state %s', array('%s'=> $e->getMessage())));
}
}
if (isset($label) && $label != $islandora_object->label) {
$params['label'] = check_plain($label);
$submit = TRUE;
try {
$islandora_object->label = $label;
drupal_set_message(t('Successfully updated label %s', array('%s' => check_plain($label))));
} catch (Exception $e) {
form_set_error(t('Error updating label %s', array('%s' => $e->getMessage())));
}
if($submit){
$islandora_object->modifyObject($params);
}
}
@ -84,4 +100,5 @@ function islandora_edit_properties_form ($form, &$form_state, $object_id){
);
return $form;
}
?>

Loading…
Cancel
Save