]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/user.rb
/diary links to users
[rails.git] / app / models / user.rb
index a8bc396153a0960f2cde1e8a4cda600777ad972d..1ecc3f7102a616dbe39010b5b6b7bd646b8f9994 100644 (file)
@@ -1,8 +1,10 @@
-require 'digest/md5'
-
 class User < ActiveRecord::Base
-  has_many :traces
+  require 'xml/libxml'
+  require 'digest/md5'
 
+  has_many :traces
+  has_many :diary_entries
   validates_confirmation_of :pass_crypt, :message => 'Password must match the confirmation password'
   validates_uniqueness_of :display_name, :allow_nil => true
   validates_uniqueness_of :email
@@ -43,4 +45,25 @@ class User < ActiveRecord::Base
     return confirmstring
   end
 
+  def to_xml
+    doc = OSM::API.new.get_xml_doc
+    doc.root << to_xml_node()
+    return doc
+  end
+
+  def to_xml_node
+    el1 = XML::Node.new 'user'
+    el1['display_name'] = self.display_name.to_s
+    el1['account_created'] = self.creation_time.xmlschema
+    return el1
+  end
+  
+  def nearby(lat_range=1, lon_range=1)
+     
+      nearby = User.find(:all,  :conditions => "#{self.home_lon} > home_lon - #{lon_range} and #{self.home_lon} < home_lon + #{lon_range} and  #{self.home_lon} > home_lon - #{lon_range} and #{self.home_lon} < home_lon + #{lon_range} and data_public = 1") 
+      return nearby
+  end
+
+
+  
 end