You are here

function user_badges_save_badge in User Badges 5

Saves information about a badge into the database

1 call to user_badges_save_badge()
user_badges_edit_form_submit in ./user_badges.module

File

./user_badges.module, line 670
@brief User Badges module file

Code

function user_badges_save_badge($edit) {
  $edit = (object) $edit;
  if (is_numeric($edit->bid)) {
    db_query('DELETE FROM {user_badges_badges} WHERE bid = %d', $edit->bid);
  }
  else {
    $edit->bid = db_next_id('user_badges_badges');
  }
  $result = db_query("\n    INSERT INTO {user_badges_badges} (bid, name, image, weight, href) \n    VALUES (%d, '%s', '%s', %d, '%s')", $edit->bid, $edit->name, $edit->image, $edit->weight, trim($edit->href));
  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.'));
  }
  drupal_goto('admin/user/user_badges');
  return $result;
}