/**
  * 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);
     }
 }
 /**
  * Add Trade Item
  *
  * @param array $data
  * @return int|null|string|void
  */
 public function addItem($data, $paymentType = BuckysTradeItem::LIST_FEE_PAYMENT_TYPE_BTC)
 {
     $tradeUserIns = new BuckysTradeUser();
     /* FreeTradeListings - uncomment to enable listing fees
        if (!$this->hasMoneyToListTradeItem($data['userID'], $paymentType)) {
            //You don't have money to list this product
            return;
        }
        */
     global $db;
     if (empty($data['userID']) || empty($data['title']) || empty($data['subtitle']) || empty($data['catID'])) {
         return;
     }
     $newID = $db->insertFromArray(TABLE_TRADE_ITEMS, $data);
     //Trade User has been created?
     $tradeUserIns->addUser($data['userID']);
     /* FreeTradeListings - uncomment to enable listing fees
        //Use one credits
        if ($newID) {
            //$tradeUserIns->useCredit($data['userID']);
            
            $flag = $this->payListingFee($data['userID'], $newID, $paymentType);
            
            if (!$flag) {
                $this->removeItems($newID);
                return; //failed since we can't charge you.
            }
            
        }
        */
     return $newID;
 }
 /**
  * Check if the user has credits or BTC to list the product
  *
  * @param mixed $userID
  * @param mixed $paymentType
  * @return boolean
  */
 public function hasMoneyToListProduct($userID, $paymentType = BuckysShopProduct::LIST_FEE_PAYMENT_TYPE_BTC)
 {
     if ($paymentType == BuckysShopProduct::LIST_FEE_PAYMENT_TYPE_CREDIT) {
         $tradeUserIns = new BuckysTradeUser();
         return $tradeUserIns->hasCredits($userID, SHOP_PRODUCT_LISTING_FEE_IN_CREDIT);
     } else {
         if ($paymentType == BuckysShopProduct::LIST_FEE_PAYMENT_TYPE_BTC) {
             $balance = BuckysBitcoin::getUserWalletBalance($userID);
             return $balance >= SHOP_PRODUCT_LISTING_FEE_IN_BTC;
         } else {
             return false;
         }
     }
 }
 /**
  * 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);
     }
 }
 /**
  * Add Trade Item
  * 
  * @param array $data
  */
 public function addItem($data)
 {
     $tradeUserIns = new BuckysTradeUser();
     if (!$tradeUserIns->hasCredits($data['userID'])) {
         return;
     }
     // no credits
     global $db;
     if (empty($data['userID']) || empty($data['title']) || empty($data['subtitle']) || empty($data['catID'])) {
         return;
     }
     $newID = $db->insertFromArray(TABLE_TRADE_ITEMS, $data);
     //Trade User has been created?
     $tradeUserIns->addUser($data['userID']);
     //Use one credits
     if ($newID) {
         $tradeUserIns->useCredit($data['userID']);
     }
     return $newID;
 }
<?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";
示例#7
0
<?php

require dirname(dirname(__FILE__)) . '/includes/bootstrap.php';
buckys_enqueue_stylesheet('trade.css');
buckys_enqueue_javascript('trade.js');
$BUCKYS_GLOBALS['content'] = 'trade/index';
$BUCKYS_GLOBALS['headerType'] = 'trade';
//Get Top Users
$tradeUserIns = new BuckysTradeUser();
$tradeItemIns = new BuckysTradeItem();
$view = array();
$view['top_users'] = $tradeUserIns->getUsersTopByItems(10);
$view['top_wanted_items'] = $tradeItemIns->getItemsTopByOffers(10);
$view['recent_items'] = $tradeItemIns->getRecentItems(10);
$BUCKYS_GLOBALS['title'] = 'BuckysRoomTrade';
require DIR_FS_TEMPLATE . $BUCKYS_GLOBALS['template'] . "/" . $BUCKYS_GLOBALS['layout'] . ".php";
/**
 * Edit trade item action by ajax
 */
