diff options
Diffstat (limited to 'app')
184 files changed, 7394 insertions, 0 deletions
diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb new file mode 100644 index 000000000..ffd2419b3 --- /dev/null +++ b/app/controllers/account_controller.rb @@ -0,0 +1,131 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class AccountController < ApplicationController
+ layout 'base'
+ helper :custom_fields
+ include CustomFieldsHelper
+
+ # prevents login action to be filtered by check_if_login_required application scope filter
+ skip_before_filter :check_if_login_required, :only => [:login, :lost_password, :register]
+ before_filter :require_login, :except => [:show, :login, :lost_password, :register]
+
+ # Show user's account
+ def show
+ @user = User.find(params[:id])
+ @custom_values = @user.custom_values.find(:all, :include => :custom_field)
+ end
+
+ # Login request and validation
+ def login
+ if request.get?
+ # Logout user
+ self.logged_in_user = nil
+ else
+ # Authenticate user
+ user = User.try_to_login(params[:login], params[:password])
+ if user
+ self.logged_in_user = user
+ redirect_back_or_default :controller => 'my', :action => 'page'
+ else
+ flash.now[:notice] = l(:notice_account_invalid_creditentials)
+ end
+ end
+ end
+
+ # Log out current user and redirect to welcome page
+ def logout
+ self.logged_in_user = nil
+ redirect_to :controller => ''
+ end
+
+ # Enable user to choose a new password
+ def lost_password
+ if params[:token]
+ @token = Token.find_by_action_and_value("recovery", params[:token])
+ redirect_to :controller => '' and return unless @token and !@token.expired?
+ @user = @token.user
+ if request.post?
+ @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation]
+ if @user.save
+ @token.destroy
+ flash[:notice] = l(:notice_account_password_updated)
+ redirect_to :action => 'login'
+ return
+ end
+ end
+ render :template => "account/password_recovery"
+ return
+ else
+ if request.post?
+ user = User.find_by_mail(params[:mail])
+ # user not found in db
+ flash.now[:notice] = l(:notice_account_unknown_email) and return unless user
+ # user uses an external authentification
+ flash.now[:notice] = l(:notice_can_t_change_password) and return if user.auth_source_id
+ # create a new token for password recovery
+ token = Token.new(:user => user, :action => "recovery")
+ if token.save
+ # send token to user via email
+ Mailer.set_language_if_valid(user.language)
+ Mailer.deliver_lost_password(token)
+ flash[:notice] = l(:notice_account_lost_email_sent)
+ redirect_to :action => 'login'
+ return
+ end
+ end
+ end
+ end
+
+ # User self-registration
+ def register
+ redirect_to :controller => '' and return if $RDM_SELF_REGISTRATION == false
+ if params[:token]
+ token = Token.find_by_action_and_value("register", params[:token])
+ redirect_to :controller => '' and return unless token and !token.expired?
+ user = token.user
+ redirect_to :controller => '' and return unless user.status == User::STATUS_REGISTERED
+ user.status = User::STATUS_ACTIVE
+ if user.save
+ token.destroy
+ flash[:notice] = l(:notice_account_activated)
+ redirect_to :action => 'login'
+ return
+ end
+ else
+ if request.get?
+ @user = User.new(:language => $RDM_DEFAULT_LANG)
+ @custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user) }
+ else
+ @user = User.new(params[:user])
+ @user.admin = false
+ @user.login = params[:user][:login]
+ @user.status = User::STATUS_REGISTERED
+ @user.password, @user.password_confirmation = params[:password], params[:password_confirmation]
+ @custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user, :value => params["custom_fields"][x.id.to_s]) }
+ @user.custom_values = @custom_values
+ token = Token.new(:user => @user, :action => "register")
+ if @user.save and token.save
+ Mailer.set_language_if_valid(@user.language)
+ Mailer.deliver_register(token)
+ flash[:notice] = l(:notice_account_register_done)
+ redirect_to :controller => ''
+ end
+ end
+ end
+ end
+end diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb new file mode 100644 index 000000000..2c9f67586 --- /dev/null +++ b/app/controllers/admin_controller.rb @@ -0,0 +1,56 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class AdminController < ApplicationController
+ layout 'base'
+ before_filter :require_admin
+
+ helper :sort
+ include SortHelper
+
+ def index
+ end
+
+ def projects
+ sort_init 'name', 'asc'
+ sort_update
+ @project_count = Project.count
+ @project_pages = Paginator.new self, @project_count,
+ 15,
+ @params['page']
+ @projects = Project.find :all, :order => sort_clause,
+ :limit => @project_pages.items_per_page,
+ :offset => @project_pages.current.offset
+
+ render :action => "projects", :layout => false if request.xhr?
+ end
+
+ def mail_options
+ @actions = Permission.find(:all, :conditions => ["mail_option=?", true]) || []
+ if request.post?
+ @actions.each { |a|
+ a.mail_enabled = (params[:action_ids] || []).include? a.id.to_s
+ a.save
+ }
+ flash.now[:notice] = l(:notice_successful_update)
+ end
+ end
+
+ def info
+ @adapter_name = ActiveRecord::Base.connection.adapter_name
+ end
+end diff --git a/app/controllers/application.rb b/app/controllers/application.rb new file mode 100644 index 000000000..3bebf4de5 --- /dev/null +++ b/app/controllers/application.rb @@ -0,0 +1,126 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class ApplicationController < ActionController::Base
+ before_filter :check_if_login_required, :set_localization
+
+ def logged_in_user=(user)
+ @logged_in_user = user
+ session[:user_id] = (user ? user.id : nil)
+ end
+
+ def logged_in_user
+ if session[:user_id]
+ @logged_in_user ||= User.find(session[:user_id], :include => :memberships)
+ else
+ nil
+ end
+ end
+
+ # check if login is globally required to access the application
+ def check_if_login_required
+ require_login if $RDM_LOGIN_REQUIRED
+ end
+
+ def set_localization
+ lang = begin
+ 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
+ self.logged_in_user.language
+ elsif request.env['HTTP_ACCEPT_LANGUAGE']
+ accept_lang = parse_qvalues(request.env['HTTP_ACCEPT_LANGUAGE']).first.split('-').first
+ if accept_lang and !accept_lang.empty? and GLoc.valid_languages.include? accept_lang.to_sym
+ accept_lang
+ end
+ end
+ rescue
+ nil
+ end || $RDM_DEFAULT_LANG
+ set_language_if_valid(lang)
+ end
+
+ def require_login
+ unless self.logged_in_user
+ store_location
+ redirect_to :controller => "account", :action => "login"
+ return false
+ end
+ true
+ end
+
+ def require_admin
+ return unless require_login
+ unless self.logged_in_user.admin?
+ render :nothing => true, :status => 403
+ return false
+ end
+ true
+ end
+
+ # authorizes the user for the requested action.
+ def authorize
+ # check if action is allowed on public projects
+ if @project.is_public? and Permission.allowed_to_public "%s/%s" % [ @params[:controller], @params[:action] ]
+ return true
+ end
+ # if action is not public, force login
+ return unless require_login
+ # admin is always authorized
+ return true if self.logged_in_user.admin?
+ # if not admin, check membership permission
+ @user_membership ||= Member.find(:first, :conditions => ["user_id=? and project_id=?", self.logged_in_user.id, @project.id])
+ if @user_membership and Permission.allowed_to_role( "%s/%s" % [ @params[:controller], @params[:action] ], @user_membership.role_id )
+ return true
+ end
+ render :nothing => true, :status => 403
+ false
+ end
+
+ # store current uri in session. + # return to this location by calling redirect_back_or_default + def store_location + session[:return_to] = @request.request_uri + end + + # move to the last store_location call or to the passed default one + def redirect_back_or_default(default) + if session[:return_to].nil? + redirect_to default + else + redirect_to_url session[:return_to] + session[:return_to] = nil + end + end +
+ # qvalues http header parser
+ # code taken from webrick
+ def parse_qvalues(value)
+ tmp = []
+ if value
+ parts = value.split(/,\s*/)
+ parts.each {|part|
+ if m = %r{^([^\s,]+?)(?:;\s*q=(\d+(?:\.\d+)?))?$}.match(part)
+ val = m[1]
+ q = (m[2] or 1).to_f
+ tmp.push([val, q])
+ end
+ }
+ tmp = tmp.sort_by{|val, q| -q}
+ tmp.collect!{|val, q| val}
+ end
+ return tmp
+ end
+end
\ No newline at end of file diff --git a/app/controllers/auth_sources_controller.rb b/app/controllers/auth_sources_controller.rb new file mode 100644 index 000000000..86b58d365 --- /dev/null +++ b/app/controllers/auth_sources_controller.rb @@ -0,0 +1,83 @@ +# redMine - project management software +# Copyright (C) 2006 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class AuthSourcesController < ApplicationController + layout 'base' + before_filter :require_admin + + def index + list + render :action => 'list' unless request.xhr? + end + + # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) + verify :method => :post, :only => [ :destroy, :create, :update ], + :redirect_to => { :action => :list } + + def list + @auth_source_pages, @auth_sources = paginate :auth_sources, :per_page => 10 + render :action => "list", :layout => false if request.xhr? + end + + def new + @auth_source = AuthSourceLdap.new + end + + def create + @auth_source = AuthSourceLdap.new(params[:auth_source]) + if @auth_source.save + flash[:notice] = l(:notice_successful_create) + redirect_to :action => 'list' + else + render :action => 'new' + end + end + + def edit + @auth_source = AuthSource.find(params[:id]) + end + + def update + @auth_source = AuthSource.find(params[:id]) + if @auth_source.update_attributes(params[:auth_source]) + flash[:notice] = l(:notice_successful_update) + redirect_to :action => 'list' + else + render :action => 'edit' + end + end + + def test_connection + @auth_method = AuthSource.find(params[:id]) + begin + @auth_method.test_connection + rescue => text + flash[:notice] = text + end + flash[:notice] ||= l(:notice_successful_connection) + redirect_to :action => 'list' + end + + def destroy + @auth_source = AuthSource.find(params[:id]) + unless @auth_source.users.find(:first) + @auth_source.destroy + flash[:notice] = l(:notice_successful_delete) + end + redirect_to :action => 'list' + end +end diff --git a/app/controllers/custom_fields_controller.rb b/app/controllers/custom_fields_controller.rb new file mode 100644 index 000000000..bfa152fd1 --- /dev/null +++ b/app/controllers/custom_fields_controller.rb @@ -0,0 +1,71 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class CustomFieldsController < ApplicationController
+ layout 'base'
+ before_filter :require_admin
+ + def index + list + render :action => 'list' unless request.xhr? + end + + def list + @custom_field_pages, @custom_fields = paginate :custom_fields, :per_page => 15
+ render :action => "list", :layout => false if request.xhr? + end +
+ def new
+ case params[:type]
+ when "IssueCustomField"
+ @custom_field = IssueCustomField.new(params[:custom_field])
+ @custom_field.trackers = Tracker.find(params[:tracker_ids]) if params[:tracker_ids]
+ when "UserCustomField"
+ @custom_field = UserCustomField.new(params[:custom_field])
+ when "ProjectCustomField"
+ @custom_field = ProjectCustomField.new(params[:custom_field])
+ else
+ redirect_to :action => 'list'
+ return
+ end
+ if request.post? and @custom_field.save
+ flash[:notice] = l(:notice_successful_create)
+ redirect_to :action => 'list'
+ end
+ @trackers = Tracker.find(:all)
+ end
+
+ def edit
+ @custom_field = CustomField.find(params[:id])
+ if request.post? and @custom_field.update_attributes(params[:custom_field])
+ if @custom_field.is_a? IssueCustomField
+ @custom_field.trackers = params[:tracker_ids] ? Tracker.find(params[:tracker_ids]) : []
+ end
+ flash[:notice] = l(:notice_successful_update)
+ redirect_to :action => 'list'
+ end
+ @trackers = Tracker.find(:all)
+ end
+ + def destroy + CustomField.find(params[:id]).destroy + redirect_to :action => 'list'
+ rescue
+ flash[:notice] = "Unable to delete custom field"
+ redirect_to :action => 'list' + end
+end diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb new file mode 100644 index 000000000..3107b3ed1 --- /dev/null +++ b/app/controllers/documents_controller.rb @@ -0,0 +1,68 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class DocumentsController < ApplicationController
+ layout 'base'
+ before_filter :find_project, :authorize
+ + def show
+ @attachments = @document.attachments.find(:all, :order => "created_on DESC") + end + + def edit
+ @categories = Enumeration::get_values('DCAT') + if request.post? and @document.update_attributes(params[:document]) + flash[:notice] = l(:notice_successful_update) + redirect_to :action => 'show', :id => @document + end + end
+ + def destroy + @document.destroy + redirect_to :controller => 'projects', :action => 'list_documents', :id => @project + end
+
+ def download
+ @attachment = @document.attachments.find(params[:attachment_id])
+ @attachment.increment_download
+ send_file @attachment.diskfile, :filename => @attachment.filename
+ rescue
+ flash.now[:notice] = l(:notice_file_not_found)
+ render :text => "", :layout => true, :status => 404
+ end
+
+ def add_attachment
+ # Save the attachment
+ if params[:attachment][:file].size > 0
+ @attachment = @document.attachments.build(params[:attachment])
+ @attachment.author_id = self.logged_in_user.id if self.logged_in_user
+ @attachment.save
+ end
+ redirect_to :action => 'show', :id => @document
+ end
+
+ def destroy_attachment
+ @document.attachments.find(params[:attachment_id]).destroy
+ redirect_to :action => 'show', :id => @document
+ end +
+private
+ def find_project
+ @document = Document.find(params[:id])
+ @project = @document.project
+ end +end diff --git a/app/controllers/enumerations_controller.rb b/app/controllers/enumerations_controller.rb new file mode 100644 index 000000000..8e5be0a20 --- /dev/null +++ b/app/controllers/enumerations_controller.rb @@ -0,0 +1,70 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class EnumerationsController < ApplicationController
+ layout 'base'
+ before_filter :require_admin
+ + def index + list + render :action => 'list' + end + + # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) + verify :method => :post, :only => [ :destroy, :create, :update ], + :redirect_to => { :action => :list } + + def list + end + + def new + @enumeration = Enumeration.new(:opt => params[:opt]) + end + + def create + @enumeration = Enumeration.new(params[:enumeration]) + if @enumeration.save + flash[:notice] = l(:notice_successful_create) + redirect_to :action => 'list', :opt => @enumeration.opt + else + render :action => 'new' + end + end + + def edit + @enumeration = Enumeration.find(params[:id]) + end + + def update + @enumeration = Enumeration.find(params[:id]) + if @enumeration.update_attributes(params[:enumeration]) + flash[:notice] = l(:notice_successful_update) + redirect_to :action => 'list', :opt => @enumeration.opt + else + render :action => 'edit' + end + end + + def destroy + Enumeration.find(params[:id]).destroy
+ flash[:notice] = l(:notice_successful_delete) + redirect_to :action => 'list'
+ rescue
+ flash[:notice] = "Unable to delete enumeration"
+ redirect_to :action => 'list' + end +end diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb new file mode 100644 index 000000000..32d822993 --- /dev/null +++ b/app/controllers/help_controller.rb @@ -0,0 +1,47 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class HelpController < ApplicationController
+
+ skip_before_filter :check_if_login_required
+ before_filter :load_help_config
+
+ # displays help page for the requested controller/action
+ def index
+ # select help page to display
+ if @params[:ctrl] and @help_config['pages'][@params[:ctrl]]
+ if @params[:page] and @help_config['pages'][@params[:ctrl]][@params[:page]]
+ template = @help_config['pages'][@params[:ctrl]][@params[:page]]
+ else
+ template = @help_config['pages'][@params[:ctrl]]['index']
+ end
+ end
+ # choose language according to available help translations
+ lang = (@help_config['langs'].include? current_language.to_s) ? current_language.to_s : @help_config['langs'].first
+
+ if template
+ redirect_to "/manual/#{lang}/#{template}"
+ else
+ redirect_to "/manual/#{lang}/"
+ end
+ end
+
+private
+ def load_help_config
+ @help_config = YAML::load(File.open("#{RAILS_ROOT}/config/help.yml"))
+ end +end diff --git a/app/controllers/issue_categories_controller.rb b/app/controllers/issue_categories_controller.rb new file mode 100644 index 000000000..965a15e78 --- /dev/null +++ b/app/controllers/issue_categories_controller.rb @@ -0,0 +1,42 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class IssueCategoriesController < ApplicationController + layout 'base'
+ before_filter :find_project, :authorize
+
+ def edit + if request.post? and @category.update_attributes(params[:category]) + flash[:notice] = l(:notice_successful_update) + redirect_to :controller => 'projects', :action => 'settings', :id => @project + end + end + + def destroy + @category.destroy + redirect_to :controller => 'projects', :action => 'settings', :id => @project
+ rescue
+ flash[:notice] = "Categorie can't be deleted" + redirect_to :controller => 'projects', :action => 'settings', :id => @project
+ end
+ +private
+ def find_project
+ @category = IssueCategory.find(params[:id])
+ @project = @category.project
+ end
+end diff --git a/app/controllers/issue_statuses_controller.rb b/app/controllers/issue_statuses_controller.rb new file mode 100644 index 000000000..18ca9c76d --- /dev/null +++ b/app/controllers/issue_statuses_controller.rb @@ -0,0 +1,69 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class IssueStatusesController < ApplicationController
+ layout 'base' + before_filter :require_admin
+
+ def index + list + render :action => 'list' unless request.xhr? + end + + def list + @issue_status_pages, @issue_statuses = paginate :issue_statuses, :per_page => 10
+ render :action => "list", :layout => false if request.xhr? + end + + def new + @issue_status = IssueStatus.new + end + + def create + @issue_status = IssueStatus.new(params[:issue_status]) + if @issue_status.save + flash[:notice] = l(:notice_successful_create) + redirect_to :action => 'list' + else + render :action => 'new' + end + end + + def edit + @issue_status = IssueStatus.find(params[:id]) + end + + def update + @issue_status = IssueStatus.find(params[:id]) + if @issue_status.update_attributes(params[:issue_status]) + flash[:notice] = l(:notice_successful_update) + redirect_to :action => 'list' + else + render :action => 'edit' + end + end + + def destroy + IssueStatus.find(params[:id]).destroy + redirect_to :action => 'list'
+ rescue
+ flash[:notice] = "Unable to delete issue status"
+ redirect_to :action => 'list' + end
+
+ +end diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb new file mode 100644 index 000000000..94e036ab3 --- /dev/null +++ b/app/controllers/issues_controller.rb @@ -0,0 +1,145 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class IssuesController < ApplicationController
+ layout 'base', :except => :export_pdf
+ before_filter :find_project, :authorize
+
+ helper :custom_fields
+ include CustomFieldsHelper
+ helper :ifpdf
+ include IfpdfHelper
+ + def show + @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
+ @custom_values = @issue.custom_values.find(:all, :include => :custom_field)
+ @journals_count = @issue.journals.count
+ @journals = @issue.journals.find(:all, :include => [:user, :details], :limit => 15, :order => "journals.created_on desc")
+ end
+
+ def history
+ @journals = @issue.journals.find(:all, :include => [:user, :details], :order => "journals.created_on desc")
+ @journals_count = @journals.length
+ end
+
+ def export_pdf
+ @custom_values = @issue.custom_values.find(:all, :include => :custom_field)
+ @options_for_rfpdf ||= {}
+ @options_for_rfpdf[:file_name] = "#{@project.name}_#{@issue.long_id}.pdf"
+ end + + def edit
+ @priorities = Enumeration::get_values('IPRI')
+ if request.get?
+ @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) }
+ else
+ begin
+ @issue.init_journal(self.logged_in_user)
+ # Retrieve custom fields and values
+ @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]) }
+ @issue.custom_values = @custom_values
+ @issue.attributes = params[:issue]
+ if @issue.save + flash[:notice] = l(:notice_successful_update)
+ redirect_to :action => 'show', :id => @issue + end
+ rescue ActiveRecord::StaleObjectError
+ # Optimistic locking exception
+ flash[:notice] = l(:notice_locking_conflict)
+ end
+ end + end
+
+ def add_note
+ unless params[:notes].empty?
+ journal = @issue.init_journal(self.logged_in_user, params[:notes])
+ #@history = @issue.histories.build(params[:history])
+ #@history.author_id = self.logged_in_user.id if self.logged_in_user
+ #@history.status = @issue.status
+ if @issue.save
+ flash[:notice] = l(:notice_successful_update)
+ Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(@params[:controller], @params[:action]).mail_enabled?
+ redirect_to :action => 'show', :id => @issue
+ return
+ end
+ end
+ show
+ render :action => 'show'
+ end
+
+ def change_status
+ #@history = @issue.histories.build(params[:history])
+ @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
+ @new_status = IssueStatus.find(params[:new_status_id])
+ if params[:confirm]
+ begin
+ #@history.author_id = self.logged_in_user.id if self.logged_in_user
+ #@issue.status = @history.status
+ #@issue.fixed_version_id = (params[:issue][:fixed_version_id])
+ #@issue.assigned_to_id = (params[:issue][:assigned_to_id])
+ #@issue.done_ratio = (params[:issue][:done_ratio])
+ #@issue.lock_version = (params[:issue][:lock_version])
+ journal = @issue.init_journal(self.logged_in_user, params[:notes])
+ @issue.status = @new_status
+ if @issue.update_attributes(params[:issue])
+ flash[:notice] = l(:notice_successful_update)
+ Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(@params[:controller], @params[:action]).mail_enabled?
+ redirect_to :action => 'show', :id => @issue
+ end
+ rescue ActiveRecord::StaleObjectError
+ # Optimistic locking exception
+ flash[:notice] = l(:notice_locking_conflict)
+ end
+ end
+ @assignable_to = @project.members.find(:all, :include => :user).collect{ |m| m.user }
+ end + + def destroy + @issue.destroy + redirect_to :controller => 'projects', :action => 'list_issues', :id => @project + end
+
+ def add_attachment
+ # Save the attachments
+ params[:attachments].each { |a|
+ @attachment = @issue.attachments.build(:file => a, :author => self.logged_in_user) unless a.size == 0
+ @attachment.save
+ } if params[:attachments] and params[:attachments].is_a? Array
+ redirect_to :action => 'show', :id => @issue
+ end
+
+ def destroy_attachment
+ @issue.attachments.find(params[:attachment_id]).destroy
+ redirect_to :action => 'show', :id => @issue
+ end
+
+ # Send the file in stream mode
+ def download
+ @attachment = @issue.attachments.find(params[:attachment_id])
+ send_file @attachment.diskfile, :filename => @attachment.filename
+ rescue
+ flash.now[:notice] = l(:notice_file_not_found)
+ render :text => "", :layout => true, :status => 404
+ end
+
+private
+ def find_project
+ @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
+ @project = @issue.project
+ @html_title = "#{@project.name} - #{@issue.tracker.name} ##{@issue.id}"
+ end +end diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb new file mode 100644 index 000000000..be3f717d1 --- /dev/null +++ b/app/controllers/members_controller.rb @@ -0,0 +1,41 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class MembersController < ApplicationController + layout 'base'
+ before_filter :find_project, :authorize
+ + def edit + if request.post? and @member.update_attributes(params[:member]) + flash[:notice] = l(:notice_successful_update) + redirect_to :controller => 'projects', :action => 'settings', :id => @project
+ end + end + + def destroy + @member.destroy
+ flash[:notice] = l(:notice_successful_delete) + redirect_to :controller => 'projects', :action => 'settings', :id => @project + end
+
+private
+ def find_project
+ @member = Member.find(params[:id])
+ @project = @member.project
+ end + +end diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb new file mode 100644 index 000000000..ff12b74d7 --- /dev/null +++ b/app/controllers/my_controller.rb @@ -0,0 +1,131 @@ +# redMine - project management software +# Copyright (C) 2006 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class MyController < ApplicationController + layout 'base' + before_filter :require_login + + BLOCKS = { 'issues_assigned_to_me' => :label_assigned_to_me_issues, + 'issues_reported_by_me' => :label_reported_issues, + 'latest_news' => :label_news_latest, + 'calendar' => :label_calendar, + 'documents' => :label_document_plural + }.freeze + + verify :xhr => true, + :session => :page_layout, + :only => [:add_block, :remove_block, :order_blocks] + + def index + page + render :action => 'page' + end + + # Show user's page + def page + @user = self.logged_in_user + @blocks = @user.pref[:my_page_layout] || { 'left' => ['issues_assigned_to_me'], 'right' => ['issues_reported_by_me'] } + end + + # Edit user's account + def account + @user = self.logged_in_user + @pref = @user.pref + @user.attributes = params[:user] + @user.pref.attributes = params[:pref] + if request.post? and @user.save + set_localization + flash.now[:notice] = l(:notice_account_updated) + self.logged_in_user.reload + end + end + + # Change user's password + def change_password + @user = self.logged_in_user + flash[:notice] = l(:notice_can_t_change_password) and redirect_to :action => 'account' and return if @user.auth_source_id + if @user.check_password?(@params[:password]) + @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] + if @user.save + flash[:notice] = l(:notice_account_password_updated) + else + render :action => 'account' + return + end + else + flash[:notice] = l(:notice_account_wrong_password) + end + redirect_to :action => 'account' + end + + # User's page layout configuration + def page_layout + @user = self.logged_in_user + @blocks = @user.pref[:my_page_layout] || { 'left' => ['issues_assigned_to_me'], 'right' => ['issues_reported_by_me'] } + session[:page_layout] = @blocks + %w(top left right).each {|f| session[:page_layout][f] ||= [] } + @block_options = [] + BLOCKS.each {|k, v| @block_options << [l(v), k]} + end + + # Add a block to user's page + # The block is added on top of the page + # params[:block] : id of the block to add + def add_block + @user = self.logged_in_user + block = params[:block] + # remove if already present in a group + %w(top left right).each {|f| (session[:page_layout][f] ||= []).delete block } + # add it on top + session[:page_layout]['top'].unshift block + render :partial => "block", :locals => {:user => @user, :block_name => block} + end + + # Remove a block to user's page + # params[:block] : id of the block to remove + def remove_block + block = params[:block] + # remove block in all groups + %w(top left right).each {|f| (session[:page_layout][f] ||= []).delete block } + render :nothing => true + end + + # Change blocks order on user's page + # params[:group] : group to order (top, left or right) + # params[:list-(top|left|right)] : array of block ids of the group + def order_blocks + group = params[:group] + group_items = params["list-#{group}"] + if group_items and group_items.is_a? Array + # remove group blocks if they are presents in other groups + %w(top left right).each {|f| + session[:page_layout][f] = (session[:page_layout][f] || []) - group_items + } + session[:page_layout][group] = group_items + end + render :nothing => true + end + + # Save user's page layout + def page_layout_save + @user = self.logged_in_user + @user.pref[:my_page_layout] = session[:page_layout] if session[:page_layout] + @user.pref.save + session[:page_layout] = nil + redirect_to :action => 'page' + end +end diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb new file mode 100644 index 000000000..b50b59dc0 --- /dev/null +++ b/app/controllers/news_controller.rb @@ -0,0 +1,42 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class NewsController < ApplicationController
+ layout 'base'
+ before_filter :find_project, :authorize
+ + def show + end + + def edit + if request.post? and @news.update_attributes(params[:news]) + flash[:notice] = l(:notice_successful_update) + redirect_to :action => 'show', :id => @news + end + end + + def destroy + @news.destroy + redirect_to :controller => 'projects', :action => 'list_news', :id => @project + end
+
+private
+ def find_project
+ @news = News.find(params[:id])
+ @project = @news.project
+ end +end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb new file mode 100644 index 000000000..c968800c3 --- /dev/null +++ b/app/controllers/projects_controller.rb @@ -0,0 +1,469 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class ProjectsController < ApplicationController
+ layout 'base', :except => :export_issues_pdf
+ before_filter :find_project, :authorize, :except => [ :index, :list, :add ]
+ before_filter :require_admin, :only => [ :add, :destroy ]
+
+ helper :sort
+ include SortHelper
+ helper :search_filter
+ include SearchFilterHelper
+ helper :custom_fields
+ include CustomFieldsHelper
+ helper :ifpdf
+ include IfpdfHelper
+ helper IssuesHelper
+
+ def index + list + render :action => 'list' unless request.xhr? + end +
+ # Lists public projects + def list
+ sort_init 'name', 'asc'
+ sort_update
+ @project_count = Project.count(["is_public=?", true])
+ @project_pages = Paginator.new self, @project_count,
+ 15,
+ @params['page']
+ @projects = Project.find :all, :order => sort_clause,
+ :conditions => ["is_public=?", true],
+ :limit => @project_pages.items_per_page,
+ :offset => @project_pages.current.offset
+
+ render :action => "list", :layout => false if request.xhr? + end
+
+ # Add a new project + def add
+ @custom_fields = IssueCustomField.find(:all)
+ @root_projects = Project.find(:all, :conditions => "parent_id is null")
+ @project = Project.new(params[:project])
+ if request.get?
+ @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project) }
+ else
+ @project.custom_fields = CustomField.find(@params[:custom_field_ids]) if @params[:custom_field_ids]
+ @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
+ @project.custom_values = @custom_values
+ if @project.save + flash[:notice] = l(:notice_successful_create) + redirect_to :controller => 'admin', :action => 'projects'
+ end
+ end
+ end
+
+ # Show @project
+ def show
+ @custom_values = @project.custom_values.find(:all, :include => :custom_field)
+ @members = @project.members.find(:all, :include => [:user, :role])
+ @subprojects = @project.children if @project.children_count > 0
+ @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "news.created_on DESC")
+ @trackers = Tracker.find(:all) + end +
+ def settings
+ @root_projects = Project::find(:all, :conditions => ["parent_id is null and id <> ?", @project.id])
+ @custom_fields = IssueCustomField::find_all
+ @issue_category ||= IssueCategory.new
+ @member ||= @project.members.new
+ @roles = Role.find_all
+ @users = User.find_all - @project.members.find(:all, :include => :user).collect{|m| m.user }
+ @custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
+ end
+
+ # Edit @project
+ def edit
+ if request.post?
+ @project.custom_fields = IssueCustomField.find(@params[:custom_field_ids]) if @params[:custom_field_ids]
+ if params[:custom_fields]
+ @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
+ @project.custom_values = @custom_values
+ end
+ if @project.update_attributes(params[:project]) + flash[:notice] = l(:notice_successful_update) + redirect_to :action => 'settings', :id => @project
+ else
+ settings
+ render :action => 'settings'
+ end
+ end + end
+
+ # Delete @project + def destroy
+ if request.post? and params[:confirm] + @project.destroy + redirect_to :controller => 'admin', :action => 'projects'
+ end + end
+
+ # Add a new issue category to @project
+ def add_issue_category
+ if request.post?
+ @issue_category = @project.issue_categories.build(params[:issue_category])
+ if @issue_category.save
+ flash[:notice] = l(:notice_successful_create)
+ redirect_to :action => 'settings', :id => @project
+ else
+ settings
+ render :action => 'settings'
+ end
+ end
+ end
+
+ # Add a new version to @project
+ def add_version
+ @version = @project.versions.build(params[:version])
+ if request.post? and @version.save
+ flash[:notice] = l(:notice_successful_create)
+ redirect_to :action => 'settings', :id => @project
+ end
+ end
+
+ # Add a new member to @project
+ def add_member
+ @member = @project.members.build(params[:member])
+ if request.post?
+ if @member.save
+ flash[:notice] = l(:notice_successful_create)
+ redirect_to :action => 'settings', :id => @project
+ else
+ settings
+ render :action => 'settings'
+ end
+ end
+ end
+
+ # Show members list of @project
+ def list_members
+ @members = @project.members
+ end
+
+ # Add a new document to @project
+ def add_document
+ @categories = Enumeration::get_values('DCAT')
+ @document = @project.documents.build(params[:document])
+ if request.post?
+ # Save the attachment
+ if params[:attachment][:file].size > 0
+ @attachment = @document.attachments.build(params[:attachment])
+ @attachment.author_id = self.logged_in_user.id if self.logged_in_user
+ end
+ if @document.save
+ flash[:notice] = l(:notice_successful_create)
+ redirect_to :action => 'list_documents', :id => @project
+ end
+ end
+ end
+
+ # Show documents list of @project + def list_documents
+ @documents = @project.documents
+ end
+
+ # Add a new issue to @project
+ def add_issue
+ @tracker = Tracker.find(params[:tracker_id])
+ @priorities = Enumeration::get_values('IPRI')
+ @issue = Issue.new(:project => @project, :tracker => @tracker)
+ if request.get?
+ @issue.start_date = Date.today
+ @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) }
+ else
+ @issue.attributes = params[:issue]
+ @issue.author_id = self.logged_in_user.id if self.logged_in_user
+ # Multiple file upload
+ params[:attachments].each { |a|
+ @attachment = @issue.attachments.build(:file => a, :author => self.logged_in_user) unless a.size == 0
+ } if params[:attachments] and params[:attachments].is_a? Array
+ @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]) }
+ @issue.custom_values = @custom_values
+ if @issue.save
+ flash[:notice] = l(:notice_successful_create)
+ Mailer.deliver_issue_add(@issue) if Permission.find_by_controller_and_action(@params[:controller], @params[:action]).mail_enabled?
+ redirect_to :action => 'list_issues', :id => @project
+ end
+ end
+ end
+
+ # Show filtered/sorted issues list of @project
+ def list_issues
+ sort_init 'issues.id', 'desc'
+ sort_update
+
+ search_filter_init_list_issues
+ search_filter_update if params[:set_filter]
+
+ @results_per_page_options = [ 15, 25, 50, 100 ]
+ if params[:per_page] and @results_per_page_options.include? params[:per_page].to_i
+ @results_per_page = params[:per_page].to_i
+ session[:results_per_page] = @results_per_page
+ else
+ @results_per_page = session[:results_per_page] || 25
+ end
+
+ @issue_count = Issue.count(:include => [:status, :project], :conditions => search_filter_clause)
+ @issue_pages = Paginator.new self, @issue_count, @results_per_page, @params['page']
+ @issues = Issue.find :all, :order => sort_clause,
+ :include => [ :author, :status, :tracker, :project ],
+ :conditions => search_filter_clause,
+ :limit => @issue_pages.items_per_page,
+ :offset => @issue_pages.current.offset
+
+ render :layout => false if request.xhr?
+ end
+
+ # Export filtered/sorted issues list to CSV
+ def export_issues_csv
+ sort_init 'issues.id', 'desc'
+ sort_update
+
+ search_filter_init_list_issues
+
+ @issues = Issue.find :all, :order => sort_clause,
+ :include => [ :author, :status, :tracker, :project, :custom_values ],
+ :conditions => search_filter_clause
+
+ ic = Iconv.new('ISO-8859-1', 'UTF-8')
+ export = StringIO.new
+ CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
+ # csv header fields
+ headers = [ "#", l(:field_status), l(:field_tracker), l(:field_subject), l(:field_author), l(:field_created_on), l(:field_updated_on) ]
+ for custom_field in @project.all_custom_fields
+ headers << custom_field.name
+ end
+ csv << headers.collect {|c| ic.iconv(c) }
+ # csv lines
+ @issues.each do |issue|
+ 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)]
+ for custom_field in @project.all_custom_fields
+ fields << (show_value issue.custom_value_for(custom_field))
+ end
+ csv << fields.collect {|c| ic.iconv(c.to_s) }
+ end
+ end
+ export.rewind
+ send_data(export.read, :type => 'text/csv; header=present', :filename => 'export.csv')
+ end
+
+ # Export filtered/sorted issues to PDF
+ def export_issues_pdf
+ sort_init 'issues.id', 'desc'
+ sort_update
+
+ search_filter_init_list_issues
+
+ @issues = Issue.find :all, :order => sort_clause,
+ :include => [ :author, :status, :tracker, :project, :custom_values ],
+ :conditions => search_filter_clause
+
+ @options_for_rfpdf ||= {}
+ @options_for_rfpdf[:file_name] = "export.pdf"
+ end
+
+ def move_issues
+ @issues = @project.issues.find(params[:issue_ids]) if params[:issue_ids]
+ redirect_to :action => 'list_issues', :id => @project and return unless @issues
+ @projects = []
+ # find projects to which the user is allowed to move the issue
+ @logged_in_user.memberships.each {|m| @projects << m.project if Permission.allowed_to_role("projects/move_issues", m.role_id)}
+ # issue can be moved to any tracker
+ @trackers = Tracker.find(:all)
+ if request.post? and params[:new_project_id] and params[:new_tracker_id]
+ new_project = Project.find(params[:new_project_id])
+ new_tracker = Tracker.find(params[:new_tracker_id])
+ @issues.each { |i|
+ # category is project dependent
+ i.category = nil unless i.project_id == new_project.id
+ # move the issue
+ i.project = new_project
+ i.tracker = new_tracker
+ i.save
+ }
+ flash[:notice] = l(:notice_successful_update)
+ redirect_to :action => 'list_issues', :id => @project
+ end
+ end
+
+ # Add a news to @project
+ def add_news
+ @news = News.new(:project => @project)
+ if request.post?
+ @news.attributes = params[:news]
+ @news.author_id = self.logged_in_user.id if self.logged_in_user
+ if @news.save
+ flash[:notice] = l(:notice_successful_create)
+ redirect_to :action => 'list_news', :id => @project
+ end
+ end
+ end
+
+ # Show news list of @project
+ def list_news
+ @news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "news.created_on DESC"
+ render :action => "list_news", :layout => false if request.xhr?
+ end
+
+ def add_file
+ if request.post?
+ # Save the attachment
+ if params[:attachment][:file].size > 0
+ @attachment = @project.versions.find(params[:version_id]).attachments.build(params[:attachment])
+ @attachment.author_id = self.logged_in_user.id if self.logged_in_user
+ if @attachment.save
+ flash[:notice] = l(:notice_successful_create)
+ redirect_to :controller => 'projects', :action => 'list_files', :id => @project
+ end
+ end
+ end
+ @versions = @project.versions
+ end
+
+ def list_files
+ @versions = @project.versions
+ end
+
+ # Show changelog for @project
+ def changelog
+ @trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true])
+ if request.get?
+ @selected_tracker_ids = @trackers.collect {|t| t.id.to_s }
+ else
+ @selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array
+ end
+ @selected_tracker_ids ||= []
+ @fixed_issues = @project.issues.find(:all,
+ :include => [ :fixed_version, :status, :tracker ],
+ :conditions => [ "issue_statuses.is_closed=? and issues.tracker_id in (#{@selected_tracker_ids.join(',')}) and issues.fixed_version_id is not null", true],
+ :order => "versions.effective_date DESC, issues.id DESC"
+ ) unless @selected_tracker_ids.empty?
+ @fixed_issues ||= []
+ end
+
+ def activity
+ if params[:year] and params[:year].to_i > 1900
+ @year = params[:year].to_i
+ if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
+ @month = params[:month].to_i
+ end
+ end
+ @year ||= Date.today.year
+ @month ||= Date.today.month
+
+ @date_from = Date.civil(@year, @month, 1)
+ @date_to = (@date_from >> 1)-1
+
+ @events_by_day = {}
+
+ unless params[:show_issues] == "0"
+ @project.issues.find(:all, :include => [:author, :status], :conditions => ["issues.created_on>=? and issues.created_on<=?", @date_from, @date_to] ).each { |i|
+ @events_by_day[i.created_on.to_date] ||= []
+ @events_by_day[i.created_on.to_date] << i
+ }
+ @show_issues = 1
+ end
+
+ unless params[:show_news] == "0"
+ @project.news.find(:all, :conditions => ["news.created_on>=? and news.created_on<=?", @date_from, @date_to] ).each { |i|
+ @events_by_day[i.created_on.to_date] ||= []
+ @events_by_day[i.created_on.to_date] << i
+ }
+ @show_news = 1
+ end
+
+ unless params[:show_files] == "0"
+ Attachment.find(:all, :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] ).each { |i|
+ @events_by_day[i.created_on.to_date] ||= []
+ @events_by_day[i.created_on.to_date] << i
+ }
+ @show_files = 1
+ end
+
+ unless params[:show_documents] == "0"
+ Attachment.find(:all, :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] ).each { |i|
+ @events_by_day[i.created_on.to_date] ||= []
+ @events_by_day[i.created_on.to_date] << i
+ }
+ @show_documents = 1
+ end
+
+ end
+
+ def calendar
+ if params[:year] and params[:year].to_i > 1900
+ @year = params[:year].to_i
+ if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
+ @month = params[:month].to_i
+ end
+ end
+ @year ||= Date.today.year
+ @month ||= Date.today.month
+
+ @date_from = Date.civil(@year, @month, 1)
+ @date_to = (@date_from >> 1)-1
+ # start on monday
+ @date_from = @date_from - (@date_from.cwday-1)
+ # finish on sunday
+ @date_to = @date_to + (7-@date_to.cwday)
+
+ @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])
+ render :layout => false if request.xhr?
+ end
+
+ def gantt
+ if params[:year] and params[:year].to_i >0
+ @year_from = params[:year].to_i
+ if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12
+ @month_from = params[:month].to_i
+ else
+ @month_from = 1
+ end
+ else
+ @month_from ||= (Date.today << 1).month
+ @year_from ||= (Date.today << 1).year
+ end
+
+ @zoom = (params[:zoom].to_i > 0 and params[:zoom].to_i < 5) ? params[:zoom].to_i : 2
+ @months = (params[:months].to_i > 0 and params[:months].to_i < 25) ? params[:months].to_i : 6
+
+ @date_from = Date.civil(@year_from, @month_from, 1)
+ @date_to = (@date_from >> @months) - 1
+ @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])
+
+ if params[:output]=='pdf'
+ @options_for_rfpdf ||= {}
+ @options_for_rfpdf[:file_name] = "gantt.pdf"
+ render :template => "projects/gantt.rfpdf", :layout => false
+ else
+ render :template => "projects/gantt.rhtml"
+ end
+ end
+
+private
+ # Find project of id params[:id]
+ # if not found, redirect to project list
+ # Used as a before_filter
+ def find_project
+ @project = Project.find(params[:id])
+ @html_title = @project.name
+ rescue + redirect_to :action => 'list'
+ end
+end diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb new file mode 100644 index 000000000..985c937fc --- /dev/null +++ b/app/controllers/reports_controller.rb @@ -0,0 +1,164 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class ReportsController < ApplicationController
+ layout 'base'
+ before_filter :find_project, :authorize
+
+ def issue_report
+ @statuses = IssueStatus.find_all
+
+ case params[:detail]
+ when "tracker"
+ @field = "tracker_id"
+ @rows = Tracker.find_all
+ @data = issues_by_tracker
+ @report_title = l(:field_tracker)
+ render :template => "reports/issue_report_details"
+ when "priority"
+ @field = "priority_id"
+ @rows = Enumeration::get_values('IPRI')
+ @data = issues_by_priority
+ @report_title = l(:field_priority)
+ render :template => "reports/issue_report_details"
+ when "category"
+ @field = "category_id"
+ @rows = @project.issue_categories
+ @data = issues_by_category
+ @report_title = l(:field_category)
+ render :template => "reports/issue_report_details"
+ when "author"
+ @field = "author_id"
+ @rows = @project.members.collect { |m| m.user }
+ @data = issues_by_author
+ @report_title = l(:field_author)
+ render :template => "reports/issue_report_details"
+ else
+ @trackers = Tracker.find(:all)
+ @priorities = Enumeration::get_values('IPRI')
+ @categories = @project.issue_categories
+ @authors = @project.members.collect { |m| m.user }
+ issues_by_tracker
+ issues_by_priority
+ issues_by_category
+ issues_by_author
+ render :template => "reports/issue_report"
+ end
+ end
+
+ def delays
+ @trackers = Tracker.find(:all)
+ if request.get?
+ @selected_tracker_ids = @trackers.collect {|t| t.id.to_s }
+ else
+ @selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array
+ end
+ @selected_tracker_ids ||= []
+ @raw =
+ ActiveRecord::Base.connection.select_all("SELECT datediff( a.created_on, b.created_on ) as delay, count(a.id) as total
+ FROM issue_histories a, issue_histories b, issues i
+ WHERE a.status_id =5
+ AND a.issue_id = b.issue_id
+ AND a.issue_id = i.id
+ AND i.tracker_id in (#{@selected_tracker_ids.join(',')})
+ AND b.id = (
+ SELECT min( c.id )
+ FROM issue_histories c
+ WHERE b.issue_id = c.issue_id )
+ GROUP BY delay") unless @selected_tracker_ids.empty?
+ @raw ||=[]
+
+ @x_from = 0
+ @x_to = 0
+ @y_from = 0
+ @y_to = 0
+ @sum_total = 0
+ @sum_delay = 0
+ @raw.each do |r|
+ @x_to = [r['delay'].to_i, @x_to].max
+ @y_to = [r['total'].to_i, @y_to].max
+ @sum_total = @sum_total + r['total'].to_i
+ @sum_delay = @sum_delay + r['total'].to_i * r['delay'].to_i
+ end
+ end
+
+private
+ # Find project of id params[:id]
+ def find_project
+ @project = Project.find(params[:id])
+ end
+
+ def issues_by_tracker
+ @issues_by_tracker ||=
+ ActiveRecord::Base.connection.select_all("select s.id as status_id,
+ s.is_closed as closed,
+ t.id as tracker_id,
+ count(i.id) as total
+ from
+ issues i, issue_statuses s, trackers t
+ where
+ i.status_id=s.id
+ and i.tracker_id=t.id
+ and i.project_id=#{@project.id}
+ group by s.id, s.is_closed, t.id")
+ end
+
+ def issues_by_priority
+ @issues_by_priority ||=
+ ActiveRecord::Base.connection.select_all("select s.id as status_id,
+ s.is_closed as closed,
+ p.id as priority_id,
+ count(i.id) as total
+ from
+ issues i, issue_statuses s, enumerations p
+ where
+ i.status_id=s.id
+ and i.priority_id=p.id
+ and i.project_id=#{@project.id}
+ group by s.id, s.is_closed, p.id")
+ end
+
+ def issues_by_category
+ @issues_by_category ||=
+ ActiveRecord::Base.connection.select_all("select s.id as status_id,
+ s.is_closed as closed,
+ c.id as category_id,
+ count(i.id) as total
+ from
+ issues i, issue_statuses s, issue_categories c
+ where
+ i.status_id=s.id
+ and i.category_id=c.id
+ and i.project_id=#{@project.id}
+ group by s.id, s.is_closed, c.id")
+ end
+
+ def issues_by_author
+ @issues_by_author ||=
+ ActiveRecord::Base.connection.select_all("select s.id as status_id,
+ s.is_closed as closed,
+ a.id as author_id,
+ count(i.id) as total
+ from
+ issues i, issue_statuses s, users a
+ where
+ i.status_id=s.id
+ and i.author_id=a.id
+ and i.project_id=#{@project.id}
+ group by s.id, s.is_closed, a.id")
+ end +end diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb new file mode 100644 index 000000000..e16127b61 --- /dev/null +++ b/app/controllers/roles_controller.rb @@ -0,0 +1,84 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class RolesController < ApplicationController
+ layout 'base'
+ before_filter :require_admin
+ + def index + list + render :action => 'list' unless request.xhr? + end + + def list + @role_pages, @roles = paginate :roles, :per_page => 10
+ render :action => "list", :layout => false if request.xhr? + end + + def new + @role = Role.new(params[:role])
+ if request.post? + @role.permissions = Permission.find(@params[:permission_ids]) if @params[:permission_ids] + if @role.save + flash[:notice] = l(:notice_successful_create) + redirect_to :action => 'list' + end
+ end + @permissions = Permission.find(:all, :conditions => ["is_public=?", false], :order => 'sort ASC') + end + + def edit + @role = Role.find(params[:id])
+ if request.post? and @role.update_attributes(params[:role]) + @role.permissions = Permission.find(@params[:permission_ids] || [])
+ Permission.allowed_to_role_expired + flash[:notice] = l(:notice_successful_update) + redirect_to :action => 'list' + end + @permissions = Permission.find(:all, :conditions => ["is_public=?", false], :order => 'sort ASC') + end + + def destroy + @role = Role.find(params[:id])
+ unless @role.members.empty?
+ flash[:notice] = 'Some members have this role. Can\'t delete it.'
+ else
+ @role.destroy
+ end + redirect_to :action => 'list' + end
+
+ def workflow
+ @role = Role.find_by_id(params[:role_id])
+ @tracker = Tracker.find_by_id(params[:tracker_id])
+
+ if request.post?
+ Workflow.destroy_all( ["role_id=? and tracker_id=?", @role.id, @tracker.id])
+ (params[:issue_status] || []).each { |old, news|
+ news.each { |new|
+ @role.workflows.build(:tracker_id => @tracker.id, :old_status_id => old, :new_status_id => new)
+ }
+ }
+ if @role.save
+ flash[:notice] = l(:notice_successful_update)
+ end
+ end
+ @roles = Role.find_all
+ @trackers = Tracker.find_all
+ @statuses = IssueStatus.find(:all, :include => :workflows)
+ end +end diff --git a/app/controllers/trackers_controller.rb b/app/controllers/trackers_controller.rb new file mode 100644 index 000000000..bbfb4f48b --- /dev/null +++ b/app/controllers/trackers_controller.rb @@ -0,0 +1,61 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class TrackersController < ApplicationController
+ layout 'base'
+ before_filter :require_admin
+ + def index + list + render :action => 'list' unless request.xhr? + end + + # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) + verify :method => :post, :only => [ :destroy ], :redirect_to => { :action => :list } + + def list + @tracker_pages, @trackers = paginate :trackers, :per_page => 10
+ render :action => "list", :layout => false if request.xhr? + end + + def new + @tracker = Tracker.new(params[:tracker]) + if request.post? and @tracker.save + flash[:notice] = l(:notice_successful_create) + redirect_to :action => 'list' + end + end + + def edit + @tracker = Tracker.find(params[:id]) + if request.post? and @tracker.update_attributes(params[:tracker]) + flash[:notice] = l(:notice_successful_update) + redirect_to :action => 'list' + end + end + + def destroy + @tracker = Tracker.find(params[:id])
+ unless @tracker.issues.empty?
+ flash[:notice] = "This tracker contains issues and can\'t be deleted."
+ else
+ @tracker.destroy
+ end + redirect_to :action => 'list' + end
+ +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb new file mode 100644 index 000000000..47d0e51c9 --- /dev/null +++ b/app/controllers/users_controller.rb @@ -0,0 +1,92 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class UsersController < ApplicationController
+ layout 'base'
+ before_filter :require_admin
+
+ helper :sort
+ include SortHelper
+ helper :custom_fields
+ include CustomFieldsHelper
+ + def index + list + render :action => 'list' unless request.xhr? + end + + def list
+ sort_init 'login', 'asc'
+ sort_update
+ @user_count = User.count
+ @user_pages = Paginator.new self, @user_count,
+ 15,
+ @params['page']
+ @users = User.find :all,:order => sort_clause,
+ :limit => @user_pages.items_per_page,
+ :offset => @user_pages.current.offset
+
+ render :action => "list", :layout => false if request.xhr? + end + + def add + if request.get?
+ @user = User.new(:language => $RDM_DEFAULT_LANG)
+ @custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user) }
+ else + @user = User.new(params[:user])
+ @user.admin = params[:user][:admin] || false
+ @user.login = params[:user][:login]
+ @user.password, @user.password_confirmation = params[:password], params[:password_confirmation] unless @user.auth_source_id
+ @custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user, :value => params["custom_fields"][x.id.to_s]) }
+ @user.custom_values = @custom_values
+ if @user.save + flash[:notice] = l(:notice_successful_create) + redirect_to :action => 'list' + end
+ end
+ @auth_sources = AuthSource.find(:all) + end + + def edit + @user = User.find(params[:id]) + if request.get?
+ @custom_values = UserCustomField.find(:all).collect { |x| @user.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
+ else
+ @user.admin = params[:user][:admin] if params[:user][:admin]
+ @user.login = params[:user][:login] if params[:user][:login]
+ @user.password, @user.password_confirmation = params[:password], params[:password_confirmation] unless params[:password].nil? or params[:password].empty? or @user.auth_source_id
+ if params[:custom_fields]
+ @custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user, :value => params["custom_fields"][x.id.to_s]) }
+ @user.custom_values = @custom_values
+ end
+ if @user.update_attributes(params[:user]) + flash[:notice] = l(:notice_successful_update) + redirect_to :action => 'list' + end
+ end + @auth_sources = AuthSource.find(:all)
+ end + + def destroy + User.find(params[:id]).destroy + redirect_to :action => 'list'
+ rescue
+ flash[:notice] = "Unable to delete user"
+ redirect_to :action => 'list' + end
+end diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb new file mode 100644 index 000000000..d1980d74f --- /dev/null +++ b/app/controllers/versions_controller.rb @@ -0,0 +1,57 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class VersionsController < ApplicationController
+ layout 'base'
+ before_filter :find_project, :authorize
+ + def edit + if request.post? and @version.update_attributes(params[:version]) + flash[:notice] = l(:notice_successful_update) + redirect_to :controller => 'projects', :action => 'settings', :id => @project + end + end + + def destroy
+ @version.destroy + redirect_to :controller => 'projects', :action => 'settings', :id => @project
+ rescue
+ flash[:notice] = "Unable to delete version"
+ redirect_to :controller => 'projects', :action => 'settings', :id => @project
+ end
+
+ def download
+ @attachment = @version.attachments.find(params[:attachment_id])
+ @attachment.increment_download
+ send_file @attachment.diskfile, :filename => @attachment.filename
+ rescue
+ flash.now[:notice] = l(:notice_file_not_found)
+ render :text => "", :layout => true, :status => 404
+ end
+
+ def destroy_file
+ @version.attachments.find(params[:attachment_id]).destroy
+ flash[:notice] = l(:notice_successful_delete)
+ redirect_to :controller => 'projects', :action => 'list_files', :id => @project
+ end
+
+private
+ def find_project
+ @version = Version.find(params[:id])
+ @project = @version.project
+ end +end diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb new file mode 100644 index 000000000..c47198d51 --- /dev/null +++ b/app/controllers/welcome_controller.rb @@ -0,0 +1,25 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class WelcomeController < ApplicationController
+ layout 'base'
+
+ def index
+ @news = News.latest
+ @projects = Project.latest
+ end +end diff --git a/app/helpers/account_helper.rb b/app/helpers/account_helper.rb new file mode 100644 index 000000000..e18ab6ff4 --- /dev/null +++ b/app/helpers/account_helper.rb @@ -0,0 +1,19 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module AccountHelper +end diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb new file mode 100644 index 000000000..db2777392 --- /dev/null +++ b/app/helpers/admin_helper.rb @@ -0,0 +1,19 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module AdminHelper +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb new file mode 100644 index 000000000..0f0deeb30 --- /dev/null +++ b/app/helpers/application_helper.rb @@ -0,0 +1,179 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module ApplicationHelper
+
+ # Return current logged in user or nil
+ def loggedin?
+ @logged_in_user
+ end
+
+ # Return true if user is logged in and is admin, otherwise false
+ def admin_loggedin?
+ @logged_in_user and @logged_in_user.admin?
+ end
+
+ # Return true if user is authorized for controller/action, otherwise false
+ def authorize_for(controller, action)
+ # check if action is allowed on public projects
+ if @project.is_public? and Permission.allowed_to_public "%s/%s" % [ controller, action ]
+ return true
+ end
+ # check if user is authorized
+ 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) ) )
+ return true
+ end
+ return false
+ end
+
+ # Display a link if user is authorized
+ def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference)
+ link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller], options[:action])
+ end
+
+ # Display a link to user's account page
+ def link_to_user(user)
+ link_to user.display_name, :controller => 'account', :action => 'show', :id => user
+ end
+
+ def format_date(date)
+ l_date(date) if date
+ end
+
+ def format_time(time)
+ l_datetime(time) if time
+ end
+
+ def day_name(day)
+ l(:general_day_names).split(',')[day-1]
+ end
+
+ def pagination_links_full(paginator, options={}, html_options={})
+ html = ''
+ html << link_to_remote(('« ' + l(:label_previous)),
+ {:update => "content", :url => { :page => paginator.current.previous }},
+ {:href => url_for(:action => 'list', :params => @params.merge({:page => paginator.current.previous}))}) + ' ' if paginator.current.previous
+
+ html << (pagination_links_each(paginator, options) do |n|
+ link_to_remote(n.to_s,
+ {:url => {:action => 'list', :params => @params.merge({:page => n})}, :update => 'content'},
+ {:href => url_for(:action => 'list', :params => @params.merge({:page => n}))})
+ end || '')
+
+ html << ' ' + link_to_remote((l(:label_next) + ' »'),
+ {:update => "content", :url => { :page => paginator.current.next }},
+ {:href => url_for(:action => 'list', :params => @params.merge({:page => paginator.current.next}))}) if paginator.current.next
+ html
+ end
+
+ def textilizable(text)
+ $RDM_TEXTILE_DISABLED ? text : RedCloth.new(text).to_html
+ end
+
+ def error_messages_for(object_name, options = {})
+ options = options.symbolize_keys
+ object = instance_variable_get("@#{object_name}")
+ if object && !object.errors.empty?
+ # build full_messages here with controller current language
+ full_messages = []
+ object.errors.each do |attr, msg|
+ next if msg.nil?
+ if attr == "base"
+ full_messages << l(msg)
+ else
+ full_messages << "« " + (l_has_string?("field_" + attr) ? l("field_" + attr) : object.class.human_attribute_name(attr)) + " » " + l(msg) unless attr == "custom_values"
+ end
+ end
+ # retrieve custom values error messages
+ if object.errors[:custom_values]
+ object.custom_values.each do |v|
+ v.errors.each do |attr, msg|
+ next if msg.nil?
+ full_messages << "« " + v.custom_field.name + " » " + l(msg)
+ end
+ end
+ end
+ content_tag("div",
+ content_tag(
+ options[:header_tag] || "h2", lwr(:gui_validation_error, full_messages.length) + " :"
+ ) +
+ content_tag("ul", full_messages.collect { |msg| content_tag("li", msg) }),
+ "id" => options[:id] || "errorExplanation", "class" => options[:class] || "errorExplanation"
+ )
+ else
+ ""
+ end
+ end
+
+ def lang_options_for_select
+ (GLoc.valid_languages.sort {|x,y| x.to_s <=> y.to_s }).collect {|lang| [ l_lang_name(lang.to_s, lang), lang.to_s]}
+ end
+
+ def label_tag_for(name, option_tags = nil, options = {})
+ label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "")
+ content_tag("label", label_text)
+ end
+
+ def labelled_tabular_form_for(name, object, options, &proc)
+ options[:html] ||= {}
+ options[:html].store :class, "tabular"
+ form_for(name, object, options.merge({ :builder => TabularFormBuilder, :lang => current_language}), &proc)
+ end
+
+ def check_all_links(form_name)
+ link_to_function(l(:button_check_all), "checkAll('#{form_name}', true)") +
+ " | " +
+ link_to_function(l(:button_uncheck_all), "checkAll('#{form_name}', false)")
+ end
+
+ def calendar_for(field_id)
+ image_tag("calendar", {:id => "#{field_id}_trigger",:class => "calendar-trigger"}) +
+ javascript_tag("Calendar.setup({inputField : '#{field_id}', ifFormat : '%Y-%m-%d', button : '#{field_id}_trigger' });")
+ end
+end +
+class TabularFormBuilder < ActionView::Helpers::FormBuilder
+ include GLoc
+
+ def initialize(object_name, object, template, options, proc)
+ set_language_if_valid options.delete(:lang)
+ @object_name, @object, @template, @options, @proc = object_name, object, template, options, proc
+ end
+
+ (field_helpers - %w(radio_button hidden_field) + %w(date_select)).each do |selector|
+ src = <<-END_SRC
+ def #{selector}(field, options = {})
+ label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "")
+ label = @template.content_tag("label", label_text,
+ :class => (@object.errors[field] ? "error" : nil),
+ :for => (@object_name.to_s + "_" + field.to_s))
+ label + super
+ end
+ END_SRC
+ class_eval src, __FILE__, __LINE__
+ end
+
+ def select(field, choices, options = {})
+ label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "")
+ label = @template.content_tag("label", label_text,
+ :class => (@object.errors[field] ? "error" : nil),
+ :for => (@object_name.to_s + "_" + field.to_s))
+ label + super
+ end
+
+end
+
diff --git a/app/helpers/auth_sources_helper.rb b/app/helpers/auth_sources_helper.rb new file mode 100644 index 000000000..d47e9856a --- /dev/null +++ b/app/helpers/auth_sources_helper.rb @@ -0,0 +1,19 @@ +# redMine - project management software +# Copyright (C) 2006 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +module AuthSourcesHelper +end diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb new file mode 100644 index 000000000..9df5c50a3 --- /dev/null +++ b/app/helpers/custom_fields_helper.rb @@ -0,0 +1,77 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module CustomFieldsHelper
+
+ # Return custom field html tag corresponding to its format
+ def custom_field_tag(custom_value)
+ custom_field = custom_value.custom_field
+ field_name = "custom_fields[#{custom_field.id}]"
+ field_id = "custom_fields_#{custom_field.id}"
+
+ case custom_field.field_format
+ when "string", "int"
+ text_field 'custom_value', 'value', :name => field_name, :id => field_id
+ when "date"
+ text_field('custom_value', 'value', :name => field_name, :id => field_id, :size => 10) +
+ calendar_for(field_id)
+ when "text"
+ text_area 'custom_value', 'value', :name => field_name, :id => field_id, :cols => 60, :rows => 3
+ when "bool"
+ check_box 'custom_value', 'value', :name => field_name, :id => field_id
+ when "list"
+ select 'custom_value', 'value', custom_field.possible_values.split('|'), { :include_blank => true }, :name => field_name, :id => field_id
+ end
+ end
+
+ # Return custom field label tag
+ def custom_field_label_tag(custom_value)
+ content_tag "label", custom_value.custom_field.name +
+ (custom_value.custom_field.is_required? ? " <span class=\"required\">*</span>" : ""),
+ :for => "custom_fields_#{custom_value.custom_field.id}",
+ :class => (custom_value.errors.empty? ? nil : "error" )
+ end
+
+ # Return custom field tag with its label tag
+ def custom_field_tag_with_label(custom_value)
+ custom_field_label_tag(custom_value) + custom_field_tag(custom_value)
+ end
+
+ # Return a string used to display a custom value
+ def show_value(custom_value)
+ return "" unless custom_value
+ format_value(custom_value.value, custom_value.custom_field.field_format)
+ end
+
+ # Return a string used to display a custom value
+ def format_value(value, field_format)
+ return "" unless value
+ case field_format
+ when "date"
+ value.empty? ? "" : l_date(value.to_date)
+ when "bool"
+ l_YesNo(value == "1")
+ else
+ value
+ end
+ end
+
+ # Return an array of custom field formats which can be used in select_tag
+ def custom_field_formats_for_select
+ CustomField::FIELD_FORMATS.keys.collect { |k| [ l(CustomField::FIELD_FORMATS[k]), k ] }
+ end +end diff --git a/app/helpers/documents_helper.rb b/app/helpers/documents_helper.rb new file mode 100644 index 000000000..c9897647d --- /dev/null +++ b/app/helpers/documents_helper.rb @@ -0,0 +1,19 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module DocumentsHelper +end diff --git a/app/helpers/enumerations_helper.rb b/app/helpers/enumerations_helper.rb new file mode 100644 index 000000000..11a216a82 --- /dev/null +++ b/app/helpers/enumerations_helper.rb @@ -0,0 +1,19 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module EnumerationsHelper +end diff --git a/app/helpers/help_helper.rb b/app/helpers/help_helper.rb new file mode 100644 index 000000000..bb629316c --- /dev/null +++ b/app/helpers/help_helper.rb @@ -0,0 +1,19 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module HelpHelper +end diff --git a/app/helpers/ifpdf_helper.rb b/app/helpers/ifpdf_helper.rb new file mode 100644 index 000000000..a0dab0f94 --- /dev/null +++ b/app/helpers/ifpdf_helper.rb @@ -0,0 +1,48 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require 'iconv'
+
+module IfpdfHelper
+
+ class IFPDF < FPDF
+
+ attr_accessor :footer_date
+
+ def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
+ @ic ||= Iconv.new('ISO-8859-1', 'UTF-8')
+ txt = begin
+ @ic.iconv(txt)
+ rescue
+ txt
+ end
+ super w,h,txt,border,ln,align,fill,link
+ end
+
+ def Footer
+ SetFont('Helvetica', 'I', 8)
+ SetY(-15)
+ SetX(15)
+ Cell(0, 5, @footer_date, 0, 0, 'L')
+ SetY(-15)
+ SetX(-30)
+ Cell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C')
+ end
+
+ end +
+end
diff --git a/app/helpers/issue_categories_helper.rb b/app/helpers/issue_categories_helper.rb new file mode 100644 index 000000000..997d830d7 --- /dev/null +++ b/app/helpers/issue_categories_helper.rb @@ -0,0 +1,19 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module IssueCategoriesHelper +end diff --git a/app/helpers/issue_statuses_helper.rb b/app/helpers/issue_statuses_helper.rb new file mode 100644 index 000000000..17704b7ba --- /dev/null +++ b/app/helpers/issue_statuses_helper.rb @@ -0,0 +1,19 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module IssueStatusesHelper +end diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb new file mode 100644 index 000000000..93bd6c050 --- /dev/null +++ b/app/helpers/issues_helper.rb @@ -0,0 +1,74 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module IssuesHelper
+
+ def show_detail(detail, no_html=false)
+ case detail.property
+ when 'attr'
+ label = l(("field_" + detail.prop_key.to_s.gsub(/\_id$/, "")).to_sym)
+ case detail.prop_key
+ when 'due_date', 'start_date'
+ value = format_date(detail.value.to_date) if detail.value
+ old_value = format_date(detail.old_value.to_date) if detail.old_value
+ when 'status_id'
+ s = IssueStatus.find_by_id(detail.value) and value = s.name if detail.value
+ s = IssueStatus.find_by_id(detail.old_value) and old_value = s.name if detail.old_value
+ when 'assigned_to_id'
+ u = User.find_by_id(detail.value) and value = u.name if detail.value
+ u = User.find_by_id(detail.old_value) and old_value = u.name if detail.old_value
+ when 'priority_id'
+ e = Enumeration.find_by_id(detail.value) and value = e.name if detail.value
+ e = Enumeration.find_by_id(detail.old_value) and old_value = e.name if detail.old_value
+ when 'category_id'
+ c = IssueCategory.find_by_id(detail.value) and value = c.name if detail.value
+ c = IssueCategory.find_by_id(detail.old_value) and old_value = c.name if detail.old_value
+ when 'fixed_version_id'
+ v = Version.find_by_id(detail.value) and value = v.name if detail.value
+ v = Version.find_by_id(detail.old_value) and old_value = v.name if detail.old_value
+ end
+ when 'cf'
+ custom_field = CustomField.find_by_id(detail.prop_key)
+ if custom_field
+ label = custom_field.name
+ value = format_value(detail.value, custom_field.field_format) if detail.value
+ old_value = format_value(detail.old_value, custom_field.field_format) if detail.old_value
+ end
+ end
+
+ label ||= detail.prop_key
+ value ||= detail.value
+ old_value ||= detail.old_value
+
+ unless no_html
+ label = content_tag('strong', label)
+ old_value = content_tag("i", old_value) if old_value
+ old_value = content_tag("strike", old_value) if old_value and !value
+ value = content_tag("i", value) if value
+ end
+
+ if value
+ if old_value
+ label + " " + l(:text_journal_changed, old_value, value)
+ else
+ label + " " + l(:text_journal_set_to, value)
+ end
+ else
+ label + " " + l(:text_journal_deleted) + " (#{old_value})"
+ end
+ end +end diff --git a/app/helpers/members_helper.rb b/app/helpers/members_helper.rb new file mode 100644 index 000000000..8bf90913d --- /dev/null +++ b/app/helpers/members_helper.rb @@ -0,0 +1,19 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module MembersHelper +end diff --git a/app/helpers/my_helper.rb b/app/helpers/my_helper.rb new file mode 100644 index 000000000..9098f67bc --- /dev/null +++ b/app/helpers/my_helper.rb @@ -0,0 +1,19 @@ +# redMine - project management software +# Copyright (C) 2006 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +module MyHelper +end diff --git a/app/helpers/news_helper.rb b/app/helpers/news_helper.rb new file mode 100644 index 000000000..f4a633f4b --- /dev/null +++ b/app/helpers/news_helper.rb @@ -0,0 +1,19 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module NewsHelper +end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb new file mode 100644 index 000000000..0c85ce24c --- /dev/null +++ b/app/helpers/projects_helper.rb @@ -0,0 +1,19 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module ProjectsHelper +end diff --git a/app/helpers/reports_helper.rb b/app/helpers/reports_helper.rb new file mode 100644 index 000000000..ed7fd7884 --- /dev/null +++ b/app/helpers/reports_helper.rb @@ -0,0 +1,32 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module ReportsHelper
+
+ def aggregate(data, criteria)
+ a = 0
+ data.each { |row|
+ match = 1
+ criteria.each { |k, v|
+ match = 0 unless row[k].to_s == v.to_s
+ } unless criteria.nil?
+ a = a + row["total"].to_i if match == 1
+ } unless data.nil?
+ a
+ end
+ +end diff --git a/app/helpers/roles_helper.rb b/app/helpers/roles_helper.rb new file mode 100644 index 000000000..8ae339053 --- /dev/null +++ b/app/helpers/roles_helper.rb @@ -0,0 +1,19 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module RolesHelper +end diff --git a/app/helpers/search_filter_helper.rb b/app/helpers/search_filter_helper.rb new file mode 100644 index 000000000..f17ffeebf --- /dev/null +++ b/app/helpers/search_filter_helper.rb @@ -0,0 +1,106 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module SearchFilterHelper
+
+ def search_filter_criteria(name, options = {})
+ @search_filter ||= {}
+ @search_filter[name] ||= {}
+ @search_filter[name][:options] = []
+ @search_filter[name][:conditions] = {}
+ yield.each { |c|
+ @search_filter[name][:options] << [c[0], c[1].to_s]
+ @search_filter[name][:conditions].store(c[1].to_s, c[2])
+ }
+ end
+
+ def search_filter_update
+ session[:search_filter] ||= {}
+ @search_filter.each_key {|field| session[:search_filter][field] = params[field] }
+ end
+
+ def search_filter_clause
+ session[:search_filter] ||= {}
+ clause = ["1=1"]
+ @search_filter.each { |k, v|
+ filter_value = session[:search_filter][k] || v[:options][0][1]
+ if v[:conditions][filter_value]
+ clause[0] = clause[0] + " AND " + v[:conditions][filter_value].first
+ clause += v[:conditions][filter_value][1..-1]
+ end
+ }
+ clause
+ end
+
+ def search_filter_tag(criteria, options = {})
+ session[:search_filter] ||= {}
+ options[:name] = criteria
+ options[:class] += " active-filter" if session[:search_filter][criteria] and session[:search_filter][criteria] != @search_filter[criteria][:options][0][1]
+ content_tag("select",
+ options_for_select(@search_filter[criteria][:options], session[:search_filter][criteria]),
+ options
+ )
+ end
+
+ def search_filter_init_list_issues
+ search_filter_criteria('status_id') {
+ [ [('['+l(:label_open_issues_plural)+']'), "O", ["issue_statuses.is_closed=?", false]],
+ [('['+l(:label_closed_issues_plural)+']'), "C", ["issue_statuses.is_closed=?", true]],
+ [('['+l(:label_all)+']'), "A", nil]
+ ] + IssueStatus.find(:all).collect {|s| [s.name, s.id, ["issues.status_id=?", s.id]] }
+ }
+
+ search_filter_criteria('tracker_id') {
+ [ [('['+l(:label_all)+']'), "A", nil]
+ ] + Tracker.find(:all).collect {|s| [s.name, s.id, ["issues.tracker_id=?", s.id]] }
+ }
+
+ search_filter_criteria('priority_id') {
+ [ [('['+l(:label_all)+']'), "A", nil]
+ ] + Enumeration.find(:all, :conditions => ['opt=?','IPRI']).collect {|s| [s.name, s.id, ["issues.priority_id=?", s.id]] }
+ }
+
+ search_filter_criteria('category_id') {
+ [ [('['+l(:label_all)+']'), "A", nil],
+ [('['+l(:label_none)+']'), "N", ["issues.category_id is null"]]
+ ] + @project.issue_categories.find(:all).collect {|s| [s.name, s.id, ["issues.category_id=?", s.id]] }
+ }
+
+ search_filter_criteria('fixed_version_id') {
+ [ [('['+l(:label_all)+']'), "A", nil],
+ [('['+l(:label_none)+']'), "N", ["issues.fixed_version_id is null"]]
+ ] + @project.versions.collect {|s| [s.name, s.id, ["issues.fixed_version_id=?", s.id]] }
+ }
+
+ search_filter_criteria('author_id') {
+ [ [('['+l(:label_all)+']'), "A", nil],
+ ] + @project.users.collect {|s| [s.display_name, s.id, ["issues.author_id=?", s.id]] }
+ }
+
+ search_filter_criteria('assigned_to_id') {
+ [ [('['+l(:label_all)+']'), "A", nil],
+ [('['+l(:label_none)+']'), "N", ["issues.assigned_to_id is null"]]
+ ] + @project.users.collect {|s| [s.display_name, s.id, ["issues.assigned_to_id=?", s.id]] }
+ }
+
+ search_filter_criteria('subproject_id') {
+ [ [('['+l(:label_none)+']'), "N", ["issues.project_id=?", @project.id]],
+ [('['+l(:label_all)+']'), "A", ["(issues.project_id=? or projects.parent_id=?)", @project.id, @project.id]]
+ ]
+ }
+ end
+end
\ No newline at end of file diff --git a/app/helpers/sort_helper.rb b/app/helpers/sort_helper.rb new file mode 100644 index 000000000..04a84c8e4 --- /dev/null +++ b/app/helpers/sort_helper.rb @@ -0,0 +1,160 @@ +# Helpers to sort tables using clickable column headers. +# +# Author: Stuart Rackham <srackham@methods.co.nz>, March 2005. +# License: This source code is released under the MIT license. +# +# - Consecutive clicks toggle the column's sort order. +# - Sort state is maintained by a session hash entry. +# - Icon image identifies sort column and state. +# - Typically used in conjunction with the Pagination module. +# +# Example code snippets: +# +# Controller: +# +# helper :sort +# include SortHelper +# +# def list +# sort_init 'last_name' +# sort_update +# @items = Contact.find_all nil, sort_clause +# end +# +# Controller (using Pagination module): +# +# helper :sort +# include SortHelper +# +# def list +# sort_init 'last_name' +# sort_update +# @contact_pages, @items = paginate :contacts, +# :order_by => sort_clause, +# :per_page => 10 +# end +# +# View (table header in list.rhtml): +# +# <thead> +# <tr> +# <%= sort_header_tag('id', :title => 'Sort by contact ID') %> +# <%= sort_header_tag('last_name', :caption => 'Name') %> +# <%= sort_header_tag('phone') %> +# <%= sort_header_tag('address', :width => 200) %> +# </tr> +# </thead> +# +# - The ascending and descending sort icon images are sort_asc.png and +# sort_desc.png and reside in the application's images directory. +# - Introduces instance variables: @sort_name, @sort_default. +# - Introduces params :sort_key and :sort_order. +# +module SortHelper + + # Initializes the default sort column (default_key) and sort order + # (default_order). + # + # - default_key is a column attribute name. + # - default_order is 'asc' or 'desc'. + # - name is the name of the session hash entry that stores the sort state, + # defaults to '<controller_name>_sort'. + # + def sort_init(default_key, default_order='asc', name=nil) + @sort_name = name || @params[:controller] + @params[:action] + '_sort' + @sort_default = {:key => default_key, :order => default_order} + end + + # Updates the sort state. Call this in the controller prior to calling + # sort_clause. + # + def sort_update() + if @params[:sort_key] + sort = {:key => @params[:sort_key], :order => @params[:sort_order]} + elsif @session[@sort_name] + sort = @session[@sort_name] # Previous sort. + else + sort = @sort_default + end + @session[@sort_name] = sort + end + + # Returns an SQL sort clause corresponding to the current sort state. + # Use this to sort the controller's table items collection. + # + def sort_clause() + @session[@sort_name][:key] + ' ' + @session[@sort_name][:order] + end + + # Returns a link which sorts by the named column. + # + # - column is the name of an attribute in the sorted record collection. + # - The optional caption explicitly specifies the displayed link text. + # - A sort icon image is positioned to the right of the sort link. + # + def sort_link(column, caption=nil) + key, order = @session[@sort_name][:key], @session[@sort_name][:order] + if key == column + if order.downcase == 'asc' + icon = 'sort_asc' + order = 'desc' + else + icon = 'sort_desc' + order = 'asc' + end + else + icon = nil + order = 'desc' # changed for desc order by default + end + caption = titleize(Inflector::humanize(column)) unless caption + params = {:params => {:sort_key => column, :sort_order => order}} + link_to_remote(caption, + {:update => "content", :url => { :sort_key => column, :sort_order => order}}, + {:href => url_for(:params => { :sort_key => column, :sort_order => order})}) + + (icon ? nbsp(2) + image_tag(icon) : '') + end + + # Returns a table header <th> tag with a sort link for the named column + # attribute. + # + # Options: + # :caption The displayed link name (defaults to titleized column name). + # :title The tag's 'title' attribute (defaults to 'Sort by :caption'). + # + # Other options hash entries generate additional table header tag attributes. + # + # Example: + # + # <%= sort_header_tag('id', :title => 'Sort by contact ID', :width => 40) %> + # + # Renders: + # + # <th title="Sort by contact ID" width="40"> + # <a href="/contact/list?sort_order=desc&sort_key=id">Id</a> + # <img alt="Sort_asc" src="/images/sort_asc.png" /> + # </th> + # + def sort_header_tag(column, options = {}) + if options[:caption] + caption = options[:caption] + options.delete(:caption) + else + caption = titleize(Inflector::humanize(column)) + end + options[:title]= "Sort by #{caption}" unless options[:title] + content_tag('th', sort_link(column, caption), options) + end + + private + + # Return n non-breaking spaces. + def nbsp(n) + ' ' * n + end + + # Return capitalized title. + def titleize(title) + title.split.map {|w| w.capitalize }.join(' ') + end + +end diff --git a/app/helpers/trackers_helper.rb b/app/helpers/trackers_helper.rb new file mode 100644 index 000000000..839327efe --- /dev/null +++ b/app/helpers/trackers_helper.rb @@ -0,0 +1,19 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module TrackersHelper +end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb new file mode 100644 index 000000000..035db3d00 --- /dev/null +++ b/app/helpers/users_helper.rb @@ -0,0 +1,19 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module UsersHelper +end diff --git a/app/helpers/versions_helper.rb b/app/helpers/versions_helper.rb new file mode 100644 index 000000000..e2724fe84 --- /dev/null +++ b/app/helpers/versions_helper.rb @@ -0,0 +1,19 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module VersionsHelper +end diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb new file mode 100644 index 000000000..cace5f542 --- /dev/null +++ b/app/helpers/welcome_helper.rb @@ -0,0 +1,19 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module WelcomeHelper +end diff --git a/app/models/attachment.rb b/app/models/attachment.rb new file mode 100644 index 000000000..2e1e9b156 --- /dev/null +++ b/app/models/attachment.rb @@ -0,0 +1,81 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require "digest/md5"
+
+class Attachment < ActiveRecord::Base
+ belongs_to :container, :polymorphic => true
+ belongs_to :author, :class_name => "User", :foreign_key => "author_id"
+
+ validates_presence_of :filename
+
+ def file=(incomming_file)
+ unless incomming_file.nil?
+ @temp_file = incomming_file
+ if @temp_file.size > 0
+ self.filename = sanitize_filename(@temp_file.original_filename)
+ self.disk_filename = DateTime.now.strftime("%y%m%d%H%M%S") + "_" + self.filename
+ self.content_type = @temp_file.content_type
+ self.filesize = @temp_file.size
+ end
+ end
+ end
+
+ # Copy temp file to its final location
+ def before_save
+ if @temp_file && (@temp_file.size > 0)
+ logger.debug("saving '#{self.diskfile}'")
+ File.open(diskfile, "wb") do |f|
+ f.write(@temp_file.read)
+ end
+ self.digest = Digest::MD5.hexdigest(File.read(diskfile))
+ end
+ end
+
+ # Deletes file on the disk
+ def after_destroy
+ if self.filename?
+ File.delete(diskfile) if File.exist?(diskfile)
+ end
+ end
+
+ # Returns file's location on disk
+ def diskfile
+ "#{$RDM_STORAGE_PATH}/#{self.disk_filename}"
+ end
+
+ def increment_download
+ increment!(:downloads)
+ end
+
+ # returns last created projects
+ def self.most_downloaded
+ find(:all, :limit => 5, :order => "downloads DESC")
+ end
+
+private
+ def sanitize_filename(value)
+ # get only the filename, not the whole path
+ just_filename = value.gsub(/^.*(\\|\/)/, '')
+ # NOTE: File.basename doesn't work right with Windows paths on Unix
+ # INCORRECT: just_filename = File.basename(value.gsub('\\\\', '/'))
+
+ # Finally, replace all non alphanumeric, underscore or periods with underscore
+ @filename = just_filename.gsub(/[^\w\.\-]/,'_')
+ end
+ +end diff --git a/app/models/auth_source.rb b/app/models/auth_source.rb new file mode 100644 index 000000000..47eec106d --- /dev/null +++ b/app/models/auth_source.rb @@ -0,0 +1,47 @@ +# redMine - project management software +# Copyright (C) 2006 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class AuthSource < ActiveRecord::Base + has_many :users + + validates_presence_of :name + validates_uniqueness_of :name + + def authenticate(login, password) + end + + def test_connection + end + + def auth_method_name + "Abstract" + end + + # Try to authenticate a user not yet registered against available sources + def self.authenticate(login, password) + AuthSource.find(:all, :conditions => ["onthefly_register=?", true]).each do |source| + begin + logger.debug "Authenticating '#{login}' against '#{source.name}'" if logger && logger.debug? + attrs = source.authenticate(login, password) + rescue + attrs = nil + end + return attrs if attrs + end + return nil + end +end diff --git a/app/models/auth_source_ldap.rb b/app/models/auth_source_ldap.rb new file mode 100644 index 000000000..895cf1c63 --- /dev/null +++ b/app/models/auth_source_ldap.rb @@ -0,0 +1,79 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require 'net/ldap'
+require 'iconv'
+
+class AuthSourceLdap < AuthSource
+ validates_presence_of :host, :port, :attr_login
+
+ def after_initialize
+ self.port = 389 if self.port == 0
+ end
+
+ def authenticate(login, password)
+ attrs = []
+ # get user's DN
+ ldap_con = initialize_ldap_con(self.account, self.account_password)
+ login_filter = Net::LDAP::Filter.eq( self.attr_login, login )
+ object_filter = Net::LDAP::Filter.eq( "objectClass", "*" )
+ dn = String.new
+ ldap_con.search( :base => self.base_dn,
+ :filter => object_filter & login_filter,
+ :attributes=> ['dn', self.attr_firstname, self.attr_lastname, self.attr_mail]) do |entry|
+ dn = entry.dn
+ attrs = [:firstname => AuthSourceLdap.get_attr(entry, self.attr_firstname),
+ :lastname => AuthSourceLdap.get_attr(entry, self.attr_lastname),
+ :mail => AuthSourceLdap.get_attr(entry, self.attr_mail),
+ :auth_source_id => self.id ]
+ end
+ return nil if dn.empty?
+ logger.debug "DN found for #{login}: #{dn}" if logger && logger.debug?
+ # authenticate user
+ ldap_con = initialize_ldap_con(dn, password)
+ return nil unless ldap_con.bind
+ # return user's attributes
+ logger.debug "Authentication successful for '#{login}'" if logger && logger.debug?
+ attrs
+ rescue Net::LDAP::LdapError => text
+ raise "LdapError: " + text
+ end
+
+ # test the connection to the LDAP
+ def test_connection
+ ldap_con = initialize_ldap_con(self.account, self.account_password)
+ ldap_con.open { }
+ rescue Net::LDAP::LdapError => text
+ raise "LdapError: " + text
+ end
+
+ def auth_method_name
+ "LDAP"
+ end
+
+private
+ def initialize_ldap_con(ldap_user, ldap_password)
+ Net::LDAP.new( {:host => self.host,
+ :port => self.port,
+ :auth => { :method => :simple, :username => Iconv.new('iso-8859-15', 'utf-8').iconv(ldap_user), :password => Iconv.new('iso-8859-15', 'utf-8').iconv(ldap_password) }}
+ )
+ end
+
+ def self.get_attr(entry, attr_name)
+ entry[attr_name].is_a?(Array) ? entry[attr_name].first : entry[attr_name]
+ end +end diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb new file mode 100644 index 000000000..924a874a3 --- /dev/null +++ b/app/models/custom_field.rb @@ -0,0 +1,42 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class CustomField < ActiveRecord::Base
+ has_many :custom_values, :dependent => true
+
+ FIELD_FORMATS = { "list" => :label_list,
+ "date" => :label_date,
+ "bool" => :label_boolean,
+ "int" => :label_integer,
+ "string" => :label_string,
+ "text" => :label_text
+ }.freeze
+
+ validates_presence_of :name, :field_format
+ validates_uniqueness_of :name
+ validates_inclusion_of :field_format, :in => FIELD_FORMATS.keys
+ validates_presence_of :possible_values, :if => Proc.new { |field| field.field_format == "list" }
+
+ # to move in project_custom_field
+ def self.for_all
+ find(:all, :conditions => ["is_for_all=?", true])
+ end
+
+ def type_name
+ nil
+ end +end
diff --git a/app/models/custom_value.rb b/app/models/custom_value.rb new file mode 100644 index 000000000..015ccd244 --- /dev/null +++ b/app/models/custom_value.rb @@ -0,0 +1,38 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class CustomValue < ActiveRecord::Base
+ belongs_to :custom_field
+ belongs_to :customized, :polymorphic => true
+
+protected
+ def validate
+ errors.add(:value, :activerecord_error_blank) and return if custom_field.is_required? and value.empty?
+ errors.add(:value, :activerecord_error_invalid) unless custom_field.regexp.empty? or value =~ Regexp.new(custom_field.regexp)
+ errors.add(:value, :activerecord_error_too_short) if custom_field.min_length > 0 and value.length < custom_field.min_length and value.length > 0
+ errors.add(:value, :activerecord_error_too_long) if custom_field.max_length > 0 and value.length > custom_field.max_length
+ case custom_field.field_format
+ when "int"
+ errors.add(:value, :activerecord_error_not_a_number) unless value =~ /^[0-9]*$/
+ when "date"
+ errors.add(:value, :activerecord_error_not_a_date) unless value =~ /^\d{4}-\d{2}-\d{2}$/ or value.empty?
+ when "list"
+ errors.add(:value, :activerecord_error_inclusion) unless custom_field.possible_values.split('|').include? value or value.empty?
+ end
+ end +end
+ diff --git a/app/models/document.rb b/app/models/document.rb new file mode 100644 index 000000000..08e0ef607 --- /dev/null +++ b/app/models/document.rb @@ -0,0 +1,24 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class Document < ActiveRecord::Base
+ belongs_to :project
+ belongs_to :category, :class_name => "Enumeration", :foreign_key => "category_id"
+ has_many :attachments, :as => :container, :dependent => true
+
+ validates_presence_of :project, :title, :category +end diff --git a/app/models/enumeration.rb b/app/models/enumeration.rb new file mode 100644 index 000000000..b5c8ed6e7 --- /dev/null +++ b/app/models/enumeration.rb @@ -0,0 +1,46 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class Enumeration < ActiveRecord::Base
+ before_destroy :check_integrity
+
+ validates_presence_of :opt, :name
+ validates_uniqueness_of :name, :scope => [:opt]
+
+ OPTIONS = {
+ "IPRI" => :enumeration_issue_priorities,
+ "DCAT" => :enumeration_doc_categories
+ }.freeze
+
+ def self.get_values(option)
+ find(:all, :conditions => ['opt=?', option])
+ end
+
+ def option_name
+ OPTIONS[self.opt]
+ end
+
+private
+ def check_integrity
+ case self.opt
+ when "IPRI"
+ raise "Can't delete enumeration" if Issue.find(:first, :conditions => ["priority_id=?", self.id])
+ when "DCAT"
+ raise "Can't delete enumeration" if Document.find(:first, :conditions => ["category_id=?", self.id])
+ end
+ end +end diff --git a/app/models/issue.rb b/app/models/issue.rb new file mode 100644 index 000000000..f00eb7a9c --- /dev/null +++ b/app/models/issue.rb @@ -0,0 +1,103 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class Issue < ActiveRecord::Base
+
+ belongs_to :project
+ belongs_to :tracker
+ belongs_to :status, :class_name => 'IssueStatus', :foreign_key => 'status_id'
+ belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
+ belongs_to :assigned_to, :class_name => 'User', :foreign_key => 'assigned_to_id'
+ belongs_to :fixed_version, :class_name => 'Version', :foreign_key => 'fixed_version_id'
+ belongs_to :priority, :class_name => 'Enumeration', :foreign_key => 'priority_id'
+ belongs_to :category, :class_name => 'IssueCategory', :foreign_key => 'category_id'
+
+ #has_many :histories, :class_name => 'IssueHistory', :dependent => true, :order => "issue_histories.created_on DESC", :include => :status
+ has_many :journals, :as => :journalized, :dependent => true
+ has_many :attachments, :as => :container, :dependent => true
+
+ has_many :custom_values, :dependent => true, :as => :customized
+ has_many :custom_fields, :through => :custom_values
+
+ validates_presence_of :subject, :description, :priority, :tracker, :author, :status
+ validates_inclusion_of :done_ratio, :in => 0..100
+ validates_associated :custom_values, :on => :update
+
+ # set default status for new issues
+ def before_validation
+ self.status = IssueStatus.default if new_record?
+ end
+
+ def validate
+ if self.due_date.nil? && @attributes['due_date'] && !@attributes['due_date'].empty?
+ errors.add :due_date, :activerecord_error_not_a_date
+ end
+
+ if self.due_date and self.start_date and self.due_date < self.start_date
+ errors.add :due_date, :activerecord_error_greater_than_start_date
+ end
+ end
+
+ #def before_create
+ # build_history
+ #end
+
+ def before_save
+ if @current_journal
+ # attributes changes
+ (Issue.column_names - %w(id description)).each {|c|
+ @current_journal.details << JournalDetail.new(:property => 'attr',
+ :prop_key => c,
+ :old_value => @issue_before_change.send(c),
+ :value => send(c)) unless send(c)==@issue_before_change.send(c)
+ }
+ # custom fields changes
+ custom_values.each {|c|
+ @current_journal.details << JournalDetail.new(:property => 'cf',
+ :prop_key => c.custom_field_id,
+ :old_value => @custom_values_before_change[c.custom_field_id],
+ :value => c.value) unless @custom_values_before_change[c.custom_field_id]==c.value
+ }
+ @current_journal.save unless @current_journal.details.empty? and @current_journal.notes.empty?
+ end
+ end
+
+ def long_id
+ "%05d" % self.id
+ end
+
+ def custom_value_for(custom_field)
+ self.custom_values.each {|v| return v if v.custom_field_id == custom_field.id }
+ return nil
+ end
+
+ def init_journal(user, notes = "")
+ @current_journal ||= Journal.new(:journalized => self, :user => user, :notes => notes)
+ @issue_before_change = self.clone
+ @custom_values_before_change = {}
+ self.custom_values.each {|c| @custom_values_before_change.store c.custom_field_id, c.value }
+ @current_journal
+ end
+
+private
+ # Creates an history for the issue
+ #def build_history
+ # @history = self.histories.build
+ # @history.status = self.status
+ # @history.author = self.author
+ #end
+end diff --git a/app/models/issue_category.rb b/app/models/issue_category.rb new file mode 100644 index 000000000..74adb8f52 --- /dev/null +++ b/app/models/issue_category.rb @@ -0,0 +1,29 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class IssueCategory < ActiveRecord::Base
+ before_destroy :check_integrity
+ belongs_to :project
+
+ validates_presence_of :name
+ validates_uniqueness_of :name, :scope => [:project_id]
+
+private
+ def check_integrity
+ raise "Can't delete category" if Issue.find(:first, :conditions => ["category_id=?", self.id])
+ end +end diff --git a/app/models/issue_custom_field.rb b/app/models/issue_custom_field.rb new file mode 100644 index 000000000..209ae206b --- /dev/null +++ b/app/models/issue_custom_field.rb @@ -0,0 +1,27 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class IssueCustomField < CustomField
+ has_and_belongs_to_many :projects, :join_table => "custom_fields_projects", :foreign_key => "custom_field_id"
+ has_and_belongs_to_many :trackers, :join_table => "custom_fields_trackers", :foreign_key => "custom_field_id"
+ has_many :issues, :through => :issue_custom_values
+
+ def type_name
+ :label_issue_plural
+ end
+end
+ diff --git a/app/models/issue_history.rb b/app/models/issue_history.rb new file mode 100644 index 000000000..4b6682600 --- /dev/null +++ b/app/models/issue_history.rb @@ -0,0 +1,24 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class IssueHistory < ActiveRecord::Base + belongs_to :status, :class_name => 'IssueStatus', :foreign_key => 'status_id'
+ belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
+ belongs_to :issue
+
+ validates_presence_of :status
+end diff --git a/app/models/issue_status.rb b/app/models/issue_status.rb new file mode 100644 index 000000000..c8a40d330 --- /dev/null +++ b/app/models/issue_status.rb @@ -0,0 +1,49 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class IssueStatus < ActiveRecord::Base
+ before_destroy :check_integrity
+ has_many :workflows, :foreign_key => "old_status_id"
+
+ validates_presence_of :name
+ validates_uniqueness_of :name
+ validates_length_of :html_color, :is => 6
+ validates_format_of :html_color, :with => /^[a-f0-9]*$/i
+
+ def before_save
+ IssueStatus.update_all "is_default=false" if self.is_default?
+ end
+
+ # Returns the default status for new issues
+ def self.default
+ find(:first, :conditions =>["is_default=?", true])
+ end
+
+ # Returns an array of all statuses the given role can switch to
+ def new_statuses_allowed_to(role, tracker)
+ statuses = []
+ for workflow in self.workflows
+ statuses << workflow.new_status if workflow.role_id == role.id and workflow.tracker_id == tracker.id
+ end unless role.nil? or tracker.nil?
+ statuses
+ end
+
+private
+ def check_integrity
+ raise "Can't delete status" if Issue.find(:first, :conditions => ["status_id=?", self.id]) or IssueHistory.find(:first, :conditions => ["status_id=?", self.id])
+ end +end diff --git a/app/models/journal.rb b/app/models/journal.rb new file mode 100644 index 000000000..9d173552f --- /dev/null +++ b/app/models/journal.rb @@ -0,0 +1,22 @@ +# redMine - project management software +# Copyright (C) 2006 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class Journal < ActiveRecord::Base + belongs_to :journalized, :polymorphic => true + belongs_to :user + has_many :details, :class_name => "JournalDetail", :dependent => true +end diff --git a/app/models/journal_detail.rb b/app/models/journal_detail.rb new file mode 100644 index 000000000..784e98bf7 --- /dev/null +++ b/app/models/journal_detail.rb @@ -0,0 +1,20 @@ +# redMine - project management software +# Copyright (C) 2006 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class JournalDetail < ActiveRecord::Base + belongs_to :journal +end diff --git a/app/models/mailer.rb b/app/models/mailer.rb new file mode 100644 index 000000000..07047c594 --- /dev/null +++ b/app/models/mailer.rb @@ -0,0 +1,53 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class Mailer < ActionMailer::Base
+
+ helper IssuesHelper + + def issue_add(issue) + # Sends to all project members + @recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification } + @from = $RDM_MAIL_FROM + @subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}" + @body['issue'] = issue
+ end
+
+ def issue_edit(journal)
+ # Sends to all project members
+ issue = journal.journalized
+ @recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }
+ @from = $RDM_MAIL_FROM
+ @subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}"
+ @body['issue'] = issue
+ @body['journal']= journal
+ end
+
+ def lost_password(token)
+ @recipients = token.user.mail
+ @from = $RDM_MAIL_FROM
+ @subject = l(:mail_subject_lost_password)
+ @body['token'] = token
+ end +
+ def register(token)
+ @recipients = token.user.mail
+ @from = $RDM_MAIL_FROM
+ @subject = l(:mail_subject_register)
+ @body['token'] = token
+ end
+end diff --git a/app/models/member.rb b/app/models/member.rb new file mode 100644 index 000000000..1214b6443 --- /dev/null +++ b/app/models/member.rb @@ -0,0 +1,29 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class Member < ActiveRecord::Base
+ belongs_to :user
+ belongs_to :role
+ belongs_to :project
+
+ validates_presence_of :role, :user, :project
+ validates_uniqueness_of :user_id, :scope => :project_id
+
+ def name
+ self.user.display_name
+ end +end diff --git a/app/models/news.rb b/app/models/news.rb new file mode 100644 index 000000000..faafa7eef --- /dev/null +++ b/app/models/news.rb @@ -0,0 +1,28 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class News < ActiveRecord::Base
+ belongs_to :project
+ belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
+
+ validates_presence_of :title, :description
+
+ # returns last created news
+ def self.latest
+ find(:all, :limit => 5, :include => [ :author, :project ], :order => "news.created_on DESC")
+ end +end diff --git a/app/models/permission.rb b/app/models/permission.rb new file mode 100644 index 000000000..620974608 --- /dev/null +++ b/app/models/permission.rb @@ -0,0 +1,63 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class Permission < ActiveRecord::Base
+ has_and_belongs_to_many :roles
+
+ validates_presence_of :controller, :action, :description
+
+ GROUPS = {
+ 100 => :label_project,
+ 200 => :label_member_plural,
+ 300 => :label_version_plural,
+ 400 => :label_issue_category_plural,
+ 1000 => :label_issue_plural,
+ 1100 => :label_news_plural,
+ 1200 => :label_document_plural,
+ 1300 => :label_attachment_plural,
+ }.freeze
+
+ @@cached_perms_for_public = nil
+ @@cached_perms_for_roles = nil
+
+ def name
+ self.controller + "/" + self.action
+ end
+
+ def group_id
+ (self.sort / 100)*100
+ end
+
+ def self.allowed_to_public(action)
+ @@cached_perms_for_public ||= find(:all, :conditions => ["is_public=?", true]).collect {|p| "#{p.controller}/#{p.action}"}
+ @@cached_perms_for_public.include? action
+ end
+
+ def self.allowed_to_role(action, role)
+ @@cached_perms_for_roles ||=
+ begin
+ perms = {}
+ find(:all, :include => :roles).each {|p| perms.store "#{p.controller}/#{p.action}", p.roles.collect {|r| r.id } }
+ perms
+ end
+ @@cached_perms_for_roles[action] and @@cached_perms_for_roles[action].include? role
+ end
+
+ def self.allowed_to_role_expired
+ @@cached_perms_for_roles = nil
+ end +end diff --git a/app/models/project.rb b/app/models/project.rb new file mode 100644 index 000000000..ae7436910 --- /dev/null +++ b/app/models/project.rb @@ -0,0 +1,57 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class Project < ActiveRecord::Base
+ has_many :versions, :dependent => true, :order => "versions.effective_date DESC, versions.name DESC"
+ has_many :members, :dependent => true
+ has_many :users, :through => :members
+ has_many :custom_values, :dependent => true, :as => :customized
+ has_many :issues, :dependent => true, :order => "issues.created_on DESC", :include => :status
+ has_many :documents, :dependent => true
+ has_many :news, :dependent => true, :include => :author
+ has_many :issue_categories, :dependent => true, :order => "issue_categories.name"
+ has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => 'custom_fields_projects', :association_foreign_key => 'custom_field_id'
+ acts_as_tree :order => "name", :counter_cache => true
+
+ validates_presence_of :name, :description
+ validates_uniqueness_of :name
+ validates_associated :custom_values, :on => :update
+
+ # returns 5 last created projects
+ def self.latest
+ find(:all, :limit => 5, :order => "created_on DESC")
+ end
+
+ # Returns an array of all custom fields enabled for project issues
+ # (explictly associated custom fields and custom fields enabled for all projects)
+ def custom_fields_for_issues(tracker)
+ tracker.custom_fields.find(:all, :include => :projects,
+ :conditions => ["is_for_all=? or project_id=?", true, self.id])
+ #(CustomField.for_all + custom_fields).uniq
+ end
+
+ def all_custom_fields
+ @all_custom_fields ||= IssueCustomField.find(:all, :include => :projects,
+ :conditions => ["is_for_all=? or project_id=?", true, self.id])
+ end
+
+protected
+ def validate
+ errors.add(parent_id, " must be a root project") if parent and parent.parent
+ errors.add_to_base("A project with subprojects can't be a subproject") if parent and projects_count > 0
+ end +end diff --git a/app/models/project_custom_field.rb b/app/models/project_custom_field.rb new file mode 100644 index 000000000..baa533812 --- /dev/null +++ b/app/models/project_custom_field.rb @@ -0,0 +1,22 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class ProjectCustomField < CustomField
+ def type_name
+ :label_project_plural
+ end
+end
diff --git a/app/models/role.rb b/app/models/role.rb new file mode 100644 index 000000000..6908095e9 --- /dev/null +++ b/app/models/role.rb @@ -0,0 +1,31 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class Role < ActiveRecord::Base
+ before_destroy :check_integrity
+ has_and_belongs_to_many :permissions
+ has_many :workflows, :dependent => true
+ has_many :members
+
+ validates_presence_of :name
+ validates_uniqueness_of :name
+
+private
+ def check_integrity
+ raise "Can't delete role" if Member.find(:first, :conditions =>["role_id=?", self.id])
+ end +end diff --git a/app/models/token.rb b/app/models/token.rb new file mode 100644 index 000000000..98745d29e --- /dev/null +++ b/app/models/token.rb @@ -0,0 +1,44 @@ +# redMine - project management software +# Copyright (C) 2006 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class Token < ActiveRecord::Base + belongs_to :user + + @@validity_time = 1.day + + def before_create + self.value = Token.generate_token_value + end + + # Return true if token has expired + def expired? + return Time.now > self.created_on + @@validity_time + end + + # Delete all expired tokens + def self.destroy_expired + Token.delete_all ["created_on < ?", Time.now - @@validity_time] + end + +private + def self.generate_token_value + chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a + token_value = '' + 40.times { |i| token_value << chars[rand(chars.size-1)] } + token_value + end +end diff --git a/app/models/tracker.rb b/app/models/tracker.rb new file mode 100644 index 000000000..a4376a351 --- /dev/null +++ b/app/models/tracker.rb @@ -0,0 +1,31 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class Tracker < ActiveRecord::Base
+ before_destroy :check_integrity
+ has_many :issues
+ has_many :workflows, :dependent => true
+ has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => 'custom_fields_trackers', :association_foreign_key => 'custom_field_id'
+
+ validates_presence_of :name
+ validates_uniqueness_of :name
+
+private
+ def check_integrity
+ raise "Can't delete tracker" if Issue.find(:first, :conditions => ["tracker_id=?", self.id])
+ end +end diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 000000000..a82c98a88 --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,129 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require "digest/sha1"
+
+class User < ActiveRecord::Base
+ has_many :memberships, :class_name => 'Member', :include => [ :project, :role ], :dependent => true
+ has_many :projects, :through => :memberships
+ has_many :custom_values, :dependent => true, :as => :customized
+ has_one :preference, :dependent => true, :class_name => 'UserPreference'
+ belongs_to :auth_source
+
+ attr_accessor :password, :password_confirmation
+ attr_accessor :last_before_login_on
+ # Prevents unauthorized assignments
+ attr_protected :login, :admin, :password, :password_confirmation, :hashed_password
+
+ validates_presence_of :login, :firstname, :lastname, :mail
+ validates_uniqueness_of :login, :mail
+ # Login must contain lettres, numbers, underscores only
+ validates_format_of :login, :with => /^[a-z0-9_]+$/i
+ validates_format_of :mail, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
+ # Password length between 4 and 12
+ validates_length_of :password, :in => 4..12, :allow_nil => true
+ validates_confirmation_of :password, :allow_nil => true
+ validates_associated :custom_values, :on => :update
+
+ # Account statuses
+ STATUS_ACTIVE = 1
+ STATUS_REGISTERED = 2
+ STATUS_LOCKED = 3
+
+ def before_save
+ # update hashed_password if password was set
+ self.hashed_password = User.hash_password(self.password) if self.password
+ end
+
+ # Returns the user that matches provided login and password, or nil
+ def self.try_to_login(login, password)
+ user = find(:first, :conditions => ["login=?", login])
+ if user
+ # user is already in local database
+ return nil if !user.active?
+ if user.auth_source
+ # user has an external authentication method
+ return nil unless user.auth_source.authenticate(login, password)
+ else
+ # authentication with local password
+ return nil unless User.hash_password(password) == user.hashed_password
+ end
+ else
+ # user is not yet registered, try to authenticate with available sources
+ attrs = AuthSource.authenticate(login, password)
+ if attrs
+ onthefly = new(*attrs)
+ onthefly.login = login
+ onthefly.language = $RDM_DEFAULT_LANG
+ if onthefly.save
+ user = find(:first, :conditions => ["login=?", login])
+ logger.info("User '#{user.login}' created on the fly.") if logger
+ end
+ end
+ end
+ user.update_attribute(:last_login_on, Time.now) if user
+ user
+
+ rescue => text
+ raise text
+ end
+
+ # Return user's full name for display
+ def display_name
+ firstname + " " + lastname
+ end
+
+ def name
+ display_name
+ end
+
+ def active?
+ self.status == STATUS_ACTIVE
+ end
+
+ def registered?
+ self.status == STATUS_REGISTERED
+ end
+
+ def locked?
+ self.status == STATUS_LOCKED
+ end
+
+ def check_password?(clear_password)
+ User.hash_password(clear_password) == self.hashed_password
+ end
+
+ def role_for_project(project_id)
+ @role_for_projects ||=
+ begin
+ roles = {}
+ self.memberships.each { |m| roles.store m.project_id, m.role_id }
+ roles
+ end
+ @role_for_projects[project_id]
+ end
+
+ def pref
+ self.preference ||= UserPreference.new(:user => self)
+ end
+
+private
+ # Return password digest
+ def self.hash_password(clear_password)
+ Digest::SHA1.hexdigest(clear_password || "")
+ end +end diff --git a/app/models/user_custom_field.rb b/app/models/user_custom_field.rb new file mode 100644 index 000000000..866234a7f --- /dev/null +++ b/app/models/user_custom_field.rb @@ -0,0 +1,23 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class UserCustomField < CustomField
+ def type_name
+ :label_user_plural
+ end
+end
+ diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb new file mode 100644 index 000000000..5240c9757 --- /dev/null +++ b/app/models/user_preference.rb @@ -0,0 +1,44 @@ +# redMine - project management software +# Copyright (C) 2006 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class UserPreference < ActiveRecord::Base + belongs_to :user + serialize :others, Hash + + attr_protected :others + + def initialize(attributes = nil) + super + self.others ||= {} + end + + def [](attr_name) + if attribute_present? attr_name + super + else + others[attr_name] + end + end + + def []=(attr_name, value) + if attribute_present? attr_name + super + else + others.store attr_name, value + end + end +end diff --git a/app/models/version.rb b/app/models/version.rb new file mode 100644 index 000000000..0ae1edda8 --- /dev/null +++ b/app/models/version.rb @@ -0,0 +1,32 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class Version < ActiveRecord::Base
+ before_destroy :check_integrity
+ belongs_to :project
+ has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id'
+ has_many :attachments, :as => :container, :dependent => true
+
+ validates_presence_of :name
+ validates_uniqueness_of :name, :scope => [:project_id]
+ validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => :activerecord_error_not_a_date
+
+private
+ def check_integrity
+ raise "Can't delete version" if self.fixed_issues.find(:first)
+ end
+end diff --git a/app/models/workflow.rb b/app/models/workflow.rb new file mode 100644 index 000000000..22c873fc7 --- /dev/null +++ b/app/models/workflow.rb @@ -0,0 +1,24 @@ +# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class Workflow < ActiveRecord::Base
+ belongs_to :role
+ belongs_to :old_status, :class_name => 'IssueStatus', :foreign_key => 'old_status_id'
+ belongs_to :new_status, :class_name => 'IssueStatus', :foreign_key => 'new_status_id'
+
+ validates_presence_of :role, :old_status, :new_status
+end diff --git a/app/views/account/login.rhtml b/app/views/account/login.rhtml new file mode 100644 index 000000000..74c075516 --- /dev/null +++ b/app/views/account/login.rhtml @@ -0,0 +1,18 @@ +<center>
+<div class="box login">
+<h2><%= image_tag 'login' %> <%=l(:label_please_login)%></h2> +
+<%= start_form_tag({:action=> "login"}, :class => "tabular") %>
+<p><label for="login"><%=l(:field_login)%>:</label>
+<%= text_field_tag 'login', nil, :size => 25 %></p>
+
+<p><label for="password"><%=l(:field_password)%>:</label>
+<%= password_field_tag 'password', nil, :size => 25 %></p>
+
+<p><center><input type="submit" name="login" value="<%=l(:button_login)%> »" class="primary" /></center> +<%= end_form_tag %>
+
+<br><% unless $RDM_SELF_REGISTRATION == false %><%= link_to l(:label_register), :action => 'register' %> |<% end %>
+<%= link_to l(:label_password_lost), :action => 'lost_password' %></p> +</div>
+</center>
\ No newline at end of file diff --git a/app/views/account/lost_password.rhtml b/app/views/account/lost_password.rhtml new file mode 100644 index 000000000..3f32e7153 --- /dev/null +++ b/app/views/account/lost_password.rhtml @@ -0,0 +1,14 @@ +<center>
+<div class="box login">
+<h2><%=l(:label_password_lost)%></h2>
+
+<%= start_form_tag({:action=> "lost_password"}, :class => "tabular") %>
+
+<p><label for="mail"><%=l(:field_mail)%> <span class="required">*</span></label>
+<%= text_field_tag 'mail', nil, :size => 40 %></p>
+
+<p><center><%= submit_tag l(:button_submit) %></center></p>
+
+<%= end_form_tag %>
+</div>
+</center>
\ No newline at end of file diff --git a/app/views/account/password_recovery.rhtml b/app/views/account/password_recovery.rhtml new file mode 100644 index 000000000..39a8071a9 --- /dev/null +++ b/app/views/account/password_recovery.rhtml @@ -0,0 +1,21 @@ +<center> +<div class="box login"> +<h2><%=l(:label_password_lost)%></h2> +
+<p><%=l(:field_login)%>: <strong><%= @user.login %></strong><br />
+ +<%= error_messages_for 'user' %> +
+ <%= start_form_tag({:token => @token.value}, :class => "tabular") %> +
+ <p><label for="new_password"><%=l(:field_new_password)%> <span class="required">*</span></label> + <%= password_field_tag 'new_password', nil, :size => 25 %></p>
+
+ <p><label for="new_password_confirmation"><%=l(:field_password_confirmation)%> <span class="required">*</span></label> + <%= password_field_tag 'new_password_confirmation', nil, :size => 25 %></p>
+ + <p><center><%= submit_tag l(:button_save) %></center></p> + <%= end_form_tag %>
+
+</div> +</center>
\ No newline at end of file diff --git a/app/views/account/register.rhtml b/app/views/account/register.rhtml new file mode 100644 index 000000000..b34aff79c --- /dev/null +++ b/app/views/account/register.rhtml @@ -0,0 +1,39 @@ +<h2><%=l(:label_register)%></h2> + +<%= start_form_tag({:action => 'register'}, :class => "tabular") %> +<%= error_messages_for 'user' %> + +<div class="box"> +<!--[form:user]--> +<p><label for="user_login"><%=l(:field_login)%> <span class="required">*</span></label> +<%= text_field 'user', 'login', :size => 25 %></p> +
+<p><label for="password"><%=l(:field_password)%> <span class="required">*</span></label> +<%= password_field_tag 'password', nil, :size => 25 %></p> + +<p><label for="password_confirmation"><%=l(:field_password_confirmation)%> <span class="required">*</span></label> +<%= password_field_tag 'password_confirmation', nil, :size => 25 %></p> + +<p><label for="user_firstname"><%=l(:field_firstname)%> <span class="required">*</span></label> +<%= text_field 'user', 'firstname' %></p> +
+<p><label for="user_lastname"><%=l(:field_lastname)%> <span class="required">*</span></label> +<%= text_field 'user', 'lastname' %></p> + +<p><label for="user_mail"><%=l(:field_mail)%> <span class="required">*</span></label> +<%= text_field 'user', 'mail' %></p>
+
+<p><label for="user_language"><%=l(:field_language)%></label> +<%= select("user", "language", lang_options_for_select) %></p>
+
+<% for @custom_value in @custom_values %> + <p><%= custom_field_tag_with_label @custom_value %></p> +<% end %>
+
+<p><label for="user_mail_notification"><%=l(:field_mail_notification)%></label> +<%= check_box 'user', 'mail_notification' %></p>
+<!--[eoform:user]--> +</div> + +<%= submit_tag l(:button_submit) %> +<%= end_form_tag %> diff --git a/app/views/account/show.rhtml b/app/views/account/show.rhtml new file mode 100644 index 000000000..985238951 --- /dev/null +++ b/app/views/account/show.rhtml @@ -0,0 +1,26 @@ +<h2><%= @user.display_name %></h2>
+
+<p>
+<%= mail_to @user.mail unless @user.pref.hide_mail %>
+<ul>
+ <li><%=l(:label_registered_on)%>: <%= format_date(@user.created_on) %></li>
+<% for custom_value in @custom_values %>
+<% if !custom_value.value.empty? %>
+ <li><%= custom_value.custom_field.name%>: <%= show_value(custom_value) %></li>
+<% end %>
+<% end %>
+</ul>
+</p>
+
+<h3><%=l(:label_project_plural)%></h3>
+<p>
+<% for membership in @user.memberships %>
+ <%= membership.project.name %> (<%= membership.role.name %>, <%= format_date(membership.created_on) %>)
+ <br />
+<% end %>
+</p>
+
+<h3><%=l(:label_activity)%></h3>
+<p>
+<%=l(:label_reported_issues)%>: <%= Issue.count(["author_id=?", @user.id]) %>
+</p>
\ No newline at end of file diff --git a/app/views/admin/index.rhtml b/app/views/admin/index.rhtml new file mode 100644 index 000000000..d937e287c --- /dev/null +++ b/app/views/admin/index.rhtml @@ -0,0 +1,50 @@ +<h2><%=l(:label_administration)%></h2>
+
+<p>
+<%= image_tag "projects" %>
+<%= link_to l(:label_project_plural), :controller => 'admin', :action => 'projects' %> |
+<%= link_to l(:label_new), :controller => 'projects', :action => 'add' %>
+</p>
+
+<p>
+<%= image_tag "users" %>
+<%= link_to l(:label_user_plural), :controller => 'users' %> |
+<%= link_to l(:label_new), :controller => 'users', :action => 'add' %>
+</p>
+
+<p>
+<%= image_tag "role" %>
+<%= link_to l(:label_role_and_permissions), :controller => 'roles' %>
+</p>
+
+<p>
+<%= image_tag "tracker" %>
+<%= link_to l(:label_tracker_plural), :controller => 'trackers' %> |
+<%= link_to l(:label_custom_field_plural), :controller => 'custom_fields' %>
+</p>
+
+<p>
+<%= image_tag "workflow" %>
+<%= link_to l(:label_issue_status_plural), :controller => 'issue_statuses' %> |
+<%= link_to l(:label_workflow), :controller => 'roles', :action => 'workflow' %>
+</p>
+
+<p>
+<%= image_tag "options" %>
+<%= link_to l(:label_enumerations), :controller => 'enumerations' %>
+</p>
+
+<p>
+<%= image_tag "mailer" %>
+<%= link_to l(:field_mail_notification), :controller => 'admin', :action => 'mail_options' %>
+</p>
+
+<p>
+<%= image_tag "login" %>
+<%= link_to l(:label_authentication), :controller => 'auth_sources' %>
+</p>
+
+<p>
+<%= image_tag "help" %>
+<%= link_to l(:label_information_plural), :controller => 'admin', :action => 'info' %>
+</p>
\ No newline at end of file diff --git a/app/views/admin/info.rhtml b/app/views/admin/info.rhtml new file mode 100644 index 000000000..4777a151e --- /dev/null +++ b/app/views/admin/info.rhtml @@ -0,0 +1,10 @@ +<h2><%=l(:label_information_plural)%></h2>
+
+<p><%=l(:field_version)%>: <strong><%= RDM_APP_NAME %> <%= RDM_APP_VERSION %></strong></p>
+
+<%=l(:label_environment)%>:
+<ul>
+<% Rails::Info.properties.each do |name, value| %>
+<li><%= name %>: <%= value %></li>
+<% end %>
+</ul>
\ No newline at end of file diff --git a/app/views/admin/mail_options.rhtml b/app/views/admin/mail_options.rhtml new file mode 100644 index 000000000..54e2daf3e --- /dev/null +++ b/app/views/admin/mail_options.rhtml @@ -0,0 +1,24 @@ +<h2><%=l(:field_mail_notification)%></h2>
+
+<%= start_form_tag ({}, :id => 'mail_options_form')%>
+
+<div class="box">
+<p><%=l(:text_select_mail_notifications)%></p>
+
+<% actions = @actions.group_by {|p| p.group_id } %>
+<% actions.keys.sort.each do |group_id| %>
+<fieldset style="margin-top: 6px;"><legend><strong><%= l(Permission::GROUPS[group_id]) %></strong></legend>
+<% actions[group_id].each do |p| %>
+ <div style="width:170px;float:left;"><%= check_box_tag "action_ids[]", p.id, p.mail_enabled? %>
+ <%= l(p.description.to_sym) %>
+ </div>
+<% end %>
+</fieldset>
+<% end %>
+
+<br />
+<p><%= check_all_links 'mail_options_form' %></p>
+</div>
+
+<%= submit_tag l(:button_save) %>
+<%= end_form_tag %>
diff --git a/app/views/admin/projects.rhtml b/app/views/admin/projects.rhtml new file mode 100644 index 000000000..39e4d9bf7 --- /dev/null +++ b/app/views/admin/projects.rhtml @@ -0,0 +1,30 @@ +<h2><%=l(:label_project_plural)%></h2> + +<table class="listTableContent"> + <tr class="ListHead"> + <%= sort_header_tag('name', :caption => l(:label_project)) %>
+ <th><%=l(:field_description)%></th>
+ <th><%=l(:field_is_public)%></th> + <th><%=l(:label_subproject_plural)%></th>
+ <%= sort_header_tag('created_on', :caption => l(:field_created_on)) %>
+ <th></th> + </tr> + +<% for project in @projects %> + <tr class="<%= cycle("odd", "even") %>">
+ <td><%= link_to project.name, :controller => 'projects', :action => 'settings', :id => project %>
+ <td><%= project.description %>
+ <td align="center"><%= image_tag 'true' if project.is_public? %> + <td align="center"><%= project.projects_count %>
+ <td align="center"><%= format_date(project.created_on) %>
+ <td align="center"> + <%= button_to l(:button_delete), { :controller => 'projects', :action => 'destroy', :id => project }, :class => "button-small" %>
+ </td>
+ </tr> +<% end %> +</table> + +<p><%= pagination_links_full @project_pages %> +[ <%= @project_pages.current.first_item %> - <%= @project_pages.current.last_item %> / <%= @project_count %> ]</p>
+ +<p><%= link_to ('» ' + l(:label_project_new)), :controller => 'projects', :action => 'add' %></p>
\ No newline at end of file diff --git a/app/views/auth_sources/_form.rhtml b/app/views/auth_sources/_form.rhtml new file mode 100644 index 000000000..b6365dce5 --- /dev/null +++ b/app/views/auth_sources/_form.rhtml @@ -0,0 +1,45 @@ +<%= error_messages_for 'auth_source' %> + +<div class="box"> +<!--[form:auth_source]--> +<p><label for="auth_source_name"><%=l(:field_name)%> <span class="required">*</span></label> +<%= text_field 'auth_source', 'name' %></p> + +<p><label for="auth_source_host"><%=l(:field_host)%> <span class="required">*</span></label> +<%= text_field 'auth_source', 'host' %></p> + +<p><label for="auth_source_port"><%=l(:field_port)%> <span class="required">*</span></label> +<%= text_field 'auth_source', 'port', :size => 6 %></p> + +<p><label for="auth_source_account"><%=l(:field_account)%></label> +<%= text_field 'auth_source', 'account' %></p> + +<p><label for="auth_source_account_password"><%=l(:field_password)%></label> +<%= password_field 'auth_source', 'account_password' %></p> + +<p><label for="auth_source_base_dn"><%=l(:field_base_dn)%> <span class="required">*</span></label> +<%= text_field 'auth_source', 'base_dn', :size => 60 %></p> +</div> + +<div class="box"> +<p><label for="auth_source_onthefly_register"><%=l(:field_onthefly)%></label> +<%= check_box 'auth_source', 'onthefly_register' %></p> + +<p> +<fieldset><legend><%=l(:label_attribute_plural)%></legend> +<p><label for="auth_source_attr_login"><%=l(:field_login)%> <span class="required">*</span></label> +<%= text_field 'auth_source', 'attr_login', :size => 20 %></p> + +<p><label for="auth_source_attr_firstname"><%=l(:field_firstname)%></label> +<%= text_field 'auth_source', 'attr_firstname', :size => 20 %></p> + +<p><label for="auth_source_attr_lastname"><%=l(:field_lastname)%></label> +<%= text_field 'auth_source', 'attr_lastname', :size => 20 %></p> + +<p><label for="auth_source_attr_mail"><%=l(:field_mail)%></label> +<%= text_field 'auth_source', 'attr_mail', :size => 20 %></p> +</fieldset> +</p> +</div> +<!--[eoform:auth_source]--> + diff --git a/app/views/auth_sources/edit.rhtml b/app/views/auth_sources/edit.rhtml new file mode 100644 index 000000000..149463e7f --- /dev/null +++ b/app/views/auth_sources/edit.rhtml @@ -0,0 +1,7 @@ +<h2><%=l(:label_auth_source)%> (<%= @auth_source.auth_method_name %>)</h2> + +<%= start_form_tag({:action => 'update', :id => @auth_source}, :class => "tabular") %> + <%= render :partial => 'form' %> + <%= submit_tag l(:button_save) %> +<%= end_form_tag %> + diff --git a/app/views/auth_sources/list.rhtml b/app/views/auth_sources/list.rhtml new file mode 100644 index 000000000..47cbeeaff --- /dev/null +++ b/app/views/auth_sources/list.rhtml @@ -0,0 +1,30 @@ +<h2><%=l(:label_auth_source_plural)%></h2> + +<table class="listTableContent"> + <tr class="ListHead"> + <th><%=l(:field_name)%></th> + <th><%=l(:field_type)%></th> + <th><%=l(:field_host)%></th> + <th></th> + <th></th> + </tr> + +<% for source in @auth_sources %> + <tr class="<%= cycle("odd", "even") %>"> + <td><%= link_to source.name, :action => 'edit', :id => source%></td> + <td align="center"><%= source.auth_method_name %></td> + <td align="center"><%= source.host %></td> + <td align="center"> + <%= link_to l(:button_test), :action => 'test_connection', :id => source %> + </td> + <td align="center"> + <%= button_to l(:button_delete), { :action => 'destroy', :id => source }, :confirm => l(:text_are_you_sure), :class => "button-small" %> + </td> + </tr> +<% end %> +</table> + +<%= pagination_links_full @auth_source_pages %> +<br /> +<%= link_to '» ' + l(:label_auth_source_new), :action => 'new' %> + diff --git a/app/views/auth_sources/new.rhtml b/app/views/auth_sources/new.rhtml new file mode 100644 index 000000000..29d66327b --- /dev/null +++ b/app/views/auth_sources/new.rhtml @@ -0,0 +1,6 @@ +<h2><%=l(:label_auth_source_new)%> (<%= @auth_source.auth_method_name %>)</h2> + +<%= start_form_tag({:action => 'create'}, :class => "tabular") %> + <%= render :partial => 'form' %> + <%= submit_tag l(:button_create) %> +<%= end_form_tag %> diff --git a/app/views/custom_fields/_form.rhtml b/app/views/custom_fields/_form.rhtml new file mode 100644 index 000000000..f7f968e33 --- /dev/null +++ b/app/views/custom_fields/_form.rhtml @@ -0,0 +1,52 @@ +<%= error_messages_for 'custom_field' %> + +<!--[form:custom_field]--> +<div class="box"> +<p><label for="custom_field_name"><%=l(:field_name)%><span class="required"> *</span></label> +<%= text_field 'custom_field', 'name' %></p> +
+<p><label for="custom_field_field_format"><%=l(:field_field_format)%></label> +<%= select("custom_field", "field_format", custom_field_formats_for_select) %></p>
+
+<p><label for="custom_field_min_length"><%=l(:label_min_max_length)%></label> +<%= text_field 'custom_field', 'min_length', :size => 5 %> - +<%= text_field 'custom_field', 'max_length', :size => 5 %><br>(<%=l(:text_min_max_length_info)%>)</p>
+
+<p><label for="custom_field_regexp"><%=l(:field_regexp)%></label> +<%= text_field 'custom_field', 'regexp', :size => 50 %><br>(<%=l(:text_regexp_info)%>)</p>
+
+<p><label for="custom_field_possible_values"><%=l(:field_possible_values)%></label> +<%= text_area 'custom_field', 'possible_values', :rows => 5, :cols => 60 %><br>(<%=l(:text_possible_values_info)%>)</p> +</div>
+<!--[eoform:custom_field]--> + +<div class="box"> +<% case type.to_s + when "IssueCustomField" %>
+
+<fieldset><legend><%=l(:label_tracker_plural)%></legend>
+<% for tracker in @trackers %>
+ <input type="checkbox"
+ name="tracker_ids[]"
+ value="<%= tracker.id %>"
+ <%if @custom_field.trackers.include? tracker%>checked="checked"<%end%>
+ > <%= tracker.name %>
+<% end %></fieldset>
+ + +<p><label for="custom_field_is_required"><%=l(:field_is_required)%></label> +<%= check_box 'custom_field', 'is_required' %></p> + +<p><label for="custom_field_is_for_all"><%=l(:field_is_for_all)%></label> +<%= check_box 'custom_field', 'is_for_all' %></p> + +<% when "UserCustomField" %> +<p><label for="custom_field_is_required"><%=l(:field_is_required)%></label> +<%= check_box 'custom_field', 'is_required' %></p> + +<% when "ProjectCustomField" %> +<p><label for="custom_field_is_required"><%=l(:field_is_required)%></label> +<%= check_box 'custom_field', 'is_required' %></p> + +<% end %> +</div> diff --git a/app/views/custom_fields/edit.rhtml b/app/views/custom_fields/edit.rhtml new file mode 100644 index 000000000..201047a8d --- /dev/null +++ b/app/views/custom_fields/edit.rhtml @@ -0,0 +1,6 @@ +<h2><%=l(:label_custom_field)%> (<%=l(@custom_field.type_name)%>)</h2> + +<%= start_form_tag({:action => 'edit', :id => @custom_field}, :class => "tabular") %> + <%= render :partial => 'form', :locals => { :type => @custom_field.type } %> + <%= submit_tag l(:button_save) %> +<%= end_form_tag %> diff --git a/app/views/custom_fields/list.rhtml b/app/views/custom_fields/list.rhtml new file mode 100644 index 000000000..858590c49 --- /dev/null +++ b/app/views/custom_fields/list.rhtml @@ -0,0 +1,36 @@ +<h2><%=l(:label_custom_field_plural)%></h2> +
+<table class="listTableContent">
+<tr class="ListHead"> + <th><%=l(:field_name)%></th> + <th><%=l(:field_type)%></th>
+ <th><%=l(:field_field_format)%></th>
+ <th><%=l(:field_is_required)%></th>
+ <th><%=l(:field_is_for_all)%></th>
+ <th><%=l(:label_used_by)%></th>
+ <th></th>
+</tr> +<% for custom_field in @custom_fields %> + <tr class="<%= cycle("odd", "even") %>">
+ <td><%= link_to custom_field.name, :action => 'edit', :id => custom_field %></td>
+ <td align="center"><%= l(custom_field.type_name) %></td> + <td align="center"><%= l(CustomField::FIELD_FORMATS[custom_field.field_format]) %></td>
+ <td align="center"><%= image_tag 'true' if custom_field.is_required? %></td>
+ <td align="center"><%= image_tag 'true' if custom_field.is_for_all? %></td>
+ <td align="center"><%= custom_field.projects.count.to_s + ' ' + lwr(:label_project, custom_field.projects.count) if custom_field.is_a? IssueCustomField and !custom_field.is_for_all? %></td> + <td align="center"> + <%= button_to l(:button_delete), { :action => 'destroy', :id => custom_field }, :confirm => l(:text_are_you_sure), :class => "button-small" %> + </td> + </tr> +<% end %> +</table>
+ +<%= pagination_links_full @custom_field_pages %> + +<br /> +<%=l(:label_custom_field_new)%>: +<ul> +<li><%= link_to l(:label_issue_plural), :action => 'new', :type => 'IssueCustomField' %></li> +<li><%= link_to l(:label_project_plural), :action => 'new', :type => 'ProjectCustomField' %></li> +<li><%= link_to l(:label_user_plural), :action => 'new', :type => 'UserCustomField' %></li> +</ul> diff --git a/app/views/custom_fields/new.rhtml b/app/views/custom_fields/new.rhtml new file mode 100644 index 000000000..3b215dc9f --- /dev/null +++ b/app/views/custom_fields/new.rhtml @@ -0,0 +1,8 @@ +<h2><%=l(:label_custom_field_new)%> (<%=l(@custom_field.type_name)%>)</h2> + +<%= start_form_tag({:action => 'new'}, :class => "tabular") %> + <%= render :partial => 'form', :locals => { :type => @custom_field.type } %> + <%= hidden_field_tag 'type', @custom_field.type %> + <%= submit_tag l(:button_save) %> +<%= end_form_tag %> + diff --git a/app/views/documents/_form.rhtml b/app/views/documents/_form.rhtml new file mode 100644 index 000000000..873c96329 --- /dev/null +++ b/app/views/documents/_form.rhtml @@ -0,0 +1,29 @@ +<%= error_messages_for 'document' %> +<div class="box"> +<!--[form:document]--> +<p><label for="document_category_id"><%=l(:field_category)%></label>
+<select name="document[category_id]">
+<%= options_from_collection_for_select @categories, "id", "name", @document.category_id %> +</select></p>
+
+<p><label for="document_title"><%=l(:field_title)%> <span class="required">*</span></label> +<%= text_field 'document', 'title', :size => 60 %></p> + +<p><label for="document_description"><%=l(:field_description)%></label> +<%= text_area 'document', 'description', :cols => 60, :rows => 15 %></p> +<!--[eoform:document]--> +</div> + +<% unless $RDM_TEXTILE_DISABLED %> +<%= javascript_include_tag 'jstoolbar' %> +<script type="text/javascript"> +//<![CDATA[ +if (document.getElementById) { + if (document.getElementById('document_description')) { + var commentTb = new jsToolBar(document.getElementById('document_description')); + commentTb.draw(); + } +} +//]]> +</script> +<% end %>
\ No newline at end of file diff --git a/app/views/documents/edit.rhtml b/app/views/documents/edit.rhtml new file mode 100644 index 000000000..3db4bcc6a --- /dev/null +++ b/app/views/documents/edit.rhtml @@ -0,0 +1,8 @@ +<h2><%=l(:label_document)%></h2> + +<%= start_form_tag({:action => 'edit', :id => @document}, :class => "tabular") %> + <%= render :partial => 'form' %> + <%= submit_tag l(:button_save) %> +<%= end_form_tag %> + + diff --git a/app/views/documents/show.rhtml b/app/views/documents/show.rhtml new file mode 100644 index 000000000..2f021e1b8 --- /dev/null +++ b/app/views/documents/show.rhtml @@ -0,0 +1,48 @@ +<h2><%= @document.title %></h2>
+
+<p><em><%= @document.category.name %><br />
+<%= format_date @document.created_on %></em></p>
+<%= textilizable @document.description %>
+
+
+<table width="100%">
+<tr><td><%= link_to_if_authorized l(:button_edit), :controller => 'documents', :action => 'edit', :id => @document %></td>
+<td align="right">
+<% if authorize_for('documents', 'destroy') %>
+ <%= start_form_tag({ :controller => 'documents', :action => 'destroy', :id => @document } ) %>
+ <%= submit_tag l(:button_delete) %>
+ <%= end_form_tag %>
+<% end %>
+</td></tr>
+</table>
+<br />
+
+<h3><%= l(:label_attachment_plural) %></h3>
+<ul> +<% for attachment in @attachments %> + <li>
+ <% if authorize_for('documents', 'destroy_attachment') %>
+ <div style="float:right;padding:6px;">
+ <%= start_form_tag({ :controller => 'documents', :action => 'destroy_attachment', :id => @document, :attachment_id => attachment } ) %>
+ <%= submit_tag l(:button_delete), :class => 'button-small' %>
+ <%= end_form_tag %>
+ </div>
+ <% end %>
+
+ <%= link_to attachment.filename, :action => 'download', :id => @document, :attachment_id => attachment %>
+ (<%= human_size attachment.filesize %>)<br />
+ <em><%= attachment.author.display_name %>, <%= format_date(attachment.created_on) %></em><br /> + <%= lwr(:label_download, attachment.downloads) %>
+ </li>
+<% end %> +</ul>
+<br />
+
+
+<% if authorize_for('documents', 'add_attachment') %>
+ <%= start_form_tag ({ :controller => 'documents', :action => 'add_attachment', :id => @document }, :multipart => true) %>
+ <label><%=l(:label_attachment_new)%></label>
+ <%= file_field 'attachment', 'file' %>
+ <%= submit_tag l(:button_add) %>
+ <%= end_form_tag %>
+<% end %>
diff --git a/app/views/enumerations/_form.rhtml b/app/views/enumerations/_form.rhtml new file mode 100644 index 000000000..637605939 --- /dev/null +++ b/app/views/enumerations/_form.rhtml @@ -0,0 +1,9 @@ +<%= error_messages_for 'enumeration' %> +<div class="box"> +<!--[form:optvalue]--> +<%= hidden_field 'enumeration', 'opt' %> + +<p><label for="enumeration_name"><%=l(:field_name)%></label> +<%= text_field 'enumeration', 'name' %></p> +<!--[eoform:optvalue]--> +</div>
\ No newline at end of file diff --git a/app/views/enumerations/edit.rhtml b/app/views/enumerations/edit.rhtml new file mode 100644 index 000000000..3002b5936 --- /dev/null +++ b/app/views/enumerations/edit.rhtml @@ -0,0 +1,10 @@ +<h2><%=l(:label_enumerations)%></h2> + +<%= start_form_tag({:action => 'update', :id => @enumeration}, :class => "tabular") %> + <%= render :partial => 'form' %> + <%= submit_tag l(:button_save) %> +<%= end_form_tag %> + +<%= start_form_tag :action => 'destroy', :id => @enumeration %> + <%= submit_tag l(:button_delete) %> +<%= end_form_tag %>
\ No newline at end of file diff --git a/app/views/enumerations/list.rhtml b/app/views/enumerations/list.rhtml new file mode 100644 index 000000000..15b91c1ac --- /dev/null +++ b/app/views/enumerations/list.rhtml @@ -0,0 +1,21 @@ +<h2><%=l(:label_enumerations)%></h2> + +<% Enumeration::OPTIONS.each do |option, name| %>
+
+ <% if @params[:opt]==option %>
+
+ <p><%= image_tag 'dir_open' %> <b><%= l(name) %></b></p>
+ <ul>
+ <% for value in Enumeration.find(:all, :conditions => ["opt = ?", option]) %>
+ <li><%= link_to value.name, :action => 'edit', :id => value %></li>
+ <% end %>
+ </ul>
+ <ul>
+ <li><%= link_to ('» ' + l(:label_new)), :action => 'new', :opt => option %></li>
+ </ul>
+
+ <% else %>
+ <p><%= image_tag 'dir' %> <%= link_to l(name), :opt => option %></p>
+ <% end %>
+
+<% end %>
\ No newline at end of file diff --git a/app/views/enumerations/new.rhtml b/app/views/enumerations/new.rhtml new file mode 100644 index 000000000..0a773519d --- /dev/null +++ b/app/views/enumerations/new.rhtml @@ -0,0 +1,6 @@ +<h2><%= l(@enumeration.option_name) %>: <%=l(:label_enumeration_new)%></h2> + +<%= start_form_tag({:action => 'create'}, :class => "tabular") %> + <%= render :partial => 'form' %> + <%= submit_tag l(:button_create) %> +<%= end_form_tag %> diff --git a/app/views/issue_categories/_form.rhtml b/app/views/issue_categories/_form.rhtml new file mode 100644 index 000000000..765b8f53d --- /dev/null +++ b/app/views/issue_categories/_form.rhtml @@ -0,0 +1,7 @@ +<%= error_messages_for 'issue_category' %> + +<!--[form:issue_category]--> +<p><label for="issue_category_name"><%l(:field_name)%></label> +<%= text_field 'issue_category', 'name' %></p> +<!--[eoform:issue_category]--> + diff --git a/app/views/issue_categories/edit.rhtml b/app/views/issue_categories/edit.rhtml new file mode 100644 index 000000000..053facbf7 --- /dev/null +++ b/app/views/issue_categories/edit.rhtml @@ -0,0 +1,6 @@ +<h2><%=l(:label_issue_category)%></h2> + +<%= start_form_tag({:action => 'edit', :id => @category}, :class => "tabular") %> + <%= render :partial => 'form' %> + <%= submit_tag l(:button_save) %> +<%= end_form_tag %> diff --git a/app/views/issue_statuses/_form.rhtml b/app/views/issue_statuses/_form.rhtml new file mode 100644 index 000000000..f3b1cf2ca --- /dev/null +++ b/app/views/issue_statuses/_form.rhtml @@ -0,0 +1,18 @@ +<%= error_messages_for 'issue_status' %> + +<div class="box"> +<!--[form:issue_status]--> +<p><label for="issue_status_name"><%=l(:field_name)%><span class="required"> *</span></label> +<%= text_field 'issue_status', 'name' %></p> + +<p><label for="issue_status_is_closed"><%=l(:field_is_closed)%></label> +<%= check_box 'issue_status', 'is_closed' %></p>
+
+<p><label for="issue_status_is_default"><%=l(:field_is_default)%></label> +<%= check_box 'issue_status', 'is_default' %></p>
+
+<p><label for="issue_status_html_color"><%=l(:field_html_color)%><span class="required"> *</span></label> +#<%= text_field 'issue_status', 'html_color', :maxlength => 6 %></p>
+ +<!--[eoform:issue_status]--> +</div>
\ No newline at end of file diff --git a/app/views/issue_statuses/edit.rhtml b/app/views/issue_statuses/edit.rhtml new file mode 100644 index 000000000..80f856a2a --- /dev/null +++ b/app/views/issue_statuses/edit.rhtml @@ -0,0 +1,6 @@ +<h2><%=l(:label_issue_status)%></h2> + +<%= start_form_tag({:action => 'update', :id => @issue_status}, :class => "tabular") %> + <%= render :partial => 'form' %> + <%= submit_tag l(:button_save) %> +<%= end_form_tag %> diff --git a/app/views/issue_statuses/list.rhtml b/app/views/issue_statuses/list.rhtml new file mode 100644 index 000000000..023863437 --- /dev/null +++ b/app/views/issue_statuses/list.rhtml @@ -0,0 +1,28 @@ +<h2><%=l(:label_issue_status_plural)%></h2> + +<table class="listTableContent"> + <tr class="ListHead"> + <th><%=l(:field_status)%></th>
+ <th><%=l(:field_is_default)%></th>
+ <th><%=l(:field_is_closed)%></th>
+ <th><%=l(:field_html_color)%></th>
+ <th></th> + </tr> + +<% for status in @issue_statuses %> + <tr class="<%= cycle("odd", "even") %>"> + <td><%= link_to status.name, :action => 'edit', :id => status %></td>
+ <td align="center"><%= image_tag 'true' if status.is_default? %></td>
+ <td align="center"><%= image_tag 'true' if status.is_closed? %></td> + <td><div style="background-color:#<%= status.html_color %>"> </div></td>
+ <td align="center"> + <%= button_to l(:button_delete), { :action => 'destroy', :id => status }, :confirm => l(:text_are_you_sure), :class => "button-small" %>
+ </td> + </tr> +<% end %> +</table> +
+<%= pagination_links_full @issue_status_pages %>
+<br /> + +<%= link_to '» ' + l(:label_issue_status_new), :action => 'new' %> diff --git a/app/views/issue_statuses/new.rhtml b/app/views/issue_statuses/new.rhtml new file mode 100644 index 000000000..2dacb1e21 --- /dev/null +++ b/app/views/issue_statuses/new.rhtml @@ -0,0 +1,6 @@ +<h2><%=l(:label_issue_status_new)%></h2> + +<%= start_form_tag({:action => 'create'}, :class => "tabular") %> + <%= render :partial => 'form' %> + <%= submit_tag l(:button_create) %> +<%= end_form_tag %> diff --git a/app/views/issues/_history.rhtml b/app/views/issues/_history.rhtml new file mode 100644 index 000000000..6dc2a84be --- /dev/null +++ b/app/views/issues/_history.rhtml @@ -0,0 +1,11 @@ +<% for journal in journals %>
+ <h4><%= format_time(journal.created_on) %> - <%= journal.user.name %></h4>
+ <ul>
+ <% for detail in journal.details %>
+ <li><%= show_detail(detail) %></li>
+ <% end %>
+ </ul>
+ <% if journal.notes? %>
+ <%= simple_format auto_link journal.notes %>
+ <% end %>
+<% end %>
diff --git a/app/views/issues/_list_simple.rhtml b/app/views/issues/_list_simple.rhtml new file mode 100644 index 000000000..94b63d613 --- /dev/null +++ b/app/views/issues/_list_simple.rhtml @@ -0,0 +1,28 @@ +<% if issues.length > 0 %>
+<table cellspacing="0" cellpadding="1" width="100%" border="0" class="listTable">
+ <tr><td>
+ <table class="listTableContent">
+ <tr class="ListHead">
+ <th>#</th>
+ <th><%=l(:field_tracker)%></th>
+ <th><%=l(:field_subject)%></th>
+ </tr>
+ <% for issue in issues %> + <tr class="<%= cycle("odd", "even") %>">
+ <td align="center" style="font-weight:bold;color:#<%= issue.status.html_color %>;">
+ <%= link_to issue.id, :controller => 'issues', :action => 'show', :id => issue %><br />
+ </td>
+ <td><p class="small"><%= issue.project.name %> - <%= issue.tracker.name %><br /> + <%= issue.status.name %> - <%= format_time(issue.updated_on) %></p></td>
+ <td>
+ <p class="small"><%= link_to issue.subject, :controller => 'issues', :action => 'show', :id => issue %></p>
+ </td> + </tr> + <% end %> + </table> + </td>
+ </tr>
+</table>
+<% else %>
+ <i><%=l(:label_no_data)%></i>
+<% end %>
\ No newline at end of file diff --git a/app/views/issues/_pdf.rfpdf b/app/views/issues/_pdf.rfpdf new file mode 100644 index 000000000..1f6a12283 --- /dev/null +++ b/app/views/issues/_pdf.rfpdf @@ -0,0 +1,100 @@ +<% pdf.SetFont('Arial','B',11)
+ pdf.Cell(190,10, "#{issue.project.name} - #{issue.tracker.name} # #{issue.long_id} - #{issue.subject}")
+ pdf.Ln
+
+ y0 = pdf.GetY
+
+ pdf.SetFont('Arial','B',9)
+ pdf.Cell(35,5, l(:field_status) + ":","LT")
+ pdf.SetFont('Arial','',9)
+ pdf.Cell(60,5, issue.status.name,"RT")
+ pdf.SetFont('Arial','B',9)
+ pdf.Cell(35,5, l(:field_priority) + ":","LT")
+ pdf.SetFont('Arial','',9)
+ pdf.Cell(60,5, issue.priority.name,"RT")
+ pdf.Ln
+
+ pdf.SetFont('Arial','B',9)
+ pdf.Cell(35,5, l(:field_author) + ":","L")
+ pdf.SetFont('Arial','',9)
+ pdf.Cell(60,5, issue.author.name,"R")
+ pdf.SetFont('Arial','B',9)
+ pdf.Cell(35,5, l(:field_category) + ":","L")
+ pdf.SetFont('Arial','',9)
+ pdf.Cell(60,5, (issue.category ? issue.category.name : "-"),"R")
+ pdf.Ln
+
+ pdf.SetFont('Arial','B',9)
+ pdf.Cell(35,5, l(:field_created_on) + ":","L")
+ pdf.SetFont('Arial','',9)
+ pdf.Cell(60,5, format_date(issue.created_on),"R")
+ pdf.SetFont('Arial','B',9)
+ pdf.Cell(35,5, l(:field_assigned_to) + ":","L")
+ pdf.SetFont('Arial','',9)
+ pdf.Cell(60,5, (issue.assigned_to ? issue.assigned_to.name : "-"),"R")
+ pdf.Ln
+
+ pdf.SetFont('Arial','B',9)
+ pdf.Cell(35,5, l(:field_updated_on) + ":","LB")
+ pdf.SetFont('Arial','',9)
+ pdf.Cell(60,5, format_date(issue.updated_on),"RB")
+ pdf.SetFont('Arial','B',9)
+ pdf.Cell(35,5, l(:field_due_date) + ":","LB")
+ pdf.SetFont('Arial','',9)
+ pdf.Cell(60,5, format_date(issue.due_date),"RB")
+ pdf.Ln
+
+ for custom_value in issue.custom_values
+ pdf.SetFont('Arial','B',9)
+ pdf.Cell(35,5, custom_value.custom_field.name + ":","L")
+ pdf.SetFont('Arial','',9)
+ pdf.MultiCell(155,5, (show_value custom_value),"R")
+ end
+
+ pdf.SetFont('Arial','B',9)
+ pdf.Cell(35,5, l(:field_subject) + ":","LTB")
+ pdf.SetFont('Arial','',9)
+ pdf.Cell(155,5, issue.subject,"RTB")
+ pdf.Ln
+
+ pdf.SetFont('Arial','B',9)
+ pdf.Cell(35,5, l(:field_description) + ":")
+ pdf.SetFont('Arial','',9)
+ pdf.MultiCell(155,5, issue.description,"BR")
+
+ pdf.Line(pdf.GetX, y0, pdf.GetX, pdf.GetY)
+ pdf.Line(pdf.GetX, pdf.GetY, 170, pdf.GetY)
+
+ pdf.Ln
+
+ pdf.SetFont('Arial','B',9)
+ pdf.Cell(190,5, l(:label_history), "B")
+ pdf.Ln
+ for journal in issue.journals.find(:all, :include => :user, :order => "journals.created_on desc")
+ pdf.SetFont('Arial','B',8)
+ pdf.Cell(190,5, format_time(journal.created_on) + " - " + journal.user.name)
+ pdf.Ln
+ pdf.SetFont('Arial','I',8)
+ for detail in journal.details
+ pdf.Cell(190,5, "- " + show_detail(detail, true))
+ pdf.Ln
+ end
+ if journal.notes?
+ pdf.SetFont('Arial','',8)
+ pdf.MultiCell(190,5, journal.notes)
+ end
+ pdf.Ln
+ end
+
+ pdf.SetFont('Arial','B',9)
+ pdf.Cell(190,5, l(:label_attachment_plural), "B")
+ pdf.Ln
+ for attachment in issue.attachments
+ pdf.SetFont('Arial','',8)
+ pdf.Cell(80,5, attachment.filename)
+ pdf.Cell(20,5, human_size(attachment.filesize),0,0,"R")
+ pdf.Cell(20,5, format_date(attachment.created_on),0,0,"R")
+ pdf.Cell(70,5, attachment.author.name,0,0,"R")
+ pdf.Ln
+ end
+%>
\ No newline at end of file diff --git a/app/views/issues/change_status.rhtml b/app/views/issues/change_status.rhtml new file mode 100644 index 000000000..2ef87183d --- /dev/null +++ b/app/views/issues/change_status.rhtml @@ -0,0 +1,37 @@ +<h2><%=l(:label_issue)%> #<%= @issue.id %>: <%= @issue.subject %></h2> +
+<%= error_messages_for 'issue' %>
+<%= start_form_tag({:action => 'change_status', :id => @issue}, :class => "tabular") %>
+
+<%= hidden_field_tag 'confirm', 1 %>
+<%= hidden_field_tag 'new_status_id', @new_status.id %> + +<div class="box">
+<p><label><%=l(:label_issue_status_new)%></label> <%= @new_status.name %></p>
+
+<p><label for="issue_assigned_to_id"><%=l(:field_assigned_to)%></label> +<select name="issue[assigned_to_id]">
+<option value=""></option>
+<%= options_from_collection_for_select @assignable_to, "id", "display_name", @issue.assigned_to_id %></p> +</select></p>
+ + +<p><label for="issue_done_ratio"><%=l(:field_done_ratio)%></label> +<%= select("issue", "done_ratio", ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) ) %> +</select></p> + +
+<p><label for="issue_fixed_version"><%=l(:field_fixed_version)%></label> +<select name="issue[fixed_version_id]">
+<option value="">--none--</option>
+<%= options_from_collection_for_select @issue.project.versions, "id", "name", @issue.fixed_version_id %>
+</select></p> + +<p><label for="notes"><%= l(:field_notes) %></label> +<%= text_area_tag 'notes', @notes, :cols => 60, :rows => 10 %></p> + +</div> +
+<%= hidden_field 'issue', 'lock_version' %> +<%= submit_tag l(:button_save) %>
+<%= end_form_tag %>
diff --git a/app/views/issues/edit.rhtml b/app/views/issues/edit.rhtml new file mode 100644 index 000000000..60cdafc1e --- /dev/null +++ b/app/views/issues/edit.rhtml @@ -0,0 +1,49 @@ +<h2><%= @issue.tracker.name %> #<%= @issue.id %> - <%= @issue.subject %></h2> + +<% labelled_tabular_form_for :issue, @issue, :url => {:action => 'edit'} do |f| %> +<%= error_messages_for 'issue' %> +<div class="box"> +<!--[form:issue]--> +<div class="splitcontentleft"> +<p><label><%=l(:field_status)%></label> <%= @issue.status.name %></p> +<p><%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), :required => true %></p> +<p><%= f.select :assigned_to_id, (@issue.project.members.collect {|m| [m.name, m.user_id]}), :include_blank => true %></p> +<p><%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}) %></p> +</div> + +<div class="splitcontentright"> +<p><%= f.text_field :start_date, :size => 10 %><%= calendar_for('issue_start_date') %></p> +<p><%= f.text_field :due_date, :size => 10 %><%= calendar_for('issue_due_date') %></p> +<p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></p> +</div> + +<div class="clear"> +<p><%= f.text_field :subject, :size => 80, :required => true %></p> +<p><%= f.text_area :description, :cols => 60, :rows => [[10, @issue.description.length / 50].max, 100].min, :required => true %></p> + +<% for @custom_value in @custom_values %> + <p><%= custom_field_tag_with_label @custom_value %></p> +<% end %> + +<p><%= f.select :fixed_version_id, (@project.versions.collect {|v| [v.name, v.id]}), { :include_blank => true } %> +</select></p> +</div> +<!--[eoform:issue]--> +</div> +<%= f.hidden_field :lock_version %> +<%= submit_tag l(:button_save) %> +<% end %> + +<% unless $RDM_TEXTILE_DISABLED %> +<%= javascript_include_tag 'jstoolbar' %> +<script type="text/javascript"> +//<![CDATA[ +if (document.getElementById) { + if (document.getElementById('issue_description')) { + var commentTb = new jsToolBar(document.getElementById('issue_description')); + commentTb.draw(); + } +} +//]]> +</script> +<% end %>
\ No newline at end of file diff --git a/app/views/issues/export_pdf.rfpdf b/app/views/issues/export_pdf.rfpdf new file mode 100644 index 000000000..a8622dd51 --- /dev/null +++ b/app/views/issues/export_pdf.rfpdf @@ -0,0 +1,9 @@ +<% pdf=IfpdfHelper::IFPDF.new
+ pdf.AliasNbPages
+ pdf.footer_date = format_date(Date.today)
+ pdf.AddPage
+
+ render :partial => 'issues/pdf', :locals => { :pdf => pdf, :issue => @issue }
+%>
+
+<%= pdf.Output %>
\ No newline at end of file diff --git a/app/views/issues/history.rhtml b/app/views/issues/history.rhtml new file mode 100644 index 000000000..2443cc739 --- /dev/null +++ b/app/views/issues/history.rhtml @@ -0,0 +1,6 @@ +<h3><%=l(:label_history)%></h3>
+<div id="history">
+<%= render :partial => 'history', :locals => { :journals => @journals } %>
+</div>
+<br />
+<p><%= link_to l(:button_back), :action => 'show', :id => @issue %></p>
\ No newline at end of file diff --git a/app/views/issues/show.rhtml b/app/views/issues/show.rhtml new file mode 100644 index 000000000..8128b74a9 --- /dev/null +++ b/app/views/issues/show.rhtml @@ -0,0 +1,133 @@ +<h2><%= @issue.tracker.name %> #<%= @issue.id %> - <%= @issue.subject %></h2>
+<div class="topright">
+<small>
+<%= link_to 'PDF', :action => 'export_pdf', :id => @issue %>
+</small>
+</div>
+ +<div class="box">
+<table width="100%">
+<tr>
+ <td width="15%"><b><%=l(:field_status)%> :</b></td><td width="35%"><%= @issue.status.name %></td>
+ <td width="15%"><b><%=l(:field_priority)%> :</b></td><td width="35%"><%= @issue.priority.name %></td>
+</tr>
+<tr>
+ <td><b><%=l(:field_assigned_to)%> :</b></td><td><%= @issue.assigned_to ? @issue.assigned_to.name : "-" %></td>
+ <td><b><%=l(:field_category)%> :</b></td><td><%= @issue.category ? @issue.category.name : "-" %></td>
+</tr>
+<tr>
+ <td><b><%=l(:field_author)%> :</b></td><td><%= link_to_user @issue.author %></td>
+ <td><b><%=l(:field_start_date)%> :</b></td><td><%= format_date(@issue.start_date) %></td>
+</tr>
+<tr>
+ <td><b><%=l(:field_created_on)%> :</b></td><td><%= format_date(@issue.created_on) %></td>
+ <td><b><%=l(:field_due_date)%> :</b></td><td><%= format_date(@issue.due_date) %></td>
+</tr>
+<tr>
+ <td><b><%=l(:field_updated_on)%> :</b></td><td><%= format_date(@issue.updated_on) %></td>
+ <td><b><%=l(:field_done_ratio)%> :</b></td><td><%= @issue.done_ratio %> %</td>
+</tr>
+<tr>
+<% n = 0
+for custom_value in @custom_values %>
+ <td><b><%= custom_value.custom_field.name %> :</b></td><td><%= show_value custom_value %></td>
+<% n = n + 1
+ if (n > 1)
+ n = 0 %>
+ </tr><tr>
+ <%end
+end %>
+</tr>
+</table>
+<hr />
+<br />
+
+<b><%=l(:field_description)%> :</b><br /><br />
+<%= textilizable @issue.description %>
+<br />
+<div style="float:left;">
+<% if authorize_for('issues', 'edit') %>
+ <%= start_form_tag ({:controller => 'issues', :action => 'edit', :id => @issue}, :method => "get" ) %>
+ <%= submit_tag l(:button_edit) %>
+ <%= end_form_tag %>
+
+<% end %>
+
+<% if authorize_for('issues', 'change_status') and @status_options and !@status_options.empty? %>
+ <%= start_form_tag ({:controller => 'issues', :action => 'change_status', :id => @issue}) %>
+ <%=l(:label_change_status)%> :
+ <select name="new_status_id">
+ <%= options_from_collection_for_select @status_options, "id", "name" %>
+ </select>
+ <%= submit_tag l(:button_change) %>
+ <%= end_form_tag %>
+
+<% end %>
+
+<% if authorize_for('projects', 'move_issues') %>
+ <%= start_form_tag ({:controller => 'projects', :action => 'move_issues', :id => @project} ) %>
+ <%= hidden_field_tag "issue_ids[]", @issue.id %>
+ <%= submit_tag l(:button_move) %>
+ <%= end_form_tag %>
+
+<% end %>
+</div>
+<div style="float:right;">
+<% if authorize_for('issues', 'destroy') %>
+ <%= start_form_tag ({:controller => 'issues', :action => 'destroy', :id => @issue} ) %>
+ <%= submit_tag l(:button_delete) %>
+ <%= end_form_tag %>
+
+<% end %>
+</div>
+<div class="clear"></div>
+</div>
+
+<div id="history" class="box">
+<h3><%=l(:label_history)%>
+<% if @journals_count > @journals.length %>(<%= l(:label_last_changes, @journals.length) %>)<% end %></h3>
+<%= render :partial => 'history', :locals => { :journals => @journals } %>
+<% if @journals_count > @journals.length %>
+ <p><center><small>[ <%= link_to l(:label_change_view_all), :action => 'history', :id => @issue %> ]</small></center></p>
+<% end %> +</div>
+
+<div class="box">
+<h3><%=l(:label_attachment_plural)%></h3>
+<table width="100%">
+<% for attachment in @issue.attachments %>
+<tr>
+<td><%= image_tag('attachment') %> <%= link_to attachment.filename, :action => 'download', :id => @issue, :attachment_id => attachment %> (<%= human_size(attachment.filesize) %>)</td>
+<td><%= format_date(attachment.created_on) %></td>
+<td><%= attachment.author.display_name %></td>
+<% if authorize_for('issues', 'destroy_attachment') %>
+ <td>
+ <%= start_form_tag :action => 'destroy_attachment', :id => @issue, :attachment_id => attachment %>
+ <%= submit_tag l(:button_delete), :class => "button-small" %>
+ <%= end_form_tag %>
+ </td>
+<% end %>
+</tr>
+<% end %> +</table>
+<br />
+<% if authorize_for('issues', 'add_attachment') %>
+ <%= start_form_tag ({ :controller => 'issues', :action => 'add_attachment', :id => @issue }, :multipart => true, :class => "tabular") %>
+ <p id="attachments_p"><label><%=l(:label_attachment_new)%>
+ <%= link_to_function image_tag('add'), "addFileField()" %></label>
+ <%= file_field_tag 'attachments[]', :size => 30 %></p>
+ <%= submit_tag l(:button_add) %>
+ <%= end_form_tag %>
+<% end %>
+</div>
+
+<% if authorize_for('issues', 'add_note') %>
+ <div class="box">
+ <h3><%= l(:label_add_note) %></h3>
+ <%= start_form_tag ({:controller => 'issues', :action => 'add_note', :id => @issue}, :class => "tabular" ) %>
+ <p><label for="notes"><%=l(:field_notes)%></label>
+ <%= text_area_tag 'notes', '', :cols => 60, :rows => 10 %></p>
+ <%= submit_tag l(:button_add) %>
+ <%= end_form_tag %>
+ </div>
+<% end %>
diff --git a/app/views/layouts/base.rhtml b/app/views/layouts/base.rhtml new file mode 100644 index 000000000..951fa88f7 --- /dev/null +++ b/app/views/layouts/base.rhtml @@ -0,0 +1,142 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<head>
+<title><%= $RDM_HEADER_TITLE + (@html_title ? ": #{@html_title}" : "") %></title>
+<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta name="description" content="redMine" />
+<meta name="keywords" content="issue,bug,tracker" />
+<%= stylesheet_link_tag "application" %>
+<%= stylesheet_link_tag "menu" %>
+<%= stylesheet_link_tag "rails" %>
+<%= javascript_include_tag :defaults %>
+<%= javascript_include_tag 'menu' %>
+<%= javascript_include_tag 'calendar/calendar' %>
+<%= javascript_include_tag "calendar/lang/calendar-#{current_language}.js" %>
+<%= javascript_include_tag 'calendar/calendar-setup' %>
+<%= stylesheet_link_tag 'calendar' %>
+<%= stylesheet_link_tag 'jstoolbar' %>
+<script type='text/javascript'>
+var menu_contenu=' \
+<div id="menuAdmin" class="menu" onmouseover="menuMouseover(event)"> \
+<a class="menuItem" href="\/admin\/projects" onmouseover="menuItemMouseover(event,\'menuProjects\');"><span class="menuItemText"><%=l(:label_project_plural)%><\/span><span class="menuItemArrow">▶<\/span><\/a> \
+<a class="menuItem" href="\/users" onmouseover="menuItemMouseover(event,\'menuUsers\');"><span class="menuItemText"><%=l(:label_user_plural)%><\/span><span class="menuItemArrow">▶<\/span><\/a> \
+<a class="menuItem" href="\/roles"><%=l(:label_role_and_permissions)%><\/a> \
+<a class="menuItem" href="\/trackers" onmouseover="menuItemMouseover(event,\'menuTrackers\');"><span class="menuItemText"><%=l(:label_tracker_plural)%><\/span><span class="menuItemArrow">▶<\/span><\/a> \
+<a class="menuItem" href="\/custom_fields"><%=l(:label_custom_field_plural)%><\/a> \
+<a class="menuItem" href="\/enumerations"><%=l(:label_enumerations)%><\/a> \
+<a class="menuItem" href="\/admin\/mail_options"><%=l(:field_mail_notification)%><\/a> \
+<a class="menuItem" href="\/auth_sources"><%=l(:label_authentication)%><\/a> \
+<a class="menuItem" href="\/admin\/info"><%=l(:label_information_plural)%><\/a> \
+<\/div> \
+<div id="menuTrackers" class="menu"> \
+<a class="menuItem" href="\/issue_statuses"><%=l(:label_issue_status_plural)%><\/a> \
+<a class="menuItem" href="\/roles\/workflow"><%=l(:label_workflow)%><\/a> \
+<\/div> \
+<div id="menuProjects" class="menu"><a class="menuItem" href="\/projects\/add"><%=l(:label_new)%><\/a><\/div> \
+<div id="menuUsers" class="menu"><a class="menuItem" href="\/users\/add"><%=l(:label_new)%><\/a><\/div> \
+ \
+<% unless @project.nil? || @project.id.nil? %> \
+<div id="menuProject" class="menu" onmouseover="menuMouseover(event)"> \
+<%= link_to l(:label_calendar), {:controller => 'projects', :action => 'calendar', :id => @project }, :class => "menuItem" %> \
+<%= link_to l(:label_issue_plural), {:controller => 'projects', :action => 'list_issues', :id => @project }, :class => "menuItem" %> \
+<%= link_to l(:label_report_plural), {:controller => 'reports', :action => 'issue_report', :id => @project }, :class => "menuItem" %> \
+<%= link_to l(:label_activity), {:controller => 'projects', :action => 'activity', :id => @project }, :class => "menuItem" %> \
+<%= link_to l(:label_news_plural), {:controller => 'projects', :action => 'list_news', :id => @project }, :class => "menuItem" %> \
+<%= link_to l(:label_change_log), {:controller => 'projects', :action => 'changelog', :id => @project }, :class => "menuItem" %> \
+<%= link_to l(:label_document_plural), {:controller => 'projects', :action => 'list_documents', :id => @project }, :class => "menuItem" %> \
+<%= link_to l(:label_member_plural), {:controller => 'projects', :action => 'list_members', :id => @project }, :class => "menuItem" %> \
+<%= link_to l(:label_attachment_plural), {:controller => 'projects', :action => 'list_files', :id => @project }, :class => "menuItem" %> \
+<%= link_to_if_authorized l(:label_settings), {:controller => 'projects', :action => 'settings', :id => @project }, :class => "menuItem" %> \
+<\/div> \
+<% end %> \
+';
+</script>
+
+</head>
+
+<body>
+<div id="container" >
+
+ <div id="header">
+ <div style="float: left;">
+ <h1><%= $RDM_HEADER_TITLE %></h1>
+ <h2><%= $RDM_HEADER_SUBTITLE %></h2>
+ </div>
+ <div style="float: right; padding-right: 1em; padding-top: 0.2em;">
+ <% if loggedin? %><small><%=l(:label_logged_as)%> <b><%= @logged_in_user.login %></b></small><% end %>
+ </div>
+ </div>
+
+ <div id="navigation">
+ <ul>
+ <li class="selected"><%= link_to l(:label_home), { :controller => '' }, :class => "picHome" %></li>
+ <li><%= link_to l(:label_my_page), { :controller => 'my', :action => 'page'}, :class => "picUserPage" %></li>
+ <li><%= link_to l(:label_project_plural), { :controller => 'projects' }, :class => "picProject" %></li>
+
+ <% unless @project.nil? || @project.id.nil? %>
+ <li><%= link_to @project.name, { :controller => 'projects', :action => 'show', :id => @project }, :class => "picProject", :onmouseover => "buttonMouseover(event, 'menuProject');" %></li>
+ <% end %>
+
+ <% if loggedin? %>
+ <li><%= link_to l(:label_my_account), { :controller => 'my', :action => 'account' }, :class => "picUser" %></li>
+ <% end %>
+
+ <% if admin_loggedin? %>
+ <li><%= link_to l(:label_administration), { :controller => 'admin' }, :class => "picAdmin", :onmouseover => "buttonMouseover(event, 'menuAdmin');" %></li>
+ <% end %>
+
+ <li class="right"><%= link_to l(:label_help), { :controller => 'help', :ctrl => @params[:controller], :page => @params[:action] }, :target => "new", :class => "picHelp" %></li>
+
+ <% if loggedin? %>
+ <li class="right"><%= link_to l(:label_logout), { :controller => 'account', :action => 'logout' }, :class => "picUser" %></li>
+ <% else %>
+ <li class="right"><%= link_to l(:label_login), { :controller => 'account', :action => 'login' }, :class => "picUser" %></li>
+ <% end %>
+ </ul>
+ </div>
+ <script type='text/javascript'>if(document.getElementById) {document.write(menu_contenu);}</script>
+
+ <div id="subcontent">
+
+ <% unless @project.nil? || @project.id.nil? %>
+ <h2><%= @project.name %></h2>
+ <ul class="menublock">
+ <li><%= link_to l(:label_overview), :controller => 'projects', :action => 'show', :id => @project %></li>
+ <li><%= link_to l(:label_calendar), :controller => 'projects', :action => 'calendar', :id => @project %></li>
+ <li><%= link_to l(:label_issue_plural), :controller => 'projects', :action => 'list_issues', :id => @project %></li>
+ <li><%= link_to l(:label_report_plural), :controller => 'reports', :action => 'issue_report', :id => @project %></li>
+ <li><%= link_to l(:label_activity), :controller => 'projects', :action => 'activity', :id => @project %></li>
+ <li><%= link_to l(:label_news_plural), :controller => 'projects', :action => 'list_news', :id => @project %></li>
+ <li><%= link_to l(:label_change_log), :controller => 'projects', :action => 'changelog', :id => @project %></li>
+ <li><%= link_to l(:label_document_plural), :controller => 'projects', :action => 'list_documents', :id => @project %></li>
+ <li><%= link_to l(:label_member_plural), :controller => 'projects', :action => 'list_members', :id => @project %></li>
+ <li><%= link_to l(:label_attachment_plural), :controller => 'projects', :action => 'list_files', :id => @project %></li>
+ <li><%= link_to_if_authorized l(:label_settings), :controller => 'projects', :action => 'settings', :id => @project %></li>
+ </ul>
+ <% end %>
+
+ <% if loggedin? and @logged_in_user.memberships.length > 0 %>
+ <h2><%=l(:label_my_projects) %></h2>
+ <ul class="menublock">
+ <% for membership in @logged_in_user.memberships %>
+ <li><%= link_to membership.project.name, :controller => 'projects', :action => 'show', :id => membership.project %></li>
+ <% end %>
+ </ul>
+ <% end %>
+ </div>
+
+ <div id="content">
+ <% if flash[:notice] %><p style="color: green"><%= flash[:notice] %></p><% end %>
+ <%= @content_for_layout %>
+ </div>
+
+ <div id="footer">
+ <p>
+ <%= auto_link $RDM_FOOTER_SIG %> |
+ <a href="http://redmine.rubyforge.org/" target="_new"><%= RDM_APP_NAME %></a> <%= RDM_APP_VERSION %>
+ </p>
+ </div>
+
+</div>
+</body>
+</html>
\ No newline at end of file diff --git a/app/views/mailer/_issue.rhtml b/app/views/mailer/_issue.rhtml new file mode 100644 index 000000000..c123ae30c --- /dev/null +++ b/app/views/mailer/_issue.rhtml @@ -0,0 +1,7 @@ +<%=l(:label_issue)%> #<%= issue.id %> - <%= issue.subject %>
+<%=l(:field_author)%>: <%= issue.author.display_name %>
+<%=l(:field_status)%>: <%= issue.status.name %>
+ +<%= issue.description %>
+
+http://<%= $RDM_HOST_NAME %>/issues/show/<%= issue.id %>
\ No newline at end of file diff --git a/app/views/mailer/issue_add_de.rhtml b/app/views/mailer/issue_add_de.rhtml new file mode 100644 index 000000000..9efec9ad9 --- /dev/null +++ b/app/views/mailer/issue_add_de.rhtml @@ -0,0 +1,3 @@ +Issue #<%= @issue.id %> has been reported.
+----------------------------------------
+<%= render :file => "_issue", :use_full_path => true, :locals => { :issue => @issue } %>
\ No newline at end of file diff --git a/app/views/mailer/issue_add_en.rhtml b/app/views/mailer/issue_add_en.rhtml new file mode 100644 index 000000000..9efec9ad9 --- /dev/null +++ b/app/views/mailer/issue_add_en.rhtml @@ -0,0 +1,3 @@ +Issue #<%= @issue.id %> has been reported.
+----------------------------------------
+<%= render :file => "_issue", :use_full_path => true, :locals => { :issue => @issue } %>
\ No newline at end of file diff --git a/app/views/mailer/issue_add_es.rhtml b/app/views/mailer/issue_add_es.rhtml new file mode 100644 index 000000000..9efec9ad9 --- /dev/null +++ b/app/views/mailer/issue_add_es.rhtml @@ -0,0 +1,3 @@ +Issue #<%= @issue.id %> has been reported.
+----------------------------------------
+<%= render :file => "_issue", :use_full_path => true, :locals => { :issue => @issue } %>
\ No newline at end of file diff --git a/app/views/mailer/issue_add_fr.rhtml b/app/views/mailer/issue_add_fr.rhtml new file mode 100644 index 000000000..628ecae12 --- /dev/null +++ b/app/views/mailer/issue_add_fr.rhtml @@ -0,0 +1,3 @@ +Une nouvelle demande (#<%= @issue.id %>) a été soumise.
+----------------------------------------
+<%= render :file => "_issue", :use_full_path => true, :locals => { :issue => @issue } %>
\ No newline at end of file diff --git a/app/views/mailer/issue_edit_de.rhtml b/app/views/mailer/issue_edit_de.rhtml new file mode 100644 index 000000000..d22d6c534 --- /dev/null +++ b/app/views/mailer/issue_edit_de.rhtml @@ -0,0 +1,8 @@ +Issue #<%= @issue.id %> has been updated.
+<%= @journal.user.name %>
+<% for detail in @journal.details %>
+<%= show_detail(detail, true) %>
+<% end %>
+<%= @journal.notes if @journal.notes? %>
+----------------------------------------
+<%= render :file => "_issue", :use_full_path => true, :locals => { :issue => @issue } %>
\ No newline at end of file diff --git a/app/views/mailer/issue_edit_en.rhtml b/app/views/mailer/issue_edit_en.rhtml new file mode 100644 index 000000000..d22d6c534 --- /dev/null +++ b/app/views/mailer/issue_edit_en.rhtml @@ -0,0 +1,8 @@ +Issue #<%= @issue.id %> has been updated.
+<%= @journal.user.name %>
+<% for detail in @journal.details %>
+<%= show_detail(detail, true) %>
+<% end %>
+<%= @journal.notes if @journal.notes? %>
+----------------------------------------
+<%= render :file => "_issue", :use_full_path => true, :locals => { :issue => @issue } %>
\ No newline at end of file diff --git a/app/views/mailer/issue_edit_es.rhtml b/app/views/mailer/issue_edit_es.rhtml new file mode 100644 index 000000000..d22d6c534 --- /dev/null +++ b/app/views/mailer/issue_edit_es.rhtml @@ -0,0 +1,8 @@ +Issue #<%= @issue.id %> has been updated.
+<%= @journal.user.name %>
+<% for detail in @journal.details %>
+<%= show_detail(detail, true) %>
+<% end %>
+<%= @journal.notes if @journal.notes? %>
+----------------------------------------
+<%= render :file => "_issue", :use_full_path => true, :locals => { :issue => @issue } %>
\ No newline at end of file diff --git a/app/views/mailer/issue_edit_fr.rhtml b/app/views/mailer/issue_edit_fr.rhtml new file mode 100644 index 000000000..9edacb703 --- /dev/null +++ b/app/views/mailer/issue_edit_fr.rhtml @@ -0,0 +1,8 @@ +La demande #<%= @issue.id %> a été mise à jour.
+<%= @journal.user.name %> - <%= format_date(@journal.created_on) %>
+<% for detail in @journal.details %>
+<%= show_detail(detail, true) %>
+<% end %>
+<%= journal.notes if journal.notes? %>
+----------------------------------------
+<%= render :file => "_issue", :use_full_path => true, :locals => { :issue => @issue } %>
\ No newline at end of file diff --git a/app/views/mailer/lost_password_de.rhtml b/app/views/mailer/lost_password_de.rhtml new file mode 100644 index 000000000..2593edbda --- /dev/null +++ b/app/views/mailer/lost_password_de.rhtml @@ -0,0 +1,3 @@ +To change your password, use the following link:
+
+http://<%= $RDM_HOST_NAME %>/account/lost_password?token=<%= @token.value %>
\ No newline at end of file diff --git a/app/views/mailer/lost_password_en.rhtml b/app/views/mailer/lost_password_en.rhtml new file mode 100644 index 000000000..2593edbda --- /dev/null +++ b/app/views/mailer/lost_password_en.rhtml @@ -0,0 +1,3 @@ +To change your password, use the following link:
+
+http://<%= $RDM_HOST_NAME %>/account/lost_password?token=<%= @token.value %>
\ No newline at end of file diff --git a/app/views/mailer/lost_password_es.rhtml b/app/views/mailer/lost_password_es.rhtml new file mode 100644 index 000000000..2593edbda --- /dev/null +++ b/app/views/mailer/lost_password_es.rhtml @@ -0,0 +1,3 @@ +To change your password, use the following link:
+
+http://<%= $RDM_HOST_NAME %>/account/lost_password?token=<%= @token.value %>
\ No newline at end of file diff --git a/app/views/mailer/lost_password_fr.rhtml b/app/views/mailer/lost_password_fr.rhtml new file mode 100644 index 000000000..30996f118 --- /dev/null +++ b/app/views/mailer/lost_password_fr.rhtml @@ -0,0 +1,3 @@ +Pour changer votre mot de passe, utilisez le lien suivant:
+
+http://<%= $RDM_HOST_NAME %>/account/lost_password?token=<%= @token.value %>
\ No newline at end of file diff --git a/app/views/mailer/register_de.rhtml b/app/views/mailer/register_de.rhtml new file mode 100644 index 000000000..2c0341b24 --- /dev/null +++ b/app/views/mailer/register_de.rhtml @@ -0,0 +1,3 @@ +To activate your redMine account, use the following link:
+
+http://<%= $RDM_HOST_NAME %>/account/register?token=<%= @token.value %>
\ No newline at end of file diff --git a/app/views/mailer/register_en.rhtml b/app/views/mailer/register_en.rhtml new file mode 100644 index 000000000..2c0341b24 --- /dev/null +++ b/app/views/mailer/register_en.rhtml @@ -0,0 +1,3 @@ +To activate your redMine account, use the following link:
+
+http://<%= $RDM_HOST_NAME %>/account/register?token=<%= @token.value %>
\ No newline at end of file diff --git a/app/views/mailer/register_es.rhtml b/app/views/mailer/register_es.rhtml new file mode 100644 index 000000000..2c0341b24 --- /dev/null +++ b/app/views/mailer/register_es.rhtml @@ -0,0 +1,3 @@ +To activate your redMine account, use the following link:
+
+http://<%= $RDM_HOST_NAME %>/account/register?token=<%= @token.value %>
\ No newline at end of file diff --git a/app/views/mailer/register_fr.rhtml b/app/views/mailer/register_fr.rhtml new file mode 100644 index 000000000..3f5d0ccaf --- /dev/null +++ b/app/views/mailer/register_fr.rhtml @@ -0,0 +1,3 @@ +Pour activer votre compte sur redMine, utilisez le lien suivant:
+
+http://<%= $RDM_HOST_NAME %>/account/register?token=<%= @token.value %>
\ No newline at end of file diff --git a/app/views/my/_block.rhtml b/app/views/my/_block.rhtml new file mode 100644 index 000000000..3f72bdaf1 --- /dev/null +++ b/app/views/my/_block.rhtml @@ -0,0 +1,16 @@ +<div id="block_<%= block_name %>" class="mypage-box">
+
+ <div style="float:right;margin-right:16px;z-index:500;">
+ <%= link_to_remote "", {
+ :url => { :action => "remove_block", :block => block_name },
+ :complete => "removeBlock('block_#{block_name}')",
+ :loading => "Element.show('indicator')",
+ :loaded => "Element.hide('indicator')" },
+ :class => "close-icon"
+ %>
+ </div>
+
+ <div class="handle">
+ <%= render :partial => "my/blocks/#{block_name}", :locals => { :user => user } %>
+ </div>
+</div>
\ No newline at end of file diff --git a/app/views/my/account.rhtml b/app/views/my/account.rhtml new file mode 100644 index 000000000..23b236e29 --- /dev/null +++ b/app/views/my/account.rhtml @@ -0,0 +1,47 @@ +<h2><%=l(:label_my_account)%></h2> +
+<p><%=l(:field_login)%>: <strong><%= @user.login %></strong><br />
+<%=l(:field_created_on)%>: <%= format_time(@user.created_on) %>,
+<%=l(:field_updated_on)%>: <%= format_time(@user.updated_on) %></p>
+ +<%= error_messages_for 'user' %> +
+<div class="box">
+<h3><%=l(:label_information_plural)%></h3> + +<% labelled_tabular_form_for :user, @user, :url => { :action => "account" } do |f| %> + +<p><%= f.text_field :firstname, :required => true %></p> +<p><%= f.text_field :lastname, :required => true %></p> +<p><%= f.text_field :mail, :required => true, :size => 40 %></p> +<p><%= f.select :language, lang_options_for_select %></p> +<p><%= f.check_box :mail_notification %></p> + +<% fields_for :pref, @user.pref, :builder => TabularFormBuilder, :lang => current_language do |pref_fields| %> +<p><%= pref_fields.check_box :hide_mail %></p> +<% end %> + +<center><%= submit_tag l(:button_save) %></center> +<% end %>
+</div>
+
+ +<% unless @user.auth_source_id %>
+ <div class="box">
+ <h3><%=l(:field_password)%></h3>
+ + <%= start_form_tag({:action => 'change_password'}, :class => "tabular") %> +
+ <p><label for="password"><%=l(:field_password)%> <span class="required">*</span></label> + <%= password_field_tag 'password', nil, :size => 25 %></p> +
+ <p><label for="new_password"><%=l(:field_new_password)%> <span class="required">*</span></label> + <%= password_field_tag 'new_password', nil, :size => 25 %></p>
+
+ <p><label for="new_password_confirmation"><%=l(:field_password_confirmation)%> <span class="required">*</span></label> + <%= password_field_tag 'new_password_confirmation', nil, :size => 25 %></p>
+ + <center><%= submit_tag l(:button_save) %></center> + <%= end_form_tag %>
+ </div> +<% end %>
diff --git a/app/views/my/blocks/_calendar.rhtml b/app/views/my/blocks/_calendar.rhtml new file mode 100644 index 000000000..2d7930f52 --- /dev/null +++ b/app/views/my/blocks/_calendar.rhtml @@ -0,0 +1,45 @@ +<h3><%= l(:label_calendar) %></h3>
+
+<%
+@date_from = Date.today - (Date.today.cwday-1)
+@date_to = Date.today + (7-Date.today.cwday)
+@issues = Issue.find :all,
+ :conditions => ["issues.project_id in (#{@user.projects.collect{|m| m.id}.join(',')}) AND ((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?))", @date_from, @date_to, @date_from, @date_to],
+ :include => [:project, :tracker] unless @user.projects.empty?
+@issues ||= []
+%>
+
+<table class="calenderTable">
+<tr class="ListHead">
+<td></td>
+<% 1.upto(7) do |d| %>
+ <td align="center" width="14%"><%= day_name(d) %></td>
+<% end %>
+</tr>
+<tr height="100">
+<% day = @date_from
+while day <= @date_to
+ if day.cwday == 1 %>
+ <td valign="middle"><%= day.cweek %></td>
+ <% end %>
+ <td valign="top" width="14%" class="<%= day.month==@month ? "even" : "odd" %>">
+ <p align="right"><%= day==Date.today ? "<b>#{day.day}</b>" : day.day %></p>
+ <% day_issues = []
+ @issues.each { |i| day_issues << i if i.start_date == day or i.due_date == day }
+ day_issues.each do |i| %>
+ <%= if day == i.start_date and day == i.due_date
+ image_tag('arrow_bw')
+ elsif day == i.start_date
+ image_tag('arrow_from')
+ elsif day == i.due_date
+ image_tag('arrow_to')
+ end %>
+ <small><%= link_to "#{i.tracker.name} ##{i.id}", :controller => 'issues', :action => 'show', :id => i %>: <%= i.subject.sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)') %></small><br />
+ <% end %>
+ </td>
+ <%= '</tr><tr height="100">' if day.cwday >= 7 and day!=@date_to %>
+ <%
+ day = day + 1
+end %>
+</tr>
+</table>
\ No newline at end of file diff --git a/app/views/my/blocks/_documents.rhtml b/app/views/my/blocks/_documents.rhtml new file mode 100644 index 000000000..5fa8c7980 --- /dev/null +++ b/app/views/my/blocks/_documents.rhtml @@ -0,0 +1,15 @@ +<h3><%=l(:label_document_plural)%></h3>
+
+<ul>
+<% for document in Document.find :all,
+ :limit => 10,
+ :conditions => "documents.project_id in (#{@user.projects.collect{|m| m.id}.join(',')})",
+ :include => [:project] %>
+ <li>
+ <b><%= link_to document.title, :controller => 'documents', :action => 'show', :id => document %></b>
+ <br />
+ <%= truncate document.description, 150 %><br />
+ <em><%= format_time(document.created_on) %></em><br />
+ </li>
+<% end unless @user.projects.empty? %>
+</ul>
\ No newline at end of file diff --git a/app/views/my/blocks/_issues_assigned_to_me.rhtml b/app/views/my/blocks/_issues_assigned_to_me.rhtml new file mode 100644 index 000000000..2a4e2a05d --- /dev/null +++ b/app/views/my/blocks/_issues_assigned_to_me.rhtml @@ -0,0 +1,10 @@ +<h3><%=l(:label_assigned_to_me_issues)%></h3>
+<% assigned_issues = Issue.find(:all,
+ :conditions => ["assigned_to_id=?", user.id],
+ :limit => 10,
+ :include => [ :status, :project, :tracker ],
+ :order => 'issues.updated_on DESC') %>
+<%= render :partial => 'issues/list_simple', :locals => { :issues => assigned_issues } %>
+<% if assigned_issues.length > 0 %>
+<p><%=lwr(:label_last_updates, assigned_issues.length)%></p>
+<% end %>
diff --git a/app/views/my/blocks/_issues_reported_by_me.rhtml b/app/views/my/blocks/_issues_reported_by_me.rhtml new file mode 100644 index 000000000..9b40b3606 --- /dev/null +++ b/app/views/my/blocks/_issues_reported_by_me.rhtml @@ -0,0 +1,10 @@ +<h3><%=l(:label_reported_issues)%></h3>
+<% reported_issues = Issue.find(:all,
+ :conditions => ["author_id=?", user.id],
+ :limit => 10,
+ :include => [ :status, :project, :tracker ],
+ :order => 'issues.updated_on DESC') %>
+<%= render :partial => 'issues/list_simple', :locals => { :issues => reported_issues } %>
+<% if reported_issues.length > 0 %>
+<p><%=lwr(:label_last_updates, reported_issues.length)%></p>
+<% end %>
\ No newline at end of file diff --git a/app/views/my/blocks/_latest_news.rhtml b/app/views/my/blocks/_latest_news.rhtml new file mode 100644 index 000000000..85430ef54 --- /dev/null +++ b/app/views/my/blocks/_latest_news.rhtml @@ -0,0 +1,13 @@ +<h3><%=l(:label_news_latest)%></h3>
+
+<ul>
+<% for news in News.find :all,
+ :limit => 10,
+ :conditions => "news.project_id in (#{@user.projects.collect{|m| m.id}.join(',')})",
+ :include => [:project, :author] %>
+ <li><%= link_to news.title, :controller => 'news', :action => 'show', :id => news %><br />
+ <% unless news.summary.empty? %><%= news.summary %><br /><% end %>
+ <em><%= news.author.name %>, <%= format_time(news.created_on) %></em><br />
+ </li>
+<% end unless @user.projects.empty? %>
+</ul>
\ No newline at end of file diff --git a/app/views/my/page.rhtml b/app/views/my/page.rhtml new file mode 100644 index 000000000..121d48ca9 --- /dev/null +++ b/app/views/my/page.rhtml @@ -0,0 +1,30 @@ +<h2><%=l(:label_my_page)%></h2>
+
+<div class="topright">
+ <small><%= link_to l(:label_personalize_page), :action => 'page_layout' %></small>
+</div>
+
+<div id="list-top">
+ <% @blocks['top'].each do |b| %>
+ <div class="mypage-box">
+ <%= render :partial => "my/blocks/#{b}", :locals => { :user => @user } %>
+ </div>
+ <% end if @blocks['top'] %>
+</div>
+
+<div id="list-left" class="splitcontentleft">
+ <% @blocks['left'].each do |b| %>
+ <div class="mypage-box">
+ <%= render :partial => "my/blocks/#{b}", :locals => { :user => @user } %>
+ </div>
+ <% end if @blocks['left'] %>
+</div>
+
+<div id="list-right" class="splitcontentright">
+ <% @blocks['right'].each do |b| %>
+ <div class="mypage-box">
+ <%= render :partial => "my/blocks/#{b}", :locals => { :user => @user } %>
+ </div>
+ <% end if @blocks['right'] %>
+</div>
+
diff --git a/app/views/my/page_layout.rhtml b/app/views/my/page_layout.rhtml new file mode 100644 index 000000000..59a38567d --- /dev/null +++ b/app/views/my/page_layout.rhtml @@ -0,0 +1,121 @@ +<script language="JavaScript">
+
+function recreateSortables() {
+ Sortable.destroy('list-top');
+ Sortable.destroy('list-left');
+ Sortable.destroy('list-right');
+
+ Sortable.create("list-top", {constraint:false, containment:['list-top','list-left','list-right'], dropOnEmpty:true, handle:'handle', onUpdate:function(){new Ajax.Request('/my/order_blocks?group=top', {asynchronous:true, evalScripts:true, onComplete:function(request){new Effect.Highlight("list-top",{});}, onLoaded:function(request){Element.hide('indicator')}, onLoading:function(request){Element.show('indicator')}, parameters:Sortable.serialize("list-top")})}, only:'mypage-box', tag:'div'})
+ Sortable.create("list-left", {constraint:false, containment:['list-top','list-left','list-right'], dropOnEmpty:true, handle:'handle', onUpdate:function(){new Ajax.Request('/my/order_blocks?group=left', {asynchronous:true, evalScripts:true, onComplete:function(request){new Effect.Highlight("list-left",{});}, onLoaded:function(request){Element.hide('indicator')}, onLoading:function(request){Element.show('indicator')}, parameters:Sortable.serialize("list-left")})}, only:'mypage-box', tag:'div'})
+ Sortable.create("list-right", {constraint:false, containment:['list-top','list-left','list-right'], dropOnEmpty:true, handle:'handle', onUpdate:function(){new Ajax.Request('/my/order_blocks?group=right', {asynchronous:true, evalScripts:true, onComplete:function(request){new Effect.Highlight("list-right",{});}, onLoaded:function(request){Element.hide('indicator')}, onLoading:function(request){Element.show('indicator')}, parameters:Sortable.serialize("list-right")})}, only:'mypage-box', tag:'div'})
+}
+
+function updateSelect() {
+ s = $('block-select')
+ for (var i = 0; i < s.options.length; i++) {
+ if ($('block_' + s.options[i].value)) {
+ s.options[i].disabled = true;
+ } else {
+ s.options[i].disabled = false;
+ }
+ }
+ s.options[0].selected = true;
+}
+
+function afterAddBlock() {
+ recreateSortables();
+ updateSelect();
+}
+
+function removeBlock(block) {
+ $(block).parentNode.removeChild($(block));
+ updateSelect();
+}
+
+</script>
+
+<div style="float:right;">
+<%= start_form_tag({:action => "add_block"}, :id => "block-form") %>
+
+<%= select_tag 'block', "<option></option>" + options_for_select(@block_options), :id => "block-select", :class => "select-small" %>
+<small>
+<%= link_to_remote l(:button_add),
+ :url => { :action => "add_block" },
+ :with => "Form.serialize('block-form')",
+ :update => "list-top",
+ :position => :top,
+ :complete => "afterAddBlock();",
+ :loading => "Element.show('indicator')",
+ :loaded => "Element.hide('indicator')"
+ %>
+</small>
+<%= end_form_tag %>
+<small>|
+<%= link_to l(:button_save), :action => 'page_layout_save' %> |
+<%= link_to l(:button_cancel), :action => 'page' %>
+</small>
+</div>
+
+<div style="float:right;margin-right:20px;">
+<span id="indicator" style="display:none"><%= image_tag "loading.gif" %></span>
+</div>
+
+<h2><%=l(:label_my_page)%></h2>
+
+<div id="list-top" class="block-receiver">
+ <% @blocks['top'].each do |b| %>
+ <%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %>
+ <% end if @blocks['top'] %>
+</div>
+
+<div id="list-left" class="splitcontentleft block-receiver">
+ <% @blocks['left'].each do |b| %>
+ <%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %>
+ <% end if @blocks['left'] %>
+</div>
+
+<div id="list-right" class="splitcontentright block-receiver">
+ <% @blocks['right'].each do |b| %>
+ <%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %>
+ <% end if @blocks['right'] %>
+</div>
+
+<%= sortable_element 'list-top',
+ :tag => 'div',
+ :only => 'mypage-box',
+ :handle => "handle",
+ :dropOnEmpty => true,
+ :containment => ['list-top', 'list-left', 'list-right'],
+ :constraint => false,
+ :complete => visual_effect(:highlight, 'list-top'),
+ :url => { :action => "order_blocks", :group => "top" },
+ :loading => "Element.show('indicator')",
+ :loaded => "Element.hide('indicator')"
+ %>
+
+
+<%= sortable_element 'list-left',
+ :tag => 'div',
+ :only => 'mypage-box',
+ :handle => "handle",
+ :dropOnEmpty => true,
+ :containment => ['list-top', 'list-left', 'list-right'],
+ :constraint => false,
+ :complete => visual_effect(:highlight, 'list-left'),
+ :url => { :action => "order_blocks", :group => "left" },
+ :loading => "Element.show('indicator')",
+ :loaded => "Element.hide('indicator')" %>
+
+<%= sortable_element 'list-right',
+ :tag => 'div',
+ :only => 'mypage-box',
+ :handle => "handle",
+ :dropOnEmpty => true,
+ :containment => ['list-top', 'list-left', 'list-right'],
+ :constraint => false,
+ :complete => visual_effect(:highlight, 'list-right'),
+ :url => { :action => "order_blocks", :group => "right" },
+ :loading => "Element.show('indicator')",
+ :loaded => "Element.hide('indicator')" %>
+
+<%= javascript_tag "updateSelect()" %>
\ No newline at end of file diff --git a/app/views/news/_form.rhtml b/app/views/news/_form.rhtml new file mode 100644 index 000000000..2dcdc9f80 --- /dev/null +++ b/app/views/news/_form.rhtml @@ -0,0 +1,20 @@ +<%= error_messages_for 'news' %> +<div class="box"> +<p><%= f.text_field :title, :required => true, :size => 60 %></p> +<p><%= f.text_area :summary, :cols => 60, :rows => 2 %></p> +<p><%= f.text_area :description, :required => true, :cols => 60, :rows => 15 %></p> +</div> + +<% unless $RDM_TEXTILE_DISABLED %> +<%= javascript_include_tag 'jstoolbar' %> +<script type="text/javascript"> +//<![CDATA[ +if (document.getElementById) { + if (document.getElementById('news_description')) { + var commentTb = new jsToolBar(document.getElementById('news_description')); + commentTb.draw(); + } +} +//]]> +</script> +<% end %>
\ No newline at end of file diff --git a/app/views/news/edit.rhtml b/app/views/news/edit.rhtml new file mode 100644 index 000000000..5e015c4c7 --- /dev/null +++ b/app/views/news/edit.rhtml @@ -0,0 +1,6 @@ +<h2><%=l(:label_news)%></h2> + +<% labelled_tabular_form_for :news, @news, :url => { :action => "edit" } do |f| %> +<%= render :partial => 'form', :locals => { :f => f } %> +<%= submit_tag l(:button_save) %> +<% end %>
\ No newline at end of file diff --git a/app/views/news/show.rhtml b/app/views/news/show.rhtml new file mode 100644 index 000000000..91df09f0f --- /dev/null +++ b/app/views/news/show.rhtml @@ -0,0 +1,16 @@ +<h2><%= @news.title %></h2>
+
+<p><em><%= @news.summary %><br />
+<%= @news.author.display_name %>, <%= format_time(@news.created_on) %></em></p>
+<br />
+<%= textilizable auto_link @news.description %> +
+<div style="float:right;">
+<% if authorize_for('news', 'destroy') %>
+ <%= start_form_tag ({:controller => 'news', :action => 'destroy', :id => @news}) %>
+ <%= submit_tag l(:button_delete) %>
+ <%= end_form_tag %>
+<% end %>
+</div>
+
+<%= link_to_if_authorized l(:button_edit), :controller => 'news', :action => 'edit', :id => @news %>
diff --git a/app/views/projects/_form.rhtml b/app/views/projects/_form.rhtml new file mode 100644 index 000000000..ab0b35fab --- /dev/null +++ b/app/views/projects/_form.rhtml @@ -0,0 +1,26 @@ +<%= error_messages_for 'project' %> +<div class="box"> +<!--[form:project]--> +<p><%= f.text_field :name, :required => true %></p> + +<% if admin_loggedin? and !@root_projects.empty? %> + <p><%= f.select :parent_id, (@root_projects.collect {|p| [p.name, p.id]}), { :include_blank => true } %></p> +<% end %> + +<p><%= f.text_area :description, :required => true, :cols => 60, :rows => 3 %></p> +<p><%= f.text_field :homepage, :size => 40 %></p> +<p><%= f.check_box :is_public %></p> +
+<% for @custom_value in @custom_values %> + <p><%= custom_field_tag_with_label @custom_value %></p> +<% end %>
+ +<% unless @custom_fields.empty? %> +<p><label><%=l(:label_custom_field_plural)%></label> +<% for custom_field in @custom_fields %> + <%= check_box_tag "custom_field_ids[]", custom_field.id, ((@project.custom_fields.include? custom_field) or custom_field.is_for_all?), (custom_field.is_for_all? ? {:disabled => "disabled"} : {}) %>
+ <%= custom_field.name %>
+<% end %></p> +<% end %>
+<!--[eoform:project]-->
+</div> diff --git a/app/views/projects/activity.rhtml b/app/views/projects/activity.rhtml new file mode 100644 index 000000000..d6e5a1a43 --- /dev/null +++ b/app/views/projects/activity.rhtml @@ -0,0 +1,41 @@ +<h2><%=l(:label_activity)%></h2>
+
+<div>
+<div class="rightbox">
+ <%= start_form_tag %>
+<p><%= select_month(@month, :prefix => "month", :discard_type => true) %>
+<%= select_year(@year, :prefix => "year", :discard_type => true) %></p>
+ <%= check_box_tag 'show_issues', 1, @show_issues %><%= hidden_field_tag 'show_issues', 0 %> <%=l(:label_issue_plural)%><br />
+ <%= check_box_tag 'show_news', 1, @show_news %><%= hidden_field_tag 'show_news', 0 %> <%=l(:label_news_plural)%><br />
+ <%= check_box_tag 'show_files', 1, @show_files %><%= hidden_field_tag 'show_files', 0 %> <%=l(:label_attachment_plural)%><br />
+ <%= check_box_tag 'show_documents', 1, @show_documents %><%= hidden_field_tag 'show_documents', 0 %> <%=l(:label_document_plural)%><br />
+ <p><center><%= submit_tag l(:button_apply), :class => 'button-small' %></center></p>
+ <%= end_form_tag %>
+ </div>
+<% @events_by_day.keys.sort {|x,y| y <=> x }.each do |day| %>
+ <h3><%= day_name(day.cwday) %> <%= format_date(day) %></h3>
+ <ul>
+ <% @events_by_day[day].sort {|x,y| y.created_on <=> x.created_on }.each do |e| %>
+ <li><p>
+ <% if e.is_a? Issue %>
+ <%= e.created_on.strftime("%H:%M") %> <%= link_to "#{e.tracker.name} ##{e.id}", :controller => 'issues', :action => 'show', :id => e %> (<%= e.status.name %>): <%= e.subject %><br />
+ <i><%= e.author.name %></i>
+ <% elsif e.is_a? News %>
+ <%= e.created_on.strftime("%H:%M") %> <%=l(:label_news)%>: <%= link_to e.title, :controller => 'news', :action => 'show', :id => e %><br />
+ <% unless e.summary.empty? %><%= e.summary %><br /><% end %>
+ <i><%= e.author.name %></i>
+ <% elsif (e.is_a? Attachment) and (e.container.is_a? Version) %>
+ <%= e.created_on.strftime("%H:%M") %> <%=l(:label_attachment)%> (Version <%= e.container.name %>): <%= link_to e.filename, :controller => 'projects', :action => 'list_files', :id => @project %><br />
+ <i><%= e.author.name %></i>
+ <% elsif (e.is_a? Attachment) and (e.container.is_a? Document) %>
+ <%= e.created_on.strftime("%H:%M") %> <%=l(:label_document)%>: <%= link_to e.container.title, :controller => 'documents', :action => 'show', :id => e %><br />
+ <i><%= e.author.name %></i>
+ <% end %>
+ </p></li>
+
+ <% end %>
+ </ul>
+<% end %>
+<% if @events_by_day.empty? %><p><i><%= l(:label_no_data) %></i></p><% end %>
+<br />
+</div>
\ No newline at end of file diff --git a/app/views/projects/add.rhtml b/app/views/projects/add.rhtml new file mode 100644 index 000000000..bafbf9145 --- /dev/null +++ b/app/views/projects/add.rhtml @@ -0,0 +1,6 @@ +<h2><%=l(:label_project_new)%></h2> + +<% labelled_tabular_form_for :project, @project, :url => { :action => "add" } do |f| %> +<%= render :partial => 'form', :locals => { :f => f } %> +<%= submit_tag l(:button_save) %> +<% end %>
\ No newline at end of file diff --git a/app/views/projects/add_document.rhtml b/app/views/projects/add_document.rhtml new file mode 100644 index 000000000..88572f409 --- /dev/null +++ b/app/views/projects/add_document.rhtml @@ -0,0 +1,14 @@ +<h2><%=l(:label_document_new)%></h2> +
+<%= start_form_tag( { :action => 'add_document', :id => @project }, :class => "tabular", :multipart => true) %>
+<%= render :partial => 'documents/form' %> + +<div class="box">
+<p><label for="attachment_file"><%=l(:label_attachment)%></label> +<%= file_field 'attachment', 'file' %></p> +</div> +
+<%= submit_tag l(:button_create) %> +<%= end_form_tag %> +
+ diff --git a/app/views/projects/add_file.rhtml b/app/views/projects/add_file.rhtml new file mode 100644 index 000000000..fee67c53f --- /dev/null +++ b/app/views/projects/add_file.rhtml @@ -0,0 +1,14 @@ +<h2><%=l(:label_attachment_new)%></h2>
+
+<%= error_messages_for 'attachment' %>
+<%= start_form_tag ({ :action => 'add_file', :project => @project }, :multipart => true) %>
+
+<p><label for="version_id"><%=l(:field_version)%></label><br />
+<select name="version_id">
+<%= options_from_collection_for_select @versions, "id", "name" %> +</select></p>
+
+<p><b><%=l(:label_attachment)%><b><br /><%= file_field 'attachment', 'file' %></p>
+<br/>
+<%= submit_tag l(:button_add) %>
+<%= end_form_tag %>
\ No newline at end of file diff --git a/app/views/projects/add_issue.rhtml b/app/views/projects/add_issue.rhtml new file mode 100644 index 000000000..b60f91a2e --- /dev/null +++ b/app/views/projects/add_issue.rhtml @@ -0,0 +1,50 @@ +<h2><%=l(:label_issue_new)%>: <%= @tracker.name %></h2> +
+<% labelled_tabular_form_for :issue, @issue, :url => {:action => 'add_issue'}, :html => {:multipart => true} do |f| %> +<%= error_messages_for 'issue' %> +<div class="box"> +<!--[form:issue]--> +<%= hidden_field_tag 'tracker_id', @tracker.id %> + +<div class="splitcontentleft"> +<p><%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), :required => true %></p>
+<p><%= f.select :assigned_to_id, (@issue.project.members.collect {|m| [m.name, m.user_id]}), :include_blank => true %></p>
+<p><%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %></p>
+</div> +<div class="splitcontentright"> +<p><%= f.text_field :start_date, :size => 10 %><%= calendar_for('issue_start_date') %></p> +<p><%= f.text_field :due_date, :size => 10 %><%= calendar_for('issue_due_date') %></p> +<p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></p> +</div> + +<div class="clear"> +<p><%= f.text_field :subject, :size => 80, :required => true %></p> +<p><%= f.text_area :description, :cols => 60, :rows => 10, :required => true %></p> +
+<% for @custom_value in @custom_values %> + <p><%= custom_field_tag_with_label @custom_value %></p> +<% end %>
+
+<p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%> +<%= link_to_function image_tag('add'), "addFileField()" %></label> +<%= file_field_tag 'attachments[]', :size => 30 %></p> + +</div> +<!--[eoform:issue]--> +</div> +<%= submit_tag l(:button_create) %>
+<% end %> + +<% unless $RDM_TEXTILE_DISABLED %> +<%= javascript_include_tag 'jstoolbar' %> +<script type="text/javascript"> +//<![CDATA[ +if (document.getElementById) { + if (document.getElementById('issue_description')) { + var commentTb = new jsToolBar(document.getElementById('issue_description')); + commentTb.draw(); + } +} +//]]> +</script> +<% end %>
\ No newline at end of file diff --git a/app/views/projects/add_news.rhtml b/app/views/projects/add_news.rhtml new file mode 100644 index 000000000..a6ecd3da7 --- /dev/null +++ b/app/views/projects/add_news.rhtml @@ -0,0 +1,6 @@ +<h2><%=l(:label_news_new)%></h2> + +<% labelled_tabular_form_for :news, @news, :url => { :action => "add_news" } do |f| %> +<%= render :partial => 'news/form', :locals => { :f => f } %> +<%= submit_tag l(:button_create) %> +<% end %>
\ No newline at end of file diff --git a/app/views/projects/add_version.rhtml b/app/views/projects/add_version.rhtml new file mode 100644 index 000000000..c038b7de9 --- /dev/null +++ b/app/views/projects/add_version.rhtml @@ -0,0 +1,6 @@ +<h2><%=l(:label_version_new)%></h2> + +<% labelled_tabular_form_for :version, @version, :url => { :action => 'add_version' } do |f| %> +<%= render :partial => 'versions/form', :locals => { :f => f } %> +<%= submit_tag l(:button_create) %> +<% end %>
\ No newline at end of file diff --git a/app/views/projects/calendar.rhtml b/app/views/projects/calendar.rhtml new file mode 100644 index 000000000..fc62921d4 --- /dev/null +++ b/app/views/projects/calendar.rhtml @@ -0,0 +1,75 @@ +<h2><%= l(:label_calendar) %></h2>
+
+<table width="100%">
+<tr>
+<td align="left">
+<%= start_form_tag :action => 'calendar', :id => @project %>
+<%= select_month(@month, :prefix => "month", :discard_type => true) %>
+<%= select_year(@year, :prefix => "year", :discard_type => true) %>
+<%= submit_tag l(:button_submit), :class => "button-small" %>
+<%= end_form_tag %>
+</td>
+<td align="right">
+<%= image_tag 'gantt' %>
+<%= link_to l(:label_gantt_chart), :action => 'gantt', :id => @project %>
+</td>
+</tr>
+</table>
+<br />
+
+<table class="calenderTable">
+<tr class="ListHead">
+<td></td>
+<% 1.upto(7) do |d| %>
+ <td align="center" width="14%"><%= day_name(d) %></td>
+<% end %>
+</tr>
+<tr height="100">
+<% day = @date_from
+while day <= @date_to
+ if day.cwday == 1 %>
+ <td valign="middle"><%= day.cweek %></td>
+ <% end %>
+ <td valign="top" width="14%" class="<%= day.month==@month ? "even" : "odd" %>">
+ <p align="right"><%= day==Date.today ? "<b>#{day.day}</b>" : day.day %></p>
+ <% day_issues = []
+ @issues.each { |i| day_issues << i if i.start_date == day or i.due_date == day }
+ day_issues.each do |i| %>
+ <%= if day == i.start_date and day == i.due_date
+ image_tag('arrow_bw')
+ elsif day == i.start_date
+ image_tag('arrow_from')
+ elsif day == i.due_date
+ image_tag('arrow_to')
+ end %>
+ <small><%= link_to "#{i.tracker.name} ##{i.id}", :controller => 'issues', :action => 'show', :id => i %>: <%= i.subject.sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)') %></small><br />
+ <% end %>
+ </td>
+ <%= '</tr><tr height="100">' if day.cwday >= 7 and day!=@date_to %>
+ <%
+ day = day + 1
+end %>
+</tr>
+</table>
+
+<table width="100%">
+<tr>
+<td align="left">
+<%= link_to_remote ('« ' + l(:label_previous)),
+ {:update => "content", :url => { :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1) }},
+ {:href => url_for(:action => 'calendar', :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1))}
+ %>
+</td>
+<td align="right">
+<%= link_to_remote (l(:label_next) + ' »'),
+ {:update => "content", :url => { :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1) }},
+ {:href => url_for(:action => 'calendar', :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1))}
+ %>
+
+</td>
+</tr>
+</table>
+<br />
+<%= image_tag 'arrow_from' %> <%= l(:text_tip_task_begin_day) %><br />
+<%= image_tag 'arrow_to' %> <%= l(:text_tip_task_end_day) %><br />
+<%= image_tag 'arrow_bw' %> <%= l(:text_tip_task_begin_end_day) %><br />
\ No newline at end of file diff --git a/app/views/projects/changelog.rhtml b/app/views/projects/changelog.rhtml new file mode 100644 index 000000000..081456413 --- /dev/null +++ b/app/views/projects/changelog.rhtml @@ -0,0 +1,28 @@ +<h2><%=l(:label_change_log)%></h2>
+
+<div>
+
+<div class="rightbox" style="width:140px;">
+<%= start_form_tag %>
+<strong><%=l(:label_tracker_plural)%></strong><br />
+<% @trackers.each do |tracker| %>
+ <%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %>
+ <%= tracker.name %><br />
+<% end %>
+<p><center><%= submit_tag l(:button_apply), :class => 'button-small' %></center></p>
+<%= end_form_tag %>
+</div>
+
+<% ver_id = nil
+ @fixed_issues.each do |issue| %>
+ <% unless ver_id == issue.fixed_version_id %>
+ <% if ver_id %></ul><% end %>
+ <h3><%= l(:label_version) %>: <%= issue.fixed_version.name %></h3>
+ <p><%= format_date(issue.fixed_version.effective_date) %><br />
+ <%=h issue.fixed_version.description %></p>
+ <ul>
+ <% ver_id = issue.fixed_version_id
+ end %>
+ <li><%= link_to issue.long_id, :controller => 'issues', :action => 'show', :id => issue %> [<%= issue.tracker.name %>]: <%= issue.subject %></li>
+<% end %>
+</div>
\ No newline at end of file diff --git a/app/views/projects/destroy.rhtml b/app/views/projects/destroy.rhtml new file mode 100644 index 000000000..d11705be4 --- /dev/null +++ b/app/views/projects/destroy.rhtml @@ -0,0 +1,14 @@ +<h2><%=l(:label_confirmation)%></h2>
+<div class="box">
+<center>
+<p><strong><%= @project.name %></strong><br />
+<%=l(:text_project_destroy_confirmation)%></p>
+
+<p>
+ <%= start_form_tag({:controller => 'projects', :action => 'destroy', :id => @project}) %>
+ <%= hidden_field_tag "confirm", 1 %>
+ <%= submit_tag l(:button_delete) %>
+ <%= end_form_tag %>
+</p>
+</center>
+</div>
\ No newline at end of file diff --git a/app/views/projects/export_issues_pdf.rfpdf b/app/views/projects/export_issues_pdf.rfpdf new file mode 100644 index 000000000..2e0acf54b --- /dev/null +++ b/app/views/projects/export_issues_pdf.rfpdf @@ -0,0 +1,11 @@ +<% pdf=IfpdfHelper::IFPDF.new
+ pdf.AliasNbPages
+ pdf.footer_date = format_date(Date.today)
+ pdf.AddPage
+ @issues.each {|i|
+ render :partial => 'issues/pdf', :locals => { :pdf => pdf, :issue => i }
+ pdf.AddPage
+ }
+%>
+
+<%= pdf.Output %>
\ No newline at end of file diff --git a/app/views/projects/gantt.rfpdf b/app/views/projects/gantt.rfpdf new file mode 100644 index 000000000..545abb483 --- /dev/null +++ b/app/views/projects/gantt.rfpdf @@ -0,0 +1,168 @@ +<%
+pdf=IfpdfHelper::IFPDF.new
+pdf.AliasNbPages
+pdf.footer_date = format_date(Date.today)
+pdf.AddPage("L")
+pdf.SetFont('Arial','B',12)
+pdf.SetX(15)
+pdf.Cell(70, 20, @project.name)
+pdf.Ln
+pdf.SetFont('Arial','B',9)
+
+subject_width = 70
+header_heigth = 5
+
+headers_heigth = header_heigth
+show_weeks = false
+show_days = false
+
+if @months < 7
+ show_weeks = true
+ headers_heigth = 2*header_heigth
+ if @months < 3
+ show_days = true
+ headers_heigth = 3*header_heigth
+ end
+end
+
+g_width = 210
+zoom = (g_width) / (@date_to - @date_from + 1)
+g_height = 120
+t_height = g_height + headers_heigth
+
+y_start = pdf.GetY
+
+
+#
+# Months headers
+#
+month_f = @date_from
+left = subject_width
+height = header_heigth
+@months.times do
+ width = ((month_f >> 1) - month_f) * zoom
+ pdf.SetY(y_start)
+ pdf.SetX(left)
+ pdf.Cell(width, height, "#{month_f.year}-#{month_f.month}", "LTR", 0, "C")
+ left = left + width
+ month_f = month_f >> 1
+end
+
+#
+# Weeks headers
+#
+if show_weeks
+ left = subject_width
+ height = header_heigth
+ if @date_from.cwday == 1
+ # @date_from is monday
+ week_f = @date_from
+ else
+ # find next monday after @date_from
+ week_f = @date_from + (7 - @date_from.cwday + 1)
+ width = (7 - @date_from.cwday + 1) * zoom-1
+ pdf.SetY(y_start + header_heigth)
+ pdf.SetX(left)
+ pdf.Cell(width + 1, height, "", "LTR")
+ left = left + width+1
+ end
+ while week_f < @date_to
+ width = (week_f + 6 <= @date_to) ? 7 * zoom : (@date_to - week_f + 1) * zoom
+ pdf.SetY(y_start + header_heigth)
+ pdf.SetX(left)
+ pdf.Cell(width, height, week_f.cweek.to_s, "LTR", 0, "C")
+ left = left + width
+ week_f = week_f+7
+ end
+end
+
+#
+# Days headers
+#
+if show_days
+ left = subject_width
+ height = header_heigth
+ wday = @date_from.cwday
+ pdf.SetFont('Arial','B',7)
+ (@date_to - @date_from + 1).to_i.times do
+ width = zoom
+ pdf.SetY(y_start + 2 * header_heigth)
+ pdf.SetX(left)
+ pdf.Cell(width, height, day_name(wday)[0,1], "LTR", 0, "C")
+ left = left + width
+ wday = wday + 1
+ wday = 1 if wday > 7
+ end
+end
+
+pdf.SetY(y_start)
+pdf.SetX(15)
+pdf.Cell(subject_width+g_width-15, headers_heigth, "", 1)
+
+
+#
+# Tasks
+#
+top = headers_heigth + y_start
+pdf.SetFont('Arial','B',7)
+@issues.each do |i|
+ pdf.SetY(top)
+ pdf.SetX(15)
+ pdf.Cell(subject_width-15, 5, "#{i.tracker.name} #{i.id}: #{i.subject}".sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)'), "LR")
+
+ pdf.SetY(top)
+ pdf.SetX(subject_width)
+ pdf.Cell(g_width, 5, "", "LR")
+
+ i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from )
+ i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to )
+
+ i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor
+ i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date )
+ i_done_date = (i_done_date >= @date_to ? @date_to : i_done_date )
+
+ i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
+
+ i_left = ((i_start_date - @date_from)*zoom)
+ i_width = ((i_end_date - i_start_date + 1)*zoom)
+ d_width = ((i_done_date - i_start_date)*zoom)
+ l_width = ((i_late_date - i_start_date+1)*zoom) if i_late_date
+ l_width ||= 0
+
+ pdf.SetY(top+1.5)
+ pdf.SetX(subject_width + i_left)
+ pdf.SetFillColor(200,200,200)
+ pdf.Cell(i_width, 2, "", 0, 0, "", 1)
+
+ if l_width > 0
+ pdf.SetY(top+1.5)
+ pdf.SetX(subject_width + i_left)
+ pdf.SetFillColor(255,100,100)
+ pdf.Cell(l_width, 2, "", 0, 0, "", 1)
+ end
+ if d_width > 0
+ pdf.SetY(top+1.5)
+ pdf.SetX(subject_width + i_left)
+ pdf.SetFillColor(100,100,255)
+ pdf.Cell(d_width, 2, "", 0, 0, "", 1)
+ end
+
+ pdf.SetY(top+1.5)
+ pdf.SetX(subject_width + i_left + i_width)
+ pdf.Cell(30, 2, "#{i.status.name} #{i.done_ratio}%")
+
+ top = top + 5
+ pdf.SetDrawColor(200, 200, 200)
+ pdf.Line(15, top, subject_width+g_width, top)
+ if pdf.GetY() > 180
+ pdf.AddPage("L")
+ top = 20
+ pdf.Line(15, top, subject_width+g_width, top)
+ end
+ pdf.SetDrawColor(0, 0, 0)
+end
+
+pdf.Line(15, top, subject_width+g_width, top)
+
+%>
+<%= pdf.Output %>
\ No newline at end of file diff --git a/app/views/projects/gantt.rhtml b/app/views/projects/gantt.rhtml new file mode 100644 index 000000000..78d3ac20a --- /dev/null +++ b/app/views/projects/gantt.rhtml @@ -0,0 +1,241 @@ +<h2><%= l(:label_gantt_chart) %></h2>
+<div class="topright">
+<small>
+<%= l(:label_export_to) %> <%= link_to 'PDF', :zoom => @zoom, :year => @year_from, :month => @month_from, :months => @months, :output => 'pdf' %>
+</small>
+</div>
+
+<table width="100%">
+<tr>
+<td align="left">
+<%= start_form_tag %>
+<input type="text" name="months" size="2" value="<%= @months %>">
+<%= l(:label_months_from) %>
+<%= select_month(@month_from, :prefix => "month", :discard_type => true) %>
+<%= select_year(@year_from, :prefix => "year", :discard_type => true) %>
+<%= hidden_field_tag 'zoom', @zoom %>
+<%= submit_tag l(:button_submit), :class => "button-small" %>
+<%= end_form_tag %>
+</td>
+<td align="right">
+<%= if @zoom < 4
+ link_to image_tag('zoom_in'), {:zoom => (@zoom+1), :year => @year_from, :month => @month_from, :months => @months}
+ else
+ image_tag 'zoom_in_g'
+ end %>
+<%= if @zoom > 1
+ link_to image_tag('zoom_out'), :zoom => (@zoom-1), :year => @year_from, :month => @month_from, :months => @months
+ else
+ image_tag 'zoom_out_g'
+ end %>
+</td>
+</tr>
+</table>
+<br />
+
+<style>
+.m_bg {
+ position:absolute;
+ top:0;
+ height:16px;
+ border-top: 1px solid #c0c0c0;
+ border-bottom: 1px solid #c0c0c0;
+ border-right: 1px solid #c0c0c0;
+ text-align: center;
+}
+
+.task {
+ position: absolute;
+ height:8px;
+ font-size:0.8em;
+ color:#888;
+ background:#aaa;
+ padding:0;
+ margin:0;
+ line-height:0.8em;
+}
+
+.task_late {
+ background:#f66;
+}
+
+.task_done {
+ background:#66f;
+}
+</style>
+
+<% zoom = 1
+@zoom.times { zoom = zoom * 2 }
+
+subject_width = 260
+header_heigth = 18
+
+headers_heigth = header_heigth
+show_weeks = false
+show_days = false
+
+if @zoom >1
+ show_weeks = true
+ headers_heigth = 2*header_heigth
+ if @zoom > 2
+ show_days = true
+ headers_heigth = 3*header_heigth
+ end
+end
+
+g_width = (@date_to - @date_from + 1)*zoom
+g_height = [(20 * @issues.length + 6), 206].max
+t_height = g_height + headers_heigth
+%>
+
+<table width="100%" border=0 cellspacing=0 cellpading=0>
+<tr>
+<td width=260>
+
+<div style="position:relative;height:<%= t_height + 24 %>px;width:<%= subject_width + 1 %>px;">
+<div style="right:-2px;width:<%= subject_width %>px;height:<%= headers_heigth %>px;" class="m_bg"></div>
+<div style="right:-2px;width:<%= subject_width %>px;height:<%= t_height %>px;border-left: 1px solid #c0c0c0;" class="m_bg"></div>
+<%
+#
+# Tasks subjects
+#
+top = headers_heigth + 8
+@issues.each do |i| %>
+ <div style="position: absolute;line-height:1em;height:16px;top:<%= top %>px;left:4px;width:<%= subject_width - 5 %>px;overflow:hidden;">
+ <small><%= link_to "#{i.tracker.name} ##{i.id}", :controller => 'issues', :action => 'show', :id => i %>:
+ <%= i.subject.sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)') %></small>
+ </div>
+<% top = top + 20
+end %>
+</div>
+</td>
+<td>
+
+<div style="position:relative;height:<%= t_height + 24 %>px;width:<%= subject_width %>;overflow:auto;">
+<div style="width:<%= g_width-1 %>px;height:<%= headers_heigth %>px;" class="m_bg"> </div>
+<%
+#
+# Months headers
+#
+month_f = @date_from
+left = 0
+height = (show_weeks ? header_heigth : header_heigth + g_height)
+@months.times do
+ width = ((month_f >> 1) - month_f) * zoom - 1
+ %>
+ <div style="left:<%= left %>px;width:<%= width %>px;height:<%= height %>px;" class="m_bg">
+ <%= link_to "#{month_f.year}-#{month_f.month}", :year => month_f.year, :month => month_f.month, :zoom => @zoom, :months => @months %>
+ </div>
+ <%
+ left = left + width + 1
+ month_f = month_f >> 1
+end %>
+
+<%
+#
+# Weeks headers
+#
+if show_weeks
+ left = 0
+ height = (show_days ? header_heigth-1 : header_heigth-1 + g_height)
+ if @date_from.cwday == 1
+ # @date_from is monday
+ week_f = @date_from
+ else
+ # find next monday after @date_from
+ week_f = @date_from + (7 - @date_from.cwday + 1)
+ width = (7 - @date_from.cwday + 1) * zoom-1
+ %>
+ <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="m_bg"> </div>
+ <%
+ left = left + width+1
+ end %>
+ <%
+ while week_f < @date_to
+ width = (week_f + 6 <= @date_to) ? 7 * zoom -1 : (@date_to - week_f + 1) * zoom-1
+ %>
+ <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="m_bg">
+ <small><%= week_f.cweek %></small>
+ </div>
+ <%
+ left = left + width+1
+ week_f = week_f+7
+ end
+end %>
+
+<%
+#
+# Days headers
+#
+if show_days
+ left = 0
+ height = g_height + header_heigth - 1
+ wday = @date_from.cwday
+ (@date_to - @date_from + 1).to_i.times do
+ width = zoom - 1
+ %>
+ <div style="left:<%= left %>px;top:37px;width:<%= width %>px;height:<%= height %>px;font-size:0.7em;<%= "background:#f1f1f1;" if wday > 5 %>" class="m_bg">
+ <%= day_name(wday)[0,1] %>
+ </div>
+ <%
+ left = left + width+1
+ wday = wday + 1
+ wday = 1 if wday > 7
+ end
+end %>
+
+<%
+#
+# Today red line
+#
+if Date.today >= @date_from and Date.today <= @date_to %>
+ <div style="position: absolute;height:<%= g_height %>px;top:<%= headers_heigth + 1 %>px;left:<%= ((Date.today-@date_from+1)*zoom).floor()-1 %>px;width:10px;border-left: 1px dashed red;"> </div>
+<% end %>
+
+<%
+#
+# Tasks
+#
+top = headers_heigth + 12
+@issues.each do |i| %>
+ <%
+ i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from )
+ i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to )
+
+ i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor
+ i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date )
+ i_done_date = (i_done_date >= @date_to ? @date_to : i_done_date )
+
+ i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
+
+ i_left = ((i_start_date - @date_from)*zoom).floor
+ i_width = ((i_end_date - i_start_date + 1)*zoom).floor
+ d_width = ((i_done_date - i_start_date)*zoom).floor
+ l_width = ((i_late_date - i_start_date+1)*zoom).floor if i_late_date
+ l_width ||= 0
+ %>
+ <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;" class="task"> </div>
+ <% if l_width > 0 %>
+ <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= l_width %>px;" class="task task_late"> </div>
+ <% end %>
+ <% if d_width > 0 %>
+ <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= d_width %>px;" class="task task_done"> </div>
+ <% end %>
+ <div style="top:<%= top %>px;left:<%= i_left + i_width + 5 %>px;background:#fff;" class="task">
+ <%= i.status.name %>
+ <%= (i.done_ratio).to_i %>%
+ </div>
+ <% top = top + 20
+end %>
+</div>
+</td>
+</tr>
+</table>
+
+<table width="100%">
+<tr>
+<td align="left"><%= link_to ('« ' + l(:label_previous)), :year => (@date_from << @months).year, :month => (@date_from << @months).month, :zoom => @zoom, :months => @months %></td>
+<td>
+<td align="right"><%= link_to (l(:label_next) + ' »'), :year => (@date_from >> @months).year, :month => (@date_from >> @months).month, :zoom => @zoom, :months => @months %></td>
+</tr>
+</table>
\ No newline at end of file diff --git a/app/views/projects/list.rhtml b/app/views/projects/list.rhtml new file mode 100644 index 000000000..0137086d9 --- /dev/null +++ b/app/views/projects/list.rhtml @@ -0,0 +1,20 @@ +<h2><%=l(:label_public_projects)%></h2> + +<table class="listTableContent"> + <tr class="ListHead"> + <%= sort_header_tag('name', :caption => l(:label_project)) %>
+ <th><%=l(:field_description)%></th>
+ <%= sort_header_tag('created_on', :caption => l(:field_created_on)) %> + </tr> + +<% for project in @projects %> + <tr class="<%= cycle("odd", "even") %>">
+ <td><%= link_to project.name, :action => 'show', :id => project %>
+ <td><%= project.description %>
+ <td align="center"><%= format_date(project.created_on) %>
+ </tr> +<% end %> +</table>
+
+<%= pagination_links_full @project_pages %> +[ <%= @project_pages.current.first_item %> - <%= @project_pages.current.last_item %> / <%= @project_count %> ]
\ No newline at end of file diff --git a/app/views/projects/list_documents.rhtml b/app/views/projects/list_documents.rhtml new file mode 100644 index 000000000..e6cf2b828 --- /dev/null +++ b/app/views/projects/list_documents.rhtml @@ -0,0 +1,23 @@ +<h2><%=l(:label_document_plural)%></h2>
+
+<% if @documents.empty? %><p><i><%= l(:label_no_data) %></i></p><% end %>
+
+<% documents = @documents.group_by {|d| d.category } %>
+<% documents.each do |category, docs| %>
+<h3><%= category.name %></h3>
+<ul>
+<% docs.each do |d| %>
+ <li>
+ <b><%= link_to d.title, :controller => 'documents', :action => 'show', :id => d %></b>
+ <br />
+ <%= truncate d.description, 250 %><br />
+ <em><%= format_time(d.created_on) %></em><br />
+ </li> +
+<% end %>
+</ul>
+<% end %>
+
+<p>
+<%= link_to_if_authorized '» ' + l(:label_document_new), :controller => 'projects', :action => 'add_document', :id => @project %> +</p>
diff --git a/app/views/projects/list_files.rhtml b/app/views/projects/list_files.rhtml new file mode 100644 index 000000000..5fe65e6a6 --- /dev/null +++ b/app/views/projects/list_files.rhtml @@ -0,0 +1,46 @@ +<h2><%=l(:label_attachment_plural)%></h2>
+
+<% delete_allowed = authorize_for('versions', 'destroy_file') %>
+
+<table class="listTableContent">
+ <tr class="ListHead">
+ <th><%=l(:field_version)%></th>
+ <th><%=l(:field_filename)%></th>
+ <th><%=l(:label_date)%></th>
+ <th><%=l(:field_filesize)%></th>
+ <th>D/L</th>
+ <th>MD5</th>
+ <% if delete_allowed %><th></th><% end %>
+ </tr>
+
+<% for version in @versions %>
+ <% unless version.attachments.empty? %>
+ <tr><td colspan="7"><%= image_tag 'package' %> <b><%= version.name %></b></td></tr>
+ <% for file in version.attachments %> + <tr class="<%= cycle("odd", "even") %>">
+ <td></td>
+ <td><%= link_to file.filename, :controller => 'versions', :action => 'download', :id => version, :attachment_id => file %></td>
+ <td align="center"><%= format_date(file.created_on) %></td>
+ <td align="center"><%= human_size(file.filesize) %></td>
+ <td align="center"><%= file.downloads %></td> + <td align="center"><small><%= file.digest %></small></td>
+ <% if delete_allowed %>
+ <td align="center">
+ <%= start_form_tag :controller => 'versions', :action => 'destroy_file', :id => version, :attachment_id => file %>
+ <%= submit_tag l(:button_delete), :class => "button-small" %>
+ <%= end_form_tag %>
+ </td>
+ <% end %> + </tr> + <% end
+ reset_cycle %>
+ <% end %>
+<% end %>
+</table>
+
+<br />
+<p>
+<%= link_to_if_authorized '» ' + l(:label_attachment_new), :controller => 'projects', :action => 'add_file', :id => @project %> +</p>
+
+
diff --git a/app/views/projects/list_issues.rhtml b/app/views/projects/list_issues.rhtml new file mode 100644 index 000000000..e7e3ceeda --- /dev/null +++ b/app/views/projects/list_issues.rhtml @@ -0,0 +1,76 @@ +<h2><%=l(:label_issue_plural)%></h2>
+<div class="topright">
+<small>
+<%= l(:label_export_to) %>
+<%= link_to 'CSV', :action => 'export_issues_csv', :id => @project %>,
+<%= link_to 'PDF', :action => 'export_issues_pdf', :id => @project %>
+</small>
+</div>
+
+<%= start_form_tag :action => 'list_issues' %>
+<table cellpadding=2>
+ <tr>
+ <td valign="bottom"><small><%=l(:field_status)%>:</small><br /><%= search_filter_tag 'status_id', :class => 'select-small' %></td>
+ <td valign="bottom"><small><%=l(:field_tracker)%>:</small><br /><%= search_filter_tag 'tracker_id', :class => 'select-small' %></td>
+ <td valign="bottom"><small><%=l(:field_priority)%>:</small><br /><%= search_filter_tag 'priority_id', :class => 'select-small' %></td>
+ <td valign="bottom"><small><%=l(:field_category)%>:</small><br /><%= search_filter_tag 'category_id', :class => 'select-small' %></td>
+ <td valign="bottom"><small><%=l(:field_fixed_version)%>:</small><br /><%= search_filter_tag 'fixed_version_id', :class => 'select-small' %></td>
+ <td valign="bottom"><small><%=l(:field_author)%>:</small><br /><%= search_filter_tag 'author_id', :class => 'select-small' %></td>
+ <td valign="bottom"><small><%=l(:field_assigned_to)%>:</small><br /><%= search_filter_tag 'assigned_to_id', :class => 'select-small' %></td>
+ <td valign="bottom"><small><%=l(:label_subproject_plural)%>:</small><br /><%= search_filter_tag 'subproject_id', :class => 'select-small' %></td>
+ <td valign="bottom">
+ <%= hidden_field_tag 'set_filter', 1 %>
+ <%= submit_tag l(:button_apply), :class => 'button-small' %>
+ </td>
+ <td valign="bottom">
+ <%= link_to l(:button_clear), :action => 'list_issues', :id => @project, :set_filter => 1 %>
+ </td>
+ </tr>
+</table>
+<%= end_form_tag %>
+
+
+<table class="listTableContent">
+ <tr>
+ <td colspan="6" align="left"><small><%= check_all_links 'issues_form' %></small></td>
+ <td colspan="2" align="right">
+ <small><%= l(:label_per_page) %>:</small>
+ <%= start_form_tag %>
+ <%= select_tag 'per_page', options_for_select(@results_per_page_options, @results_per_page), :class => 'select-small'%>
+ <%= submit_tag l(:button_apply), :class => 'button-small'%>
+ <%= end_form_tag %>
+ </td>
+ </tr>
+</table>
+<%= start_form_tag({:controller => 'projects', :action => 'move_issues', :id => @project}, :id => 'issues_form' ) %>
+<table class="listTableContent">
+
+ <tr class="ListHead">
+ <td></td>
+ <%= sort_header_tag('issues.id', :caption => '#') %>
+ <%= sort_header_tag('issue_statuses.name', :caption => l(:field_status)) %>
+ <%= sort_header_tag('issues.tracker_id', :caption => l(:field_tracker)) %>
+ <th><%=l(:field_subject)%></th>
+ <%= sort_header_tag('users.lastname', :caption => l(:field_author)) %>
+ <%= sort_header_tag('issues.created_on', :caption => l(:field_created_on)) %>
+ <%= sort_header_tag('issues.updated_on', :caption => l(:field_updated_on)) %>
+ </tr>
+ <% for issue in @issues %> + <tr class="<%= cycle("odd", "even") %>">
+ <td width="15"><%= check_box_tag "issue_ids[]", issue.id %></td>
+ <td align="center"><%= link_to issue.long_id, :controller => 'issues', :action => 'show', :id => issue %></td>
+ <td align="center" style="font-weight:bold;color:#<%= issue.status.html_color %>;"><%= issue.status.name %></font></td>
+ <td align="center"><%= issue.tracker.name %></td>
+ <td><%= link_to issue.subject, :controller => 'issues', :action => 'show', :id => issue %></td> + <td align="center"><%= issue.author.display_name %></td>
+ <td align="center"><%= format_time(issue.created_on) %></td> + <td align="center"><%= format_time(issue.updated_on) %></td> + </tr> + <% end %> +</table>
+<p>
+<%= pagination_links_full @issue_pages %>
+[ <%= @issue_pages.current.first_item %> - <%= @issue_pages.current.last_item %> / <%= @issue_count %> ]
+</p>
+<%= submit_tag l(:button_move) %>
+<%= end_form_tag %>
\ No newline at end of file diff --git a/app/views/projects/list_members.rhtml b/app/views/projects/list_members.rhtml new file mode 100644 index 000000000..655abb280 --- /dev/null +++ b/app/views/projects/list_members.rhtml @@ -0,0 +1,11 @@ +<h2><%=l(:label_member_plural)%></h2>
+
+<% members = @members.group_by {|m| m.role } %>
+<% members.each do |role, member| %>
+<h3><%= role.name %></h3>
+<ul>
+<% member.each do |m| %>
+<li><%= link_to m.user.display_name, :controller => 'account', :action => 'show', :id => m.user %> (<%= format_date m.created_on %>)</li>
+<% end %>
+</ul>
+<% end %>
diff --git a/app/views/projects/list_news.rhtml b/app/views/projects/list_news.rhtml new file mode 100644 index 000000000..6880de32f --- /dev/null +++ b/app/views/projects/list_news.rhtml @@ -0,0 +1,18 @@ +<h2><%=l(:label_news_plural)%></h2> + +<% if @news.empty? %><p><i><%= l(:label_no_data) %></i></p><% end %> + +<ul> +<% for news in @news %>
+ <li><%= link_to news.title, :controller => 'news', :action => 'show', :id => news %><br />
+ <% unless news.summary.empty? %><%= news.summary %><br /><% end %> + <em><%= news.author.name %>, <%= format_time(news.created_on) %></em><br />
+ </li>
+<% end %> +</ul> + +
+<%= pagination_links_full @news_pages %>
+<p> +<%= link_to_if_authorized '» ' + l(:label_news_new), :controller => 'projects', :action => 'add_news', :id => @project %> +</p>
diff --git a/app/views/projects/move_issues.rhtml b/app/views/projects/move_issues.rhtml new file mode 100644 index 000000000..380d47fd5 --- /dev/null +++ b/app/views/projects/move_issues.rhtml @@ -0,0 +1,24 @@ +<h2><%=l(:button_move)%></h2> + + +<%= start_form_tag({:action => 'move_issues', :id => @project}, :class => "tabular") %> + +<div class="box"> +<p><label><%= l(:label_issue_plural) %>:</label> +<% for issue in @issues %> + <b><%= link_to issue.long_id, :controller => 'issues', :action => 'show', :id => issue %></b> - <%= issue.subject %> + <%= hidden_field_tag "issue_ids[]", issue.id %><br /> +<% end %> +<i>(<%= @issues.length%> <%= lwr(:label_issue, @issues.length)%>)</i></p> + + + +<!--[form:issue]--> +<p><label for="new_project_id"><%=l(:field_project)%></label> +<%= select_tag "new_project_id", options_from_collection_for_select(@projects, "id", "name", @project.id) %></p> + +<p><label for="new_tracker_id"><%=l(:field_tracker)%></label> +<%= select_tag "new_tracker_id", options_from_collection_for_select(@trackers, "id", "name") %></p> +</div> +<%= submit_tag l(:button_move) %> +<%= end_form_tag %> diff --git a/app/views/projects/settings.rhtml b/app/views/projects/settings.rhtml new file mode 100644 index 000000000..3f9cba0a0 --- /dev/null +++ b/app/views/projects/settings.rhtml @@ -0,0 +1,118 @@ +<h2><%=l(:label_settings)%></h2> + +<% if authorize_for('projects', 'edit') %>
+ <% labelled_tabular_form_for :project, @project, :url => { :action => "edit", :id => @project } do |f| %> + <%= render :partial => 'form', :locals => { :f => f } %> + <%= submit_tag l(:button_save) %> + <% end %> + <br /> +<% end %> +
+<div class="box"> +<h3><%=l(:label_member_plural)%></h3>
+<%= error_messages_for 'member' %>
+<table>
+<% for member in @project.members.find(:all, :include => :user) %>
+ <% unless member.new_record? %>
+ <tr>
+ <td><%= member.user.display_name %></td>
+ <td>
+ <% if authorize_for('members', 'edit') %> + <%= start_form_tag :controller => 'members', :action => 'edit', :id => member %>
+ <select name="member[role_id]">
+ <%= options_from_collection_for_select @roles, "id", "name", member.role_id %> + </select>
+ <%= submit_tag l(:button_change), :class => "button-small" %> + <%= end_form_tag %> + <% end %> + </td>
+ <td> + <% if authorize_for('members', 'destroy') %>
+ <%= start_form_tag :controller => 'members', :action => 'destroy', :id => member %>
+ <%= submit_tag l(:button_delete), :class => "button-small" %>
+ <%= end_form_tag %> + <% end %>
+ </td>
+ </tr>
+ <% end %>
+<% end %>
+</table> +<% if authorize_for('projects', 'add_member') %>
+ <hr />
+ <label><%=l(:label_member_new)%></label><br/>
+ <%= start_form_tag :controller => 'projects', :action => 'add_member', :id => @project %>
+ <select name="member[user_id]">
+ <%= options_from_collection_for_select @users, "id", "display_name", @member.user_id %> + </select>
+ <select name="member[role_id]">
+ <%= options_from_collection_for_select @roles, "id", "name", @member.role_id %> + </select>
+ <%= submit_tag l(:button_add) %>
+ <%= end_form_tag %> +<% end %>
+</div>
+
+<div class="box">
+<h3><%=l(:label_version_plural)%></h3>
+<table>
+<% for version in @project.versions %>
+ <tr>
+ <td width="100"><strong><%=h version.name %></strong></td>
+ <td width="100"><%= format_date(version.effective_date) %></td>
+ <td><%=h version.description %></td> + <td> + <%= link_to_if_authorized l(:button_edit), :controller => 'versions', :action => 'edit', :id => version %> + <% if authorize_for('versions', 'destroy') %> +
+ <%= start_form_tag :controller => 'versions', :action => 'destroy', :id => version %>
+ <%= submit_tag l(:button_delete), :class => "button-small" %>
+ <%= end_form_tag %> + <% end %>
+ </td>
+ </tr>
+<% end %>
+</table> +<% if authorize_for('projects', 'add_version') %>
+ <hr /> + <%= link_to l(:label_version_new), :controller => 'projects', :action => 'add_version', :id => @project %>
+<% end %>
+</div>
+
+
+<div class="box">
+<h3><%=l(:label_issue_category_plural)%></h3> +<table>
+<% for @category in @project.issue_categories %>
+ <% unless @category.new_record? %>
+ <tr>
+ <td>
+ <%= start_form_tag :controller => 'issue_categories', :action => 'edit', :id => @category %>
+ <%= text_field 'category', 'name', :size => 25 %>
+ </td>
+ <td> + <% if authorize_for('issue_categories', 'edit') %>
+ <%= submit_tag l(:button_save), :class => "button-small" %>
+ <%= end_form_tag %> + <% end %>
+ </td>
+ <td> + <% if authorize_for('issue_categories', 'destroy') %>
+ <%= start_form_tag :controller => 'issue_categories', :action => 'destroy', :id => @category %>
+ <%= submit_tag l(:button_delete), :class => "button-small" %>
+ <%= end_form_tag %> + <% end %>
+ </td>
+ </tr>
+ <% end %>
+<% end %>
+</table> +<% if authorize_for('projects', 'add_issue_category') %>
+ <hr />
+ <%= start_form_tag :action => 'add_issue_category', :id => @project %> + <label for="issue_category_name"><%=l(:label_issue_category_new)%></label><br/> + <%= error_messages_for 'issue_category' %>
+ <%= text_field 'issue_category', 'name', :size => 25 %> + <%= submit_tag l(:button_create) %>
+ <%= end_form_tag %>
+<% end %>
+</div>
diff --git a/app/views/projects/show.rhtml b/app/views/projects/show.rhtml new file mode 100644 index 000000000..79e36a586 --- /dev/null +++ b/app/views/projects/show.rhtml @@ -0,0 +1,72 @@ +<h2><%=l(:label_overview)%></h2>
+
+<div class="splitcontentleft">
+ <%= simple_format(auto_link(@project.description)) %>
+ <ul>
+ <% unless @project.homepage.empty? %><li><%=l(:field_homepage)%>: <%= auto_link @project.homepage %></li><% end %>
+ <li><%=l(:field_created_on)%>: <%= format_date(@project.created_on) %></li>
+ <% for custom_value in @custom_values %>
+ <% if !custom_value.value.empty? %>
+ <li><%= custom_value.custom_field.name%>: <%= show_value(custom_value) %></li>
+ <% end %>
+ <% end %>
+ </ul>
+
+ <div class="box">
+ <h3><%= image_tag "tracker" %> <%=l(:label_tracker_plural)%></h3>
+ <ul>
+ <% for tracker in @trackers %>
+ <li><%= link_to tracker.name, :controller => 'projects', :action => 'list_issues', :id => @project,
+ :set_filter => 1,
+ "tracker_id" => tracker.id %>:
+ <%= issue_count = Issue.count(:conditions => ["project_id=? and tracker_id=? and issue_statuses.is_closed=?", @project.id, tracker.id, false], :include => :status) %>
+ <%= lwr(:label_open_issues, issue_count) %>
+ </li>
+ <% end %>
+ </ul> + <% if authorize_for 'projects', 'add_issue' %>
+ » <%=l(:label_issue_new)%>:
+ <ul>
+ <% @trackers.each do |tracker| %>
+ <li><%= link_to tracker.name, :controller => 'projects', :action => 'add_issue', :id => @project, :tracker_id => tracker %></li>
+ <% end %>
+ </ul>
+ <% end %> + <center><small>[ <%= link_to l(:label_issue_view_all), :controller => 'projects', :action => 'list_issues', :id => @project, :set_filter => 1 %> ]</small></center>
+ </div> +</div>
+
+<div class="splitcontentright">
+ <div class="box">
+ <h3><%= image_tag "users" %> <%=l(:label_member_plural)%></h3>
+ <% for member in @members %>
+ <%= link_to_user member.user %> (<%= member.role.name %>)<br />
+ <% end %>
+ </div>
+
+ <% if @subprojects %>
+ <div class="box">
+ <h3><%= image_tag "projects" %> <%=l(:label_subproject_plural)%></h3>
+ <% for subproject in @subprojects %>
+ <%= link_to subproject.name, :action => 'show', :id => subproject %><br />
+ <% end %>
+ </div>
+ <% end %>
+
+ <div class="box">
+ <h3><%=l(:label_news_latest)%></h3>
+ <% for news in @news %>
+ <p><b><%= news.title %></b> <small>(<%= link_to_user news.author %> <%= format_time(news.created_on) %>)</small><br />
+ <%= news.summary %>
+ <small>[<%= link_to l(:label_read), :controller => 'news', :action => 'show', :id => news %>]</small></p>
+ <hr />
+ <% end %> + <center><small>[ <%= link_to l(:label_news_view_all), :controller => 'projects', :action => 'list_news', :id => @project %> ]</small></center>
+ </div>
+</div>
+
+
+
+ +
+
diff --git a/app/views/reports/_details.rhtml b/app/views/reports/_details.rhtml new file mode 100644 index 000000000..be4c82e77 --- /dev/null +++ b/app/views/reports/_details.rhtml @@ -0,0 +1,47 @@ +<% if @statuses.empty? or rows.empty? %>
+ <p><i><%=l(:label_no_data)%></i></p>
+<% else %>
+<% col_width = 70 / (@statuses.length+3) %>
+<table class="reportTableContent">
+<tr>
+<td width="25%"></td>
+<% for status in @statuses %>
+ <td align="center" width="<%= col_width %>%" bgcolor="#<%= status.html_color %>"><small><%= status.name %></small></td>
+<% end %>
+<td align="center" width="<%= col_width %>%"><strong><%=l(:label_open_issues_plural)%></strong></td>
+<td align="center" width="<%= col_width %>%"><strong><%=l(:label_closed_issues_plural)%></strong></td>
+<td align="center" width="<%= col_width %>%"><strong><%=l(:label_total)%></strong></td>
+</tr>
+
+<% for row in rows %>
+<tr class="<%= cycle("odd", "even") %>">
+ <td><%= link_to row.name, :controller => 'projects', :action => 'list_issues', :id => @project,
+ :set_filter => 1,
+ "#{field_name}" => row.id %></td>
+ <% for status in @statuses %>
+ <td align="center"><%= link_to (aggregate data, { field_name => row.id, "status_id" => status.id }),
+ :controller => 'projects', :action => 'list_issues', :id => @project,
+ :set_filter => 1,
+ "status_id" => status.id,
+ "#{field_name}" => row.id %></td>
+ <% end %>
+ <td align="center"><%= link_to (aggregate data, { field_name => row.id, "closed" => 0 }),
+ :controller => 'projects', :action => 'list_issues', :id => @project,
+ :set_filter => 1,
+ "#{field_name}" => row.id,
+ "status_id" => "O" %></td>
+ <td align="center"><%= link_to (aggregate data, { field_name => row.id, "closed" => 1 }),
+ :controller => 'projects', :action => 'list_issues', :id => @project,
+ :set_filter => 1,
+ "#{field_name}" => row.id,
+ "status_id" => "C" %></td>
+ <td align="center"><%= link_to (aggregate data, { field_name => row.id }),
+ :controller => 'projects', :action => 'list_issues', :id => @project,
+ :set_filter => 1,
+ "#{field_name}" => row.id,
+ "status_id" => "A" %></td>
+<% end %>
+</tr>
+</table>
+<% end
+ reset_cycle %>
\ No newline at end of file diff --git a/app/views/reports/_simple.rhtml b/app/views/reports/_simple.rhtml new file mode 100644 index 000000000..3be1281c5 --- /dev/null +++ b/app/views/reports/_simple.rhtml @@ -0,0 +1,36 @@ +<% if @statuses.empty? or rows.empty? %>
+ <p><i><%=l(:label_no_data)%></i></p>
+<% else %>
+<table class="reportTableContent">
+<tr>
+<td width="25%"></td>
+<td align="center" width="25%"><%=l(:label_open_issues_plural)%></td>
+<td align="center" width="25%"><%=l(:label_closed_issues_plural)%></td>
+<td align="center" width="25%"><%=l(:label_total)%></td>
+</tr>
+
+<% for row in rows %>
+<tr class="<%= cycle("odd", "even") %>">
+ <td><%= link_to row.name, :controller => 'projects', :action => 'list_issues', :id => @project,
+ :set_filter => 1,
+ "#{field_name}" => row.id %></td>
+ <td align="center"><%= link_to (aggregate data, { field_name => row.id, "closed" => 0 }),
+ :controller => 'projects', :action => 'list_issues', :id => @project,
+ :set_filter => 1,
+ "#{field_name}" => row.id,
+ "status_id" => "O" %></td>
+ <td align="center"><%= link_to (aggregate data, { field_name => row.id, "closed" => 1 }),
+ :controller => 'projects', :action => 'list_issues', :id => @project,
+ :set_filter => 1,
+ "#{field_name}" => row.id,
+ "status_id" => "C" %></td>
+ <td align="center"><%= link_to (aggregate data, { field_name => row.id }),
+ :controller => 'projects', :action => 'list_issues', :id => @project,
+ :set_filter => 1,
+ "#{field_name}" => row.id,
+ "status_id" => "A" %></td>
+<% end %>
+</tr>
+</table>
+<% end
+ reset_cycle %>
\ No newline at end of file diff --git a/app/views/reports/issue_report.rhtml b/app/views/reports/issue_report.rhtml new file mode 100644 index 000000000..4927186a9 --- /dev/null +++ b/app/views/reports/issue_report.rhtml @@ -0,0 +1,20 @@ +<h2><%=l(:label_report_plural)%></h2>
+
+<div class="splitcontentleft">
+<h3><%=l(:field_tracker)%> <%= link_to image_tag('details'), :detail => 'author' %></h3>
+<%= render :partial => 'simple', :locals => { :data => @issues_by_tracker, :field_name => "tracker_id", :rows => @trackers } %>
+<br />
+<h3><%=l(:field_priority)%> <%= link_to image_tag('details'), :detail => 'priority' %></h3>
+<%= render :partial => 'simple', :locals => { :data => @issues_by_priority, :field_name => "priority_id", :rows => @priorities } %>
+<br />
+<h3><%=l(:field_author)%> <%= link_to image_tag('details'), :detail => 'author' %></h3>
+<%= render :partial => 'simple', :locals => { :data => @issues_by_author, :field_name => "author_id", :rows => @authors } %>
+<br />
+</div>
+
+<div class="splitcontentright">
+<h3><%=l(:field_category)%> <%= link_to image_tag('details'), :detail => 'category' %></h3>
+<%= render :partial => 'simple', :locals => { :data => @issues_by_category, :field_name => "category_id", :rows => @categories } %>
+<br />
+</div>
+
diff --git a/app/views/reports/issue_report_details.rhtml b/app/views/reports/issue_report_details.rhtml new file mode 100644 index 000000000..e37d38649 --- /dev/null +++ b/app/views/reports/issue_report_details.rhtml @@ -0,0 +1,7 @@ +<h2><%=l(:label_report_plural)%></h2>
+
+<h3><%=@report_title%></h3>
+<%= render :partial => 'details', :locals => { :data => @data, :field_name => @field, :rows => @rows } %>
+<br />
+<%= link_to l(:button_back), :action => 'issue_report' %>
+
diff --git a/app/views/roles/_form.rhtml b/app/views/roles/_form.rhtml new file mode 100644 index 000000000..e0ab1c099 --- /dev/null +++ b/app/views/roles/_form.rhtml @@ -0,0 +1,20 @@ +<%= error_messages_for 'role' %> +<div class="box"> +<!--[form:role]-->
+<p><%= f.text_field :name, :required => true %></p>
+
+<strong><%=l(:label_permissions)%>:</strong>
+<% permissions = @permissions.group_by {|p| p.group_id } %>
+<% permissions.keys.sort.each do |group_id| %> +<fieldset style="margin-top: 6px;"><legend><strong><%= l(Permission::GROUPS[group_id]) %></strong></legend>
+<% permissions[group_id].each do |p| %>
+ <div style="width:170px;float:left;"><%= check_box_tag "permission_ids[]", p.id, (@role.permissions.include? p) %>
+ <%= l(p.description.to_sym) %>
+ </div>
+<% end %>
+</fieldset>
+<% end %>
+<br /> +<%= check_all_links 'role_form' %>
+<!--[eoform:role]--> +</div> diff --git a/app/views/roles/edit.rhtml b/app/views/roles/edit.rhtml new file mode 100644 index 000000000..ffe117cef --- /dev/null +++ b/app/views/roles/edit.rhtml @@ -0,0 +1,6 @@ +<h2><%=l(:label_role)%></h2> + +<% labelled_tabular_form_for :role, @role, :url => { :action => 'edit' }, :html => {:id => 'role_form'} do |f| %> +<%= render :partial => 'form', :locals => { :f => f } %> +<%= submit_tag l(:button_save) %> +<% end %>
diff --git a/app/views/roles/list.rhtml b/app/views/roles/list.rhtml new file mode 100644 index 000000000..169b3d1c0 --- /dev/null +++ b/app/views/roles/list.rhtml @@ -0,0 +1,21 @@ +<h2><%=l(:label_role_plural)%></h2> + +<table class="listTableContent"> + <tr class="ListHead"> + <th><%=l(:label_role)%></th> + <th></th> + </tr> + +<% for role in @roles %> + <tr class="<%= cycle("odd", "even") %>"> + <td><%= link_to role.name, :action => 'edit', :id => role %></td> + <td align="center"> + <%= button_to l(:button_delete), { :action => 'destroy', :id => role }, :confirm => l(:text_are_you_sure), :class => "button-small" %>
+ </tr> +<% end %> +</table> +
+<%= pagination_links_full @role_pages %> +<br /> + +<%= link_to '» ' + l(:label_role_new), :action => 'new' %> diff --git a/app/views/roles/new.rhtml b/app/views/roles/new.rhtml new file mode 100644 index 000000000..a73c36cb1 --- /dev/null +++ b/app/views/roles/new.rhtml @@ -0,0 +1,6 @@ +<h2><%=l(:label_role_new)%></h2> +
+<% labelled_tabular_form_for :role, @role, :url => { :action => 'new' }, :html => {:id => 'role_form'} do |f| %> +<%= render :partial => 'form', :locals => { :f => f } %> +<%= submit_tag l(:button_create) %> +<% end %>
\ No newline at end of file diff --git a/app/views/roles/workflow.rhtml b/app/views/roles/workflow.rhtml new file mode 100644 index 000000000..ee5b3a278 --- /dev/null +++ b/app/views/roles/workflow.rhtml @@ -0,0 +1,71 @@ +<h2><%=l(:label_workflow)%></h2>
+
+<p><%=l(:text_workflow_edit)%>:</p>
+
+<%= start_form_tag ({:action => 'workflow'}, :method => 'get') %>
+<div style="float:left;margin-right:10px;">
+<p><label for="role_id"><%=l(:label_role)%></label><br/>
+<select id="role_id" name="role_id">
+ <%= options_from_collection_for_select @roles, "id", "name", (@role.id unless @role.nil?) %>
+</select></p>
+</div>
+
+<div>
+<p><label for="tracker_id"><%=l(:label_tracker)%></label><br/>
+<select id="tracker_id" name="tracker_id">
+ <%= options_from_collection_for_select @trackers, "id", "name", (@tracker.id unless @tracker.nil?) %>
+</select>
+
+<%= submit_tag l(:button_edit) %>
+</p>
+</div>
+<%= end_form_tag %>
+
+
+
+<% unless @tracker.nil? or @role.nil? %>
+<div class="box">
+ <%= form_tag ({:action => 'workflow', :role_id => @role, :tracker_id => @tracker }, :id => 'workflow_form' ) %>
+ <table>
+ <tr>
+ <td align="center" colspan="2"><strong><%=l(:label_current_status)%></strong></td>
+ <td align="center" colspan="<%= @statuses.length %>"><strong><%=l(:label_new_statuses_allowed)%></strong></td>
+ </tr>
+ <tr>
+ <td colspan="2"></td>
+ <% for new_status in @statuses %>
+ <td width="80" align="center"><%= new_status.name %></td>
+ <% end %>
+ </tr>
+
+ <% for old_status in @statuses %>
+ <tr>
+ <td width="20" align="center"><div style="background-color:#<%= old_status.html_color %>"> </div></td>
+ <td><%= old_status.name %></td>
+
+ <% for new_status in @statuses %>
+ <td align="center">
+
+ <input type="checkbox"
+ name="issue_status[<%= old_status.id %>][]"
+ value="<%= new_status.id %>"
+ <%if old_status.new_statuses_allowed_to(@role, @tracker).include? new_status%>checked="checked"<%end%>
+ <%if old_status==new_status%>disabled<%end%>
+ >
+ </td>
+ <% end %>
+
+ </tr>
+ <% end %>
+ </table>
+<br />
+<p>
+<a href="javascript:checkAll('workflow_form', true)"><%=l(:button_check_all)%></a> |
+<a href="javascript:checkAll('workflow_form', false)"><%=l(:button_uncheck_all)%></a>
+</p>
+<br />
+<%= submit_tag l(:button_save) %> +<%= end_form_tag %>
+
+<% end %>
+</div>
\ No newline at end of file diff --git a/app/views/trackers/_form.rhtml b/app/views/trackers/_form.rhtml new file mode 100644 index 000000000..625c0d636 --- /dev/null +++ b/app/views/trackers/_form.rhtml @@ -0,0 +1,7 @@ +<%= error_messages_for 'tracker' %> +<div class="box"> +<!--[form:tracker]--> +<p><%= f.text_field :name, :required => true %></p>
+<p><%= f.check_box :is_in_chlog %></p>
+<!--[eoform:tracker]--> +</div> diff --git a/app/views/trackers/edit.rhtml b/app/views/trackers/edit.rhtml new file mode 100644 index 000000000..d8411099c --- /dev/null +++ b/app/views/trackers/edit.rhtml @@ -0,0 +1,6 @@ +<h2><%=l(:label_tracker)%></h2> + +<% labelled_tabular_form_for :tracker, @tracker, :url => { :action => 'edit' } do |f| %> +<%= render :partial => 'form', :locals => { :f => f } %> +<%= submit_tag l(:button_save) %> +<% end %>
\ No newline at end of file diff --git a/app/views/trackers/list.rhtml b/app/views/trackers/list.rhtml new file mode 100644 index 000000000..8d4a5c595 --- /dev/null +++ b/app/views/trackers/list.rhtml @@ -0,0 +1,22 @@ +<h2><%=l(:label_tracker_plural)%></h2> + +<table class="listTableContent"> + <tr class="ListHead"> + <th><%=l(:label_tracker)%></th>
+ <th></th> + </tr> + +<% for tracker in @trackers %> + <tr class="<%= cycle("odd", "even") %>"> + <td><%= link_to tracker.name, :action => 'edit', :id => tracker %></td> + <td align="center"> + <%= button_to l(:button_delete), { :action => 'destroy', :id => tracker }, :confirm => l(:text_are_you_sure), :class => "button-small" %>
+ </td> + </tr> +<% end %> +</table> +
+<%= pagination_links_full @tracker_pages %> +<br /> + +<%= link_to '» ' + l(:label_tracker_new), :action => 'new' %> diff --git a/app/views/trackers/new.rhtml b/app/views/trackers/new.rhtml new file mode 100644 index 000000000..b318a5dc4 --- /dev/null +++ b/app/views/trackers/new.rhtml @@ -0,0 +1,6 @@ +<h2><%=l(:label_tracker_new)%></h2> + +<% labelled_tabular_form_for :tracker, @tracker, :url => { :action => 'new' } do |f| %> +<%= render :partial => 'form', :locals => { :f => f } %> +<%= submit_tag l(:button_create) %> +<% end %>
\ No newline at end of file diff --git a/app/views/users/_form.rhtml b/app/views/users/_form.rhtml new file mode 100644 index 000000000..089d4d23c --- /dev/null +++ b/app/views/users/_form.rhtml @@ -0,0 +1,30 @@ +<%= error_messages_for 'user' %> + +<!--[form:user]--> +<div class="box"> +<h3><%=l(:label_information_plural)%></h3> +<p><%= f.text_field :login, :required => true, :size => 25 %></p> +<p><%= f.text_field :firstname, :required => true %></p>
+<p><%= f.text_field :lastname, :required => true %></p> +<p><%= f.text_field :mail, :required => true %></p>
+<p><%= f.select :language, lang_options_for_select %></p>
+
+<% for @custom_value in @custom_values %> + <p><%= custom_field_tag_with_label @custom_value %></p> +<% end %>
+
+<p><%= f.check_box :admin %></p>
+<p><%= f.check_box :mail_notification %></p>
+</div> + +<div class="box"> +<h3><%=l(:label_authentication)%></h3> +<% unless @auth_sources.empty? %> +<p><%= f.select :auth_source_id, [[l(:label_internal), ""]] + @auth_sources.collect { |a| [a.name, a.id] } %></p> +<% end %> +<p><label for="password"><%=l(:field_password)%><span class="required"> *</span></label> +<%= password_field_tag 'password', nil, :size => 25 %></p> +<p><label for="password_confirmation"><%=l(:field_password_confirmation)%><span class="required"> *</span></label> +<%= password_field_tag 'password_confirmation', nil, :size => 25 %></p> +</div> +<!--[eoform:user]--> diff --git a/app/views/users/add.rhtml b/app/views/users/add.rhtml new file mode 100644 index 000000000..d4c6a15f4 --- /dev/null +++ b/app/views/users/add.rhtml @@ -0,0 +1,6 @@ +<h2><%=l(:label_user_new)%></h2> + +<% labelled_tabular_form_for :user, @user, :url => { :action => "add" } do |f| %> +<%= render :partial => 'form', :locals => { :f => f } %> +<%= submit_tag l(:button_create) %> +<% end %>
\ No newline at end of file diff --git a/app/views/users/edit.rhtml b/app/views/users/edit.rhtml new file mode 100644 index 000000000..2332b70ad --- /dev/null +++ b/app/views/users/edit.rhtml @@ -0,0 +1,6 @@ +<h2><%=l(:label_user)%></h2> + +<% labelled_tabular_form_for :user, @user, :url => { :action => "edit" } do |f| %> +<%= render :partial => 'form', :locals => { :f => f } %> +<%= submit_tag l(:button_save) %> +<% end %> diff --git a/app/views/users/list.rhtml b/app/views/users/list.rhtml new file mode 100644 index 000000000..9f4438138 --- /dev/null +++ b/app/views/users/list.rhtml @@ -0,0 +1,46 @@ +<h2><%=l(:label_user_plural)%></h2> +
+<table class="listTableContent">
+<tr class="ListHead"> + <%= sort_header_tag('login', :caption => l(:field_login)) %>
+ <%= sort_header_tag('firstname', :caption => l(:field_firstname)) %>
+ <%= sort_header_tag('lastname', :caption => l(:field_lastname)) %>
+ <th><%=l(:field_mail)%></th>
+ <%= sort_header_tag('admin', :caption => l(:field_admin)) %>
+ <%= sort_header_tag('status', :caption => l(:field_status)) %>
+ <%= sort_header_tag('created_on', :caption => l(:field_created_on)) %>
+ <%= sort_header_tag('last_login_on', :caption => l(:field_last_login_on)) %>
+ <th></th>
+</tr> +<% for user in @users %> + <tr class="<%= cycle("odd", "even") %>">
+ <td><%= link_to user.login, :action => 'edit', :id => user %></td>
+ <td><%= user.firstname %></td>
+ <td><%= user.lastname %></td>
+ <td><%= user.mail %></td>
+ <td align="center"><%= image_tag 'true' if user.admin? %></td>
+ <td align="center"><%= image_tag 'locked' if user.locked? %><%= image_tag 'user_new' if user.registered? %></td>
+ <td align="center"><%= format_time(user.created_on) %></td>
+ <td align="center"><%= format_time(user.last_login_on) unless user.last_login_on.nil? %></td>
+ <td align="center">
+ <%= start_form_tag :action => 'edit', :id => user %>
+ <% if user.locked? %>
+ <%= hidden_field_tag 'user[status]', User::STATUS_ACTIVE %>
+ <%= submit_tag l(:button_unlock), :class => "button-small" %>
+ <% else %>
+ <%= hidden_field_tag 'user[status]', User::STATUS_LOCKED %>
+ <%= submit_tag l(:button_lock), :class => "button-small" %>
+ <% end %>
+ <%= end_form_tag %>
+ </td> + </tr> +<% end %> +</table> +
+<p><%= pagination_links_full @user_pages %>
+[ <%= @user_pages.current.first_item %> - <%= @user_pages.current.last_item %> / <%= @user_count %> ]
+</p>
+ +<p> +<%= link_to '» ' + l(:label_user_new), :action => 'add' %> +</p>
\ No newline at end of file diff --git a/app/views/versions/_form.rhtml b/app/views/versions/_form.rhtml new file mode 100644 index 000000000..3d0eb0a2d --- /dev/null +++ b/app/views/versions/_form.rhtml @@ -0,0 +1,9 @@ +<%= error_messages_for 'version' %> + +<div class="box"> +<!--[form:version]--> +<p><%= f.text_field :name, :size => 20, :required => true %></p> +<p><%= f.text_field :description, :size => 60 %></p> +<p><%= f.text_field :effective_date, :size => 10, :required => true %><%= calendar_for('version_effective_date') %></p> +<!--[eoform:version]--> +</div>
\ No newline at end of file diff --git a/app/views/versions/edit.rhtml b/app/views/versions/edit.rhtml new file mode 100644 index 000000000..1556ebba1 --- /dev/null +++ b/app/views/versions/edit.rhtml @@ -0,0 +1,7 @@ +<h2><%=l(:label_version)%></h2> + +<% labelled_tabular_form_for :version, @version, :url => { :action => 'edit' } do |f| %> +<%= render :partial => 'form', :locals => { :f => f } %> +<%= submit_tag l(:button_save) %> +<% end %> + diff --git a/app/views/welcome/index.rhtml b/app/views/welcome/index.rhtml new file mode 100644 index 000000000..abee85691 --- /dev/null +++ b/app/views/welcome/index.rhtml @@ -0,0 +1,30 @@ +<h2><%= $RDM_WELCOME_TITLE || l(:label_home) %></h2>
+
+<div class="splitcontentleft">
+ <% if $RDM_WELCOME_TEXT %><p><%= $RDM_WELCOME_TEXT %></p><br /><% end %>
+ <div class="box">
+ <h3><%=l(:label_news_latest)%></h3> + <% for news in @news %>
+ <p>
+ <b><%= news.title %></b> (<%= link_to_user news.author %> <%= format_time(news.created_on) %> - <%= news.project.name %>)<br />
+ <% unless news.summary.empty? %><%= news.summary %><br /><% end %>
+ [<%= link_to l(:label_read), :controller => 'news', :action => 'show', :id => news %>]
+ </p>
+ <hr />
+ <% end %>
+ </div>
+</div>
+
+<div class="splitcontentright">
+ <div class="box">
+ <h3><%=l(:label_project_latest)%></h3>
+ <ul> + <% for project in @projects %>
+ <li>
+ <%= link_to project.name, :controller => 'projects', :action => 'show', :id => project %> (<%= format_time(project.created_on) %>)<br />
+ <%= project.description %>
+ </li>
+ <% end %>
+ </ul>
+ </div>
+</div>
|