case "my_watch_list_view.php": $refer[] = "Back to My Watched Auctions"; break; case "my_current_bids_view.php": $refer[] = "Back to My Current Bids"; break; case "my_successful_bids_view.php": $refer[] = "Back to My Won Auctions"; break; case "my_unsuccessful_bids_view.php": $refer[] = "Back to My Lost Auctions"; break; } } $auction = QueryOperator::getLiveAuction($auctionId); $bids = QueryOperator::getAuctionBids($auction->getAuctionId()); $watches = QueryOperator::getAuctionWatches($auction->getAuctionId()); $isMyAuction = $auction->getSellerUsername() == SessionOperator::getUser()->getUsername(); //increment num_views of auction on database $dbAuction = DbAuction::find($auctionId); $dbAuction->setField("views", $dbAuction->getField("views") + 1); $dbAuction->save(); //increment views displayed on page $views = $auction->getViews() + 1; //is user watching this auction $user = SessionOperator::getUser(); $alreadyWatching = DbAuctionWatch::withConditions("WHERE userId = " . $user->getUserId() . " AND auctionId =" . $auctionId)->exists(); ?> <!DOCTYPE html> <html lang="en">
$auctionId = $_GET["id"]; // Prevent sql injection if (!is_numeric($auctionId)) { HelperOperator::redirectTo("../views/my_live_auctions_view.php"); } /* @var User $user */ $user = SessionOperator::getUser(); $userId = $user->getUserId(); /* @var DbAuction $auction */ /* @var DbItem $item */ $auction = DbAuction::find($auctionId); $item = DbItem::find($auction->getField("itemId")); // User owns auction if ($item->getField("userId") == $userId) { // Notifiy current highest bidder $highestBid = QueryOperator::getAuctionBids($auctionId, 1)[0]; if (!empty($highestBid)) { $comment = "The auction \"" . $item->getField("itemName") . " " . $item->getField("itemBrand") . "\" with "; $comment .= "your current highest bid of " . $highestBid->getBidPrice() . " GSP was deleted by " . $user->getUsername() . "."; QueryOperator::addNotification($highestBid->getBidderId(), $comment, QueryOperator::NOTIFICATION_AUCTION_DELETED); } // Delete auction $auction->delete(); if (!empty($imageName = $item->getField("image"))) { unlink(ROOT . $imageName); } // Delete auction event QueryOperator::dropAuctionEvent($auctionId); // Set feedback session SessionOperator::setNotification(SessionOperator::DELETED_AUCTION); }
public static function checkBidPrice($input, $auctionId) { $currentHighestBid = QueryOperator::getAuctionBids($auctionId, 1); // There exists a highest bid if (!empty($currentHighestBid)) { $currentHighestBid = $currentHighestBid[0]->getBidPrice(); $currentHighestBid += HelperOperator::getIncrement($currentHighestBid); } else { $currentHighestBid = -1; } // Invalid bid price if ($input < $currentHighestBid) { SessionOperator::setInputErrors(["bidPrice" => self::PRICES[self::INVALID_BID] . $currentHighestBid]); return false; } // No error return true; }