예제 #1
0
 function isDataValid(&$errors)
 {
     $errors = array();
     if ($this->name == '') {
         $errors['Zip Code'] = 'EMPTY_VALUE';
     }
     $count = SJB_DB::queryValue("SELECT count(*) FROM `locations` WHERE `name` = ?s AND `country_sid` = ?s AND `state` = ?s AND `city` = ?s AND sid <> ?n ", $this->name, $this->country_sid, $this->state, $this->city, $this->sid);
     if ($count) {
         $errors['Zip Code'] = 'NOT_UNIQUE_VALUE';
     }
     if ($this->longitude == '') {
         $errors['Longitude'] = 'EMPTY_VALUE';
     } elseif (!is_numeric($this->longitude)) {
         $errors['Longitude'] = 'NOT_FLOAT_VALUE';
     }
     if ($this->latitude == '') {
         $errors['Latitude'] = 'EMPTY_VALUE';
     } elseif (!is_numeric($this->latitude)) {
         $errors['Latitude'] = 'NOT_FLOAT_VALUE';
     }
     if ($this->country_sid == '') {
         $errors['Country'] = 'EMPTY_VALUE';
     }
     return count($errors) == 0;
 }
예제 #2
0
 public static function saveListingOnDB($listing_sid, $user_sid)
 {
     $record_exists = SJB_DB::queryValue("SELECT COUNT(*) FROM saved_listings WHERE user_sid = ?n AND listing_sid = ?n", $user_sid, $listing_sid);
     if (!$record_exists) {
         SJB_DB::query("INSERT INTO saved_listings SET listing_sid = ?n, user_sid = ?n", $listing_sid, $user_sid);
     }
 }
예제 #3
0
파일: admin.php 프로젝트: Maxlander/shixi
 public static function isAdminExist($username, $password)
 {
     $username = SJB_DB::quote($username);
     $password = md5(SJB_DB::quote($password));
     $value = SJB_DB::queryValue("SELECT * FROM `administrator` WHERE `username` = ?s AND `password` = '?w'", $username, $password);
     return !empty($value);
 }
예제 #4
0
 /**
  * @param $feedSID
  * @return mixed|null
  */
 public function getSavedAccessToken($feedSID)
 {
     if ($feedSID) {
         $accessToken = SJB_DB::queryValue('SELECT `access_token` FROM `twitter_feeds` WHERE `sid` = ?s', $feedSID);
         if (!empty($accessToken)) {
             return unserialize($accessToken);
         }
     }
     return null;
 }
예제 #5
0
 public static function isSubAdminExist()
 {
     $username = SJB_DB::quote(SJB_Request::getVar('username'));
     $password = md5(SJB_DB::quote(SJB_Request::getVar('password')));
     $value = SJB_DB::queryValue("SELECT * FROM `subadmins` WHERE `username` = ?s AND `password` = '?w'", $username, $password);
     if (empty($value)) {
         return false;
     }
     return true;
 }
 public function saveListItem($list_item)
 {
     $item_sid = $list_item->getSID();
     if (is_null($item_sid)) {
         $max_order = SJB_DB::queryValue("SELECT MAX(`order`) FROM `" . $this->table_prefix . "_field_list` WHERE `field_sid` = ?n", $list_item->getFieldSID());
         $max_order = empty($max_order) ? 0 : $max_order;
         return SJB_DB::query("INSERT INTO `" . $this->table_prefix . "_field_list` SET `field_sid` = ?n, `value` = ?s, `order` = ?n, `score` = ?s", $list_item->getFieldSID(), $list_item->getValue(), ++$max_order, $list_item->score);
     } else {
         return SJB_DB::query("UPDATE `" . $this->table_prefix . "_field_list` SET `value` = ?s WHERE `sid` = ?n", $list_item->getValue(), $item_sid);
     }
 }
예제 #7
0
 public function getItemsFromDB($uri, $decorate = false)
 {
     $items = SJB_DB::queryValue("SELECT `data` FROM `browse` WHERE `page_uri` = ?s", $uri);
     $items = unserialize($items);
     if ($decorate) {
         $searcherFactory = $this->searcherFactory;
         $categorySearcher = $searcherFactory->getCategorySearcher($this->_getField());
         $items = $categorySearcher->decorateItems($this->requestdata, $items);
     }
     return $items;
 }
