- history = Node.find(nodeid).old_nodes.reverse.collect do |old_node|
- user = old_node.user.data_public? ? old_node.user.display_name : 'anonymous'
- uid = old_node.user.data_public? ? old_node.user.id : 0
- [old_node.timestamp.to_i, old_node.timestamp.strftime("%d %b %Y, %H:%M"), old_node.visible ? 1 : 0, user, uid]
- end
+ begin
+ history = Node.find(nodeid).old_nodes.reverse.collect do |old_node|
+ user_object = old_node.changeset.user
+ user = user_object.data_public? ? user_object.display_name : 'anonymous'
+ uid = user_object.data_public? ? user_object.id : 0
+ [old_node.version, old_node.timestamp.strftime("%d %b %Y, %H:%M"), old_node.visible ? 1 : 0, user, uid]
+ end
+
+ return ['node',nodeid,history]
+ rescue ActiveRecord::RecordNotFound
+ return ['node', nodeid, []]
+ end
+ end
+
+ # Find GPS traces with specified name/id.
+ # Returns array listing GPXs, each one comprising id, name and description.
+
+ def findgpx(searchterm, usertoken)
+ uid = getuserid(usertoken)
+ if !uid then return -1,"You must be logged in to search for GPX traces." end