function user_badges_edit_form_submit in User Badges 6.2
Same name and namespace in other branches
- 5 user_badges.module \user_badges_edit_form_submit()
- 6 user_badges.admin.inc \user_badges_edit_form_submit()
- 7 user_badges.admin.inc \user_badges_edit_form_submit()
- 7.2 user_badges.admin.inc \user_badges_edit_form_submit()
- 7.3 user_badges.admin.inc \user_badges_edit_form_submit()
Process user_badges_edit_form form submissions.
Inserts the badge into the DB and sets a success message
File
- ./
user_badges.admin.inc, line 316 - @brief User Badges admin functions
Code
function user_badges_edit_form_submit($form, &$form_state) {
$edit = $form_state['values'];
$edit = (object) $edit;
$image = $edit->imageurl ? trim($edit->imageurl) : $edit->image;
// If the badge already exists, delete it and re-insert it.
if (isset($edit->bid) && preg_match("/^[0-9]+\$/D", $edit->bid)) {
db_query('DELETE FROM {user_badges_badges} WHERE bid = %d', $edit->bid);
$result = db_query("\n INSERT INTO {user_badges_badges} (bid, name, image, weight, href, unhideable, fixedweight, doesnotcounttolimit, tid)\n VALUES (%d, '%s', '%s', %d, '%s', %d, %d, %d, %d)", $edit->bid, trim($edit->name), $image, $edit->weight, trim($edit->href), $edit->unhideable, $edit->fixedweight, $edit->doesnotcounttolimit, $edit->tid);
}
else {
$result = db_query("\n INSERT INTO {user_badges_badges} (name, image, weight, href, unhideable, fixedweight, doesnotcounttolimit, tid)\n VALUES ('%s', '%s', %d, '%s', %d, %d, %d, %d)", trim($edit->name), $image, $edit->weight, trim($edit->href), $edit->unhideable, $edit->fixedweight, $edit->doesnotcounttolimit, $edit->tid);
}
if ($result) {
drupal_set_message(t('Badge %badgename saved.', array(
'%badgename' => $edit->name,
)));
}
else {
drupal_set_message(t('There was a problem saving the badge information into the database.'));
}
$form_state['redirect'] = 'admin/user/user_badges';
}