- if !user then return -1,"You must be logged in to search for GPX traces.",[] end
- unless user.active_blocks.empty? then return -1,t('application.setup_user_auth.blocked'),[] end
-
- gpxs = []
- if searchterm.to_i>0 then
- gpx = Trace.find(searchterm.to_i, :conditions => ["visible=? AND (public=? OR user_id=?)",true,true,user.id] )
- if gpx then
- gpxs.push([gpx.id, gpx.name, gpx.description])
- end
+ if !user then return -1,"You must be logged in to search for GPX traces." end
+ unless user.active_blocks.empty? then return -1,t('application.setup_user_auth.blocked') end
+
+ query = Trace.visible_to(user)
+ if searchterm.to_i > 0 then
+ query = query.where(:id => searchterm.to_i)