function slickgrid_undo_form_submit in Slickgrid 7.2
Submit function for the deletion of entities.
File
- includes/
slickgrid.form.inc, line 277
Code
function slickgrid_undo_form_submit($form, &$form_state) {
$commands = array();
if ($form_state['values']['op'] == $form_state['values']['do']) {
// I'm not happy about this, but we're hard coding entity types for undo
// here. A generic solution needs to be implemented.
switch ($form_state['values']['entity_type']) {
case 'node':
// We get the highest vid for this node which is earlier than the
// current one.
$node_revision = node_load($form_state['values']['entity_id'], $form_state['values']['revision_id']['vid']);
$node_revision->revision = 1;
$node_revision->log = t('Copy of the revision from %date.', array(
'%date' => format_date($node_revision->revision_timestamp),
));
node_save($node_revision);
}
$commands[] = ajax_command_invoke('', 'slickgrid_undo_pop');
$commands[] = ajax_command_invoke('', 'slickgrid_messages', array(
array(
array(
'type' => 'status',
'message' => t('Undone'),
),
),
));
$commands[] = ajax_command_invoke('', 'slickgrid_refresh');
}
$commands[] = ajax_command_remove('#' . $form_state['values']['form_id'] . ' ~ div');
$form_state['slickgrid_commands'] = $commands;
}