/** * 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; }
} else { $paramType = 'received'; } if ($userID != buckys_is_logged_in()) { $baseURLParts[] = "user="******"'s Feedback Given - " . TNB_SITE_NAME; } else { $TNB_GLOBALS['title'] = trim($userData['firstName'] . ' ' . $userData['lastName']) . "'s Feedback Received- " . TNB_SITE_NAME; //Mark the activity (offer received) as read $tradeNotificationIns = new BuckysTradeNotification(); $tradeNotificationIns->markAsRead($userID, BuckysTradeNotification::ACTION_TYPE_FEEDBACK); } } else { $TNB_GLOBALS['title'] = 'Feedback - ' . TNB_SITE_NAME; } 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('trade.css'); buckys_enqueue_javascript('trade.js'); $BUCKYS_GLOBALS['content'] = 'trade/offer_received'; $BUCKYS_GLOBALS['headerType'] = 'trade'; $paramCurrentPage = get_secure_integer($_REQUEST['page']); $paramTargetID = get_secure_integer($_REQUEST['targetID']); $view = array(); //Get offer_received info $tradeOfferIns = new BuckysTradeOffer(); $view['offers'] = $tradeOfferIns->getOfferReceived($userID, $paramTargetID); $view['offers'] = buckys_trade_pagination($view['offers'], '/trade/offer_received.php', $paramCurrentPage, TRADE_ROWS_PER_PAGE); $BUCKYS_GLOBALS['title'] = 'Offer Received - BuckysRoomTrade'; //Mark the activity (offer received) as read $tradeNotificationIns = new BuckysTradeNotification(); $tradeNotificationIns->markAsRead($userID, BuckysTradeNotification::ACTION_TYPE_OFFER_RECEIVED); $tradeOfferIns->markAsRead($userID, BuckysTradeOffer::STATUS_OFFER_ACTIVE); require DIR_FS_TEMPLATE . $BUCKYS_GLOBALS['template'] . "/" . $BUCKYS_GLOBALS['layout'] . ".php";
/** * Update feedback; * * @param integer $feedbackID * @param integer $userID * @param integer $score * @param string $feedback * @return int|void */ public function updateFeedback($feedbackID, $userID, $score, $feedback) { global $db; if (!is_numeric($feedbackID) || !is_numeric($userID) || !is_numeric($score) || $feedback == '') { return; } $feedbackData = $this->getFeedbackByID($feedbackID); $otherUserID = null; if (!$feedbackData) { return; } if ($feedbackData['sellerID'] == $userID && $feedbackData['sellerToBuyerScore'] == 0) { $param = ['sellerToBuyerScore' => $score, 'sellerToBuyerFeedback' => $feedback, 'sellerToBuyerFeedbackCreatedAt' => date('Y-m-d H:i:s')]; $otherUserID = $feedbackData['buyerID']; } else { if ($feedbackData['buyerID'] == $userID && $feedbackData['buyerToSellerScore'] == 0) { $param = ['buyerToSellerScore' => $score, 'buyerToSellerFeedback' => $feedback, 'buyerToSellerFeedbackCreatedAt' => date('Y-m-d H:i:s')]; $otherUserID = $feedbackData['sellerID']; } else { return; //no rights } } $res = $db->updateFromArray(TABLE_TRADE_FEEDBACK, $param, ['feedbackID' => $feedbackID]); if ($otherUserID) { //Update TradeUser Table for rating calculation $this->_updateRanking($otherUserID); //Create notification $tradeNotificationIns = new BuckysTradeNotification(); $tradeNotificationIns->createNotification($otherUserID, $userID, BuckysTradeNotification::ACTION_TYPE_FEEDBACK, $feedbackID); } return $feedbackID; }
/** * Decline offer * * @param integer $offerID */ public function declineOffer($offerID) { global $db; if (!is_numeric($offerID)) { return; } $dateTimeStamp = date('Y-m-d H:i:s'); $query = sprintf("UPDATE %s SET STATUS=%d, lastUpdateDate='%s' WHERE offerID=%d", TABLE_TRADE_OFFERS, BuckysTradeOffer::STATUS_OFFER_DECLINED, $dateTimeStamp, $offerID); $db->query($query); //Notification $tradeItemIns = new BuckysTradeItem(); $offerData = $this->getOfferByID($offerID); if ($offerData) { $buyerItemData = $tradeItemIns->getItemById($offerData['offeredItemID']); $sellerItemData = $tradeItemIns->getItemById($offerData['targetItemID']); if ($buyerItemData) { //Create notification $tradeNotificationIns = new BuckysTradeNotification(); $tradeNotificationIns->createNotification($buyerItemData['userID'], $sellerItemData['userID'], BuckysTradeNotification::ACTION_TYPE_OFFER_DECLINED, $offerID); } } }
" id="emails-notifications-icon"> <span class="dropDownNotificationList"> <?php render_footer_link_content('mail', $newMails); ?> </span> </span> <?php } else { echo '<span class="notificationLinks no-mails inactive-notify no-data" id="emails-notifications-icon"><span class="dropDownNotificationList"><a href="/messages_inbox.php" class="nodata">No new messages</a></span></span>'; } ?> <?php $tradeNotiIns = new BuckysTradeNotification(); $newMsgFlag = 1; $newMsgNum = $tradeNotiIns->getNumOfNewMessages($userID, null, $newMsgFlag); if ($newMsgNum == 0) { $newMsgFlag = 0; $newMsgNum = $tradeNotiIns->getNumOfNewMessages($userID, null, $newMsgFlag); } if ($newMsgNum && $newMsgNum > 0) { $newTradeNotify = $tradeNotiIns->getReceivedMessages($userID, null, $newMsgFlag, $notificationLimit); ?> <span class="notificationLinks <?php if ($newMsgFlag == 0) { echo 'inactive-notify'; } ?> " id="trade-notify-icon">
?> <span class="nodata">There is not a new message.</span> <?php } ?> <a class="view-detail-links" href="/messages_inbox.php"> Go to Inbox </a> </span> </span> <?php } ?> <?php $tradeNotiIns = new BuckysTradeNotification(); $newMsgNum = $tradeNotiIns->getNumOfNewMessages($userID); if ($newMsgNum) { $newMails = $tradeNotiIns->getReceivedMessages($userID); ?> <span class="notificationLinks" id="trade-notify-icon"> <span class="dropDownNotificationList"> <?php foreach ($newMails as $idx => $row) { $htmlBodyContent = ''; if ($row['activityType'] == BuckysTradeNotification::ACTION_TYPE_OFFER_ACCEPTED) { $actionUrl = '/trade/traded.php'; $htmlBodyContent .= sprintf('<span class="redBold">%s</span>', $row['senderName']); $htmlBodyContent .= sprintf('<span> accepted your </span>'); $htmlBodyContent .= sprintf('<span class="redBold">offer</span>'); } else {
$result = ['success' => 1, 'content' => '']; $type = isset($_REQUEST['type']) ? strtolower($_REQUEST['type']) : null; if (isset($_POST['action']) && $_POST['action'] == 'read') { switch ($type) { case 'my': BuckysActivity::markReadNotifications($userID); $notiData = BuckysActivity::getNotifications($userID, $notificationLimit, 0); $result['content'] = render_footer_link_content($type, $notiData, false); break; case 'forum': BuckysForumNotification::makeNotificationsToRead($userID); $notiData = BuckysForumNotification::getNewNotifications($userID, 0, $notificationLimit); $result['content'] = render_footer_link_content($type, $notiData, false); break; case 'trade': $tradeNotiIns = new BuckysTradeNotification(); $tradeNotiIns->markAsRead($userID); $notiData = $tradeNotiIns->getReceivedMessages($userID, null, 0, $notificationLimit); $result['content'] = render_footer_link_content($type, $notiData, false); break; case 'shop': $shopNotiIns = new BuckysShopNotification(); $shopNotiIns->markAsRead($userID); $notiData = $shopNotiIns->getReceivedMessages($userID, null, 0, $notificationLimit); $result['content'] = render_footer_link_content($type, $notiData, false); break; } echo json_encode($result); exit; } echo MSG_INVALID_REQUEST;