before_filter :authorize
after_filter :compress_output
+ helper :user
+ model :user
+
+ def authorize_web
+ @current_user = User.find_by_token(session[:token])
+ end
+
# The maximum area you're allowed to request, in square degrees
MAX_REQUEST_AREA = 0.25
def diary
@this_user = User.find_by_display_name(params[:display_name])
end
-
+
+ def contact_others(user_id, message_body)
+ @to = User.find_by_id(user_id)
+ @to.messages.new = body
+ if @to.save
+ flash[:notice] = Message sent
+ end
+
+ #Send a message to other users - maybe there's a rails messaging plugin
+ end
end
return el1
end
- def get_nearby_users
+ 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
</div>
</div>
+<% if @user and params['lon'].nil? and params['lat'].nil? %>
+<% lon = @user.home_lon %>
+<% lat = @user.home_lat %>
+<% zoom = '10' %>
+<%else%>
<% lon = params['lon'] || '-0.1' %>
<% lat = params['lat'] || '51.5' %>
<% zoom = params['zoom'] || '4' %>
+<% end %>
<script type="text/javascript">
var lon = <%= lon %>;
<h2>Users in your area</h2>
-These users are mapping in your area:
+<% if @user.nearby.empty? %>
+There are no users mapping in your area. Better go out and spread the word about OSM!
+<% else %>
+
+<p>These users are mapping in your area:</p>
+<table>
+<tr>
+<th>Email</th>
+<th>Name</th>
+<th>Contact</th>
+</tr>
+<% @user.nearby(1,1).each do |nearby| %>
+<tr>
+<td><%= nearby.email %></td>
+<td><%= nearby.display_name %></td>
+<td>FIXME: send user an email</td>
+</tr>
+<%end%>
+</table>
+<%end%>
+<br />
+FIXME: OL Map showing the users on
<h2>Privacy</h2>
<% if @user.data_public? %>
alter table users add column (home_lat double default NULL);
alter table users add column (home_lon double default NULL);
+alter table users add column within_lon double default null;
+alter table users add column within_lat double default null;
+create table messages (id bigint not null auto_increment, user_id bigint(20) not null, title varchar(255), body text, sent_on datetime, message_read boolean default 0, primary key(id));