function editor_note_confirm_edit_form_update in Editor Notes 7
Submit callback for 'Update' button in 'editor_note_confirm_edit_form'.
1 string reference to 'editor_note_confirm_edit_form_update'
- editor_note_confirm_edit_form in ./
editor_note.pages.inc - Builds confirmation form for editing the note which displays in popup.
File
- ./
editor_note.pages.inc, line 171 - Page callbacks defined in hook_menu for the Editor Notes module.
Code
function editor_note_confirm_edit_form_update(&$form, &$form_state) {
global $user;
$message_text = t('Note has been updated and saved.');
$field_name = $form_state['values']['note_field_name'];
$entity_type = $form_state['values']['note_entity_type'];
$entity_id = $form_state['values']['note_entity_id'];
$note_id = $form_state['values']['note_id'];
$field = field_info_field($field_name);
$edit_path = implode('/', array(
$entity_type,
$entity_id,
'edit',
));
// Updates note entity in the database.
$note = editor_note_load($note_id);
$note->note = !empty($form_state['values']['note']['value']) ? $form_state['values']['note']['value'] : $form_state['values']['note'];
$note->text_format = !empty($form_state['values']['note']['format']) ? $form_state['values']['note']['format'] : EDITOR_NOTE_DEFAULT_TEXT_FORMAT;
$note->changed = REQUEST_TIME;
$note->uid = $user->uid;
$note
->save();
if ($form_state['values']['method'] == 'ajax') {
// Closes the modal.
$form_state['ajax_commands'][] = ctools_modal_command_dismiss();
// Displays remove message.
$message = theme('editor_note_message', array(
'field_name' => $field_name,
'message_text' => $message_text,
'message_type' => 'status',
));
$form_state['ajax_commands'][] = ajax_command_replace('#status_message_' . $field_name, $message);
// Updates notes table and pager.
$entity_array = entity_load($entity_type, array(
$entity_id,
));
$entity = $entity_array[$entity_id];
$notes = editor_note_get_notes($entity_type, $entity, $field);
$formatted_notes = editor_note_get_formatted_notes($field, $notes, TRUE, $edit_path);
$form_state['ajax_commands'][] = ajax_command_replace('#formatted_notes_' . $field_name, drupal_render($formatted_notes));
}
else {
drupal_set_message($message_text);
}
}