function editTradeItem()
{
    $userID = buckys_is_logged_in();
    if (!$userID) {
        return;
    }
    $tradeItemIns = new BuckysTradeItem();
    $inputValidFlag = true;
    $requiredFields = ['title', 'subtitle', 'description', 'category'];
    foreach ($requiredFields as $requiredField) {
        if ($_REQUEST[$requiredField] == '') {
            $inputValidFlag = false;
        }
    }
    $actionType = get_secure_string($_REQUEST['type']);
    $paramItemID = get_secure_integer($_REQUEST['itemID']);
    $data = [];
    $editableFlag = false;
    if ($actionType == 'relist') {
        $tradeItemData = $tradeItemIns->getItemById($paramItemID, true);
        if (!$tradeItemData) {
            echo json_encode(['success' => 0, 'msg' => 'You could not relist this item.']);
            exit;
        }
        //you can relist this item
        $data['createdDate'] = date('Y-m-d H:i:s');
        $tradeUserIns = new BuckysTradeUser();
        if (!$tradeUserIns->hasCredits($userID)) {
            echo json_encode(['success' => 0, 'msg' => 'You could not relist this item. You have no credits.']);
            exit;
        }
        if ($tradeItemData['userID'] == $userID) {
            $editableFlag = true;
        } else {
            $editableFlag = false;
        }
    } else {
        $tradeItemData = $tradeItemIns->getItemById($paramItemID, false);
        if ($tradeItemData && $tradeItemData['userID'] == $userID) {
            $editableFlag = true;
        }
    }
    if ($inputValidFlag) {
        if ($editableFlag) {
            $data['title'] = get_secure_string($_REQUEST['title']);
            $data['subtitle'] = get_secure_string($_REQUEST['subtitle']);
            $data['description'] = get_secure_string($_REQUEST['description']);
            $data['itemWanted'] = get_secure_string($_REQUEST['items_wanted']);
            $data['images'] = get_secure_string($_REQUEST['images']);
            $data['catID'] = get_secure_string($_REQUEST['category']);
            $data['locationID'] = get_secure_string($_REQUEST['location']);
            $data['listingDuration'] = get_secure_string($_REQUEST['listing_duration']);
            $data['expiryDate'] = $data['listingDuration'] == -1 ? '0000-00-00 00:00:00' : date('Y-m-d H:i:s', time() + 3600 * 24 * $data['listingDuration']);
            $data['images'] = moveTradeTmpImages($data['images']);
            if ($data['images'] === false) {
                echo json_encode(['success' => 0, 'msg' => 'Something goes wrong, please contact administrator.']);
                exit;
            }
            if ($actionType == 'relist') {
                $tradeUserIns->useCredit($userID);
            }
            $tradeItemIns->updateItem($paramItemID, $data);
            echo json_encode(['success' => 1, 'msg' => 'An item has been updated successfully.']);
        } else {
            echo json_encode(['success' => 0, 'msg' => "You don't have permission."]);
        }
    } else {
        //error
        echo json_encode(['success' => 0, 'msg' => 'Please input required field(s).']);
    }
}
示例#9
0
<?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/shipping_info';
$BUCKYS_GLOBALS['headerType'] = 'trade';
$view = array();
//Save Shipping info
$tradeUserIns = new BuckysTradeUser();
$countryIns = new BuckysCountry();
$view['update_message'] = '';
if ($_POST['action'] == 'saveShippingInfo') {
    $paramData = array('shippingAddress' => $_POST['shippingAddress'], 'shippingCity' => $_POST['shippingCity'], 'shippingState' => $_POST['shippingState'], 'shippingZip' => $_POST['shippingZip'], 'shippingCountryID' => $_POST['shippingCountryID']);
    $retVal = $tradeUserIns->updateShippingInfo($userID, $paramData);
    if ($retVal == false) {
        $view['update_message'] = 'Something goes wrong';
    } else {
        $view['update_message'] = 'Your shipping info has been updated successfully.';
    }
}
//Get offer_received info
$view['trade_user_info'] = $tradeUserIns->getUserByID($userID);
$view['country_list'] = $countryIns->getCountryList();
if (empty($view['trade_user_info'])) {
    buckys_redirect('/trade/index.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
}
$BUCKYS_GLOBALS['title'] = 'Shipping Info - BuckysRoomTrade';
}
buckys_enqueue_stylesheet('uploadify.css');
buckys_enqueue_stylesheet('jquery.Jcrop.css');
buckys_enqueue_stylesheet('trade.css');
buckys_enqueue_javascript('uploadify/jquery.uploadify.js');
buckys_enqueue_javascript('jquery.Jcrop.js');
buckys_enqueue_javascript('jquery.color.js');
buckys_enqueue_javascript('trade.js');
buckys_enqueue_javascript('trade-edit.js');
buckys_enqueue_javascript('uploadify/flash_install.js');
$TNB_GLOBALS['content'] = 'trade/additem';
$TNB_GLOBALS['headerType'] = 'trade';
$view = [];
$tradeCatIns = new BuckysTradeCategory();
$countryIns = new BuckysCountry();
$tradeUserIns = new BuckysTradeUser();
$view['no_cash'] = false;
$view['no_credits'] = false;
if (!$tradeUserIns->hasCredits($userID)) {
    $view['no_credits'] = true;
}
$userInfo = BuckysUser::getUserBasicInfo($userID);
$view['category_list'] = $tradeCatIns->getCategoryList(0);
$view['country_list'] = $countryIns->getCountryList();
$view['action_name'] = 'addTradeItem';
$view['page_title'] = 'Add an Item';
$view['type'] = 'additem';
$view['my_bitcoin_balance'] = BuckysBitcoin::getUserWalletBalance($userID);
$view['my_credit_balance'] = $userInfo['credits'];
if ($view['my_bitcoin_balance'] < TRADE_ITEM_LISTING_FEE_IN_BTC && $view['my_credit_balance'] < TRADE_ITEM_LISTING_FEE_IN_CREDIT) {
    $view['no_cash'] = true;
 /**
  * It will update user feedback ranking when you leave feedback;
  */
 public function _updateRanking($userID)
 {
     if (!is_numeric($userID)) {
         return;
     }
     $tradeUserIns = new BuckysTradeUser();
     $totalFeedback = $this->getReceivedFeedbackCount($userID, false);
     $positiveFeedback = $this->getReceivedFeedbackCount($userID, true);
     $tradeUserIns->updateTradeUser($userID, ['totalRating' => $totalFeedback, 'positiveRating' => $positiveFeedback]);
 }
示例#12
0
<?php

require dirname(dirname(__FILE__)) . '/includes/bootstrap.php';
$userID = buckys_is_logged_in();
buckys_enqueue_stylesheet('shop.css');
buckys_enqueue_javascript('shop.js');
$TNB_GLOBALS['content'] = 'shop/view';
$TNB_GLOBALS['headerType'] = 'shop';
$paramShopID = get_secure_integer($_REQUEST['id']);
$view = [];
$shopProductIns = new BuckysShopProduct();
$catIns = new BuckysShopCategory();
$countryIns = new BuckysCountry();
$userIns = new BuckysUser();
$shippingInfoIns = new BuckysTradeUser();
$view['product'] = $shopProductIns->getProductById($paramShopID);
$view['myID'] = $userID;
if (!isset($view['product']) || $view['product']['status'] == BuckysShopProduct::STATUS_INACTIVE) {
    buckys_redirect('/shop/index.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
}
//Check if the items owner is active one
$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']);
 /**
  * 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;
}
示例#15
0
$baseURLParts = array();
if ($paramType == 'given') {
    $baseURLParts[] = "type=" . $paramType;
} else {
    $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);
    }