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