コード例 #1
0
 public static function CancelAuction($auctionId)
 {
     global $config, $user;
     // validate args
     $auctionId = floor((int) $auctionId);
     if ($auctionId < 1) {
         $_SESSION['error'][] = 'Invalid auction id!';
         return FALSE;
     }
     // query auction
     $auction = QueryAuctions::QuerySingle($auctionId);
     if (!$auction) {
         $_SESSION['error'][] = 'Auction not found!';
         return FALSE;
     }
     // isAdmin or owns auction
     if (!$user->hasPerms('isAdmin') && $auction->getSellerId() != $user->getId()) {
         $_SESSION['error'][] = 'You don\'t own that auction!';
         return FALSE;
     }
     // remove auction
     self::RemoveAuction($auctionId, -1);
     // add item to inventory
     $tableRowId = ItemFuncs::AddCreateItem($auction->getSellerId(), $auction->getItem());
     // add sale log
     $Item = $auction->getItem();
     LogSales::addLog(LogSales::LOG_CANCEL, LogSales::SALE_BUYNOW, $user->getId(), NULL, $Item, 0.0, FALSE, '');
     return TRUE;
 }