##// END OF EJS Templates
replaced deprecated controller instance variables: @params, @session, @request...
Jean-Philippe Lang -
r124:95cc65f14e02
parent child
Show More
@@ -1,56 +1,56
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 class AdminController < ApplicationController
18 class AdminController < ApplicationController
19 layout 'base'
19 layout 'base'
20 before_filter :require_admin
20 before_filter :require_admin
21
21
22 helper :sort
22 helper :sort
23 include SortHelper
23 include SortHelper
24
24
25 def index
25 def index
26 end
26 end
27
27
28 def projects
28 def projects
29 sort_init 'name', 'asc'
29 sort_init 'name', 'asc'
30 sort_update
30 sort_update
31 @project_count = Project.count
31 @project_count = Project.count
32 @project_pages = Paginator.new self, @project_count,
32 @project_pages = Paginator.new self, @project_count,
33 15,
33 15,
34 @params['page']
34 params['page']
35 @projects = Project.find :all, :order => sort_clause,
35 @projects = Project.find :all, :order => sort_clause,
36 :limit => @project_pages.items_per_page,
36 :limit => @project_pages.items_per_page,
37 :offset => @project_pages.current.offset
37 :offset => @project_pages.current.offset
38
38
39 render :action => "projects", :layout => false if request.xhr?
39 render :action => "projects", :layout => false if request.xhr?
40 end
40 end
41
41
42 def mail_options
42 def mail_options
43 @actions = Permission.find(:all, :conditions => ["mail_option=?", true]) || []
43 @actions = Permission.find(:all, :conditions => ["mail_option=?", true]) || []
44 if request.post?
44 if request.post?
45 @actions.each { |a|
45 @actions.each { |a|
46 a.mail_enabled = (params[:action_ids] || []).include? a.id.to_s
46 a.mail_enabled = (params[:action_ids] || []).include? a.id.to_s
47 a.save
47 a.save
48 }
48 }
49 flash.now[:notice] = l(:notice_successful_update)
49 flash.now[:notice] = l(:notice_successful_update)
50 end
50 end
51 end
51 end
52
52
53 def info
53 def info
54 @adapter_name = ActiveRecord::Base.connection.adapter_name
54 @adapter_name = ActiveRecord::Base.connection.adapter_name
55 end
55 end
56 end
56 end
@@ -1,126 +1,126
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 class ApplicationController < ActionController::Base
18 class ApplicationController < ActionController::Base
19 before_filter :check_if_login_required, :set_localization
19 before_filter :check_if_login_required, :set_localization
20
20
21 def logged_in_user=(user)
21 def logged_in_user=(user)
22 @logged_in_user = user
22 @logged_in_user = user
23 session[:user_id] = (user ? user.id : nil)
23 session[:user_id] = (user ? user.id : nil)
24 end
24 end
25
25
26 def logged_in_user
26 def logged_in_user
27 if session[:user_id]
27 if session[:user_id]
28 @logged_in_user ||= User.find(session[:user_id])
28 @logged_in_user ||= User.find(session[:user_id])
29 else
29 else
30 nil
30 nil
31 end
31 end
32 end
32 end
33
33
34 # check if login is globally required to access the application
34 # check if login is globally required to access the application
35 def check_if_login_required
35 def check_if_login_required
36 require_login if $RDM_LOGIN_REQUIRED
36 require_login if $RDM_LOGIN_REQUIRED
37 end
37 end
38
38
39 def set_localization
39 def set_localization
40 lang = begin
40 lang = begin
41 if self.logged_in_user and self.logged_in_user.language and !self.logged_in_user.language.empty? and GLoc.valid_languages.include? self.logged_in_user.language.to_sym
41 if self.logged_in_user and self.logged_in_user.language and !self.logged_in_user.language.empty? and GLoc.valid_languages.include? self.logged_in_user.language.to_sym
42 self.logged_in_user.language
42 self.logged_in_user.language
43 elsif request.env['HTTP_ACCEPT_LANGUAGE']
43 elsif request.env['HTTP_ACCEPT_LANGUAGE']
44 accept_lang = parse_qvalues(request.env['HTTP_ACCEPT_LANGUAGE']).first.split('-').first
44 accept_lang = parse_qvalues(request.env['HTTP_ACCEPT_LANGUAGE']).first.split('-').first
45 if accept_lang and !accept_lang.empty? and GLoc.valid_languages.include? accept_lang.to_sym
45 if accept_lang and !accept_lang.empty? and GLoc.valid_languages.include? accept_lang.to_sym
46 accept_lang
46 accept_lang
47 end
47 end
48 end
48 end
49 rescue
49 rescue
50 nil
50 nil
51 end || $RDM_DEFAULT_LANG
51 end || $RDM_DEFAULT_LANG
52 set_language_if_valid(lang)
52 set_language_if_valid(lang)
53 end
53 end
54
54
55 def require_login
55 def require_login
56 unless self.logged_in_user
56 unless self.logged_in_user
57 store_location
57 store_location
58 redirect_to :controller => "account", :action => "login"
58 redirect_to :controller => "account", :action => "login"
59 return false
59 return false
60 end
60 end
61 true
61 true
62 end
62 end
63
63
64 def require_admin
64 def require_admin
65 return unless require_login
65 return unless require_login
66 unless self.logged_in_user.admin?
66 unless self.logged_in_user.admin?
67 render :nothing => true, :status => 403
67 render :nothing => true, :status => 403
68 return false
68 return false
69 end
69 end
70 true
70 true
71 end
71 end
72
72
73 # authorizes the user for the requested action.
73 # authorizes the user for the requested action.
74 def authorize(ctrl = @params[:controller], action = @params[:action])
74 def authorize(ctrl = params[:controller], action = params[:action])
75 # check if action is allowed on public projects
75 # check if action is allowed on public projects
76 if @project.is_public? and Permission.allowed_to_public "%s/%s" % [ ctrl, action ]
76 if @project.is_public? and Permission.allowed_to_public "%s/%s" % [ ctrl, action ]
77 return true
77 return true
78 end
78 end
79 # if action is not public, force login
79 # if action is not public, force login
80 return unless require_login
80 return unless require_login
81 # admin is always authorized
81 # admin is always authorized
82 return true if self.logged_in_user.admin?
82 return true if self.logged_in_user.admin?
83 # if not admin, check membership permission
83 # if not admin, check membership permission
84 @user_membership ||= Member.find(:first, :conditions => ["user_id=? and project_id=?", self.logged_in_user.id, @project.id])
84 @user_membership ||= Member.find(:first, :conditions => ["user_id=? and project_id=?", self.logged_in_user.id, @project.id])
85 if @user_membership and Permission.allowed_to_role( "%s/%s" % [ ctrl, action ], @user_membership.role_id )
85 if @user_membership and Permission.allowed_to_role( "%s/%s" % [ ctrl, action ], @user_membership.role_id )
86 return true
86 return true
87 end
87 end
88 render :nothing => true, :status => 403
88 render :nothing => true, :status => 403
89 false
89 false
90 end
90 end
91
91
92 # store current uri in session.
92 # store current uri in session.
93 # return to this location by calling redirect_back_or_default
93 # return to this location by calling redirect_back_or_default
94 def store_location
94 def store_location
95 session[:return_to] = @request.request_uri
95 session[:return_to] = request.request_uri
96 end
96 end
97
97
98 # move to the last store_location call or to the passed default one
98 # move to the last store_location call or to the passed default one
99 def redirect_back_or_default(default)
99 def redirect_back_or_default(default)
100 if session[:return_to].nil?
100 if session[:return_to].nil?
101 redirect_to default
101 redirect_to default
102 else
102 else
103 redirect_to_url session[:return_to]
103 redirect_to_url session[:return_to]
104 session[:return_to] = nil
104 session[:return_to] = nil
105 end
105 end
106 end
106 end
107
107
108 # qvalues http header parser
108 # qvalues http header parser
109 # code taken from webrick
109 # code taken from webrick
110 def parse_qvalues(value)
110 def parse_qvalues(value)
111 tmp = []
111 tmp = []
112 if value
112 if value
113 parts = value.split(/,\s*/)
113 parts = value.split(/,\s*/)
114 parts.each {|part|
114 parts.each {|part|
115 if m = %r{^([^\s,]+?)(?:;\s*q=(\d+(?:\.\d+)?))?$}.match(part)
115 if m = %r{^([^\s,]+?)(?:;\s*q=(\d+(?:\.\d+)?))?$}.match(part)
116 val = m[1]
116 val = m[1]
117 q = (m[2] or 1).to_f
117 q = (m[2] or 1).to_f
118 tmp.push([val, q])
118 tmp.push([val, q])
119 end
119 end
120 }
120 }
121 tmp = tmp.sort_by{|val, q| -q}
121 tmp = tmp.sort_by{|val, q| -q}
122 tmp.collect!{|val, q| val}
122 tmp.collect!{|val, q| val}
123 end
123 end
124 return tmp
124 return tmp
125 end
125 end
126 end No newline at end of file
126 end
@@ -1,47 +1,47
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 class HelpController < ApplicationController
18 class HelpController < ApplicationController
19
19
20 skip_before_filter :check_if_login_required
20 skip_before_filter :check_if_login_required
21 before_filter :load_help_config
21 before_filter :load_help_config
22
22
23 # displays help page for the requested controller/action
23 # displays help page for the requested controller/action
24 def index
24 def index
25 # select help page to display
25 # select help page to display
26 if @params[:ctrl] and @help_config['pages'][@params[:ctrl]]
26 if params[:ctrl] and @help_config['pages'][params[:ctrl]]
27 if @params[:page] and @help_config['pages'][@params[:ctrl]][@params[:page]]
27 if params[:page] and @help_config['pages'][params[:ctrl]][params[:page]]
28 template = @help_config['pages'][@params[:ctrl]][@params[:page]]
28 template = @help_config['pages'][params[:ctrl]][params[:page]]
29 else
29 else
30 template = @help_config['pages'][@params[:ctrl]]['index']
30 template = @help_config['pages'][params[:ctrl]]['index']
31 end
31 end
32 end
32 end
33 # choose language according to available help translations
33 # choose language according to available help translations
34 lang = (@help_config['langs'].include? current_language.to_s) ? current_language.to_s : @help_config['langs'].first
34 lang = (@help_config['langs'].include? current_language.to_s) ? current_language.to_s : @help_config['langs'].first
35
35
36 if template
36 if template
37 redirect_to "/manual/#{lang}/#{template}"
37 redirect_to "/manual/#{lang}/#{template}"
38 else
38 else
39 redirect_to "/manual/#{lang}/"
39 redirect_to "/manual/#{lang}/"
40 end
40 end
41 end
41 end
42
42
43 private
43 private
44 def load_help_config
44 def load_help_config
45 @help_config = YAML::load(File.open("#{RAILS_ROOT}/config/help.yml"))
45 @help_config = YAML::load(File.open("#{RAILS_ROOT}/config/help.yml"))
46 end
46 end
47 end
47 end
@@ -1,145 +1,145
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 class IssuesController < ApplicationController
18 class IssuesController < ApplicationController
19 layout 'base', :except => :export_pdf
19 layout 'base', :except => :export_pdf
20 before_filter :find_project, :authorize
20 before_filter :find_project, :authorize
21
21
22 helper :custom_fields
22 helper :custom_fields
23 include CustomFieldsHelper
23 include CustomFieldsHelper
24 helper :ifpdf
24 helper :ifpdf
25 include IfpdfHelper
25 include IfpdfHelper
26
26
27 def show
27 def show
28 @status_options = @issue.status.workflows.find(:all, :include => :new_status, :conditions => ["role_id=? and tracker_id=?", self.logged_in_user.role_for_project(@project.id), @issue.tracker.id]).collect{ |w| w.new_status } if self.logged_in_user
28 @status_options = @issue.status.workflows.find(:all, :include => :new_status, :conditions => ["role_id=? and tracker_id=?", self.logged_in_user.role_for_project(@project.id), @issue.tracker.id]).collect{ |w| w.new_status } if self.logged_in_user
29 @custom_values = @issue.custom_values.find(:all, :include => :custom_field)
29 @custom_values = @issue.custom_values.find(:all, :include => :custom_field)
30 @journals_count = @issue.journals.count
30 @journals_count = @issue.journals.count
31 @journals = @issue.journals.find(:all, :include => [:user, :details], :limit => 15, :order => "journals.created_on desc")
31 @journals = @issue.journals.find(:all, :include => [:user, :details], :limit => 15, :order => "journals.created_on desc")
32 end
32 end
33
33
34 def history
34 def history
35 @journals = @issue.journals.find(:all, :include => [:user, :details], :order => "journals.created_on desc")
35 @journals = @issue.journals.find(:all, :include => [:user, :details], :order => "journals.created_on desc")
36 @journals_count = @journals.length
36 @journals_count = @journals.length
37 end
37 end
38
38
39 def export_pdf
39 def export_pdf
40 @custom_values = @issue.custom_values.find(:all, :include => :custom_field)
40 @custom_values = @issue.custom_values.find(:all, :include => :custom_field)
41 @options_for_rfpdf ||= {}
41 @options_for_rfpdf ||= {}
42 @options_for_rfpdf[:file_name] = "#{@project.name}_#{@issue.long_id}.pdf"
42 @options_for_rfpdf[:file_name] = "#{@project.name}_#{@issue.long_id}.pdf"
43 end
43 end
44
44
45 def edit
45 def edit
46 @priorities = Enumeration::get_values('IPRI')
46 @priorities = Enumeration::get_values('IPRI')
47 if request.get?
47 if request.get?
48 @custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| @issue.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x, :customized => @issue) }
48 @custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| @issue.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x, :customized => @issue) }
49 else
49 else
50 begin
50 begin
51 @issue.init_journal(self.logged_in_user)
51 @issue.init_journal(self.logged_in_user)
52 # Retrieve custom fields and values
52 # Retrieve custom fields and values
53 @custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) }
53 @custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) }
54 @issue.custom_values = @custom_values
54 @issue.custom_values = @custom_values
55 @issue.attributes = params[:issue]
55 @issue.attributes = params[:issue]
56 if @issue.save
56 if @issue.save
57 flash[:notice] = l(:notice_successful_update)
57 flash[:notice] = l(:notice_successful_update)
58 redirect_to :action => 'show', :id => @issue
58 redirect_to :action => 'show', :id => @issue
59 end
59 end
60 rescue ActiveRecord::StaleObjectError
60 rescue ActiveRecord::StaleObjectError
61 # Optimistic locking exception
61 # Optimistic locking exception
62 flash[:notice] = l(:notice_locking_conflict)
62 flash[:notice] = l(:notice_locking_conflict)
63 end
63 end
64 end
64 end
65 end
65 end
66
66
67 def add_note
67 def add_note
68 unless params[:notes].empty?
68 unless params[:notes].empty?
69 journal = @issue.init_journal(self.logged_in_user, params[:notes])
69 journal = @issue.init_journal(self.logged_in_user, params[:notes])
70 #@history = @issue.histories.build(params[:history])
70 #@history = @issue.histories.build(params[:history])
71 #@history.author_id = self.logged_in_user.id if self.logged_in_user
71 #@history.author_id = self.logged_in_user.id if self.logged_in_user
72 #@history.status = @issue.status
72 #@history.status = @issue.status
73 if @issue.save
73 if @issue.save
74 flash[:notice] = l(:notice_successful_update)
74 flash[:notice] = l(:notice_successful_update)
75 Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(@params[:controller], @params[:action]).mail_enabled?
75 Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
76 redirect_to :action => 'show', :id => @issue
76 redirect_to :action => 'show', :id => @issue
77 return
77 return
78 end
78 end
79 end
79 end
80 show
80 show
81 render :action => 'show'
81 render :action => 'show'
82 end
82 end
83
83
84 def change_status
84 def change_status
85 #@history = @issue.histories.build(params[:history])
85 #@history = @issue.histories.build(params[:history])
86 @status_options = @issue.status.workflows.find(:all, :conditions => ["role_id=? and tracker_id=?", self.logged_in_user.role_for_project(@project.id), @issue.tracker.id]).collect{ |w| w.new_status } if self.logged_in_user
86 @status_options = @issue.status.workflows.find(:all, :conditions => ["role_id=? and tracker_id=?", self.logged_in_user.role_for_project(@project.id), @issue.tracker.id]).collect{ |w| w.new_status } if self.logged_in_user
87 @new_status = IssueStatus.find(params[:new_status_id])
87 @new_status = IssueStatus.find(params[:new_status_id])
88 if params[:confirm]
88 if params[:confirm]
89 begin
89 begin
90 #@history.author_id = self.logged_in_user.id if self.logged_in_user
90 #@history.author_id = self.logged_in_user.id if self.logged_in_user
91 #@issue.status = @history.status
91 #@issue.status = @history.status
92 #@issue.fixed_version_id = (params[:issue][:fixed_version_id])
92 #@issue.fixed_version_id = (params[:issue][:fixed_version_id])
93 #@issue.assigned_to_id = (params[:issue][:assigned_to_id])
93 #@issue.assigned_to_id = (params[:issue][:assigned_to_id])
94 #@issue.done_ratio = (params[:issue][:done_ratio])
94 #@issue.done_ratio = (params[:issue][:done_ratio])
95 #@issue.lock_version = (params[:issue][:lock_version])
95 #@issue.lock_version = (params[:issue][:lock_version])
96 journal = @issue.init_journal(self.logged_in_user, params[:notes])
96 journal = @issue.init_journal(self.logged_in_user, params[:notes])
97 @issue.status = @new_status
97 @issue.status = @new_status
98 if @issue.update_attributes(params[:issue])
98 if @issue.update_attributes(params[:issue])
99 flash[:notice] = l(:notice_successful_update)
99 flash[:notice] = l(:notice_successful_update)
100 Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(@params[:controller], @params[:action]).mail_enabled?
100 Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
101 redirect_to :action => 'show', :id => @issue
101 redirect_to :action => 'show', :id => @issue
102 end
102 end
103 rescue ActiveRecord::StaleObjectError
103 rescue ActiveRecord::StaleObjectError
104 # Optimistic locking exception
104 # Optimistic locking exception
105 flash[:notice] = l(:notice_locking_conflict)
105 flash[:notice] = l(:notice_locking_conflict)
106 end
106 end
107 end
107 end
108 @assignable_to = @project.members.find(:all, :include => :user).collect{ |m| m.user }
108 @assignable_to = @project.members.find(:all, :include => :user).collect{ |m| m.user }
109 end
109 end
110
110
111 def destroy
111 def destroy
112 @issue.destroy
112 @issue.destroy
113 redirect_to :controller => 'projects', :action => 'list_issues', :id => @project
113 redirect_to :controller => 'projects', :action => 'list_issues', :id => @project
114 end
114 end
115
115
116 def add_attachment
116 def add_attachment
117 # Save the attachments
117 # Save the attachments
118 params[:attachments].each { |a|
118 params[:attachments].each { |a|
119 @attachment = @issue.attachments.build(:file => a, :author => self.logged_in_user) unless a.size == 0
119 @attachment = @issue.attachments.build(:file => a, :author => self.logged_in_user) unless a.size == 0
120 @attachment.save
120 @attachment.save
121 } if params[:attachments] and params[:attachments].is_a? Array
121 } if params[:attachments] and params[:attachments].is_a? Array
122 redirect_to :action => 'show', :id => @issue
122 redirect_to :action => 'show', :id => @issue
123 end
123 end
124
124
125 def destroy_attachment
125 def destroy_attachment
126 @issue.attachments.find(params[:attachment_id]).destroy
126 @issue.attachments.find(params[:attachment_id]).destroy
127 redirect_to :action => 'show', :id => @issue
127 redirect_to :action => 'show', :id => @issue
128 end
128 end
129
129
130 # Send the file in stream mode
130 # Send the file in stream mode
131 def download
131 def download
132 @attachment = @issue.attachments.find(params[:attachment_id])
132 @attachment = @issue.attachments.find(params[:attachment_id])
133 send_file @attachment.diskfile, :filename => @attachment.filename
133 send_file @attachment.diskfile, :filename => @attachment.filename
134 rescue
134 rescue
135 flash.now[:notice] = l(:notice_file_not_found)
135 flash.now[:notice] = l(:notice_file_not_found)
136 render :text => "", :layout => true, :status => 404
136 render :text => "", :layout => true, :status => 404
137 end
137 end
138
138
139 private
139 private
140 def find_project
140 def find_project
141 @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
141 @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
142 @project = @issue.project
142 @project = @issue.project
143 @html_title = "#{@project.name} - #{@issue.tracker.name} ##{@issue.id}"
143 @html_title = "#{@project.name} - #{@issue.tracker.name} ##{@issue.id}"
144 end
144 end
145 end
145 end
@@ -1,131 +1,131
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 class MyController < ApplicationController
18 class MyController < ApplicationController
19 layout 'base'
19 layout 'base'
20 before_filter :require_login
20 before_filter :require_login
21
21
22 BLOCKS = { 'issues_assigned_to_me' => :label_assigned_to_me_issues,
22 BLOCKS = { 'issues_assigned_to_me' => :label_assigned_to_me_issues,
23 'issues_reported_by_me' => :label_reported_issues,
23 'issues_reported_by_me' => :label_reported_issues,
24 'latest_news' => :label_news_latest,
24 'latest_news' => :label_news_latest,
25 'calendar' => :label_calendar,
25 'calendar' => :label_calendar,
26 'documents' => :label_document_plural
26 'documents' => :label_document_plural
27 }.freeze
27 }.freeze
28
28
29 verify :xhr => true,
29 verify :xhr => true,
30 :session => :page_layout,
30 :session => :page_layout,
31 :only => [:add_block, :remove_block, :order_blocks]
31 :only => [:add_block, :remove_block, :order_blocks]
32
32
33 def index
33 def index
34 page
34 page
35 render :action => 'page'
35 render :action => 'page'
36 end
36 end
37
37
38 # Show user's page
38 # Show user's page
39 def page
39 def page
40 @user = self.logged_in_user
40 @user = self.logged_in_user
41 @blocks = @user.pref[:my_page_layout] || { 'left' => ['issues_assigned_to_me'], 'right' => ['issues_reported_by_me'] }
41 @blocks = @user.pref[:my_page_layout] || { 'left' => ['issues_assigned_to_me'], 'right' => ['issues_reported_by_me'] }
42 end
42 end
43
43
44 # Edit user's account
44 # Edit user's account
45 def account
45 def account
46 @user = self.logged_in_user
46 @user = self.logged_in_user
47 @pref = @user.pref
47 @pref = @user.pref
48 @user.attributes = params[:user]
48 @user.attributes = params[:user]
49 @user.pref.attributes = params[:pref]
49 @user.pref.attributes = params[:pref]
50 if request.post? and @user.save
50 if request.post? and @user.save
51 set_localization
51 set_localization
52 flash.now[:notice] = l(:notice_account_updated)
52 flash.now[:notice] = l(:notice_account_updated)
53 self.logged_in_user.reload
53 self.logged_in_user.reload
54 end
54 end
55 end
55 end
56
56
57 # Change user's password
57 # Change user's password
58 def change_password
58 def change_password
59 @user = self.logged_in_user
59 @user = self.logged_in_user
60 flash[:notice] = l(:notice_can_t_change_password) and redirect_to :action => 'account' and return if @user.auth_source_id
60 flash[:notice] = l(:notice_can_t_change_password) and redirect_to :action => 'account' and return if @user.auth_source_id
61 if @user.check_password?(@params[:password])
61 if @user.check_password?(params[:password])
62 @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation]
62 @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation]
63 if @user.save
63 if @user.save
64 flash[:notice] = l(:notice_account_password_updated)
64 flash[:notice] = l(:notice_account_password_updated)
65 else
65 else
66 render :action => 'account'
66 render :action => 'account'
67 return
67 return
68 end
68 end
69 else
69 else
70 flash[:notice] = l(:notice_account_wrong_password)
70 flash[:notice] = l(:notice_account_wrong_password)
71 end
71 end
72 redirect_to :action => 'account'
72 redirect_to :action => 'account'
73 end
73 end
74
74
75 # User's page layout configuration
75 # User's page layout configuration
76 def page_layout
76 def page_layout
77 @user = self.logged_in_user
77 @user = self.logged_in_user
78 @blocks = @user.pref[:my_page_layout] || { 'left' => ['issues_assigned_to_me'], 'right' => ['issues_reported_by_me'] }
78 @blocks = @user.pref[:my_page_layout] || { 'left' => ['issues_assigned_to_me'], 'right' => ['issues_reported_by_me'] }
79 session[:page_layout] = @blocks
79 session[:page_layout] = @blocks
80 %w(top left right).each {|f| session[:page_layout][f] ||= [] }
80 %w(top left right).each {|f| session[:page_layout][f] ||= [] }
81 @block_options = []
81 @block_options = []
82 BLOCKS.each {|k, v| @block_options << [l(v), k]}
82 BLOCKS.each {|k, v| @block_options << [l(v), k]}
83 end
83 end
84
84
85 # Add a block to user's page
85 # Add a block to user's page
86 # The block is added on top of the page
86 # The block is added on top of the page
87 # params[:block] : id of the block to add
87 # params[:block] : id of the block to add
88 def add_block
88 def add_block
89 @user = self.logged_in_user
89 @user = self.logged_in_user
90 block = params[:block]
90 block = params[:block]
91 # remove if already present in a group
91 # remove if already present in a group
92 %w(top left right).each {|f| (session[:page_layout][f] ||= []).delete block }
92 %w(top left right).each {|f| (session[:page_layout][f] ||= []).delete block }
93 # add it on top
93 # add it on top
94 session[:page_layout]['top'].unshift block
94 session[:page_layout]['top'].unshift block
95 render :partial => "block", :locals => {:user => @user, :block_name => block}
95 render :partial => "block", :locals => {:user => @user, :block_name => block}
96 end
96 end
97
97
98 # Remove a block to user's page
98 # Remove a block to user's page
99 # params[:block] : id of the block to remove
99 # params[:block] : id of the block to remove
100 def remove_block
100 def remove_block
101 block = params[:block]
101 block = params[:block]
102 # remove block in all groups
102 # remove block in all groups
103 %w(top left right).each {|f| (session[:page_layout][f] ||= []).delete block }
103 %w(top left right).each {|f| (session[:page_layout][f] ||= []).delete block }
104 render :nothing => true
104 render :nothing => true
105 end
105 end
106
106
107 # Change blocks order on user's page
107 # Change blocks order on user's page
108 # params[:group] : group to order (top, left or right)
108 # params[:group] : group to order (top, left or right)
109 # params[:list-(top|left|right)] : array of block ids of the group
109 # params[:list-(top|left|right)] : array of block ids of the group
110 def order_blocks
110 def order_blocks
111 group = params[:group]
111 group = params[:group]
112 group_items = params["list-#{group}"]
112 group_items = params["list-#{group}"]
113 if group_items and group_items.is_a? Array
113 if group_items and group_items.is_a? Array
114 # remove group blocks if they are presents in other groups
114 # remove group blocks if they are presents in other groups
115 %w(top left right).each {|f|
115 %w(top left right).each {|f|
116 session[:page_layout][f] = (session[:page_layout][f] || []) - group_items
116 session[:page_layout][f] = (session[:page_layout][f] || []) - group_items
117 }
117 }
118 session[:page_layout][group] = group_items
118 session[:page_layout][group] = group_items
119 end
119 end
120 render :nothing => true
120 render :nothing => true
121 end
121 end
122
122
123 # Save user's page layout
123 # Save user's page layout
124 def page_layout_save
124 def page_layout_save
125 @user = self.logged_in_user
125 @user = self.logged_in_user
126 @user.pref[:my_page_layout] = session[:page_layout] if session[:page_layout]
126 @user.pref[:my_page_layout] = session[:page_layout] if session[:page_layout]
127 @user.pref.save
127 @user.pref.save
128 session[:page_layout] = nil
128 session[:page_layout] = nil
129 redirect_to :action => 'page'
129 redirect_to :action => 'page'
130 end
130 end
131 end
131 end
@@ -1,535 +1,535
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 class ProjectsController < ApplicationController
18 class ProjectsController < ApplicationController
19 layout 'base'
19 layout 'base'
20 before_filter :find_project, :authorize, :except => [ :index, :list, :add ]
20 before_filter :find_project, :authorize, :except => [ :index, :list, :add ]
21 before_filter :require_admin, :only => [ :add, :destroy ]
21 before_filter :require_admin, :only => [ :add, :destroy ]
22
22
23 helper :sort
23 helper :sort
24 include SortHelper
24 include SortHelper
25 helper :custom_fields
25 helper :custom_fields
26 include CustomFieldsHelper
26 include CustomFieldsHelper
27 helper :ifpdf
27 helper :ifpdf
28 include IfpdfHelper
28 include IfpdfHelper
29 helper IssuesHelper
29 helper IssuesHelper
30 helper :queries
30 helper :queries
31 include QueriesHelper
31 include QueriesHelper
32
32
33 def index
33 def index
34 list
34 list
35 render :action => 'list' unless request.xhr?
35 render :action => 'list' unless request.xhr?
36 end
36 end
37
37
38 # Lists public projects
38 # Lists public projects
39 def list
39 def list
40 sort_init 'name', 'asc'
40 sort_init 'name', 'asc'
41 sort_update
41 sort_update
42 @project_count = Project.count(["is_public=?", true])
42 @project_count = Project.count(["is_public=?", true])
43 @project_pages = Paginator.new self, @project_count,
43 @project_pages = Paginator.new self, @project_count,
44 15,
44 15,
45 @params['page']
45 params['page']
46 @projects = Project.find :all, :order => sort_clause,
46 @projects = Project.find :all, :order => sort_clause,
47 :conditions => ["is_public=?", true],
47 :conditions => ["is_public=?", true],
48 :limit => @project_pages.items_per_page,
48 :limit => @project_pages.items_per_page,
49 :offset => @project_pages.current.offset
49 :offset => @project_pages.current.offset
50
50
51 render :action => "list", :layout => false if request.xhr?
51 render :action => "list", :layout => false if request.xhr?
52 end
52 end
53
53
54 # Add a new project
54 # Add a new project
55 def add
55 def add
56 @custom_fields = IssueCustomField.find(:all)
56 @custom_fields = IssueCustomField.find(:all)
57 @root_projects = Project.find(:all, :conditions => "parent_id is null")
57 @root_projects = Project.find(:all, :conditions => "parent_id is null")
58 @project = Project.new(params[:project])
58 @project = Project.new(params[:project])
59 if request.get?
59 if request.get?
60 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project) }
60 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project) }
61 else
61 else
62 @project.custom_fields = CustomField.find(@params[:custom_field_ids]) if @params[:custom_field_ids]
62 @project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids]
63 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
63 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
64 @project.custom_values = @custom_values
64 @project.custom_values = @custom_values
65 if params[:repository_enabled] && params[:repository_enabled] == "1"
65 if params[:repository_enabled] && params[:repository_enabled] == "1"
66 @project.repository = Repository.new
66 @project.repository = Repository.new
67 @project.repository.attributes = params[:repository]
67 @project.repository.attributes = params[:repository]
68 end
68 end
69 if @project.save
69 if @project.save
70 flash[:notice] = l(:notice_successful_create)
70 flash[:notice] = l(:notice_successful_create)
71 redirect_to :controller => 'admin', :action => 'projects'
71 redirect_to :controller => 'admin', :action => 'projects'
72 end
72 end
73 end
73 end
74 end
74 end
75
75
76 # Show @project
76 # Show @project
77 def show
77 def show
78 @custom_values = @project.custom_values.find(:all, :include => :custom_field)
78 @custom_values = @project.custom_values.find(:all, :include => :custom_field)
79 @members = @project.members.find(:all, :include => [:user, :role])
79 @members = @project.members.find(:all, :include => [:user, :role])
80 @subprojects = @project.children if @project.children_count > 0
80 @subprojects = @project.children if @project.children_count > 0
81 @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "news.created_on DESC")
81 @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "news.created_on DESC")
82 @trackers = Tracker.find(:all)
82 @trackers = Tracker.find(:all)
83 end
83 end
84
84
85 def settings
85 def settings
86 @root_projects = Project::find(:all, :conditions => ["parent_id is null and id <> ?", @project.id])
86 @root_projects = Project::find(:all, :conditions => ["parent_id is null and id <> ?", @project.id])
87 @custom_fields = IssueCustomField.find(:all)
87 @custom_fields = IssueCustomField.find(:all)
88 @issue_category ||= IssueCategory.new
88 @issue_category ||= IssueCategory.new
89 @member ||= @project.members.new
89 @member ||= @project.members.new
90 @roles = Role.find(:all)
90 @roles = Role.find(:all)
91 @users = User.find(:all) - @project.members.find(:all, :include => :user).collect{|m| m.user }
91 @users = User.find(:all) - @project.members.find(:all, :include => :user).collect{|m| m.user }
92 @custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
92 @custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
93 end
93 end
94
94
95 # Edit @project
95 # Edit @project
96 def edit
96 def edit
97 if request.post?
97 if request.post?
98 @project.custom_fields = IssueCustomField.find(@params[:custom_field_ids]) if @params[:custom_field_ids]
98 @project.custom_fields = IssueCustomField.find(params[:custom_field_ids]) if params[:custom_field_ids]
99 if params[:custom_fields]
99 if params[:custom_fields]
100 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
100 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
101 @project.custom_values = @custom_values
101 @project.custom_values = @custom_values
102 end
102 end
103 if params[:repository_enabled]
103 if params[:repository_enabled]
104 case params[:repository_enabled]
104 case params[:repository_enabled]
105 when "0"
105 when "0"
106 @project.repository = nil
106 @project.repository = nil
107 when "1"
107 when "1"
108 @project.repository ||= Repository.new
108 @project.repository ||= Repository.new
109 @project.repository.attributes = params[:repository]
109 @project.repository.attributes = params[:repository]
110 end
110 end
111 end
111 end
112 @project.attributes = params[:project]
112 @project.attributes = params[:project]
113 if @project.save
113 if @project.save
114 flash[:notice] = l(:notice_successful_update)
114 flash[:notice] = l(:notice_successful_update)
115 redirect_to :action => 'settings', :id => @project
115 redirect_to :action => 'settings', :id => @project
116 else
116 else
117 settings
117 settings
118 render :action => 'settings'
118 render :action => 'settings'
119 end
119 end
120 end
120 end
121 end
121 end
122
122
123 # Delete @project
123 # Delete @project
124 def destroy
124 def destroy
125 if request.post? and params[:confirm]
125 if request.post? and params[:confirm]
126 @project.destroy
126 @project.destroy
127 redirect_to :controller => 'admin', :action => 'projects'
127 redirect_to :controller => 'admin', :action => 'projects'
128 end
128 end
129 end
129 end
130
130
131 # Add a new issue category to @project
131 # Add a new issue category to @project
132 def add_issue_category
132 def add_issue_category
133 if request.post?
133 if request.post?
134 @issue_category = @project.issue_categories.build(params[:issue_category])
134 @issue_category = @project.issue_categories.build(params[:issue_category])
135 if @issue_category.save
135 if @issue_category.save
136 flash[:notice] = l(:notice_successful_create)
136 flash[:notice] = l(:notice_successful_create)
137 redirect_to :action => 'settings', :id => @project
137 redirect_to :action => 'settings', :id => @project
138 else
138 else
139 settings
139 settings
140 render :action => 'settings'
140 render :action => 'settings'
141 end
141 end
142 end
142 end
143 end
143 end
144
144
145 # Add a new version to @project
145 # Add a new version to @project
146 def add_version
146 def add_version
147 @version = @project.versions.build(params[:version])
147 @version = @project.versions.build(params[:version])
148 if request.post? and @version.save
148 if request.post? and @version.save
149 flash[:notice] = l(:notice_successful_create)
149 flash[:notice] = l(:notice_successful_create)
150 redirect_to :action => 'settings', :id => @project
150 redirect_to :action => 'settings', :id => @project
151 end
151 end
152 end
152 end
153
153
154 # Add a new member to @project
154 # Add a new member to @project
155 def add_member
155 def add_member
156 @member = @project.members.build(params[:member])
156 @member = @project.members.build(params[:member])
157 if request.post?
157 if request.post?
158 if @member.save
158 if @member.save
159 flash[:notice] = l(:notice_successful_create)
159 flash[:notice] = l(:notice_successful_create)
160 redirect_to :action => 'settings', :id => @project
160 redirect_to :action => 'settings', :id => @project
161 else
161 else
162 settings
162 settings
163 render :action => 'settings'
163 render :action => 'settings'
164 end
164 end
165 end
165 end
166 end
166 end
167
167
168 # Show members list of @project
168 # Show members list of @project
169 def list_members
169 def list_members
170 @members = @project.members
170 @members = @project.members
171 end
171 end
172
172
173 # Add a new document to @project
173 # Add a new document to @project
174 def add_document
174 def add_document
175 @categories = Enumeration::get_values('DCAT')
175 @categories = Enumeration::get_values('DCAT')
176 @document = @project.documents.build(params[:document])
176 @document = @project.documents.build(params[:document])
177 if request.post?
177 if request.post?
178 # Save the attachment
178 # Save the attachment
179 if params[:attachment][:file].size > 0
179 if params[:attachment][:file].size > 0
180 @attachment = @document.attachments.build(params[:attachment])
180 @attachment = @document.attachments.build(params[:attachment])
181 @attachment.author_id = self.logged_in_user.id if self.logged_in_user
181 @attachment.author_id = self.logged_in_user.id if self.logged_in_user
182 end
182 end
183 if @document.save
183 if @document.save
184 flash[:notice] = l(:notice_successful_create)
184 flash[:notice] = l(:notice_successful_create)
185 redirect_to :action => 'list_documents', :id => @project
185 redirect_to :action => 'list_documents', :id => @project
186 end
186 end
187 end
187 end
188 end
188 end
189
189
190 # Show documents list of @project
190 # Show documents list of @project
191 def list_documents
191 def list_documents
192 @documents = @project.documents.find :all, :include => :category
192 @documents = @project.documents.find :all, :include => :category
193 end
193 end
194
194
195 # Add a new issue to @project
195 # Add a new issue to @project
196 def add_issue
196 def add_issue
197 @tracker = Tracker.find(params[:tracker_id])
197 @tracker = Tracker.find(params[:tracker_id])
198 @priorities = Enumeration::get_values('IPRI')
198 @priorities = Enumeration::get_values('IPRI')
199 @issue = Issue.new(:project => @project, :tracker => @tracker)
199 @issue = Issue.new(:project => @project, :tracker => @tracker)
200 if request.get?
200 if request.get?
201 @issue.start_date = Date.today
201 @issue.start_date = Date.today
202 @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) }
202 @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) }
203 else
203 else
204 @issue.attributes = params[:issue]
204 @issue.attributes = params[:issue]
205 @issue.author_id = self.logged_in_user.id if self.logged_in_user
205 @issue.author_id = self.logged_in_user.id if self.logged_in_user
206 # Multiple file upload
206 # Multiple file upload
207 @attachments = []
207 @attachments = []
208 params[:attachments].each { |a|
208 params[:attachments].each { |a|
209 @attachments << Attachment.new(:container => @issue, :file => a, :author => logged_in_user) unless a.size == 0
209 @attachments << Attachment.new(:container => @issue, :file => a, :author => logged_in_user) unless a.size == 0
210 } if params[:attachments] and params[:attachments].is_a? Array
210 } if params[:attachments] and params[:attachments].is_a? Array
211 @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) }
211 @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) }
212 @issue.custom_values = @custom_values
212 @issue.custom_values = @custom_values
213 if @issue.save
213 if @issue.save
214 @attachments.each(&:save)
214 @attachments.each(&:save)
215 flash[:notice] = l(:notice_successful_create)
215 flash[:notice] = l(:notice_successful_create)
216 Mailer.deliver_issue_add(@issue) if Permission.find_by_controller_and_action(@params[:controller], @params[:action]).mail_enabled?
216 Mailer.deliver_issue_add(@issue) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
217 redirect_to :action => 'list_issues', :id => @project
217 redirect_to :action => 'list_issues', :id => @project
218 end
218 end
219 end
219 end
220 end
220 end
221
221
222 # Show filtered/sorted issues list of @project
222 # Show filtered/sorted issues list of @project
223 def list_issues
223 def list_issues
224 sort_init 'issues.id', 'desc'
224 sort_init 'issues.id', 'desc'
225 sort_update
225 sort_update
226
226
227 retrieve_query
227 retrieve_query
228
228
229 @results_per_page_options = [ 15, 25, 50, 100 ]
229 @results_per_page_options = [ 15, 25, 50, 100 ]
230 if params[:per_page] and @results_per_page_options.include? params[:per_page].to_i
230 if params[:per_page] and @results_per_page_options.include? params[:per_page].to_i
231 @results_per_page = params[:per_page].to_i
231 @results_per_page = params[:per_page].to_i
232 session[:results_per_page] = @results_per_page
232 session[:results_per_page] = @results_per_page
233 else
233 else
234 @results_per_page = session[:results_per_page] || 25
234 @results_per_page = session[:results_per_page] || 25
235 end
235 end
236
236
237 if @query.valid?
237 if @query.valid?
238 @issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement)
238 @issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement)
239 @issue_pages = Paginator.new self, @issue_count, @results_per_page, @params['page']
239 @issue_pages = Paginator.new self, @issue_count, @results_per_page, params['page']
240 @issues = Issue.find :all, :order => sort_clause,
240 @issues = Issue.find :all, :order => sort_clause,
241 :include => [ :author, :status, :tracker, :project ],
241 :include => [ :author, :status, :tracker, :project ],
242 :conditions => @query.statement,
242 :conditions => @query.statement,
243 :limit => @issue_pages.items_per_page,
243 :limit => @issue_pages.items_per_page,
244 :offset => @issue_pages.current.offset
244 :offset => @issue_pages.current.offset
245 end
245 end
246 render :layout => false if request.xhr?
246 render :layout => false if request.xhr?
247 end
247 end
248
248
249 # Export filtered/sorted issues list to CSV
249 # Export filtered/sorted issues list to CSV
250 def export_issues_csv
250 def export_issues_csv
251 sort_init 'issues.id', 'desc'
251 sort_init 'issues.id', 'desc'
252 sort_update
252 sort_update
253
253
254 retrieve_query
254 retrieve_query
255 render :action => 'list_issues' and return unless @query.valid?
255 render :action => 'list_issues' and return unless @query.valid?
256
256
257 @issues = Issue.find :all, :order => sort_clause,
257 @issues = Issue.find :all, :order => sort_clause,
258 :include => [ :author, :status, :tracker, :project, :custom_values ],
258 :include => [ :author, :status, :tracker, :project, :custom_values ],
259 :conditions => @query.statement
259 :conditions => @query.statement
260
260
261 ic = Iconv.new('ISO-8859-1', 'UTF-8')
261 ic = Iconv.new('ISO-8859-1', 'UTF-8')
262 export = StringIO.new
262 export = StringIO.new
263 CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
263 CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
264 # csv header fields
264 # csv header fields
265 headers = [ "#", l(:field_status), l(:field_tracker), l(:field_subject), l(:field_author), l(:field_created_on), l(:field_updated_on) ]
265 headers = [ "#", l(:field_status), l(:field_tracker), l(:field_subject), l(:field_author), l(:field_created_on), l(:field_updated_on) ]
266 for custom_field in @project.all_custom_fields
266 for custom_field in @project.all_custom_fields
267 headers << custom_field.name
267 headers << custom_field.name
268 end
268 end
269 csv << headers.collect {|c| ic.iconv(c) }
269 csv << headers.collect {|c| ic.iconv(c) }
270 # csv lines
270 # csv lines
271 @issues.each do |issue|
271 @issues.each do |issue|
272 fields = [issue.id, issue.status.name, issue.tracker.name, issue.subject, issue.author.display_name, l_datetime(issue.created_on), l_datetime(issue.updated_on)]
272 fields = [issue.id, issue.status.name, issue.tracker.name, issue.subject, issue.author.display_name, l_datetime(issue.created_on), l_datetime(issue.updated_on)]
273 for custom_field in @project.all_custom_fields
273 for custom_field in @project.all_custom_fields
274 fields << (show_value issue.custom_value_for(custom_field))
274 fields << (show_value issue.custom_value_for(custom_field))
275 end
275 end
276 csv << fields.collect {|c| ic.iconv(c.to_s) }
276 csv << fields.collect {|c| ic.iconv(c.to_s) }
277 end
277 end
278 end
278 end
279 export.rewind
279 export.rewind
280 send_data(export.read, :type => 'text/csv; header=present', :filename => 'export.csv')
280 send_data(export.read, :type => 'text/csv; header=present', :filename => 'export.csv')
281 end
281 end
282
282
283 # Export filtered/sorted issues to PDF
283 # Export filtered/sorted issues to PDF
284 def export_issues_pdf
284 def export_issues_pdf
285 sort_init 'issues.id', 'desc'
285 sort_init 'issues.id', 'desc'
286 sort_update
286 sort_update
287
287
288 retrieve_query
288 retrieve_query
289 render :action => 'list_issues' and return unless @query.valid?
289 render :action => 'list_issues' and return unless @query.valid?
290
290
291 @issues = Issue.find :all, :order => sort_clause,
291 @issues = Issue.find :all, :order => sort_clause,
292 :include => [ :author, :status, :tracker, :project, :custom_values ],
292 :include => [ :author, :status, :tracker, :project, :custom_values ],
293 :conditions => @query.statement
293 :conditions => @query.statement
294
294
295 @options_for_rfpdf ||= {}
295 @options_for_rfpdf ||= {}
296 @options_for_rfpdf[:file_name] = "export.pdf"
296 @options_for_rfpdf[:file_name] = "export.pdf"
297 render :layout => false
297 render :layout => false
298 end
298 end
299
299
300 def move_issues
300 def move_issues
301 @issues = @project.issues.find(params[:issue_ids]) if params[:issue_ids]
301 @issues = @project.issues.find(params[:issue_ids]) if params[:issue_ids]
302 redirect_to :action => 'list_issues', :id => @project and return unless @issues
302 redirect_to :action => 'list_issues', :id => @project and return unless @issues
303 @projects = []
303 @projects = []
304 # find projects to which the user is allowed to move the issue
304 # find projects to which the user is allowed to move the issue
305 @logged_in_user.memberships.each {|m| @projects << m.project if Permission.allowed_to_role("projects/move_issues", m.role_id)}
305 @logged_in_user.memberships.each {|m| @projects << m.project if Permission.allowed_to_role("projects/move_issues", m.role_id)}
306 # issue can be moved to any tracker
306 # issue can be moved to any tracker
307 @trackers = Tracker.find(:all)
307 @trackers = Tracker.find(:all)
308 if request.post? and params[:new_project_id] and params[:new_tracker_id]
308 if request.post? and params[:new_project_id] and params[:new_tracker_id]
309 new_project = Project.find(params[:new_project_id])
309 new_project = Project.find(params[:new_project_id])
310 new_tracker = Tracker.find(params[:new_tracker_id])
310 new_tracker = Tracker.find(params[:new_tracker_id])
311 @issues.each { |i|
311 @issues.each { |i|
312 # project dependent properties
312 # project dependent properties
313 unless i.project_id == new_project.id
313 unless i.project_id == new_project.id
314 i.category = nil
314 i.category = nil
315 i.fixed_version = nil
315 i.fixed_version = nil
316 end
316 end
317 # move the issue
317 # move the issue
318 i.project = new_project
318 i.project = new_project
319 i.tracker = new_tracker
319 i.tracker = new_tracker
320 i.save
320 i.save
321 }
321 }
322 flash[:notice] = l(:notice_successful_update)
322 flash[:notice] = l(:notice_successful_update)
323 redirect_to :action => 'list_issues', :id => @project
323 redirect_to :action => 'list_issues', :id => @project
324 end
324 end
325 end
325 end
326
326
327 def add_query
327 def add_query
328 @query = Query.new(params[:query])
328 @query = Query.new(params[:query])
329 @query.project = @project
329 @query.project = @project
330 @query.user = logged_in_user
330 @query.user = logged_in_user
331
331
332 params[:fields].each do |field|
332 params[:fields].each do |field|
333 @query.add_filter(field, params[:operators][field], params[:values][field])
333 @query.add_filter(field, params[:operators][field], params[:values][field])
334 end if params[:fields]
334 end if params[:fields]
335
335
336 if request.post? and @query.save
336 if request.post? and @query.save
337 flash[:notice] = l(:notice_successful_create)
337 flash[:notice] = l(:notice_successful_create)
338 redirect_to :controller => 'reports', :action => 'issue_report', :id => @project
338 redirect_to :controller => 'reports', :action => 'issue_report', :id => @project
339 end
339 end
340 render :layout => false if request.xhr?
340 render :layout => false if request.xhr?
341 end
341 end
342
342
343 # Add a news to @project
343 # Add a news to @project
344 def add_news
344 def add_news
345 @news = News.new(:project => @project)
345 @news = News.new(:project => @project)
346 if request.post?
346 if request.post?
347 @news.attributes = params[:news]
347 @news.attributes = params[:news]
348 @news.author_id = self.logged_in_user.id if self.logged_in_user
348 @news.author_id = self.logged_in_user.id if self.logged_in_user
349 if @news.save
349 if @news.save
350 flash[:notice] = l(:notice_successful_create)
350 flash[:notice] = l(:notice_successful_create)
351 redirect_to :action => 'list_news', :id => @project
351 redirect_to :action => 'list_news', :id => @project
352 end
352 end
353 end
353 end
354 end
354 end
355
355
356 # Show news list of @project
356 # Show news list of @project
357 def list_news
357 def list_news
358 @news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "news.created_on DESC"
358 @news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "news.created_on DESC"
359 render :action => "list_news", :layout => false if request.xhr?
359 render :action => "list_news", :layout => false if request.xhr?
360 end
360 end
361
361
362 def add_file
362 def add_file
363 @attachment = Attachment.new(params[:attachment])
363 @attachment = Attachment.new(params[:attachment])
364 if request.post? and params[:attachment][:file].size > 0
364 if request.post? and params[:attachment][:file].size > 0
365 @attachment.container = @project.versions.find_by_id(params[:version_id])
365 @attachment.container = @project.versions.find_by_id(params[:version_id])
366 @attachment.author = logged_in_user
366 @attachment.author = logged_in_user
367 if @attachment.save
367 if @attachment.save
368 flash[:notice] = l(:notice_successful_create)
368 flash[:notice] = l(:notice_successful_create)
369 redirect_to :controller => 'projects', :action => 'list_files', :id => @project
369 redirect_to :controller => 'projects', :action => 'list_files', :id => @project
370 end
370 end
371 end
371 end
372 @versions = @project.versions
372 @versions = @project.versions
373 end
373 end
374
374
375 def list_files
375 def list_files
376 @versions = @project.versions
376 @versions = @project.versions
377 end
377 end
378
378
379 # Show changelog for @project
379 # Show changelog for @project
380 def changelog
380 def changelog
381 @trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true])
381 @trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true])
382 if request.get?
382 if request.get?
383 @selected_tracker_ids = @trackers.collect {|t| t.id.to_s }
383 @selected_tracker_ids = @trackers.collect {|t| t.id.to_s }
384 else
384 else
385 @selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array
385 @selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array
386 end
386 end
387 @selected_tracker_ids ||= []
387 @selected_tracker_ids ||= []
388 @fixed_issues = @project.issues.find(:all,
388 @fixed_issues = @project.issues.find(:all,
389 :include => [ :fixed_version, :status, :tracker ],
389 :include => [ :fixed_version, :status, :tracker ],
390 :conditions => [ "issue_statuses.is_closed=? and issues.tracker_id in (#{@selected_tracker_ids.join(',')}) and issues.fixed_version_id is not null", true],
390 :conditions => [ "issue_statuses.is_closed=? and issues.tracker_id in (#{@selected_tracker_ids.join(',')}) and issues.fixed_version_id is not null", true],
391 :order => "versions.effective_date DESC, issues.id DESC"
391 :order => "versions.effective_date DESC, issues.id DESC"
392 ) unless @selected_tracker_ids.empty?
392 ) unless @selected_tracker_ids.empty?
393 @fixed_issues ||= []
393 @fixed_issues ||= []
394 end
394 end
395
395
396 def activity
396 def activity
397 if params[:year] and params[:year].to_i > 1900
397 if params[:year] and params[:year].to_i > 1900
398 @year = params[:year].to_i
398 @year = params[:year].to_i
399 if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
399 if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
400 @month = params[:month].to_i
400 @month = params[:month].to_i
401 end
401 end
402 end
402 end
403 @year ||= Date.today.year
403 @year ||= Date.today.year
404 @month ||= Date.today.month
404 @month ||= Date.today.month
405
405
406 @date_from = Date.civil(@year, @month, 1)
406 @date_from = Date.civil(@year, @month, 1)
407 @date_to = (@date_from >> 1)-1
407 @date_to = (@date_from >> 1)-1
408
408
409 @events_by_day = {}
409 @events_by_day = {}
410
410
411 unless params[:show_issues] == "0"
411 unless params[:show_issues] == "0"
412 @project.issues.find(:all, :include => [:author, :status], :conditions => ["issues.created_on>=? and issues.created_on<=?", @date_from, @date_to] ).each { |i|
412 @project.issues.find(:all, :include => [:author, :status], :conditions => ["issues.created_on>=? and issues.created_on<=?", @date_from, @date_to] ).each { |i|
413 @events_by_day[i.created_on.to_date] ||= []
413 @events_by_day[i.created_on.to_date] ||= []
414 @events_by_day[i.created_on.to_date] << i
414 @events_by_day[i.created_on.to_date] << i
415 }
415 }
416 @show_issues = 1
416 @show_issues = 1
417 end
417 end
418
418
419 unless params[:show_news] == "0"
419 unless params[:show_news] == "0"
420 @project.news.find(:all, :conditions => ["news.created_on>=? and news.created_on<=?", @date_from, @date_to], :include => :author ).each { |i|
420 @project.news.find(:all, :conditions => ["news.created_on>=? and news.created_on<=?", @date_from, @date_to], :include => :author ).each { |i|
421 @events_by_day[i.created_on.to_date] ||= []
421 @events_by_day[i.created_on.to_date] ||= []
422 @events_by_day[i.created_on.to_date] << i
422 @events_by_day[i.created_on.to_date] << i
423 }
423 }
424 @show_news = 1
424 @show_news = 1
425 end
425 end
426
426
427 unless params[:show_files] == "0"
427 unless params[:show_files] == "0"
428 Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN versions ON versions.id = attachments.container_id", :conditions => ["attachments.container_type='Version' and versions.project_id=? and attachments.created_on>=? and attachments.created_on<=?", @project.id, @date_from, @date_to], :include => :author ).each { |i|
428 Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN versions ON versions.id = attachments.container_id", :conditions => ["attachments.container_type='Version' and versions.project_id=? and attachments.created_on>=? and attachments.created_on<=?", @project.id, @date_from, @date_to], :include => :author ).each { |i|
429 @events_by_day[i.created_on.to_date] ||= []
429 @events_by_day[i.created_on.to_date] ||= []
430 @events_by_day[i.created_on.to_date] << i
430 @events_by_day[i.created_on.to_date] << i
431 }
431 }
432 @show_files = 1
432 @show_files = 1
433 end
433 end
434
434
435 unless params[:show_documents] == "0"
435 unless params[:show_documents] == "0"
436 @project.documents.find(:all, :conditions => ["documents.created_on>=? and documents.created_on<=?", @date_from, @date_to] ).each { |i|
436 @project.documents.find(:all, :conditions => ["documents.created_on>=? and documents.created_on<=?", @date_from, @date_to] ).each { |i|
437 @events_by_day[i.created_on.to_date] ||= []
437 @events_by_day[i.created_on.to_date] ||= []
438 @events_by_day[i.created_on.to_date] << i
438 @events_by_day[i.created_on.to_date] << i
439 }
439 }
440 Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN documents ON documents.id = attachments.container_id", :conditions => ["attachments.container_type='Document' and documents.project_id=? and attachments.created_on>=? and attachments.created_on<=?", @project.id, @date_from, @date_to], :include => :author ).each { |i|
440 Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN documents ON documents.id = attachments.container_id", :conditions => ["attachments.container_type='Document' and documents.project_id=? and attachments.created_on>=? and attachments.created_on<=?", @project.id, @date_from, @date_to], :include => :author ).each { |i|
441 @events_by_day[i.created_on.to_date] ||= []
441 @events_by_day[i.created_on.to_date] ||= []
442 @events_by_day[i.created_on.to_date] << i
442 @events_by_day[i.created_on.to_date] << i
443 }
443 }
444 @show_documents = 1
444 @show_documents = 1
445 end
445 end
446
446
447 render :layout => false if request.xhr?
447 render :layout => false if request.xhr?
448 end
448 end
449
449
450 def calendar
450 def calendar
451 if params[:year] and params[:year].to_i > 1900
451 if params[:year] and params[:year].to_i > 1900
452 @year = params[:year].to_i
452 @year = params[:year].to_i
453 if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
453 if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
454 @month = params[:month].to_i
454 @month = params[:month].to_i
455 end
455 end
456 end
456 end
457 @year ||= Date.today.year
457 @year ||= Date.today.year
458 @month ||= Date.today.month
458 @month ||= Date.today.month
459
459
460 @date_from = Date.civil(@year, @month, 1)
460 @date_from = Date.civil(@year, @month, 1)
461 @date_to = (@date_from >> 1)-1
461 @date_to = (@date_from >> 1)-1
462 # start on monday
462 # start on monday
463 @date_from = @date_from - (@date_from.cwday-1)
463 @date_from = @date_from - (@date_from.cwday-1)
464 # finish on sunday
464 # finish on sunday
465 @date_to = @date_to + (7-@date_to.cwday)
465 @date_to = @date_to + (7-@date_to.cwday)
466
466
467 @issues = @project.issues.find(:all, :include => :tracker, :conditions => ["((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?))", @date_from, @date_to, @date_from, @date_to])
467 @issues = @project.issues.find(:all, :include => :tracker, :conditions => ["((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?))", @date_from, @date_to, @date_from, @date_to])
468 render :layout => false if request.xhr?
468 render :layout => false if request.xhr?
469 end
469 end
470
470
471 def gantt
471 def gantt
472 if params[:year] and params[:year].to_i >0
472 if params[:year] and params[:year].to_i >0
473 @year_from = params[:year].to_i
473 @year_from = params[:year].to_i
474 if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12
474 if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12
475 @month_from = params[:month].to_i
475 @month_from = params[:month].to_i
476 else
476 else
477 @month_from = 1
477 @month_from = 1
478 end
478 end
479 else
479 else
480 @month_from ||= (Date.today << 1).month
480 @month_from ||= (Date.today << 1).month
481 @year_from ||= (Date.today << 1).year
481 @year_from ||= (Date.today << 1).year
482 end
482 end
483
483
484 @zoom = (params[:zoom].to_i > 0 and params[:zoom].to_i < 5) ? params[:zoom].to_i : 2
484 @zoom = (params[:zoom].to_i > 0 and params[:zoom].to_i < 5) ? params[:zoom].to_i : 2
485 @months = (params[:months].to_i > 0 and params[:months].to_i < 25) ? params[:months].to_i : 6
485 @months = (params[:months].to_i > 0 and params[:months].to_i < 25) ? params[:months].to_i : 6
486
486
487 @date_from = Date.civil(@year_from, @month_from, 1)
487 @date_from = Date.civil(@year_from, @month_from, 1)
488 @date_to = (@date_from >> @months) - 1
488 @date_to = (@date_from >> @months) - 1
489 @issues = @project.issues.find(:all, :order => "start_date, due_date", :conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_date<? and due_date>?)) and start_date is not null and due_date is not null)", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to])
489 @issues = @project.issues.find(:all, :order => "start_date, due_date", :conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_date<? and due_date>?)) and start_date is not null and due_date is not null)", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to])
490
490
491 if params[:output]=='pdf'
491 if params[:output]=='pdf'
492 @options_for_rfpdf ||= {}
492 @options_for_rfpdf ||= {}
493 @options_for_rfpdf[:file_name] = "gantt.pdf"
493 @options_for_rfpdf[:file_name] = "gantt.pdf"
494 render :template => "projects/gantt.rfpdf", :layout => false
494 render :template => "projects/gantt.rfpdf", :layout => false
495 else
495 else
496 render :template => "projects/gantt.rhtml"
496 render :template => "projects/gantt.rhtml"
497 end
497 end
498 end
498 end
499
499
500 private
500 private
501 # Find project of id params[:id]
501 # Find project of id params[:id]
502 # if not found, redirect to project list
502 # if not found, redirect to project list
503 # Used as a before_filter
503 # Used as a before_filter
504 def find_project
504 def find_project
505 @project = Project.find(params[:id])
505 @project = Project.find(params[:id])
506 @html_title = @project.name
506 @html_title = @project.name
507 rescue
507 rescue
508 redirect_to :action => 'list'
508 redirect_to :action => 'list'
509 end
509 end
510
510
511 # Retrieve query from session or build a new query
511 # Retrieve query from session or build a new query
512 def retrieve_query
512 def retrieve_query
513 if params[:query_id]
513 if params[:query_id]
514 @query = @project.queries.find(params[:query_id])
514 @query = @project.queries.find(params[:query_id])
515 else
515 else
516 if params[:set_filter] or !session[:query] or session[:query].project_id != @project.id
516 if params[:set_filter] or !session[:query] or session[:query].project_id != @project.id
517 # Give it a name, required to be valid
517 # Give it a name, required to be valid
518 @query = Query.new(:name => "_")
518 @query = Query.new(:name => "_")
519 @query.project = @project
519 @query.project = @project
520 if params[:fields] and params[:fields].is_a? Array
520 if params[:fields] and params[:fields].is_a? Array
521 params[:fields].each do |field|
521 params[:fields].each do |field|
522 @query.add_filter(field, params[:operators][field], params[:values][field])
522 @query.add_filter(field, params[:operators][field], params[:values][field])
523 end
523 end
524 else
524 else
525 @query.available_filters.keys.each do |field|
525 @query.available_filters.keys.each do |field|
526 @query.add_short_filter(field, params[field]) if params[field]
526 @query.add_short_filter(field, params[field]) if params[field]
527 end
527 end
528 end
528 end
529 session[:query] = @query
529 session[:query] = @query
530 else
530 else
531 @query = session[:query]
531 @query = session[:query]
532 end
532 end
533 end
533 end
534 end
534 end
535 end
535 end
@@ -1,84 +1,84
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 class RolesController < ApplicationController
18 class RolesController < ApplicationController
19 layout 'base'
19 layout 'base'
20 before_filter :require_admin
20 before_filter :require_admin
21
21
22 def index
22 def index
23 list
23 list
24 render :action => 'list' unless request.xhr?
24 render :action => 'list' unless request.xhr?
25 end
25 end
26
26
27 def list
27 def list
28 @role_pages, @roles = paginate :roles, :per_page => 10
28 @role_pages, @roles = paginate :roles, :per_page => 10
29 render :action => "list", :layout => false if request.xhr?
29 render :action => "list", :layout => false if request.xhr?
30 end
30 end
31
31
32 def new
32 def new
33 @role = Role.new(params[:role])
33 @role = Role.new(params[:role])
34 if request.post?
34 if request.post?
35 @role.permissions = Permission.find(@params[:permission_ids]) if @params[:permission_ids]
35 @role.permissions = Permission.find(params[:permission_ids]) if params[:permission_ids]
36 if @role.save
36 if @role.save
37 flash[:notice] = l(:notice_successful_create)
37 flash[:notice] = l(:notice_successful_create)
38 redirect_to :action => 'list'
38 redirect_to :action => 'list'
39 end
39 end
40 end
40 end
41 @permissions = Permission.find(:all, :conditions => ["is_public=?", false], :order => 'sort ASC')
41 @permissions = Permission.find(:all, :conditions => ["is_public=?", false], :order => 'sort ASC')
42 end
42 end
43
43
44 def edit
44 def edit
45 @role = Role.find(params[:id])
45 @role = Role.find(params[:id])
46 if request.post? and @role.update_attributes(params[:role])
46 if request.post? and @role.update_attributes(params[:role])
47 @role.permissions = Permission.find(@params[:permission_ids] || [])
47 @role.permissions = Permission.find(params[:permission_ids] || [])
48 Permission.allowed_to_role_expired
48 Permission.allowed_to_role_expired
49 flash[:notice] = l(:notice_successful_update)
49 flash[:notice] = l(:notice_successful_update)
50 redirect_to :action => 'list'
50 redirect_to :action => 'list'
51 end
51 end
52 @permissions = Permission.find(:all, :conditions => ["is_public=?", false], :order => 'sort ASC')
52 @permissions = Permission.find(:all, :conditions => ["is_public=?", false], :order => 'sort ASC')
53 end
53 end
54
54
55 def destroy
55 def destroy
56 @role = Role.find(params[:id])
56 @role = Role.find(params[:id])
57 unless @role.members.empty?
57 unless @role.members.empty?
58 flash[:notice] = 'Some members have this role. Can\'t delete it.'
58 flash[:notice] = 'Some members have this role. Can\'t delete it.'
59 else
59 else
60 @role.destroy
60 @role.destroy
61 end
61 end
62 redirect_to :action => 'list'
62 redirect_to :action => 'list'
63 end
63 end
64
64
65 def workflow
65 def workflow
66 @role = Role.find_by_id(params[:role_id])
66 @role = Role.find_by_id(params[:role_id])
67 @tracker = Tracker.find_by_id(params[:tracker_id])
67 @tracker = Tracker.find_by_id(params[:tracker_id])
68
68
69 if request.post?
69 if request.post?
70 Workflow.destroy_all( ["role_id=? and tracker_id=?", @role.id, @tracker.id])
70 Workflow.destroy_all( ["role_id=? and tracker_id=?", @role.id, @tracker.id])
71 (params[:issue_status] || []).each { |old, news|
71 (params[:issue_status] || []).each { |old, news|
72 news.each { |new|
72 news.each { |new|
73 @role.workflows.build(:tracker_id => @tracker.id, :old_status_id => old, :new_status_id => new)
73 @role.workflows.build(:tracker_id => @tracker.id, :old_status_id => old, :new_status_id => new)
74 }
74 }
75 }
75 }
76 if @role.save
76 if @role.save
77 flash[:notice] = l(:notice_successful_update)
77 flash[:notice] = l(:notice_successful_update)
78 end
78 end
79 end
79 end
80 @roles = Role.find :all
80 @roles = Role.find :all
81 @trackers = Tracker.find :all
81 @trackers = Tracker.find :all
82 @statuses = IssueStatus.find(:all, :include => :workflows)
82 @statuses = IssueStatus.find(:all, :include => :workflows)
83 end
83 end
84 end
84 end
@@ -1,113 +1,113
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 class UsersController < ApplicationController
18 class UsersController < ApplicationController
19 layout 'base'
19 layout 'base'
20 before_filter :require_admin
20 before_filter :require_admin
21
21
22 helper :sort
22 helper :sort
23 include SortHelper
23 include SortHelper
24 helper :custom_fields
24 helper :custom_fields
25 include CustomFieldsHelper
25 include CustomFieldsHelper
26
26
27 def index
27 def index
28 list
28 list
29 render :action => 'list' unless request.xhr?
29 render :action => 'list' unless request.xhr?
30 end
30 end
31
31
32 def list
32 def list
33 sort_init 'login', 'asc'
33 sort_init 'login', 'asc'
34 sort_update
34 sort_update
35 @user_count = User.count
35 @user_count = User.count
36 @user_pages = Paginator.new self, @user_count,
36 @user_pages = Paginator.new self, @user_count,
37 15,
37 15,
38 @params['page']
38 params['page']
39 @users = User.find :all,:order => sort_clause,
39 @users = User.find :all,:order => sort_clause,
40 :limit => @user_pages.items_per_page,
40 :limit => @user_pages.items_per_page,
41 :offset => @user_pages.current.offset
41 :offset => @user_pages.current.offset
42
42
43 render :action => "list", :layout => false if request.xhr?
43 render :action => "list", :layout => false if request.xhr?
44 end
44 end
45
45
46 def add
46 def add
47 if request.get?
47 if request.get?
48 @user = User.new(:language => $RDM_DEFAULT_LANG)
48 @user = User.new(:language => $RDM_DEFAULT_LANG)
49 @custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user) }
49 @custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user) }
50 else
50 else
51 @user = User.new(params[:user])
51 @user = User.new(params[:user])
52 @user.admin = params[:user][:admin] || false
52 @user.admin = params[:user][:admin] || false
53 @user.login = params[:user][:login]
53 @user.login = params[:user][:login]
54 @user.password, @user.password_confirmation = params[:password], params[:password_confirmation] unless @user.auth_source_id
54 @user.password, @user.password_confirmation = params[:password], params[:password_confirmation] unless @user.auth_source_id
55 @custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user, :value => params["custom_fields"][x.id.to_s]) }
55 @custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user, :value => params["custom_fields"][x.id.to_s]) }
56 @user.custom_values = @custom_values
56 @user.custom_values = @custom_values
57 if @user.save
57 if @user.save
58 flash[:notice] = l(:notice_successful_create)
58 flash[:notice] = l(:notice_successful_create)
59 redirect_to :action => 'list'
59 redirect_to :action => 'list'
60 end
60 end
61 end
61 end
62 @auth_sources = AuthSource.find(:all)
62 @auth_sources = AuthSource.find(:all)
63 end
63 end
64
64
65 def edit
65 def edit
66 @user = User.find(params[:id])
66 @user = User.find(params[:id])
67 if request.get?
67 if request.get?
68 @custom_values = UserCustomField.find(:all).collect { |x| @user.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
68 @custom_values = UserCustomField.find(:all).collect { |x| @user.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
69 else
69 else
70 @user.admin = params[:user][:admin] if params[:user][:admin]
70 @user.admin = params[:user][:admin] if params[:user][:admin]
71 @user.login = params[:user][:login] if params[:user][:login]
71 @user.login = params[:user][:login] if params[:user][:login]
72 @user.password, @user.password_confirmation = params[:password], params[:password_confirmation] unless params[:password].nil? or params[:password].empty? or @user.auth_source_id
72 @user.password, @user.password_confirmation = params[:password], params[:password_confirmation] unless params[:password].nil? or params[:password].empty? or @user.auth_source_id
73 if params[:custom_fields]
73 if params[:custom_fields]
74 @custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user, :value => params["custom_fields"][x.id.to_s]) }
74 @custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user, :value => params["custom_fields"][x.id.to_s]) }
75 @user.custom_values = @custom_values
75 @user.custom_values = @custom_values
76 end
76 end
77 if @user.update_attributes(params[:user])
77 if @user.update_attributes(params[:user])
78 flash[:notice] = l(:notice_successful_update)
78 flash[:notice] = l(:notice_successful_update)
79 redirect_to :action => 'list'
79 redirect_to :action => 'list'
80 end
80 end
81 end
81 end
82 @auth_sources = AuthSource.find(:all)
82 @auth_sources = AuthSource.find(:all)
83 @roles = Role.find :all
83 @roles = Role.find :all
84 @projects = Project.find(:all) - @user.projects
84 @projects = Project.find(:all) - @user.projects
85 @membership ||= Member.new
85 @membership ||= Member.new
86 end
86 end
87
87
88 def edit_membership
88 def edit_membership
89 @user = User.find(params[:id])
89 @user = User.find(params[:id])
90 @membership = params[:membership_id] ? Member.find(params[:membership_id]) : Member.new(:user => @user)
90 @membership = params[:membership_id] ? Member.find(params[:membership_id]) : Member.new(:user => @user)
91 @membership.attributes = params[:membership]
91 @membership.attributes = params[:membership]
92 if request.post? and @membership.save
92 if request.post? and @membership.save
93 flash[:notice] = l(:notice_successful_update)
93 flash[:notice] = l(:notice_successful_update)
94 end
94 end
95 redirect_to :action => 'edit', :id => @user and return
95 redirect_to :action => 'edit', :id => @user and return
96 end
96 end
97
97
98 def destroy_membership
98 def destroy_membership
99 @user = User.find(params[:id])
99 @user = User.find(params[:id])
100 if request.post? and Member.find(params[:membership_id]).destroy
100 if request.post? and Member.find(params[:membership_id]).destroy
101 flash[:notice] = l(:notice_successful_update)
101 flash[:notice] = l(:notice_successful_update)
102 end
102 end
103 redirect_to :action => 'edit', :id => @user and return
103 redirect_to :action => 'edit', :id => @user and return
104 end
104 end
105
105
106 def destroy
106 def destroy
107 User.find(params[:id]).destroy
107 User.find(params[:id]).destroy
108 redirect_to :action => 'list'
108 redirect_to :action => 'list'
109 rescue
109 rescue
110 flash[:notice] = "Unable to delete user"
110 flash[:notice] = "Unable to delete user"
111 redirect_to :action => 'list'
111 redirect_to :action => 'list'
112 end
112 end
113 end
113 end
@@ -1,184 +1,184
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 module ApplicationHelper
18 module ApplicationHelper
19
19
20 # Return current logged in user or nil
20 # Return current logged in user or nil
21 def loggedin?
21 def loggedin?
22 @logged_in_user
22 @logged_in_user
23 end
23 end
24
24
25 # Return true if user is logged in and is admin, otherwise false
25 # Return true if user is logged in and is admin, otherwise false
26 def admin_loggedin?
26 def admin_loggedin?
27 @logged_in_user and @logged_in_user.admin?
27 @logged_in_user and @logged_in_user.admin?
28 end
28 end
29
29
30 # Return true if user is authorized for controller/action, otherwise false
30 # Return true if user is authorized for controller/action, otherwise false
31 def authorize_for(controller, action)
31 def authorize_for(controller, action)
32 # check if action is allowed on public projects
32 # check if action is allowed on public projects
33 if @project.is_public? and Permission.allowed_to_public "%s/%s" % [ controller, action ]
33 if @project.is_public? and Permission.allowed_to_public "%s/%s" % [ controller, action ]
34 return true
34 return true
35 end
35 end
36 # check if user is authorized
36 # check if user is authorized
37 if @logged_in_user and (@logged_in_user.admin? or Permission.allowed_to_role( "%s/%s" % [ controller, action ], @logged_in_user.role_for_project(@project.id) ) )
37 if @logged_in_user and (@logged_in_user.admin? or Permission.allowed_to_role( "%s/%s" % [ controller, action ], @logged_in_user.role_for_project(@project.id) ) )
38 return true
38 return true
39 end
39 end
40 return false
40 return false
41 end
41 end
42
42
43 # Display a link if user is authorized
43 # Display a link if user is authorized
44 def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference)
44 def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference)
45 link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller], options[:action])
45 link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller], options[:action])
46 end
46 end
47
47
48 # Display a link to user's account page
48 # Display a link to user's account page
49 def link_to_user(user)
49 def link_to_user(user)
50 link_to user.display_name, :controller => 'account', :action => 'show', :id => user
50 link_to user.display_name, :controller => 'account', :action => 'show', :id => user
51 end
51 end
52
52
53 def format_date(date)
53 def format_date(date)
54 l_date(date) if date
54 l_date(date) if date
55 end
55 end
56
56
57 def format_time(time)
57 def format_time(time)
58 l_datetime(time) if time
58 l_datetime(time) if time
59 end
59 end
60
60
61 def day_name(day)
61 def day_name(day)
62 l(:general_day_names).split(',')[day-1]
62 l(:general_day_names).split(',')[day-1]
63 end
63 end
64
64
65 def month_name(month)
65 def month_name(month)
66 l(:actionview_datehelper_select_month_names).split(',')[month-1]
66 l(:actionview_datehelper_select_month_names).split(',')[month-1]
67 end
67 end
68
68
69 def pagination_links_full(paginator, options={}, html_options={})
69 def pagination_links_full(paginator, options={}, html_options={})
70 html = ''
70 html = ''
71 html << link_to_remote(('&#171; ' + l(:label_previous)),
71 html << link_to_remote(('&#171; ' + l(:label_previous)),
72 {:update => "content", :url => { :page => paginator.current.previous }},
72 {:update => "content", :url => { :page => paginator.current.previous }},
73 {:href => url_for(:action => 'list', :params => @params.merge({:page => paginator.current.previous}))}) + ' ' if paginator.current.previous
73 {:href => url_for(:action => 'list', :params => params.merge({:page => paginator.current.previous}))}) + ' ' if paginator.current.previous
74
74
75 html << (pagination_links_each(paginator, options) do |n|
75 html << (pagination_links_each(paginator, options) do |n|
76 link_to_remote(n.to_s,
76 link_to_remote(n.to_s,
77 {:url => {:action => 'list', :params => @params.merge({:page => n})}, :update => 'content'},
77 {:url => {:action => 'list', :params => params.merge({:page => n})}, :update => 'content'},
78 {:href => url_for(:action => 'list', :params => @params.merge({:page => n}))})
78 {:href => url_for(:action => 'list', :params => params.merge({:page => n}))})
79 end || '')
79 end || '')
80
80
81 html << ' ' + link_to_remote((l(:label_next) + ' &#187;'),
81 html << ' ' + link_to_remote((l(:label_next) + ' &#187;'),
82 {:update => "content", :url => { :page => paginator.current.next }},
82 {:update => "content", :url => { :page => paginator.current.next }},
83 {:href => url_for(:action => 'list', :params => @params.merge({:page => paginator.current.next}))}) if paginator.current.next
83 {:href => url_for(:action => 'list', :params => params.merge({:page => paginator.current.next}))}) if paginator.current.next
84 html
84 html
85 end
85 end
86
86
87 def textilizable(text)
87 def textilizable(text)
88 $RDM_TEXTILE_DISABLED ? simple_format(auto_link(h(text))) : RedCloth.new(h(text)).to_html
88 $RDM_TEXTILE_DISABLED ? simple_format(auto_link(h(text))) : RedCloth.new(h(text)).to_html
89 end
89 end
90
90
91 def error_messages_for(object_name, options = {})
91 def error_messages_for(object_name, options = {})
92 options = options.symbolize_keys
92 options = options.symbolize_keys
93 object = instance_variable_get("@#{object_name}")
93 object = instance_variable_get("@#{object_name}")
94 if object && !object.errors.empty?
94 if object && !object.errors.empty?
95 # build full_messages here with controller current language
95 # build full_messages here with controller current language
96 full_messages = []
96 full_messages = []
97 object.errors.each do |attr, msg|
97 object.errors.each do |attr, msg|
98 next if msg.nil?
98 next if msg.nil?
99 if attr == "base"
99 if attr == "base"
100 full_messages << l(msg)
100 full_messages << l(msg)
101 else
101 else
102 full_messages << "&#171; " + (l_has_string?("field_" + attr) ? l("field_" + attr) : object.class.human_attribute_name(attr)) + " &#187; " + l(msg) unless attr == "custom_values"
102 full_messages << "&#171; " + (l_has_string?("field_" + attr) ? l("field_" + attr) : object.class.human_attribute_name(attr)) + " &#187; " + l(msg) unless attr == "custom_values"
103 end
103 end
104 end
104 end
105 # retrieve custom values error messages
105 # retrieve custom values error messages
106 if object.errors[:custom_values]
106 if object.errors[:custom_values]
107 object.custom_values.each do |v|
107 object.custom_values.each do |v|
108 v.errors.each do |attr, msg|
108 v.errors.each do |attr, msg|
109 next if msg.nil?
109 next if msg.nil?
110 full_messages << "&#171; " + v.custom_field.name + " &#187; " + l(msg)
110 full_messages << "&#171; " + v.custom_field.name + " &#187; " + l(msg)
111 end
111 end
112 end
112 end
113 end
113 end
114 content_tag("div",
114 content_tag("div",
115 content_tag(
115 content_tag(
116 options[:header_tag] || "h2", lwr(:gui_validation_error, full_messages.length) + " :"
116 options[:header_tag] || "h2", lwr(:gui_validation_error, full_messages.length) + " :"
117 ) +
117 ) +
118 content_tag("ul", full_messages.collect { |msg| content_tag("li", msg) }),
118 content_tag("ul", full_messages.collect { |msg| content_tag("li", msg) }),
119 "id" => options[:id] || "errorExplanation", "class" => options[:class] || "errorExplanation"
119 "id" => options[:id] || "errorExplanation", "class" => options[:class] || "errorExplanation"
120 )
120 )
121 else
121 else
122 ""
122 ""
123 end
123 end
124 end
124 end
125
125
126 def lang_options_for_select
126 def lang_options_for_select
127 (GLoc.valid_languages.sort {|x,y| x.to_s <=> y.to_s }).collect {|lang| [ l_lang_name(lang.to_s, lang), lang.to_s]}
127 (GLoc.valid_languages.sort {|x,y| x.to_s <=> y.to_s }).collect {|lang| [ l_lang_name(lang.to_s, lang), lang.to_s]}
128 end
128 end
129
129
130 def label_tag_for(name, option_tags = nil, options = {})
130 def label_tag_for(name, option_tags = nil, options = {})
131 label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "")
131 label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "")
132 content_tag("label", label_text)
132 content_tag("label", label_text)
133 end
133 end
134
134
135 def labelled_tabular_form_for(name, object, options, &proc)
135 def labelled_tabular_form_for(name, object, options, &proc)
136 options[:html] ||= {}
136 options[:html] ||= {}
137 options[:html].store :class, "tabular"
137 options[:html].store :class, "tabular"
138 form_for(name, object, options.merge({ :builder => TabularFormBuilder, :lang => current_language}), &proc)
138 form_for(name, object, options.merge({ :builder => TabularFormBuilder, :lang => current_language}), &proc)
139 end
139 end
140
140
141 def check_all_links(form_name)
141 def check_all_links(form_name)
142 link_to_function(l(:button_check_all), "checkAll('#{form_name}', true)") +
142 link_to_function(l(:button_check_all), "checkAll('#{form_name}', true)") +
143 " | " +
143 " | " +
144 link_to_function(l(:button_uncheck_all), "checkAll('#{form_name}', false)")
144 link_to_function(l(:button_uncheck_all), "checkAll('#{form_name}', false)")
145 end
145 end
146
146
147 def calendar_for(field_id)
147 def calendar_for(field_id)
148 image_tag("calendar", {:id => "#{field_id}_trigger",:class => "calendar-trigger"}) +
148 image_tag("calendar", {:id => "#{field_id}_trigger",:class => "calendar-trigger"}) +
149 javascript_tag("Calendar.setup({inputField : '#{field_id}', ifFormat : '%Y-%m-%d', button : '#{field_id}_trigger' });")
149 javascript_tag("Calendar.setup({inputField : '#{field_id}', ifFormat : '%Y-%m-%d', button : '#{field_id}_trigger' });")
150 end
150 end
151 end
151 end
152
152
153 class TabularFormBuilder < ActionView::Helpers::FormBuilder
153 class TabularFormBuilder < ActionView::Helpers::FormBuilder
154 include GLoc
154 include GLoc
155
155
156 def initialize(object_name, object, template, options, proc)
156 def initialize(object_name, object, template, options, proc)
157 set_language_if_valid options.delete(:lang)
157 set_language_if_valid options.delete(:lang)
158 @object_name, @object, @template, @options, @proc = object_name, object, template, options, proc
158 @object_name, @object, @template, @options, @proc = object_name, object, template, options, proc
159 end
159 end
160
160
161 (field_helpers - %w(radio_button hidden_field) + %w(date_select)).each do |selector|
161 (field_helpers - %w(radio_button hidden_field) + %w(date_select)).each do |selector|
162 src = <<-END_SRC
162 src = <<-END_SRC
163 def #{selector}(field, options = {})
163 def #{selector}(field, options = {})
164 return super if options.delete :no_label
164 return super if options.delete :no_label
165 label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "")
165 label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "")
166 label = @template.content_tag("label", label_text,
166 label = @template.content_tag("label", label_text,
167 :class => (@object && @object.errors[field] ? "error" : nil),
167 :class => (@object && @object.errors[field] ? "error" : nil),
168 :for => (@object_name.to_s + "_" + field.to_s))
168 :for => (@object_name.to_s + "_" + field.to_s))
169 label + super
169 label + super
170 end
170 end
171 END_SRC
171 END_SRC
172 class_eval src, __FILE__, __LINE__
172 class_eval src, __FILE__, __LINE__
173 end
173 end
174
174
175 def select(field, choices, options = {}, html_options = {})
175 def select(field, choices, options = {}, html_options = {})
176 label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "")
176 label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "")
177 label = @template.content_tag("label", label_text,
177 label = @template.content_tag("label", label_text,
178 :class => (@object && @object.errors[field] ? "error" : nil),
178 :class => (@object && @object.errors[field] ? "error" : nil),
179 :for => (@object_name.to_s + "_" + field.to_s))
179 :for => (@object_name.to_s + "_" + field.to_s))
180 label + super
180 label + super
181 end
181 end
182
182
183 end
183 end
184
184
@@ -1,160 +1,160
1 # Helpers to sort tables using clickable column headers.
1 # Helpers to sort tables using clickable column headers.
2 #
2 #
3 # Author: Stuart Rackham <srackham@methods.co.nz>, March 2005.
3 # Author: Stuart Rackham <srackham@methods.co.nz>, March 2005.
4 # License: This source code is released under the MIT license.
4 # License: This source code is released under the MIT license.
5 #
5 #
6 # - Consecutive clicks toggle the column's sort order.
6 # - Consecutive clicks toggle the column's sort order.
7 # - Sort state is maintained by a session hash entry.
7 # - Sort state is maintained by a session hash entry.
8 # - Icon image identifies sort column and state.
8 # - Icon image identifies sort column and state.
9 # - Typically used in conjunction with the Pagination module.
9 # - Typically used in conjunction with the Pagination module.
10 #
10 #
11 # Example code snippets:
11 # Example code snippets:
12 #
12 #
13 # Controller:
13 # Controller:
14 #
14 #
15 # helper :sort
15 # helper :sort
16 # include SortHelper
16 # include SortHelper
17 #
17 #
18 # def list
18 # def list
19 # sort_init 'last_name'
19 # sort_init 'last_name'
20 # sort_update
20 # sort_update
21 # @items = Contact.find_all nil, sort_clause
21 # @items = Contact.find_all nil, sort_clause
22 # end
22 # end
23 #
23 #
24 # Controller (using Pagination module):
24 # Controller (using Pagination module):
25 #
25 #
26 # helper :sort
26 # helper :sort
27 # include SortHelper
27 # include SortHelper
28 #
28 #
29 # def list
29 # def list
30 # sort_init 'last_name'
30 # sort_init 'last_name'
31 # sort_update
31 # sort_update
32 # @contact_pages, @items = paginate :contacts,
32 # @contact_pages, @items = paginate :contacts,
33 # :order_by => sort_clause,
33 # :order_by => sort_clause,
34 # :per_page => 10
34 # :per_page => 10
35 # end
35 # end
36 #
36 #
37 # View (table header in list.rhtml):
37 # View (table header in list.rhtml):
38 #
38 #
39 # <thead>
39 # <thead>
40 # <tr>
40 # <tr>
41 # <%= sort_header_tag('id', :title => 'Sort by contact ID') %>
41 # <%= sort_header_tag('id', :title => 'Sort by contact ID') %>
42 # <%= sort_header_tag('last_name', :caption => 'Name') %>
42 # <%= sort_header_tag('last_name', :caption => 'Name') %>
43 # <%= sort_header_tag('phone') %>
43 # <%= sort_header_tag('phone') %>
44 # <%= sort_header_tag('address', :width => 200) %>
44 # <%= sort_header_tag('address', :width => 200) %>
45 # </tr>
45 # </tr>
46 # </thead>
46 # </thead>
47 #
47 #
48 # - The ascending and descending sort icon images are sort_asc.png and
48 # - The ascending and descending sort icon images are sort_asc.png and
49 # sort_desc.png and reside in the application's images directory.
49 # sort_desc.png and reside in the application's images directory.
50 # - Introduces instance variables: @sort_name, @sort_default.
50 # - Introduces instance variables: @sort_name, @sort_default.
51 # - Introduces params :sort_key and :sort_order.
51 # - Introduces params :sort_key and :sort_order.
52 #
52 #
53 module SortHelper
53 module SortHelper
54
54
55 # Initializes the default sort column (default_key) and sort order
55 # Initializes the default sort column (default_key) and sort order
56 # (default_order).
56 # (default_order).
57 #
57 #
58 # - default_key is a column attribute name.
58 # - default_key is a column attribute name.
59 # - default_order is 'asc' or 'desc'.
59 # - default_order is 'asc' or 'desc'.
60 # - name is the name of the session hash entry that stores the sort state,
60 # - name is the name of the session hash entry that stores the sort state,
61 # defaults to '<controller_name>_sort'.
61 # defaults to '<controller_name>_sort'.
62 #
62 #
63 def sort_init(default_key, default_order='asc', name=nil)
63 def sort_init(default_key, default_order='asc', name=nil)
64 @sort_name = name || @params[:controller] + @params[:action] + '_sort'
64 @sort_name = name || params[:controller] + params[:action] + '_sort'
65 @sort_default = {:key => default_key, :order => default_order}
65 @sort_default = {:key => default_key, :order => default_order}
66 end
66 end
67
67
68 # Updates the sort state. Call this in the controller prior to calling
68 # Updates the sort state. Call this in the controller prior to calling
69 # sort_clause.
69 # sort_clause.
70 #
70 #
71 def sort_update()
71 def sort_update()
72 if @params[:sort_key]
72 if params[:sort_key]
73 sort = {:key => @params[:sort_key], :order => @params[:sort_order]}
73 sort = {:key => params[:sort_key], :order => params[:sort_order]}
74 elsif @session[@sort_name]
74 elsif session[@sort_name]
75 sort = @session[@sort_name] # Previous sort.
75 sort = session[@sort_name] # Previous sort.
76 else
76 else
77 sort = @sort_default
77 sort = @sort_default
78 end
78 end
79 @session[@sort_name] = sort
79 session[@sort_name] = sort
80 end
80 end
81
81
82 # Returns an SQL sort clause corresponding to the current sort state.
82 # Returns an SQL sort clause corresponding to the current sort state.
83 # Use this to sort the controller's table items collection.
83 # Use this to sort the controller's table items collection.
84 #
84 #
85 def sort_clause()
85 def sort_clause()
86 @session[@sort_name][:key] + ' ' + @session[@sort_name][:order]
86 session[@sort_name][:key] + ' ' + session[@sort_name][:order]
87 end
87 end
88
88
89 # Returns a link which sorts by the named column.
89 # Returns a link which sorts by the named column.
90 #
90 #
91 # - column is the name of an attribute in the sorted record collection.
91 # - column is the name of an attribute in the sorted record collection.
92 # - The optional caption explicitly specifies the displayed link text.
92 # - The optional caption explicitly specifies the displayed link text.
93 # - A sort icon image is positioned to the right of the sort link.
93 # - A sort icon image is positioned to the right of the sort link.
94 #
94 #
95 def sort_link(column, caption=nil)
95 def sort_link(column, caption=nil)
96 key, order = @session[@sort_name][:key], @session[@sort_name][:order]
96 key, order = session[@sort_name][:key], session[@sort_name][:order]
97 if key == column
97 if key == column
98 if order.downcase == 'asc'
98 if order.downcase == 'asc'
99 icon = 'sort_asc'
99 icon = 'sort_asc'
100 order = 'desc'
100 order = 'desc'
101 else
101 else
102 icon = 'sort_desc'
102 icon = 'sort_desc'
103 order = 'asc'
103 order = 'asc'
104 end
104 end
105 else
105 else
106 icon = nil
106 icon = nil
107 order = 'desc' # changed for desc order by default
107 order = 'desc' # changed for desc order by default
108 end
108 end
109 caption = titleize(Inflector::humanize(column)) unless caption
109 caption = titleize(Inflector::humanize(column)) unless caption
110 params = {:params => {:sort_key => column, :sort_order => order}}
110 params = {:params => {:sort_key => column, :sort_order => order}}
111 link_to_remote(caption,
111 link_to_remote(caption,
112 {:update => "content", :url => { :sort_key => column, :sort_order => order}},
112 {:update => "content", :url => { :sort_key => column, :sort_order => order}},
113 {:href => url_for(:params => { :sort_key => column, :sort_order => order})}) +
113 {:href => url_for(:params => { :sort_key => column, :sort_order => order})}) +
114 (icon ? nbsp(2) + image_tag(icon) : '')
114 (icon ? nbsp(2) + image_tag(icon) : '')
115 end
115 end
116
116
117 # Returns a table header <th> tag with a sort link for the named column
117 # Returns a table header <th> tag with a sort link for the named column
118 # attribute.
118 # attribute.
119 #
119 #
120 # Options:
120 # Options:
121 # :caption The displayed link name (defaults to titleized column name).
121 # :caption The displayed link name (defaults to titleized column name).
122 # :title The tag's 'title' attribute (defaults to 'Sort by :caption').
122 # :title The tag's 'title' attribute (defaults to 'Sort by :caption').
123 #
123 #
124 # Other options hash entries generate additional table header tag attributes.
124 # Other options hash entries generate additional table header tag attributes.
125 #
125 #
126 # Example:
126 # Example:
127 #
127 #
128 # <%= sort_header_tag('id', :title => 'Sort by contact ID', :width => 40) %>
128 # <%= sort_header_tag('id', :title => 'Sort by contact ID', :width => 40) %>
129 #
129 #
130 # Renders:
130 # Renders:
131 #
131 #
132 # <th title="Sort by contact ID" width="40">
132 # <th title="Sort by contact ID" width="40">
133 # <a href="/contact/list?sort_order=desc&amp;sort_key=id">Id</a>
133 # <a href="/contact/list?sort_order=desc&amp;sort_key=id">Id</a>
134 # &nbsp;&nbsp;<img alt="Sort_asc" src="/images/sort_asc.png" />
134 # &nbsp;&nbsp;<img alt="Sort_asc" src="/images/sort_asc.png" />
135 # </th>
135 # </th>
136 #
136 #
137 def sort_header_tag(column, options = {})
137 def sort_header_tag(column, options = {})
138 if options[:caption]
138 if options[:caption]
139 caption = options[:caption]
139 caption = options[:caption]
140 options.delete(:caption)
140 options.delete(:caption)
141 else
141 else
142 caption = titleize(Inflector::humanize(column))
142 caption = titleize(Inflector::humanize(column))
143 end
143 end
144 options[:title]= "Sort by #{caption}" unless options[:title]
144 options[:title]= "Sort by #{caption}" unless options[:title]
145 content_tag('th', sort_link(column, caption), options)
145 content_tag('th', sort_link(column, caption), options)
146 end
146 end
147
147
148 private
148 private
149
149
150 # Return n non-breaking spaces.
150 # Return n non-breaking spaces.
151 def nbsp(n)
151 def nbsp(n)
152 '&nbsp;' * n
152 '&nbsp;' * n
153 end
153 end
154
154
155 # Return capitalized title.
155 # Return capitalized title.
156 def titleize(title)
156 def titleize(title)
157 title.split.map {|w| w.capitalize }.join(' ')
157 title.split.map {|w| w.capitalize }.join(' ')
158 end
158 end
159
159
160 end
160 end
@@ -1,21 +1,21
1 <h2><%=l(:label_enumerations)%></h2>
1 <h2><%=l(:label_enumerations)%></h2>
2
2
3 <% Enumeration::OPTIONS.each do |option, name| %>
3 <% Enumeration::OPTIONS.each do |option, name| %>
4
4
5 <% if @params[:opt]==option %>
5 <% if params[:opt]==option %>
6
6
7 <p><%= image_tag 'dir_open' %> <b><%= l(name) %></b></p>
7 <p><%= image_tag 'dir_open' %> <b><%= l(name) %></b></p>
8 <ul>
8 <ul>
9 <% for value in Enumeration.find(:all, :conditions => ["opt = ?", option]) %>
9 <% for value in Enumeration.find(:all, :conditions => ["opt = ?", option]) %>
10 <li><%= link_to value.name, :action => 'edit', :id => value %></li>
10 <li><%= link_to value.name, :action => 'edit', :id => value %></li>
11 <% end %>
11 <% end %>
12 </ul>
12 </ul>
13 <ul>
13 <ul>
14 <li><%= link_to ('&#187; ' + l(:label_new)), :action => 'new', :opt => option %></li>
14 <li><%= link_to ('&#187; ' + l(:label_new)), :action => 'new', :opt => option %></li>
15 </ul>
15 </ul>
16
16
17 <% else %>
17 <% else %>
18 <p><%= image_tag 'dir' %> <%= link_to l(name), :opt => option %></p>
18 <p><%= image_tag 'dir' %> <%= link_to l(name), :opt => option %></p>
19 <% end %>
19 <% end %>
20
20
21 <% end %> No newline at end of file
21 <% end %>
@@ -1,145 +1,145
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
3 <head>
3 <head>
4 <title><%= $RDM_HEADER_TITLE + (@html_title ? ": #{@html_title}" : "") %></title>
4 <title><%= $RDM_HEADER_TITLE + (@html_title ? ": #{@html_title}" : "") %></title>
5 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
5 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
6 <meta name="description" content="redMine" />
6 <meta name="description" content="redMine" />
7 <meta name="keywords" content="issue,bug,tracker" />
7 <meta name="keywords" content="issue,bug,tracker" />
8 <%= stylesheet_link_tag "application" %>
8 <%= stylesheet_link_tag "application" %>
9 <%= stylesheet_link_tag "print", :media => "print" %>
9 <%= stylesheet_link_tag "print", :media => "print" %>
10 <%= javascript_include_tag :defaults %>
10 <%= javascript_include_tag :defaults %>
11 <%= javascript_include_tag 'menu' %>
11 <%= javascript_include_tag 'menu' %>
12 <%= javascript_include_tag 'calendar/calendar' %>
12 <%= javascript_include_tag 'calendar/calendar' %>
13 <%= javascript_include_tag "calendar/lang/calendar-#{current_language}.js" %>
13 <%= javascript_include_tag "calendar/lang/calendar-#{current_language}.js" %>
14 <%= javascript_include_tag 'calendar/calendar-setup' %>
14 <%= javascript_include_tag 'calendar/calendar-setup' %>
15 <%= stylesheet_link_tag 'calendar' %>
15 <%= stylesheet_link_tag 'calendar' %>
16 <%= stylesheet_link_tag 'jstoolbar' %>
16 <%= stylesheet_link_tag 'jstoolbar' %>
17 <!-- page specific tags -->
17 <!-- page specific tags -->
18 <%= yield :header_tags %>
18 <%= yield :header_tags %>
19 </head>
19 </head>
20
20
21 <body>
21 <body>
22 <div id="container" >
22 <div id="container" >
23
23
24 <div id="header">
24 <div id="header">
25 <div style="float: left;">
25 <div style="float: left;">
26 <h1><%= $RDM_HEADER_TITLE %></h1>
26 <h1><%= $RDM_HEADER_TITLE %></h1>
27 <h2><%= $RDM_HEADER_SUBTITLE %></h2>
27 <h2><%= $RDM_HEADER_SUBTITLE %></h2>
28 </div>
28 </div>
29 <div style="float: right; padding-right: 1em; padding-top: 0.2em;">
29 <div style="float: right; padding-right: 1em; padding-top: 0.2em;">
30 <% if loggedin? %><small><%=l(:label_logged_as)%> <b><%= @logged_in_user.login %></b></small><% end %>
30 <% if loggedin? %><small><%=l(:label_logged_as)%> <b><%= @logged_in_user.login %></b></small><% end %>
31 </div>
31 </div>
32 </div>
32 </div>
33
33
34 <div id="navigation">
34 <div id="navigation">
35 <ul>
35 <ul>
36 <li class="selected"><%= link_to l(:label_home), { :controller => '' }, :class => "picHome" %></li>
36 <li class="selected"><%= link_to l(:label_home), { :controller => '' }, :class => "picHome" %></li>
37 <li><%= link_to l(:label_my_page), { :controller => 'my', :action => 'page'}, :class => "picUserPage" %></li>
37 <li><%= link_to l(:label_my_page), { :controller => 'my', :action => 'page'}, :class => "picUserPage" %></li>
38 <li><%= link_to l(:label_project_plural), { :controller => 'projects' }, :class => "picProject" %></li>
38 <li><%= link_to l(:label_project_plural), { :controller => 'projects' }, :class => "picProject" %></li>
39
39
40 <% unless @project.nil? || @project.id.nil? %>
40 <% unless @project.nil? || @project.id.nil? %>
41 <li class="submenu"><%= link_to @project.name, { :controller => 'projects', :action => 'show', :id => @project }, :class => "picProject", :onmouseover => "buttonMouseover(event, 'menuProject');" %></li>
41 <li class="submenu"><%= link_to @project.name, { :controller => 'projects', :action => 'show', :id => @project }, :class => "picProject", :onmouseover => "buttonMouseover(event, 'menuProject');" %></li>
42 <% end %>
42 <% end %>
43
43
44 <% if loggedin? %>
44 <% if loggedin? %>
45 <li><%= link_to l(:label_my_account), { :controller => 'my', :action => 'account' }, :class => "picUser" %></li>
45 <li><%= link_to l(:label_my_account), { :controller => 'my', :action => 'account' }, :class => "picUser" %></li>
46 <% end %>
46 <% end %>
47
47
48 <% if admin_loggedin? %>
48 <% if admin_loggedin? %>
49 <li class="submenu"><%= link_to l(:label_administration), { :controller => 'admin' }, :class => "picAdmin", :onmouseover => "buttonMouseover(event, 'menuAdmin');" %></li>
49 <li class="submenu"><%= link_to l(:label_administration), { :controller => 'admin' }, :class => "picAdmin", :onmouseover => "buttonMouseover(event, 'menuAdmin');" %></li>
50 <% end %>
50 <% end %>
51
51
52 <li class="right"><%= link_to l(:label_help), { :controller => 'help', :ctrl => @params[:controller], :page => @params[:action] }, :target => "new", :class => "picHelp" %></li>
52 <li class="right"><%= link_to l(:label_help), { :controller => 'help', :ctrl => params[:controller], :page => params[:action] }, :target => "new", :class => "picHelp" %></li>
53
53
54 <% if loggedin? %>
54 <% if loggedin? %>
55 <li class="right"><%= link_to l(:label_logout), { :controller => 'account', :action => 'logout' }, :class => "picUser" %></li>
55 <li class="right"><%= link_to l(:label_logout), { :controller => 'account', :action => 'logout' }, :class => "picUser" %></li>
56 <% else %>
56 <% else %>
57 <li class="right"><%= link_to l(:label_login), { :controller => 'account', :action => 'login' }, :class => "picUser" %></li>
57 <li class="right"><%= link_to l(:label_login), { :controller => 'account', :action => 'login' }, :class => "picUser" %></li>
58 <% end %>
58 <% end %>
59 </ul>
59 </ul>
60 </div>
60 </div>
61
61
62 <% if admin_loggedin? %>
62 <% if admin_loggedin? %>
63 <div id="menuAdmin" class="menu" onmouseover="menuMouseover(event)">
63 <div id="menuAdmin" class="menu" onmouseover="menuMouseover(event)">
64 <a class="menuItem" href="/admin/projects" onmouseover="menuItemMouseover(event,'menuProjects');"><span class="menuItemText"><%=l(:label_project_plural)%></span><span class="menuItemArrow">&#9654;</span></a>
64 <a class="menuItem" href="/admin/projects" onmouseover="menuItemMouseover(event,'menuProjects');"><span class="menuItemText"><%=l(:label_project_plural)%></span><span class="menuItemArrow">&#9654;</span></a>
65 <a class="menuItem" href="/users" onmouseover="menuItemMouseover(event,'menuUsers');"><span class="menuItemText"><%=l(:label_user_plural)%></span><span class="menuItemArrow">&#9654;</span></a>
65 <a class="menuItem" href="/users" onmouseover="menuItemMouseover(event,'menuUsers');"><span class="menuItemText"><%=l(:label_user_plural)%></span><span class="menuItemArrow">&#9654;</span></a>
66 <a class="menuItem" href="/roles"><%=l(:label_role_and_permissions)%></a>
66 <a class="menuItem" href="/roles"><%=l(:label_role_and_permissions)%></a>
67 <a class="menuItem" href="/trackers" onmouseover="menuItemMouseover(event,'menuTrackers');"><span class="menuItemText"><%=l(:label_tracker_plural)%></span><span class="menuItemArrow">&#9654;</span></a>
67 <a class="menuItem" href="/trackers" onmouseover="menuItemMouseover(event,'menuTrackers');"><span class="menuItemText"><%=l(:label_tracker_plural)%></span><span class="menuItemArrow">&#9654;</span></a>
68 <a class="menuItem" href="/custom_fields"><%=l(:label_custom_field_plural)%></a>
68 <a class="menuItem" href="/custom_fields"><%=l(:label_custom_field_plural)%></a>
69 <a class="menuItem" href="/enumerations"><%=l(:label_enumerations)%></a>
69 <a class="menuItem" href="/enumerations"><%=l(:label_enumerations)%></a>
70 <a class="menuItem" href="/admin/mail_options"><%=l(:field_mail_notification)%></a>
70 <a class="menuItem" href="/admin/mail_options"><%=l(:field_mail_notification)%></a>
71 <a class="menuItem" href="/auth_sources"><%=l(:label_authentication)%></a>
71 <a class="menuItem" href="/auth_sources"><%=l(:label_authentication)%></a>
72 <a class="menuItem" href="/admin/info"><%=l(:label_information_plural)%></a>
72 <a class="menuItem" href="/admin/info"><%=l(:label_information_plural)%></a>
73 </div>
73 </div>
74 <div id="menuTrackers" class="menu">
74 <div id="menuTrackers" class="menu">
75 <a class="menuItem" href="/issue_statuses"><%=l(:label_issue_status_plural)%></a>
75 <a class="menuItem" href="/issue_statuses"><%=l(:label_issue_status_plural)%></a>
76 <a class="menuItem" href="/roles/workflow"><%=l(:label_workflow)%></a>
76 <a class="menuItem" href="/roles/workflow"><%=l(:label_workflow)%></a>
77 </div>
77 </div>
78 <div id="menuProjects" class="menu"><a class="menuItem" href="/projects/add"><%=l(:label_new)%></a></div>
78 <div id="menuProjects" class="menu"><a class="menuItem" href="/projects/add"><%=l(:label_new)%></a></div>
79 <div id="menuUsers" class="menu"><a class="menuItem" href="/users/add"><%=l(:label_new)%></a></div>
79 <div id="menuUsers" class="menu"><a class="menuItem" href="/users/add"><%=l(:label_new)%></a></div>
80 <% end %>
80 <% end %>
81
81
82 <% unless @project.nil? || @project.id.nil? %>
82 <% unless @project.nil? || @project.id.nil? %>
83 <div id="menuProject" class="menu" onmouseover="menuMouseover(event)">
83 <div id="menuProject" class="menu" onmouseover="menuMouseover(event)">
84 <%= link_to l(:label_calendar), {:controller => 'projects', :action => 'calendar', :id => @project }, :class => "menuItem" %>
84 <%= link_to l(:label_calendar), {:controller => 'projects', :action => 'calendar', :id => @project }, :class => "menuItem" %>
85 <%= link_to l(:label_gantt), {:controller => 'projects', :action => 'gantt', :id => @project }, :class => "menuItem" %>
85 <%= link_to l(:label_gantt), {:controller => 'projects', :action => 'gantt', :id => @project }, :class => "menuItem" %>
86 <%= link_to l(:label_issue_plural), {:controller => 'projects', :action => 'list_issues', :id => @project }, :class => "menuItem" %>
86 <%= link_to l(:label_issue_plural), {:controller => 'projects', :action => 'list_issues', :id => @project }, :class => "menuItem" %>
87 <%= link_to l(:label_report_plural), {:controller => 'reports', :action => 'issue_report', :id => @project }, :class => "menuItem" %>
87 <%= link_to l(:label_report_plural), {:controller => 'reports', :action => 'issue_report', :id => @project }, :class => "menuItem" %>
88 <%= link_to l(:label_activity), {:controller => 'projects', :action => 'activity', :id => @project }, :class => "menuItem" %>
88 <%= link_to l(:label_activity), {:controller => 'projects', :action => 'activity', :id => @project }, :class => "menuItem" %>
89 <%= link_to l(:label_news_plural), {:controller => 'projects', :action => 'list_news', :id => @project }, :class => "menuItem" %>
89 <%= link_to l(:label_news_plural), {:controller => 'projects', :action => 'list_news', :id => @project }, :class => "menuItem" %>
90 <%= link_to l(:label_change_log), {:controller => 'projects', :action => 'changelog', :id => @project }, :class => "menuItem" %>
90 <%= link_to l(:label_change_log), {:controller => 'projects', :action => 'changelog', :id => @project }, :class => "menuItem" %>
91 <%= link_to l(:label_document_plural), {:controller => 'projects', :action => 'list_documents', :id => @project }, :class => "menuItem" %>
91 <%= link_to l(:label_document_plural), {:controller => 'projects', :action => 'list_documents', :id => @project }, :class => "menuItem" %>
92 <%= link_to l(:label_member_plural), {:controller => 'projects', :action => 'list_members', :id => @project }, :class => "menuItem" %>
92 <%= link_to l(:label_member_plural), {:controller => 'projects', :action => 'list_members', :id => @project }, :class => "menuItem" %>
93 <%= link_to l(:label_attachment_plural), {:controller => 'projects', :action => 'list_files', :id => @project }, :class => "menuItem" %>
93 <%= link_to l(:label_attachment_plural), {:controller => 'projects', :action => 'list_files', :id => @project }, :class => "menuItem" %>
94 <%= link_to l(:label_repository), {:controller => 'repositories', :action => 'show', :id => @project}, :class => "menuItem" if @project.repository and !@project.repository.new_record? %>
94 <%= link_to l(:label_repository), {:controller => 'repositories', :action => 'show', :id => @project}, :class => "menuItem" if @project.repository and !@project.repository.new_record? %>
95 <%= link_to_if_authorized l(:label_settings), {:controller => 'projects', :action => 'settings', :id => @project }, :class => "menuItem" %>
95 <%= link_to_if_authorized l(:label_settings), {:controller => 'projects', :action => 'settings', :id => @project }, :class => "menuItem" %>
96 </div>
96 </div>
97 <% end %>
97 <% end %>
98
98
99
99
100 <div id="subcontent">
100 <div id="subcontent">
101
101
102 <% unless @project.nil? || @project.id.nil? %>
102 <% unless @project.nil? || @project.id.nil? %>
103 <h2><%= @project.name %></h2>
103 <h2><%= @project.name %></h2>
104 <ul class="menublock">
104 <ul class="menublock">
105 <li><%= link_to l(:label_overview), :controller => 'projects', :action => 'show', :id => @project %></li>
105 <li><%= link_to l(:label_overview), :controller => 'projects', :action => 'show', :id => @project %></li>
106 <li><%= link_to l(:label_calendar), :controller => 'projects', :action => 'calendar', :id => @project %></li>
106 <li><%= link_to l(:label_calendar), :controller => 'projects', :action => 'calendar', :id => @project %></li>
107 <li><%= link_to l(:label_gantt), :controller => 'projects', :action => 'gantt', :id => @project %></li>
107 <li><%= link_to l(:label_gantt), :controller => 'projects', :action => 'gantt', :id => @project %></li>
108 <li><%= link_to l(:label_issue_plural), :controller => 'projects', :action => 'list_issues', :id => @project %></li>
108 <li><%= link_to l(:label_issue_plural), :controller => 'projects', :action => 'list_issues', :id => @project %></li>
109 <li><%= link_to l(:label_report_plural), :controller => 'reports', :action => 'issue_report', :id => @project %></li>
109 <li><%= link_to l(:label_report_plural), :controller => 'reports', :action => 'issue_report', :id => @project %></li>
110 <li><%= link_to l(:label_activity), :controller => 'projects', :action => 'activity', :id => @project %></li>
110 <li><%= link_to l(:label_activity), :controller => 'projects', :action => 'activity', :id => @project %></li>
111 <li><%= link_to l(:label_news_plural), :controller => 'projects', :action => 'list_news', :id => @project %></li>
111 <li><%= link_to l(:label_news_plural), :controller => 'projects', :action => 'list_news', :id => @project %></li>
112 <li><%= link_to l(:label_change_log), :controller => 'projects', :action => 'changelog', :id => @project %></li>
112 <li><%= link_to l(:label_change_log), :controller => 'projects', :action => 'changelog', :id => @project %></li>
113 <li><%= link_to l(:label_document_plural), :controller => 'projects', :action => 'list_documents', :id => @project %></li>
113 <li><%= link_to l(:label_document_plural), :controller => 'projects', :action => 'list_documents', :id => @project %></li>
114 <li><%= link_to l(:label_member_plural), :controller => 'projects', :action => 'list_members', :id => @project %></li>
114 <li><%= link_to l(:label_member_plural), :controller => 'projects', :action => 'list_members', :id => @project %></li>
115 <li><%= link_to l(:label_attachment_plural), :controller => 'projects', :action => 'list_files', :id => @project %></li>
115 <li><%= link_to l(:label_attachment_plural), :controller => 'projects', :action => 'list_files', :id => @project %></li>
116 <li><%= link_to l(:label_repository), :controller => 'repositories', :action => 'show', :id => @project if @project.repository and !@project.repository.new_record? %></li>
116 <li><%= link_to l(:label_repository), :controller => 'repositories', :action => 'show', :id => @project if @project.repository and !@project.repository.new_record? %></li>
117 <li><%= link_to_if_authorized l(:label_settings), :controller => 'projects', :action => 'settings', :id => @project %></li>
117 <li><%= link_to_if_authorized l(:label_settings), :controller => 'projects', :action => 'settings', :id => @project %></li>
118 </ul>
118 </ul>
119 <% end %>
119 <% end %>
120
120
121 <% if loggedin? and @logged_in_user.memberships.length > 0 %>
121 <% if loggedin? and @logged_in_user.memberships.length > 0 %>
122 <h2><%=l(:label_my_projects) %></h2>
122 <h2><%=l(:label_my_projects) %></h2>
123 <ul class="menublock">
123 <ul class="menublock">
124 <% for membership in @logged_in_user.memberships %>
124 <% for membership in @logged_in_user.memberships %>
125 <li><%= link_to membership.project.name, :controller => 'projects', :action => 'show', :id => membership.project %></li>
125 <li><%= link_to membership.project.name, :controller => 'projects', :action => 'show', :id => membership.project %></li>
126 <% end %>
126 <% end %>
127 </ul>
127 </ul>
128 <% end %>
128 <% end %>
129 </div>
129 </div>
130
130
131 <div id="content">
131 <div id="content">
132 <% if flash[:notice] %><p style="color: green"><%= flash[:notice] %></p><% end %>
132 <% if flash[:notice] %><p style="color: green"><%= flash[:notice] %></p><% end %>
133 <%= @content_for_layout %>
133 <%= @content_for_layout %>
134 </div>
134 </div>
135
135
136 <div id="footer">
136 <div id="footer">
137 <p>
137 <p>
138 <%= auto_link $RDM_FOOTER_SIG %> |
138 <%= auto_link $RDM_FOOTER_SIG %> |
139 <a href="http://redmine.rubyforge.org/" target="_new"><%= RDM_APP_NAME %></a> <%= RDM_APP_VERSION %>
139 <a href="http://redmine.rubyforge.org/" target="_new"><%= RDM_APP_NAME %></a> <%= RDM_APP_VERSION %>
140 </p>
140 </p>
141 </div>
141 </div>
142
142
143 </div>
143 </div>
144 </body>
144 </body>
145 </html> No newline at end of file
145 </html>
General Comments 0
You need to be logged in to leave comments. Login now