diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 78ac4d208..54346c0cc 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -236,13 +236,7 @@ class ApplicationController < ActionController::Base # Authorize the user for the requested action def authorize(ctrl = params[:controller], action = params[:action], global = false) #modify by NWB - if @project - allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global) - elsif @course - allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @course || @courses, :global => global) - else - allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global) - end + allowed = authorize_allowed(params[:controller], params[:action],global) if allowed true @@ -255,6 +249,17 @@ class ApplicationController < ActionController::Base end end + def authorize_allowed(ctrl = params[:controller], action = params[:action], global = false) + #modify by NWB + if @project + allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global) + elsif @course + allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @course || @courses, :global => global) + else + allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global) + end + allowed + end def authorize_attachment_download(ctrl = params[:controller], action = params[:action], global = false) case @attachment.container_type when "Memo" diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4049c2ae8..410818fdb 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -433,9 +433,16 @@ class UsersController < ApplicationController else activity = Activity.where(where_condition).where('user_id = ?', @user.id).order('id desc') end + activity = activity.reject { |e| + ((e.act_type=="Issue") && ( !e.act.visible?(User.current))) || + ((e.act_type == "Journal") && (!e.act.project.visible?(User.current))) || + ((e.act_type == "Bid") && (e.act.homework_for_courses.count > 0 && + (!e.act.homework_for_courses.first.course.visible?(User.current) || + !User.current.member_of_course?(e.act.homework_for_courses.first.course) || !User.current.admin?))) + } @activity_count = activity.count @activity_pages = Paginator.new @activity_count, pre_count, params['page'] - @activity = activity.offset(@activity_pages.offset).limit(@activity_pages.per_page).all + @activity = activity.slice(@activity_pages.offset,@activity_pages.per_page) @state = 0 end diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 28994fe29..aac2c72b4 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -46,9 +46,10 @@ <% act = e.act %> <% unless act.nil? %> <% if e.act_type == 'JournalsForMessage' || e.act_type == 'Bid' || e.act_type == 'Journal'|| e.act_type == 'Changeset' || e.act_type == 'Message' || e.act_type == 'Principal' || e.act_type == 'News' || e.act_type == 'Issue' || e.act_type == 'Contest'%> - + +
- <% when 'Issue' %> - - <% if e.user == User.current %> + <% if e.user == User.current %> + + - <% else %> - - <% end %> + + + + + + + + <% else %> + + + <% end %> + <% when 'Contest' %> <% if e.user == User.current && @show_contest == 1%> @@ -531,7 +558,9 @@
+ <%= image_tag(url_to_avatar(e.user), :class => "avatar") %> @@ -430,8 +431,9 @@
<%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> @@ -445,20 +447,42 @@ :action => 'show', :id => act.id} %> - - <%= link_to(h(e.user), user_path(e.user_id)) %> -   - - <%= l(:label_new_activity) %> -   - <%= link_to format_activity_title("#{act.source_from} (#{act.status}): #{act.tracker.name} #{act.subject}"), - {:controller => 'issues', - :action => 'show', - :id => act.id} %> -
+ <%= textAreailizable act, :description %> +
+
+ + <%= (l(:label_update_time).to_s << ':' << format_time(e.act.created_on)).to_s %> + +
+
+ + <%= link_to l(:label_find_all_comments), {:controller => 'issues', :action => 'show', :id => act.id} %> + + + <%= l(:label_comments_count, :count => e.act.journals.count) %> + +
+
+ + <%= link_to(h(e.user), user_path(e.user_id)) %> +   + + <%= l(:label_new_activity) %> +   + <%= link_to format_activity_title("#{act.source_from} (#{act.status}): #{act.tracker.name} #{act.subject}"), + {:controller => 'issues', + :action => 'show', + :id => act.id} %> +
@@ -482,6 +506,9 @@
- <% end %> + + + <% end %> <% end %> <% end %>