You are here

function heartbeat_activity_modal_delete in Heartbeat 7

CTools modal wrapper function to delete activity.

1 string reference to 'heartbeat_activity_modal_delete'
heartbeat_menu in ./heartbeat.module
Implements hook_menu().

File

./heartbeat.pages.inc, line 219
Separate codefile for page displays

Code

function heartbeat_activity_modal_delete($js, $heartbeatActivity) {
  if (empty($heartbeatActivity)) {
    return drupal_not_found();
  }
  $uaid = $heartbeatActivity->uaid;
  if ($js) {
    ctools_include('modal');
    ctools_include('ajax');
  }
  $form_state = array(
    'title' => t('Are you sure you want to delete this message?'),
    'ajax' => TRUE,
    'uaid' => $uaid,
  );

  // Fall back if $js is not set.
  if (!$js) {
    return drupal_get_form('heartbeat_delete_log_confirm', $uaid);
  }
  else {

    // Send this all off to our form. This is like drupal_get_form only wizardy.
    $output = ctools_modal_form_wrapper('heartbeat_delete_log_confirm', $form_state);
    if (!empty($form_state['executed'])) {

      // We'll just overwrite the form output if it was successful.
      $output = array();
      $output[] = ctools_modal_command_dismiss();
      $output[] = ajax_command_invoke('.heartbeat-activity-' . $uaid, 'heartbeatRemoveElement', array(
        $uaid,
        t('Activity deleted.'),
      ));
    }
    print ajax_render($output);
    exit;
  }
}