function entity_legal_document_form_submit in Entity Legal 7
Same name and namespace in other branches
- 7.2 entity_legal.admin.inc \entity_legal_document_form_submit()
Form submit handler for saving a legal document revision.
1 string reference to 'entity_legal_document_form_submit'
- entity_legal_document_form in ./
entity_legal.admin.inc - Generates the profile type editing form.
File
- ./
entity_legal.admin.inc, line 229 - Administration hooks and helpers for entity_legal module.
Code
function entity_legal_document_form_submit(&$form, &$form_state) {
$form_state['values']['require_signup'] = $form_state['values']['settings']['new_users']['require'];
$form_state['values']['require_existing'] = $form_state['values']['settings']['existing_users']['require'];
$document_entity = entity_ui_form_submit_build_entity($form, $form_state);
// If it's a new document, redirect to the versions page.
if (!empty($document_entity->is_new)) {
$form_state['redirect'] = 'admin/structure/legal/manage/' . $document_entity
->identifier() . '/add';
}
$document_entity
->save();
if (!empty($form_state['values']['path'])) {
$path = $form_state['values']['path'];
$alias = trim($path['alias']);
$pid = $path['pid'];
// Compare new and old.
$original_alias = '';
if (!empty($pid)) {
$original_path = path_load(array(
'pid' => $pid,
));
$original_alias = $original_path['alias'];
}
if ($alias != $original_alias) {
// Delete old alias.
if (!empty($pid)) {
path_delete($pid);
}
// Create new alias.
if (!empty($alias)) {
unset($path['pid']);
$default_uri = $document_entity
->uri();
$path['source'] = $default_uri['path'];
path_save($path);
}
}
}
}