X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/f07819d81a7437e58c6e64c2e76ba7e54fad9034..2bc44dfddc214efcec9dd2e920fac14a7c2dcec0:/app/controllers/amf_controller.rb diff --git a/app/controllers/amf_controller.rb b/app/controllers/amf_controller.rb index 447ebbc5f..534e41a80 100644 --- a/app/controllers/amf_controller.rb +++ b/app/controllers/amf_controller.rb @@ -186,6 +186,12 @@ class AmfController < ApplicationController user = getuser(usertoken) if !user then return -1,"You are not logged in, so Potlatch can't write any changes to the database." end unless user.active_blocks.empty? then return -1,t('application.setup_user_auth.blocked') end + if REQUIRE_TERMS_AGREED and user.terms_agreed.nil? then return -1,"You must accept the contributor terms before you can edit." end + + if cstags + if !tags_ok(cstags) then return -1,"One of the tags is invalid. Linux users may need to upgrade to Flash Player 10.1." end + cstags = strip_non_xml_chars cstags + end # close previous changeset and add comment if closeid @@ -197,6 +203,8 @@ class AmfController < ApplicationController cs.save! else cs.tags['comment']=closecomment + # in case closecomment has chars not allowed in xml + cs.tags = strip_non_xml_chars cs.tags cs.save_with_tags! end end @@ -206,7 +214,11 @@ class AmfController < ApplicationController cs = Changeset.new cs.tags = cstags cs.user_id = user.id - if !closecomment.empty? then cs.tags['comment']=closecomment end + if !closecomment.empty? + cs.tags['comment']=closecomment + # in case closecomment has chars not allowed in xml + cs.tags = strip_non_xml_chars cs.tags + end # smsm1 doesn't like the next two lines and thinks they need to be abstracted to the model more/better cs.created_at = Time.now.getutc cs.closed_at = cs.created_at + Changeset::IDLE_TIMEOUT @@ -253,14 +265,14 @@ class AmfController < ApplicationController loaded_lang = 'en' # Load English defaults - en = YAML::load(File.open("#{RAILS_ROOT}/config/potlatch/locales/en.yml"))["en"] + en = YAML::load(File.open("#{Rails.root}/config/potlatch/locales/en.yml"))["en"] if lang == 'en' return [loaded_lang, en] else # Use English as a fallback begin - other = YAML::load(File.open("#{RAILS_ROOT}/config/potlatch/locales/#{lang}.yml"))[lang] + other = YAML::load(File.open("#{Rails.root}/config/potlatch/locales/#{lang}.yml"))[lang] loaded_lang = lang rescue other = en @@ -562,6 +574,8 @@ class AmfController < ApplicationController user = getuser(usertoken) if !user then return -1,"You are not logged in, so the relation could not be saved." end unless user.active_blocks.empty? then return -1,t('application.setup_user_auth.blocked') end + if REQUIRE_TERMS_AGREED and user.terms_agreed.nil? then return -1,"You must accept the contributor terms before you can edit." end + if !tags_ok(tags) then return -1,"One of the tags is invalid. Linux users may need to upgrade to Flash Player 10.1." end tags = strip_non_xml_chars tags @@ -650,7 +664,10 @@ class AmfController < ApplicationController user = getuser(usertoken) if !user then return -1,"You are not logged in, so the way could not be saved." end unless user.active_blocks.empty? then return -1,t('application.setup_user_auth.blocked') end + if REQUIRE_TERMS_AGREED and user.terms_agreed.nil? then return -1,"You must accept the contributor terms before you can edit." end + if pointlist.length < 2 then return -2,"Server error - way is only #{points.length} points long." end + if !tags_ok(attributes) then return -1,"One of the tags is invalid. Linux users may need to upgrade to Flash Player 10.1." end attributes = strip_non_xml_chars attributes @@ -756,6 +773,8 @@ class AmfController < ApplicationController user = getuser(usertoken) if !user then return -1,"You are not logged in, so the point could not be saved." end unless user.active_blocks.empty? then return -1,t('application.setup_user_auth.blocked') end + if REQUIRE_TERMS_AGREED and user.terms_agreed.nil? then return -1,"You must accept the contributor terms before you can edit." end + if !tags_ok(tags) then return -1,"One of the tags is invalid. Linux users may need to upgrade to Flash Player 10.1." end tags = strip_non_xml_chars tags @@ -839,6 +858,7 @@ class AmfController < ApplicationController user = getuser(usertoken) unless user then return -1,"You are not logged in, so the way could not be deleted." end unless user.active_blocks.empty? then return -1,t('application.setup_user_auth.blocked') end + if REQUIRE_TERMS_AGREED and user.terms_agreed.nil? then return -1,"You must accept the contributor terms before you can edit." end way_id = way_id.to_i nodeversions = {} @@ -896,7 +916,7 @@ class AmfController < ApplicationController end def getlocales - Dir.glob("#{RAILS_ROOT}/config/potlatch/locales/*").collect { |f| File.basename(f, ".yml") } + Dir.glob("#{Rails.root}/config/potlatch/locales/*").collect { |f| File.basename(f, ".yml") } end ##