Ejemplo n.º 1
0
 /**
  * @param int $userSID
  * @param int $productSID
  * @param int $contractID
  * @param int $listingNumber
  */
 public static function activateListingsAfterPaid($userSID, $productSID, $contractID, $listingNumber)
 {
     $limit = '';
     if ($listingNumber != null) {
         $limit = 'LIMIT 0,' . $listingNumber;
     }
     $serializedProductSID = SJB_ProductsManager::generateQueryBySID($productSID);
     $listingsSIDsToProceed = SJB_DB::query("SELECT `sid` FROM `listings` WHERE `checkouted` = 0 AND `complete` = 1 AND `contract_id` = 0 AND `user_sid` = ?n AND `product_info` REGEXP '({$serializedProductSID})' ORDER BY `sid` DESC {$limit}", $userSID);
     if (!empty($listingsSIDsToProceed)) {
         foreach ($listingsSIDsToProceed as $listingSIDToProceed) {
             SJB_DB::query('UPDATE `listings` SET `contract_id` = ?n, `checkouted` = 1 WHERE `sid` = ?n', $contractID, $listingSIDToProceed['sid']);
             self::activateListingBySID($listingSIDToProceed['sid']);
         }
         SJB_ProductsManager::incrementPostingsNumber($productSID, count($listingsSIDsToProceed));
         SJB_ContractSql::updatePostingsNumber($contractID, count($listingsSIDsToProceed));
     }
 }
Ejemplo n.º 2
0
 /**
  * @param $userSID
  * @param $productSID
  * @param $limitCheckoutedListingsToDelete
  */
 public function deleteCheckoutedListingsByProduct($userSID, $productSID, $limitCheckoutedListingsToDelete)
 {
     $serializedProductSID = SJB_ProductsManager::generateQueryBySID($productSID);
     $listingsToDelete = SJB_DB::query("SELECT `sid` FROM `listings` WHERE `checkouted` = 0 AND `complete` = 1 AND `contract_id` = 0 AND `user_sid` = ?n AND `product_info` REGEXP '({$serializedProductSID})' ORDER BY `sid` DESC LIMIT ?n", $userSID, $limitCheckoutedListingsToDelete);
     $criteriaSaver = new SJB_ListingCriteriaSaver('MyListings');
     $foundListingsSIDs = $criteriaSaver->getObjectSIDs();
     foreach ($listingsToDelete as $listing) {
         SJB_ListingManager::deleteListingBySID($listing['sid']);
         if ($foundListingsSIDs != null) {
             $key = array_search($listing['sid'], $foundListingsSIDs);
             unset($foundListingsSIDs[$key]);
         }
     }
     if ($foundListingsSIDs != null) {
         $criteriaSaver->setSessionForObjectSIDs($foundListingsSIDs);
     }
 }
Ejemplo n.º 3
0
 public static function getNumberOfCheckoutedListingsByProductSID($productSID, $currentUserID)
 {
     $serializedProductSID = SJB_ProductsManager::generateQueryBySID($productSID);
     return SJB_DB::queryValue("SELECT COUNT(`sid`) FROM `listings` WHERE `checkouted` = 0 AND `complete` = 1 AND `contract_id` = 0 AND `user_sid` = ?n AND `product_info` REGEXP '({$serializedProductSID})'", $currentUserID);
 }