From a115edea9d3b6677533b953f72c72a221005e172 Mon Sep 17 00:00:00 2001 From: nwb Date: Thu, 26 Jun 2014 14:47:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=BE=E7=A8=8B=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E9=A1=B5=E9=80=89=E4=B8=AD=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 4 ++++ config/routes.rb | 1 + lib/redmine/menu_manager.rb | 10 ++++++++++ 3 files changed, 15 insertions(+) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 7128014d..c0d7c1e2 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -5,6 +5,10 @@ class CoursesController < ApplicationController helper :members helper :words + menu_item :overview + menu_item :feedback, :only => :feedback + menu_item :homework, :only => :homework + menu_item l(:label_sort_by_time), :only => :index menu_item l(:label_sort_by_active), :only => :index menu_item l(:label_sort_by_influence), :only => :index diff --git a/config/routes.rb b/config/routes.rb index 2b7f4b00..e4a93147 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -580,6 +580,7 @@ RedmineApp::Application.routes.draw do get 'homework', :action => 'homework', :as => 'homework' get 'new_homework', :action => 'new_homework', :as => 'new_homework' get 'file', :action => 'file', :as => 'file' + get 'feedback', :action => 'feedback', :as => 'course_feedback' get 'member', :controller => 'courses', :action => 'member', :as => 'member' post 'finishcourse' post 'restartcourse' diff --git a/lib/redmine/menu_manager.rb b/lib/redmine/menu_manager.rb index e28d46fb..75e79d06 100644 --- a/lib/redmine/menu_manager.rb +++ b/lib/redmine/menu_manager.rb @@ -67,6 +67,16 @@ module Redmine end false end + + def redirect_to_course_menu_item(course, name) + item = Redmine::MenuManager.items(:course_menu).detect {|i| i.name.to_s == name.to_s} + if item && User.current.allowed_to?(item.url, course) && (item.condition.nil? || item.condition.call(course)) + redirect_to({item.param => course}.merge(item.url)) + return true + end + false + end + end module MenuHelper