예제 #8
0
 public static function moveDownABdBySID($ABSsid)
 {
     $ABInfo = SJB_DB::query("SELECT * FROM alphabet WHERE  sid = ?n", $ABSsid);
     if (empty($ABInfo)) {
         return false;
     }
     $ABInfo = array_pop($ABInfo);
     $current_order = $ABInfo['order'];
     $less_order = SJB_DB::queryValue("SELECT MIN(`order`) FROM alphabet WHERE  `order` > ?n", $current_order);
     if ($less_order == 0) {
         return false;
     }
     SJB_DB::query("UPDATE alphabet SET `order` = ?n WHERE `order` = ?n", $current_order, $less_order);
     SJB_DB::query("UPDATE alphabet SET `order` = ?n WHERE sid = ?n", $less_order, $ABSsid);
     return true;
 }
예제 #9
0
 public function moveDownItem($item_sid)
 {
     $item_info = SJB_DB::query("SELECT * FROM {$this->table_prefix}_field_list WHERE sid = ?n", $item_sid);
     if (empty($item_info)) {
         return false;
     }
     $item_info = array_pop($item_info);
     $current_order = $item_info['order'];
     $field_sid = $item_info['field_sid'];
     $less_order = SJB_DB::queryValue("SELECT MIN(`order`) FROM {$this->table_prefix}_field_list WHERE field_sid = ?n AND `order` > ?n", $field_sid, $current_order);
     if (empty($less_order)) {
         return false;
     }
     SJB_DB::query("UPDATE {$this->table_prefix}_field_list SET `order` = ?n WHERE field_sid = ?n AND `order` = ?n", $current_order, $field_sid, $less_order);
     SJB_DB::query("UPDATE {$this->table_prefix}_field_list SET `order` = ?n WHERE sid = ?n", $less_order, $item_sid);
     return true;
 }
예제 #10
0
 function isValid()
 {
     if (!preg_match("/^[a-zA-Z0-9\\._-]+@[a-zA-Z0-9\\._-]+\\.[a-zA-Z]{2,}\$/", $this->property_info['value']['original'])) {
         return 'NOT_VALID_EMAIL_FORMAT';
     }
     if ($this->email_confirmation == 1 && $this->property_info['value']['original'] != $this->property_info['value']['confirmed']) {
         return 'NOT_CONFIRMED';
     }
     if ($this->property_info['is_system']) {
         $count = SJB_DB::queryValue("SELECT count(*) FROM ?w WHERE ?w = ?s AND sid <> ?n", $this->property_info['table_name'], $this->property_info['id'], $this->property_info['value']['original'], $this->object_sid);
     } else {
         $count = SJB_DB::queryValue("SELECT COUNT(*) FROM ?w WHERE id = ?s AND value = ?s AND object_sid <> ?n", $this->property_info['table_name'] . "_properties", $this->property_info['id'], $this->property_info['value']['original'], $this->object_sid);
     }
     if ($count) {
         return 'NOT_UNIQUE_VALUE';
     }
     return true;
 }
예제 #11
0
 public function execute()
 {
     $username = SJB_Request::getVar('username', '');
     $password = SJB_Request::getVar('password', '');
     $user_exists_by_username = SJB_DB::queryValue('SELECT count(*) FROM `users` WHERE `username` = ?s', $username);
     if ($user_exists_by_username) {
         $user_exists_by_password = SJB_DB::queryValue('SELECT count(*) FROM `users` WHERE `username` = ?s AND `password` = ?s', $username, $password);
         if ($user_exists_by_password) {
             $user_info = SJB_UserManager::getUserInfoByUserName($username);
             if (!$user_info['active']) {
                 echo '<br>' . $username . '<br><br><font color="red">Your account is not active</font>';
             }
         } else {
             echo '<br><font color="red">Incorrect username or/and password</font>';
         }
     } else {
         echo '<br><font color="red">Incorrect username or/and password</font>';
     }
     exit;
 }
