Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
9bf8abd03b
|
@ -174,7 +174,9 @@ class AttachmentsController < ApplicationController
|
|||
respond_to do |format|
|
||||
# modify by nwb
|
||||
if !@attachment.container.nil? && (@attachment.container.is_a?(Course) || @attachment.container.course)
|
||||
if @course.nil?
|
||||
if @attachment.container.is_a?(News)
|
||||
format.html { redirect_to_referer_or news_path(@attachment.container) }
|
||||
elsif @course.nil?
|
||||
format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) }
|
||||
else
|
||||
format.html { redirect_to_referer_or course_path(@course) }
|
||||
|
|
|
@ -68,6 +68,10 @@ module ApplicationHelper
|
|||
link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action])
|
||||
end
|
||||
|
||||
def link_to_if_authorized_course(name, options = {}, html_options = nil, *parameters_for_method_reference)
|
||||
link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for_course(options[:controller] || params[:controller], options[:action])
|
||||
end
|
||||
|
||||
def link_to_if_authorized_contest(name, options = {}, html_options = nil, *parameters_for_method_reference)
|
||||
link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for_contest(options[:controller] || params[:controller], options[:action])
|
||||
end
|
||||
|
|
|
@ -69,6 +69,7 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
def self.remove_by_user? user
|
||||
if( self.user == user ||
|
||||
( self.jour.kind_of?(User) && self.jour== user )
|
||||
|
@ -88,6 +89,15 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
User.find(reply_id)
|
||||
end
|
||||
|
||||
def delete_by_user?user
|
||||
# 用户可删除自己的留言
|
||||
if self.user.id == user.id || user.admin?
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def self.reference_message(user_id)
|
||||
@user = User.find(user_id)
|
||||
message = JournalsForMessage.find_by_sql("select * from journals_for_messages where reply_id = #{@user.id}
|
||||
|
|
|
@ -78,6 +78,9 @@ function checkMaxLength() {
|
|||
'#{l(:label_reply_plural)} #{journal.user.name}: ');
|
||||
return false;"} %>
|
||||
<% end %>
|
||||
<% if journal.delete_by_user?(User.current) %>
|
||||
<%= link_to(l(:button_delete), {:controller => 'words', :action => 'destroy', :object_id => journal, :user_id => journal.user}, :method => :delete,:remote => true)%>
|
||||
<% end %>
|
||||
</span>
|
||||
</span>
|
||||
<div style="clear: both;"></div>
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td align="left"><span class="font_lighter"> <%= format_time(comment.created_on) %></span></td>
|
||||
<td width="200" align="right" class="a"><%= link_to_if_authorized image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @news, :comment_id => comment},
|
||||
<td width="200" align="right" class="a"><%= link_to_if_authorized_course image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @news, :comment_id => comment},
|
||||
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %></td>
|
||||
</tr>
|
||||
</table></td>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
</div>
|
||||
<div class="wiki-description">
|
||||
<p>
|
||||
<%= textilizable(project.short_description, :project => project) %>
|
||||
<%= textilizable(project.short_description.strip, :project => project) %>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -48,9 +48,14 @@ module Redmine
|
|||
end
|
||||
|
||||
def attachments_deletable?(user=User.current)
|
||||
if (self.has_attribute?(:course) ||self.has_attribute?(:course_id)) && self.course
|
||||
(respond_to?(:visible?) ? visible?(user) : true) &&
|
||||
user.allowed_to?(self.class.attachable_options[:delete_permission], self.course)
|
||||
else
|
||||
(respond_to?(:visible?) ? visible?(user) : true) &&
|
||||
user.allowed_to?(self.class.attachable_options[:delete_permission], self.project)
|
||||
end
|
||||
end
|
||||
|
||||
def saved_attachments
|
||||
@saved_attachments ||= []
|
||||
|
|
Loading…
Reference in New Issue