IT's FINALLY HAPPENING. Fred and Daphne are getting married and in less than a month, the wedding will happen. Of course Velma will be Daphne's Maid of Honor and Shaggy being Fred's Best Man. As for Scooby-Doo, he is the Best Dog. Old friends will reunite for this special occasion. However, just as this will be a event of a lifetime...there is always a monster waiting. When Daphne receives a rare blue amulet, she and the Mystrey Inc. gang has no idea the amulet will awaken the vile Shadow Creature. And if that's not bad enough, the couple are getting cold feet before the day. With a creature on the loose, family and friends unaware they are in danger, and the couple nervous, Shaggy and Scooby will try their best to make things calm, yet can't wait to get to the buffet at the reception--if only they can make it there.
if use_new_lookup_system == false
sites = Array.new
if controller.controller_name == "site"
#sites = Site_slave.find_by_sql(["SELECT * FROM sites, (SELECT id FROM sites WHERE (category_id = ? AND ext_type IN (5,6,7) AND id <= ?) ORDER BY id DESC LIMIT #{mobile_page_size}) as x WHERE sites.id = x.id", @site.category_id, @site.id])
if @permalink_site.ext_type == 4
if false # this loads same type of content after the permalink
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type = 4 AND id <= ?", @permalink_site.category_id, @permalink_site.id], :order=>"datecreated DESC, id DESC", :limit=>numshowing, :offset=>array_start)
if sites.length == 0
offset_count = Site_slave.count(:all, :conditions=>["category_id = ? AND ext_type = 4 AND id <= ?", @permalink_site.category_id, @permalink_site.id])
new_current_page = current_page - ((offset_count+numshowing-1) / numshowing) # page number starting from 0 is going to be the current page minus the number of pages it took to show from permalink to end
array_start = numshowing * (new_current_page - 1)
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type = 4 AND id > ?", @permalink_site.category_id, @permalink_site.id], :order=>"datecreated DESC, id DESC", :limit=>numshowing, :offset=>array_start)
end
else
# sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (1,5,6,7,9,10) and id <= ?", @category.id, @permalink_site.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
sites = Site_slave.find_by_sql(["SELECT sites.* FROM sites, (SELECT id FROM sites WHERE category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id <= ? ORDER BY datecreated DESC LIMIT ?, ?) AS x WHERE x.id = sites.id", @permalink_site.category_id, @permalink_site.id, array_start, numshowing])
if sites.length == 0
offset_count = Site_slave.count(:all, :conditions=>["category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id <= ?", @permalink_site.category_id, @permalink_site.id])
new_current_page = current_page - ((offset_count+numshowing-1) / numshowing) # page number starting from 0 is going to be the current page minus the number of pages it took to show from permalink to end
array_start = numshowing * (new_current_page - 1)
# sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id > ?", @permalink_site.category_id, @permalink_site.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
sites = Site_slave.find_by_sql(["SELECT sites.* FROM sites, (SELECT id FROM sites WHERE category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id > ? ORDER BY datecreated DESC LIMIT ?, ?) AS x WHERE x.id = sites.id", @permalink_site.category_id, @permalink_site.id, array_start, numshowing])
end
end
elsif @permalink_site.is_image?
if false # this loads same type of content after the permalink
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (5,6,7) AND id <= ?", @permalink_site.category_id, @permalink_site.id], :order=>"datecreated DESC, id DESC", :limit=>numshowing, :offset=>array_start)
if sites.length == 0 # wrap to newest if no results were found going back in time
offset_count = Site_slave.count(:all, :conditions=>["category_id = ? AND ext_type IN (5,6,7) AND id <= ?", @permalink_site.category_id, @permalink_site.id])
new_current_page = current_page - ((offset_count+numshowing-1) / numshowing) # page number starting from 0 is going to be the current page minus the number of pages it took to show from permalink to end
array_start = numshowing * (new_current_page - 1)
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (5,6,7) AND id > ?", @permalink_site.category_id, @permalink_site.id], :order=>"datecreated DESC, id DESC", :limit=>numshowing, :offset=>array_start)
end
else # this loads any type of content after the permalink
# sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (1,5,6,7,9,10) and id <= ?", @category.id, @permalink_site.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
sites = Site_slave.find_by_sql(["SELECT sites.* FROM sites, (SELECT id FROM sites WHERE category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id <= ? ORDER BY datecreated DESC LIMIT ?, ?) AS x WHERE x.id = sites.id", @permalink_site.category_id, @permalink_site.id, array_start, numshowing])
if sites.length == 0
offset_count = Site_slave.count(:all, :conditions=>["category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id <= ?", @permalink_site.category_id, @permalink_site.id])
new_current_page = current_page - ((offset_count+numshowing-1) / numshowing) # page number starting from 0 is going to be the current page minus the number of pages it took to show from permalink to end
array_start = numshowing * (new_current_page - 1)
# sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id > ?", @permalink_site.category_id, @permalink_site.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
sites = Site_slave.find_by_sql(["SELECT sites.* FROM sites, (SELECT id FROM sites WHERE category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id > ? ORDER BY datecreated DESC LIMIT ?, ?) AS x WHERE x.id = sites.id", @permalink_site.category_id, @permalink_site.id, array_start, numshowing])
end
end
elsif @permalink_site.is_video?
if false # this loads same type of content after the permalink
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (9,10) AND id <= ?", @permalink_site.category_id, @permalink_site.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
if sites.length == 0
offset_count = Site_slave.count(:all, :conditions=>["category_id = ? AND ext_type IN (9,10) AND id <= ?", @permalink_site.category_id, @permalink_site.id])
new_current_page = current_page - ((offset_count+numshowing-1) / numshowing) # page number starting from 0 is going to be the current page minus the number of pages it took to show from permalink to end
array_start = numshowing * (new_current_page - 1)
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (9,10) AND id > ?", @permalink_site.category_id, @permalink_site.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
end
else # this loads any type of content after the permalink
# sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (1,5,6,7,9,10) and id <= ?", @category.id, @permalink_site.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
sites = Site_slave.find_by_sql(["SELECT sites.* FROM sites, (SELECT id FROM sites WHERE category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id <= ? ORDER BY datecreated DESC LIMIT ?, ?) AS x WHERE x.id = sites.id", @permalink_site.category_id, @permalink_site.id, array_start, numshowing])
if sites.length == 0
offset_count = Site_slave.count(:all, :conditions=>["category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id <= ?", @permalink_site.category_id, @permalink_site.id])
new_current_page = current_page - ((offset_count+numshowing-1) / numshowing) # page number starting from 0 is going to be the current page minus the number of pages it took to show from permalink to end
array_start = numshowing * (new_current_page - 1)
# sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id > ?", @permalink_site.category_id, @permalink_site.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
sites = Site_slave.find_by_sql(["SELECT sites.* FROM sites, (SELECT id FROM sites WHERE category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id > ? ORDER BY datecreated DESC LIMIT ?, ?) AS x WHERE x.id = sites.id", @permalink_site.category_id, @permalink_site.id, array_start, numshowing])
end
end
end
elsif controller.controller_name == "search"
sites = @site_results #@site_results is the array of site objects returned by sphinx
elsif controller.controller_name == "collection"
sites = @sites_collections2D##.collect {|site| site[0]} Special case below to bundle site and collection_site together for display later
elsif controller.controller_name == "welcome"
sites = Popculture_slave.find(:all, :order=>"publish_date desc", :limit=>numshowing, :offset=>array_start)
elsif controller.controller_name == "soapbox" && controller.action_name == "show"
if false # this loads same type of content after the permalink
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type = 1 AND id <= ?", @permalink_site.category_id, @permalink_site.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
if sites.length == 0
offset_count = Site_slave.count(:all, :conditions=>["category_id = ? AND ext_type = 1 AND id <= ?", @permalink_site.category_id, @permalink_site.id])
new_current_page = current_page - ((offset_count+numshowing-1) / numshowing) # page number starting from 0 is going to be the current page minus the number of pages it took to show from permalink to end
array_start = numshowing * (new_current_page - 1)
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type = 1 AND id > ?", @permalink_site.category_id, @permalink_site.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
end
else # this loads any type of content after the permalink
# sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (1,5,6,7,9,10) and id <= ?", @category.id, @permalink_site.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
sites = Site_slave.find_by_sql(["SELECT sites.* FROM sites, (SELECT id FROM sites WHERE category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id <= ? ORDER BY datecreated DESC LIMIT ?, ?) AS x WHERE x.id = sites.id", @permalink_site.category_id, @permalink_site.id, array_start, numshowing])
if sites.length == 0
offset_count = Site_slave.count(:all, :conditions=>["category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id <= ?", @permalink_site.category_id, @permalink_site.id])
new_current_page = current_page - ((offset_count+numshowing-1) / numshowing) # page number starting from 0 is going to be the current page minus the number of pages it took to show from permalink to end
array_start = numshowing * (new_current_page - 1)
# sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id > ?", @permalink_site.category_id, @permalink_site.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
sites = Site_slave.find_by_sql(["SELECT sites.* FROM sites, (SELECT id FROM sites WHERE category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id > ? ORDER BY datecreated DESC LIMIT ?, ?) AS x WHERE x.id = sites.id", @permalink_site.category_id, @permalink_site.id, array_start, numshowing])
end
end
elsif controller.controller_name == "soapbox" && controller.action_name == "list"
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type = 1", @category.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
elsif controller.controller_name == "category" && controller.action_name == "home"
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (1,5,6,7,9,10)", @category.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
if false && @luser && @luser.id < 10
if sites.length > 0
if current_page.to_i == 1
wall_entries = Wall_entry_slave.find(:all, :conditions=>["category_id = ? AND timestamp > ? AND deleted_by = 0", @category.id, sites[sites.length - 1].datecreated], :order=>"timestamp DESC")
else
wall_entries = Wall_entry_slave.find(:all, :conditions=>["category_id = ? AND timestamp < ? and timestamp > ? AND deleted_by = 0", @category.id, sites[0].datecreated, sites[sites.length - 1].datecreated], :order=>"timestamp DESC")
end
begin
wall_entries.each do |wall_entry|
wall_site_hash = {:card_type=>"chatter", :datecreated=>wall_entry.timestamp, :chatter_data=>wall_entry}
site_counter = 0
sites.each do |site_object|
if site_object.is_a? Site_slave
if site_counter == 0 && wall_site_hash[:datecreated] > site_object.datecreated #wall post is newer than the newest site in the array
sites.insert(0, wall_site_hash)
break
end
if site_counter > 0 && site_object.datecreated < wall_site_hash[:datecreated]
sites.insert(site_counter, wall_site_hash)
break
end
end
site_counter = site_counter + 1
end
end
rescue StandardError => kaboom
Notifier::deliver_email_alert_request("Cliff Szu", "theclifbar@gmail.com", "Error: chatter card error", "#{kaboom.inspect}")
puts "################################### _viewer_main_viewer_body_cardcontainer Error: #{__LINE__} #{kaboom.inspect} :::: #{session.inspect.to_s}, #{params.to_s}, #{request.env.to_s}"
end
end
end
site = sites[0]
# commented following line out - there should not be a @permalink_site on club home; the first card should not be treated differently on club home
# @permalink_site = sites[0]
else
#I also need to change pagination to pull from a different set... maybe we should just pass in a parameter or object like @site or site_id, and if that is not nil, then use similar queries to pull the subsequent pages for sites
if params[:show_only].to_s != ""
show_only = params[:show_only].to_s
case show_only
when "images"
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (5,6,7)", @category.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
when "videos"
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (9,10)", @category.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
when "trivia"
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type = 3", @category.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
when "polls"
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type = 2", @category.id], :order=>"datecreated DESC", :limit=>numshowing, :off