예제 #12
0
 public static function getDefaultCountryByParentSID($parentSID)
 {
     $result = SJB_DB::queryValue("SELECT `default_value` FROM `user_profile_fields` WHERE `id` = 'Country' AND `parent_sid` = ?n", $parentSID);
     if ($result == 'default_country') {
         return SJB_Settings::getSettingByName('default_country');
     }
     return $result;
 }
예제 #13
0
 /**
  * Get count of contacts by user id
  *
  * @param integer $userID
  * @return integer
  */
 public static function getTotalContacts($userID)
 {
     return SJB_DB::queryValue('SELECT COUNT(*) FROM `private_message_contacts` WHERE `user_sid` = ?n', $userID);
 }
예제 #14
0
 public static function isUserExistsByUserSid($userSid)
 {
     return SJB_DB::queryValue("SELECT count(*) FROM `users` WHERE `sid` = ?n LIMIT 1", $userSid);
 }
예제 #15
0
파일: mailing.php 프로젝트: Maxlander/shixi
 /**
  * send mailings
  * @return boolean
  */
 public function send()
 {
     $mailIndex = $this->checkIfMailingExists();
     if ($mailIndex !== false) {
         SJB_DB::query("DELETE FROM `mailing_info` WHERE `mailing_id` = ?n", $this->_mailingID);
         foreach ($this->_aMailings[$mailIndex]['mail_arr'] as $val) {
             $email = SJB_DB::queryValue('SELECT `email` FROM `users` WHERE `sid`=?n', $val['sid']);
             if (!empty($email)) {
                 $query = 'INSERT INTO `mailing_info` (`mailing_id`, `email`, `username`, `status`) VALUES (?n, ?s, ?s, 0)';
                 SJB_DB::query($query, $this->_mailingID, $email, $val['username']);
             }
         }
         return $this->sendToUndelivered();
     }
     return false;
 }
