You are here

function user_badges_delete_form_submit in User Badges 7.3

Same name and namespace in other branches
  1. 5 user_badges.module \user_badges_delete_form_submit()
  2. 6.2 user_badges.module \user_badges_delete_form_submit()
  3. 6 user_badges.module \user_badges_delete_form_submit()
  4. 7 user_badges.admin.inc \user_badges_delete_form_submit()
  5. 7.2 user_badges.admin.inc \user_badges_delete_form_submit()

Submit handler for user badge deletion.

File

./user_badges.admin.inc, line 1110
@brief User Badges admin functions

Code

function user_badges_delete_form_submit($form, &$form_state) {
  $bid = $form_state['values']['bid'];
  $badge = user_badge_load($bid);

  // Let other modules know about this.
  module_invoke_all('user_badges_delete', $badge);

  // Remove file usage for image file.
  $file = _user_badges_managed_file($badge->image);
  if ($file) {
    file_usage_delete($file, 'user_badges', 'user_badge', $badge->bid);
  }
  db_delete('user_badges_badges')
    ->condition('bid', $bid)
    ->execute();
  db_delete('user_badges_user')
    ->condition('bid', $bid)
    ->execute();
  db_delete('user_badges_roles')
    ->condition('bid', $bid)
    ->execute();
  drupal_set_message(t('The @name badge has been deleted.', array(
    '@name' => $badge->name,
  )));
  $form_state['redirect'] = USER_BADGES_ADMIN_PATH;
}