/** * It will create Notification on Activities table * * @param integer $userID * @param integer $senderID (the man who creates this alert) * @param string $actionType : one of action types (const defined for this class) * @param integer $actionID : related trade offer, feedback ID */ function createNotification($userID, $senderID, $actionType, $actionID) { //Check if this user will get this notification. (it will be set by Notification setting page) $tradeUserIns = new BuckysTradeUser(); $userData = $tradeUserIns->getUserByID($userID); $flagEnabled = 0; // user checked that he didn't want to have this notification switch ($actionType) { case BuckysActivity::ACTION_TYPE_OFFER_ACCEPTED: $notificationType = BuckysActivity::NOTIFICATION_TYPE_OFFER_ACCEPTED; $flagEnabled = $userData['optOfferAccepted']; break; case BuckysActivity::ACTION_TYPE_OFFER_RECEIVED: $notificationType = BuckysActivity::NOTIFICATION_TYPE_OFFER_RECEIVED; $flagEnabled = $userData['optOfferReceived']; break; case BuckysActivity::ACTION_TYPE_OFFER_DECLINED: $notificationType = BuckysActivity::NOTIFICATION_TYPE_OFFER_DECLINED; $flagEnabled = $userData['optOfferDeclined']; break; case BuckysActivity::ACTION_TYPE_FEEDBACK: $notificationType = BuckysActivity::NOTIFICATION_TYPE_OFFER_FEEDBACK; $flagEnabled = $userData['optFeedbackReceived']; break; } if ($flagEnabled == 1) { //Create Notification. $activityIns = new BuckysActivity(); $activityId = $activityIns->addActivity($userID, $senderID, $this->objectType, $actionType, $actionID); $activityIns->addNotification($userID, $activityId, $notificationType); } }
/** * It will create Notification on Activities table * * @param integer $userID * @param integer $senderID (the man who creates this alert) * @param string $actionType : one of action types (const defined for this class) * @param integer $actionID : related shop order ID */ function createNotification($userID, $senderID, $actionType, $actionID) { //Check if this user will get this notification. (it will be set by Notification setting page) $userIns = new BuckysTradeUser(); $userData = $userIns->getUserByID($userID); $flagEnabled = 0; // user checked that he didn't want to have this notification switch ($actionType) { case BuckysActivity::ACTION_TYPE_PRODUCT_SOLD: $flagEnabled = $userData['optProductSoldOnShop']; break; } if ($flagEnabled == 1) { //Create Notification. $activityIns = new BuckysActivity(); $activityId = $activityIns->addActivity($userID, $senderID, $this->objectType, $actionType, $actionID); $activityIns->addNotification($userID, $activityId, BuckysActivity::NOTIFICATION_TYPE_PRODUCT_SOLD); } }
<?php require dirname(__FILE__) . '/includes/bootstrap.php'; if (!($userID = buckys_is_logged_in())) { buckys_redirect('/index.php', MSG_NOT_LOGGED_IN_USER, MSG_TYPE_ERROR); } $view = []; //Save Shipping info $tradeUserIns = new BuckysTradeUser(); if (isset($_POST['action']) && $_POST['action'] == 'saveNotifyInfo') { $result = BuckysUser::saveUserNotificationSettings($userID, $_POST); if ($result === true) { buckys_redirect('/notify.php', MSG_NOTIFICATION_SETTINGS_SAVED); } else { buckys_redirect('/notify.php', $result, MSG_TYPE_ERROR); } } //Get offer_received info $view['trade_user_info'] = $tradeUserIns->getUserByID($userID); $userNotifyInfo = BuckysUser::getUserNotificationSettings($userID); if (empty($view['trade_user_info'])) { buckys_redirect('/index.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR); } buckys_enqueue_stylesheet('account.css'); buckys_enqueue_stylesheet('info.css'); $TNB_GLOBALS['content'] = 'notify'; $TNB_GLOBALS['title'] = 'Notification Settings - ' . TNB_SITE_NAME; require DIR_FS_TEMPLATE . $TNB_GLOBALS['template'] . "/" . $TNB_GLOBALS['layout'] . ".php";
$userData = $userIns->getUserData($view['product']['userID']); if ($userData['status'] == BuckysUser::STATUS_USER_BANNED) { buckys_redirect('/shop/index.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR); } //Read more info from DB $catData = $catIns->getCategoryByID($view['product']['catID']); $view['product']['categoryName'] = isset($catData) ? $catData['name'] : ''; $countryData = $countryIns->getCountryById($view['product']['locationID']); $view['product']['locationName'] = isset($countryData) ? $countryData['country_title'] : ''; $view['product']['userInfo'] = $userIns->getUserBasicInfo($view['product']['userID']); if (!isset($view['product']['userInfo'])) { buckys_redirect('/shop/index.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR); } $view['my_product_flag'] = false; $view['available_shipping_price'] = null; $view['my_shipping_info'] = $myShippingData = $shippingInfoIns->getUserByID($userID); $view['fill_shipping_info'] = false; $view['my_info'] = $userIns->getUserBasicInfo($userID); $view['is_purchased'] = $shopProductIns->isPurchased($userID, $paramShopID); if (!$userID || $userID == $view['product']['userID']) { $view['my_product_flag'] = true; } else { if ($view['product']['isDownloadable'] == 1) { $view['available_shipping_price'] = true; } else { //shipping price show $productShippingInfo = $shopProductIns->getShippingPrice($view['product']['productID']); if (isset($myShippingData)) { if (is_numeric($myShippingData['shippingCountryID']) && $myShippingData['shippingCountryID'] > 0) { $view['available_shipping_price'] = fn_buckys_get_available_shipping_price($userID, $view['product']['productID']); } else {
/** * Create shipping info * * @param mixed $userID */ public function createShippingInfo($userID) { global $db; $newID = null; $shippingInfoIns = new BuckysTradeUser(); $myShippingData = $shippingInfoIns->getUserByID($userID); if (!$myShippingData) { return; } $param = ['address' => $myShippingData['shippingAddress'], 'address2' => $myShippingData['shippingAddress2'], 'city' => $myShippingData['shippingCity'], 'state' => $myShippingData['shippingState'], 'zip' => $myShippingData['shippingZip'], 'countryID' => $myShippingData['shippingCountryID']]; $newID = $db->insertFromArray(TABLE_SHOP_ORDERS_SHIPPING, $param); return $newID; }
/** * @param $buyerID * @param $productID * @return null */ function fn_buckys_get_available_shipping_price($buyerID, $productID) { $shopProductIns = new BuckysShopProduct(); $shippingInfoIns = new BuckysTradeUser(); $myShippingData = $shippingInfoIns->getUserByID($buyerID); $productShippingInfo = $shopProductIns->getShippingPrice($productID); $availableShippingPrice = null; if ($myShippingData) { if (is_numeric($myShippingData['shippingCountryID']) && $myShippingData['shippingCountryID'] > 0) { if (is_array($productShippingInfo) && count($productShippingInfo) > 0) { foreach ($productShippingInfo as $shippingData) { if ($shippingData['locationID'] == $myShippingData['shippingCountryID']) { $availableShippingPrice = $shippingData['price']; } else { if ($shippingData['locationID'] == BuckysShopProduct::SHIPPING_LOCATION_WORLDWIDE && $availableShippingPrice == null) { $availableShippingPrice = $shippingData['price']; } } } } } } return $availableShippingPrice; }
$paramType = 'received'; } if ($userID != buckys_is_logged_in()) { $baseURLParts[] = "user="******"'s Feedback Given - BuckysRoomTrade"; } else { $BUCKYS_GLOBALS['title'] = trim($userData['firstName'] . ' ' . $userData['lastName']) . "'s Feedback Received- BuckysRoomTrade"; //Mark the activity (offer received) as read $tradeNotificationIns = new BuckysTradeNotification(); $tradeNotificationIns->markAsRead($userID, BuckysTradeNotification::ACTION_TYPE_FEEDBACK); } } else { $BUCKYS_GLOBALS['title'] = 'Feedback - BuckysRoomTrade'; } require DIR_FS_TEMPLATE . $BUCKYS_GLOBALS['template'] . "/" . $BUCKYS_GLOBALS['layout'] . ".php";