예제 #16
0
 /**
  * @param $db_table_name
  * @param SJB_Object $object
  * @param bool $sid
  * @param array $listingSidsForCopy
  * @return bool
  */
 public static function saveObject($db_table_name, SJB_Object $object, $sid = false, $listingSidsForCopy = array())
 {
     $object_sid = $object->getSID();
     if (is_null($object_sid)) {
         if ($sid) {
             if (!SJB_DB::query("INSERT INTO ?w (sid) VALUES({$sid})", $db_table_name)) {
                 return false;
             } else {
                 $object_sid = $sid;
             }
         } elseif (!$sid && !($object_sid = SJB_DB::query("INSERT INTO ?w() VALUES()", $db_table_name))) {
             return false;
         }
         $object->setSID($object_sid);
     }
     if (!empty($listingSidsForCopy)) {
         SJB_ListingManager::copyFilesAndPicturesFromListing($listingSidsForCopy['filesFrom'], $object_sid, $listingSidsForCopy['picturesFrom']);
     }
     $object_details = $object->getDetails();
     $object_properties = $object_details->getProperties();
     $complexFields = array();
     foreach ($object_properties as $object_property) {
         if (!$object_property->saveIntoBD()) {
             continue;
         }
         if ($object_property->isComplex()) {
             $complexProperties = $object_property->type->complex->getProperties();
             $propertyId = $object_property->getID();
             $complexFields[$propertyId] = array();
             if ($complexProperties) {
                 foreach ($complexProperties as $complexProperty) {
                     $complexProperty->setObjectSID($object_property->object_sid);
                     $fieldValues = $complexProperty->getValue();
                     if (!empty($fieldValues) && is_array($fieldValues)) {
                         foreach ($fieldValues as $complexEnum => $value) {
                             $complexProperty->setValue($value);
                             $complexProperty->setComplexEnum($complexEnum);
                             $complexProperty->setComplexParent($propertyId);
                             $propertySqlValue = $complexProperty->getSQLValue();
                             $complexPropertyID = $complexProperty->getID();
                             $complexParameter = $complexProperty->getAddParameter();
                             if ($complexParameter == '') {
                                 $complexFields[$propertyId][$complexPropertyID][$complexEnum] = $propertySqlValue == 'NULL' ? NULL : $propertySqlValue;
                             } else {
                                 $complexFields[$propertyId][$complexPropertyID][$complexEnum] = array('add_parameter' => $complexParameter, 'value' => $propertySqlValue == 'NULL' ? NULL : $propertySqlValue);
                             }
                         }
                         $complexProperty->setValue($fieldValues);
                     }
                 }
             }
         } elseif ($object_property->isParent()) {
             $childProperties = $object_property->type->child->getProperties();
             $parentID = $object_property->getID();
             $keywords = '';
             if ($childProperties) {
                 foreach ($childProperties as $childProperty) {
                     $childProperty->setObjectSID($object_property->object_sid);
                     $property_id = $parentID . "_" . $childProperty->getID();
                     $property_sql_value = $childProperty->getSQLValue();
                     if ($childProperty->getID() == 'State') {
                         $displayAS = $childProperty->display_as;
                         $displayAS = $displayAS ? $displayAS : 'state_name';
                         $childProperty->type->list_values = SJB_StatesManager::getStatesNamesByCountry(false, true, $displayAS);
                     }
                     $keywords .= $childProperty->getKeywordValue() . ' ';
                     if (empty($property_sql_value) && in_array($childProperty->getType(), array('boolean', 'integer', 'float'))) {
                         $property_sql_value = 0;
                     }
                     SJB_DB::query("UPDATE `?w` SET `?w` = ?s WHERE sid = ?n", $db_table_name, $property_id, $property_sql_value, $object_sid);
                 }
             }
             $origValue = $object_property->getValue();
             $object_property->setValue($keywords);
             $property_id = $object_property->getID();
             $property_sql_value = $object_property->getSQLValue();
             $object_property->setValue($origValue);
             SJB_DB::query("UPDATE `?w` SET `?w` = ?s WHERE sid = ?n", $db_table_name, $property_id, $property_sql_value, $object_sid);
         } else {
             $property_id = $object_property->getID();
             $property_sql_value = $object_property->getSQLValue();
             $property_sql_add_parameter = $object_property->getAddParameter();
             if ($object_property->isSystem()) {
                 if (empty($property_sql_value) && in_array($object_property->getType(), array('boolean', 'integer', 'float'))) {
                     $property_sql_value = 0;
                 }
                 SJB_DB::query("UPDATE `?w` SET `?w` = ?s WHERE sid = ?n", $db_table_name, $property_id, $property_sql_value, $object_sid);
                 if (!empty($property_sql_add_parameter)) {
                     if ($object_property->getType() == 'monetary' && $object->getObjectType() != 'field') {
                         SJB_DB::query("UPDATE `?w` SET `?w` = ?w WHERE sid = ?n", $db_table_name, $property_id . '_parameter', $property_sql_add_parameter, $object_sid);
                     } else {
                         SJB_DB::query("UPDATE `?w` SET `add_parameter` = ?w WHERE sid = ?n", $db_table_name, $property_sql_add_parameter, $object_sid);
                     }
                 }
             } else {
                 if (SJB_DB::table_exists($db_table_name . "_properties")) {
                     $property_exists = SJB_DB::queryValue("SELECT COUNT(*) FROM ?w WHERE object_sid = ?n AND id = ?s", $db_table_name . "_properties", $object_sid, $property_id);
                     if ($property_exists) {
                         SJB_DB::query("UPDATE ?w SET value = ?s, add_parameter = ?s WHERE object_sid = ?n AND id = ?s", $db_table_name . "_properties", $property_sql_value, $property_sql_add_parameter, $object_sid, $property_id);
                     } else {
                         SJB_DB::query("INSERT INTO ?w(object_sid, id , value, add_parameter) VALUES(?n, ?s, ?s, ?s)", $db_table_name . "_properties", $object_sid, $property_id, $property_sql_value, $property_sql_add_parameter);
                     }
                 }
             }
         }
     }
     if (!empty($complexFields)) {
         SJB_DB::query("UPDATE `?w` SET `?w` = ?s WHERE sid = ?n", $db_table_name, 'complex', serialize($complexFields), $object_sid);
     }
 }
예제 #17
0
 /**
  * Gets an Application Email from Application Settings
  *
  * @param int $listing_id
  * @return string
  */
 public static function getApplicationEmailbyListingId($listing_id)
 {
     $application_email = SJB_DB::queryValue("SELECT `value` FROM `listings_properties` WHERE `object_sid` = ?n AND `id` = ?s AND `add_parameter` = ?n AND `value` <> ''", $listing_id, 'ApplicationSettings', 1);
     if ($application_email) {
         return $application_email;
     }
     return '';
 }
