]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/amf_controller.rb
Various updates to the user management, including the creation of a
[rails.git] / app / controllers / amf_controller.rb
index 3bcab182b7d976d22f7c51019f85819094fdc588..8db813b38602e1c5348de7a20017f7851909c902 100644 (file)
@@ -1,6 +1,9 @@
 class AmfController < ApplicationController
   require 'stringio'
 
+  session :off
+  before_filter :check_availability
+
   # to log:
   # RAILS_DEFAULT_LOGGER.error("Args: #{args[0]}, #{args[1]}, #{args[2]}, #{args[3]}")
 
@@ -120,6 +123,15 @@ preserved railway: railway=preserved
 disused railway tracks: railway=disused
 course of old railway: railway=abandoned
 
+way/natural
+forest: natural=wood,landuse=forest
+woodland: natural=wood,landuse=
+reservoir: natural=water,landuse=reservoir
+lake: natural=water,landuse=
+marsh: natural=marsh
+beach: natural=beach
+coastline: natural=coastline
+
 point/road
 mini roundabout: highway=mini_roundabout
 traffic lights: highway=traffic_signals
@@ -144,6 +156,9 @@ point/railway
 station: railway=station
 viaduct: railway=viaduct
 level crossing: railway=crossing
+
+point/natural
+peak: natural=peak
 EOF
 
     StringIO.open(txt) do |file|
@@ -295,10 +310,14 @@ EOF
       # compare node
       if node<0
         # new node - create
-        newnode=ActiveRecord::Base.connection.insert("INSERT INTO current_nodes (   latitude,longitude,timestamp,user_id,visible,tags) VALUES (           #{ys},#{xs},#{db_now},#{uid},1,#{tagsql})")
-                       ActiveRecord::Base.connection.insert("INSERT INTO nodes         (id,latitude,longitude,timestamp,user_id,visible,tags) VALUES (#{newnode},#{ys},#{xs},#{db_now},#{uid},1,#{tagsql})")
-        points[i][2]=newnode
-        renumberednodes[node.to_s]=newnode.to_s
+               if renumberednodes[node.to_s].nil?
+                       newnode=ActiveRecord::Base.connection.insert("INSERT INTO current_nodes (   latitude,longitude,timestamp,user_id,visible,tags) VALUES (           #{ys},#{xs},#{db_now},#{uid},1,#{tagsql})")
+                                       ActiveRecord::Base.connection.insert("INSERT INTO nodes         (id,latitude,longitude,timestamp,user_id,visible,tags) VALUES (#{newnode},#{ys},#{xs},#{db_now},#{uid},1,#{tagsql})")
+                       points[i][2]=newnode
+                       renumberednodes[node.to_s]=newnode.to_s
+               else
+                       points[i][2]=renumberednodes[node.to_s].to_i
+               end
 
       elsif xc.has_key?(node)
         # old node from original way - update
@@ -717,12 +736,13 @@ def array2tag(a)
 end
 
 def getuserid(token)
-  token=sqlescape(token)
-  if (token=~/^(.+)\+(.+)$/) then
-    return ActiveRecord::Base.connection.select_value("SELECT id FROM users WHERE active=1 AND email='#{$1}' AND pass_crypt=MD5('#{$2}')")
+  if (token =~ /^(.+)\+(.+)$/) then
+    user = User.authenticate(:username => $1, :password => $2)
   else
-    return ActiveRecord::Base.connection.select_value("SELECT id FROM users WHERE active=1 AND token='#{token}'")
+    user = User.authenticate(:token => token)
   end
+
+  return user ? user.id : nil;
 end