Skip to content

Commit

Permalink
Rolled back secure code between version and node (is not needed with …
Browse files Browse the repository at this point in the history
…:inverse_of...).
  • Loading branch information
gaspard committed Sep 3, 2009
1 parent 46c3e90 commit 81d1fab
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
8 changes: 6 additions & 2 deletions lib/zena/acts/multiversion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -386,15 +386,19 @@ def version(key=nil) #:doc:
min_status = (key == :pub) ? Zena::Status[:pub] : Zena::Status[:red]
if max_status >= Zena::Status[:red]
# normal version
versions.find(:first,
v = versions.find(:first,
:select => "*, (lang = #{Node.connection.quote(visitor.lang)}) as lang_ok, (lang = #{Node.connection.quote(ref_lang)}) as ref_ok",
:conditions => [ "(status >= #{min_status} AND user_id = ? AND lang = ?) OR status >= #{can_drive? ? [min_status, Zena::Status[:prop]].max : Zena::Status[:pub]}", visitor.id, visitor.lang ],
:order => "lang_ok DESC, ref_ok DESC, status ASC, publish_from ASC")
v.node = self if v # FIXME: remove when :inverse_of moves in Rails stable
v
else
# drive only
versions.find(:first,
v = versions.find(:first,
:select => "*, (lang = #{Node.connection.quote(visitor.lang)}) as lang_ok, (lang = #{Node.connection.quote(ref_lang)}) as ref_ok",
:order => "lang_ok DESC, ref_ok DESC, status ASC, publish_from ASC")
v.node = self if v # FIXME: remove when :inverse_of moves in Rails stable
v
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/zena/test_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ def templates=(templates)
end
end
def test_compile
render :text=>ZafuParser.new_with_url(@test_url, :helper => zafu_helper).render(:dev => params['dev'])
render :text => ZafuParser.new_with_url(@test_url, :helper => zafu_helper).render(:dev => params['dev'])
end

def test_render
render :inline=>@text
render :inline => @text
end

def test_zazen
render :text=>ZazenParser.new(@text, :helper => zafu_helper).render
render :text => ZazenParser.new(@text, :helper => zafu_helper).render
end

private
Expand Down
4 changes: 2 additions & 2 deletions lib/zena/use/i18n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ def _(str)
# Show a little [xx] next to the title if the desired language could not be found. You can
# use a :text => '(lang)' option. The word 'lang' will be replaced by the real value.
def check_lang(obj, opts={})
wlang = (opts[:text] || '[#LANG]').sub('#LANG', obj.v_lang).sub('_LANG', _(obj.v_lang))
obj.v_lang != lang ? "<#{opts[:wrap] || 'span'} class='#{opts[:class] || 'wrong_lang'}'>#{wlang}</#{opts[:wrap] || 'span'}>" : ""
wlang = (opts[:text] || '[#LANG]').sub('#LANG', obj.version.lang).sub('_LANG', _(obj.version.lang))
obj.version.lang != lang ? "<#{opts[:wrap] || 'span'} class='#{opts[:class] || 'wrong_lang'}'>#{wlang}</#{opts[:wrap] || 'span'}>" : ""
end

end # ViewMethods
Expand Down

0 comments on commit 81d1fab

Please sign in to comment.