/** * Add feedback * * @param mixed $writerID * @param mixed $score * @param mixed $feedback * @param mixed $activityID * @param mixed $activityType * @return int|null|string|void */ public function addFeedback($writerID, $score, $feedback, $activityID, $activityType = BuckysFeedback::ACTIVITY_TYPE_TRADE) { global $db; if (!is_numeric($activityID) || !is_numeric($writerID) || !is_numeric($score) || $feedback == '') { return; } // failed //If you left feedback already, then return if ($this->hasFeedback($writerID, $activityID, $activityType)) { return; } //exists $param = ['activityID' => $activityID, 'activityType' => $activityType, 'writerID' => $writerID, 'score' => $score, 'comment' => $feedback, 'createdDate' => date('Y-m-d H:i:s')]; $otherUserID = null; switch ($activityType) { case BuckysFeedback::ACTIVITY_TYPE_TRADE: $tradeIns = new BuckysTrade(); $tradeData = $tradeIns->getTradeByID($activityID); if (!$tradeData) { return; } //no such trade if ($tradeData['sellerID'] == $writerID) { $otherUserID = $param['receiverID'] = $tradeData['buyerID']; $param['itemID'] = $tradeData['buyerItemID']; } else { if ($tradeData['buyerID'] == $writerID) { $otherUserID = $param['receiverID'] = $tradeData['sellerID']; $param['itemID'] = $tradeData['sellerItemID']; } else { return; //no rights } } break; case BuckysFeedback::ACTIVITY_TYPE_SHOP: $shopOrderIns = new BuckysShopOrder(); $orderData = $shopOrderIns->getOrderByID($activityID); if (!$orderData || $orderData['buyerID'] != $writerID) { return; } //no such trade $otherUserID = $param['receiverID'] = $orderData['sellerID']; $param['itemID'] = $orderData['productID']; break; default: return; //no such cases break; } $newID = $db->insertFromArray(TABLE_FEEDBACK, $param); if ($newID && $otherUserID) { //Update TradeUser Table for rating calculation $this->_updateRanking($otherUserID); } //Create notification $tradeNotificationIns = new BuckysTradeNotification(); $tradeNotificationIns->createNotification($otherUserID, $writerID, BuckysTradeNotification::ACTION_TYPE_FEEDBACK, $newID); return $newID; }
/** * Save feedback; */ function saveFeedback() { $userID = buckys_is_logged_in(); if (!$userID) { //You should be logged in return; } else { $feedbackIns = new BuckysFeedback(); $orderIns = new BuckysShopOrder(); $orderID = get_secure_integer($_REQUEST['orderID']); $score = get_secure_string($_REQUEST['score']); $feedback = get_secure_string($_REQUEST['feedback']); $orderData = $orderIns->getOrderByID($orderID); $feedbackID = null; if ($orderData['buyerID'] == $userID) { $feedbackID = $feedbackIns->addFeedback($userID, $score, $feedback, $orderID, BuckysFeedback::ACTIVITY_TYPE_SHOP); } if (!$feedbackID) { echo json_encode(['success' => 0, 'msg' => "You do not have permission."]); } else { echo json_encode(['success' => 1, 'msg' => "You have left feedback successfully."]); } } }
<?php require dirname(dirname(__FILE__)) . '/includes/bootstrap.php'; if (!($userID = buckys_is_logged_in())) { buckys_redirect('/index.php', MSG_NOT_LOGGED_IN_USER, MSG_TYPE_ERROR); } buckys_enqueue_stylesheet('shop.css'); buckys_enqueue_javascript('shop.js'); $TNB_GLOBALS['content'] = 'shop/purchase'; $TNB_GLOBALS['headerType'] = 'shop'; $paramCurrentPage = get_secure_integer($_REQUEST['page']); $paramType = get_secure_string($_REQUEST['type']); $view = []; $orderIns = new BuckysShopOrder(); $view['purchase'] = null; $view['type'] = null; if ($paramType == 'archived') { //Purchases archived $view['subtitle'] = 'My Purchases Archived'; $view['purchase'] = $orderIns->getPurchased($userID, BuckysShopOrder::ORDER_ARCHIVED); $view['type'] = 'archived'; } else { //Purchases not archived $view['subtitle'] = 'My Recent Purchases'; $view['purchase'] = $orderIns->getPurchased($userID); } $view['purchase'] = fn_buckys_pagination($view['purchase'], '/shop/purchase.php', $paramCurrentPage, COMMON_ROWS_PER_PAGE); $TNB_GLOBALS['title'] = $view['subtitle'] . ' - BuckysRoomShop'; require DIR_FS_TEMPLATE . $TNB_GLOBALS['template'] . "/" . $TNB_GLOBALS['layout'] . ".php";
<?php require dirname(dirname(__FILE__)) . '/includes/bootstrap.php'; if (!($userID = buckys_is_logged_in())) { buckys_redirect('/index.php', MSG_NOT_LOGGED_IN_USER, MSG_TYPE_ERROR); } buckys_enqueue_stylesheet('shop.css'); buckys_enqueue_javascript('shop.js'); $TNB_GLOBALS['content'] = 'shop/sold'; $TNB_GLOBALS['headerType'] = 'shop'; //Update sold notification as read $notificationIns = new BuckysShopNotification(); $notificationIns->markAsRead($userID, BuckysShopNotification::ACTION_TYPE_PRODUCT_SOLD); $paramCurrentPage = get_secure_integer(isset($_REQUEST['page']) ? $_REQUEST['page'] : null); $paramType = get_secure_string(isset($_REQUEST['type']) ? $_REQUEST['type'] : ""); $view = []; $orderIns = new BuckysShopOrder(); $view['sold'] = $orderIns->getSold($userID); //Update Sold product as read $orderIns->updateSoldAsRead($userID); $view['sold'] = fn_buckys_pagination($view['sold'], '/shop/sold.php', $paramCurrentPage, COMMON_ROWS_PER_PAGE); $TNB_GLOBALS['title'] = 'My Sold Items - BuckysRoomShop'; require DIR_FS_TEMPLATE . $TNB_GLOBALS['template'] . "/" . $TNB_GLOBALS['layout'] . ".php";
<?php /** * Display shop left side navitation */ $soldItemCount = 0; $userData = $TNB_GLOBALS['user']; if (isset($userData) && isset($userData['userID'])) { $orderIns = new BuckysShopOrder(); $soldItemCount = $orderIns->getNewSoldItemCount($userData['userID']); } ?> <aside id="main_aside" class="shop-left-panel"> <span class="titles">Shop Account</span> <a href="/shop/available.php" class="accountLinks" style="margin-top:10px;">Selling</a> <a href="/shop/available.php" class="accountSubLinks">Selling Now</a> <br/> <a href="/shop/sold.php" class="accountSubLinks<?php echo $soldItemCount > 0 ? 'Bold' : ''; ?> ">Sold<?php echo $soldItemCount > 0 ? ' (' . $soldItemCount . ') ' : ''; ?> </a><br/> <a href="/shop/available.php?type=expired" class="accountSubLinks">Expired</a> <br/><br/> <a href="/shop/purchase.php" class="accountLinks">Purchases</a> <a href="/shop/purchase.php" class="accountSubLinks">Recent</a> <br/> <a href="/shop/purchase.php?type=archived" class="accountSubLinks">Archived</a> <br/><br/> <a href="/notify.php" class="accountLinks">Shop Settings</a> <a href="/notify.php"