Esempio n. 1
0
 /**
  * @param  $listing SJB_Listing
  * @return array|bool
  */
 public static function saveListing($listing, $listingSidsForCopy = array())
 {
     $listing_type_sid = $listing->getListingTypeSID();
     if (!is_null($listing_type_sid)) {
         $keywords = SJB_ListingDBManager::getListingKeywordsArray($listing);
         // Строчку в низ не переносить, так как после сохранения объекта вытащить кейворды сложнее
         parent::saveObject('listings', $listing, false, $listingSidsForCopy);
         $user_info = SJB_UserManager::getUserInfoBySID($listing->getUserSID());
         $user_keywords = SJB_ListingDBManager::getUserKeywords($user_info);
         if ($user_keywords) {
             $keywords[] = $user_keywords;
         }
         SJB_Cache::getInstance()->clean('matchingAnyTag', array(SJB_Cache::TAG_LISTINGS));
         foreach ($keywords as $keyword) {
             SJB_ListingDBManager::saveListingKeyword($keyword, $listing->getSID(), $listing->isActive());
         }
         if (!SJB_ListingManager::hasListingProduct($listing->getSID())) {
             SJB_ListingManager::insertProduct($listing->getSID(), $listing->getProductInfo());
         }
         return SJB_DB::query('UPDATE `?w` SET `listing_type_sid` = ?n, `user_sid` = ?n, `keywords` = ?s, ' . '`activation_date` = ' . ($listing->getActivationDate() == null ? 'NOW()' : "'{$listing->getActivationDate()}'") . ' WHERE `sid` = ?n', 'listings', $listing_type_sid, $listing->getUserSID(), $listing->getKeywords(), $listing->getSID());
     }
     return false;
 }