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