예제 #18
0
 public static function isUserActiveBySID($user_sid)
 {
     return SJB_DB::queryValue("SELECT active FROM users WHERE sid = ?n", $user_sid);
 }
예제 #19
0
 public static function moveItemAfterBySID($item_sid, $after_tree_item_sid)
 {
     if ($item_sid == $after_tree_item_sid) {
         return false;
     }
     $item_info = SJB_DB::query("SELECT * FROM listing_field_tree WHERE sid = ?n", $item_sid);
     if (empty($item_info)) {
         return false;
     } else {
         $item_info = array_pop($item_info);
         $current_order = $item_info['order'];
         SJB_DB::query("UPDATE listing_field_tree SET `order` = `order` - 1 WHERE `order` > ?n AND parent_sid = ?n", $current_order, $item_info['parent_sid']);
         $after_order = SJB_DB::queryValue("SELECT `order` FROM listing_field_tree WHERE sid = ?n", $after_tree_item_sid);
         $new_order = $after_order + 1;
         SJB_DB::query("UPDATE listing_field_tree SET `order` = `order` + 1 WHERE `order` > ?n AND parent_sid = ?n", $after_order, $item_info['parent_sid']);
         SJB_DB::query("UPDATE listing_field_tree SET `order` = ?n WHERE sid = ?n", $new_order, $item_sid);
         return true;
     }
 }
예제 #20
0
 public static function getSIDByID($gateway_id)
 {
     return SJB_DB::queryValue('SELECT `sid` FROM `payment_gateways` WHERE `id`=?s', $gateway_id);
 }
예제 #21
0
 function uploadImage($image_file_name, $image_caption)
 {
     $image_info = getimagesize($image_file_name);
     // $image_info['2'] = 1 {GIF}, 2 {JPG}, 3 {PNG}, 4 {SWF}, 5 {PSD}, 6 {BMP}, 7 {TIFF}, 8 {TIFF}, 9 {JPC}, 10 {JP2}, 11 {JPX}
     if ($image_info['2'] >= 1 && $image_info['2'] <= 3) {
         if ($image_info['2'] == 1) {
             $image_resource = imagecreatefromgif($image_file_name);
         } elseif ($image_info['2'] == 2) {
             $image_resource = imagecreatefromjpeg($image_file_name);
         } else {
             $image_resource = imagecreatefrompng($image_file_name);
         }
         $picture_max_size['width'] = SJB_System::getSettingByName('listing_picture_width');
         $picture_max_size['height'] = SJB_System::getSettingByName('listing_picture_height');
         $picture_resource = $this->getResizedImageResource($image_resource, $picture_max_size);
         $thumb_max_size['width'] = SJB_System::getSettingByName('listing_thumbnail_width');
         $thumb_max_size['height'] = SJB_System::getSettingByName('listing_thumbnail_height');
         $thumb_resource = $this->getResizedImageResource($image_resource, $thumb_max_size);
         $max_order = SJB_DB::queryValue("SELECT MAX(`order`) FROM listings_pictures WHERE `listing_sid` = ?n", $this->listing_sid);
         $max_order = empty($max_order) ? 0 : $max_order;
         $order = $max_order + 1;
         $upload_file_directory = SJB_System::getSystemSettings('UPLOAD_FILES_DIRECTORY');
         $picture_sid = SJB_DB::query("INSERT INTO listings_pictures" . " SET `listing_sid` = ?n, `caption` = ?s, `order` = ?n", $this->listing_sid, mb_substr($image_caption, 0, 255), $order);
         $picture_file_basename = 'picture_' . $picture_sid . '.jpg';
         $thumb_file_basename = 'thumb_' . $picture_sid . '.jpg';
         $picture_name = $upload_file_directory . "/pictures/" . $picture_file_basename;
         $thumb_name = $upload_file_directory . "/pictures/" . $thumb_file_basename;
         imagejpeg($picture_resource, $picture_name);
         imagejpeg($thumb_resource, $thumb_name);
         SJB_DB::query("UPDATE listings_pictures SET `picture_saved_name` = ?s, `thumb_saved_name` = ?s WHERE sid = ?n", $picture_file_basename, $thumb_file_basename, $picture_sid);
         $this->setListingPictureAmount($this->getPicturesAmount());
     } else {
         $this->error = 'NOT_SUPPORTED_IMAGE_FORMAT';
         return false;
     }
 }
 /**
  * @return int
  */
 public function getPostedTodayByFeed()
 {
     $query = "SELECT count(`listing_sid`) as `posted` FROM `social_network_postings`\n\t\t\t\t\tWHERE `feed_sid` = ?n AND (INTERVAL 1 DAY + `date`) > NOW() AND `network_id` = ?s";
     $result = SJB_DB::queryValue($query, $this->feedInfo["sid"], $this->networkID);
     return (int) $result;
 }
