##// END OF EJS Templates
Removed @html_title assignments in controllers....
Jean-Philippe Lang -
r704:7e4611ad3180
parent child
Show More
@@ -1,172 +1,170
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
2 # Copyright (C) 2006-2007 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 :user_setup, :check_if_login_required, :set_localization
19 before_filter :user_setup, :check_if_login_required, :set_localization
20 filter_parameter_logging :password
20 filter_parameter_logging :password
21
21
22 REDMINE_SUPPORTED_SCM.each do |scm|
22 REDMINE_SUPPORTED_SCM.each do |scm|
23 require_dependency "repository/#{scm.underscore}"
23 require_dependency "repository/#{scm.underscore}"
24 end
24 end
25
25
26 def logged_in_user
26 def logged_in_user
27 User.current.logged? ? User.current : nil
27 User.current.logged? ? User.current : nil
28 end
28 end
29
29
30 def current_role
30 def current_role
31 @current_role ||= User.current.role_for_project(@project)
31 @current_role ||= User.current.role_for_project(@project)
32 end
32 end
33
33
34 def user_setup
34 def user_setup
35 Setting.check_cache
35 Setting.check_cache
36 if session[:user_id]
36 if session[:user_id]
37 # existing session
37 # existing session
38 User.current = User.find(session[:user_id])
38 User.current = User.find(session[:user_id])
39 elsif cookies[:autologin] && Setting.autologin?
39 elsif cookies[:autologin] && Setting.autologin?
40 # auto-login feature
40 # auto-login feature
41 User.current = User.find_by_autologin_key(cookies[:autologin])
41 User.current = User.find_by_autologin_key(cookies[:autologin])
42 elsif params[:key] && accept_key_auth_actions.include?(params[:action])
42 elsif params[:key] && accept_key_auth_actions.include?(params[:action])
43 # RSS key authentication
43 # RSS key authentication
44 User.current = User.find_by_rss_key(params[:key])
44 User.current = User.find_by_rss_key(params[:key])
45 else
45 else
46 User.current = User.anonymous
46 User.current = User.anonymous
47 end
47 end
48 end
48 end
49
49
50 # check if login is globally required to access the application
50 # check if login is globally required to access the application
51 def check_if_login_required
51 def check_if_login_required
52 # no check needed if user is already logged in
52 # no check needed if user is already logged in
53 return true if User.current.logged?
53 return true if User.current.logged?
54 require_login if Setting.login_required?
54 require_login if Setting.login_required?
55 end
55 end
56
56
57 def set_localization
57 def set_localization
58 lang = begin
58 lang = begin
59 if !User.current.language.blank? and GLoc.valid_languages.include? User.current.language.to_sym
59 if !User.current.language.blank? and GLoc.valid_languages.include? User.current.language.to_sym
60 User.current.language
60 User.current.language
61 elsif request.env['HTTP_ACCEPT_LANGUAGE']
61 elsif request.env['HTTP_ACCEPT_LANGUAGE']
62 accept_lang = parse_qvalues(request.env['HTTP_ACCEPT_LANGUAGE']).first.split('-').first
62 accept_lang = parse_qvalues(request.env['HTTP_ACCEPT_LANGUAGE']).first.split('-').first
63 if accept_lang and !accept_lang.empty? and GLoc.valid_languages.include? accept_lang.to_sym
63 if accept_lang and !accept_lang.empty? and GLoc.valid_languages.include? accept_lang.to_sym
64 accept_lang
64 accept_lang
65 end
65 end
66 end
66 end
67 rescue
67 rescue
68 nil
68 nil
69 end || Setting.default_language
69 end || Setting.default_language
70 set_language_if_valid(lang)
70 set_language_if_valid(lang)
71 end
71 end
72
72
73 def require_login
73 def require_login
74 if !User.current.logged?
74 if !User.current.logged?
75 store_location
75 store_location
76 redirect_to :controller => "account", :action => "login"
76 redirect_to :controller => "account", :action => "login"
77 return false
77 return false
78 end
78 end
79 true
79 true
80 end
80 end
81
81
82 def require_admin
82 def require_admin
83 return unless require_login
83 return unless require_login
84 if !User.current.admin?
84 if !User.current.admin?
85 render_403
85 render_403
86 return false
86 return false
87 end
87 end
88 true
88 true
89 end
89 end
90
90
91 # Authorize the user for the requested action
91 # Authorize the user for the requested action
92 def authorize(ctrl = params[:controller], action = params[:action])
92 def authorize(ctrl = params[:controller], action = params[:action])
93 allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project)
93 allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project)
94 allowed ? true : (User.current.logged? ? render_403 : require_login)
94 allowed ? true : (User.current.logged? ? render_403 : require_login)
95 end
95 end
96
96
97 # make sure that the user is a member of the project (or admin) if project is private
97 # make sure that the user is a member of the project (or admin) if project is private
98 # used as a before_filter for actions that do not require any particular permission on the project
98 # used as a before_filter for actions that do not require any particular permission on the project
99 def check_project_privacy
99 def check_project_privacy
100 unless @project.active?
100 unless @project.active?
101 @project = nil
101 @project = nil
102 render_404
102 render_404
103 return false
103 return false
104 end
104 end
105 return true if @project.is_public? || User.current.member_of?(@project) || User.current.admin?
105 return true if @project.is_public? || User.current.member_of?(@project) || User.current.admin?
106 User.current.logged? ? render_403 : require_login
106 User.current.logged? ? render_403 : require_login
107 end
107 end
108
108
109 # store current uri in session.
109 # store current uri in session.
110 # return to this location by calling redirect_back_or_default
110 # return to this location by calling redirect_back_or_default
111 def store_location
111 def store_location
112 session[:return_to_params] = params
112 session[:return_to_params] = params
113 end
113 end
114
114
115 # move to the last store_location call or to the passed default one
115 # move to the last store_location call or to the passed default one
116 def redirect_back_or_default(default)
116 def redirect_back_or_default(default)
117 if session[:return_to_params].nil?
117 if session[:return_to_params].nil?
118 redirect_to default
118 redirect_to default
119 else
119 else
120 redirect_to session[:return_to_params]
120 redirect_to session[:return_to_params]
121 session[:return_to_params] = nil
121 session[:return_to_params] = nil
122 end
122 end
123 end
123 end
124
124
125 def render_403
125 def render_403
126 @html_title = "403"
127 @project = nil
126 @project = nil
128 render :template => "common/403", :layout => true, :status => 403
127 render :template => "common/403", :layout => true, :status => 403
129 return false
128 return false
130 end
129 end
131
130
132 def render_404
131 def render_404
133 @html_title = "404"
134 render :template => "common/404", :layout => true, :status => 404
132 render :template => "common/404", :layout => true, :status => 404
135 return false
133 return false
136 end
134 end
137
135
138 def render_feed(items, options={})
136 def render_feed(items, options={})
139 @items = items || []
137 @items = items || []
140 @items.sort! {|x,y| y.event_datetime <=> x.event_datetime }
138 @items.sort! {|x,y| y.event_datetime <=> x.event_datetime }
141 @title = options[:title] || Setting.app_title
139 @title = options[:title] || Setting.app_title
142 render :template => "common/feed.atom.rxml", :layout => false, :content_type => 'application/atom+xml'
140 render :template => "common/feed.atom.rxml", :layout => false, :content_type => 'application/atom+xml'
143 end
141 end
144
142
145 def self.accept_key_auth(*actions)
143 def self.accept_key_auth(*actions)
146 actions = actions.flatten.map(&:to_s)
144 actions = actions.flatten.map(&:to_s)
147 write_inheritable_attribute('accept_key_auth_actions', actions)
145 write_inheritable_attribute('accept_key_auth_actions', actions)
148 end
146 end
149
147
150 def accept_key_auth_actions
148 def accept_key_auth_actions
151 self.class.read_inheritable_attribute('accept_key_auth_actions') || []
149 self.class.read_inheritable_attribute('accept_key_auth_actions') || []
152 end
150 end
153
151
154 # qvalues http header parser
152 # qvalues http header parser
155 # code taken from webrick
153 # code taken from webrick
156 def parse_qvalues(value)
154 def parse_qvalues(value)
157 tmp = []
155 tmp = []
158 if value
156 if value
159 parts = value.split(/,\s*/)
157 parts = value.split(/,\s*/)
160 parts.each {|part|
158 parts.each {|part|
161 if m = %r{^([^\s,]+?)(?:;\s*q=(\d+(?:\.\d+)?))?$}.match(part)
159 if m = %r{^([^\s,]+?)(?:;\s*q=(\d+(?:\.\d+)?))?$}.match(part)
162 val = m[1]
160 val = m[1]
163 q = (m[2] or 1).to_f
161 q = (m[2] or 1).to_f
164 tmp.push([val, q])
162 tmp.push([val, q])
165 end
163 end
166 }
164 }
167 tmp = tmp.sort_by{|val, q| -q}
165 tmp = tmp.sort_by{|val, q| -q}
168 tmp.collect!{|val, q| val}
166 tmp.collect!{|val, q| val}
169 end
167 end
170 return tmp
168 return tmp
171 end
169 end
172 end
170 end
@@ -1,196 +1,195
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
2 # Copyright (C) 2006-2007 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, :except => :index
20 before_filter :find_project, :authorize, :except => :index
21 accept_key_auth :index
21 accept_key_auth :index
22
22
23 cache_sweeper :issue_sweeper, :only => [ :edit, :change_status, :destroy ]
23 cache_sweeper :issue_sweeper, :only => [ :edit, :change_status, :destroy ]
24
24
25 helper :projects
25 helper :projects
26 include ProjectsHelper
26 include ProjectsHelper
27 helper :custom_fields
27 helper :custom_fields
28 include CustomFieldsHelper
28 include CustomFieldsHelper
29 helper :ifpdf
29 helper :ifpdf
30 include IfpdfHelper
30 include IfpdfHelper
31 helper :issue_relations
31 helper :issue_relations
32 include IssueRelationsHelper
32 include IssueRelationsHelper
33 helper :watchers
33 helper :watchers
34 include WatchersHelper
34 include WatchersHelper
35 helper :attachments
35 helper :attachments
36 include AttachmentsHelper
36 include AttachmentsHelper
37 helper :queries
37 helper :queries
38 helper :sort
38 helper :sort
39 include SortHelper
39 include SortHelper
40
40
41 def index
41 def index
42 sort_init "#{Issue.table_name}.id", "desc"
42 sort_init "#{Issue.table_name}.id", "desc"
43 sort_update
43 sort_update
44 retrieve_query
44 retrieve_query
45 if @query.valid?
45 if @query.valid?
46 @issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement)
46 @issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement)
47 @issue_pages = Paginator.new self, @issue_count, 25, params['page']
47 @issue_pages = Paginator.new self, @issue_count, 25, params['page']
48 @issues = Issue.find :all, :order => sort_clause,
48 @issues = Issue.find :all, :order => sort_clause,
49 :include => [ :assigned_to, :status, :tracker, :project, :priority ],
49 :include => [ :assigned_to, :status, :tracker, :project, :priority ],
50 :conditions => @query.statement,
50 :conditions => @query.statement,
51 :limit => @issue_pages.items_per_page,
51 :limit => @issue_pages.items_per_page,
52 :offset => @issue_pages.current.offset
52 :offset => @issue_pages.current.offset
53 end
53 end
54 respond_to do |format|
54 respond_to do |format|
55 format.html { render :layout => false if request.xhr? }
55 format.html { render :layout => false if request.xhr? }
56 format.atom { render_feed(@issues, :title => l(:label_issue_plural)) }
56 format.atom { render_feed(@issues, :title => l(:label_issue_plural)) }
57 end
57 end
58 end
58 end
59
59
60 def show
60 def show
61 @status_options = @issue.status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user
61 @status_options = @issue.status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user
62 @custom_values = @issue.custom_values.find(:all, :include => :custom_field)
62 @custom_values = @issue.custom_values.find(:all, :include => :custom_field)
63 @journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC")
63 @journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC")
64 end
64 end
65
65
66 def export_pdf
66 def export_pdf
67 @custom_values = @issue.custom_values.find(:all, :include => :custom_field)
67 @custom_values = @issue.custom_values.find(:all, :include => :custom_field)
68 @options_for_rfpdf ||= {}
68 @options_for_rfpdf ||= {}
69 @options_for_rfpdf[:file_name] = "#{@project.name}_#{@issue.id}.pdf"
69 @options_for_rfpdf[:file_name] = "#{@project.name}_#{@issue.id}.pdf"
70 end
70 end
71
71
72 def edit
72 def edit
73 @priorities = Enumeration::get_values('IPRI')
73 @priorities = Enumeration::get_values('IPRI')
74 if request.get?
74 if request.get?
75 @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) }
75 @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) }
76 else
76 else
77 begin
77 begin
78 @issue.init_journal(self.logged_in_user)
78 @issue.init_journal(self.logged_in_user)
79 # Retrieve custom fields and values
79 # Retrieve custom fields and values
80 @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]) }
80 @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]) }
81 @issue.custom_values = @custom_values
81 @issue.custom_values = @custom_values
82 @issue.attributes = params[:issue]
82 @issue.attributes = params[:issue]
83 if @issue.save
83 if @issue.save
84 flash[:notice] = l(:notice_successful_update)
84 flash[:notice] = l(:notice_successful_update)
85 redirect_to :action => 'show', :id => @issue
85 redirect_to :action => 'show', :id => @issue
86 end
86 end
87 rescue ActiveRecord::StaleObjectError
87 rescue ActiveRecord::StaleObjectError
88 # Optimistic locking exception
88 # Optimistic locking exception
89 flash[:error] = l(:notice_locking_conflict)
89 flash[:error] = l(:notice_locking_conflict)
90 end
90 end
91 end
91 end
92 end
92 end
93
93
94 def add_note
94 def add_note
95 unless params[:notes].empty?
95 unless params[:notes].empty?
96 journal = @issue.init_journal(self.logged_in_user, params[:notes])
96 journal = @issue.init_journal(self.logged_in_user, params[:notes])
97 if @issue.save
97 if @issue.save
98 params[:attachments].each { |file|
98 params[:attachments].each { |file|
99 next unless file.size > 0
99 next unless file.size > 0
100 a = Attachment.create(:container => @issue, :file => file, :author => logged_in_user)
100 a = Attachment.create(:container => @issue, :file => file, :author => logged_in_user)
101 journal.details << JournalDetail.new(:property => 'attachment',
101 journal.details << JournalDetail.new(:property => 'attachment',
102 :prop_key => a.id,
102 :prop_key => a.id,
103 :value => a.filename) unless a.new_record?
103 :value => a.filename) unless a.new_record?
104 } if params[:attachments] and params[:attachments].is_a? Array
104 } if params[:attachments] and params[:attachments].is_a? Array
105 flash[:notice] = l(:notice_successful_update)
105 flash[:notice] = l(:notice_successful_update)
106 Mailer.deliver_issue_edit(journal) #if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
106 Mailer.deliver_issue_edit(journal) #if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
107 redirect_to :action => 'show', :id => @issue
107 redirect_to :action => 'show', :id => @issue
108 return
108 return
109 end
109 end
110 end
110 end
111 show
111 show
112 render :action => 'show'
112 render :action => 'show'
113 end
113 end
114
114
115 def change_status
115 def change_status
116 @status_options = @issue.status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user
116 @status_options = @issue.status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user
117 @new_status = IssueStatus.find(params[:new_status_id])
117 @new_status = IssueStatus.find(params[:new_status_id])
118 if params[:confirm]
118 if params[:confirm]
119 begin
119 begin
120 journal = @issue.init_journal(self.logged_in_user, params[:notes])
120 journal = @issue.init_journal(self.logged_in_user, params[:notes])
121 @issue.status = @new_status
121 @issue.status = @new_status
122 if @issue.update_attributes(params[:issue])
122 if @issue.update_attributes(params[:issue])
123 # Save attachments
123 # Save attachments
124 params[:attachments].each { |file|
124 params[:attachments].each { |file|
125 next unless file.size > 0
125 next unless file.size > 0
126 a = Attachment.create(:container => @issue, :file => file, :author => logged_in_user)
126 a = Attachment.create(:container => @issue, :file => file, :author => logged_in_user)
127 journal.details << JournalDetail.new(:property => 'attachment',
127 journal.details << JournalDetail.new(:property => 'attachment',
128 :prop_key => a.id,
128 :prop_key => a.id,
129 :value => a.filename) unless a.new_record?
129 :value => a.filename) unless a.new_record?
130 } if params[:attachments] and params[:attachments].is_a? Array
130 } if params[:attachments] and params[:attachments].is_a? Array
131
131
132 # Log time
132 # Log time
133 if current_role.allowed_to?(:log_time)
133 if current_role.allowed_to?(:log_time)
134 @time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => logged_in_user, :spent_on => Date.today)
134 @time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => logged_in_user, :spent_on => Date.today)
135 @time_entry.attributes = params[:time_entry]
135 @time_entry.attributes = params[:time_entry]
136 @time_entry.save
136 @time_entry.save
137 end
137 end
138
138
139 flash[:notice] = l(:notice_successful_update)
139 flash[:notice] = l(:notice_successful_update)
140 Mailer.deliver_issue_edit(journal) #if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
140 Mailer.deliver_issue_edit(journal) #if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
141 redirect_to :action => 'show', :id => @issue
141 redirect_to :action => 'show', :id => @issue
142 end
142 end
143 rescue ActiveRecord::StaleObjectError
143 rescue ActiveRecord::StaleObjectError
144 # Optimistic locking exception
144 # Optimistic locking exception
145 flash[:error] = l(:notice_locking_conflict)
145 flash[:error] = l(:notice_locking_conflict)
146 end
146 end
147 end
147 end
148 @assignable_to = @project.members.find(:all, :include => :user).collect{ |m| m.user }
148 @assignable_to = @project.members.find(:all, :include => :user).collect{ |m| m.user }
149 @activities = Enumeration::get_values('ACTI')
149 @activities = Enumeration::get_values('ACTI')
150 end
150 end
151
151
152 def destroy
152 def destroy
153 @issue.destroy
153 @issue.destroy
154 redirect_to :controller => 'projects', :action => 'list_issues', :id => @project
154 redirect_to :controller => 'projects', :action => 'list_issues', :id => @project
155 end
155 end
156
156
157 def destroy_attachment
157 def destroy_attachment
158 a = @issue.attachments.find(params[:attachment_id])
158 a = @issue.attachments.find(params[:attachment_id])
159 a.destroy
159 a.destroy
160 journal = @issue.init_journal(self.logged_in_user)
160 journal = @issue.init_journal(self.logged_in_user)
161 journal.details << JournalDetail.new(:property => 'attachment',
161 journal.details << JournalDetail.new(:property => 'attachment',
162 :prop_key => a.id,
162 :prop_key => a.id,
163 :old_value => a.filename)
163 :old_value => a.filename)
164 journal.save
164 journal.save
165 redirect_to :action => 'show', :id => @issue
165 redirect_to :action => 'show', :id => @issue
166 end
166 end
167
167
168 private
168 private
169 def find_project
169 def find_project
170 @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
170 @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
171 @project = @issue.project
171 @project = @issue.project
172 @html_title = "#{@project.name} - #{@issue.tracker.name} ##{@issue.id}"
173 rescue ActiveRecord::RecordNotFound
172 rescue ActiveRecord::RecordNotFound
174 render_404
173 render_404
175 end
174 end
176
175
177 # Retrieve query from session or build a new query
176 # Retrieve query from session or build a new query
178 def retrieve_query
177 def retrieve_query
179 if params[:set_filter] or !session[:query] or session[:query].project_id
178 if params[:set_filter] or !session[:query] or session[:query].project_id
180 # Give it a name, required to be valid
179 # Give it a name, required to be valid
181 @query = Query.new(:name => "_", :executed_by => logged_in_user)
180 @query = Query.new(:name => "_", :executed_by => logged_in_user)
182 if params[:fields] and params[:fields].is_a? Array
181 if params[:fields] and params[:fields].is_a? Array
183 params[:fields].each do |field|
182 params[:fields].each do |field|
184 @query.add_filter(field, params[:operators][field], params[:values][field])
183 @query.add_filter(field, params[:operators][field], params[:values][field])
185 end
184 end
186 else
185 else
187 @query.available_filters.keys.each do |field|
186 @query.available_filters.keys.each do |field|
188 @query.add_short_filter(field, params[field]) if params[field]
187 @query.add_short_filter(field, params[field]) if params[field]
189 end
188 end
190 end
189 end
191 session[:query] = @query
190 session[:query] = @query
192 else
191 else
193 @query = session[:query]
192 @query = session[:query]
194 end
193 end
195 end
194 end
196 end
195 end
@@ -1,673 +1,672
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
2 # Copyright (C) 2006-2007 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 require 'csv'
18 require 'csv'
19
19
20 class ProjectsController < ApplicationController
20 class ProjectsController < ApplicationController
21 layout 'base'
21 layout 'base'
22 before_filter :find_project, :except => [ :index, :list, :add ]
22 before_filter :find_project, :except => [ :index, :list, :add ]
23 before_filter :authorize, :except => [ :index, :list, :add, :archive, :unarchive, :destroy ]
23 before_filter :authorize, :except => [ :index, :list, :add, :archive, :unarchive, :destroy ]
24 before_filter :require_admin, :only => [ :add, :archive, :unarchive, :destroy ]
24 before_filter :require_admin, :only => [ :add, :archive, :unarchive, :destroy ]
25 accept_key_auth :activity, :calendar
25 accept_key_auth :activity, :calendar
26
26
27 cache_sweeper :project_sweeper, :only => [ :add, :edit, :archive, :unarchive, :destroy ]
27 cache_sweeper :project_sweeper, :only => [ :add, :edit, :archive, :unarchive, :destroy ]
28 cache_sweeper :issue_sweeper, :only => [ :add_issue ]
28 cache_sweeper :issue_sweeper, :only => [ :add_issue ]
29 cache_sweeper :version_sweeper, :only => [ :add_version ]
29 cache_sweeper :version_sweeper, :only => [ :add_version ]
30
30
31 helper :sort
31 helper :sort
32 include SortHelper
32 include SortHelper
33 helper :custom_fields
33 helper :custom_fields
34 include CustomFieldsHelper
34 include CustomFieldsHelper
35 helper :ifpdf
35 helper :ifpdf
36 include IfpdfHelper
36 include IfpdfHelper
37 helper IssuesHelper
37 helper IssuesHelper
38 helper :queries
38 helper :queries
39 include QueriesHelper
39 include QueriesHelper
40 helper :repositories
40 helper :repositories
41 include RepositoriesHelper
41 include RepositoriesHelper
42 include ProjectsHelper
42 include ProjectsHelper
43
43
44 def index
44 def index
45 list
45 list
46 render :action => 'list' unless request.xhr?
46 render :action => 'list' unless request.xhr?
47 end
47 end
48
48
49 # Lists public projects
49 # Lists public projects
50 def list
50 def list
51 sort_init "#{Project.table_name}.name", "asc"
51 sort_init "#{Project.table_name}.name", "asc"
52 sort_update
52 sort_update
53 @project_count = Project.count(:all, :conditions => Project.visible_by(logged_in_user))
53 @project_count = Project.count(:all, :conditions => Project.visible_by(logged_in_user))
54 @project_pages = Paginator.new self, @project_count,
54 @project_pages = Paginator.new self, @project_count,
55 15,
55 15,
56 params['page']
56 params['page']
57 @projects = Project.find :all, :order => sort_clause,
57 @projects = Project.find :all, :order => sort_clause,
58 :conditions => Project.visible_by(logged_in_user),
58 :conditions => Project.visible_by(logged_in_user),
59 :include => :parent,
59 :include => :parent,
60 :limit => @project_pages.items_per_page,
60 :limit => @project_pages.items_per_page,
61 :offset => @project_pages.current.offset
61 :offset => @project_pages.current.offset
62
62
63 render :action => "list", :layout => false if request.xhr?
63 render :action => "list", :layout => false if request.xhr?
64 end
64 end
65
65
66 # Add a new project
66 # Add a new project
67 def add
67 def add
68 @custom_fields = IssueCustomField.find(:all)
68 @custom_fields = IssueCustomField.find(:all)
69 @root_projects = Project.find(:all, :conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}")
69 @root_projects = Project.find(:all, :conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}")
70 @project = Project.new(params[:project])
70 @project = Project.new(params[:project])
71 if request.get?
71 if request.get?
72 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project) }
72 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project) }
73 else
73 else
74 @project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids]
74 @project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids]
75 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => (params[:custom_fields] ? params["custom_fields"][x.id.to_s] : nil)) }
75 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => (params[:custom_fields] ? params["custom_fields"][x.id.to_s] : nil)) }
76 @project.custom_values = @custom_values
76 @project.custom_values = @custom_values
77 if params[:repository_enabled] && params[:repository_enabled] == "1"
77 if params[:repository_enabled] && params[:repository_enabled] == "1"
78 @project.repository = Repository.factory(params[:repository_scm])
78 @project.repository = Repository.factory(params[:repository_scm])
79 @project.repository.attributes = params[:repository]
79 @project.repository.attributes = params[:repository]
80 end
80 end
81 if "1" == params[:wiki_enabled]
81 if "1" == params[:wiki_enabled]
82 @project.wiki = Wiki.new
82 @project.wiki = Wiki.new
83 @project.wiki.attributes = params[:wiki]
83 @project.wiki.attributes = params[:wiki]
84 end
84 end
85 if @project.save
85 if @project.save
86 flash[:notice] = l(:notice_successful_create)
86 flash[:notice] = l(:notice_successful_create)
87 redirect_to :controller => 'admin', :action => 'projects'
87 redirect_to :controller => 'admin', :action => 'projects'
88 end
88 end
89 end
89 end
90 end
90 end
91
91
92 # Show @project
92 # Show @project
93 def show
93 def show
94 @custom_values = @project.custom_values.find(:all, :include => :custom_field)
94 @custom_values = @project.custom_values.find(:all, :include => :custom_field)
95 @members_by_role = @project.members.find(:all, :include => [:user, :role], :order => 'position').group_by {|m| m.role}
95 @members_by_role = @project.members.find(:all, :include => [:user, :role], :order => 'position').group_by {|m| m.role}
96 @subprojects = @project.active_children
96 @subprojects = @project.active_children
97 @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC")
97 @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC")
98 @trackers = Tracker.find(:all, :order => 'position')
98 @trackers = Tracker.find(:all, :order => 'position')
99 @open_issues_by_tracker = Issue.count(:group => :tracker, :joins => "INNER JOIN #{IssueStatus.table_name} ON #{IssueStatus.table_name}.id = #{Issue.table_name}.status_id", :conditions => ["project_id=? and #{IssueStatus.table_name}.is_closed=?", @project.id, false])
99 @open_issues_by_tracker = Issue.count(:group => :tracker, :joins => "INNER JOIN #{IssueStatus.table_name} ON #{IssueStatus.table_name}.id = #{Issue.table_name}.status_id", :conditions => ["project_id=? and #{IssueStatus.table_name}.is_closed=?", @project.id, false])
100 @total_issues_by_tracker = Issue.count(:group => :tracker, :conditions => ["project_id=?", @project.id])
100 @total_issues_by_tracker = Issue.count(:group => :tracker, :conditions => ["project_id=?", @project.id])
101 @key = User.current.rss_key
101 @key = User.current.rss_key
102 end
102 end
103
103
104 def settings
104 def settings
105 @root_projects = Project::find(:all, :conditions => ["parent_id IS NULL AND status = #{Project::STATUS_ACTIVE} AND id <> ?", @project.id])
105 @root_projects = Project::find(:all, :conditions => ["parent_id IS NULL AND status = #{Project::STATUS_ACTIVE} AND id <> ?", @project.id])
106 @custom_fields = IssueCustomField.find(:all)
106 @custom_fields = IssueCustomField.find(:all)
107 @issue_category ||= IssueCategory.new
107 @issue_category ||= IssueCategory.new
108 @member ||= @project.members.new
108 @member ||= @project.members.new
109 @custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
109 @custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
110 end
110 end
111
111
112 # Edit @project
112 # Edit @project
113 def edit
113 def edit
114 if request.post?
114 if request.post?
115 @project.custom_fields = IssueCustomField.find(params[:custom_field_ids]) if params[:custom_field_ids]
115 @project.custom_fields = IssueCustomField.find(params[:custom_field_ids]) if params[:custom_field_ids]
116 if params[:custom_fields]
116 if params[:custom_fields]
117 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
117 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
118 @project.custom_values = @custom_values
118 @project.custom_values = @custom_values
119 end
119 end
120 if params[:repository_enabled]
120 if params[:repository_enabled]
121 case params[:repository_enabled]
121 case params[:repository_enabled]
122 when "0"
122 when "0"
123 @project.repository = nil
123 @project.repository = nil
124 when "1"
124 when "1"
125 @project.repository ||= Repository.factory(params[:repository_scm])
125 @project.repository ||= Repository.factory(params[:repository_scm])
126 @project.repository.update_attributes params[:repository] if @project.repository
126 @project.repository.update_attributes params[:repository] if @project.repository
127 end
127 end
128 end
128 end
129 if params[:wiki_enabled]
129 if params[:wiki_enabled]
130 case params[:wiki_enabled]
130 case params[:wiki_enabled]
131 when "0"
131 when "0"
132 @project.wiki.destroy if @project.wiki
132 @project.wiki.destroy if @project.wiki
133 when "1"
133 when "1"
134 @project.wiki ||= Wiki.new
134 @project.wiki ||= Wiki.new
135 @project.wiki.update_attributes params[:wiki]
135 @project.wiki.update_attributes params[:wiki]
136 end
136 end
137 end
137 end
138 @project.attributes = params[:project]
138 @project.attributes = params[:project]
139 if @project.save
139 if @project.save
140 flash[:notice] = l(:notice_successful_update)
140 flash[:notice] = l(:notice_successful_update)
141 redirect_to :action => 'settings', :id => @project
141 redirect_to :action => 'settings', :id => @project
142 else
142 else
143 settings
143 settings
144 render :action => 'settings'
144 render :action => 'settings'
145 end
145 end
146 end
146 end
147 end
147 end
148
148
149 def archive
149 def archive
150 @project.archive if request.post? && @project.active?
150 @project.archive if request.post? && @project.active?
151 redirect_to :controller => 'admin', :action => 'projects'
151 redirect_to :controller => 'admin', :action => 'projects'
152 end
152 end
153
153
154 def unarchive
154 def unarchive
155 @project.unarchive if request.post? && !@project.active?
155 @project.unarchive if request.post? && !@project.active?
156 redirect_to :controller => 'admin', :action => 'projects'
156 redirect_to :controller => 'admin', :action => 'projects'
157 end
157 end
158
158
159 # Delete @project
159 # Delete @project
160 def destroy
160 def destroy
161 @project_to_destroy = @project
161 @project_to_destroy = @project
162 if request.post? and params[:confirm]
162 if request.post? and params[:confirm]
163 @project_to_destroy.destroy
163 @project_to_destroy.destroy
164 redirect_to :controller => 'admin', :action => 'projects'
164 redirect_to :controller => 'admin', :action => 'projects'
165 end
165 end
166 # hide project in layout
166 # hide project in layout
167 @project = nil
167 @project = nil
168 end
168 end
169
169
170 # Add a new issue category to @project
170 # Add a new issue category to @project
171 def add_issue_category
171 def add_issue_category
172 @category = @project.issue_categories.build(params[:category])
172 @category = @project.issue_categories.build(params[:category])
173 if request.post? and @category.save
173 if request.post? and @category.save
174 respond_to do |format|
174 respond_to do |format|
175 format.html do
175 format.html do
176 flash[:notice] = l(:notice_successful_create)
176 flash[:notice] = l(:notice_successful_create)
177 redirect_to :action => 'settings', :tab => 'categories', :id => @project
177 redirect_to :action => 'settings', :tab => 'categories', :id => @project
178 end
178 end
179 format.js do
179 format.js do
180 # IE doesn't support the replace_html rjs method for select box options
180 # IE doesn't support the replace_html rjs method for select box options
181 render(:update) {|page| page.replace "issue_category_id",
181 render(:update) {|page| page.replace "issue_category_id",
182 content_tag('select', '<option></option>' + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]')
182 content_tag('select', '<option></option>' + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]')
183 }
183 }
184 end
184 end
185 end
185 end
186 end
186 end
187 end
187 end
188
188
189 # Add a new version to @project
189 # Add a new version to @project
190 def add_version
190 def add_version
191 @version = @project.versions.build(params[:version])
191 @version = @project.versions.build(params[:version])
192 if request.post? and @version.save
192 if request.post? and @version.save
193 flash[:notice] = l(:notice_successful_create)
193 flash[:notice] = l(:notice_successful_create)
194 redirect_to :action => 'settings', :tab => 'versions', :id => @project
194 redirect_to :action => 'settings', :tab => 'versions', :id => @project
195 end
195 end
196 end
196 end
197
197
198 # Add a new member to @project
198 # Add a new member to @project
199 def add_member
199 def add_member
200 @member = @project.members.build(params[:member])
200 @member = @project.members.build(params[:member])
201 if request.post? && @member.save
201 if request.post? && @member.save
202 respond_to do |format|
202 respond_to do |format|
203 format.html { redirect_to :action => 'settings', :tab => 'members', :id => @project }
203 format.html { redirect_to :action => 'settings', :tab => 'members', :id => @project }
204 format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'members'} }
204 format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'members'} }
205 end
205 end
206 else
206 else
207 settings
207 settings
208 render :action => 'settings'
208 render :action => 'settings'
209 end
209 end
210 end
210 end
211
211
212 # Show members list of @project
212 # Show members list of @project
213 def list_members
213 def list_members
214 @members = @project.members.find(:all)
214 @members = @project.members.find(:all)
215 end
215 end
216
216
217 # Add a new document to @project
217 # Add a new document to @project
218 def add_document
218 def add_document
219 @categories = Enumeration::get_values('DCAT')
219 @categories = Enumeration::get_values('DCAT')
220 @document = @project.documents.build(params[:document])
220 @document = @project.documents.build(params[:document])
221 if request.post? and @document.save
221 if request.post? and @document.save
222 # Save the attachments
222 # Save the attachments
223 params[:attachments].each { |a|
223 params[:attachments].each { |a|
224 Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0
224 Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0
225 } if params[:attachments] and params[:attachments].is_a? Array
225 } if params[:attachments] and params[:attachments].is_a? Array
226 flash[:notice] = l(:notice_successful_create)
226 flash[:notice] = l(:notice_successful_create)
227 Mailer.deliver_document_add(@document) #if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
227 Mailer.deliver_document_add(@document) #if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
228 redirect_to :action => 'list_documents', :id => @project
228 redirect_to :action => 'list_documents', :id => @project
229 end
229 end
230 end
230 end
231
231
232 # Show documents list of @project
232 # Show documents list of @project
233 def list_documents
233 def list_documents
234 @documents = @project.documents.find :all, :include => :category
234 @documents = @project.documents.find :all, :include => :category
235 end
235 end
236
236
237 # Add a new issue to @project
237 # Add a new issue to @project
238 def add_issue
238 def add_issue
239 @tracker = Tracker.find(params[:tracker_id])
239 @tracker = Tracker.find(params[:tracker_id])
240 @priorities = Enumeration::get_values('IPRI')
240 @priorities = Enumeration::get_values('IPRI')
241
241
242 default_status = IssueStatus.default
242 default_status = IssueStatus.default
243 unless default_status
243 unless default_status
244 flash.now[:error] = 'No default issue status defined. Please check your configuration.'
244 flash.now[:error] = 'No default issue status defined. Please check your configuration.'
245 render :nothing => true, :layout => true
245 render :nothing => true, :layout => true
246 return
246 return
247 end
247 end
248 @issue = Issue.new(:project => @project, :tracker => @tracker)
248 @issue = Issue.new(:project => @project, :tracker => @tracker)
249 @issue.status = default_status
249 @issue.status = default_status
250 @allowed_statuses = ([default_status] + default_status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker))if logged_in_user
250 @allowed_statuses = ([default_status] + default_status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker))if logged_in_user
251 if request.get?
251 if request.get?
252 @issue.start_date = Date.today
252 @issue.start_date = Date.today
253 @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) }
253 @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) }
254 else
254 else
255 @issue.attributes = params[:issue]
255 @issue.attributes = params[:issue]
256
256
257 requested_status = IssueStatus.find_by_id(params[:issue][:status_id])
257 requested_status = IssueStatus.find_by_id(params[:issue][:status_id])
258 @issue.status = (@allowed_statuses.include? requested_status) ? requested_status : default_status
258 @issue.status = (@allowed_statuses.include? requested_status) ? requested_status : default_status
259
259
260 @issue.author_id = self.logged_in_user.id if self.logged_in_user
260 @issue.author_id = self.logged_in_user.id if self.logged_in_user
261 # Multiple file upload
261 # Multiple file upload
262 @attachments = []
262 @attachments = []
263 params[:attachments].each { |a|
263 params[:attachments].each { |a|
264 @attachments << Attachment.new(:container => @issue, :file => a, :author => logged_in_user) unless a.size == 0
264 @attachments << Attachment.new(:container => @issue, :file => a, :author => logged_in_user) unless a.size == 0
265 } if params[:attachments] and params[:attachments].is_a? Array
265 } if params[:attachments] and params[:attachments].is_a? Array
266 @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]) }
266 @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]) }
267 @issue.custom_values = @custom_values
267 @issue.custom_values = @custom_values
268 if @issue.save
268 if @issue.save
269 @attachments.each(&:save)
269 @attachments.each(&:save)
270 flash[:notice] = l(:notice_successful_create)
270 flash[:notice] = l(:notice_successful_create)
271 Mailer.deliver_issue_add(@issue) #if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
271 Mailer.deliver_issue_add(@issue) #if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
272 redirect_to :action => 'list_issues', :id => @project
272 redirect_to :action => 'list_issues', :id => @project
273 end
273 end
274 end
274 end
275 end
275 end
276
276
277 # Show filtered/sorted issues list of @project
277 # Show filtered/sorted issues list of @project
278 def list_issues
278 def list_issues
279 sort_init "#{Issue.table_name}.id", "desc"
279 sort_init "#{Issue.table_name}.id", "desc"
280 sort_update
280 sort_update
281
281
282 retrieve_query
282 retrieve_query
283
283
284 @results_per_page_options = [ 15, 25, 50, 100 ]
284 @results_per_page_options = [ 15, 25, 50, 100 ]
285 if params[:per_page] and @results_per_page_options.include? params[:per_page].to_i
285 if params[:per_page] and @results_per_page_options.include? params[:per_page].to_i
286 @results_per_page = params[:per_page].to_i
286 @results_per_page = params[:per_page].to_i
287 session[:results_per_page] = @results_per_page
287 session[:results_per_page] = @results_per_page
288 else
288 else
289 @results_per_page = session[:results_per_page] || 25
289 @results_per_page = session[:results_per_page] || 25
290 end
290 end
291
291
292 if @query.valid?
292 if @query.valid?
293 @issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement)
293 @issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement)
294 @issue_pages = Paginator.new self, @issue_count, @results_per_page, params['page']
294 @issue_pages = Paginator.new self, @issue_count, @results_per_page, params['page']
295 @issues = Issue.find :all, :order => sort_clause,
295 @issues = Issue.find :all, :order => sort_clause,
296 :include => [ :assigned_to, :status, :tracker, :project, :priority ],
296 :include => [ :assigned_to, :status, :tracker, :project, :priority ],
297 :conditions => @query.statement,
297 :conditions => @query.statement,
298 :limit => @issue_pages.items_per_page,
298 :limit => @issue_pages.items_per_page,
299 :offset => @issue_pages.current.offset
299 :offset => @issue_pages.current.offset
300 end
300 end
301 render :layout => false if request.xhr?
301 render :layout => false if request.xhr?
302 end
302 end
303
303
304 # Export filtered/sorted issues list to CSV
304 # Export filtered/sorted issues list to CSV
305 def export_issues_csv
305 def export_issues_csv
306 sort_init "#{Issue.table_name}.id", "desc"
306 sort_init "#{Issue.table_name}.id", "desc"
307 sort_update
307 sort_update
308
308
309 retrieve_query
309 retrieve_query
310 render :action => 'list_issues' and return unless @query.valid?
310 render :action => 'list_issues' and return unless @query.valid?
311
311
312 @issues = Issue.find :all, :order => sort_clause,
312 @issues = Issue.find :all, :order => sort_clause,
313 :include => [ :assigned_to, :author, :status, :tracker, :priority, :project, {:custom_values => :custom_field} ],
313 :include => [ :assigned_to, :author, :status, :tracker, :priority, :project, {:custom_values => :custom_field} ],
314 :conditions => @query.statement,
314 :conditions => @query.statement,
315 :limit => Setting.issues_export_limit.to_i
315 :limit => Setting.issues_export_limit.to_i
316
316
317 ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
317 ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
318 export = StringIO.new
318 export = StringIO.new
319 CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
319 CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
320 # csv header fields
320 # csv header fields
321 headers = [ "#", l(:field_status),
321 headers = [ "#", l(:field_status),
322 l(:field_project),
322 l(:field_project),
323 l(:field_tracker),
323 l(:field_tracker),
324 l(:field_priority),
324 l(:field_priority),
325 l(:field_subject),
325 l(:field_subject),
326 l(:field_assigned_to),
326 l(:field_assigned_to),
327 l(:field_author),
327 l(:field_author),
328 l(:field_start_date),
328 l(:field_start_date),
329 l(:field_due_date),
329 l(:field_due_date),
330 l(:field_done_ratio),
330 l(:field_done_ratio),
331 l(:field_created_on),
331 l(:field_created_on),
332 l(:field_updated_on)
332 l(:field_updated_on)
333 ]
333 ]
334 for custom_field in @project.all_custom_fields
334 for custom_field in @project.all_custom_fields
335 headers << custom_field.name
335 headers << custom_field.name
336 end
336 end
337 csv << headers.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
337 csv << headers.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
338 # csv lines
338 # csv lines
339 @issues.each do |issue|
339 @issues.each do |issue|
340 fields = [issue.id, issue.status.name,
340 fields = [issue.id, issue.status.name,
341 issue.project.name,
341 issue.project.name,
342 issue.tracker.name,
342 issue.tracker.name,
343 issue.priority.name,
343 issue.priority.name,
344 issue.subject,
344 issue.subject,
345 (issue.assigned_to ? issue.assigned_to.name : ""),
345 (issue.assigned_to ? issue.assigned_to.name : ""),
346 issue.author.name,
346 issue.author.name,
347 issue.start_date ? l_date(issue.start_date) : nil,
347 issue.start_date ? l_date(issue.start_date) : nil,
348 issue.due_date ? l_date(issue.due_date) : nil,
348 issue.due_date ? l_date(issue.due_date) : nil,
349 issue.done_ratio,
349 issue.done_ratio,
350 l_datetime(issue.created_on),
350 l_datetime(issue.created_on),
351 l_datetime(issue.updated_on)
351 l_datetime(issue.updated_on)
352 ]
352 ]
353 for custom_field in @project.all_custom_fields
353 for custom_field in @project.all_custom_fields
354 fields << (show_value issue.custom_value_for(custom_field))
354 fields << (show_value issue.custom_value_for(custom_field))
355 end
355 end
356 csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
356 csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
357 end
357 end
358 end
358 end
359 export.rewind
359 export.rewind
360 send_data(export.read, :type => 'text/csv; header=present', :filename => 'export.csv')
360 send_data(export.read, :type => 'text/csv; header=present', :filename => 'export.csv')
361 end
361 end
362
362
363 # Export filtered/sorted issues to PDF
363 # Export filtered/sorted issues to PDF
364 def export_issues_pdf
364 def export_issues_pdf
365 sort_init "#{Issue.table_name}.id", "desc"
365 sort_init "#{Issue.table_name}.id", "desc"
366 sort_update
366 sort_update
367
367
368 retrieve_query
368 retrieve_query
369 render :action => 'list_issues' and return unless @query.valid?
369 render :action => 'list_issues' and return unless @query.valid?
370
370
371 @issues = Issue.find :all, :order => sort_clause,
371 @issues = Issue.find :all, :order => sort_clause,
372 :include => [ :author, :status, :tracker, :priority, :project ],
372 :include => [ :author, :status, :tracker, :priority, :project ],
373 :conditions => @query.statement,
373 :conditions => @query.statement,
374 :limit => Setting.issues_export_limit.to_i
374 :limit => Setting.issues_export_limit.to_i
375
375
376 @options_for_rfpdf ||= {}
376 @options_for_rfpdf ||= {}
377 @options_for_rfpdf[:file_name] = "export.pdf"
377 @options_for_rfpdf[:file_name] = "export.pdf"
378 render :layout => false
378 render :layout => false
379 end
379 end
380
380
381 def move_issues
381 def move_issues
382 @issues = @project.issues.find(params[:issue_ids]) if params[:issue_ids]
382 @issues = @project.issues.find(params[:issue_ids]) if params[:issue_ids]
383 redirect_to :action => 'list_issues', :id => @project and return unless @issues
383 redirect_to :action => 'list_issues', :id => @project and return unless @issues
384 @projects = []
384 @projects = []
385 # find projects to which the user is allowed to move the issue
385 # find projects to which the user is allowed to move the issue
386 User.current.memberships.each {|m| @projects << m.project if m.role.allowed_to?(:controller => 'projects', :action => 'move_issues')}
386 User.current.memberships.each {|m| @projects << m.project if m.role.allowed_to?(:controller => 'projects', :action => 'move_issues')}
387 # issue can be moved to any tracker
387 # issue can be moved to any tracker
388 @trackers = Tracker.find(:all)
388 @trackers = Tracker.find(:all)
389 if request.post? and params[:new_project_id] and params[:new_tracker_id]
389 if request.post? and params[:new_project_id] and params[:new_tracker_id]
390 new_project = Project.find_by_id(params[:new_project_id])
390 new_project = Project.find_by_id(params[:new_project_id])
391 new_tracker = Tracker.find_by_id(params[:new_tracker_id])
391 new_tracker = Tracker.find_by_id(params[:new_tracker_id])
392 @issues.each do |i|
392 @issues.each do |i|
393 if new_project && i.project_id != new_project.id
393 if new_project && i.project_id != new_project.id
394 # issue is moved to another project
394 # issue is moved to another project
395 i.category = nil
395 i.category = nil
396 i.fixed_version = nil
396 i.fixed_version = nil
397 # delete issue relations
397 # delete issue relations
398 i.relations_from.clear
398 i.relations_from.clear
399 i.relations_to.clear
399 i.relations_to.clear
400 i.project = new_project
400 i.project = new_project
401 end
401 end
402 if new_tracker
402 if new_tracker
403 i.tracker = new_tracker
403 i.tracker = new_tracker
404 end
404 end
405 i.save
405 i.save
406 end
406 end
407 flash[:notice] = l(:notice_successful_update)
407 flash[:notice] = l(:notice_successful_update)
408 redirect_to :action => 'list_issues', :id => @project
408 redirect_to :action => 'list_issues', :id => @project
409 end
409 end
410 end
410 end
411
411
412 # Add a news to @project
412 # Add a news to @project
413 def add_news
413 def add_news
414 @news = News.new(:project => @project)
414 @news = News.new(:project => @project)
415 if request.post?
415 if request.post?
416 @news.attributes = params[:news]
416 @news.attributes = params[:news]
417 @news.author_id = self.logged_in_user.id if self.logged_in_user
417 @news.author_id = self.logged_in_user.id if self.logged_in_user
418 if @news.save
418 if @news.save
419 flash[:notice] = l(:notice_successful_create)
419 flash[:notice] = l(:notice_successful_create)
420 redirect_to :action => 'list_news', :id => @project
420 redirect_to :action => 'list_news', :id => @project
421 end
421 end
422 end
422 end
423 end
423 end
424
424
425 # Show news list of @project
425 # Show news list of @project
426 def list_news
426 def list_news
427 @news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "#{News.table_name}.created_on DESC"
427 @news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "#{News.table_name}.created_on DESC"
428
428
429 respond_to do |format|
429 respond_to do |format|
430 format.html { render :layout => false if request.xhr? }
430 format.html { render :layout => false if request.xhr? }
431 format.atom { render_feed(@news, :title => "#{@project.name}: #{l(:label_news_plural)}") }
431 format.atom { render_feed(@news, :title => "#{@project.name}: #{l(:label_news_plural)}") }
432 end
432 end
433 end
433 end
434
434
435 def add_file
435 def add_file
436 if request.post?
436 if request.post?
437 @version = @project.versions.find_by_id(params[:version_id])
437 @version = @project.versions.find_by_id(params[:version_id])
438 # Save the attachments
438 # Save the attachments
439 @attachments = []
439 @attachments = []
440 params[:attachments].each { |file|
440 params[:attachments].each { |file|
441 next unless file.size > 0
441 next unless file.size > 0
442 a = Attachment.create(:container => @version, :file => file, :author => logged_in_user)
442 a = Attachment.create(:container => @version, :file => file, :author => logged_in_user)
443 @attachments << a unless a.new_record?
443 @attachments << a unless a.new_record?
444 } if params[:attachments] and params[:attachments].is_a? Array
444 } if params[:attachments] and params[:attachments].is_a? Array
445 Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? #and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
445 Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? #and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
446 redirect_to :controller => 'projects', :action => 'list_files', :id => @project
446 redirect_to :controller => 'projects', :action => 'list_files', :id => @project
447 end
447 end
448 @versions = @project.versions.sort
448 @versions = @project.versions.sort
449 end
449 end
450
450
451 def list_files
451 def list_files
452 @versions = @project.versions.sort
452 @versions = @project.versions.sort
453 end
453 end
454
454
455 # Show changelog for @project
455 # Show changelog for @project
456 def changelog
456 def changelog
457 @trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position')
457 @trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position')
458 retrieve_selected_tracker_ids(@trackers)
458 retrieve_selected_tracker_ids(@trackers)
459 @versions = @project.versions.sort
459 @versions = @project.versions.sort
460 end
460 end
461
461
462 def roadmap
462 def roadmap
463 @trackers = Tracker.find(:all, :conditions => ["is_in_roadmap=?", true], :order => 'position')
463 @trackers = Tracker.find(:all, :conditions => ["is_in_roadmap=?", true], :order => 'position')
464 retrieve_selected_tracker_ids(@trackers)
464 retrieve_selected_tracker_ids(@trackers)
465 @versions = @project.versions.sort
465 @versions = @project.versions.sort
466 @versions = @versions.select {|v| !v.completed? } unless params[:completed]
466 @versions = @versions.select {|v| !v.completed? } unless params[:completed]
467 end
467 end
468
468
469 def activity
469 def activity
470 if params[:year] and params[:year].to_i > 1900
470 if params[:year] and params[:year].to_i > 1900
471 @year = params[:year].to_i
471 @year = params[:year].to_i
472 if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
472 if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
473 @month = params[:month].to_i
473 @month = params[:month].to_i
474 end
474 end
475 end
475 end
476 @year ||= Date.today.year
476 @year ||= Date.today.year
477 @month ||= Date.today.month
477 @month ||= Date.today.month
478
478
479 case params[:format]
479 case params[:format]
480 when 'rss'
480 when 'rss'
481 # 30 last days
481 # 30 last days
482 @date_from = Date.today - 30
482 @date_from = Date.today - 30
483 @date_to = Date.today + 1
483 @date_to = Date.today + 1
484 else
484 else
485 # current month
485 # current month
486 @date_from = Date.civil(@year, @month, 1)
486 @date_from = Date.civil(@year, @month, 1)
487 @date_to = @date_from >> 1
487 @date_to = @date_from >> 1
488 end
488 end
489
489
490 @event_types = %w(issues news attachments documents wiki_edits revisions)
490 @event_types = %w(issues news attachments documents wiki_edits revisions)
491 @event_types.delete('wiki_edits') unless @project.wiki
491 @event_types.delete('wiki_edits') unless @project.wiki
492 @event_types.delete('changesets') unless @project.repository
492 @event_types.delete('changesets') unless @project.repository
493
493
494 @scope = @event_types.select {|t| params["show_#{t}"]}
494 @scope = @event_types.select {|t| params["show_#{t}"]}
495 # default events if none is specified in parameters
495 # default events if none is specified in parameters
496 @scope = (@event_types - %w(wiki_edits))if @scope.empty?
496 @scope = (@event_types - %w(wiki_edits))if @scope.empty?
497
497
498 @events = []
498 @events = []
499
499
500 if @scope.include?('issues')
500 if @scope.include?('issues')
501 @events += @project.issues.find(:all, :include => [:author, :tracker], :conditions => ["#{Issue.table_name}.created_on>=? and #{Issue.table_name}.created_on<=?", @date_from, @date_to] )
501 @events += @project.issues.find(:all, :include => [:author, :tracker], :conditions => ["#{Issue.table_name}.created_on>=? and #{Issue.table_name}.created_on<=?", @date_from, @date_to] )
502 end
502 end
503
503
504 if @scope.include?('news')
504 if @scope.include?('news')
505 @events += @project.news.find(:all, :conditions => ["#{News.table_name}.created_on>=? and #{News.table_name}.created_on<=?", @date_from, @date_to], :include => :author )
505 @events += @project.news.find(:all, :conditions => ["#{News.table_name}.created_on>=? and #{News.table_name}.created_on<=?", @date_from, @date_to], :include => :author )
506 end
506 end
507
507
508 if @scope.include?('attachments')
508 if @scope.include?('attachments')
509 @events += Attachment.find(:all, :select => "#{Attachment.table_name}.*", :joins => "LEFT JOIN #{Version.table_name} ON #{Version.table_name}.id = #{Attachment.table_name}.container_id", :conditions => ["#{Attachment.table_name}.container_type='Version' and #{Version.table_name}.project_id=? and #{Attachment.table_name}.created_on>=? and #{Attachment.table_name}.created_on<=?", @project.id, @date_from, @date_to], :include => :author )
509 @events += Attachment.find(:all, :select => "#{Attachment.table_name}.*", :joins => "LEFT JOIN #{Version.table_name} ON #{Version.table_name}.id = #{Attachment.table_name}.container_id", :conditions => ["#{Attachment.table_name}.container_type='Version' and #{Version.table_name}.project_id=? and #{Attachment.table_name}.created_on>=? and #{Attachment.table_name}.created_on<=?", @project.id, @date_from, @date_to], :include => :author )
510 end
510 end
511
511
512 if @scope.include?('documents')
512 if @scope.include?('documents')
513 @events += @project.documents.find(:all, :conditions => ["#{Document.table_name}.created_on>=? and #{Document.table_name}.created_on<=?", @date_from, @date_to] )
513 @events += @project.documents.find(:all, :conditions => ["#{Document.table_name}.created_on>=? and #{Document.table_name}.created_on<=?", @date_from, @date_to] )
514 @events += Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN #{Document.table_name} ON #{Document.table_name}.id = #{Attachment.table_name}.container_id", :conditions => ["#{Attachment.table_name}.container_type='Document' and #{Document.table_name}.project_id=? and #{Attachment.table_name}.created_on>=? and #{Attachment.table_name}.created_on<=?", @project.id, @date_from, @date_to], :include => :author )
514 @events += Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN #{Document.table_name} ON #{Document.table_name}.id = #{Attachment.table_name}.container_id", :conditions => ["#{Attachment.table_name}.container_type='Document' and #{Document.table_name}.project_id=? and #{Attachment.table_name}.created_on>=? and #{Attachment.table_name}.created_on<=?", @project.id, @date_from, @date_to], :include => :author )
515 end
515 end
516
516
517 if @scope.include?('wiki_edits') && @project.wiki
517 if @scope.include?('wiki_edits') && @project.wiki
518 select = "#{WikiContent.versioned_table_name}.updated_on, #{WikiContent.versioned_table_name}.comments, " +
518 select = "#{WikiContent.versioned_table_name}.updated_on, #{WikiContent.versioned_table_name}.comments, " +
519 "#{WikiContent.versioned_table_name}.#{WikiContent.version_column}, #{WikiPage.table_name}.title, " +
519 "#{WikiContent.versioned_table_name}.#{WikiContent.version_column}, #{WikiPage.table_name}.title, " +
520 "#{WikiContent.versioned_table_name}.page_id, #{WikiContent.versioned_table_name}.author_id, " +
520 "#{WikiContent.versioned_table_name}.page_id, #{WikiContent.versioned_table_name}.author_id, " +
521 "#{WikiContent.versioned_table_name}.id"
521 "#{WikiContent.versioned_table_name}.id"
522 joins = "LEFT JOIN #{WikiPage.table_name} ON #{WikiPage.table_name}.id = #{WikiContent.versioned_table_name}.page_id " +
522 joins = "LEFT JOIN #{WikiPage.table_name} ON #{WikiPage.table_name}.id = #{WikiContent.versioned_table_name}.page_id " +
523 "LEFT JOIN #{Wiki.table_name} ON #{Wiki.table_name}.id = #{WikiPage.table_name}.wiki_id "
523 "LEFT JOIN #{Wiki.table_name} ON #{Wiki.table_name}.id = #{WikiPage.table_name}.wiki_id "
524 conditions = ["#{Wiki.table_name}.project_id = ? AND #{WikiContent.versioned_table_name}.updated_on BETWEEN ? AND ?",
524 conditions = ["#{Wiki.table_name}.project_id = ? AND #{WikiContent.versioned_table_name}.updated_on BETWEEN ? AND ?",
525 @project.id, @date_from, @date_to]
525 @project.id, @date_from, @date_to]
526
526
527 @events += WikiContent.versioned_class.find(:all, :select => select, :joins => joins, :conditions => conditions)
527 @events += WikiContent.versioned_class.find(:all, :select => select, :joins => joins, :conditions => conditions)
528 end
528 end
529
529
530 if @scope.include?('revisions') && @project.repository
530 if @scope.include?('revisions') && @project.repository
531 @events += @project.repository.changesets.find(:all, :conditions => ["#{Changeset.table_name}.committed_on BETWEEN ? AND ?", @date_from, @date_to])
531 @events += @project.repository.changesets.find(:all, :conditions => ["#{Changeset.table_name}.committed_on BETWEEN ? AND ?", @date_from, @date_to])
532 end
532 end
533
533
534 @events_by_day = @events.group_by(&:event_date)
534 @events_by_day = @events.group_by(&:event_date)
535
535
536 respond_to do |format|
536 respond_to do |format|
537 format.html { render :layout => false if request.xhr? }
537 format.html { render :layout => false if request.xhr? }
538 format.atom { render_feed(@events, :title => "#{@project.name}: #{l(:label_activity)}") }
538 format.atom { render_feed(@events, :title => "#{@project.name}: #{l(:label_activity)}") }
539 end
539 end
540 end
540 end
541
541
542 def calendar
542 def calendar
543 @trackers = Tracker.find(:all, :order => 'position')
543 @trackers = Tracker.find(:all, :order => 'position')
544 retrieve_selected_tracker_ids(@trackers)
544 retrieve_selected_tracker_ids(@trackers)
545
545
546 if params[:year] and params[:year].to_i > 1900
546 if params[:year] and params[:year].to_i > 1900
547 @year = params[:year].to_i
547 @year = params[:year].to_i
548 if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
548 if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
549 @month = params[:month].to_i
549 @month = params[:month].to_i
550 end
550 end
551 end
551 end
552 @year ||= Date.today.year
552 @year ||= Date.today.year
553 @month ||= Date.today.month
553 @month ||= Date.today.month
554
554
555 @date_from = Date.civil(@year, @month, 1)
555 @date_from = Date.civil(@year, @month, 1)
556 @date_to = (@date_from >> 1)-1
556 @date_to = (@date_from >> 1)-1
557 # start on monday
557 # start on monday
558 @date_from = @date_from - (@date_from.cwday-1)
558 @date_from = @date_from - (@date_from.cwday-1)
559 # finish on sunday
559 # finish on sunday
560 @date_to = @date_to + (7-@date_to.cwday)
560 @date_to = @date_to + (7-@date_to.cwday)
561
561
562 @events = []
562 @events = []
563 @project.issues_with_subprojects(params[:with_subprojects]) do
563 @project.issues_with_subprojects(params[:with_subprojects]) do
564 @events += Issue.find(:all,
564 @events += Issue.find(:all,
565 :include => [:tracker, :status, :assigned_to, :priority, :project],
565 :include => [:tracker, :status, :assigned_to, :priority, :project],
566 :conditions => ["((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?)) and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')})", @date_from, @date_to, @date_from, @date_to]
566 :conditions => ["((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?)) and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')})", @date_from, @date_to, @date_from, @date_to]
567 ) unless @selected_tracker_ids.empty?
567 ) unless @selected_tracker_ids.empty?
568 end
568 end
569 @events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to])
569 @events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to])
570
570
571 @ending_events_by_days = @events.group_by {|event| event.due_date}
571 @ending_events_by_days = @events.group_by {|event| event.due_date}
572 @starting_events_by_days = @events.group_by {|event| event.start_date}
572 @starting_events_by_days = @events.group_by {|event| event.start_date}
573
573
574 render :layout => false if request.xhr?
574 render :layout => false if request.xhr?
575 end
575 end
576
576
577 def gantt
577 def gantt
578 @trackers = Tracker.find(:all, :order => 'position')
578 @trackers = Tracker.find(:all, :order => 'position')
579 retrieve_selected_tracker_ids(@trackers)
579 retrieve_selected_tracker_ids(@trackers)
580
580
581 if params[:year] and params[:year].to_i >0
581 if params[:year] and params[:year].to_i >0
582 @year_from = params[:year].to_i
582 @year_from = params[:year].to_i
583 if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12
583 if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12
584 @month_from = params[:month].to_i
584 @month_from = params[:month].to_i
585 else
585 else
586 @month_from = 1
586 @month_from = 1
587 end
587 end
588 else
588 else
589 @month_from ||= (Date.today << 1).month
589 @month_from ||= (Date.today << 1).month
590 @year_from ||= (Date.today << 1).year
590 @year_from ||= (Date.today << 1).year
591 end
591 end
592
592
593 @zoom = (params[:zoom].to_i > 0 and params[:zoom].to_i < 5) ? params[:zoom].to_i : 2
593 @zoom = (params[:zoom].to_i > 0 and params[:zoom].to_i < 5) ? params[:zoom].to_i : 2
594 @months = (params[:months].to_i > 0 and params[:months].to_i < 25) ? params[:months].to_i : 6
594 @months = (params[:months].to_i > 0 and params[:months].to_i < 25) ? params[:months].to_i : 6
595
595
596 @date_from = Date.civil(@year_from, @month_from, 1)
596 @date_from = Date.civil(@year_from, @month_from, 1)
597 @date_to = (@date_from >> @months) - 1
597 @date_to = (@date_from >> @months) - 1
598
598
599 @events = []
599 @events = []
600 @project.issues_with_subprojects(params[:with_subprojects]) do
600 @project.issues_with_subprojects(params[:with_subprojects]) do
601 @events += Issue.find(:all,
601 @events += Issue.find(:all,
602 :order => "start_date, due_date",
602 :order => "start_date, due_date",
603 :include => [:tracker, :status, :assigned_to, :priority, :project],
603 :include => [:tracker, :status, :assigned_to, :priority, :project],
604 :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 and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')}))", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to]
604 :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 and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')}))", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to]
605 ) unless @selected_tracker_ids.empty?
605 ) unless @selected_tracker_ids.empty?
606 end
606 end
607 @events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to])
607 @events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to])
608 @events.sort! {|x,y| x.start_date <=> y.start_date }
608 @events.sort! {|x,y| x.start_date <=> y.start_date }
609
609
610 if params[:format]=='pdf'
610 if params[:format]=='pdf'
611 @options_for_rfpdf ||= {}
611 @options_for_rfpdf ||= {}
612 @options_for_rfpdf[:file_name] = "#{@project.identifier}-gantt.pdf"
612 @options_for_rfpdf[:file_name] = "#{@project.identifier}-gantt.pdf"
613 render :template => "projects/gantt.rfpdf", :layout => false
613 render :template => "projects/gantt.rfpdf", :layout => false
614 elsif params[:format]=='png' && respond_to?('gantt_image')
614 elsif params[:format]=='png' && respond_to?('gantt_image')
615 image = gantt_image(@events, @date_from, @months, @zoom)
615 image = gantt_image(@events, @date_from, @months, @zoom)
616 image.format = 'PNG'
616 image.format = 'PNG'
617 send_data(image.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "#{@project.identifier}-gantt.png")
617 send_data(image.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "#{@project.identifier}-gantt.png")
618 else
618 else
619 render :template => "projects/gantt.rhtml"
619 render :template => "projects/gantt.rhtml"
620 end
620 end
621 end
621 end
622
622
623 def feeds
623 def feeds
624 @queries = @project.queries.find :all, :conditions => ["is_public=? or user_id=?", true, (logged_in_user ? logged_in_user.id : 0)]
624 @queries = @project.queries.find :all, :conditions => ["is_public=? or user_id=?", true, (logged_in_user ? logged_in_user.id : 0)]
625 @key = User.current.rss_key
625 @key = User.current.rss_key
626 end
626 end
627
627
628 private
628 private
629 # Find project of id params[:id]
629 # Find project of id params[:id]
630 # if not found, redirect to project list
630 # if not found, redirect to project list
631 # Used as a before_filter
631 # Used as a before_filter
632 def find_project
632 def find_project
633 @project = Project.find(params[:id])
633 @project = Project.find(params[:id])
634 @html_title = @project.name
635 rescue ActiveRecord::RecordNotFound
634 rescue ActiveRecord::RecordNotFound
636 render_404
635 render_404
637 end
636 end
638
637
639 def retrieve_selected_tracker_ids(selectable_trackers)
638 def retrieve_selected_tracker_ids(selectable_trackers)
640 if ids = params[:tracker_ids]
639 if ids = params[:tracker_ids]
641 @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s }
640 @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s }
642 else
641 else
643 @selected_tracker_ids = selectable_trackers.collect {|t| t.id.to_s }
642 @selected_tracker_ids = selectable_trackers.collect {|t| t.id.to_s }
644 end
643 end
645 end
644 end
646
645
647 # Retrieve query from session or build a new query
646 # Retrieve query from session or build a new query
648 def retrieve_query
647 def retrieve_query
649 if params[:query_id]
648 if params[:query_id]
650 @query = @project.queries.find(params[:query_id])
649 @query = @project.queries.find(params[:query_id])
651 @query.executed_by = logged_in_user
650 @query.executed_by = logged_in_user
652 session[:query] = @query
651 session[:query] = @query
653 else
652 else
654 if params[:set_filter] or !session[:query] or session[:query].project_id != @project.id
653 if params[:set_filter] or !session[:query] or session[:query].project_id != @project.id
655 # Give it a name, required to be valid
654 # Give it a name, required to be valid
656 @query = Query.new(:name => "_", :executed_by => logged_in_user)
655 @query = Query.new(:name => "_", :executed_by => logged_in_user)
657 @query.project = @project
656 @query.project = @project
658 if params[:fields] and params[:fields].is_a? Array
657 if params[:fields] and params[:fields].is_a? Array
659 params[:fields].each do |field|
658 params[:fields].each do |field|
660 @query.add_filter(field, params[:operators][field], params[:values][field])
659 @query.add_filter(field, params[:operators][field], params[:values][field])
661 end
660 end
662 else
661 else
663 @query.available_filters.keys.each do |field|
662 @query.available_filters.keys.each do |field|
664 @query.add_short_filter(field, params[field]) if params[field]
663 @query.add_short_filter(field, params[field]) if params[field]
665 end
664 end
666 end
665 end
667 session[:query] = @query
666 session[:query] = @query
668 else
667 else
669 @query = session[:query]
668 @query = session[:query]
670 end
669 end
671 end
670 end
672 end
671 end
673 end
672 end
@@ -1,85 +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 SearchController < ApplicationController
18 class SearchController < ApplicationController
19 layout 'base'
19 layout 'base'
20
20
21 helper :messages
21 helper :messages
22 include MessagesHelper
22 include MessagesHelper
23
23
24 def index
24 def index
25 @question = params[:q] || ""
25 @question = params[:q] || ""
26 @question.strip!
26 @question.strip!
27 @all_words = params[:all_words] || (params[:submit] ? false : true)
27 @all_words = params[:all_words] || (params[:submit] ? false : true)
28 @scope = params[:scope] || (params[:submit] ? [] : %w(projects issues changesets news documents wiki messages) )
28 @scope = params[:scope] || (params[:submit] ? [] : %w(projects issues changesets news documents wiki messages) )
29
29
30 # quick jump to an issue
30 # quick jump to an issue
31 if @scope.include?('issues') && @question.match(/^#?(\d+)$/) && Issue.find_by_id($1, :include => :project, :conditions => Project.visible_by(logged_in_user))
31 if @scope.include?('issues') && @question.match(/^#?(\d+)$/) && Issue.find_by_id($1, :include => :project, :conditions => Project.visible_by(logged_in_user))
32 redirect_to :controller => "issues", :action => "show", :id => $1
32 redirect_to :controller => "issues", :action => "show", :id => $1
33 return
33 return
34 end
34 end
35
35
36 if params[:id]
36 if params[:id]
37 find_project
37 find_project
38 return unless check_project_privacy
38 return unless check_project_privacy
39 end
39 end
40
40
41 # tokens must be at least 3 character long
41 # tokens must be at least 3 character long
42 @tokens = @question.split.uniq.select {|w| w.length > 2 }
42 @tokens = @question.split.uniq.select {|w| w.length > 2 }
43
43
44 if !@tokens.empty?
44 if !@tokens.empty?
45 # no more than 5 tokens to search for
45 # no more than 5 tokens to search for
46 @tokens.slice! 5..-1 if @tokens.size > 5
46 @tokens.slice! 5..-1 if @tokens.size > 5
47 # strings used in sql like statement
47 # strings used in sql like statement
48 like_tokens = @tokens.collect {|w| "%#{w.downcase}%"}
48 like_tokens = @tokens.collect {|w| "%#{w.downcase}%"}
49 operator = @all_words ? " AND " : " OR "
49 operator = @all_words ? " AND " : " OR "
50 limit = 10
50 limit = 10
51 @results = []
51 @results = []
52 if @project
52 if @project
53 @results += @project.issues.find(:all, :limit => limit, :include => :author, :conditions => [ (["(LOWER(subject) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'issues'
53 @results += @project.issues.find(:all, :limit => limit, :include => :author, :conditions => [ (["(LOWER(subject) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'issues'
54 Journal.with_scope :find => {:conditions => ["#{Issue.table_name}.project_id = ?", @project.id]} do
54 Journal.with_scope :find => {:conditions => ["#{Issue.table_name}.project_id = ?", @project.id]} do
55 @results += Journal.find(:all, :include => :issue, :limit => limit, :conditions => [ (["(LOWER(notes) like ? OR LOWER(notes) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ).collect(&:issue) if @scope.include? 'issues'
55 @results += Journal.find(:all, :include => :issue, :limit => limit, :conditions => [ (["(LOWER(notes) like ? OR LOWER(notes) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ).collect(&:issue) if @scope.include? 'issues'
56 end
56 end
57 @results.uniq!
57 @results.uniq!
58 @results += @project.news.find(:all, :limit => limit, :conditions => [ (["(LOWER(title) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort], :include => :author ) if @scope.include? 'news'
58 @results += @project.news.find(:all, :limit => limit, :conditions => [ (["(LOWER(title) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort], :include => :author ) if @scope.include? 'news'
59 @results += @project.documents.find(:all, :limit => limit, :conditions => [ (["(LOWER(title) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'documents'
59 @results += @project.documents.find(:all, :limit => limit, :conditions => [ (["(LOWER(title) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'documents'
60 @results += @project.wiki.pages.find(:all, :limit => limit, :include => :content, :conditions => [ (["(LOWER(title) like ? OR LOWER(text) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @project.wiki && @scope.include?('wiki')
60 @results += @project.wiki.pages.find(:all, :limit => limit, :include => :content, :conditions => [ (["(LOWER(title) like ? OR LOWER(text) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @project.wiki && @scope.include?('wiki')
61 @results += @project.repository.changesets.find(:all, :limit => limit, :conditions => [ (["(LOWER(comments) like ?)"] * like_tokens.size).join(operator), * (like_tokens).sort] ) if @project.repository && @scope.include?('changesets')
61 @results += @project.repository.changesets.find(:all, :limit => limit, :conditions => [ (["(LOWER(comments) like ?)"] * like_tokens.size).join(operator), * (like_tokens).sort] ) if @project.repository && @scope.include?('changesets')
62 Message.with_scope :find => {:conditions => ["#{Board.table_name}.project_id = ?", @project.id]} do
62 Message.with_scope :find => {:conditions => ["#{Board.table_name}.project_id = ?", @project.id]} do
63 @results += Message.find(:all, :include => :board, :limit => limit, :conditions => [ (["(LOWER(subject) like ? OR LOWER(content) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'messages'
63 @results += Message.find(:all, :include => :board, :limit => limit, :conditions => [ (["(LOWER(subject) like ? OR LOWER(content) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'messages'
64 end
64 end
65 else
65 else
66 Project.with_scope(:find => {:conditions => Project.visible_by(logged_in_user)}) do
66 Project.with_scope(:find => {:conditions => Project.visible_by(logged_in_user)}) do
67 @results += Project.find(:all, :limit => limit, :conditions => [ (["(LOWER(name) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'projects'
67 @results += Project.find(:all, :limit => limit, :conditions => [ (["(LOWER(name) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'projects'
68 end
68 end
69 # if only one project is found, user is redirected to its overview
69 # if only one project is found, user is redirected to its overview
70 redirect_to :controller => 'projects', :action => 'show', :id => @results.first and return if @results.size == 1
70 redirect_to :controller => 'projects', :action => 'show', :id => @results.first and return if @results.size == 1
71 end
71 end
72 @question = @tokens.join(" ")
72 @question = @tokens.join(" ")
73 else
73 else
74 @question = ""
74 @question = ""
75 end
75 end
76 end
76 end
77
77
78 private
78 private
79 def find_project
79 def find_project
80 @project = Project.find(params[:id])
80 @project = Project.find(params[:id])
81 @html_title = @project.name
82 rescue ActiveRecord::RecordNotFound
81 rescue ActiveRecord::RecordNotFound
83 render_404
82 render_404
84 end
83 end
85 end
84 end
@@ -1,308 +1,320
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
2 # Copyright (C) 2006-2007 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 def current_role
20 def current_role
21 @current_role ||= User.current.role_for_project(@project)
21 @current_role ||= User.current.role_for_project(@project)
22 end
22 end
23
23
24 # Return true if user is authorized for controller/action, otherwise false
24 # Return true if user is authorized for controller/action, otherwise false
25 def authorize_for(controller, action)
25 def authorize_for(controller, action)
26 User.current.allowed_to?({:controller => controller, :action => action}, @project)
26 User.current.allowed_to?({:controller => controller, :action => action}, @project)
27 end
27 end
28
28
29 # Display a link if user is authorized
29 # Display a link if user is authorized
30 def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference)
30 def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference)
31 link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action])
31 link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action])
32 end
32 end
33
33
34 # Display a link to user's account page
34 # Display a link to user's account page
35 def link_to_user(user)
35 def link_to_user(user)
36 link_to user.name, :controller => 'account', :action => 'show', :id => user
36 link_to user.name, :controller => 'account', :action => 'show', :id => user
37 end
37 end
38
38
39 def link_to_issue(issue)
39 def link_to_issue(issue)
40 link_to "#{issue.tracker.name} ##{issue.id}", :controller => "issues", :action => "show", :id => issue
40 link_to "#{issue.tracker.name} ##{issue.id}", :controller => "issues", :action => "show", :id => issue
41 end
41 end
42
42
43 def toggle_link(name, id, options={})
43 def toggle_link(name, id, options={})
44 onclick = "Element.toggle('#{id}'); "
44 onclick = "Element.toggle('#{id}'); "
45 onclick << (options[:focus] ? "Form.Element.focus('#{options[:focus]}'); " : "this.blur(); ")
45 onclick << (options[:focus] ? "Form.Element.focus('#{options[:focus]}'); " : "this.blur(); ")
46 onclick << "return false;"
46 onclick << "return false;"
47 link_to(name, "#", :onclick => onclick)
47 link_to(name, "#", :onclick => onclick)
48 end
48 end
49
49
50 def image_to_function(name, function, html_options = {})
50 def image_to_function(name, function, html_options = {})
51 html_options.symbolize_keys!
51 html_options.symbolize_keys!
52 tag(:input, html_options.merge({
52 tag(:input, html_options.merge({
53 :type => "image", :src => image_path(name),
53 :type => "image", :src => image_path(name),
54 :onclick => (html_options[:onclick] ? "#{html_options[:onclick]}; " : "") + "#{function};"
54 :onclick => (html_options[:onclick] ? "#{html_options[:onclick]}; " : "") + "#{function};"
55 }))
55 }))
56 end
56 end
57
57
58 def prompt_to_remote(name, text, param, url, html_options = {})
58 def prompt_to_remote(name, text, param, url, html_options = {})
59 html_options[:onclick] = "promptToRemote('#{text}', '#{param}', '#{url_for(url)}'); return false;"
59 html_options[:onclick] = "promptToRemote('#{text}', '#{param}', '#{url_for(url)}'); return false;"
60 link_to name, {}, html_options
60 link_to name, {}, html_options
61 end
61 end
62
62
63 def format_date(date)
63 def format_date(date)
64 return nil unless date
64 return nil unless date
65 @date_format_setting ||= Setting.date_format.to_i
65 @date_format_setting ||= Setting.date_format.to_i
66 @date_format_setting == 0 ? l_date(date) : date.strftime("%Y-%m-%d")
66 @date_format_setting == 0 ? l_date(date) : date.strftime("%Y-%m-%d")
67 end
67 end
68
68
69 def format_time(time)
69 def format_time(time)
70 return nil unless time
70 return nil unless time
71 @date_format_setting ||= Setting.date_format.to_i
71 @date_format_setting ||= Setting.date_format.to_i
72 time = time.to_time if time.is_a?(String)
72 time = time.to_time if time.is_a?(String)
73 @date_format_setting == 0 ? l_datetime(time) : (time.strftime("%Y-%m-%d") + ' ' + l_time(time))
73 @date_format_setting == 0 ? l_datetime(time) : (time.strftime("%Y-%m-%d") + ' ' + l_time(time))
74 end
74 end
75
75
76 def day_name(day)
76 def day_name(day)
77 l(:general_day_names).split(',')[day-1]
77 l(:general_day_names).split(',')[day-1]
78 end
78 end
79
79
80 def month_name(month)
80 def month_name(month)
81 l(:actionview_datehelper_select_month_names).split(',')[month-1]
81 l(:actionview_datehelper_select_month_names).split(',')[month-1]
82 end
82 end
83
83
84 def pagination_links_full(paginator, options={}, html_options={})
84 def pagination_links_full(paginator, options={}, html_options={})
85 page_param = options.delete(:page_param) || :page
85 page_param = options.delete(:page_param) || :page
86
86
87 html = ''
87 html = ''
88 html << link_to_remote(('&#171; ' + l(:label_previous)),
88 html << link_to_remote(('&#171; ' + l(:label_previous)),
89 {:update => "content", :url => options.merge(page_param => paginator.current.previous)},
89 {:update => "content", :url => options.merge(page_param => paginator.current.previous)},
90 {:href => url_for(:params => options.merge(page_param => paginator.current.previous))}) + ' ' if paginator.current.previous
90 {:href => url_for(:params => options.merge(page_param => paginator.current.previous))}) + ' ' if paginator.current.previous
91
91
92 html << (pagination_links_each(paginator, options) do |n|
92 html << (pagination_links_each(paginator, options) do |n|
93 link_to_remote(n.to_s,
93 link_to_remote(n.to_s,
94 {:url => {:params => options.merge(page_param => n)}, :update => 'content'},
94 {:url => {:params => options.merge(page_param => n)}, :update => 'content'},
95 {:href => url_for(:params => options.merge(page_param => n))})
95 {:href => url_for(:params => options.merge(page_param => n))})
96 end || '')
96 end || '')
97
97
98 html << ' ' + link_to_remote((l(:label_next) + ' &#187;'),
98 html << ' ' + link_to_remote((l(:label_next) + ' &#187;'),
99 {:update => "content", :url => options.merge(page_param => paginator.current.next)},
99 {:update => "content", :url => options.merge(page_param => paginator.current.next)},
100 {:href => url_for(:params => options.merge(page_param => paginator.current.next))}) if paginator.current.next
100 {:href => url_for(:params => options.merge(page_param => paginator.current.next))}) if paginator.current.next
101 html
101 html
102 end
102 end
103
103
104 def set_html_title(text)
105 @html_header_title = text
106 end
107
108 def html_title
109 title = []
110 title << @project.name if @project
111 title << @html_header_title
112 title << Setting.app_title
113 title.compact.join(' - ')
114 end
115
104 # format text according to system settings
116 # format text according to system settings
105 def textilizable(text, options = {})
117 def textilizable(text, options = {})
106 return "" if text.blank?
118 return "" if text.blank?
107
119
108 # when using an image link, try to use an attachment, if possible
120 # when using an image link, try to use an attachment, if possible
109 attachments = options[:attachments]
121 attachments = options[:attachments]
110 if attachments
122 if attachments
111 text = text.gsub(/!([<>=]*)(\S+\.(gif|jpg|jpeg|png))!/) do |m|
123 text = text.gsub(/!([<>=]*)(\S+\.(gif|jpg|jpeg|png))!/) do |m|
112 align = $1
124 align = $1
113 filename = $2
125 filename = $2
114 rf = Regexp.new(filename, Regexp::IGNORECASE)
126 rf = Regexp.new(filename, Regexp::IGNORECASE)
115 # search for the picture in attachments
127 # search for the picture in attachments
116 if found = attachments.detect { |att| att.filename =~ rf }
128 if found = attachments.detect { |att| att.filename =~ rf }
117 image_url = url_for :controller => 'attachments', :action => 'download', :id => found.id
129 image_url = url_for :controller => 'attachments', :action => 'download', :id => found.id
118 "!#{align}#{image_url}!"
130 "!#{align}#{image_url}!"
119 else
131 else
120 "!#{align}#{filename}!"
132 "!#{align}#{filename}!"
121 end
133 end
122 end
134 end
123 end
135 end
124
136
125 text = (Setting.text_formatting == 'textile') ?
137 text = (Setting.text_formatting == 'textile') ?
126 Redmine::WikiFormatting.to_html(text) : simple_format(auto_link(h(text)))
138 Redmine::WikiFormatting.to_html(text) : simple_format(auto_link(h(text)))
127
139
128 # different methods for formatting wiki links
140 # different methods for formatting wiki links
129 case options[:wiki_links]
141 case options[:wiki_links]
130 when :local
142 when :local
131 # used for local links to html files
143 # used for local links to html files
132 format_wiki_link = Proc.new {|project, title| "#{title}.html" }
144 format_wiki_link = Proc.new {|project, title| "#{title}.html" }
133 when :anchor
145 when :anchor
134 # used for single-file wiki export
146 # used for single-file wiki export
135 format_wiki_link = Proc.new {|project, title| "##{title}" }
147 format_wiki_link = Proc.new {|project, title| "##{title}" }
136 else
148 else
137 format_wiki_link = Proc.new {|project, title| url_for :controller => 'wiki', :action => 'index', :id => project, :page => title }
149 format_wiki_link = Proc.new {|project, title| url_for :controller => 'wiki', :action => 'index', :id => project, :page => title }
138 end
150 end
139
151
140 project = options[:project] || @project
152 project = options[:project] || @project
141
153
142 # turn wiki links into html links
154 # turn wiki links into html links
143 # example:
155 # example:
144 # [[mypage]]
156 # [[mypage]]
145 # [[mypage|mytext]]
157 # [[mypage|mytext]]
146 # wiki links can refer other project wikis, using project name or identifier:
158 # wiki links can refer other project wikis, using project name or identifier:
147 # [[project:]] -> wiki starting page
159 # [[project:]] -> wiki starting page
148 # [[project:|mytext]]
160 # [[project:|mytext]]
149 # [[project:mypage]]
161 # [[project:mypage]]
150 # [[project:mypage|mytext]]
162 # [[project:mypage|mytext]]
151 text = text.gsub(/\[\[([^\]\|]+)(\|([^\]\|]+))?\]\]/) do |m|
163 text = text.gsub(/\[\[([^\]\|]+)(\|([^\]\|]+))?\]\]/) do |m|
152 link_project = project
164 link_project = project
153 page = $1
165 page = $1
154 title = $3
166 title = $3
155 if page =~ /^([^\:]+)\:(.*)$/
167 if page =~ /^([^\:]+)\:(.*)$/
156 link_project = Project.find_by_name($1) || Project.find_by_identifier($1)
168 link_project = Project.find_by_name($1) || Project.find_by_identifier($1)
157 page = title || $2
169 page = title || $2
158 title = $1 if page.blank?
170 title = $1 if page.blank?
159 end
171 end
160
172
161 if link_project && link_project.wiki
173 if link_project && link_project.wiki
162 # check if page exists
174 # check if page exists
163 wiki_page = link_project.wiki.find_page(page)
175 wiki_page = link_project.wiki.find_page(page)
164 link_to((title || page), format_wiki_link.call(link_project, Wiki.titleize(page)),
176 link_to((title || page), format_wiki_link.call(link_project, Wiki.titleize(page)),
165 :class => ('wiki-page' + (wiki_page ? '' : ' new')))
177 :class => ('wiki-page' + (wiki_page ? '' : ' new')))
166 else
178 else
167 # project or wiki doesn't exist
179 # project or wiki doesn't exist
168 title || page
180 title || page
169 end
181 end
170 end
182 end
171
183
172 # turn issue and revision ids into links
184 # turn issue and revision ids into links
173 # example:
185 # example:
174 # #52 -> <a href="/issues/show/52">#52</a>
186 # #52 -> <a href="/issues/show/52">#52</a>
175 # r52 -> <a href="/repositories/revision/6?rev=52">r52</a> (project.id is 6)
187 # r52 -> <a href="/repositories/revision/6?rev=52">r52</a> (project.id is 6)
176 text = text.gsub(%r{([\s,-^])(#|r)(\d+)(?=[[:punct:]]|\s|<|$)}) do |m|
188 text = text.gsub(%r{([\s,-^])(#|r)(\d+)(?=[[:punct:]]|\s|<|$)}) do |m|
177 leading, otype, oid = $1, $2, $3
189 leading, otype, oid = $1, $2, $3
178 link = nil
190 link = nil
179 if otype == 'r'
191 if otype == 'r'
180 if project && (changeset = project.changesets.find_by_revision(oid))
192 if project && (changeset = project.changesets.find_by_revision(oid))
181 link = link_to("r#{oid}", {:controller => 'repositories', :action => 'revision', :id => project.id, :rev => oid}, :class => 'changeset',
193 link = link_to("r#{oid}", {:controller => 'repositories', :action => 'revision', :id => project.id, :rev => oid}, :class => 'changeset',
182 :title => truncate(changeset.comments, 100))
194 :title => truncate(changeset.comments, 100))
183 end
195 end
184 else
196 else
185 if issue = Issue.find_by_id(oid.to_i, :include => [:project, :status], :conditions => Project.visible_by(User.current))
197 if issue = Issue.find_by_id(oid.to_i, :include => [:project, :status], :conditions => Project.visible_by(User.current))
186 link = link_to("##{oid}", {:controller => 'issues', :action => 'show', :id => oid}, :class => 'issue',
198 link = link_to("##{oid}", {:controller => 'issues', :action => 'show', :id => oid}, :class => 'issue',
187 :title => "#{truncate(issue.subject, 100)} (#{issue.status.name})")
199 :title => "#{truncate(issue.subject, 100)} (#{issue.status.name})")
188 link = content_tag('del', link) if issue.closed?
200 link = content_tag('del', link) if issue.closed?
189 end
201 end
190 end
202 end
191 leading + (link || "#{otype}#{oid}")
203 leading + (link || "#{otype}#{oid}")
192 end
204 end
193
205
194 text
206 text
195 end
207 end
196
208
197 # Same as Rails' simple_format helper without using paragraphs
209 # Same as Rails' simple_format helper without using paragraphs
198 def simple_format_without_paragraph(text)
210 def simple_format_without_paragraph(text)
199 text.to_s.
211 text.to_s.
200 gsub(/\r\n?/, "\n"). # \r\n and \r -> \n
212 gsub(/\r\n?/, "\n"). # \r\n and \r -> \n
201 gsub(/\n\n+/, "<br /><br />"). # 2+ newline -> 2 br
213 gsub(/\n\n+/, "<br /><br />"). # 2+ newline -> 2 br
202 gsub(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br
214 gsub(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br
203 end
215 end
204
216
205 def error_messages_for(object_name, options = {})
217 def error_messages_for(object_name, options = {})
206 options = options.symbolize_keys
218 options = options.symbolize_keys
207 object = instance_variable_get("@#{object_name}")
219 object = instance_variable_get("@#{object_name}")
208 if object && !object.errors.empty?
220 if object && !object.errors.empty?
209 # build full_messages here with controller current language
221 # build full_messages here with controller current language
210 full_messages = []
222 full_messages = []
211 object.errors.each do |attr, msg|
223 object.errors.each do |attr, msg|
212 next if msg.nil?
224 next if msg.nil?
213 msg = msg.first if msg.is_a? Array
225 msg = msg.first if msg.is_a? Array
214 if attr == "base"
226 if attr == "base"
215 full_messages << l(msg)
227 full_messages << l(msg)
216 else
228 else
217 full_messages << "&#171; " + (l_has_string?("field_" + attr) ? l("field_" + attr) : object.class.human_attribute_name(attr)) + " &#187; " + l(msg) unless attr == "custom_values"
229 full_messages << "&#171; " + (l_has_string?("field_" + attr) ? l("field_" + attr) : object.class.human_attribute_name(attr)) + " &#187; " + l(msg) unless attr == "custom_values"
218 end
230 end
219 end
231 end
220 # retrieve custom values error messages
232 # retrieve custom values error messages
221 if object.errors[:custom_values]
233 if object.errors[:custom_values]
222 object.custom_values.each do |v|
234 object.custom_values.each do |v|
223 v.errors.each do |attr, msg|
235 v.errors.each do |attr, msg|
224 next if msg.nil?
236 next if msg.nil?
225 msg = msg.first if msg.is_a? Array
237 msg = msg.first if msg.is_a? Array
226 full_messages << "&#171; " + v.custom_field.name + " &#187; " + l(msg)
238 full_messages << "&#171; " + v.custom_field.name + " &#187; " + l(msg)
227 end
239 end
228 end
240 end
229 end
241 end
230 content_tag("div",
242 content_tag("div",
231 content_tag(
243 content_tag(
232 options[:header_tag] || "span", lwr(:gui_validation_error, full_messages.length) + ":"
244 options[:header_tag] || "span", lwr(:gui_validation_error, full_messages.length) + ":"
233 ) +
245 ) +
234 content_tag("ul", full_messages.collect { |msg| content_tag("li", msg) }),
246 content_tag("ul", full_messages.collect { |msg| content_tag("li", msg) }),
235 "id" => options[:id] || "errorExplanation", "class" => options[:class] || "errorExplanation"
247 "id" => options[:id] || "errorExplanation", "class" => options[:class] || "errorExplanation"
236 )
248 )
237 else
249 else
238 ""
250 ""
239 end
251 end
240 end
252 end
241
253
242 def lang_options_for_select(blank=true)
254 def lang_options_for_select(blank=true)
243 (blank ? [["(auto)", ""]] : []) +
255 (blank ? [["(auto)", ""]] : []) +
244 GLoc.valid_languages.collect{|lang| [ ll(lang.to_s, :general_lang_name), lang.to_s]}.sort{|x,y| x.first <=> y.first }
256 GLoc.valid_languages.collect{|lang| [ ll(lang.to_s, :general_lang_name), lang.to_s]}.sort{|x,y| x.first <=> y.first }
245 end
257 end
246
258
247 def label_tag_for(name, option_tags = nil, options = {})
259 def label_tag_for(name, option_tags = nil, options = {})
248 label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "")
260 label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "")
249 content_tag("label", label_text)
261 content_tag("label", label_text)
250 end
262 end
251
263
252 def labelled_tabular_form_for(name, object, options, &proc)
264 def labelled_tabular_form_for(name, object, options, &proc)
253 options[:html] ||= {}
265 options[:html] ||= {}
254 options[:html].store :class, "tabular"
266 options[:html].store :class, "tabular"
255 form_for(name, object, options.merge({ :builder => TabularFormBuilder, :lang => current_language}), &proc)
267 form_for(name, object, options.merge({ :builder => TabularFormBuilder, :lang => current_language}), &proc)
256 end
268 end
257
269
258 def check_all_links(form_name)
270 def check_all_links(form_name)
259 link_to_function(l(:button_check_all), "checkAll('#{form_name}', true)") +
271 link_to_function(l(:button_check_all), "checkAll('#{form_name}', true)") +
260 " | " +
272 " | " +
261 link_to_function(l(:button_uncheck_all), "checkAll('#{form_name}', false)")
273 link_to_function(l(:button_uncheck_all), "checkAll('#{form_name}', false)")
262 end
274 end
263
275
264 def calendar_for(field_id)
276 def calendar_for(field_id)
265 image_tag("calendar.png", {:id => "#{field_id}_trigger",:class => "calendar-trigger"}) +
277 image_tag("calendar.png", {:id => "#{field_id}_trigger",:class => "calendar-trigger"}) +
266 javascript_tag("Calendar.setup({inputField : '#{field_id}', ifFormat : '%Y-%m-%d', button : '#{field_id}_trigger' });")
278 javascript_tag("Calendar.setup({inputField : '#{field_id}', ifFormat : '%Y-%m-%d', button : '#{field_id}_trigger' });")
267 end
279 end
268
280
269 def wikitoolbar_for(field_id)
281 def wikitoolbar_for(field_id)
270 return '' unless Setting.text_formatting == 'textile'
282 return '' unless Setting.text_formatting == 'textile'
271 javascript_include_tag('jstoolbar') + javascript_tag("var toolbar = new jsToolBar($('#{field_id}')); toolbar.draw();")
283 javascript_include_tag('jstoolbar') + javascript_tag("var toolbar = new jsToolBar($('#{field_id}')); toolbar.draw();")
272 end
284 end
273 end
285 end
274
286
275 class TabularFormBuilder < ActionView::Helpers::FormBuilder
287 class TabularFormBuilder < ActionView::Helpers::FormBuilder
276 include GLoc
288 include GLoc
277
289
278 def initialize(object_name, object, template, options, proc)
290 def initialize(object_name, object, template, options, proc)
279 set_language_if_valid options.delete(:lang)
291 set_language_if_valid options.delete(:lang)
280 @object_name, @object, @template, @options, @proc = object_name, object, template, options, proc
292 @object_name, @object, @template, @options, @proc = object_name, object, template, options, proc
281 end
293 end
282
294
283 (field_helpers - %w(radio_button hidden_field) + %w(date_select)).each do |selector|
295 (field_helpers - %w(radio_button hidden_field) + %w(date_select)).each do |selector|
284 src = <<-END_SRC
296 src = <<-END_SRC
285 def #{selector}(field, options = {})
297 def #{selector}(field, options = {})
286 return super if options.delete :no_label
298 return super if options.delete :no_label
287 label_text = l(options[:label]) if options[:label]
299 label_text = l(options[:label]) if options[:label]
288 label_text ||= l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym)
300 label_text ||= l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym)
289 label_text << @template.content_tag("span", " *", :class => "required") if options.delete(:required)
301 label_text << @template.content_tag("span", " *", :class => "required") if options.delete(:required)
290 label = @template.content_tag("label", label_text,
302 label = @template.content_tag("label", label_text,
291 :class => (@object && @object.errors[field] ? "error" : nil),
303 :class => (@object && @object.errors[field] ? "error" : nil),
292 :for => (@object_name.to_s + "_" + field.to_s))
304 :for => (@object_name.to_s + "_" + field.to_s))
293 label + super
305 label + super
294 end
306 end
295 END_SRC
307 END_SRC
296 class_eval src, __FILE__, __LINE__
308 class_eval src, __FILE__, __LINE__
297 end
309 end
298
310
299 def select(field, choices, options = {}, html_options = {})
311 def select(field, choices, options = {}, html_options = {})
300 label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "")
312 label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "")
301 label = @template.content_tag("label", label_text,
313 label = @template.content_tag("label", label_text,
302 :class => (@object && @object.errors[field] ? "error" : nil),
314 :class => (@object && @object.errors[field] ? "error" : nil),
303 :for => (@object_name.to_s + "_" + field.to_s))
315 :for => (@object_name.to_s + "_" + field.to_s))
304 label + super
316 label + super
305 end
317 end
306
318
307 end
319 end
308
320
@@ -1,4 +1,6
1 <h2>403</h2>
1 <h2>403</h2>
2
2
3 <p><%= l(:notice_not_authorized) %></p>
3 <p><%= l(:notice_not_authorized) %></p>
4 <p><a href="javascript:history.back()">Back</a></p>
4 <p><a href="javascript:history.back()">Back</a></p>
5
6 <% set_html_title '403' %>
@@ -1,4 +1,6
1 <h2>404</h2>
1 <h2>404</h2>
2
2
3 <p><%= l(:notice_file_not_found) %></p>
3 <p><%= l(:notice_file_not_found) %></p>
4 <p><a href="javascript:history.back()">Back</a></p>
4 <p><a href="javascript:history.back()">Back</a></p>
5
6 <% set_html_title '404' %>
@@ -1,111 +1,113
1 <div class="contextual">
1 <div class="contextual">
2 <%= link_to_if_authorized l(:button_edit), {:controller => 'issues', :action => 'edit', :id => @issue}, :class => 'icon icon-edit' %>
2 <%= link_to_if_authorized l(:button_edit), {:controller => 'issues', :action => 'edit', :id => @issue}, :class => 'icon icon-edit' %>
3 <%= link_to_if_authorized l(:button_log_time), {:controller => 'timelog', :action => 'edit', :issue_id => @issue}, :class => 'icon icon-time' %>
3 <%= link_to_if_authorized l(:button_log_time), {:controller => 'timelog', :action => 'edit', :issue_id => @issue}, :class => 'icon icon-time' %>
4 <%= watcher_tag(@issue, User.current) %>
4 <%= watcher_tag(@issue, User.current) %>
5 <%= link_to_if_authorized l(:button_move), {:controller => 'projects', :action => 'move_issues', :id => @project, "issue_ids[]" => @issue.id }, :class => 'icon icon-move' %>
5 <%= link_to_if_authorized l(:button_move), {:controller => 'projects', :action => 'move_issues', :id => @project, "issue_ids[]" => @issue.id }, :class => 'icon icon-move' %>
6 <%= link_to_if_authorized l(:button_delete), {:controller => 'issues', :action => 'destroy', :id => @issue}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %>
6 <%= link_to_if_authorized l(:button_delete), {:controller => 'issues', :action => 'destroy', :id => @issue}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %>
7 </div>
7 </div>
8
8
9 <h2><%= @issue.tracker.name %> #<%= @issue.id %> - <%=h @issue.subject %></h2>
9 <h2><%= @issue.tracker.name %> #<%= @issue.id %> - <%=h @issue.subject %></h2>
10
10
11 <div class="box">
11 <div class="box">
12 <table width="100%">
12 <table width="100%">
13 <tr>
13 <tr>
14 <td style="width:15%"><b><%=l(:field_status)%> :</b></td><td style="width:35%"><%= @issue.status.name %></td>
14 <td style="width:15%"><b><%=l(:field_status)%> :</b></td><td style="width:35%"><%= @issue.status.name %></td>
15 <td style="width:15%"><b><%=l(:field_priority)%> :</b></td><td style="width:35%"><%= @issue.priority.name %></td>
15 <td style="width:15%"><b><%=l(:field_priority)%> :</b></td><td style="width:35%"><%= @issue.priority.name %></td>
16 </tr>
16 </tr>
17 <tr>
17 <tr>
18 <td><b><%=l(:field_assigned_to)%> :</b></td><td><%= @issue.assigned_to ? link_to_user(@issue.assigned_to) : "-" %></td>
18 <td><b><%=l(:field_assigned_to)%> :</b></td><td><%= @issue.assigned_to ? link_to_user(@issue.assigned_to) : "-" %></td>
19 <td><b><%=l(:field_category)%> :</b></td><td><%=h @issue.category ? @issue.category.name : "-" %></td>
19 <td><b><%=l(:field_category)%> :</b></td><td><%=h @issue.category ? @issue.category.name : "-" %></td>
20 </tr>
20 </tr>
21 <tr>
21 <tr>
22 <td><b><%=l(:field_author)%> :</b></td><td><%= link_to_user @issue.author %></td>
22 <td><b><%=l(:field_author)%> :</b></td><td><%= link_to_user @issue.author %></td>
23 <td><b><%=l(:field_start_date)%> :</b></td><td><%= format_date(@issue.start_date) %></td>
23 <td><b><%=l(:field_start_date)%> :</b></td><td><%= format_date(@issue.start_date) %></td>
24 </tr>
24 </tr>
25 <tr>
25 <tr>
26 <td><b><%=l(:field_created_on)%> :</b></td><td><%= format_date(@issue.created_on) %></td>
26 <td><b><%=l(:field_created_on)%> :</b></td><td><%= format_date(@issue.created_on) %></td>
27 <td><b><%=l(:field_due_date)%> :</b></td><td><%= format_date(@issue.due_date) %></td>
27 <td><b><%=l(:field_due_date)%> :</b></td><td><%= format_date(@issue.due_date) %></td>
28 </tr>
28 </tr>
29 <tr>
29 <tr>
30 <td><b><%=l(:field_updated_on)%> :</b></td><td><%= format_date(@issue.updated_on) %></td>
30 <td><b><%=l(:field_updated_on)%> :</b></td><td><%= format_date(@issue.updated_on) %></td>
31 <td><b><%=l(:field_done_ratio)%> :</b></td><td><%= @issue.done_ratio %> %</td>
31 <td><b><%=l(:field_done_ratio)%> :</b></td><td><%= @issue.done_ratio %> %</td>
32 </tr>
32 </tr>
33 <tr>
33 <tr>
34 <td><b><%=l(:field_fixed_version)%> :</b></td><td><%= @issue.fixed_version ? link_to_version(@issue.fixed_version) : "-" %></td>
34 <td><b><%=l(:field_fixed_version)%> :</b></td><td><%= @issue.fixed_version ? link_to_version(@issue.fixed_version) : "-" %></td>
35 <td><b><%=l(:label_spent_time)%> :</b></td>
35 <td><b><%=l(:label_spent_time)%> :</b></td>
36 <td><%= @issue.spent_hours > 0 ? (link_to lwr(:label_f_hour, @issue.spent_hours), {:controller => 'timelog', :action => 'details', :issue_id => @issue}, :class => 'icon icon-time') : "-" %></td>
36 <td><%= @issue.spent_hours > 0 ? (link_to lwr(:label_f_hour, @issue.spent_hours), {:controller => 'timelog', :action => 'details', :issue_id => @issue}, :class => 'icon icon-time') : "-" %></td>
37 </tr>
37 </tr>
38 <tr>
38 <tr>
39 <% n = 0
39 <% n = 0
40 for custom_value in @custom_values %>
40 for custom_value in @custom_values %>
41 <td valign="top"><b><%= custom_value.custom_field.name %> :</b></td><td valign="top"><%= simple_format(h(show_value(custom_value))) %></td>
41 <td valign="top"><b><%= custom_value.custom_field.name %> :</b></td><td valign="top"><%= simple_format(h(show_value(custom_value))) %></td>
42 <% n = n + 1
42 <% n = n + 1
43 if (n > 1)
43 if (n > 1)
44 n = 0 %>
44 n = 0 %>
45 </tr><tr>
45 </tr><tr>
46 <%end
46 <%end
47 end %>
47 end %>
48 </tr>
48 </tr>
49 </table>
49 </table>
50 <hr />
50 <hr />
51
51
52 <% if @issue.changesets.any? %>
52 <% if @issue.changesets.any? %>
53 <div style="float:right;">
53 <div style="float:right;">
54 <em><%= l(:label_revision_plural) %>: <%= @issue.changesets.collect{|changeset| link_to(changeset.revision, :controller => 'repositories', :action => 'revision', :id => @project, :rev => changeset.revision)}.join(", ") %></em>
54 <em><%= l(:label_revision_plural) %>: <%= @issue.changesets.collect{|changeset| link_to(changeset.revision, :controller => 'repositories', :action => 'revision', :id => @project, :rev => changeset.revision)}.join(", ") %></em>
55 </div>
55 </div>
56 <% end %>
56 <% end %>
57
57
58 <b><%=l(:field_description)%> :</b><br /><br />
58 <b><%=l(:field_description)%> :</b><br /><br />
59 <%= textilizable @issue.description, :attachments => @issue.attachments %>
59 <%= textilizable @issue.description, :attachments => @issue.attachments %>
60
60
61 <div class="contextual">
61 <div class="contextual">
62 </div>
62 </div>
63
63
64 <% if authorize_for('issues', 'change_status') and @status_options and !@status_options.empty? %>
64 <% if authorize_for('issues', 'change_status') and @status_options and !@status_options.empty? %>
65 <% form_tag({:controller => 'issues', :action => 'change_status', :id => @issue}) do %>
65 <% form_tag({:controller => 'issues', :action => 'change_status', :id => @issue}) do %>
66 <%=l(:label_change_status)%> :
66 <%=l(:label_change_status)%> :
67 <select name="new_status_id">
67 <select name="new_status_id">
68 <%= options_from_collection_for_select @status_options, "id", "name" %>
68 <%= options_from_collection_for_select @status_options, "id", "name" %>
69 </select>
69 </select>
70 <%= submit_tag l(:button_change) %>
70 <%= submit_tag l(:button_change) %>
71 <% end %>
71 <% end %>
72 <% end %>
72 <% end %>
73 </div>
73 </div>
74
74
75 <% if authorize_for('issue_relations', 'new') || @issue.relations.any? %>
75 <% if authorize_for('issue_relations', 'new') || @issue.relations.any? %>
76 <div id="relations" class="box">
76 <div id="relations" class="box">
77 <%= render :partial => 'relations' %>
77 <%= render :partial => 'relations' %>
78 </div>
78 </div>
79 <% end %>
79 <% end %>
80
80
81 <% if @issue.attachments.any? %>
81 <% if @issue.attachments.any? %>
82 <div class="box">
82 <div class="box">
83 <h3><%=l(:label_attachment_plural)%></h3>
83 <h3><%=l(:label_attachment_plural)%></h3>
84 <%= link_to_attachments @issue.attachments, :delete_url => (authorize_for('issues', 'destroy_attachment') ? {:controller => 'issues', :action => 'destroy_attachment', :id => @issue} : nil) %>
84 <%= link_to_attachments @issue.attachments, :delete_url => (authorize_for('issues', 'destroy_attachment') ? {:controller => 'issues', :action => 'destroy_attachment', :id => @issue} : nil) %>
85 </div>
85 </div>
86 <% end %>
86 <% end %>
87
87
88 <% if @journals.any? %>
88 <% if @journals.any? %>
89 <div id="history" class="box">
89 <div id="history" class="box">
90 <h3><%=l(:label_history)%></h3>
90 <h3><%=l(:label_history)%></h3>
91 <%= render :partial => 'history', :locals => { :journals => @journals } %>
91 <%= render :partial => 'history', :locals => { :journals => @journals } %>
92 </div>
92 </div>
93 <% end %>
93 <% end %>
94
94
95 <% if authorize_for('issues', 'add_note') %>
95 <% if authorize_for('issues', 'add_note') %>
96 <div class="box">
96 <div class="box">
97 <h3><%= l(:label_add_note) %></h3>
97 <h3><%= l(:label_add_note) %></h3>
98 <% form_tag({:controller => 'issues', :action => 'add_note', :id => @issue}, :class => "tabular", :multipart => true) do %>
98 <% form_tag({:controller => 'issues', :action => 'add_note', :id => @issue}, :class => "tabular", :multipart => true) do %>
99 <p><label for="notes"><%=l(:field_notes)%></label>
99 <p><label for="notes"><%=l(:field_notes)%></label>
100 <%= text_area_tag 'notes', '', :cols => 60, :rows => 10, :class => 'wiki-edit' %></p>
100 <%= text_area_tag 'notes', '', :cols => 60, :rows => 10, :class => 'wiki-edit' %></p>
101 <%= wikitoolbar_for 'notes' %>
101 <%= wikitoolbar_for 'notes' %>
102 <%= render :partial => 'attachments/form' %>
102 <%= render :partial => 'attachments/form' %>
103 <%= submit_tag l(:button_add) %>
103 <%= submit_tag l(:button_add) %>
104 <% end %>
104 <% end %>
105 </div>
105 </div>
106 <% end %>
106 <% end %>
107
107
108 <div class="contextual">
108 <div class="contextual">
109 <%= l(:label_export_to) %><%= link_to 'PDF', {:action => 'export_pdf', :id => @issue}, :class => 'icon icon-pdf' %>
109 <%= l(:label_export_to) %><%= link_to 'PDF', {:action => 'export_pdf', :id => @issue}, :class => 'icon icon-pdf' %>
110 </div>
110 </div>
111 &nbsp;
111 &nbsp;
112
113 <% set_html_title "#{@issue.tracker.name} ##{@issue.id}" %>
@@ -1,101 +1,101
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><%= Setting.app_title + (@html_title ? ": #{@html_title}" : "") %></title>
4 <title><%=h 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::Info.app_name %>" />
6 <meta name="description" content="<%= Redmine::Info.app_name %>" />
7 <meta name="keywords" content="issue,bug,tracker" />
7 <meta name="keywords" content="issue,bug,tracker" />
8 <!--[if IE]>
8 <!--[if IE]>
9 <style type="text/css">
9 <style type="text/css">
10 body {behavior: url(<%= stylesheet_path "csshover.htc" %>);}
10 body {behavior: url(<%= stylesheet_path "csshover.htc" %>);}
11 </style>
11 </style>
12 <![endif]-->
12 <![endif]-->
13 <%= stylesheet_link_tag "application" %>
13 <%= stylesheet_link_tag "application" %>
14 <%= stylesheet_link_tag "print", :media => "print" %>
14 <%= stylesheet_link_tag "print", :media => "print" %>
15 <%= javascript_include_tag :defaults %>
15 <%= javascript_include_tag :defaults %>
16 <%= javascript_include_tag 'menu' %>
16 <%= javascript_include_tag 'menu' %>
17 <%= stylesheet_link_tag 'jstoolbar' %>
17 <%= stylesheet_link_tag 'jstoolbar' %>
18 <!-- page specific tags --><%= yield :header_tags %>
18 <!-- page specific tags --><%= 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><%= Setting.app_title %></h1>
26 <h1><%= Setting.app_title %></h1>
27 <h2><%= Setting.app_subtitle %></h2>
27 <h2><%= Setting.app_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 User.current.logged? %><small><%=l(:label_logged_as)%> <strong><%= User.current.login %></strong> -</small><% end %>
30 <% if User.current.logged? %><small><%=l(:label_logged_as)%> <strong><%= User.current.login %></strong> -</small><% end %>
31 <small><%= toggle_link l(:label_search), 'quick-search-form', :focus => 'quick-search-input' %></small>
31 <small><%= toggle_link l(:label_search), 'quick-search-form', :focus => 'quick-search-input' %></small>
32 <% form_tag({:controller => 'search', :action => 'index', :id => @project}, :method => :get, :id => 'quick-search-form', :style => "display:none;" ) do %>
32 <% form_tag({:controller => 'search', :action => 'index', :id => @project}, :method => :get, :id => 'quick-search-form', :style => "display:none;" ) do %>
33 <%= text_field_tag 'q', @question, :size => 15, :class => 'small', :id => 'quick-search-input' %>
33 <%= text_field_tag 'q', @question, :size => 15, :class => 'small', :id => 'quick-search-input' %>
34 <% end %>
34 <% end %>
35 </div>
35 </div>
36 </div>
36 </div>
37
37
38 <div id="navigation">
38 <div id="navigation">
39 <ul>
39 <ul>
40 <li><%= link_to l(:label_home), { :controller => 'welcome' }, :class => "icon icon-home" %></li>
40 <li><%= link_to l(:label_home), { :controller => 'welcome' }, :class => "icon icon-home" %></li>
41 <li><%= link_to l(:label_my_page), { :controller => 'my', :action => 'page'}, :class => "icon icon-mypage" %></li>
41 <li><%= link_to l(:label_my_page), { :controller => 'my', :action => 'page'}, :class => "icon icon-mypage" %></li>
42
42
43 <% if User.current.memberships.any? %>
43 <% if User.current.memberships.any? %>
44 <li class="submenu"><%= link_to l(:label_project_plural), { :controller => 'projects' }, :class => "icon icon-projects", :onmouseover => "buttonMouseover(event, 'menuAllProjects');" %></li>
44 <li class="submenu"><%= link_to l(:label_project_plural), { :controller => 'projects' }, :class => "icon icon-projects", :onmouseover => "buttonMouseover(event, 'menuAllProjects');" %></li>
45 <% else %>
45 <% else %>
46 <li><%= link_to l(:label_project_plural), { :controller => 'projects' }, :class => "icon icon-projects" %></li>
46 <li><%= link_to l(:label_project_plural), { :controller => 'projects' }, :class => "icon icon-projects" %></li>
47 <% end %>
47 <% end %>
48
48
49 <% if User.current.logged? %>
49 <% if User.current.logged? %>
50 <li><%= link_to l(:label_my_account), { :controller => 'my', :action => 'account' }, :class => "icon icon-user" %></li>
50 <li><%= link_to l(:label_my_account), { :controller => 'my', :action => 'account' }, :class => "icon icon-user" %></li>
51 <% end %>
51 <% end %>
52
52
53 <% if User.current.admin? %>
53 <% if User.current.admin? %>
54 <li class="submenu"><%= link_to l(:label_administration), { :controller => 'admin' }, :class => "icon icon-admin", :onmouseover => "buttonMouseover(event, 'menuAdmin');" %></li>
54 <li class="submenu"><%= link_to l(:label_administration), { :controller => 'admin' }, :class => "icon icon-admin", :onmouseover => "buttonMouseover(event, 'menuAdmin');" %></li>
55 <% end %>
55 <% end %>
56
56
57 <li class="right"><%= link_to l(:label_help), { :controller => 'help', :ctrl => params[:controller], :page => params[:action] }, :onclick => "window.open(this.href); return false;", :class => "icon icon-help" %></li>
57 <li class="right"><%= link_to l(:label_help), { :controller => 'help', :ctrl => params[:controller], :page => params[:action] }, :onclick => "window.open(this.href); return false;", :class => "icon icon-help" %></li>
58
58
59 <% if User.current.logged? %>
59 <% if User.current.logged? %>
60 <li class="right"><%= link_to l(:label_logout), { :controller => 'account', :action => 'logout' }, :class => "icon icon-user" %></li>
60 <li class="right"><%= link_to l(:label_logout), { :controller => 'account', :action => 'logout' }, :class => "icon icon-user" %></li>
61 <% else %>
61 <% else %>
62 <li class="right"><%= link_to l(:label_login), { :controller => 'account', :action => 'login' }, :class => "icon icon-user" %></li>
62 <li class="right"><%= link_to l(:label_login), { :controller => 'account', :action => 'login' }, :class => "icon icon-user" %></li>
63 <% end %>
63 <% end %>
64 </ul>
64 </ul>
65 </div>
65 </div>
66
66
67 <%= render(:partial => 'admin/menu') if User.current.admin? %>
67 <%= render(:partial => 'admin/menu') if User.current.admin? %>
68 <%= render(:partial => 'layouts/projects_menu') if User.current.memberships.any? %>
68 <%= render(:partial => 'layouts/projects_menu') if User.current.memberships.any? %>
69
69
70 <div id="subcontent">
70 <div id="subcontent">
71 <% if @project && !@project.new_record? %>
71 <% if @project && !@project.new_record? %>
72 <h2><%= @project.name %></h2>
72 <h2><%= @project.name %></h2>
73 <ul class="menublock">
73 <ul class="menublock">
74 <% Redmine::MenuManager.allowed_items(:project_menu, current_role).each do |item| %>
74 <% Redmine::MenuManager.allowed_items(:project_menu, current_role).each do |item| %>
75 <% unless item.condition && !item.condition.call(@project) %>
75 <% unless item.condition && !item.condition.call(@project) %>
76 <li><%= link_to l(item.name), {item.param => @project}.merge(item.url) %></li>
76 <li><%= link_to l(item.name), {item.param => @project}.merge(item.url) %></li>
77 <% end %>
77 <% end %>
78 <% end %>
78 <% end %>
79 </ul>
79 </ul>
80 <% end %>
80 <% end %>
81 </div>
81 </div>
82
82
83 <div id="content">
83 <div id="content">
84 <div id="flash">
84 <div id="flash">
85 <%= content_tag('div', flash[:error], :class => 'error') if flash[:error] %>
85 <%= content_tag('div', flash[:error], :class => 'error') if flash[:error] %>
86 <%= content_tag('div', flash[:notice], :class => 'notice') if flash[:notice] %>
86 <%= content_tag('div', flash[:notice], :class => 'notice') if flash[:notice] %>
87 </div>
87 </div>
88 <%= yield %>
88 <%= yield %>
89 </div>
89 </div>
90
90
91 <div id="ajax-indicator" style="display:none;">
91 <div id="ajax-indicator" style="display:none;">
92 <span><%= l(:label_loading) %></span>
92 <span><%= l(:label_loading) %></span>
93 </div>
93 </div>
94
94
95 <div id="footer">
95 <div id="footer">
96 <p><%= link_to Redmine::Info.app_name, Redmine::Info.url %> <small><%= Redmine::VERSION %> &copy 2006-2007 Jean-Philippe Lang</small></p>
96 <p><%= link_to Redmine::Info.app_name, Redmine::Info.url %> <small><%= Redmine::VERSION %> &copy 2006-2007 Jean-Philippe Lang</small></p>
97 </div>
97 </div>
98
98
99 </div>
99 </div>
100 </body>
100 </body>
101 </html>
101 </html>
@@ -1,85 +1,87
1 <% if @query.new_record? %>
1 <% if @query.new_record? %>
2 <div class="contextual">
2 <div class="contextual">
3 <%= link_to l(:label_query_plural), :controller => 'queries', :project_id => @project %>
3 <%= link_to l(:label_query_plural), :controller => 'queries', :project_id => @project %>
4 <% if authorize_for('projects', 'add_issue') %>| <%= l(:label_issue_new) %>: <%= new_issue_selector %><% end %>
4 <% if authorize_for('projects', 'add_issue') %>| <%= l(:label_issue_new) %>: <%= new_issue_selector %><% end %>
5 </div>
5 </div>
6 <h2><%=l(:label_issue_plural)%></h2>
6 <h2><%=l(:label_issue_plural)%></h2>
7 <% set_html_title l(:label_issue_plural) %>
7
8
8 <% form_tag({:action => 'list_issues'}, :id => 'query_form') do %>
9 <% form_tag({:action => 'list_issues'}, :id => 'query_form') do %>
9 <%= render :partial => 'queries/filters', :locals => {:query => @query} %>
10 <%= render :partial => 'queries/filters', :locals => {:query => @query} %>
10 <% end %>
11 <% end %>
11 <div class="contextual">
12 <div class="contextual">
12 <%= link_to_remote l(:button_apply),
13 <%= link_to_remote l(:button_apply),
13 { :url => { :controller => 'projects', :action => 'list_issues', :id => @project, :set_filter => 1 },
14 { :url => { :controller => 'projects', :action => 'list_issues', :id => @project, :set_filter => 1 },
14 :update => "content",
15 :update => "content",
15 :with => "Form.serialize('query_form')"
16 :with => "Form.serialize('query_form')"
16 }, :class => 'icon icon-edit' %>
17 }, :class => 'icon icon-edit' %>
17
18
18 <%= link_to_remote l(:button_clear),
19 <%= link_to_remote l(:button_clear),
19 { :url => {:controller => 'projects', :action => 'list_issues', :id => @project, :set_filter => 1},
20 { :url => {:controller => 'projects', :action => 'list_issues', :id => @project, :set_filter => 1},
20 :update => "content",
21 :update => "content",
21 }, :class => 'icon icon-reload' %>
22 }, :class => 'icon icon-reload' %>
22
23
23 <% if current_role.allowed_to?(:save_queries) %>
24 <% if current_role.allowed_to?(:save_queries) %>
24 <%= link_to_remote l(:button_save),
25 <%= link_to_remote l(:button_save),
25 { :url => { :controller => 'queries', :action => 'new', :project_id => @project },
26 { :url => { :controller => 'queries', :action => 'new', :project_id => @project },
26 :method => 'get',
27 :method => 'get',
27 :update => "content",
28 :update => "content",
28 :with => "Form.serialize('query_form')"
29 :with => "Form.serialize('query_form')"
29 }, :class => 'icon icon-save' %>
30 }, :class => 'icon icon-save' %>
30 <% end %>
31 <% end %>
31 </div>
32 </div>
32 <br />
33 <br />
33 <% else %>
34 <% else %>
34 <div class="contextual">
35 <div class="contextual">
35 <%= link_to l(:label_query_plural), {:controller => 'queries', :project_id => @project} %> |
36 <%= link_to l(:label_query_plural), {:controller => 'queries', :project_id => @project} %> |
36 <%= link_to l(:label_issue_view_all), {:controller => 'projects', :action => 'list_issues', :id => @project, :set_filter => 1} %>
37 <%= link_to l(:label_issue_view_all), {:controller => 'projects', :action => 'list_issues', :id => @project, :set_filter => 1} %>
37 <% if authorize_for('projects', 'add_issue') %>| <%= l(:label_issue_new) %>: <%= new_issue_selector %><% end %>
38 <% if authorize_for('projects', 'add_issue') %>| <%= l(:label_issue_new) %>: <%= new_issue_selector %><% end %>
38 </div>
39 </div>
39 <h2><%= @query.name %></h2>
40 <h2><%= @query.name %></h2>
41 <% set_html_title @query.name %>
40 <% end %>
42 <% end %>
41 <%= error_messages_for 'query' %>
43 <%= error_messages_for 'query' %>
42 <% if @query.valid? %>
44 <% if @query.valid? %>
43 <% if @issues.empty? %>
45 <% if @issues.empty? %>
44 <p><i><%= l(:label_no_data) %></i></p>
46 <p><i><%= l(:label_no_data) %></i></p>
45 <% else %>
47 <% else %>
46 &nbsp;
48 &nbsp;
47 <% form_tag({:controller => 'projects', :action => 'move_issues', :id => @project}, :id => 'issues_form' ) do %>
49 <% form_tag({:controller => 'projects', :action => 'move_issues', :id => @project}, :id => 'issues_form' ) do %>
48 <table class="list">
50 <table class="list">
49 <thead><tr>
51 <thead><tr>
50 <th></th>
52 <th></th>
51 <%= sort_header_tag("#{Issue.table_name}.id", :caption => '#') %>
53 <%= sort_header_tag("#{Issue.table_name}.id", :caption => '#') %>
52 <%= sort_header_tag("#{Issue.table_name}.tracker_id", :caption => l(:field_tracker)) %>
54 <%= sort_header_tag("#{Issue.table_name}.tracker_id", :caption => l(:field_tracker)) %>
53 <%= sort_header_tag("#{IssueStatus.table_name}.name", :caption => l(:field_status)) %>
55 <%= sort_header_tag("#{IssueStatus.table_name}.name", :caption => l(:field_status)) %>
54 <%= sort_header_tag("#{Issue.table_name}.priority_id", :caption => l(:field_priority)) %>
56 <%= sort_header_tag("#{Issue.table_name}.priority_id", :caption => l(:field_priority)) %>
55 <th><%=l(:field_subject)%></th>
57 <th><%=l(:field_subject)%></th>
56 <%= sort_header_tag("#{User.table_name}.lastname", :caption => l(:field_assigned_to)) %>
58 <%= sort_header_tag("#{User.table_name}.lastname", :caption => l(:field_assigned_to)) %>
57 <%= sort_header_tag("#{Issue.table_name}.updated_on", :caption => l(:field_updated_on)) %>
59 <%= sort_header_tag("#{Issue.table_name}.updated_on", :caption => l(:field_updated_on)) %>
58 </tr></thead>
60 </tr></thead>
59 <tbody>
61 <tbody>
60 <% for issue in @issues %>
62 <% for issue in @issues %>
61 <tr class="<%= cycle("odd", "even") %>">
63 <tr class="<%= cycle("odd", "even") %>">
62 <th style="width:15px;"><%= check_box_tag "issue_ids[]", issue.id, false, :id => "issue_#{issue.id}" %></th>
64 <th style="width:15px;"><%= check_box_tag "issue_ids[]", issue.id, false, :id => "issue_#{issue.id}" %></th>
63 <td align="center"><%= link_to issue.id, :controller => 'issues', :action => 'show', :id => issue %></td>
65 <td align="center"><%= link_to issue.id, :controller => 'issues', :action => 'show', :id => issue %></td>
64 <td align="center"><%= issue.tracker.name %></td>
66 <td align="center"><%= issue.tracker.name %></td>
65 <td><div class="square" style="background:#<%= issue.status.html_color %>;"></div> <%= issue.status.name %></td>
67 <td><div class="square" style="background:#<%= issue.status.html_color %>;"></div> <%= issue.status.name %></td>
66 <td align="center"><%= issue.priority.name %></td>
68 <td align="center"><%= issue.priority.name %></td>
67 <td><%= "#{issue.project.name} - " unless @project && @project == issue.project %><%= link_to h(issue.subject), :controller => 'issues', :action => 'show', :id => issue %></td>
69 <td><%= "#{issue.project.name} - " unless @project && @project == issue.project %><%= link_to h(issue.subject), :controller => 'issues', :action => 'show', :id => issue %></td>
68 <td align="center"><%= issue.assigned_to.name if issue.assigned_to %></td>
70 <td align="center"><%= issue.assigned_to.name if issue.assigned_to %></td>
69 <td align="center"><%= format_time(issue.updated_on) %></td>
71 <td align="center"><%= format_time(issue.updated_on) %></td>
70 </tr>
72 </tr>
71 <% end %>
73 <% end %>
72 </tbody>
74 </tbody>
73 </table>
75 </table>
74 <div class="contextual">
76 <div class="contextual">
75 <%= l(:label_export_to) %>
77 <%= l(:label_export_to) %>
76 <%= link_to 'CSV', {:action => 'export_issues_csv', :id => @project}, :class => 'icon icon-csv' %>,
78 <%= link_to 'CSV', {:action => 'export_issues_csv', :id => @project}, :class => 'icon icon-csv' %>,
77 <%= link_to 'PDF', {:action => 'export_issues_pdf', :id => @project}, :class => 'icon icon-pdf' %>
79 <%= link_to 'PDF', {:action => 'export_issues_pdf', :id => @project}, :class => 'icon icon-pdf' %>
78 </div>
80 </div>
79 <p><%= submit_tag(l(:button_move), :class => "button-small") if authorize_for('projects', 'move_issues') %>
81 <p><%= submit_tag(l(:button_move), :class => "button-small") if authorize_for('projects', 'move_issues') %>
80 <%= pagination_links_full @issue_pages %>
82 <%= pagination_links_full @issue_pages %>
81 [ <%= @issue_pages.current.first_item %> - <%= @issue_pages.current.last_item %> / <%= @issue_count %> ]
83 [ <%= @issue_pages.current.first_item %> - <%= @issue_pages.current.last_item %> / <%= @issue_count %> ]
82 </p>
84 </p>
83 <% end %>
85 <% end %>
84 <% end %>
86 <% end %>
85 <% end %>
87 <% end %>
@@ -1,33 +1,35
1 <div class="contextual">
1 <div class="contextual">
2 <%= link_to(l(:label_page_index), {:action => 'special', :page => 'Page_index'}, :class => 'icon icon-index') %>
2 <%= link_to(l(:label_page_index), {:action => 'special', :page => 'Page_index'}, :class => 'icon icon-index') %>
3 </div>
3 </div>
4
4
5 <h2><%= @page.pretty_title %></h2>
5 <h2><%= @page.pretty_title %></h2>
6
6
7 <% form_for :content, @content, :url => {:action => 'edit', :page => @page.title}, :html => {:id => 'wiki_form'} do |f| %>
7 <% form_for :content, @content, :url => {:action => 'edit', :page => @page.title}, :html => {:id => 'wiki_form'} do |f| %>
8 <%= f.hidden_field :version %>
8 <%= f.hidden_field :version %>
9 <%= error_messages_for 'content' %>
9 <%= error_messages_for 'content' %>
10 <div class="contextual">
10 <div class="contextual">
11 <%= l(:setting_text_formatting) %>:
11 <%= l(:setting_text_formatting) %>:
12 <%= link_to l(:label_help), {:controller => 'help', :ctrl => 'wiki', :page => 'syntax' },
12 <%= link_to l(:label_help), {:controller => 'help', :ctrl => 'wiki', :page => 'syntax' },
13 :onclick => "window.open('#{ url_for :controller => 'help', :ctrl => 'wiki', :page => 'syntax' }', '', 'resizable=yes, location=no, width=300, height=500, menubar=no, status=no, scrollbars=yes'); return false;" %>
13 :onclick => "window.open('#{ url_for :controller => 'help', :ctrl => 'wiki', :page => 'syntax' }', '', 'resizable=yes, location=no, width=300, height=500, menubar=no, status=no, scrollbars=yes'); return false;" %>
14 </div>
14 </div>
15 <p><%= f.text_area :text, :cols => 100, :rows => 25, :class => 'wiki-edit' %></p>
15 <p><%= f.text_area :text, :cols => 100, :rows => 25, :class => 'wiki-edit' %></p>
16 <p><label><%= l(:field_comments) %></label><br /><%= f.text_field :comments, :size => 120 %></p>
16 <p><label><%= l(:field_comments) %></label><br /><%= f.text_field :comments, :size => 120 %></p>
17 <p><%= submit_tag l(:button_save) %>
17 <p><%= submit_tag l(:button_save) %>
18 <%= link_to_remote l(:label_preview),
18 <%= link_to_remote l(:label_preview),
19 { :url => { :controller => 'wiki', :action => 'preview', :id => @project, :page => @page.title },
19 { :url => { :controller => 'wiki', :action => 'preview', :id => @project, :page => @page.title },
20 :method => 'post',
20 :method => 'post',
21 :update => 'preview',
21 :update => 'preview',
22 :with => "Form.serialize('wiki_form')",
22 :with => "Form.serialize('wiki_form')",
23 :complete => "location.href='#preview-top'"
23 :complete => "location.href='#preview-top'"
24 } %></p>
24 } %></p>
25 <%= wikitoolbar_for 'content_text' %>
25 <%= wikitoolbar_for 'content_text' %>
26 <% end %>
26 <% end %>
27
27
28 <a name="preview-top"></a>
28 <a name="preview-top"></a>
29 <div id="preview" class="wiki"></div>
29 <div id="preview" class="wiki"></div>
30
30
31 <% content_for :header_tags do %>
31 <% content_for :header_tags do %>
32 <%= stylesheet_link_tag 'scm' %>
32 <%= stylesheet_link_tag 'scm' %>
33 <% end %>
33 <% end %>
34
35 <% set_html_title @page.pretty_title %>
@@ -1,43 +1,45
1 <div class="contextual">
1 <div class="contextual">
2 <%= link_to_if_authorized(l(:button_edit), {:action => 'edit', :page => @page.title}, :class => 'icon icon-edit') if @content.version == @page.content.version %>
2 <%= link_to_if_authorized(l(:button_edit), {:action => 'edit', :page => @page.title}, :class => 'icon icon-edit') if @content.version == @page.content.version %>
3 <%= link_to_if_authorized(l(:button_delete), {:action => 'destroy', :page => @page.title}, :method => :post, :confirm => l(:text_are_you_sure), :class => 'icon icon-del') %>
3 <%= link_to_if_authorized(l(:button_delete), {:action => 'destroy', :page => @page.title}, :method => :post, :confirm => l(:text_are_you_sure), :class => 'icon icon-del') %>
4 <%= link_to_if_authorized(l(:button_rollback), {:action => 'edit', :page => @page.title, :version => @content.version }, :class => 'icon icon-cancel') if @content.version < @page.content.version %>
4 <%= link_to_if_authorized(l(:button_rollback), {:action => 'edit', :page => @page.title, :version => @content.version }, :class => 'icon icon-cancel') if @content.version < @page.content.version %>
5 <%= link_to(l(:label_history), {:action => 'history', :page => @page.title}, :class => 'icon icon-history') %>
5 <%= link_to(l(:label_history), {:action => 'history', :page => @page.title}, :class => 'icon icon-history') %>
6 <%= link_to(l(:label_page_index), {:action => 'special', :page => 'Page_index'}, :class => 'icon icon-index') %>
6 <%= link_to(l(:label_page_index), {:action => 'special', :page => 'Page_index'}, :class => 'icon icon-index') %>
7 </div>
7 </div>
8
8
9 <% if @content.version != @page.content.version %>
9 <% if @content.version != @page.content.version %>
10 <p>
10 <p>
11 <%= link_to(('&#171; ' + l(:label_previous)), :action => 'index', :page => @page.title, :version => (@content.version - 1)) + " - " if @content.version > 1 %>
11 <%= link_to(('&#171; ' + l(:label_previous)), :action => 'index', :page => @page.title, :version => (@content.version - 1)) + " - " if @content.version > 1 %>
12 <%= "#{l(:label_version)} #{@content.version}/#{@page.content.version}" %>
12 <%= "#{l(:label_version)} #{@content.version}/#{@page.content.version}" %>
13 <%= '(' + link_to('diff', :controller => 'wiki', :action => 'diff', :page => @page.title, :version => @content.version) + ')' if @content.version > 1 %> -
13 <%= '(' + link_to('diff', :controller => 'wiki', :action => 'diff', :page => @page.title, :version => @content.version) + ')' if @content.version > 1 %> -
14 <%= link_to((l(:label_next) + ' &#187;'), :action => 'index', :page => @page.title, :version => (@content.version + 1)) + " - " if @content.version < @page.content.version %>
14 <%= link_to((l(:label_next) + ' &#187;'), :action => 'index', :page => @page.title, :version => (@content.version + 1)) + " - " if @content.version < @page.content.version %>
15 <%= link_to(l(:label_current_version), :action => 'index', :page => @page.title) %>
15 <%= link_to(l(:label_current_version), :action => 'index', :page => @page.title) %>
16 <br />
16 <br />
17 <em><%= @content.author ? @content.author.name : "anonyme" %>, <%= format_time(@content.updated_on) %> </em><br />
17 <em><%= @content.author ? @content.author.name : "anonyme" %>, <%= format_time(@content.updated_on) %> </em><br />
18 <%=h @content.comments %>
18 <%=h @content.comments %>
19 </p>
19 </p>
20 <hr />
20 <hr />
21 <% end %>
21 <% end %>
22
22
23 <%= render(:partial => "wiki/content", :locals => {:content => @content}) %>
23 <%= render(:partial => "wiki/content", :locals => {:content => @content}) %>
24
24
25 <%= link_to_attachments @page.attachments, :delete_url => (authorize_for('wiki', 'destroy_attachment') ? {:controller => 'wiki', :action => 'destroy_attachment', :page => @page.title} : nil) %>
25 <%= link_to_attachments @page.attachments, :delete_url => (authorize_for('wiki', 'destroy_attachment') ? {:controller => 'wiki', :action => 'destroy_attachment', :page => @page.title} : nil) %>
26
26
27 <div class="contextual">
27 <div class="contextual">
28 <%= l(:label_export_to) %>
28 <%= l(:label_export_to) %>
29 <%= link_to 'HTML', {:export => 'html', :version => @content.version}, :class => 'icon icon-html' %>,
29 <%= link_to 'HTML', {:export => 'html', :version => @content.version}, :class => 'icon icon-html' %>,
30 <%= link_to 'TXT', {:export => 'txt', :version => @content.version}, :class => 'icon icon-txt' %>
30 <%= link_to 'TXT', {:export => 'txt', :version => @content.version}, :class => 'icon icon-txt' %>
31 </div>
31 </div>
32
32
33 <% if authorize_for('wiki', 'add_attachment') %>
33 <% if authorize_for('wiki', 'add_attachment') %>
34 <p><%= toggle_link l(:label_attachment_new), "add_attachment_form" %></p>
34 <p><%= toggle_link l(:label_attachment_new), "add_attachment_form" %></p>
35 <% form_tag({ :controller => 'wiki', :action => 'add_attachment', :page => @page.title }, :multipart => true, :class => "tabular", :id => "add_attachment_form", :style => "display:none;") do %>
35 <% form_tag({ :controller => 'wiki', :action => 'add_attachment', :page => @page.title }, :multipart => true, :class => "tabular", :id => "add_attachment_form", :style => "display:none;") do %>
36 <%= render :partial => 'attachments/form' %>
36 <%= render :partial => 'attachments/form' %>
37 <%= submit_tag l(:button_add) %>
37 <%= submit_tag l(:button_add) %>
38 <% end %>
38 <% end %>
39 <% end %>
39 <% end %>
40
40
41 <% content_for :header_tags do %>
41 <% content_for :header_tags do %>
42 <%= stylesheet_link_tag 'scm' %>
42 <%= stylesheet_link_tag 'scm' %>
43 <% end %>
43 <% end %>
44
45 <% set_html_title @page.pretty_title %>
General Comments 0
You need to be logged in to leave comments. Login now