You are here

function user_badges_userweight_form_submit in User Badges 7

Same name and namespace in other branches
  1. 6.2 user_badges.module \user_badges_userweight_form_submit()
  2. 6 user_badges.module \user_badges_userweight_form_submit()
  3. 7.4 user_badges.module \user_badges_userweight_form_submit()
  4. 7.2 user_badges.module \user_badges_userweight_form_submit()
  5. 7.3 user_badges.module \user_badges_userweight_form_submit()

Process user_badges_userweight_form form submissions.

Update the badge userweights

File

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

Code

function user_badges_userweight_form_submit($form, &$form_state) {
  if (isset($form['weight']) && is_array($form['weight'])) {
    foreach (element_children($form['weight']) as $bid) {

      // TODO Please review the conversion of this statement to the D7 database API syntax.

      /* db_query("UPDATE {user_badges_user} SET userweight = %d WHERE bid = %d AND uid = %d", $form_state['values'][$bid], $bid, $form_state['values']['uid']) */
      db_update('user_badges_user')
        ->fields(array(
        'userweight' => $form_state['values'][$bid],
      ))
        ->condition('bid', $bid)
        ->condition('uid', $form_state['values']['uid'])
        ->execute();
    }
    drupal_set_message(t('Your badge order has been updated.'));
  }
}