예제 #23
0
 /**
  * @param $listingSID
  * @return int
  */
 public static function isListingCheckOuted($listingSID)
 {
     return SJB_DB::queryValue("SELECT `checkouted` FROM `listings` WHERE `sid` = ?n", $listingSID);
 }
예제 #24
0
 public static function getTemplateBySID($sid)
 {
     $emailTemplate = SJB_DB::queryValue("SELECT `name` FROM `email_templates` WHERE `sid` = ?s", $sid);
     return $emailTemplate ? $emailTemplate : false;
 }
 public static function moveDownFieldBySID($field_sid)
 {
     $field_info = SJB_DB::query("SELECT * FROM questions WHERE sid = ?n", $field_sid);
     if (empty($field_info)) {
         return false;
     }
     $field_info = array_pop($field_info);
     $current_order = $field_info['order'];
     $less_order = SJB_DB::queryValue("SELECT MIN(`order`) FROM questions WHERE questionnaire_sid = ?n AND `order` > ?n", $field_info['questionnaire_sid'], $current_order);
     if ($less_order == 0) {
         return false;
     }
     SJB_DB::query("UPDATE questions SET `order` = ?n WHERE `order` = ?n AND questionnaire_sid = ?n", $current_order, $less_order, $field_info['questionnaire_sid']);
     SJB_DB::query("UPDATE questions SET `order` = ?n WHERE sid = ?n", $less_order, $field_sid);
     return true;
 }
예제 #26
0
 public static function moveDownFieldBySID($field_sid)
 {
     $field_info = SJB_UserProfileFieldDBManager::getUserProfileFieldInfoBySID($field_sid);
     if (empty($field_info)) {
         return false;
     }
     $user_group_sid = $field_info['user_group_sid'];
     $current_order = $field_info['order'];
     $less_order = SJB_DB::queryValue("SELECT MIN(`order`) FROM user_profile_fields WHERE user_group_sid = ?n AND `order` > ?n", $user_group_sid, $current_order);
     if ($less_order == 0) {
         return false;
     }
     SJB_DB::query("UPDATE user_profile_fields SET `order` = ?n WHERE `order` = ?n AND `user_group_sid` = ?n", $current_order, $less_order, $user_group_sid);
     SJB_DB::query("UPDATE user_profile_fields SET `order` = ?n WHERE `sid` = ?n", $less_order, $field_sid);
     return true;
 }
예제 #27
0
 public static function moveDownCategoryBySID($sid)
 {
     $category_info = SJB_DB::query("SELECT * FROM `news_categories` WHERE id = ?n", $sid);
     if (empty($category_info)) {
         return false;
     }
     $category_info = array_pop($category_info);
     $current_order = $category_info['order'];
     $less_order = SJB_DB::queryValue("SELECT MIN(`order`) FROM `news_categories` WHERE `order` > ?n", $current_order);
     if ($less_order == 0) {
         return false;
     }
     SJB_DB::query("UPDATE `news_categories` SET `order` = ?n WHERE `order` = ?n", $current_order, $less_order);
     SJB_DB::query("UPDATE `news_categories` SET `order` = ?n WHERE id = ?n", $less_order, $sid);
     return true;
 }
예제 #28
0
 public static function getBannedIPByID($id)
 {
     $sql = SJB_DB::queryValue("SELECT `value` FROM `banned_ips` WHERE `id`=?s", $id);
     return $sql ? $sql : false;
 }
