if ($form_state['values']['user_bid']) { // This query is actually not even needed - 19 Nov 2008 peterng // It doesn't seem to work without the query - 23 nov 2008 $result = db_query('SELECT high_bidder, mxbid FROM {uc_auction} WHERE nid = %d GROUP BY nid', $form_state['values']['nid']); while ($row = db_fetch_array($result)) { $m_uid = $row['high_bidder']; $m_mxbid = $row['mxbid']; } // there need to be a bid difference with the max.max.bid of at least 6.00 $bid_change = 6.00; $new_bid_limit = $m_mxbid + $bid_change; // new bid limit when curent max.max.bid and current bid is less than 5.00 - 20 nov 2008 - peterng $bid_change_diff = $form_state['values']['user_bid'] - $m_mxbid; // bid difference - 20 Nov 2008 peterng $bid_diff = 5.00; // new_sell_price or bid will just be 5.00 less than the previous bid limit. - 19 Nov 2008 peterng $price_change = 5.00; $new_sell_price = $m_mxbid + $price_change; // verify if the bid is less than current max. max. bid and less than current max.max. bid minus 5 euro // and new_sell_price or bid will just be 1.00 less than the current bid. The new bid will already be lower than the current // max.max.bid (mxbid) - 19 Nov 2008 peter ng $price_change2 = 1.00; // $current_bid = $form_state['values']['user_bid']; $new_sell_price2 = $m_mxbid + $price_change2; // verify if the bid is less than current max. max. bid and less than current max.max. bid minus 5 euro and that it's the first bid // check if the entered bid is the first bid if ($node->uc_auction['start_price'] == $m_mxbid) { // update the bids table to the new bid from the current bidder $record = array( 'nid' => $form_state['values']['nid'], 'uid' => $user->uid, 'time' => time(), 'bid' => $new_sell_price, ); drupal_write_record('uc_auction_bids', $record); // update the high_bidder and the new max. max bid in uc_rauction from the new bidder db_query('UPDATE {uc_auction} SET high_bidder = %d, mxbid = %d WHERE nid = %d', $user->uid, $form_state['values']['user_bid'], $form_state['values']['nid']); // update the sell_price db_query('UPDATE {uc_products} SET sell_price = %d WHERE nid = %d', $new_sell_price, $form_state['values']['nid']); } else { // bid is less or equal to current max.bid if ($form_state['values']['user_bid'] <= $m_mxbid) { global $user; // first write the current max. bid to the bids table from the current high_bidder - added 19/11/2008 $record = array( 'nid' => $form_state['values']['nid'], 'uid' => $user->uid, 'time' => time(), 'bid' => $form_state['values']['user_bid'], ); drupal_write_record('uc_auction_bids', $record); // write the new bid to the bids table from the new bidder $record2 = array( 'nid' => $form_state['values']['nid'], 'uid' => $node->uc_auction['high_bidder'], 'time' => time(), 'bid' => $form_state['values']['user_bid'], ); drupal_write_record('uc_auction_bids', $record2); // update the uc_products table to the new sell_price db_query('UPDATE {uc_products} SET sell_price = %d WHERE nid = %d', $form_state['values']['user_bid'], $form_state['values']['nid']); } // Verify if the bid is more than the new_bid_limit which currently is max.max.bid + 6.00 elseif ($form_state['values']['user_bid'] > $m_mxbid && $form_state['values']['user_bid'] > $new_bid_limit && $bid_change_diff <= $bid_diff) { global $user; // first write the current min. bid to the bids table from the current high_bidder - added 19/11/2008 $record = array( 'nid' => $form_state['values']['nid'], 'uid' => $node->uc_auction['high_bidder'], 'time' => time(), 'bid' => $node->uc_auction['mxbid'], ); drupal_write_record('uc_auction_bids', $record); // then write the new bid to the bids table from the new bidder. This is currently the max.min.bid + 5.00 $record2 = array( 'nid' => $form_state['values']['nid'], 'uid' => $user->uid, 'time' => time(), 'bid' => $new_sell_price, ); drupal_write_record('uc_auction_bids', $record2); // update the uc_products table to the new sell_price db_query('UPDATE {uc_products} SET sell_price = %d WHERE nid = %d', $new_sell_price, $form_state['values']['nid']); // update the high_bidder and the new max. maximum bid in uc_rauction from the new bidder db_query('UPDATE {uc_auction} SET high_bidder = %d, mxbid = %d WHERE nid = %d', $user->uid, $form_state['values']['user_bid'], $form_state['values']['nid']); } // Verify if the bid is less than the new_bid_limit which currently is max.max.bid + 6.00 elseif ($form_state['values']['user_bid'] > $m_mxbid && $form_state['values']['user_bid'] > $new_bid_limit && $bid_change_diff > $bid_diff) { global $user; // first write the current max. bid to the bids table from the current high_bidder - added 19/11/2008 $record = array( 'nid' => $form_state['values']['nid'], 'uid' => $node->uc_auction['high_bidder'], 'time' => time(), 'bid' => $node->uc_auction['mxbid'], ); drupal_write_record('uc_auction_bids', $record); // then write the new bid to the bids table from the new bidder. This is currently the max.max.bid + 1.00 $record2 = array( 'nid' => $form_state['values']['nid'], 'uid' => $user->uid, 'time' => time(), 'bid' => $new_sell_price2, ); drupal_write_record('uc_auction_bids', $record2); // update the uc_products table to the new sell_price db_query('UPDATE {uc_products} SET sell_price = %d WHERE nid = %d', $new_sell_price2, $form_state['values']['nid']); // update the high_bidder and the new max. maximum bid in uc_rauction from the new bidder db_query('UPDATE {uc_auction} SET high_bidder = %d, mxbid = %d WHERE nid = %d', $user->uid, $form_state['values']['user_bid'], $form_state['values']['nid']); } else { // current bid is more than max.min.bid (mxbid) + 5.00 global $user; // first write the current min. bid to the bids table from the current high_bidder - added 19/11/2008 $record = array( 'nid' => $form_state['values']['nid'], 'uid' => $node->uc_auction['high_bidder'], 'time' => time(), 'bid' => $m_mxbid, ); drupal_write_record('uc_auction_bids', $record); // then write the new bid to the bids table from the new bidder $record2 = array( 'nid' => $form_state['values']['nid'], 'uid' => $user->uid, 'time' => time(), 'bid' => $form_state['values']['user_bid'], ); drupal_write_record('uc_auction_bids', $record2); // update the uc_products table to the new sell_price db_query('UPDATE {uc_products} SET sell_price = %d WHERE nid = %d', $form_state['values']['user_bid'], $form_state['values']['nid']); // update the high_bidder and the new max. maximum bid in uc_rauction from the new bidder db_query('UPDATE {uc_auction} SET high_bidder = %d, mxbid = %d WHERE nid = %d', $user->uid, $form_state['values']['user_bid'], $form_state['values']['nid']); } } } // Do we want to notify the outbid user? if (variable_get('uc_auction_notify_outbid', TRUE) && $outbid != 0) { $outbid_user = user_load($outbid); if (!isset($outbid_user->uc_auction_notify_outbid) || $outbid_user->uc_auction_notify_outbid) { drupal_mail('uc_auction', 'uc_auction_notify_outbid', $outbid_user->mail, user_preferred_language($outbid_user), array('node' => $node, 'user' => $outbid_user)); watchdog('uc_auction', '@user was notified that they were outbid on an auction for !item.', array('@user' => $outbid_user->name, '!item' => l($node->title, "node/{$node->nid}"))); } } }