/** * Change offer status 1) to Activate 2) to make inactive * It will find all offers related to this user, and change status as the $status parameter * This function will be called when banning the user or unbanning the user * * @param integer $userID * @param integer $status (one of STATUS_OFFER_INACTIVE, STATUS_OFFER_ACTIVE) * @return bool|void */ public function massStatusChange($userID, $status = BuckysTradeOffer::STATUS_OFFER_INACTIVE) { global $db; if (!is_numeric($userID)) { return; } $tradeItemIns = new BuckysTradeItem(); $itemList = $tradeItemIns->getItemList($userID); $itemIDList = []; if (count($itemList) > 0) { foreach ($itemList as $itemData) { $itemIDList[] = $itemData['itemID']; } } $itemStr = ''; if (count($itemIDList) > 0) { $itemStr = implode(',', $itemIDList); if ($status == BuckysTradeOffer::STATUS_OFFER_INACTIVE) { //make pending offers to inactive status $query = sprintf('UPDATE %s SET STATUS=%d WHERE (targetItemID IN (%s) OR offeredItemID IN (%s)) AND STATUS=%d', TABLE_TRADE_OFFERS, BuckysTradeOffer::STATUS_OFFER_INACTIVE, $itemStr, $itemStr, BuckysTradeOffer::STATUS_OFFER_ACTIVE); } else { if ($status == BuckysTradeOffer::STATUS_OFFER_ACTIVE) { //Make inactive offers to pending status $query = sprintf('UPDATE %s SET STATUS=%d WHERE (targetItemID IN (%s) OR offeredItemID IN (%s)) AND STATUS=%d', TABLE_TRADE_OFFERS, BuckysTradeOffer::STATUS_OFFER_ACTIVE, $itemStr, $itemStr, BuckysTradeOffer::STATUS_OFFER_INACTIVE); } else { //We don't have this case return; } } $db->query($query); } return true; }
if ($userData['status'] == BuckysUser::STATUS_USER_BANNED) { buckys_redirect('/trade/index.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR); } //Read more info from DB $catData = $tradeCatIns->getCategoryByID($view['item']['catID']); $view['item']['categoryName'] = isset($catData) ? $catData['name'] : ''; $countryData = $countryIns->getCountryById($view['item']['locationID']); $view['item']['locationName'] = isset($countryData) ? $countryData['country_title'] : ''; $view['item']['userInfo'] = $userIns->getUserBasicInfo($view['item']['userID']); if (!isset($view['item']['userInfo'])) { buckys_redirect('/trade/index.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR); } //Check if you can make an offer to this user. If this user decline your offer before for this item, then you can't send again $view['offerDisabled'] = false; if (!$userID || $userID == $view['item']['userID']) { $view['offerDisabled'] = true; } else { /** * If it has been set, then it means you can't make an offer if one of your offer declined by this user. * When you enable this block, please note BuckysTradeOffer::addOffer() function, there are parts disabled */ //$view['offerDisabled'] = $tradeOfferIns->checkDeclinedOffer($view['item']['itemID'], null, $userID); } //If you are logged in, then get available to make an offer $view['availableItems'] = array(); if ($userID && is_numeric($userID) && $view['offerDisabled'] == false) { $view['availableItems'] = $tradeItemIns->getItemList($userID, false, BuckysTradeItem::STATUS_ITEM_ACTIVE); $view['availableItems'] = $tradeOfferIns->getAvailableItemList($view['item']['itemID'], $view['availableItems']); } $BUCKYS_GLOBALS['title'] = $view['item']['title'] . ' - BuckysRoomTrade'; require DIR_FS_TEMPLATE . $BUCKYS_GLOBALS['template'] . "/" . $BUCKYS_GLOBALS['layout'] . ".php";
buckys_enqueue_javascript('trade.js'); $TNB_GLOBALS['content'] = 'trade/available'; $TNB_GLOBALS['headerType'] = 'trade'; $paramCurrentPage = get_secure_integer($_REQUEST['page']); $paramType = get_secure_string($_REQUEST['type']); $view = []; //Get available items $tradeItemIns = new BuckysTradeItem(); $baseURL = '/trade/available.php'; if ($paramType == 'expired') { $baseURL .= "?type=" . $paramType; } else { $paramType = ''; } switch ($paramType) { case 'expired': $view['pagetitle'] = 'My Expired Items'; $view['items'] = $tradeItemIns->getItemList($userID, true, BuckysTradeItem::STATUS_ITEM_ACTIVE); $view['type'] = 'expired'; break; case 'available': default: $view['items'] = $tradeItemIns->getItemList($userID, false, BuckysTradeItem::STATUS_ITEM_ACTIVE); $view['pagetitle'] = 'My Available Items'; $view['type'] = 'available'; break; } $view['items'] = fn_buckys_pagination($view['items'], $baseURL, $paramCurrentPage, COMMON_ROWS_PER_PAGE); $view['type'] = $paramType; $TNB_GLOBALS['title'] = $view['pagetitle'] . ' - BuckysRoomTrade'; require DIR_FS_TEMPLATE . $TNB_GLOBALS['template'] . "/" . $TNB_GLOBALS['layout'] . ".php";