예제 #29
0
 /**
  * @param $itemSID
  * @param $userSID
  */
 public function findCheckoutedListingsByProduct($itemSID, $userSID)
 {
     $shopCartProduct = SJB_DB::query("SELECT `product_info` FROM `shopping_cart` WHERE `sid` = ?n", $itemSID);
     if (!empty($shopCartProduct)) {
         $productInfo = unserialize($shopCartProduct[0]['product_info']);
         $countCheckoutedListings = SJB_ListingDBManager::getNumberOfCheckoutedListingsByProductSID($productInfo['sid'], $userSID);
         if ($countCheckoutedListings != 0) {
             $serializedProductSIDForShopCart = '"sid";s:' . strlen($productInfo['sid']) . ':"' . $productInfo['sid'] . '";';
             $countOfOtherShopCartProducts = SJB_DB::queryValue("SELECT COUNT(`sid`) FROM `shopping_cart` WHERE `sid` != ?n AND `user_sid` = ?n AND `product_info` REGEXP '({$serializedProductSIDForShopCart})' ORDER BY `sid` ASC", $itemSID, $userSID);
             if ($productInfo['product_type'] == 'mixed_product' || isset($productInfo['pricing_type']) && $productInfo['pricing_type'] == 'fixed') {
                 $limitCheckoutedListingsToDelete = $countCheckoutedListings - $countOfOtherShopCartProducts * $productInfo['number_of_listings'];
                 if ($limitCheckoutedListingsToDelete > 0) {
                     $this->deleteCheckoutedListingsByProduct($userSID, $productInfo['sid'], $limitCheckoutedListingsToDelete);
                 }
             }
             if (isset($productInfo['pricing_type']) && $productInfo['pricing_type'] == 'volume_based') {
                 $maxAvailableListings = end($productInfo['volume_based_pricing']['listings_range_to']);
                 $shopCartProductsToUpdate = SJB_DB::query("SELECT `sid`,`product_info` FROM `shopping_cart` WHERE `sid` != ?n AND `user_sid` = ?n AND `product_info` REGEXP '({$serializedProductSIDForShopCart})' ORDER BY `sid` ASC", $itemSID, $userSID);
                 $limitCheckoutedListingsToDelete = $countCheckoutedListings - $countOfOtherShopCartProducts * $maxAvailableListings;
                 if ($limitCheckoutedListingsToDelete >= 0) {
                     foreach ($shopCartProductsToUpdate as $shopCartProductToUpdate) {
                         $shopCartProductInfo = unserialize($shopCartProductToUpdate['product_info']);
                         $shopCartProductInfo['number_of_listings'] = $maxAvailableListings;
                         SJB_ShoppingCart::updateItemBySID($shopCartProductToUpdate['sid'], $shopCartProductInfo);
                     }
                     if ($limitCheckoutedListingsToDelete > 0) {
                         $this->deleteCheckoutedListingsByProduct($userSID, $productInfo['sid'], $limitCheckoutedListingsToDelete);
                     }
                 } else {
                     foreach ($shopCartProductsToUpdate as $shopCartProductToUpdate) {
                         $shopCartProductInfo = unserialize($shopCartProductToUpdate['product_info']);
                         if ($limitCheckoutedListingsToDelete > end($shopCartProductInfo['volume_based_pricing']['listings_range_to'])) {
                             $limitCheckoutedListingsToDelete -= end($shopCartProductInfo['volume_based_pricing']['listings_range_to']);
                             $shopCartProductInfo['number_of_listings'] = $maxAvailableListings;
                         } else {
                             $shopCartProductInfo['number_of_listings'] = $limitCheckoutedListingsToDelete;
                         }
                         SJB_ShoppingCart::updateItemBySID($shopCartProductToUpdate['sid'], $shopCartProductInfo);
                     }
                 }
             }
         }
     }
 }
예제 #30
0
 public static function getSystemPropertyValueByObjectSID($db_table_name, $sid, $property_name)
 {
     return SJB_DB::queryValue("SELECT `?w` FROM `?w`\n\t\t\t\t\t\t\tWHERE `sid`=?s", $property_name, $db_table_name, $sid);
 }