You are here

function content_menu_item_delete_form_submit in Content Menu 8

Same name and namespace in other branches
  1. 7 content_menu.module \content_menu_item_delete_form_submit()

Extended submit handler for menu_item_delete_form.

1 string reference to 'content_menu_item_delete_form_submit'
content_menu_form_menu_item_delete_form_alter in ./content_menu.module
Implements hook_form_FORM_ID_alter().

File

./content_menu.module, line 263

Code

function content_menu_item_delete_form_submit($form, &$form_state) {

  // Call default submit handler to handle deletion of menu item itself.
  menu_item_delete_form_submit($form, $form_state);

  // Delete an associated node as well, if intended and user is permitted.
  if ($form_state['input']['delete_node'] == 1) {
    $nid = explode('/', $form['#item']['link_path']);
    if (isset($nid[1]) && is_numeric($nid[1])) {
      $node = node_load($nid[1]);
      if (is_object($node) && node_access('delete', $node) && $node->nid == $form_state['values']['delete_node_nid']) {
        node_delete($node->nid);
        watchdog('content', '@type: deleted %title.', array(
          '@type' => $node->type,
          '%title' => $node->title,
        ));
        drupal_set_message(t('@type %title has been deleted.', array(
          '@type' => node_type_get_name($node),
          '%title' => $node->title,
        )));
      }
    }
  }
}