function user_badges_delete_form_submit in User Badges 7
Same name and namespace in other branches
- 5 user_badges.module \user_badges_delete_form_submit()
- 6.2 user_badges.module \user_badges_delete_form_submit()
- 6 user_badges.module \user_badges_delete_form_submit()
- 7.2 user_badges.admin.inc \user_badges_delete_form_submit()
- 7.3 user_badges.admin.inc \user_badges_delete_form_submit()
Submit handler for user badge deletion.
File
- ./
user_badges.admin.inc, line 942 - @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);
if (file_valid_uri($badge->image)) {
// Also delete file usage.
$fid = db_select('file_managed', 'f')
->fields('f', array(
'fid',
))
->condition('f.uri', $badge->image)
->execute()
->fetchField();
$file = file_load($fid);
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' => $name,
)));
$form_state['redirect'] = BASE_ADMIN_PATH;
}