From 027bf93849e82ef3c60e4a3024db49d65f0fb3c9 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 12 Mar 2007 17:59:02 +0000 Subject: [PATCH] added svn:eol-style native property on /app files git-svn-id: http://redmine.rubyforge.org/svn/trunk@333 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/account_controller.rb | 260 ++-- app/controllers/admin_controller.rb | 110 +- app/controllers/application.rb | 262 ++-- app/controllers/custom_fields_controller.rb | 118 +- app/controllers/documents_controller.rb | 110 +- app/controllers/enumerations_controller.rb | 48 +- app/controllers/help_controller.rb | 90 +- .../issue_categories_controller.rb | 62 +- app/controllers/issue_statuses_controller.rb | 84 +- app/controllers/issues_controller.rb | 270 ++-- app/controllers/members_controller.rb | 62 +- app/controllers/news_controller.rb | 88 +- app/controllers/projects_controller.rb | 1188 ++++++++--------- app/controllers/reports_controller.rb | 330 ++--- app/controllers/roles_controller.rb | 136 +- app/controllers/trackers_controller.rb | 82 +- app/controllers/users_controller.rb | 168 +-- app/controllers/versions_controller.rb | 94 +- app/controllers/welcome_controller.rb | 46 +- app/helpers/account_helper.rb | 34 +- app/helpers/admin_helper.rb | 34 +- app/helpers/application_helper.rb | 456 +++---- app/helpers/custom_fields_helper.rb | 150 +-- app/helpers/documents_helper.rb | 34 +- app/helpers/enumerations_helper.rb | 34 +- app/helpers/help_helper.rb | 34 +- app/helpers/ifpdf_helper.rb | 138 +- app/helpers/issue_categories_helper.rb | 34 +- app/helpers/issue_statuses_helper.rb | 34 +- app/helpers/issues_helper.rb | 144 +- app/helpers/members_helper.rb | 34 +- app/helpers/news_helper.rb | 34 +- app/helpers/projects_helper.rb | 54 +- app/helpers/reports_helper.rb | 60 +- app/helpers/roles_helper.rb | 34 +- app/helpers/trackers_helper.rb | 34 +- app/helpers/users_helper.rb | 34 +- app/helpers/versions_helper.rb | 34 +- app/helpers/welcome_helper.rb | 34 +- app/models/attachment.rb | 180 +-- app/models/auth_source_ldap.rb | 154 +-- app/models/custom_field.rb | 118 +- app/models/custom_value.rb | 74 +- app/models/document.rb | 44 +- app/models/enumeration.rb | 90 +- app/models/issue.rb | 202 +-- app/models/issue_category.rb | 54 +- app/models/issue_custom_field.rb | 52 +- app/models/issue_history.rb | 44 +- app/models/issue_status.rb | 98 +- app/models/mailer.rb | 158 +-- app/models/member.rb | 54 +- app/models/news.rb | 54 +- app/models/permission.rb | 126 +- app/models/project.rb | 138 +- app/models/project_custom_field.rb | 44 +- app/models/role.rb | 62 +- app/models/svn_repos.rb | 430 +++--- app/models/tracker.rb | 62 +- app/models/user.rb | 280 ++-- app/models/user_custom_field.rb | 44 +- app/models/version.rb | 62 +- app/models/workflow.rb | 46 +- app/views/account/login.rhtml | 42 +- app/views/account/lost_password.rhtml | 26 +- app/views/account/password_recovery.rhtml | 18 +- app/views/account/register.rhtml | 18 +- app/views/account/show.rhtml | 50 +- app/views/admin/index.rhtml | 88 +- app/views/admin/info.rhtml | 4 +- app/views/admin/mail_options.rhtml | 50 +- app/views/admin/projects.rhtml | 22 +- app/views/common/404.rhtml | 8 +- app/views/custom_fields/_form.rhtml | 16 +- app/views/custom_fields/list.rhtml | 24 +- app/views/documents/_document.rhtml | 4 +- app/views/documents/_form.rhtml | 8 +- app/views/documents/show.rhtml | 66 +- app/views/enumerations/list.rhtml | 32 +- app/views/issue_statuses/_form.rhtml | 10 +- app/views/issue_statuses/list.rhtml | 16 +- app/views/issues/_add_shortcut.rhtml | 10 +- app/views/issues/_history.rhtml | 22 +- app/views/issues/_list_simple.rhtml | 38 +- app/views/issues/_tooltip.rhtml | 12 +- app/views/issues/change_status.rhtml | 36 +- app/views/issues/history.rhtml | 10 +- app/views/issues/show.rhtml | 216 +-- app/views/layouts/base.rhtml | 296 ++-- app/views/mailer/_issue.rhtml | 10 +- app/views/mailer/attachments_add_de.rhtml | 10 +- app/views/mailer/attachments_add_en.rhtml | 10 +- app/views/mailer/attachments_add_es.rhtml | 10 +- app/views/mailer/attachments_add_fr.rhtml | 10 +- app/views/mailer/attachments_add_ja.rhtml | 10 +- app/views/mailer/document_add_de.rhtml | 6 +- app/views/mailer/document_add_en.rhtml | 6 +- app/views/mailer/document_add_es.rhtml | 6 +- app/views/mailer/document_add_fr.rhtml | 6 +- app/views/mailer/document_add_ja.rhtml | 6 +- app/views/mailer/issue_add_de.rhtml | 4 +- app/views/mailer/issue_add_en.rhtml | 4 +- app/views/mailer/issue_add_es.rhtml | 4 +- app/views/mailer/issue_add_fr.rhtml | 4 +- app/views/mailer/issue_add_ja.rhtml | 4 +- app/views/mailer/issue_edit_de.rhtml | 14 +- app/views/mailer/issue_edit_en.rhtml | 14 +- app/views/mailer/issue_edit_es.rhtml | 14 +- app/views/mailer/issue_edit_fr.rhtml | 14 +- app/views/mailer/issue_edit_ja.rhtml | 14 +- app/views/mailer/lost_password_de.rhtml | 4 +- app/views/mailer/lost_password_en.rhtml | 4 +- app/views/mailer/lost_password_es.rhtml | 4 +- app/views/mailer/lost_password_fr.rhtml | 4 +- app/views/mailer/lost_password_ja.rhtml | 4 +- app/views/mailer/register_de.rhtml | 4 +- app/views/mailer/register_en.rhtml | 4 +- app/views/mailer/register_es.rhtml | 4 +- app/views/mailer/register_fr.rhtml | 4 +- app/views/mailer/register_ja.rhtml | 4 +- app/views/my/_block.rhtml | 30 +- app/views/my/account.rhtml | 36 +- app/views/my/blocks/_calendar.rhtml | 92 +- app/views/my/blocks/_documents.rhtml | 14 +- app/views/my/blocks/_issuesassignedtome.rhtml | 20 +- app/views/my/blocks/_issuesreportedbyme.rhtml | 18 +- app/views/my/blocks/_news.rhtml | 14 +- app/views/my/page.rhtml | 66 +- app/views/my/page_layout.rhtml | 232 ++-- app/views/news/_news.rhtml | 8 +- app/views/news/show.rhtml | 62 +- app/views/projects/_form.rhtml | 10 +- app/views/projects/activity.rhtml | 116 +- app/views/projects/add_document.rhtml | 10 +- app/views/projects/add_file.rhtml | 28 +- app/views/projects/add_issue.rhtml | 16 +- app/views/projects/add_query.rhtml | 10 +- app/views/projects/calendar.rhtml | 146 +- app/views/projects/changelog.rhtml | 58 +- app/views/projects/destroy.rhtml | 26 +- app/views/projects/gantt.rhtml | 428 +++--- app/views/projects/list.rhtml | 16 +- app/views/projects/list_documents.rhtml | 24 +- app/views/projects/list_files.rhtml | 78 +- app/views/projects/list_issues.rhtml | 154 +-- app/views/projects/list_members.rhtml | 26 +- app/views/projects/list_news.rhtml | 2 +- app/views/projects/roadmap.rhtml | 54 +- app/views/projects/search.rhtml | 84 +- app/views/projects/settings.rhtml | 116 +- app/views/projects/show.rhtml | 104 +- app/views/queries/_filters.rhtml | 198 +-- app/views/reports/_details.rhtml | 94 +- app/views/reports/_simple.rhtml | 72 +- app/views/reports/issue_report.rhtml | 64 +- app/views/reports/issue_report_details.rhtml | 14 +- app/views/repositories/_dir_list.rhtml | 44 +- app/views/repositories/_navigation.rhtml | 34 +- app/views/repositories/browse.rhtml | 26 +- app/views/repositories/diff.rhtml | 134 +- app/views/repositories/revision.rhtml | 74 +- app/views/repositories/revisions.rhtml | 80 +- app/views/roles/_form.rhtml | 28 +- app/views/roles/edit.rhtml | 2 +- app/views/roles/list.rhtml | 4 +- app/views/roles/new.rhtml | 2 +- app/views/roles/workflow.rhtml | 134 +- app/views/trackers/_form.rhtml | 4 +- app/views/trackers/list.rhtml | 6 +- app/views/users/_form.rhtml | 16 +- app/views/users/_memberships.rhtml | 56 +- app/views/users/list.rhtml | 66 +- app/views/welcome/index.rhtml | 48 +- app/views/wiki/_preview.rhtml | 6 +- app/views/wiki/edit.rhtml | 86 +- app/views/wiki/export.rhtml | 28 +- app/views/wiki/export_multiple.rhtml | 52 +- app/views/wiki/history.rhtml | 54 +- app/views/wiki/show.rhtml | 58 +- app/views/wiki/special_page_index.rhtml | 24 +- 180 files changed, 6362 insertions(+), 6362 deletions(-) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index e561e151..61c71557 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -1,131 +1,131 @@ -# redMine - project management software -# Copyright (C) 2006-2007 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, :only => :logout - - # Show user's account - def show - @user = User.find(params[:id]) - @custom_values = @user.custom_values.find(:all, :include => :custom_field) - rescue ActiveRecord::RecordNotFound - render_404 - 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 => 'welcome' - end - - # Enable user to choose a new password - def lost_password - redirect_to :controller => 'welcome' and return unless Setting.lost_password? - if params[:token] - @token = Token.find_by_action_and_value("recovery", params[:token]) - redirect_to :controller => 'welcome' 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 - 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 => 'welcome' and return unless Setting.self_registration? - if params[:token] - token = Token.find_by_action_and_value("register", params[:token]) - redirect_to :controller => 'welcome' and return unless token and !token.expired? - user = token.user - redirect_to :controller => 'welcome' 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 => Setting.default_language) - @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.deliver_register(token) - flash[:notice] = l(:notice_account_register_done) - redirect_to :controller => 'welcome' and return - end - end - end - end +# redMine - project management software +# Copyright (C) 2006-2007 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, :only => :logout + + # Show user's account + def show + @user = User.find(params[:id]) + @custom_values = @user.custom_values.find(:all, :include => :custom_field) + rescue ActiveRecord::RecordNotFound + render_404 + 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 => 'welcome' + end + + # Enable user to choose a new password + def lost_password + redirect_to :controller => 'welcome' and return unless Setting.lost_password? + if params[:token] + @token = Token.find_by_action_and_value("recovery", params[:token]) + redirect_to :controller => 'welcome' 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 + 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 => 'welcome' and return unless Setting.self_registration? + if params[:token] + token = Token.find_by_action_and_value("register", params[:token]) + redirect_to :controller => 'welcome' and return unless token and !token.expired? + user = token.user + redirect_to :controller => 'welcome' 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 => Setting.default_language) + @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.deliver_register(token) + flash[:notice] = l(:notice_account_register_done) + redirect_to :controller => 'welcome' and return + end + end + end + end end diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index d5574c1b..a9ad09ed 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -1,56 +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 - @db_adapter_name = ActiveRecord::Base.connection.adapter_name - end +# 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 + @db_adapter_name = ActiveRecord::Base.connection.adapter_name + end end diff --git a/app/controllers/application.rb b/app/controllers/application.rb index c0b24902..36287ff1 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -1,109 +1,109 @@ -# redMine - project management software -# Copyright (C) 2006-2007 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 - filter_parameter_logging :password - - 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]) - else - nil - end - end - - def logged_in_user_membership - @user_membership ||= Member.find(:first, :conditions => ["user_id=? and project_id=?", self.logged_in_user.id, @project.id]) - end - - # check if login is globally required to access the application - def check_if_login_required - require_login if Setting.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 || Setting.default_language - 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(ctrl = params[:controller], action = params[:action]) - # check if action is allowed on public projects - if @project.is_public? and Permission.allowed_to_public "%s/%s" % [ ctrl, 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" % [ ctrl, action ], @user_membership.role_id ) - return true - end - render :nothing => true, :status => 403 - false - end - - # make sure that the user is a member of the project (or admin) if project is private - # used as a before_filter for actions that do not require any particular permission on the project - def check_project_privacy - return true if @project.is_public? - return false unless logged_in_user - return true if logged_in_user.admin? || logged_in_user_membership - render :nothing => true, :status => 403 - false - end - +# redMine - project management software +# Copyright (C) 2006-2007 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 + filter_parameter_logging :password + + 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]) + else + nil + end + end + + def logged_in_user_membership + @user_membership ||= Member.find(:first, :conditions => ["user_id=? and project_id=?", self.logged_in_user.id, @project.id]) + end + + # check if login is globally required to access the application + def check_if_login_required + require_login if Setting.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 || Setting.default_language + 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(ctrl = params[:controller], action = params[:action]) + # check if action is allowed on public projects + if @project.is_public? and Permission.allowed_to_public "%s/%s" % [ ctrl, 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" % [ ctrl, action ], @user_membership.role_id ) + return true + end + render :nothing => true, :status => 403 + false + end + + # make sure that the user is a member of the project (or admin) if project is private + # used as a before_filter for actions that do not require any particular permission on the project + def check_project_privacy + return true if @project.is_public? + return false unless logged_in_user + return true if logged_in_user.admin? || logged_in_user_membership + 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 @@ -118,30 +118,30 @@ class ApplicationController < ActionController::Base redirect_to session[:return_to_params] session[:return_to_params] = nil end - end - - def render_404 - @html_title = "404" - render :template => "common/404", :layout => true, :status => 404 - return false 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 + + def render_404 + @html_title = "404" + render :template => "common/404", :layout => true, :status => 404 + return false + 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/custom_fields_controller.rb b/app/controllers/custom_fields_controller.rb index 7d882964..ddeff718 100644 --- a/app/controllers/custom_fields_controller.rb +++ b/app/controllers/custom_fields_controller.rb @@ -1,23 +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 CustomFieldsController < ApplicationController - layout 'base' - before_filter :require_admin +# 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 @@ -25,48 +25,48 @@ class CustomFieldsController < ApplicationController end def list - @custom_fields_by_type = CustomField.find(:all).group_by {|f| f.type.to_s } - @tab = params[:tab] || 'IssueCustomField' + @custom_fields_by_type = CustomField.find(:all).group_by {|f| f.type.to_s } + @tab = params[:tab] || 'IssueCustomField' 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', :tab => @custom_field.type - end - @trackers = Tracker.find(:all, :order => 'position') - 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', :tab => @custom_field.type - end - @trackers = Tracker.find(:all, :order => 'position') - 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', :tab => @custom_field.type + end + @trackers = Tracker.find(:all, :order => 'position') + 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', :tab => @custom_field.type + end + @trackers = Tracker.find(:all, :order => 'position') + end def destroy - @custom_field = CustomField.find(params[:id]).destroy - redirect_to :action => 'list', :tab => @custom_field.type - rescue - flash[:notice] = "Unable to delete custom field" + @custom_field = CustomField.find(params[:id]).destroy + redirect_to :action => 'list', :tab => @custom_field.type + rescue + flash[:notice] = "Unable to delete custom field" redirect_to :action => 'list' - end + end end diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index fe0f2d34..3c7e56b4 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -1,71 +1,71 @@ -# redMine - project management software -# Copyright (C) 2006-2007 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 +# redMine - project management software +# Copyright (C) 2006-2007 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. - def show +class DocumentsController < ApplicationController + layout 'base' + before_filter :find_project, :authorize + + def show @attachments = @document.attachments.find(:all, :order => "created_on DESC") end - def edit + 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 + 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 - render_404 - end - - def add_attachment - # Save the attachments - @attachments = [] - params[:attachments].each { |file| - next unless file.size > 0 - a = Attachment.create(:container => @document, :file => file, :author => logged_in_user) - @attachments << a unless a.new_record? - } if params[:attachments] and params[:attachments].is_a? Array - Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? - 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 - rescue ActiveRecord::RecordNotFound - render_404 + + def download + @attachment = @document.attachments.find(params[:attachment_id]) + @attachment.increment_download + send_file @attachment.diskfile, :filename => @attachment.filename + rescue + render_404 + end + + def add_attachment + # Save the attachments + @attachments = [] + params[:attachments].each { |file| + next unless file.size > 0 + a = Attachment.create(:container => @document, :file => file, :author => logged_in_user) + @attachments << a unless a.new_record? + } if params[:attachments] and params[:attachments].is_a? Array + Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? + 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 + rescue ActiveRecord::RecordNotFound + render_404 end end diff --git a/app/controllers/enumerations_controller.rb b/app/controllers/enumerations_controller.rb index 8e5be0a2..16e41977 100644 --- a/app/controllers/enumerations_controller.rb +++ b/app/controllers/enumerations_controller.rb @@ -1,23 +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 EnumerationsController < ApplicationController - layout 'base' - before_filter :require_admin +# 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 @@ -60,11 +60,11 @@ class EnumerationsController < ApplicationController end def destroy - Enumeration.find(params[:id]).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' + 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 index 9a81eed2..50505a3d 100644 --- a/app/controllers/help_controller.rb +++ b/app/controllers/help_controller.rb @@ -1,47 +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}/index.html" - end - end - -private - def load_help_config - @help_config = YAML::load(File.open("#{RAILS_ROOT}/config/help.yml")) +# 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}/index.html" + 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 index a718b2c1..9a0f4027 100644 --- a/app/controllers/issue_categories_controller.rb +++ b/app/controllers/issue_categories_controller.rb @@ -1,24 +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. - +# 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 - + layout 'base' + before_filter :find_project, :authorize + def edit if request.post? and @category.update_attributes(params[:category]) flash[:notice] = l(:notice_successful_update) @@ -28,17 +28,17 @@ class IssueCategoriesController < ApplicationController def destroy @category.destroy - redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project - rescue + redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project + rescue flash[:notice] = "Categorie can't be deleted" - redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project - end + redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project + end -private - def find_project - @category = IssueCategory.find(params[:id]) - @project = @category.project - rescue ActiveRecord::RecordNotFound - render_404 - end +private + def find_project + @category = IssueCategory.find(params[:id]) + @project = @category.project + rescue ActiveRecord::RecordNotFound + render_404 + end end diff --git a/app/controllers/issue_statuses_controller.rb b/app/controllers/issue_statuses_controller.rb index 9180533c..70d35244 100644 --- a/app/controllers/issue_statuses_controller.rb +++ b/app/controllers/issue_statuses_controller.rb @@ -1,34 +1,34 @@ -# 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 +# 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 - - verify :method => :post, :only => [ :destroy, :create, :update, :move ], - :redirect_to => { :action => :list } - + before_filter :require_admin + + verify :method => :post, :only => [ :destroy, :create, :update, :move ], + :redirect_to => { :action => :list } + def index list render :action => 'list' unless request.xhr? end def list - @issue_status_pages, @issue_statuses = paginate :issue_statuses, :per_page => 25, :order => "position" + @issue_status_pages, @issue_statuses = paginate :issue_statuses, :per_page => 25, :order => "position" render :action => "list", :layout => false if request.xhr? end @@ -58,28 +58,28 @@ class IssueStatusesController < ApplicationController else render :action => 'edit' end - end - - def move - @issue_status = IssueStatus.find(params[:id]) - case params[:position] - when 'highest' - @issue_status.move_to_top - when 'higher' - @issue_status.move_higher - when 'lower' - @issue_status.move_lower - when 'lowest' - @issue_status.move_to_bottom - end if params[:position] - redirect_to :action => 'list' + end + + def move + @issue_status = IssueStatus.find(params[:id]) + case params[:position] + when 'highest' + @issue_status.move_to_top + when 'higher' + @issue_status.move_higher + when 'lower' + @issue_status.move_lower + when 'lowest' + @issue_status.move_to_bottom + end if params[:position] + redirect_to :action => 'list' end def destroy IssueStatus.find(params[:id]).destroy - redirect_to :action => 'list' - rescue - flash[:notice] = "Unable to delete issue status" + 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 index 491062e2..8c78692d 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -1,149 +1,149 @@ -# redMine - project management software -# Copyright (C) 2006-2007 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 +# redMine - project management software +# Copyright (C) 2006-2007 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, :order => 'position', :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" + @status_options = @issue.status.workflows.find(:all, :order => 'position', :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] + 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) + 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 + 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, :order => 'position', :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 - @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 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, :order => 'position', :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 + @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 - @attachments = [] - params[:attachments].each { |file| - next unless file.size > 0 - a = Attachment.create(:container => @issue, :file => file, :author => logged_in_user) - @attachments << a unless a.new_record? - } if params[:attachments] and params[:attachments].is_a? Array - Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? - 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 - render_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}" - rescue ActiveRecord::RecordNotFound - render_404 + end + + def add_attachment + # Save the attachments + @attachments = [] + params[:attachments].each { |file| + next unless file.size > 0 + a = Attachment.create(:container => @issue, :file => file, :author => logged_in_user) + @attachments << a unless a.new_record? + } if params[:attachments] and params[:attachments].is_a? Array + Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? + 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 + render_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}" + rescue ActiveRecord::RecordNotFound + render_404 end end diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 884454ac..ad9e44ff 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -1,42 +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. - +# 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 + layout 'base' + before_filter :find_project, :authorize def edit - if request.post? and @member.update_attributes(params[:member]) + if request.post? and @member.update_attributes(params[:member]) flash[:notice] = l(:notice_successful_update) - redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project + redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project end end - + def destroy - @member.destroy + @member.destroy flash[:notice] = l(:notice_successful_delete) redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project - end - -private - def find_project - @member = Member.find(params[:id]) - @project = @member.project - rescue ActiveRecord::RecordNotFound - render_404 + end + +private + def find_project + @member = Member.find(params[:id]) + @project = @member.project + rescue ActiveRecord::RecordNotFound + render_404 end end diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 2afd2050..6b143dde 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -1,23 +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 NewsController < ApplicationController - layout 'base' - before_filter :find_project, :authorize +# 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 @@ -27,34 +27,34 @@ class NewsController < ApplicationController flash[:notice] = l(:notice_successful_update) redirect_to :action => 'show', :id => @news end - end - - def add_comment - @comment = Comment.new(params[:comment]) - @comment.author = logged_in_user - if @news.comments << @comment - flash[:notice] = l(:label_comment_added) - redirect_to :action => 'show', :id => @news - else - render :action => 'show' - end end - - def destroy_comment - @news.comments.find(params[:comment_id]).destroy - redirect_to :action => 'show', :id => @news - end + + def add_comment + @comment = Comment.new(params[:comment]) + @comment.author = logged_in_user + if @news.comments << @comment + flash[:notice] = l(:label_comment_added) + redirect_to :action => 'show', :id => @news + else + render :action => 'show' + end + end + + def destroy_comment + @news.comments.find(params[:comment_id]).destroy + redirect_to :action => 'show', :id => @news + 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 - rescue ActiveRecord::RecordNotFound - render_404 + end + +private + def find_project + @news = News.find(params[:id]) + @project = @news.project + rescue ActiveRecord::RecordNotFound + render_404 end end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 51ca6648..70a07c85 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -1,614 +1,614 @@ -# redMine - project management software -# Copyright (C) 2006-2007 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 'csv' - -class ProjectsController < ApplicationController - layout 'base' - before_filter :find_project, :authorize, :except => [ :index, :list, :add ] - before_filter :require_admin, :only => [ :add, :destroy ] - - helper :sort - include SortHelper - helper :custom_fields - include CustomFieldsHelper - helper :ifpdf - include IfpdfHelper - helper IssuesHelper - helper :queries - include QueriesHelper - +# redMine - project management software +# Copyright (C) 2006-2007 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 'csv' + +class ProjectsController < ApplicationController + layout 'base' + before_filter :find_project, :authorize, :except => [ :index, :list, :add ] + before_filter :require_admin, :only => [ :add, :destroy ] + + helper :sort + include SortHelper + helper :custom_fields + include CustomFieldsHelper + helper :ifpdf + include IfpdfHelper + helper IssuesHelper + helper :queries + include QueriesHelper + 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(:all, :conditions => ["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 - + def list + sort_init 'name', 'asc' + sort_update + @project_count = Project.count(:all, :conditions => ["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 - + 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 params[:repository_enabled] && params[:repository_enabled] == "1" - @project.repository = Repository.new - @project.repository.attributes = params[:repository] - end - if "1" == params[:wiki_enabled] - @project.wiki = Wiki.new - @project.wiki.attributes = params[:wiki] - end + 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 params[:repository_enabled] && params[:repository_enabled] == "1" + @project.repository = Repository.new + @project.repository.attributes = params[:repository] + end + if "1" == params[:wiki_enabled] + @project.wiki = Wiki.new + @project.wiki.attributes = params[:wiki] + end 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.size > 0 - @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "news.created_on DESC") - @trackers = Tracker.find(:all, :order => 'position') - @open_issues_by_tracker = Issue.count(:group => :tracker, :joins => "INNER JOIN issue_statuses ON issue_statuses.id = issues.status_id", :conditions => ["project_id=? and issue_statuses.is_closed=?", @project.id, false]) - @total_issues_by_tracker = Issue.count(:group => :tracker, :conditions => ["project_id=?", @project.id]) + redirect_to :controller => 'admin', :action => 'projects' + end + end 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, :order => 'position') - @users = User.find_active(:all) - @project.users - @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 params[:repository_enabled] - case params[:repository_enabled] - when "0" - @project.repository = nil - when "1" - @project.repository ||= Repository.new - @project.repository.update_attributes params[:repository] - end - end - if params[:wiki_enabled] - case params[:wiki_enabled] - when "0" - @project.wiki.destroy if @project.wiki - when "1" - @project.wiki ||= Wiki.new - @project.wiki.update_attributes params[:wiki] - end - end - @project.attributes = params[:project] + + # 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.size > 0 + @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "news.created_on DESC") + @trackers = Tracker.find(:all, :order => 'position') + @open_issues_by_tracker = Issue.count(:group => :tracker, :joins => "INNER JOIN issue_statuses ON issue_statuses.id = issues.status_id", :conditions => ["project_id=? and issue_statuses.is_closed=?", @project.id, false]) + @total_issues_by_tracker = Issue.count(:group => :tracker, :conditions => ["project_id=?", @project.id]) + 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, :order => 'position') + @users = User.find_active(:all) - @project.users + @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 params[:repository_enabled] + case params[:repository_enabled] + when "0" + @project.repository = nil + when "1" + @project.repository ||= Repository.new + @project.repository.update_attributes params[:repository] + end + end + if params[:wiki_enabled] + case params[:wiki_enabled] + when "0" + @project.wiki.destroy if @project.wiki + when "1" + @project.wiki ||= Wiki.new + @project.wiki.update_attributes params[:wiki] + end + end + @project.attributes = params[:project] if @project.save flash[:notice] = l(:notice_successful_update) - redirect_to :action => 'settings', :id => @project - else - settings - render :action => 'settings' - end + redirect_to :action => 'settings', :id => @project + else + settings + render :action => 'settings' + end end - end - + end + # Delete @project - def destroy + def destroy if request.post? and params[:confirm] @project.destroy - redirect_to :controller => 'admin', :action => 'projects' + 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', :tab => 'categories', :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', :tab => 'versions', :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', :tab => 'members', :id => @project - else - settings - render :action => 'settings' - end - end - end - - # Show members list of @project - def list_members - @members = @project.members.find(:all) - end - - # Add a new document to @project - def add_document - @categories = Enumeration::get_values('DCAT') - @document = @project.documents.build(params[:document]) - if request.post? and @document.save - # Save the attachments - params[:attachments].each { |a| - Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0 - } if params[:attachments] and params[:attachments].is_a? Array - flash[:notice] = l(:notice_successful_create) - Mailer.deliver_document_add(@document) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? - redirect_to :action => 'list_documents', :id => @project - end - 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', :tab => 'categories', :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', :tab => 'versions', :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', :tab => 'members', :id => @project + else + settings + render :action => 'settings' + end + end + end + + # Show members list of @project + def list_members + @members = @project.members.find(:all) + end + + # Add a new document to @project + def add_document + @categories = Enumeration::get_values('DCAT') + @document = @project.documents.build(params[:document]) + if request.post? and @document.save + # Save the attachments + params[:attachments].each { |a| + Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0 + } if params[:attachments] and params[:attachments].is_a? Array + flash[:notice] = l(:notice_successful_create) + Mailer.deliver_document_add(@document) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? + redirect_to :action => 'list_documents', :id => @project + end + end + # Show documents list of @project - def list_documents - @documents = @project.documents.find :all, :include => :category - 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 - @attachments = [] - params[:attachments].each { |a| - @attachments << Attachment.new(:container => @issue, :file => a, :author => 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 - @attachments.each(&: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 - - retrieve_query - - @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 - - if @query.valid? - @issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement) - @issue_pages = Paginator.new self, @issue_count, @results_per_page, params['page'] - @issues = Issue.find :all, :order => sort_clause, - :include => [ :author, :status, :tracker, :project, :priority ], - :conditions => @query.statement, - :limit => @issue_pages.items_per_page, - :offset => @issue_pages.current.offset - end - @trackers = Tracker.find :all, :order => 'position' - 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 - - retrieve_query - render :action => 'list_issues' and return unless @query.valid? - - @issues = Issue.find :all, :order => sort_clause, - :include => [ :author, :status, :tracker, :priority, {:custom_values => :custom_field} ], - :conditions => @query.statement, - :limit => Setting.issues_export_limit - - ic = Iconv.new(l(:general_csv_encoding), '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_priority), - l(:field_subject), - l(:field_author), - l(:field_start_date), - l(:field_due_date), - l(:field_done_ratio), - 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.priority.name, - issue.subject, - issue.author.display_name, - issue.start_date ? l_date(issue.start_date) : nil, - issue.due_date ? l_date(issue.due_date) : nil, - issue.done_ratio, - 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 - - retrieve_query - render :action => 'list_issues' and return unless @query.valid? - - @issues = Issue.find :all, :order => sort_clause, - :include => [ :author, :status, :tracker, :priority ], - :conditions => @query.statement, - :limit => Setting.issues_export_limit - - @options_for_rfpdf ||= {} - @options_for_rfpdf[:file_name] = "export.pdf" - render :layout => false - 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| - # project dependent properties - unless i.project_id == new_project.id - i.category = nil - i.fixed_version = nil - end - # 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 - - def add_query - @query = Query.new(params[:query]) - @query.project = @project - @query.user = logged_in_user - - params[:fields].each do |field| - @query.add_filter(field, params[:operators][field], params[:values][field]) - end if params[:fields] - - if request.post? and @query.save - flash[:notice] = l(:notice_successful_create) - redirect_to :controller => 'reports', :action => 'issue_report', :id => @project - end - render :layout => false if request.xhr? - 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? - @version = @project.versions.find_by_id(params[:version_id]) - # Save the attachments - @attachments = [] - params[:attachments].each { |file| - next unless file.size > 0 - a = Attachment.create(:container => @version, :file => file, :author => logged_in_user) - @attachments << a unless a.new_record? - } if params[:attachments] and params[:attachments].is_a? Array - Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? - redirect_to :controller => 'projects', :action => 'list_files', :id => @project - 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], :order => 'position') - 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 roadmap - @trackers = Tracker.find(:all, :conditions => ["is_in_roadmap=?", true], :order => 'position') - 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 ||= [] - @versions = @project.versions.find(:all, - :conditions => [ "versions.effective_date>?", Date.today], - :order => "versions.effective_date ASC" - ) - 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], :include => :author ).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, :select => "attachments.*", :joins => "LEFT JOIN versions ON versions.id = attachments.container_id", :conditions => ["attachments.container_type='Version' and versions.project_id=? and attachments.created_on>=? and attachments.created_on<=?", @project.id, @date_from, @date_to], :include => :author ).each { |i| - @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" - @project.documents.find(:all, :conditions => ["documents.created_on>=? and documents.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 - } - Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN documents ON documents.id = attachments.container_id", :conditions => ["attachments.container_type='Document' and documents.project_id=? and attachments.created_on>=? and attachments.created_on<=?", @project.id, @date_from, @date_to], :include => :author ).each { |i| - @events_by_day[i.created_on.to_date] ||= [] - @events_by_day[i.created_on.to_date] << i - } - @show_documents = 1 - end - - render :layout => false if request.xhr? - 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, :status, :assigned_to, :priority], :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", :include => [:tracker, :status, :assigned_to, :priority], :conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_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 - - def search - @question = params[:q] || "" - @question.strip! - @all_words = params[:all_words] || (params[:submit] ? false : true) - @scope = params[:scope] || (params[:submit] ? [] : %w(issues news documents wiki) ) - if !@question.empty? - # tokens must be at least 3 character long - @tokens = @question.split.uniq.select {|w| w.length > 2 } - # no more than 5 tokens to search for - @tokens.slice! 5..-1 if @tokens.size > 5 - # strings used in sql like statement - like_tokens = @tokens.collect {|w| "%#{w}%"} - operator = @all_words ? " AND " : " OR " - limit = 10 - @results = [] - @results += @project.issues.find(:all, :limit => limit, :include => :author, :conditions => [ (["(LOWER(issues.subject) like ? OR LOWER(issues.description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'issues' - @results += @project.news.find(:all, :limit => limit, :conditions => [ (["(LOWER(news.title) like ? OR LOWER(news.description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort], :include => :author ) if @scope.include? 'news' - @results += @project.documents.find(:all, :limit => limit, :conditions => [ (["(LOWER(title) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'documents' - @results += @project.wiki.pages.find(:all, :limit => limit, :include => :content, :conditions => [ (["(LOWER(wiki_pages.title) like ? OR LOWER(wiki_contents.text) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @project.wiki && @scope.include?('wiki') - @question = @tokens.join(" ") - 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 + def list_documents + @documents = @project.documents.find :all, :include => :category + 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 + @attachments = [] + params[:attachments].each { |a| + @attachments << Attachment.new(:container => @issue, :file => a, :author => 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 + @attachments.each(&: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 + + retrieve_query + + @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 + + if @query.valid? + @issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement) + @issue_pages = Paginator.new self, @issue_count, @results_per_page, params['page'] + @issues = Issue.find :all, :order => sort_clause, + :include => [ :author, :status, :tracker, :project, :priority ], + :conditions => @query.statement, + :limit => @issue_pages.items_per_page, + :offset => @issue_pages.current.offset + end + @trackers = Tracker.find :all, :order => 'position' + 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 + + retrieve_query + render :action => 'list_issues' and return unless @query.valid? + + @issues = Issue.find :all, :order => sort_clause, + :include => [ :author, :status, :tracker, :priority, {:custom_values => :custom_field} ], + :conditions => @query.statement, + :limit => Setting.issues_export_limit + + ic = Iconv.new(l(:general_csv_encoding), '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_priority), + l(:field_subject), + l(:field_author), + l(:field_start_date), + l(:field_due_date), + l(:field_done_ratio), + 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.priority.name, + issue.subject, + issue.author.display_name, + issue.start_date ? l_date(issue.start_date) : nil, + issue.due_date ? l_date(issue.due_date) : nil, + issue.done_ratio, + 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 + + retrieve_query + render :action => 'list_issues' and return unless @query.valid? + + @issues = Issue.find :all, :order => sort_clause, + :include => [ :author, :status, :tracker, :priority ], + :conditions => @query.statement, + :limit => Setting.issues_export_limit + + @options_for_rfpdf ||= {} + @options_for_rfpdf[:file_name] = "export.pdf" + render :layout => false + 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| + # project dependent properties + unless i.project_id == new_project.id + i.category = nil + i.fixed_version = nil + end + # 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 + + def add_query + @query = Query.new(params[:query]) + @query.project = @project + @query.user = logged_in_user + + params[:fields].each do |field| + @query.add_filter(field, params[:operators][field], params[:values][field]) + end if params[:fields] + + if request.post? and @query.save + flash[:notice] = l(:notice_successful_create) + redirect_to :controller => 'reports', :action => 'issue_report', :id => @project + end + render :layout => false if request.xhr? + 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? + @version = @project.versions.find_by_id(params[:version_id]) + # Save the attachments + @attachments = [] + params[:attachments].each { |file| + next unless file.size > 0 + a = Attachment.create(:container => @version, :file => file, :author => logged_in_user) + @attachments << a unless a.new_record? + } if params[:attachments] and params[:attachments].is_a? Array + Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? + redirect_to :controller => 'projects', :action => 'list_files', :id => @project + 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], :order => 'position') + 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 roadmap + @trackers = Tracker.find(:all, :conditions => ["is_in_roadmap=?", true], :order => 'position') + 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 ||= [] + @versions = @project.versions.find(:all, + :conditions => [ "versions.effective_date>?", Date.today], + :order => "versions.effective_date ASC" + ) + 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], :include => :author ).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, :select => "attachments.*", :joins => "LEFT JOIN versions ON versions.id = attachments.container_id", :conditions => ["attachments.container_type='Version' and versions.project_id=? and attachments.created_on>=? and attachments.created_on<=?", @project.id, @date_from, @date_to], :include => :author ).each { |i| + @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" + @project.documents.find(:all, :conditions => ["documents.created_on>=? and documents.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 + } + Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN documents ON documents.id = attachments.container_id", :conditions => ["attachments.container_type='Document' and documents.project_id=? and attachments.created_on>=? and attachments.created_on<=?", @project.id, @date_from, @date_to], :include => :author ).each { |i| + @events_by_day[i.created_on.to_date] ||= [] + @events_by_day[i.created_on.to_date] << i + } + @show_documents = 1 + end + + render :layout => false if request.xhr? + 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, :status, :assigned_to, :priority], :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", :include => [:tracker, :status, :assigned_to, :priority], :conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_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 + + def search + @question = params[:q] || "" + @question.strip! + @all_words = params[:all_words] || (params[:submit] ? false : true) + @scope = params[:scope] || (params[:submit] ? [] : %w(issues news documents wiki) ) + if !@question.empty? + # tokens must be at least 3 character long + @tokens = @question.split.uniq.select {|w| w.length > 2 } + # no more than 5 tokens to search for + @tokens.slice! 5..-1 if @tokens.size > 5 + # strings used in sql like statement + like_tokens = @tokens.collect {|w| "%#{w}%"} + operator = @all_words ? " AND " : " OR " + limit = 10 + @results = [] + @results += @project.issues.find(:all, :limit => limit, :include => :author, :conditions => [ (["(LOWER(issues.subject) like ? OR LOWER(issues.description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'issues' + @results += @project.news.find(:all, :limit => limit, :conditions => [ (["(LOWER(news.title) like ? OR LOWER(news.description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort], :include => :author ) if @scope.include? 'news' + @results += @project.documents.find(:all, :limit => limit, :conditions => [ (["(LOWER(title) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'documents' + @results += @project.wiki.pages.find(:all, :limit => limit, :include => :content, :conditions => [ (["(LOWER(wiki_pages.title) like ? OR LOWER(wiki_contents.text) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @project.wiki && @scope.include?('wiki') + @question = @tokens.join(" ") + 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 ActiveRecord::RecordNotFound - render_404 - end - - # Retrieve query from session or build a new query - def retrieve_query - if params[:query_id] - @query = @project.queries.find(params[:query_id]) - session[:query] = @query - else - if params[:set_filter] or !session[:query] or session[:query].project_id != @project.id - # Give it a name, required to be valid - @query = Query.new(:name => "_") - @query.project = @project - if params[:fields] and params[:fields].is_a? Array - params[:fields].each do |field| - @query.add_filter(field, params[:operators][field], params[:values][field]) - end - else - @query.available_filters.keys.each do |field| - @query.add_short_filter(field, params[field]) if params[field] - end - end - session[:query] = @query - else - @query = session[:query] - end - end - end + render_404 + end + + # Retrieve query from session or build a new query + def retrieve_query + if params[:query_id] + @query = @project.queries.find(params[:query_id]) + session[:query] = @query + else + if params[:set_filter] or !session[:query] or session[:query].project_id != @project.id + # Give it a name, required to be valid + @query = Query.new(:name => "_") + @query.project = @project + if params[:fields] and params[:fields].is_a? Array + params[:fields].each do |field| + @query.add_filter(field, params[:operators][field], params[:values][field]) + end + else + @query.available_filters.keys.each do |field| + @query.add_short_filter(field, params[field]) if params[field] + end + end + session[:query] = @query + else + @query = session[:query] + end + end + end end diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index aa26e24b..37c6cf12 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -1,167 +1,167 @@ -# 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, :order => 'position') - - case params[:detail] - when "tracker" - @field = "tracker_id" - @rows = Tracker.find :all, :order => 'position' - @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 - @queries = @project.queries.find :all, :conditions => ["is_public=? or user_id=?", true, (logged_in_user ? logged_in_user.id : 0)] - @trackers = Tracker.find(:all, :order => 'position') - @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]) - rescue ActiveRecord::RecordNotFound - render_404 - 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") +# 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, :order => 'position') + + case params[:detail] + when "tracker" + @field = "tracker_id" + @rows = Tracker.find :all, :order => 'position' + @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 + @queries = @project.queries.find :all, :conditions => ["is_public=? or user_id=?", true, (logged_in_user ? logged_in_user.id : 0)] + @trackers = Tracker.find(:all, :order => 'position') + @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]) + rescue ActiveRecord::RecordNotFound + render_404 + 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 index b26cf730..d0dd8eb4 100644 --- a/app/controllers/roles_controller.rb +++ b/app/controllers/roles_controller.rb @@ -1,26 +1,26 @@ -# 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 - - verify :method => :post, :only => [ :destroy, :move ], - :redirect_to => { :action => :list } +# 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 + + verify :method => :post, :only => [ :destroy, :move ], + :redirect_to => { :action => :list } def index list @@ -28,26 +28,26 @@ class RolesController < ApplicationController end def list - @role_pages, @roles = paginate :roles, :per_page => 10, :order => "position" + @role_pages, @roles = paginate :roles, :per_page => 10, :order => "position" render :action => "list", :layout => false if request.xhr? end def new - @role = Role.new(params[:role]) + @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 end @permissions = Permission.find(:all, :conditions => ["is_public=?", false], :order => 'sort ASC') end def edit - @role = Role.find(params[:id]) + @role = Role.find(params[:id]) if request.post? and @role.update_attributes(params[:role]) - @role.permissions = Permission.find(params[:permission_ids] || []) + @role.permissions = Permission.find(params[:permission_ids] || []) Permission.allowed_to_role_expired flash[:notice] = l(:notice_successful_update) redirect_to :action => 'list' @@ -56,47 +56,47 @@ class RolesController < ApplicationController 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 + @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 move - @role = Role.find(params[:id]) - case params[:position] - when 'highest' - @role.move_to_top - when 'higher' - @role.move_higher - when 'lower' - @role.move_lower - when 'lowest' - @role.move_to_bottom - end if params[:position] - 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, :order => 'position') - @trackers = Tracker.find(:all, :order => 'position') - @statuses = IssueStatus.find(:all, :include => :workflows, :order => 'position') + end + + def move + @role = Role.find(params[:id]) + case params[:position] + when 'highest' + @role.move_to_top + when 'higher' + @role.move_higher + when 'lower' + @role.move_lower + when 'lowest' + @role.move_to_bottom + end if params[:position] + 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, :order => 'position') + @trackers = Tracker.find(:all, :order => 'position') + @statuses = IssueStatus.find(:all, :include => :workflows, :order => 'position') end end diff --git a/app/controllers/trackers_controller.rb b/app/controllers/trackers_controller.rb index 00590494..db30862c 100644 --- a/app/controllers/trackers_controller.rb +++ b/app/controllers/trackers_controller.rb @@ -1,23 +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 TrackersController < ApplicationController - layout 'base' - before_filter :require_admin +# 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 @@ -28,7 +28,7 @@ class TrackersController < ApplicationController verify :method => :post, :only => [ :destroy, :move ], :redirect_to => { :action => :list } def list - @tracker_pages, @trackers = paginate :trackers, :per_page => 10, :order => 'position' + @tracker_pages, @trackers = paginate :trackers, :per_page => 10, :order => 'position' render :action => "list", :layout => false if request.xhr? end @@ -47,28 +47,28 @@ class TrackersController < ApplicationController redirect_to :action => 'list' end end - - def move - @tracker = Tracker.find(params[:id]) - case params[:position] - when 'highest' - @tracker.move_to_top - when 'higher' - @tracker.move_higher - when 'lower' - @tracker.move_lower - when 'lowest' - @tracker.move_to_bottom - end if params[:position] - redirect_to :action => 'list' - end + + def move + @tracker = Tracker.find(params[:id]) + case params[:position] + when 'highest' + @tracker.move_to_top + when 'higher' + @tracker.move_higher + when 'lower' + @tracker.move_lower + when 'lowest' + @tracker.move_to_bottom + end if params[:position] + redirect_to :action => 'list' + 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 + @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 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4ddbe054..5f0afcec 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,113 +1,113 @@ -# redMine - project management software -# Copyright (C) 2006-2007 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 +# redMine - project management software +# Copyright (C) 2006-2007 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 - + 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 => Setting.default_language) - @custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user) } + if request.get? + @user = User.new(:language => Setting.default_language) + @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 + @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 + 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 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 end - @auth_sources = AuthSource.find(:all) - @roles = Role.find(:all, :order => 'position') - @projects = Project.find(:all) - @user.projects - @membership ||= Member.new - end - - def edit_membership - @user = User.find(params[:id]) - @membership = params[:membership_id] ? Member.find(params[:membership_id]) : Member.new(:user => @user) - @membership.attributes = params[:membership] - if request.post? and @membership.save - flash[:notice] = l(:notice_successful_update) - end - redirect_to :action => 'edit', :id => @user and return - end - - def destroy_membership - @user = User.find(params[:id]) - if request.post? and Member.find(params[:membership_id]).destroy - flash[:notice] = l(:notice_successful_update) - end - redirect_to :action => 'edit', :id => @user and return + @auth_sources = AuthSource.find(:all) + @roles = Role.find(:all, :order => 'position') + @projects = Project.find(:all) - @user.projects + @membership ||= Member.new + end + + def edit_membership + @user = User.find(params[:id]) + @membership = params[:membership_id] ? Member.find(params[:membership_id]) : Member.new(:user => @user) + @membership.attributes = params[:membership] + if request.post? and @membership.save + flash[:notice] = l(:notice_successful_update) + end + redirect_to :action => 'edit', :id => @user and return + end + + def destroy_membership + @user = User.find(params[:id]) + if request.post? and Member.find(params[:membership_id]).destroy + flash[:notice] = l(:notice_successful_update) + end + redirect_to :action => 'edit', :id => @user and return end def destroy User.find(params[:id]).destroy - redirect_to :action => 'list' - rescue - flash[:notice] = "Unable to delete user" redirect_to :action => 'list' - end + 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 index f5fd4e23..c46c0118 100644 --- a/app/controllers/versions_controller.rb +++ b/app/controllers/versions_controller.rb @@ -1,23 +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 VersionsController < ApplicationController - layout 'base' - before_filter :find_project, :authorize +# 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]) @@ -26,33 +26,33 @@ class VersionsController < ApplicationController end end - def destroy + def destroy @version.destroy - redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project - rescue - flash[:notice] = "Unable to delete version" - redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project - end - - def download - @attachment = @version.attachments.find(params[:attachment_id]) - @attachment.increment_download - send_file @attachment.diskfile, :filename => @attachment.filename - rescue - render_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 - rescue ActiveRecord::RecordNotFound - render_404 + redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project + rescue + flash[:notice] = "Unable to delete version" + redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project + end + + def download + @attachment = @version.attachments.find(params[:attachment_id]) + @attachment.increment_download + send_file @attachment.diskfile, :filename => @attachment.filename + rescue + render_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 + rescue ActiveRecord::RecordNotFound + render_404 end end diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index ce45076d..2eac2268 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -1,25 +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 logged_in_user - @projects = Project.latest logged_in_user +# 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 logged_in_user + @projects = Project.latest logged_in_user end end diff --git a/app/helpers/account_helper.rb b/app/helpers/account_helper.rb index e18ab6ff..ff18b76a 100644 --- a/app/helpers/account_helper.rb +++ b/app/helpers/account_helper.rb @@ -1,19 +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. - +# 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 index db277739..4f82a379 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -1,19 +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. - +# 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 index f9010df1..0a6c2910 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,229 +1,229 @@ -# redMine - project management software -# Copyright (C) 2006-2007 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 image_to_function(name, function, html_options = {}) - html_options.symbolize_keys! - tag(:input, html_options.merge({ - :type => "image", :src => image_path(name), - :onclick => (html_options[:onclick] ? "#{html_options[:onclick]}; " : "") + "#{function};" - })) - end - - def format_date(date) - l_date(date) if date - end - - def format_time(time) - l_datetime((time.is_a? String) ? time.to_time : time) if time - end - - def day_name(day) - l(:general_day_names).split(',')[day-1] - end - - def month_name(month) - l(:actionview_datehelper_select_month_names).split(',')[month-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 - - # textilize text according to system settings and RedCloth availability - def textilizable(text, options = {}) - # different methods for formatting wiki links - case options[:wiki_links] - when :local - # used for local links to html files - format_wiki_link = Proc.new {|title| "#{title}.html" } - when :anchor - # used for single-file wiki export - format_wiki_link = Proc.new {|title| "##{title}" } - else - if @project - format_wiki_link = Proc.new {|title| url_for :controller => 'wiki', :action => 'index', :id => @project, :page => title } - else - format_wiki_link = Proc.new {|title| title } - end - end - - # turn wiki links into textile links: - # example: - # [[link]] -> "link":link - # [[link|title]] -> "title":link - text = text.gsub(/\[\[([^\]\|]+)(\|([^\]\|]+))?\]\]/) {|m| "\"#{$3 || $1}\":" + format_wiki_link.call(Wiki.titleize($1)) } - - # turn issue ids to textile links - # example: - # #52 -> "#52":/issues/show/52 - text = text.gsub(/#(\d+)([\s\.\(\)\-,:;])/) {|m| "\"##{$1}\":" + url_for(:controller => 'issues', :action => 'show', :id => $1) + $2 } - - # turn revision ids to textile links (@project needed) - # example: - # r52 -> "r52":/repositories/revision/6?rev=52 (@project.id is 6) - text = text.gsub(/r(\d+)([\s\.\(\)\-,:;])/) {|m| "\"r#{$1}\":" + url_for(:controller => 'repositories', :action => 'revision', :id => @project.id, :rev => $1) + $2 } if @project - - # finally textilize text - text = (Setting.text_formatting == 'textile') && (ActionView::Helpers::TextHelper.method_defined? "textilize") ? auto_link(RedCloth.new(text, [:filter_html]).to_html) : simple_format(auto_link(h(text))) - 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? - msg = msg.first if msg.is_a? Array - 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? - msg = msg.first if msg.is_a? Array - 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(blank=true) - (blank ? [["(auto)", ""]] : []) + - (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.png", {:id => "#{field_id}_trigger",:class => "calendar-trigger"}) + - javascript_tag("Calendar.setup({inputField : '#{field_id}', ifFormat : '%Y-%m-%d', button : '#{field_id}_trigger' });") - end +# redMine - project management software +# Copyright (C) 2006-2007 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 image_to_function(name, function, html_options = {}) + html_options.symbolize_keys! + tag(:input, html_options.merge({ + :type => "image", :src => image_path(name), + :onclick => (html_options[:onclick] ? "#{html_options[:onclick]}; " : "") + "#{function};" + })) + end + + def format_date(date) + l_date(date) if date + end + + def format_time(time) + l_datetime((time.is_a? String) ? time.to_time : time) if time + end + + def day_name(day) + l(:general_day_names).split(',')[day-1] + end + + def month_name(month) + l(:actionview_datehelper_select_month_names).split(',')[month-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 + + # textilize text according to system settings and RedCloth availability + def textilizable(text, options = {}) + # different methods for formatting wiki links + case options[:wiki_links] + when :local + # used for local links to html files + format_wiki_link = Proc.new {|title| "#{title}.html" } + when :anchor + # used for single-file wiki export + format_wiki_link = Proc.new {|title| "##{title}" } + else + if @project + format_wiki_link = Proc.new {|title| url_for :controller => 'wiki', :action => 'index', :id => @project, :page => title } + else + format_wiki_link = Proc.new {|title| title } + end + end + + # turn wiki links into textile links: + # example: + # [[link]] -> "link":link + # [[link|title]] -> "title":link + text = text.gsub(/\[\[([^\]\|]+)(\|([^\]\|]+))?\]\]/) {|m| "\"#{$3 || $1}\":" + format_wiki_link.call(Wiki.titleize($1)) } + + # turn issue ids to textile links + # example: + # #52 -> "#52":/issues/show/52 + text = text.gsub(/#(\d+)([\s\.\(\)\-,:;])/) {|m| "\"##{$1}\":" + url_for(:controller => 'issues', :action => 'show', :id => $1) + $2 } + + # turn revision ids to textile links (@project needed) + # example: + # r52 -> "r52":/repositories/revision/6?rev=52 (@project.id is 6) + text = text.gsub(/r(\d+)([\s\.\(\)\-,:;])/) {|m| "\"r#{$1}\":" + url_for(:controller => 'repositories', :action => 'revision', :id => @project.id, :rev => $1) + $2 } if @project + + # finally textilize text + text = (Setting.text_formatting == 'textile') && (ActionView::Helpers::TextHelper.method_defined? "textilize") ? auto_link(RedCloth.new(text, [:filter_html]).to_html) : simple_format(auto_link(h(text))) + 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? + msg = msg.first if msg.is_a? Array + 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? + msg = msg.first if msg.is_a? Array + 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(blank=true) + (blank ? [["(auto)", ""]] : []) + + (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.png", {: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 = {}) - return super if options.delete :no_label - 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 && @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 = {}, html_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 && @object.errors[field] ? "error" : nil), - :for => (@object_name.to_s + "_" + field.to_s)) - label + super - 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 = {}) + return super if options.delete :no_label + 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 && @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 = {}, html_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 && @object.errors[field] ? "error" : nil), + :for => (@object_name.to_s + "_" + field.to_s)) + label + super + end + +end + diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb index 6a596b89..d6dc586c 100644 --- a/app/helpers/custom_fields_helper.rb +++ b/app/helpers/custom_fields_helper.rb @@ -1,77 +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, { :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? ? " *" : ""), - :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 && !value.empty? - case field_format - when "date" - begin; l_date(value.to_date); rescue; value end - 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.sort {|a,b| a[1][:order]<=>b[1][:order]}.collect { |k| [ l(k[1][:name]), k[0] ] } +# 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, { :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? ? " *" : ""), + :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 && !value.empty? + case field_format + when "date" + begin; l_date(value.to_date); rescue; value end + 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.sort {|a,b| a[1][:order]<=>b[1][:order]}.collect { |k| [ l(k[1][:name]), k[0] ] } end end diff --git a/app/helpers/documents_helper.rb b/app/helpers/documents_helper.rb index c9897647..7e96a6db 100644 --- a/app/helpers/documents_helper.rb +++ b/app/helpers/documents_helper.rb @@ -1,19 +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. - +# 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 index 11a216a8..c0daf64d 100644 --- a/app/helpers/enumerations_helper.rb +++ b/app/helpers/enumerations_helper.rb @@ -1,19 +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. - +# 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 index bb629316..41fc5917 100644 --- a/app/helpers/help_helper.rb +++ b/app/helpers/help_helper.rb @@ -1,19 +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. - +# 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 index 481c2c31..267f9666 100644 --- a/app/helpers/ifpdf_helper.rb +++ b/app/helpers/ifpdf_helper.rb @@ -1,70 +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. - -require 'iconv' -require 'rfpdf/chinese' - -module IfpdfHelper - - class IFPDF < FPDF - include GLoc - attr_accessor :footer_date - - def initialize(lang) - super() - set_language_if_valid lang - case current_language - when :ja - extend(PDF_Japanese) - AddSJISFont() - @font_for_content = 'SJIS' - @font_for_footer = 'SJIS' - else - @font_for_content = 'Arial' - @font_for_footer = 'Helvetica' - end - SetCreator("redMine #{Redmine::VERSION}") - SetFont(@font_for_content) - end - - def SetFontStyle(style, size) - SetFont(@font_for_content, style, size) - end - - def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='') - @ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8') - txt = begin - @ic.iconv(txt) - rescue - txt - end - super w,h,txt,border,ln,align,fill,link - end - - def Footer - SetFont(@font_for_footer, '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 - +# 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' +require 'rfpdf/chinese' + +module IfpdfHelper + + class IFPDF < FPDF + include GLoc + attr_accessor :footer_date + + def initialize(lang) + super() + set_language_if_valid lang + case current_language + when :ja + extend(PDF_Japanese) + AddSJISFont() + @font_for_content = 'SJIS' + @font_for_footer = 'SJIS' + else + @font_for_content = 'Arial' + @font_for_footer = 'Helvetica' + end + SetCreator("redMine #{Redmine::VERSION}") + SetFont(@font_for_content) + end + + def SetFontStyle(style, size) + SetFont(@font_for_content, style, size) + end + + def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='') + @ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8') + txt = begin + @ic.iconv(txt) + rescue + txt + end + super w,h,txt,border,ln,align,fill,link + end + + def Footer + SetFont(@font_for_footer, '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 + +end diff --git a/app/helpers/issue_categories_helper.rb b/app/helpers/issue_categories_helper.rb index 997d830d..0109e7fa 100644 --- a/app/helpers/issue_categories_helper.rb +++ b/app/helpers/issue_categories_helper.rb @@ -1,19 +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. - +# 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 index 17704b7b..859b0991 100644 --- a/app/helpers/issue_statuses_helper.rb +++ b/app/helpers/issue_statuses_helper.rb @@ -1,19 +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. - +# 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 index 57fb0160..8fa9f75e 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -1,74 +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", h(old_value)) if detail.old_value - old_value = content_tag("strike", old_value) if detail.old_value and (!detail.value or detail.value.empty?) - value = content_tag("i", h(value)) if value - end - - if detail.value and !detail.value.to_s.empty? - 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 +# 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", h(old_value)) if detail.old_value + old_value = content_tag("strike", old_value) if detail.old_value and (!detail.value or detail.value.empty?) + value = content_tag("i", h(value)) if value + end + + if detail.value and !detail.value.to_s.empty? + 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 index 8bf90913..fcf9c92e 100644 --- a/app/helpers/members_helper.rb +++ b/app/helpers/members_helper.rb @@ -1,19 +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. - +# 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/news_helper.rb b/app/helpers/news_helper.rb index f4a633f4..28d36f31 100644 --- a/app/helpers/news_helper.rb +++ b/app/helpers/news_helper.rb @@ -1,19 +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. - +# 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 index 694dd912..43febd41 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -1,29 +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. - -module ProjectsHelper - - def highlight_tokens(text, tokens) - return text unless tokens && !tokens.empty? - regexp = Regexp.new "(#{tokens.join('|')})", Regexp::IGNORECASE - result = '' - text.split(regexp).each_with_index do |words, i| - result << (i.even? ? (words.length > 100 ? "#{words[0..44]} ... #{words[-45..-1]}" : words) : content_tag('span', words, :class => 'highlight')) - end - result +# 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 + + def highlight_tokens(text, tokens) + return text unless tokens && !tokens.empty? + regexp = Regexp.new "(#{tokens.join('|')})", Regexp::IGNORECASE + result = '' + text.split(regexp).each_with_index do |words, i| + result << (i.even? ? (words.length > 100 ? "#{words[0..44]} ... #{words[-45..-1]}" : words) : content_tag('span', words, :class => 'highlight')) + end + result end end diff --git a/app/helpers/reports_helper.rb b/app/helpers/reports_helper.rb index ed7fd788..af7a1a97 100644 --- a/app/helpers/reports_helper.rb +++ b/app/helpers/reports_helper.rb @@ -1,32 +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 +# 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 index 8ae33905..ab3a7ff0 100644 --- a/app/helpers/roles_helper.rb +++ b/app/helpers/roles_helper.rb @@ -1,19 +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. - +# 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/trackers_helper.rb b/app/helpers/trackers_helper.rb index 839327ef..89f92e33 100644 --- a/app/helpers/trackers_helper.rb +++ b/app/helpers/trackers_helper.rb @@ -1,19 +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. - +# 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 index 035db3d0..adc62fb7 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -1,19 +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. - +# 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 index e2724fe8..452f4d7f 100644 --- a/app/helpers/versions_helper.rb +++ b/app/helpers/versions_helper.rb @@ -1,19 +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. - +# 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 index cace5f54..753e1f12 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -1,19 +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. - +# 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 index 773f2ebe..82fcdadf 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -1,92 +1,92 @@ -# redMine - project management software -# Copyright (C) 2006-2007 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 :container, :filename - - cattr_accessor :storage_path - @@storage_path = "#{RAILS_ROOT}/files" - - def validate - errors.add_to_base :too_long if self.filesize > Setting.attachment_max_size.to_i.kilobytes - end - - 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 - - def file - nil - 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 - "#{@@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 +# redMine - project management software +# Copyright (C) 2006-2007 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 :container, :filename + + cattr_accessor :storage_path + @@storage_path = "#{RAILS_ROOT}/files" + + def validate + errors.add_to_base :too_long if self.filesize > Setting.attachment_max_size.to_i.kilobytes + end + + 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 + + def file + nil + 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 + "#{@@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_ldap.rb b/app/models/auth_source_ldap.rb index 895cf1c6..31259afc 100644 --- a/app/models/auth_source_ldap.rb +++ b/app/models/auth_source_ldap.rb @@ -1,79 +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] +# 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 index ea11edc4..554504a9 100644 --- a/app/models/custom_field.rb +++ b/app/models/custom_field.rb @@ -1,60 +1,60 @@ -# 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 => :delete_all - serialize :possible_values - - FIELD_FORMATS = { "string" => { :name => :label_string, :order => 1 }, - "text" => { :name => :label_text, :order => 2 }, - "int" => { :name => :label_integer, :order => 3 }, - "list" => { :name => :label_list, :order => 4 }, - "date" => { :name => :label_date, :order => 5 }, - "bool" => { :name => :label_boolean, :order => 6 } - }.freeze - - validates_presence_of :name, :field_format - validates_uniqueness_of :name - validates_format_of :name, :with => /^[\w\s\'\-]*$/i - validates_inclusion_of :field_format, :in => FIELD_FORMATS.keys - - def initialize(attributes = nil) - super - self.possible_values ||= [] - end - - def before_validation - # remove empty values - self.possible_values = self.possible_values.collect{|v| v unless v.empty?}.compact - end - - def validate - if self.field_format == "list" - errors.add(:possible_values, :activerecord_error_blank) if self.possible_values.nil? || self.possible_values.empty? - errors.add(:possible_values, :activerecord_error_invalid) unless self.possible_values.is_a? Array - end - end - - # to move in project_custom_field - def self.for_all - find(:all, :conditions => ["is_for_all=?", true]) - end - - def type_name - nil +# 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 => :delete_all + serialize :possible_values + + FIELD_FORMATS = { "string" => { :name => :label_string, :order => 1 }, + "text" => { :name => :label_text, :order => 2 }, + "int" => { :name => :label_integer, :order => 3 }, + "list" => { :name => :label_list, :order => 4 }, + "date" => { :name => :label_date, :order => 5 }, + "bool" => { :name => :label_boolean, :order => 6 } + }.freeze + + validates_presence_of :name, :field_format + validates_uniqueness_of :name + validates_format_of :name, :with => /^[\w\s\'\-]*$/i + validates_inclusion_of :field_format, :in => FIELD_FORMATS.keys + + def initialize(attributes = nil) + super + self.possible_values ||= [] end -end + + def before_validation + # remove empty values + self.possible_values = self.possible_values.collect{|v| v unless v.empty?}.compact + end + + def validate + if self.field_format == "list" + errors.add(:possible_values, :activerecord_error_blank) if self.possible_values.nil? || self.possible_values.empty? + errors.add(:possible_values, :activerecord_error_invalid) unless self.possible_values.is_a? Array + end + end + + # 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 index e93dfb4f..a1b2c9c4 100644 --- a/app/models/custom_value.rb +++ b/app/models/custom_value.rb @@ -1,38 +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.include? value or value.empty? - end - end -end +# 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.include? value or value.empty? + end + end +end diff --git a/app/models/document.rb b/app/models/document.rb index 40a9765a..141489a7 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -1,24 +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 => :destroy - +# 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 => :destroy + validates_presence_of :project, :title, :category end diff --git a/app/models/enumeration.rb b/app/models/enumeration.rb index 0d6554f8..251f00fb 100644 --- a/app/models/enumeration.rb +++ b/app/models/enumeration.rb @@ -1,47 +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 Enumeration < ActiveRecord::Base - before_destroy :check_integrity - - validates_presence_of :opt, :name - validates_uniqueness_of :name, :scope => [:opt] - validates_format_of :name, :with => /^[\w\s\'\-]*$/i - - 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 +# 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] + validates_format_of :name, :with => /^[\w\s\'\-]*$/i + + 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 index 6f77bef3..14007187 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1,102 +1,102 @@ -# 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 :journals, :as => :journalized, :dependent => :destroy - has_many :attachments, :as => :container, :dependent => :destroy - - has_many :custom_values, :dependent => :delete_all, :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 +# 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 :journals, :as => :journalized, :dependent => :destroy + has_many :attachments, :as => :container, :dependent => :destroy + + has_many :custom_values, :dependent => :delete_all, :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 index 74adb8f5..1a1daffb 100644 --- a/app/models/issue_category.rb +++ b/app/models/issue_category.rb @@ -1,29 +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]) +# 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 index 209ae206..7759c905 100644 --- a/app/models/issue_custom_field.rb +++ b/app/models/issue_custom_field.rb @@ -1,27 +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 +# 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 index 4b668260..38366bbc 100644 --- a/app/models/issue_history.rb +++ b/app/models/issue_history.rb @@ -1,24 +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. - +# 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 + 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 index 1a690b44..fd6194c9 100644 --- a/app/models/issue_status.rb +++ b/app/models/issue_status.rb @@ -1,51 +1,51 @@ -# 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" - acts_as_list - - validates_presence_of :name - validates_uniqueness_of :name - validates_format_of :name, :with => /^[\w\s\'\-]*$/i - 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=#{connection.quoted_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]) +# 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" + acts_as_list + + validates_presence_of :name + validates_uniqueness_of :name + validates_format_of :name, :with => /^[\w\s\'\-]*$/i + 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=#{connection.quoted_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]) end end diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 42d20eca..36bcddc2 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -1,88 +1,88 @@ -# redMine - project management software -# Copyright (C) 2006-2007 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 +# redMine - project management software +# Copyright (C) 2006-2007 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) + def issue_add(issue) set_language_if_valid(Setting.default_language) # Sends to all project members @recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }.compact @from = Setting.mail_from @subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}" - @body['issue'] = issue - end - - def issue_edit(journal) - set_language_if_valid(Setting.default_language) - # Sends to all project members - issue = journal.journalized - @recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }.compact - @from = Setting.mail_from - @subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}" - @body['issue'] = issue - @body['journal']= journal - end - - def document_add(document) - set_language_if_valid(Setting.default_language) - @recipients = document.project.users.collect { |u| u.mail if u.mail_notification }.compact - @from = Setting.mail_from - @subject = "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}" - @body['document'] = document - end - - def attachments_add(attachments) - set_language_if_valid(Setting.default_language) - container = attachments.first.container - url = "http://#{Setting.host_name}/" - added_to = "" - case container.class.to_s - when 'Version' - url << "projects/list_files/#{container.project_id}" - added_to = "#{l(:label_version)}: #{container.name}" - when 'Document' - url << "documents/show/#{container.id}" - added_to = "#{l(:label_document)}: #{container.title}" - when 'Issue' - url << "issues/show/#{container.id}" - added_to = "#{container.tracker.name} ##{container.id}: #{container.subject}" - end - @recipients = container.project.users.collect { |u| u.mail if u.mail_notification }.compact - @from = Setting.mail_from - @subject = "[#{container.project.name}] #{l(:label_attachment_new)}" - @body['attachments'] = attachments - @body['url'] = url - @body['added_to'] = added_to - end - - def lost_password(token) - set_language_if_valid(token.user.language) - @recipients = token.user.mail - @from = Setting.mail_from - @subject = l(:mail_subject_lost_password) - @body['token'] = token + @body['issue'] = issue + end + + def issue_edit(journal) + set_language_if_valid(Setting.default_language) + # Sends to all project members + issue = journal.journalized + @recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }.compact + @from = Setting.mail_from + @subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}" + @body['issue'] = issue + @body['journal']= journal + end + + def document_add(document) + set_language_if_valid(Setting.default_language) + @recipients = document.project.users.collect { |u| u.mail if u.mail_notification }.compact + @from = Setting.mail_from + @subject = "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}" + @body['document'] = document + end + + def attachments_add(attachments) + set_language_if_valid(Setting.default_language) + container = attachments.first.container + url = "http://#{Setting.host_name}/" + added_to = "" + case container.class.to_s + when 'Version' + url << "projects/list_files/#{container.project_id}" + added_to = "#{l(:label_version)}: #{container.name}" + when 'Document' + url << "documents/show/#{container.id}" + added_to = "#{l(:label_document)}: #{container.title}" + when 'Issue' + url << "issues/show/#{container.id}" + added_to = "#{container.tracker.name} ##{container.id}: #{container.subject}" + end + @recipients = container.project.users.collect { |u| u.mail if u.mail_notification }.compact + @from = Setting.mail_from + @subject = "[#{container.project.name}] #{l(:label_attachment_new)}" + @body['attachments'] = attachments + @body['url'] = url + @body['added_to'] = added_to + end + + def lost_password(token) + set_language_if_valid(token.user.language) + @recipients = token.user.mail + @from = Setting.mail_from + @subject = l(:mail_subject_lost_password) + @body['token'] = token end - - def register(token) - set_language_if_valid(token.user.language) - @recipients = token.user.mail - @from = Setting.mail_from - @subject = l(:mail_subject_register) - @body['token'] = token - end + + def register(token) + set_language_if_valid(token.user.language) + @recipients = token.user.mail + @from = Setting.mail_from + @subject = l(:mail_subject_register) + @body['token'] = token + end end diff --git a/app/models/member.rb b/app/models/member.rb index 1214b644..9814faa5 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -1,29 +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 +# 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 index 89e94f1c..84851730 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -1,29 +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 News < ActiveRecord::Base - belongs_to :project - belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' - has_many :comments, :as => :commented, :dependent => :delete_all, :order => "created_on" - - validates_presence_of :title, :description - - # returns latest news for projects visible by user - def self.latest(user=nil, count=5) - find(:all, :limit => count, :conditions => Project.visible_by(user), :include => [ :author, :project ], :order => "news.created_on DESC") +# 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' + has_many :comments, :as => :commented, :dependent => :delete_all, :order => "created_on" + + validates_presence_of :title, :description + + # returns latest news for projects visible by user + def self.latest(user=nil, count=5) + find(:all, :limit => count, :conditions => Project.visible_by(user), :include => [ :author, :project ], :order => "news.created_on DESC") end end diff --git a/app/models/permission.rb b/app/models/permission.rb index 65b9253c..3ce40d11 100644 --- a/app/models/permission.rb +++ b/app/models/permission.rb @@ -1,65 +1,65 @@ -# 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, - 600 => :label_query_plural, - 1000 => :label_issue_plural, - 1100 => :label_news_plural, - 1200 => :label_document_plural, - 1300 => :label_attachment_plural, - 1400 => :label_repository - }.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 - allowed_to_public(action) or (@@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 +# 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, + 600 => :label_query_plural, + 1000 => :label_issue_plural, + 1100 => :label_news_plural, + 1200 => :label_document_plural, + 1300 => :label_attachment_plural, + 1400 => :label_repository + }.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 + allowed_to_public(action) or (@@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 index 3f9ec168..3cf5a816 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1,71 +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 Project < ActiveRecord::Base - has_many :versions, :dependent => :destroy, :order => "versions.effective_date DESC, versions.name DESC" - has_many :members, :dependent => :delete_all, :include => :user, :conditions => "users.status=#{User::STATUS_ACTIVE}" - has_many :users, :through => :members - has_many :custom_values, :dependent => :delete_all, :as => :customized - has_many :issues, :dependent => :destroy, :order => "issues.created_on DESC", :include => [:status, :tracker] - has_many :queries, :dependent => :delete_all - has_many :documents, :dependent => :destroy - has_many :news, :dependent => :delete_all, :include => :author - has_many :issue_categories, :dependent => :delete_all, :order => "issue_categories.name" - has_one :repository, :dependent => :destroy - has_one :wiki, :dependent => :destroy - 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 - validates_associated :repository, :wiki - validates_format_of :name, :with => /^[\w\s\'\-]*$/i - - # returns latest created projects - # non public projects will be returned only if user is a member of those - def self.latest(user=nil, count=5) - find(:all, :limit => count, :conditions => visible_by(user), :order => "projects.created_on DESC") - end - - def self.visible_by(user=nil) - if user && !user.memberships.empty? - return ["projects.is_public = ? or projects.id IN (#{user.memberships.collect{|m| m.project_id}.join(',')})", true] - else - return ["projects.is_public = ?", true] - end - 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 children.size > 0 +# 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 => :destroy, :order => "versions.effective_date DESC, versions.name DESC" + has_many :members, :dependent => :delete_all, :include => :user, :conditions => "users.status=#{User::STATUS_ACTIVE}" + has_many :users, :through => :members + has_many :custom_values, :dependent => :delete_all, :as => :customized + has_many :issues, :dependent => :destroy, :order => "issues.created_on DESC", :include => [:status, :tracker] + has_many :queries, :dependent => :delete_all + has_many :documents, :dependent => :destroy + has_many :news, :dependent => :delete_all, :include => :author + has_many :issue_categories, :dependent => :delete_all, :order => "issue_categories.name" + has_one :repository, :dependent => :destroy + has_one :wiki, :dependent => :destroy + 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 + validates_associated :repository, :wiki + validates_format_of :name, :with => /^[\w\s\'\-]*$/i + + # returns latest created projects + # non public projects will be returned only if user is a member of those + def self.latest(user=nil, count=5) + find(:all, :limit => count, :conditions => visible_by(user), :order => "projects.created_on DESC") + end + + def self.visible_by(user=nil) + if user && !user.memberships.empty? + return ["projects.is_public = ? or projects.id IN (#{user.memberships.collect{|m| m.project_id}.join(',')})", true] + else + return ["projects.is_public = ?", true] + end + 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 children.size > 0 end end diff --git a/app/models/project_custom_field.rb b/app/models/project_custom_field.rb index baa53381..f0dab691 100644 --- a/app/models/project_custom_field.rb +++ b/app/models/project_custom_field.rb @@ -1,22 +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 +# 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 index d00a2b21..7798f3bc 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -1,33 +1,33 @@ -# 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 => :delete_all - has_many :members - acts_as_list - - validates_presence_of :name - validates_uniqueness_of :name - validates_format_of :name, :with => /^[\w\s\'\-]*$/i - -private - def check_integrity - raise "Can't delete role" if Member.find(:first, :conditions =>["role_id=?", self.id]) +# 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 => :delete_all + has_many :members + acts_as_list + + validates_presence_of :name + validates_uniqueness_of :name + validates_format_of :name, :with => /^[\w\s\'\-]*$/i + +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/svn_repos.rb b/app/models/svn_repos.rb index aed9f1b5..3ed81403 100644 --- a/app/models/svn_repos.rb +++ b/app/models/svn_repos.rb @@ -1,216 +1,216 @@ -# 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 'rexml/document' - -module SvnRepos - - class CommandFailed < StandardError #:nodoc: - end - - class Base - - def initialize(url, login=nil, password=nil) - @url = url - @login = login if login && !login.empty? - @password = (password || "") if @login - end - - # Returns the entry identified by path and revision identifier - # or nil if entry doesn't exist in the repository - def entry(path=nil, identifier=nil) - e = entries(path, identifier) - e ? e.first : nil - end - - # Returns an Entries collection - # or nil if the given path doesn't exist in the repository - def entries(path=nil, identifier=nil) - path ||= '' - identifier = 'HEAD' unless identifier and identifier > 0 - entries = Entries.new - cmd = "svn list --xml #{target(path)}@#{identifier}" - cmd << " --username #{@login} --password #{@password}" if @login - shellout(cmd) do |io| - begin - doc = REXML::Document.new(io) - doc.elements.each("lists/list/entry") do |entry| - entries << Entry.new({:name => entry.elements['name'].text, - :path => ((path.empty? ? "" : "#{path}/") + entry.elements['name'].text), - :kind => entry.attributes['kind'], - :size => (entry.elements['size'] and entry.elements['size'].text).to_i, - :lastrev => Revision.new({ - :identifier => entry.elements['commit'].attributes['revision'], - :time => Time.parse(entry.elements['commit'].elements['date'].text), - :author => (entry.elements['commit'].elements['author'] ? entry.elements['commit'].elements['author'].text : "anonymous") - }) - }) - end - rescue - end - end - return nil if $? && $?.exitstatus != 0 - entries.sort_by_name - rescue Errno::ENOENT => e - raise CommandFailed - end - - def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={}) - path ||= '' - identifier_from = 'HEAD' unless identifier_from and identifier_from.to_i > 0 - identifier_to = 1 unless identifier_to and identifier_to.to_i > 0 - revisions = Revisions.new - cmd = "svn log --xml -r #{identifier_from}:#{identifier_to}" - cmd << " --username #{@login} --password #{@password}" if @login - cmd << " --verbose " if options[:with_paths] - cmd << target(path) - shellout(cmd) do |io| - begin - doc = REXML::Document.new(io) - doc.elements.each("log/logentry") do |logentry| - paths = [] - logentry.elements.each("paths/path") do |path| - paths << {:action => path.attributes['action'], - :path => path.text - } - end - paths.sort! { |x,y| x[:path] <=> y[:path] } - - revisions << Revision.new({:identifier => logentry.attributes['revision'], - :author => (logentry.elements['author'] ? logentry.elements['author'].text : "anonymous"), - :time => Time.parse(logentry.elements['date'].text), - :message => logentry.elements['msg'].text, - :paths => paths - }) - end - rescue - end - end - return nil if $? && $?.exitstatus != 0 - revisions - rescue Errno::ENOENT => e - raise CommandFailed - end - - def diff(path, identifier_from, identifier_to=nil) - path ||= '' - if identifier_to and identifier_to.to_i > 0 - identifier_to = identifier_to.to_i - else - identifier_to = identifier_from.to_i - 1 - end - cmd = "svn diff -r " - cmd << "#{identifier_to}:" - cmd << "#{identifier_from}" - cmd << "#{target(path)}@#{identifier_from}" - cmd << " --username #{@login} --password #{@password}" if @login - diff = [] - shellout(cmd) do |io| - io.each_line do |line| - diff << line - end - end - return nil if $? && $?.exitstatus != 0 - diff - rescue Errno::ENOENT => e - raise CommandFailed - end - - def cat(path, identifier=nil) - identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD" - cmd = "svn cat #{target(path)}@#{identifier}" - cmd << " --username #{@login} --password #{@password}" if @login - cat = nil - shellout(cmd) do |io| - cat = io.read - end - return nil if $? && $?.exitstatus != 0 - cat - rescue Errno::ENOENT => e - raise CommandFailed - end - - private - def target(path) - " \"" << "#{@url}/#{path}".gsub(/["'?<>\*]/, '') << "\"" - end - - def logger - RAILS_DEFAULT_LOGGER - end - - def shellout(cmd, &block) - logger.debug "Shelling out: #{cmd}" if logger && logger.debug? - IO.popen(cmd, "r+") do |io| - io.close_write - block.call(io) if block_given? - end - end - end - - class Entries < Array - def sort_by_name - sort {|x,y| - if x.kind == y.kind - x.name <=> y.name - else - x.kind <=> y.kind - end - } - end - - def revisions - revisions ||= Revisions.new(collect{|entry| entry.lastrev}) - end - end - - class Entry - attr_accessor :name, :path, :kind, :size, :lastrev - def initialize(attributes={}) - self.name = attributes[:name] if attributes[:name] - self.path = attributes[:path] if attributes[:path] - self.kind = attributes[:kind] if attributes[:kind] - self.size = attributes[:size].to_i if attributes[:size] - self.lastrev = attributes[:lastrev] - end - - def is_file? - 'file' == self.kind - end - - def is_dir? - 'dir' == self.kind - end - end - - class Revisions < Array - def latest - sort {|x,y| x.time <=> y.time}.last - end - end - - class Revision - attr_accessor :identifier, :author, :time, :message, :paths - def initialize(attributes={}) - self.identifier = attributes[:identifier] - self.author = attributes[:author] - self.time = attributes[:time] - self.message = attributes[:message] || "" - self.paths = attributes[:paths] - end - end +# 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 'rexml/document' + +module SvnRepos + + class CommandFailed < StandardError #:nodoc: + end + + class Base + + def initialize(url, login=nil, password=nil) + @url = url + @login = login if login && !login.empty? + @password = (password || "") if @login + end + + # Returns the entry identified by path and revision identifier + # or nil if entry doesn't exist in the repository + def entry(path=nil, identifier=nil) + e = entries(path, identifier) + e ? e.first : nil + end + + # Returns an Entries collection + # or nil if the given path doesn't exist in the repository + def entries(path=nil, identifier=nil) + path ||= '' + identifier = 'HEAD' unless identifier and identifier > 0 + entries = Entries.new + cmd = "svn list --xml #{target(path)}@#{identifier}" + cmd << " --username #{@login} --password #{@password}" if @login + shellout(cmd) do |io| + begin + doc = REXML::Document.new(io) + doc.elements.each("lists/list/entry") do |entry| + entries << Entry.new({:name => entry.elements['name'].text, + :path => ((path.empty? ? "" : "#{path}/") + entry.elements['name'].text), + :kind => entry.attributes['kind'], + :size => (entry.elements['size'] and entry.elements['size'].text).to_i, + :lastrev => Revision.new({ + :identifier => entry.elements['commit'].attributes['revision'], + :time => Time.parse(entry.elements['commit'].elements['date'].text), + :author => (entry.elements['commit'].elements['author'] ? entry.elements['commit'].elements['author'].text : "anonymous") + }) + }) + end + rescue + end + end + return nil if $? && $?.exitstatus != 0 + entries.sort_by_name + rescue Errno::ENOENT => e + raise CommandFailed + end + + def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={}) + path ||= '' + identifier_from = 'HEAD' unless identifier_from and identifier_from.to_i > 0 + identifier_to = 1 unless identifier_to and identifier_to.to_i > 0 + revisions = Revisions.new + cmd = "svn log --xml -r #{identifier_from}:#{identifier_to}" + cmd << " --username #{@login} --password #{@password}" if @login + cmd << " --verbose " if options[:with_paths] + cmd << target(path) + shellout(cmd) do |io| + begin + doc = REXML::Document.new(io) + doc.elements.each("log/logentry") do |logentry| + paths = [] + logentry.elements.each("paths/path") do |path| + paths << {:action => path.attributes['action'], + :path => path.text + } + end + paths.sort! { |x,y| x[:path] <=> y[:path] } + + revisions << Revision.new({:identifier => logentry.attributes['revision'], + :author => (logentry.elements['author'] ? logentry.elements['author'].text : "anonymous"), + :time => Time.parse(logentry.elements['date'].text), + :message => logentry.elements['msg'].text, + :paths => paths + }) + end + rescue + end + end + return nil if $? && $?.exitstatus != 0 + revisions + rescue Errno::ENOENT => e + raise CommandFailed + end + + def diff(path, identifier_from, identifier_to=nil) + path ||= '' + if identifier_to and identifier_to.to_i > 0 + identifier_to = identifier_to.to_i + else + identifier_to = identifier_from.to_i - 1 + end + cmd = "svn diff -r " + cmd << "#{identifier_to}:" + cmd << "#{identifier_from}" + cmd << "#{target(path)}@#{identifier_from}" + cmd << " --username #{@login} --password #{@password}" if @login + diff = [] + shellout(cmd) do |io| + io.each_line do |line| + diff << line + end + end + return nil if $? && $?.exitstatus != 0 + diff + rescue Errno::ENOENT => e + raise CommandFailed + end + + def cat(path, identifier=nil) + identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD" + cmd = "svn cat #{target(path)}@#{identifier}" + cmd << " --username #{@login} --password #{@password}" if @login + cat = nil + shellout(cmd) do |io| + cat = io.read + end + return nil if $? && $?.exitstatus != 0 + cat + rescue Errno::ENOENT => e + raise CommandFailed + end + + private + def target(path) + " \"" << "#{@url}/#{path}".gsub(/["'?<>\*]/, '') << "\"" + end + + def logger + RAILS_DEFAULT_LOGGER + end + + def shellout(cmd, &block) + logger.debug "Shelling out: #{cmd}" if logger && logger.debug? + IO.popen(cmd, "r+") do |io| + io.close_write + block.call(io) if block_given? + end + end + end + + class Entries < Array + def sort_by_name + sort {|x,y| + if x.kind == y.kind + x.name <=> y.name + else + x.kind <=> y.kind + end + } + end + + def revisions + revisions ||= Revisions.new(collect{|entry| entry.lastrev}) + end + end + + class Entry + attr_accessor :name, :path, :kind, :size, :lastrev + def initialize(attributes={}) + self.name = attributes[:name] if attributes[:name] + self.path = attributes[:path] if attributes[:path] + self.kind = attributes[:kind] if attributes[:kind] + self.size = attributes[:size].to_i if attributes[:size] + self.lastrev = attributes[:lastrev] + end + + def is_file? + 'file' == self.kind + end + + def is_dir? + 'dir' == self.kind + end + end + + class Revisions < Array + def latest + sort {|x,y| x.time <=> y.time}.last + end + end + + class Revision + attr_accessor :identifier, :author, :time, :message, :paths + def initialize(attributes={}) + self.identifier = attributes[:identifier] + self.author = attributes[:author] + self.time = attributes[:time] + self.message = attributes[:message] || "" + self.paths = attributes[:paths] + end + end end \ No newline at end of file diff --git a/app/models/tracker.rb b/app/models/tracker.rb index b584704c..51ae73d1 100644 --- a/app/models/tracker.rb +++ b/app/models/tracker.rb @@ -1,33 +1,33 @@ -# 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 => :delete_all - has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => 'custom_fields_trackers', :association_foreign_key => 'custom_field_id' - acts_as_list - - validates_presence_of :name - validates_uniqueness_of :name - validates_format_of :name, :with => /^[\w\s\'\-]*$/i - -private - def check_integrity - raise "Can't delete tracker" if Issue.find(:first, :conditions => ["tracker_id=?", self.id]) +# 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 => :delete_all + has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => 'custom_fields_trackers', :association_foreign_key => 'custom_field_id' + acts_as_list + + validates_presence_of :name + validates_uniqueness_of :name + validates_format_of :name, :with => /^[\w\s\'\-]*$/i + +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 index bf2930a0..3a315239 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,142 +1,142 @@ -# redMine - project management software -# Copyright (C) 2006-2007 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 => :delete_all - has_many :projects, :through => :memberships - has_many :custom_values, :dependent => :delete_all, :as => :customized - has_one :preference, :dependent => :destroy, :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 :firstname, :lastname, :with => /^[\w\s\'\-]*$/i - 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 - - def self.active - with_scope :find => { :conditions => [ "status = ?", STATUS_ACTIVE ] } do - yield - end - end - - def self.find_active(*args) - active do - find(*args) - end - 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 = Setting.default_language - 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 || "") +# redMine - project management software +# Copyright (C) 2006-2007 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 => :delete_all + has_many :projects, :through => :memberships + has_many :custom_values, :dependent => :delete_all, :as => :customized + has_one :preference, :dependent => :destroy, :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 :firstname, :lastname, :with => /^[\w\s\'\-]*$/i + 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 + + def self.active + with_scope :find => { :conditions => [ "status = ?", STATUS_ACTIVE ] } do + yield + end + end + + def self.find_active(*args) + active do + find(*args) + end + 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 = Setting.default_language + 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 index 866234a7..99e76eea 100644 --- a/app/models/user_custom_field.rb +++ b/app/models/user_custom_field.rb @@ -1,23 +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 +# 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/version.rb b/app/models/version.rb index 71a8a880..611500c8 100644 --- a/app/models/version.rb +++ b/app/models/version.rb @@ -1,32 +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 => :destroy - - 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 +# 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 => :destroy + + 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 index 22c873fc..89322aa5 100644 --- a/app/models/workflow.rb +++ b/app/models/workflow.rb @@ -1,24 +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 +# 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 index 5a94cb1e..73f6fe49 100644 --- a/app/views/account/login.rhtml +++ b/app/views/account/login.rhtml @@ -1,24 +1,24 @@ -
-
\ No newline at end of file diff --git a/app/views/account/lost_password.rhtml b/app/views/account/lost_password.rhtml index ebc64e32..b27123a6 100644 --- a/app/views/account/lost_password.rhtml +++ b/app/views/account/lost_password.rhtml @@ -1,14 +1,14 @@ -
- +
+
\ No newline at end of file diff --git a/app/views/account/password_recovery.rhtml b/app/views/account/password_recovery.rhtml index 2aa58104..89b10529 100644 --- a/app/views/account/password_recovery.rhtml +++ b/app/views/account/password_recovery.rhtml @@ -1,21 +1,21 @@
\ No newline at end of file diff --git a/app/views/account/register.rhtml b/app/views/account/register.rhtml index ac16c3b4..ef9a12ac 100644 --- a/app/views/account/register.rhtml +++ b/app/views/account/register.rhtml @@ -7,7 +7,7 @@

<%= text_field 'user', 'login', :size => 25 %>

- +

<%= password_field_tag 'password', nil, :size => 25 %>

@@ -16,22 +16,22 @@

<%= text_field 'user', 'firstname' %>

- +

<%= text_field 'user', 'lastname' %>

-<%= text_field 'user', 'mail' %>

- +<%= text_field 'user', 'mail' %>

+

-<%= select("user", "language", lang_options_for_select) %>

- +<%= select("user", "language", lang_options_for_select) %>

+ <% for @custom_value in @custom_values %>

<%= custom_field_tag_with_label @custom_value %>

-<% end %> - +<% end %> +

-<%= check_box 'user', 'mail_notification' %>

+<%= check_box 'user', 'mail_notification' %>

diff --git a/app/views/account/show.rhtml b/app/views/account/show.rhtml index c686b709..19fedb3b 100644 --- a/app/views/account/show.rhtml +++ b/app/views/account/show.rhtml @@ -1,26 +1,26 @@ -

<%= @user.display_name %>

- -

-<%= mail_to @user.mail unless @user.pref.hide_mail %> -

-

- -

<%=l(:label_project_plural)%>

-

-<% for membership in @user.memberships %> - <%= membership.project.name %> (<%= membership.role.name %>, <%= format_date(membership.created_on) %>) -
-<% end %> -

- -

<%=l(:label_activity)%>

-

-<%=l(:label_reported_issues)%>: <%= Issue.count(["author_id=?", @user.id]) %> +

<%= @user.display_name %>

+ +

+<%= mail_to @user.mail unless @user.pref.hide_mail %> +

+

+ +

<%=l(:label_project_plural)%>

+

+<% for membership in @user.memberships %> + <%= membership.project.name %> (<%= membership.role.name %>, <%= format_date(membership.created_on) %>) +
+<% end %> +

+ +

<%=l(:label_activity)%>

+

+<%=l(:label_reported_issues)%>: <%= Issue.count(["author_id=?", @user.id]) %>

\ No newline at end of file diff --git a/app/views/admin/index.rhtml b/app/views/admin/index.rhtml index 535a90b5..02eb5ae8 100644 --- a/app/views/admin/index.rhtml +++ b/app/views/admin/index.rhtml @@ -1,45 +1,45 @@ -

<%=l(:label_administration)%>

- -

-<%= link_to l(:label_project_plural), :controller => 'admin', :action => 'projects' %> | -<%= link_to l(:label_new), :controller => 'projects', :action => 'add' %> -

- -

-<%= link_to l(:label_user_plural), :controller => 'users' %> | -<%= link_to l(:label_new), :controller => 'users', :action => 'add' %> -

- -

-<%= link_to l(:label_role_and_permissions), :controller => 'roles' %> -

- -

-<%= link_to l(:label_tracker_plural), :controller => 'trackers' %> | -<%= link_to l(:label_issue_status_plural), :controller => 'issue_statuses' %> | -<%= link_to l(:label_workflow), :controller => 'roles', :action => 'workflow' %> -

- -

-<%= link_to l(:label_custom_field_plural), :controller => 'custom_fields' %> -

- -

-<%= link_to l(:label_enumerations), :controller => 'enumerations' %> -

- -

-<%= link_to l(:field_mail_notification), :controller => 'admin', :action => 'mail_options' %> -

- -

-<%= link_to l(:label_authentication), :controller => 'auth_sources' %> -

- -

-<%= link_to l(:label_settings), :controller => 'settings' %> -

- -

-<%= link_to l(:label_information_plural), :controller => 'admin', :action => 'info' %> +

<%=l(:label_administration)%>

+ +

+<%= link_to l(:label_project_plural), :controller => 'admin', :action => 'projects' %> | +<%= link_to l(:label_new), :controller => 'projects', :action => 'add' %> +

+ +

+<%= link_to l(:label_user_plural), :controller => 'users' %> | +<%= link_to l(:label_new), :controller => 'users', :action => 'add' %> +

+ +

+<%= link_to l(:label_role_and_permissions), :controller => 'roles' %> +

+ +

+<%= link_to l(:label_tracker_plural), :controller => 'trackers' %> | +<%= link_to l(:label_issue_status_plural), :controller => 'issue_statuses' %> | +<%= link_to l(:label_workflow), :controller => 'roles', :action => 'workflow' %> +

+ +

+<%= link_to l(:label_custom_field_plural), :controller => 'custom_fields' %> +

+ +

+<%= link_to l(:label_enumerations), :controller => 'enumerations' %> +

+ +

+<%= link_to l(:field_mail_notification), :controller => 'admin', :action => 'mail_options' %> +

+ +

+<%= link_to l(:label_authentication), :controller => 'auth_sources' %> +

+ +

+<%= link_to l(:label_settings), :controller => 'settings' %> +

+ +

+<%= link_to l(:label_information_plural), :controller => 'admin', :action => 'info' %>

\ No newline at end of file diff --git a/app/views/admin/info.rhtml b/app/views/admin/info.rhtml index b9f50af4..2ea692c7 100644 --- a/app/views/admin/info.rhtml +++ b/app/views/admin/info.rhtml @@ -1,3 +1,3 @@ -

<%=l(:label_information_plural)%>

- +

<%=l(:label_information_plural)%>

+

<%=l(:field_version)%>: redMine <%= Redmine::VERSION %> (<%= @db_adapter_name %>)

\ No newline at end of file diff --git a/app/views/admin/mail_options.rhtml b/app/views/admin/mail_options.rhtml index 590c75b3..8fd5de7e 100644 --- a/app/views/admin/mail_options.rhtml +++ b/app/views/admin/mail_options.rhtml @@ -1,25 +1,25 @@ -

<%=l(:field_mail_notification)%>

- -<% form_tag ({:action => 'mail_options'}, :id => 'mail_options_form') do %> - -
-

<%=l(:text_select_mail_notifications)%>

- -<% actions = @actions.group_by {|p| p.group_id } %> -<% actions.keys.sort.each do |group_id| %> -
<%= l(Permission::GROUPS[group_id]) %> -<% actions[group_id].each do |p| %> -
<%= check_box_tag "action_ids[]", p.id, p.mail_enabled? %> - <%= l(p.description.to_sym) %> -
-<% end %> -
-
-<% end %> - -
-

<%= check_all_links 'mail_options_form' %>

-
- -<%= submit_tag l(:button_save) %> -<% end %> +

<%=l(:field_mail_notification)%>

+ +<% form_tag ({:action => 'mail_options'}, :id => 'mail_options_form') do %> + +
+

<%=l(:text_select_mail_notifications)%>

+ +<% actions = @actions.group_by {|p| p.group_id } %> +<% actions.keys.sort.each do |group_id| %> +
<%= l(Permission::GROUPS[group_id]) %> +<% actions[group_id].each do |p| %> +
<%= check_box_tag "action_ids[]", p.id, p.mail_enabled? %> + <%= l(p.description.to_sym) %> +
+<% end %> +
+
+<% end %> + +
+

<%= check_all_links 'mail_options_form' %>

+
+ +<%= submit_tag l(:button_save) %> +<% end %> diff --git a/app/views/admin/projects.rhtml b/app/views/admin/projects.rhtml index cf7c0607..9c0595eb 100644 --- a/app/views/admin/projects.rhtml +++ b/app/views/admin/projects.rhtml @@ -6,24 +6,24 @@ - <%= sort_header_tag('name', :caption => l(:label_project)) %> - + <%= sort_header_tag('name', :caption => l(:label_project)) %> + - - <%= sort_header_tag('created_on', :caption => l(:field_created_on)) %> + + <%= sort_header_tag('created_on', :caption => l(:field_created_on)) %> <% for project in @projects %> - "> - "> + + <%= button_to l(:button_delete), { :controller => 'projects', :action => 'destroy', :id => project }, :class => "button-small" %> + <% end %> diff --git a/app/views/common/404.rhtml b/app/views/common/404.rhtml index a81eeba0..a1a11c32 100644 --- a/app/views/common/404.rhtml +++ b/app/views/common/404.rhtml @@ -1,4 +1,4 @@ -

404

- -

<%= l(:notice_file_not_found) %>

-

Back

+

404

+ +

<%= l(:notice_file_not_found) %>

+

Back

diff --git a/app/views/custom_fields/_form.rhtml b/app/views/custom_fields/_form.rhtml index 36be6259..42727644 100644 --- a/app/views/custom_fields/_form.rhtml +++ b/app/views/custom_fields/_form.rhtml @@ -57,30 +57,30 @@ function deleteValueField(e) {

<%= f.text_field :name, :required => true %>

-

<%= f.select :field_format, custom_field_formats_for_select, {}, :onchange => "toggle_custom_field_format();" %>

+

<%= f.select :field_format, custom_field_formats_for_select, {}, :onchange => "toggle_custom_field_format();" %>

<%= f.text_field :min_length, :size => 5, :no_label => true %> - <%= f.text_field :max_length, :size => 5, :no_label => true %>
(<%=l(:text_min_max_length_info)%>)

-

<%= f.text_field :regexp, :size => 50 %>
(<%=l(:text_regexp_info)%>)

+

<%= f.text_field :regexp, :size => 50 %>
(<%=l(:text_regexp_info)%>)

<% (@custom_field.possible_values.to_a + [""]).each do |value| %> <%= text_field_tag 'custom_field[possible_values][]', value, :size => 30 %> <%= image_to_function "delete.png", "deleteValueField(this);return false" %>
<% end %>

-
+ <%= javascript_tag "toggle_custom_field_format();" %>
<% case @custom_field.type.to_s -when "IssueCustomField" %> - -
<%=l(:label_tracker_plural)%> +when "IssueCustomField" %> + +
<%=l(:label_tracker_plural)%> <% for tracker in @trackers %> - <%= check_box_tag "tracker_ids[]", tracker.id, (@custom_field.trackers.include? tracker) %> <%= tracker.name %> + <%= check_box_tag "tracker_ids[]", tracker.id, (@custom_field.trackers.include? tracker) %> <%= tracker.name %> <% end %> -
+
 

<%= f.check_box :is_required %>

<%= f.check_box :is_for_all %>

diff --git a/app/views/custom_fields/list.rhtml b/app/views/custom_fields/list.rhtml index 76637c8d..b6f1f278 100644 --- a/app/views/custom_fields/list.rhtml +++ b/app/views/custom_fields/list.rhtml @@ -6,29 +6,29 @@
  • <%= link_to l(:label_project_plural), {}, :id=> "tab-ProjectCustomField", :onclick => "showTab('ProjectCustomField'); this.blur(); return false;" %>
  • <%= link_to l(:label_user_plural), {}, :id=> "tab-UserCustomField", :onclick => "showTab('UserCustomField'); this.blur(); return false;" %>
  • -
    + <% %w(IssueCustomField ProjectCustomField UserCustomField).each do |type| %>
    -
    <%=l(:field_description)%><%=l(:field_description)%> <%=l(:field_is_public)%><%=l(:label_subproject_plural)%><%=l(:label_subproject_plural)%>
    <%= link_to project.name, :controller => 'projects', :action => 'settings', :id => project %> - <%=h project.description %> +
    <%= link_to project.name, :controller => 'projects', :action => 'settings', :id => project %> + <%=h project.description %> <%= image_tag 'true.png' if project.is_public? %> - <%= project.children.size %> - <%= format_date(project.created_on) %> + <%= project.children.size %> + <%= format_date(project.created_on) %> - <%= button_to l(:button_delete), { :controller => 'projects', :action => 'destroy', :id => project }, :class => "button-small" %> -
    +
    - - + + - <% if type == 'IssueCustomField' %> - + <% if type == 'IssueCustomField' %> + - <% end %> - + <% end %> + <% for custom_field in (@custom_fields_by_type[type] || []) %> - "> + "> - + - <% if type == 'IssueCustomField' %> - + <% if type == 'IssueCustomField' %> + <% end %>
    <%=l(:field_name)%><%=l(:field_field_format)%><%=l(:field_name)%><%=l(:field_field_format)%> <%=l(:field_is_required)%><%=l(:field_is_for_all)%><%=l(:field_is_for_all)%> <%=l(:label_used_by)%>
    <%= link_to custom_field.name, :action => 'edit', :id => custom_field %><%= l(CustomField::FIELD_FORMATS[custom_field.field_format][:name]) %><%= l(CustomField::FIELD_FORMATS[custom_field.field_format][:name]) %> <%= image_tag 'true.png' if custom_field.is_required? %><%= image_tag 'true.png' if custom_field.is_for_all? %><%= image_tag 'true.png' if custom_field.is_for_all? %> <%= 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? %> diff --git a/app/views/documents/_document.rhtml b/app/views/documents/_document.rhtml index 81e039be..e1539b82 100644 --- a/app/views/documents/_document.rhtml +++ b/app/views/documents/_document.rhtml @@ -1,3 +1,3 @@ -

    <%= link_to h(document.title), :controller => 'documents', :action => 'show', :id => document %>
    -<% unless document.description.empty? %><%=h(truncate(document.description, 250)) %>
    <% end %> +

    <%= link_to h(document.title), :controller => 'documents', :action => 'show', :id => document %>
    +<% unless document.description.empty? %><%=h(truncate(document.description, 250)) %>
    <% end %> <%= format_time(document.created_on) %>

    \ No newline at end of file diff --git a/app/views/documents/_form.rhtml b/app/views/documents/_form.rhtml index 40bbdc66..bd6e6cc7 100644 --- a/app/views/documents/_form.rhtml +++ b/app/views/documents/_form.rhtml @@ -1,11 +1,11 @@ <%= error_messages_for 'document' %>
    -

    - <%= options_from_collection_for_select @categories, "id", "name", @document.category_id %> -

    - +

    +

    <%= text_field 'document', 'title', :size => 60 %>

    diff --git a/app/views/documents/show.rhtml b/app/views/documents/show.rhtml index 31595ab0..730cbbb1 100644 --- a/app/views/documents/show.rhtml +++ b/app/views/documents/show.rhtml @@ -1,37 +1,37 @@ -
    -<%= link_to_if_authorized l(:button_edit), {:controller => 'documents', :action => 'edit', :id => @document}, :class => 'icon icon-edit' %> -<%= link_to_if_authorized l(:button_delete), {:controller => 'documents', :action => 'destroy', :id => @document}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> -
    - -

    <%= @document.title %>

    - -

    <%= @document.category.name %>
    -<%= format_date @document.created_on %>

    -<%= textilizable @document.description %> -
    - -

    <%= l(:label_attachment_plural) %>

    +
    +<%= link_to_if_authorized l(:button_edit), {:controller => 'documents', :action => 'edit', :id => @document}, :class => 'icon icon-edit' %> +<%= link_to_if_authorized l(:button_delete), {:controller => 'documents', :action => 'destroy', :id => @document}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> +
    + +

    <%= @document.title %>

    + +

    <%= @document.category.name %>
    +<%= format_date @document.created_on %>

    +<%= textilizable @document.description %> +
    + +

    <%= l(:label_attachment_plural) %>

      <% for attachment in @attachments %> -
    • -
      - <%= link_to_if_authorized l(:button_delete), {:controller => 'documents', :action => 'destroy_attachment', :id => @document, :attachment_id => attachment}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> -
      - <%= link_to attachment.filename, :action => 'download', :id => @document, :attachment_id => attachment %> - (<%= number_to_human_size attachment.filesize %>)
      +
    • +
      + <%= link_to_if_authorized l(:button_delete), {:controller => 'documents', :action => 'destroy_attachment', :id => @document, :attachment_id => attachment}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> +
      + <%= link_to attachment.filename, :action => 'download', :id => @document, :attachment_id => attachment %> + (<%= number_to_human_size attachment.filesize %>)
      <%= attachment.author.display_name %>, <%= format_date(attachment.created_on) %>
      - <%= lwr(:label_download, attachment.downloads) %> -
    • + <%= lwr(:label_download, attachment.downloads) %> + +<% end %> +
    +
    + + +<% if authorize_for('documents', 'add_attachment') %> + <% form_tag ({ :controller => 'documents', :action => 'add_attachment', :id => @document }, :multipart => true, :class => "tabular") do %> +

    + <%= file_field_tag 'attachments[]', :size => 30 %> (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)

    + <%= submit_tag l(:button_add) %> + <% end %> <% end %> - -
    - - -<% if authorize_for('documents', 'add_attachment') %> - <% form_tag ({ :controller => 'documents', :action => 'add_attachment', :id => @document }, :multipart => true, :class => "tabular") do %> -

    - <%= file_field_tag 'attachments[]', :size => 30 %> (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)

    - <%= submit_tag l(:button_add) %> - <% end %> -<% end %> diff --git a/app/views/enumerations/list.rhtml b/app/views/enumerations/list.rhtml index 18508125..f7756ce3 100644 --- a/app/views/enumerations/list.rhtml +++ b/app/views/enumerations/list.rhtml @@ -1,19 +1,19 @@

    <%=l(:label_enumerations)%>

      -<% Enumeration::OPTIONS.each do |option, name| %> - - <% if params[:opt]==option %> - -

    <%= l(name) %>

    -
      - <% for value in Enumeration.find(:all, :conditions => ["opt = ?", option]) %> -
    • <%= link_to value.name, :action => 'edit', :id => value %>
    • - <% end %> -
    -

    <%= link_to l(:label_enumeration_new), { :action => 'new', :opt => option }, :class => "icon icon-add" %>

      - - <% else %> -

    <%= link_to l(name), :opt => option %>

    - <% end %> - +<% Enumeration::OPTIONS.each do |option, name| %> + + <% if params[:opt]==option %> + +

    <%= l(name) %>

    +
      + <% for value in Enumeration.find(:all, :conditions => ["opt = ?", option]) %> +
    • <%= link_to value.name, :action => 'edit', :id => value %>
    • + <% end %> +
    +

    <%= link_to l(:label_enumeration_new), { :action => 'new', :opt => option }, :class => "icon icon-add" %>

      + + <% else %> +

    <%= link_to l(name), :opt => option %>

    + <% end %> + <% end %> \ No newline at end of file diff --git a/app/views/issue_statuses/_form.rhtml b/app/views/issue_statuses/_form.rhtml index f3b1cf2c..7f6dc5be 100644 --- a/app/views/issue_statuses/_form.rhtml +++ b/app/views/issue_statuses/_form.rhtml @@ -6,13 +6,13 @@ <%= text_field 'issue_status', 'name' %>

    -<%= check_box 'issue_status', 'is_closed' %>

    - +<%= check_box 'issue_status', 'is_closed' %>

    +

    -<%= check_box 'issue_status', 'is_default' %>

    - +<%= check_box 'issue_status', 'is_default' %>

    +

    -#<%= text_field 'issue_status', 'html_color', :maxlength => 6 %>

    +#<%= text_field 'issue_status', 'html_color', :maxlength => 6 %>

    \ No newline at end of file diff --git a/app/views/issue_statuses/list.rhtml b/app/views/issue_statuses/list.rhtml index 01617c32..973cc9c7 100644 --- a/app/views/issue_statuses/list.rhtml +++ b/app/views/issue_statuses/list.rhtml @@ -6,18 +6,18 @@ - - - + + + <% for status in @issue_statuses %> "> - - - + + + <% end %>
    <%=l(:field_status)%><%=l(:field_is_default)%><%=l(:field_is_closed)%><%=l(:field_status)%><%=l(:field_is_default)%><%=l(:field_is_closed)%> <%=l(:button_sort)%>
    <%= link_to status.name, :action => 'edit', :id => status %>
    <%= image_tag 'true.png' if status.is_default? %><%= image_tag 'true.png' if status.is_closed? %>
    <%= link_to status.name, :action => 'edit', :id => status %>
    <%= image_tag 'true.png' if status.is_default? %><%= image_tag 'true.png' if status.is_closed? %> <%= link_to image_tag('2uparrow.png', :alt => l(:label_sort_highest)), {:action => 'move', :id => status, :position => 'highest'}, :method => :post, :title => l(:label_sort_highest) %> <%= link_to image_tag('1uparrow.png', :alt => l(:label_sort_higher)), {:action => 'move', :id => status, :position => 'higher'}, :method => :post, :title => l(:label_sort_higher) %> - @@ -25,11 +25,11 @@ <%= link_to image_tag('2downarrow.png', :alt => l(:label_sort_lowest)), {:action => 'move', :id => status, :position => 'lowest'}, :method => :post, :title => l(:label_sort_lowest) %> - <%= button_to l(:button_delete), { :action => 'destroy', :id => status }, :confirm => l(:text_are_you_sure), :class => "button-small" %> + <%= button_to l(:button_delete), { :action => 'destroy', :id => status }, :confirm => l(:text_are_you_sure), :class => "button-small" %>
    - + <%= pagination_links_full @issue_status_pages %> \ No newline at end of file diff --git a/app/views/issues/_add_shortcut.rhtml b/app/views/issues/_add_shortcut.rhtml index 7cd3114c..c6a5a466 100644 --- a/app/views/issues/_add_shortcut.rhtml +++ b/app/views/issues/_add_shortcut.rhtml @@ -1,5 +1,5 @@ -<% if authorize_for('projects', 'add_issue') %> -<% form_tag({ :controller => 'projects', :action => 'add_issue', :id => @project }, :method => 'get') do %> -<%= l(:label_issue_new) %>: <%= select_tag 'tracker_id', ("" + options_from_collection_for_select(trackers, 'id', 'name')), :onchange => "if (this.value!='') {this.form.submit();}" %> -<% end %> -<% end %> +<% if authorize_for('projects', 'add_issue') %> +<% form_tag({ :controller => 'projects', :action => 'add_issue', :id => @project }, :method => 'get') do %> +<%= l(:label_issue_new) %>: <%= select_tag 'tracker_id', ("" + options_from_collection_for_select(trackers, 'id', 'name')), :onchange => "if (this.value!='') {this.form.submit();}" %> +<% end %> +<% end %> diff --git a/app/views/issues/_history.rhtml b/app/views/issues/_history.rhtml index 37faf977..cc02eee4 100644 --- a/app/views/issues/_history.rhtml +++ b/app/views/issues/_history.rhtml @@ -1,11 +1,11 @@ -<% for journal in journals %> -

    <%= format_time(journal.created_on) %> - <%= journal.user.name %>

    -
      - <% for detail in journal.details %> -
    • <%= show_detail(detail) %>
    • - <% end %> -
    - <% if journal.notes? %> - <%= textilizable journal.notes %> - <% end %> -<% end %> +<% for journal in journals %> +

    <%= format_time(journal.created_on) %> - <%= journal.user.name %>

    +
      + <% for detail in journal.details %> +
    • <%= show_detail(detail) %>
    • + <% end %> +
    + <% if journal.notes? %> + <%= textilizable journal.notes %> + <% end %> +<% end %> diff --git a/app/views/issues/_list_simple.rhtml b/app/views/issues/_list_simple.rhtml index 10d880f4..0e3c39bb 100644 --- a/app/views/issues/_list_simple.rhtml +++ b/app/views/issues/_list_simple.rhtml @@ -1,25 +1,25 @@ -<% if issues.length > 0 %> - - - - - - - +<% if issues.length > 0 %> +
    #<%=l(:field_tracker)%><%=l(:field_subject)%>
    + + + + + + <% for issue in issues %> - "> - + "> + - + - <% end %> + <% end %> -
    #<%=l(:field_tracker)%><%=l(:field_subject)%>
    - <%= link_to issue.id, :controller => 'issues', :action => 'show', :id => issue %> -
    + <%= link_to issue.id, :controller => 'issues', :action => 'show', :id => issue %> +

    <%= issue.project.name %> - <%= issue.tracker.name %>
    - <%= issue.status.name %> - <%= format_time(issue.updated_on) %>

    -

    <%= link_to h(issue.subject), :controller => 'issues', :action => 'show', :id => issue %>

    + <%= issue.status.name %> - <%= format_time(issue.updated_on) %>

    +

    <%= link_to h(issue.subject), :controller => 'issues', :action => 'show', :id => issue %>

    -<% else %> - <%=l(:label_no_data)%> +
    +<% else %> + <%=l(:label_no_data)%> <% end %> \ No newline at end of file diff --git a/app/views/issues/_tooltip.rhtml b/app/views/issues/_tooltip.rhtml index d7b555e4..d186322c 100644 --- a/app/views/issues/_tooltip.rhtml +++ b/app/views/issues/_tooltip.rhtml @@ -1,6 +1,6 @@ -<%= link_to "#{issue.tracker.name} ##{issue.id}", { :controller => 'issues', :action => 'show', :id => issue } %>: <%=h issue.subject %>
    -
    -<%= l(:field_start_date) %>: <%= format_date(issue.start_date) %>
    -<%= l(:field_due_date) %>: <%= format_date(issue.due_date) %>
    -<%= l(:field_assigned_to) %>: <%= issue.assigned_to ? issue.assigned_to.name : "-" %>
    -<%= l(:field_priority) %>: <%= issue.priority.name %> +<%= link_to "#{issue.tracker.name} ##{issue.id}", { :controller => 'issues', :action => 'show', :id => issue } %>: <%=h issue.subject %>
    +
    +<%= l(:field_start_date) %>: <%= format_date(issue.start_date) %>
    +<%= l(:field_due_date) %>: <%= format_date(issue.due_date) %>
    +<%= l(:field_assigned_to) %>: <%= issue.assigned_to ? issue.assigned_to.name : "-" %>
    +<%= l(:field_priority) %>: <%= issue.priority.name %> diff --git a/app/views/issues/change_status.rhtml b/app/views/issues/change_status.rhtml index 377e0da2..61e2fad2 100644 --- a/app/views/issues/change_status.rhtml +++ b/app/views/issues/change_status.rhtml @@ -1,37 +1,37 @@

    <%=l(:label_issue)%> #<%= @issue.id %>: <%=h @issue.subject %>

    - -<%= error_messages_for 'issue' %> -<% form_tag({:action => 'change_status', :id => @issue}, :class => "tabular") do %> - -<%= hidden_field_tag 'confirm', 1 %> + +<%= error_messages_for 'issue' %> +<% form_tag({:action => 'change_status', :id => @issue}, :class => "tabular") do %> + +<%= hidden_field_tag 'confirm', 1 %> <%= hidden_field_tag 'new_status_id', @new_status.id %> -
    -

    <%= @new_status.name %>

    - +
    +

    <%= @new_status.name %>

    +

    - + <%= options_from_collection_for_select @assignable_to, "id", "display_name", @issue.assigned_to_id %>

    -

    +

    <%= select("issue", "done_ratio", ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) ) %>

    - +

    - + +<%= options_from_collection_for_select @issue.project.versions, "id", "name", @issue.fixed_version_id %>

    <%= text_area_tag 'notes', @notes, :cols => 60, :rows => 10, :class => 'wiki-edit' %>

    - + <%= hidden_field 'issue', 'lock_version' %> -<%= submit_tag l(:button_save) %> -<% end %> +<%= submit_tag l(:button_save) %> +<% end %> diff --git a/app/views/issues/history.rhtml b/app/views/issues/history.rhtml index 2443cc73..830e1fc8 100644 --- a/app/views/issues/history.rhtml +++ b/app/views/issues/history.rhtml @@ -1,6 +1,6 @@ -

    <%=l(:label_history)%>

    -
    -<%= render :partial => 'history', :locals => { :journals => @journals } %> -
    -
    +

    <%=l(:label_history)%>

    +
    +<%= render :partial => 'history', :locals => { :journals => @journals } %> +
    +

    <%= link_to l(:button_back), :action => 'show', :id => @issue %>

    \ No newline at end of file diff --git a/app/views/issues/show.rhtml b/app/views/issues/show.rhtml index 442c30ab..43e959c1 100644 --- a/app/views/issues/show.rhtml +++ b/app/views/issues/show.rhtml @@ -1,111 +1,111 @@ -
    -<%= l(:label_export_to) %><%= link_to 'PDF', {:action => 'export_pdf', :id => @issue}, :class => 'icon icon-pdf' %> -
    - -

    <%= @issue.tracker.name %> #<%= @issue.id %> - <%=h @issue.subject %>

    +
    +<%= l(:label_export_to) %><%= link_to 'PDF', {:action => 'export_pdf', :id => @issue}, :class => 'icon icon-pdf' %> +
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - -<% n = 0 -for custom_value in @custom_values %> - -<% n = n + 1 - if (n > 1) - n = 0 %> - - <%end -end %> - -
    <%=l(:field_status)%> :<%= @issue.status.name %><%=l(:field_priority)%> :<%= @issue.priority.name %>
    <%=l(:field_assigned_to)%> :<%= @issue.assigned_to ? @issue.assigned_to.name : "-" %><%=l(:field_category)%> :<%=h @issue.category ? @issue.category.name : "-" %>
    <%=l(:field_author)%> :<%= link_to_user @issue.author %><%=l(:field_start_date)%> :<%= format_date(@issue.start_date) %>
    <%=l(:field_created_on)%> :<%= format_date(@issue.created_on) %><%=l(:field_due_date)%> :<%= format_date(@issue.due_date) %>
    <%=l(:field_updated_on)%> :<%= format_date(@issue.updated_on) %><%=l(:field_done_ratio)%> :<%= @issue.done_ratio %> %
    <%=l(:field_fixed_version)%> :<%= @issue.fixed_version ? @issue.fixed_version.name : "-" %>
    <%= custom_value.custom_field.name %> :<%=h show_value custom_value %>
    -
    -
    - -<%=l(:field_description)%> :

    -<%= textilizable @issue.description %> -
    - -
    -<%= link_to_if_authorized l(:button_edit), {:controller => 'issues', :action => 'edit', :id => @issue}, :class => 'icon icon-edit' %> -<%= link_to_if_authorized l(:button_move), {:controller => 'projects', :action => 'move_issues', :id => @project, "issue_ids[]" => @issue.id }, :class => 'icon icon-move' %> -<%= link_to_if_authorized l(:button_delete), {:controller => 'issues', :action => 'destroy', :id => @issue}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> -
    - -<% if authorize_for('issues', 'change_status') and @status_options and !@status_options.empty? %> - <% form_tag ({:controller => 'issues', :action => 'change_status', :id => @issue}) do %> - <%=l(:label_change_status)%> : - - <%= submit_tag l(:button_change) %> - <% end %> -<% end %> -  -
    - -
    -

    <%=l(:label_history)%> -<% if @journals_count > @journals.length %>(<%= l(:label_last_changes, @journals.length) %>)<% end %>

    -<%= render :partial => 'history', :locals => { :journals => @journals } %> -<% if @journals_count > @journals.length %> -

    <%= link_to l(:label_change_view_all), :action => 'history', :id => @issue %>

    +

    <%= @issue.tracker.name %> #<%= @issue.id %> - <%=h @issue.subject %>

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +<% n = 0 +for custom_value in @custom_values %> + +<% n = n + 1 + if (n > 1) + n = 0 %> + + <%end +end %> + +
    <%=l(:field_status)%> :<%= @issue.status.name %><%=l(:field_priority)%> :<%= @issue.priority.name %>
    <%=l(:field_assigned_to)%> :<%= @issue.assigned_to ? @issue.assigned_to.name : "-" %><%=l(:field_category)%> :<%=h @issue.category ? @issue.category.name : "-" %>
    <%=l(:field_author)%> :<%= link_to_user @issue.author %><%=l(:field_start_date)%> :<%= format_date(@issue.start_date) %>
    <%=l(:field_created_on)%> :<%= format_date(@issue.created_on) %><%=l(:field_due_date)%> :<%= format_date(@issue.due_date) %>
    <%=l(:field_updated_on)%> :<%= format_date(@issue.updated_on) %><%=l(:field_done_ratio)%> :<%= @issue.done_ratio %> %
    <%=l(:field_fixed_version)%> :<%= @issue.fixed_version ? @issue.fixed_version.name : "-" %>
    <%= custom_value.custom_field.name %> :<%=h show_value custom_value %>
    +
    +
    + +<%=l(:field_description)%> :

    +<%= textilizable @issue.description %> +
    + +
    +<%= link_to_if_authorized l(:button_edit), {:controller => 'issues', :action => 'edit', :id => @issue}, :class => 'icon icon-edit' %> +<%= link_to_if_authorized l(:button_move), {:controller => 'projects', :action => 'move_issues', :id => @project, "issue_ids[]" => @issue.id }, :class => 'icon icon-move' %> +<%= link_to_if_authorized l(:button_delete), {:controller => 'issues', :action => 'destroy', :id => @issue}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> +
    + +<% if authorize_for('issues', 'change_status') and @status_options and !@status_options.empty? %> + <% form_tag ({:controller => 'issues', :action => 'change_status', :id => @issue}) do %> + <%=l(:label_change_status)%> : + + <%= submit_tag l(:button_change) %> + <% end %> <% end %> -
    - -
    -

    <%=l(:label_attachment_plural)%>

    - -<% for attachment in @issue.attachments %> - - - - - - +  + + +
    +

    <%=l(:label_history)%> +<% if @journals_count > @journals.length %>(<%= l(:label_last_changes, @journals.length) %>)<% end %>

    +<%= render :partial => 'history', :locals => { :journals => @journals } %> +<% if @journals_count > @journals.length %> +

    <%= link_to l(:label_change_view_all), :action => 'history', :id => @issue %>

    +<% end %> +
    + +
    +

    <%=l(:label_attachment_plural)%>

    +
    <%= link_to attachment.filename, { :action => 'download', :id => @issue, :attachment_id => attachment }, :class => 'icon icon-attachment' %> (<%= number_to_human_size(attachment.filesize) %>)<%= format_date(attachment.created_on) %><%= attachment.author.display_name %>
    <%= link_to_if_authorized l(:button_delete), {:controller => 'issues', :action => 'destroy_attachment', :id => @issue, :attachment_id => attachment }, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %>
    +<% for attachment in @issue.attachments %> + + + + + + +<% end %> +
    <%= link_to attachment.filename, { :action => 'download', :id => @issue, :attachment_id => attachment }, :class => 'icon icon-attachment' %> (<%= number_to_human_size(attachment.filesize) %>)<%= format_date(attachment.created_on) %><%= attachment.author.display_name %>
    <%= link_to_if_authorized l(:button_delete), {:controller => 'issues', :action => 'destroy_attachment', :id => @issue, :attachment_id => attachment }, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %>
    +
    +<% if authorize_for('issues', 'add_attachment') %> + <% form_tag ({ :controller => 'issues', :action => 'add_attachment', :id => @issue }, :multipart => true, :class => "tabular") do %> +

    + <%= file_field_tag 'attachments[]', :size => 30 %> (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)

    + <%= submit_tag l(:button_add) %> + <% end %> +<% end %> +
    + +<% if authorize_for('issues', 'add_note') %> +
    +

    <%= l(:label_add_note) %>

    + <% form_tag ({:controller => 'issues', :action => 'add_note', :id => @issue}, :class => "tabular" ) do %> +

    + <%= text_area_tag 'notes', '', :cols => 60, :rows => 10, :class => 'wiki-edit' %>

    + <%= submit_tag l(:button_add) %> + <% end %> +
    <% end %> - -
    -<% if authorize_for('issues', 'add_attachment') %> - <% form_tag ({ :controller => 'issues', :action => 'add_attachment', :id => @issue }, :multipart => true, :class => "tabular") do %> -

    - <%= file_field_tag 'attachments[]', :size => 30 %> (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)

    - <%= submit_tag l(:button_add) %> - <% end %> -<% end %> -
    - -<% if authorize_for('issues', 'add_note') %> -
    -

    <%= l(:label_add_note) %>

    - <% form_tag ({:controller => 'issues', :action => 'add_note', :id => @issue}, :class => "tabular" ) do %> -

    - <%= text_area_tag 'notes', '', :cols => 60, :rows => 10, :class => 'wiki-edit' %>

    - <%= submit_tag l(:button_add) %> - <% end %> -
    -<% end %> diff --git a/app/views/layouts/base.rhtml b/app/views/layouts/base.rhtml index 7665632e..2c7ceb9a 100644 --- a/app/views/layouts/base.rhtml +++ b/app/views/layouts/base.rhtml @@ -1,149 +1,149 @@ - - - -<%= Setting.app_title + (@html_title ? ": #{@html_title}" : "") %> - - - - -<%= stylesheet_link_tag "application" %> -<%= stylesheet_link_tag "print", :media => "print" %> -<%= javascript_include_tag :defaults %> -<%= javascript_include_tag 'menu' %> -<%= stylesheet_link_tag 'jstoolbar' %> -<%= yield :header_tags %> - - - -
    - - - - - - <% if admin_loggedin? %> - - - - - <% end %> - - <% unless @project.nil? || @project.id.nil? %> - - <% end %> - - -
    - - <% unless @project.nil? || @project.id.nil? %> -

    <%= @project.name %>

    - - <% end %> - - <% if loggedin? and @logged_in_user.memberships.length > 0 %> -

    <%=l(:label_my_projects) %>

    - - <% end %> -
    - -
    - <% if flash[:notice] %>

    <%= flash[:notice] %>

    <% end %> - <%= @content_for_layout %> -
    - - - -
    - + + + +<%= Setting.app_title + (@html_title ? ": #{@html_title}" : "") %> + + + + +<%= stylesheet_link_tag "application" %> +<%= stylesheet_link_tag "print", :media => "print" %> +<%= javascript_include_tag :defaults %> +<%= javascript_include_tag 'menu' %> +<%= stylesheet_link_tag 'jstoolbar' %> +<%= yield :header_tags %> + + + +
    + + + + + + <% if admin_loggedin? %> + + + + + <% end %> + + <% unless @project.nil? || @project.id.nil? %> + + <% end %> + + +
    + + <% unless @project.nil? || @project.id.nil? %> +

    <%= @project.name %>

    + + <% end %> + + <% if loggedin? and @logged_in_user.memberships.length > 0 %> +

    <%=l(:label_my_projects) %>

    + + <% end %> +
    + +
    + <% if flash[:notice] %>

    <%= flash[:notice] %>

    <% end %> + <%= @content_for_layout %> +
    + + + +
    + \ No newline at end of file diff --git a/app/views/mailer/_issue.rhtml b/app/views/mailer/_issue.rhtml index 4c5255d3..877947d3 100644 --- a/app/views/mailer/_issue.rhtml +++ b/app/views/mailer/_issue.rhtml @@ -1,7 +1,7 @@ -<%=l(:label_issue)%> #<%= issue.id %> - <%= issue.subject %> -<%=l(:field_author)%>: <%= issue.author.display_name %> -<%=l(:field_status)%>: <%= issue.status.name %> +<%=l(:label_issue)%> #<%= issue.id %> - <%= issue.subject %> +<%=l(:field_author)%>: <%= issue.author.display_name %> +<%=l(:field_status)%>: <%= issue.status.name %> + +<%= issue.description %> -<%= issue.description %> - http://<%= Setting.host_name %>/issues/show/<%= issue.id %> \ No newline at end of file diff --git a/app/views/mailer/attachments_add_de.rhtml b/app/views/mailer/attachments_add_de.rhtml index f17af9d8..81e2974c 100644 --- a/app/views/mailer/attachments_add_de.rhtml +++ b/app/views/mailer/attachments_add_de.rhtml @@ -1,6 +1,6 @@ -<%= @added_to %> -<%= @attachments.size %> files(s) added. -<% @attachments.each do |attachment | %> -- <%= attachment.filename %><% end %> - +<%= @added_to %> +<%= @attachments.size %> files(s) added. +<% @attachments.each do |attachment | %> +- <%= attachment.filename %><% end %> + <%= @url %> \ No newline at end of file diff --git a/app/views/mailer/attachments_add_en.rhtml b/app/views/mailer/attachments_add_en.rhtml index f17af9d8..81e2974c 100644 --- a/app/views/mailer/attachments_add_en.rhtml +++ b/app/views/mailer/attachments_add_en.rhtml @@ -1,6 +1,6 @@ -<%= @added_to %> -<%= @attachments.size %> files(s) added. -<% @attachments.each do |attachment | %> -- <%= attachment.filename %><% end %> - +<%= @added_to %> +<%= @attachments.size %> files(s) added. +<% @attachments.each do |attachment | %> +- <%= attachment.filename %><% end %> + <%= @url %> \ No newline at end of file diff --git a/app/views/mailer/attachments_add_es.rhtml b/app/views/mailer/attachments_add_es.rhtml index f17af9d8..81e2974c 100644 --- a/app/views/mailer/attachments_add_es.rhtml +++ b/app/views/mailer/attachments_add_es.rhtml @@ -1,6 +1,6 @@ -<%= @added_to %> -<%= @attachments.size %> files(s) added. -<% @attachments.each do |attachment | %> -- <%= attachment.filename %><% end %> - +<%= @added_to %> +<%= @attachments.size %> files(s) added. +<% @attachments.each do |attachment | %> +- <%= attachment.filename %><% end %> + <%= @url %> \ No newline at end of file diff --git a/app/views/mailer/attachments_add_fr.rhtml b/app/views/mailer/attachments_add_fr.rhtml index 381b4896..8a0430d8 100644 --- a/app/views/mailer/attachments_add_fr.rhtml +++ b/app/views/mailer/attachments_add_fr.rhtml @@ -1,6 +1,6 @@ -<%= @added_to %> -<%= @attachments.size %> fichier(s) ajouté(s). -<% @attachments.each do |attachment | %> -- <%= attachment.filename %><% end %> - +<%= @added_to %> +<%= @attachments.size %> fichier(s) ajouté(s). +<% @attachments.each do |attachment | %> +- <%= attachment.filename %><% end %> + <%= @url %> \ No newline at end of file diff --git a/app/views/mailer/attachments_add_ja.rhtml b/app/views/mailer/attachments_add_ja.rhtml index e0e95bd0..41131e57 100644 --- a/app/views/mailer/attachments_add_ja.rhtml +++ b/app/views/mailer/attachments_add_ja.rhtml @@ -1,6 +1,6 @@ -<%= @added_to %> -<%= @attachments.size %> ファイルが追加されました。 -<% @attachments.each do |attachment | %> -- <%= attachment.filename %><% end %> - +<%= @added_to %> +<%= @attachments.size %> ファイルが追加されました。 +<% @attachments.each do |attachment | %> +- <%= attachment.filename %><% end %> + <%= @url %> \ No newline at end of file diff --git a/app/views/mailer/document_add_de.rhtml b/app/views/mailer/document_add_de.rhtml index a022829a..67648de1 100644 --- a/app/views/mailer/document_add_de.rhtml +++ b/app/views/mailer/document_add_de.rhtml @@ -1,4 +1,4 @@ -A document has been added to <%= @document.project.name %> (<%= @document.category.name %>): -<%= l(:field_title) %>: <%= @document.title %> - +A document has been added to <%= @document.project.name %> (<%= @document.category.name %>): +<%= l(:field_title) %>: <%= @document.title %> + http://<%= Setting.host_name %>/documents/show/<%= @document.id %> \ No newline at end of file diff --git a/app/views/mailer/document_add_en.rhtml b/app/views/mailer/document_add_en.rhtml index a022829a..67648de1 100644 --- a/app/views/mailer/document_add_en.rhtml +++ b/app/views/mailer/document_add_en.rhtml @@ -1,4 +1,4 @@ -A document has been added to <%= @document.project.name %> (<%= @document.category.name %>): -<%= l(:field_title) %>: <%= @document.title %> - +A document has been added to <%= @document.project.name %> (<%= @document.category.name %>): +<%= l(:field_title) %>: <%= @document.title %> + http://<%= Setting.host_name %>/documents/show/<%= @document.id %> \ No newline at end of file diff --git a/app/views/mailer/document_add_es.rhtml b/app/views/mailer/document_add_es.rhtml index a022829a..67648de1 100644 --- a/app/views/mailer/document_add_es.rhtml +++ b/app/views/mailer/document_add_es.rhtml @@ -1,4 +1,4 @@ -A document has been added to <%= @document.project.name %> (<%= @document.category.name %>): -<%= l(:field_title) %>: <%= @document.title %> - +A document has been added to <%= @document.project.name %> (<%= @document.category.name %>): +<%= l(:field_title) %>: <%= @document.title %> + http://<%= Setting.host_name %>/documents/show/<%= @document.id %> \ No newline at end of file diff --git a/app/views/mailer/document_add_fr.rhtml b/app/views/mailer/document_add_fr.rhtml index c116c84c..b6f87757 100644 --- a/app/views/mailer/document_add_fr.rhtml +++ b/app/views/mailer/document_add_fr.rhtml @@ -1,4 +1,4 @@ -Un document a été ajouté à <%= @document.project.name %> (<%= @document.category.name %>): -<%= l(:field_title) %>: <%= @document.title %> - +Un document a été ajouté à <%= @document.project.name %> (<%= @document.category.name %>): +<%= l(:field_title) %>: <%= @document.title %> + http://<%= Setting.host_name %>/documents/show/<%= @document.id %> \ No newline at end of file diff --git a/app/views/mailer/document_add_ja.rhtml b/app/views/mailer/document_add_ja.rhtml index c64740fb..3834947b 100644 --- a/app/views/mailer/document_add_ja.rhtml +++ b/app/views/mailer/document_add_ja.rhtml @@ -1,4 +1,4 @@ -文書が <%= @document.project.name %> (<%= @document.category.name %>) に追加されました: -<%= l(:field_title) %>: <%= @document.title %> - +文書が <%= @document.project.name %> (<%= @document.category.name %>) に追加されました: +<%= l(:field_title) %>: <%= @document.title %> + http://<%= Setting.host_name %>/documents/show/<%= @document.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 index 9efec9ad..823de2ce 100644 --- a/app/views/mailer/issue_add_de.rhtml +++ b/app/views/mailer/issue_add_de.rhtml @@ -1,3 +1,3 @@ -Issue #<%= @issue.id %> has been reported. ----------------------------------------- +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 index 9efec9ad..823de2ce 100644 --- a/app/views/mailer/issue_add_en.rhtml +++ b/app/views/mailer/issue_add_en.rhtml @@ -1,3 +1,3 @@ -Issue #<%= @issue.id %> has been reported. ----------------------------------------- +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 index 9efec9ad..823de2ce 100644 --- a/app/views/mailer/issue_add_es.rhtml +++ b/app/views/mailer/issue_add_es.rhtml @@ -1,3 +1,3 @@ -Issue #<%= @issue.id %> has been reported. ----------------------------------------- +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 index 628ecae1..45818878 100644 --- a/app/views/mailer/issue_add_fr.rhtml +++ b/app/views/mailer/issue_add_fr.rhtml @@ -1,3 +1,3 @@ -Une nouvelle demande (#<%= @issue.id %>) a été soumise. ----------------------------------------- +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_add_ja.rhtml b/app/views/mailer/issue_add_ja.rhtml index 113546ae..14d9258a 100644 --- a/app/views/mailer/issue_add_ja.rhtml +++ b/app/views/mailer/issue_add_ja.rhtml @@ -1,3 +1,3 @@ -問題 #<%= @issue.id %> が報告されました。 ----------------------------------------- +問題 #<%= @issue.id %> が報告されました。 +---------------------------------------- <%= 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 index d22d6c53..7a9ca163 100644 --- a/app/views/mailer/issue_edit_de.rhtml +++ b/app/views/mailer/issue_edit_de.rhtml @@ -1,8 +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? %> ----------------------------------------- +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 index d22d6c53..7a9ca163 100644 --- a/app/views/mailer/issue_edit_en.rhtml +++ b/app/views/mailer/issue_edit_en.rhtml @@ -1,8 +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? %> ----------------------------------------- +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 index d22d6c53..7a9ca163 100644 --- a/app/views/mailer/issue_edit_es.rhtml +++ b/app/views/mailer/issue_edit_es.rhtml @@ -1,8 +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? %> ----------------------------------------- +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 index d86f29c2..ecea9e27 100644 --- a/app/views/mailer/issue_edit_fr.rhtml +++ b/app/views/mailer/issue_edit_fr.rhtml @@ -1,8 +1,8 @@ -La demande #<%= @issue.id %> a été mise à jour. -<%= @journal.user.name %> -<% for detail in @journal.details %> -<%= show_detail(detail, true) %> -<% end %> -<%= @journal.notes if @journal.notes? %> ----------------------------------------- +La demande #<%= @issue.id %> a été mise à jour. +<%= @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_ja.rhtml b/app/views/mailer/issue_edit_ja.rhtml index b0a93db8..d3b1b520 100644 --- a/app/views/mailer/issue_edit_ja.rhtml +++ b/app/views/mailer/issue_edit_ja.rhtml @@ -1,8 +1,8 @@ -問題 #<%= @issue.id %> が更新されました。 -<%= @journal.user.name %> -<% for detail in @journal.details %> -<%= show_detail(detail, true) %> -<% end %> -<%= @journal.notes if @journal.notes? %> ----------------------------------------- +問題 #<%= @issue.id %> が更新されました。 +<%= @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/lost_password_de.rhtml b/app/views/mailer/lost_password_de.rhtml index 0b391498..332ddeb0 100644 --- a/app/views/mailer/lost_password_de.rhtml +++ b/app/views/mailer/lost_password_de.rhtml @@ -1,3 +1,3 @@ -To change your password, use the following link: - +To change your password, use the following link: + http://<%= Setting.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 index 0b391498..332ddeb0 100644 --- a/app/views/mailer/lost_password_en.rhtml +++ b/app/views/mailer/lost_password_en.rhtml @@ -1,3 +1,3 @@ -To change your password, use the following link: - +To change your password, use the following link: + http://<%= Setting.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 index 0b391498..332ddeb0 100644 --- a/app/views/mailer/lost_password_es.rhtml +++ b/app/views/mailer/lost_password_es.rhtml @@ -1,3 +1,3 @@ -To change your password, use the following link: - +To change your password, use the following link: + http://<%= Setting.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 index 18b6bf6a..8282611e 100644 --- a/app/views/mailer/lost_password_fr.rhtml +++ b/app/views/mailer/lost_password_fr.rhtml @@ -1,3 +1,3 @@ -Pour changer votre mot de passe, utilisez le lien suivant: - +Pour changer votre mot de passe, utilisez le lien suivant: + http://<%= Setting.host_name %>/account/lost_password?token=<%= @token.value %> \ No newline at end of file diff --git a/app/views/mailer/lost_password_ja.rhtml b/app/views/mailer/lost_password_ja.rhtml index 99266be2..1f203e8d 100644 --- a/app/views/mailer/lost_password_ja.rhtml +++ b/app/views/mailer/lost_password_ja.rhtml @@ -1,3 +1,3 @@ -パスワードを変更するには、以下のリンクをたどってください: - +パスワードを変更するには、以下のリンクをたどってください: + http://<%= Setting.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 index 95cc7c4a..64477feb 100644 --- a/app/views/mailer/register_de.rhtml +++ b/app/views/mailer/register_de.rhtml @@ -1,3 +1,3 @@ -To activate your redMine account, use the following link: - +To activate your redMine account, use the following link: + http://<%= Setting.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 index 95cc7c4a..64477feb 100644 --- a/app/views/mailer/register_en.rhtml +++ b/app/views/mailer/register_en.rhtml @@ -1,3 +1,3 @@ -To activate your redMine account, use the following link: - +To activate your redMine account, use the following link: + http://<%= Setting.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 index 95cc7c4a..64477feb 100644 --- a/app/views/mailer/register_es.rhtml +++ b/app/views/mailer/register_es.rhtml @@ -1,3 +1,3 @@ -To activate your redMine account, use the following link: - +To activate your redMine account, use the following link: + http://<%= Setting.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 index 402b2a5d..2258480c 100644 --- a/app/views/mailer/register_fr.rhtml +++ b/app/views/mailer/register_fr.rhtml @@ -1,3 +1,3 @@ -Pour activer votre compte sur redMine, utilisez le lien suivant: - +Pour activer votre compte sur redMine, utilisez le lien suivant: + http://<%= Setting.host_name %>/account/register?token=<%= @token.value %> \ No newline at end of file diff --git a/app/views/mailer/register_ja.rhtml b/app/views/mailer/register_ja.rhtml index b990b934..2f5846fb 100644 --- a/app/views/mailer/register_ja.rhtml +++ b/app/views/mailer/register_ja.rhtml @@ -1,3 +1,3 @@ -redMine アカウントをアクティブにするには、以下のリンクをたどってください: - +redMine アカウントをアクティブにするには、以下のリンクをたどってください: + http://<%= Setting.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 index 3f72bdaf..39e6c3bd 100644 --- a/app/views/my/_block.rhtml +++ b/app/views/my/_block.rhtml @@ -1,16 +1,16 @@ -
    - -
    - <%= 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" - %> -
    - -
    - <%= render :partial => "my/blocks/#{block_name}", :locals => { :user => user } %> -
    +
    + +
    + <%= 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" + %> +
    + +
    + <%= render :partial => "my/blocks/#{block_name}", :locals => { :user => user } %> +
    \ No newline at end of file diff --git a/app/views/my/account.rhtml b/app/views/my/account.rhtml index 09a43b46..8a1468cd 100644 --- a/app/views/my/account.rhtml +++ b/app/views/my/account.rhtml @@ -1,11 +1,11 @@

    <%=l(:label_my_account)%>

    - -

    <%=l(:field_login)%>: <%= @user.login %>
    -<%=l(:field_created_on)%>: <%= format_time(@user.created_on) %>

    + +

    <%=l(:field_login)%>: <%= @user.login %>
    +<%=l(:field_created_on)%>: <%= format_time(@user.created_on) %>

    <%= error_messages_for 'user' %> - -
    + +

    <%=l(:label_information_plural)%>

    <% labelled_tabular_form_for :user, @user, :url => { :action => "account" } do |f| %> @@ -21,26 +21,26 @@ <% end %>
    <%= submit_tag l(:button_save) %>
    -<% end %> -
    - +<% end %> +
    -<% unless @user.auth_source_id %> -
    -

    <%=l(:field_password)%>

    + +<% unless @user.auth_source_id %> +
    +

    <%=l(:field_password)%>

    <% form_tag({:action => 'change_password'}, :class => "tabular") do %> - +

    <%= password_field_tag 'password', nil, :size => 25 %>

    - +

    - <%= password_field_tag 'new_password', nil, :size => 25 %>

    - + <%= password_field_tag 'new_password', nil, :size => 25 %>

    +

    - <%= password_field_tag 'new_password_confirmation', nil, :size => 25 %>

    + <%= password_field_tag 'new_password_confirmation', nil, :size => 25 %>

    <%= submit_tag l(:button_save) %>
    - <% end %> + <% end %>
    -<% end %> +<% end %> diff --git a/app/views/my/blocks/_calendar.rhtml b/app/views/my/blocks/_calendar.rhtml index dfff5b78..4c583e49 100644 --- a/app/views/my/blocks/_calendar.rhtml +++ b/app/views/my/blocks/_calendar.rhtml @@ -1,47 +1,47 @@ -

    <%= l(:label_calendar) %>

    - -<% -@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 ||= [] -%> - - - - -<% 1.upto(7) do |d| %> - -<% end %> - - - -<% day = @date_from -while day <= @date_to - if day.cwday == 1 %> - - <% end %> - - <%= '' if day.cwday >= 7 and day!=@date_to %> - <% - day = day + 1 -end %> - - +

    <%= l(:label_calendar) %>

    + +<% +@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 ||= [] +%> + +
    <%= day_name(d) %>
    <%= day.cweek %>"> -

    <%= day==Date.today ? "#{day.day}" : day.day %>

    - <% 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.png') - elsif day == i.start_date - image_tag('arrow_from.png') - elsif day == i.due_date - image_tag('arrow_to.png') - end %> - <%= link_to "#{i.tracker.name} ##{i.id}", :controller => 'issues', :action => 'show', :id => i %>: <%=h i.subject.sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)') %>
    - <% end %> -
    + + +<% 1.upto(7) do |d| %> + +<% end %> + + + +<% day = @date_from +while day <= @date_to + if day.cwday == 1 %> + + <% end %> + + <%= '' if day.cwday >= 7 and day!=@date_to %> + <% + day = day + 1 +end %> + +
    <%= day_name(d) %>
    <%= day.cweek %>"> +

    <%= day==Date.today ? "#{day.day}" : day.day %>

    + <% 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.png') + elsif day == i.start_date + image_tag('arrow_from.png') + elsif day == i.due_date + image_tag('arrow_to.png') + end %> + <%= link_to "#{i.tracker.name} ##{i.id}", :controller => 'issues', :action => 'show', :id => i %>: <%=h i.subject.sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)') %>
    + <% end %> +
    \ No newline at end of file diff --git a/app/views/my/blocks/_documents.rhtml b/app/views/my/blocks/_documents.rhtml index eb8c16a5..a1bb0b36 100644 --- a/app/views/my/blocks/_documents.rhtml +++ b/app/views/my/blocks/_documents.rhtml @@ -1,8 +1,8 @@ -

    <%=l(:label_document_plural)%>

    - -<%= render(:partial => 'documents/document', - :collection => Document.find(:all, - :limit => 10, - :order => 'documents.created_on DESC', - :conditions => "documents.project_id in (#{@user.projects.collect{|m| m.id}.join(',')})", +

    <%=l(:label_document_plural)%>

    + +<%= render(:partial => 'documents/document', + :collection => Document.find(:all, + :limit => 10, + :order => 'documents.created_on DESC', + :conditions => "documents.project_id in (#{@user.projects.collect{|m| m.id}.join(',')})", :include => [:project])) unless @user.projects.empty? %> \ No newline at end of file diff --git a/app/views/my/blocks/_issuesassignedtome.rhtml b/app/views/my/blocks/_issuesassignedtome.rhtml index 2a4e2a05..e52e0fad 100644 --- a/app/views/my/blocks/_issuesassignedtome.rhtml +++ b/app/views/my/blocks/_issuesassignedtome.rhtml @@ -1,10 +1,10 @@ -

    <%=l(:label_assigned_to_me_issues)%>

    -<% 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 %> -

    <%=lwr(:label_last_updates, assigned_issues.length)%>

    -<% end %> +

    <%=l(:label_assigned_to_me_issues)%>

    +<% 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 %> +

    <%=lwr(:label_last_updates, assigned_issues.length)%>

    +<% end %> diff --git a/app/views/my/blocks/_issuesreportedbyme.rhtml b/app/views/my/blocks/_issuesreportedbyme.rhtml index 9b40b360..4e173d3c 100644 --- a/app/views/my/blocks/_issuesreportedbyme.rhtml +++ b/app/views/my/blocks/_issuesreportedbyme.rhtml @@ -1,10 +1,10 @@ -

    <%=l(:label_reported_issues)%>

    -<% 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 %> -

    <%=lwr(:label_last_updates, reported_issues.length)%>

    +

    <%=l(:label_reported_issues)%>

    +<% 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 %> +

    <%=lwr(:label_last_updates, reported_issues.length)%>

    <% end %> \ No newline at end of file diff --git a/app/views/my/blocks/_news.rhtml b/app/views/my/blocks/_news.rhtml index 4bad9a54..30085cf4 100644 --- a/app/views/my/blocks/_news.rhtml +++ b/app/views/my/blocks/_news.rhtml @@ -1,8 +1,8 @@ -

    <%=l(:label_news_latest)%>

    - -<%= render (:partial => 'news/news', - :collection => News.find(:all, - :limit => 10, - :order => 'news.created_on DESC', - :conditions => "news.project_id in (#{@user.projects.collect{|m| m.id}.join(',')})", +

    <%=l(:label_news_latest)%>

    + +<%= render (:partial => 'news/news', + :collection => News.find(:all, + :limit => 10, + :order => 'news.created_on DESC', + :conditions => "news.project_id in (#{@user.projects.collect{|m| m.id}.join(',')})", :include => [:project, :author])) unless @user.projects.empty? %> \ No newline at end of file diff --git a/app/views/my/page.rhtml b/app/views/my/page.rhtml index 0c7920d6..5c6c906d 100644 --- a/app/views/my/page.rhtml +++ b/app/views/my/page.rhtml @@ -1,33 +1,33 @@ -
    - <%= link_to l(:label_personalize_page), :action => 'page_layout' %> -
    - -

    <%=l(:label_my_page)%>

    - -
    - <% @blocks['top'].each do |b| - next unless MyController::BLOCKS.keys.include? b %> -
    - <%= render :partial => "my/blocks/#{b}", :locals => { :user => @user } %> -
    - <% end if @blocks['top'] %> -
    - -
    - <% @blocks['left'].each do |b| - next unless MyController::BLOCKS.keys.include? b %> -
    - <%= render :partial => "my/blocks/#{b}", :locals => { :user => @user } %> -
    - <% end if @blocks['left'] %> -
    - -
    - <% @blocks['right'].each do |b| - next unless MyController::BLOCKS.keys.include? b %> -
    - <%= render :partial => "my/blocks/#{b}", :locals => { :user => @user } %> -
    - <% end if @blocks['right'] %> -
    - +
    + <%= link_to l(:label_personalize_page), :action => 'page_layout' %> +
    + +

    <%=l(:label_my_page)%>

    + +
    + <% @blocks['top'].each do |b| + next unless MyController::BLOCKS.keys.include? b %> +
    + <%= render :partial => "my/blocks/#{b}", :locals => { :user => @user } %> +
    + <% end if @blocks['top'] %> +
    + +
    + <% @blocks['left'].each do |b| + next unless MyController::BLOCKS.keys.include? b %> +
    + <%= render :partial => "my/blocks/#{b}", :locals => { :user => @user } %> +
    + <% end if @blocks['left'] %> +
    + +
    + <% @blocks['right'].each do |b| + next unless MyController::BLOCKS.keys.include? b %> +
    + <%= render :partial => "my/blocks/#{b}", :locals => { :user => @user } %> +
    + <% end if @blocks['right'] %> +
    + diff --git a/app/views/my/page_layout.rhtml b/app/views/my/page_layout.rhtml index 2fe94474..8cb09a55 100644 --- a/app/views/my/page_layout.rhtml +++ b/app/views/my/page_layout.rhtml @@ -1,117 +1,117 @@ - - -
    - -<% form_tag({:action => "add_block"}, :id => "block-form") do %> -<%= select_tag 'block', "" + options_for_select(@block_options), :id => "block-select" %> -<%= 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')" - }, :class => 'icon icon-add' - %> -<% end %> -<%= link_to l(:button_save), {:action => 'page_layout_save'}, :class => 'icon icon-save' %> -<%= link_to l(:button_cancel), {:action => 'page'}, :class => 'icon icon-cancel' %> -
    - -

    <%=l(:label_my_page)%>

    - -
    - <% @blocks['top'].each do |b| - next unless MyController::BLOCKS.keys.include? b %> - <%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %> - <% end if @blocks['top'] %> -
    - -
    - <% @blocks['left'].each do |b| - next unless MyController::BLOCKS.keys.include? b %> - <%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %> - <% end if @blocks['left'] %> -
    - -
    - <% @blocks['right'].each do |b| - next unless MyController::BLOCKS.keys.include? b %> - <%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %> - <% end if @blocks['right'] %> -
    - -<%= 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')" %> - + + +
    + +<% form_tag({:action => "add_block"}, :id => "block-form") do %> +<%= select_tag 'block', "" + options_for_select(@block_options), :id => "block-select" %> +<%= 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')" + }, :class => 'icon icon-add' + %> +<% end %> +<%= link_to l(:button_save), {:action => 'page_layout_save'}, :class => 'icon icon-save' %> +<%= link_to l(:button_cancel), {:action => 'page'}, :class => 'icon icon-cancel' %> +
    + +

    <%=l(:label_my_page)%>

    + +
    + <% @blocks['top'].each do |b| + next unless MyController::BLOCKS.keys.include? b %> + <%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %> + <% end if @blocks['top'] %> +
    + +
    + <% @blocks['left'].each do |b| + next unless MyController::BLOCKS.keys.include? b %> + <%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %> + <% end if @blocks['left'] %> +
    + +
    + <% @blocks['right'].each do |b| + next unless MyController::BLOCKS.keys.include? b %> + <%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %> + <% end if @blocks['right'] %> +
    + +<%= 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/_news.rhtml b/app/views/news/_news.rhtml index 75a80d63..e48e5041 100644 --- a/app/views/news/_news.rhtml +++ b/app/views/news/_news.rhtml @@ -1,4 +1,4 @@ -

    <%= link_to h(news.title), :controller => 'news', :action => 'show', :id => news %>
    -<% unless news.summary.empty? %><%=h news.summary %>
    <% end %> -<%= news.author.name %>, <%= format_time(news.created_on) %>
    -<%= news.comments_count %> <%= lwr(:label_comment, news.comments_count).downcase %>

    +

    <%= link_to h(news.title), :controller => 'news', :action => 'show', :id => news %>
    +<% unless news.summary.empty? %><%=h news.summary %>
    <% end %> +<%= news.author.name %>, <%= format_time(news.created_on) %>
    +<%= news.comments_count %> <%= lwr(:label_comment, news.comments_count).downcase %>

    diff --git a/app/views/news/show.rhtml b/app/views/news/show.rhtml index cf283aae..92e66445 100644 --- a/app/views/news/show.rhtml +++ b/app/views/news/show.rhtml @@ -1,33 +1,33 @@ -
    -<%= link_to_if_authorized l(:button_edit), {:controller => 'news', :action => 'edit', :id => @news}, :class => 'icon icon-edit' %> -<%= link_to_if_authorized l(:button_delete), {:controller => 'news', :action => 'destroy', :id => @news}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> -
    - -

    <%=h @news.title %>

    - -

    <% unless @news.summary.empty? %><%=h @news.summary %>
    <% end %> -<%= @news.author.display_name %>, <%= format_time(@news.created_on) %>

    -
    +
    +<%= link_to_if_authorized l(:button_edit), {:controller => 'news', :action => 'edit', :id => @news}, :class => 'icon icon-edit' %> +<%= link_to_if_authorized l(:button_delete), {:controller => 'news', :action => 'destroy', :id => @news}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> +
    + +

    <%=h @news.title %>

    + +

    <% unless @news.summary.empty? %><%=h @news.summary %>
    <% end %> +<%= @news.author.display_name %>, <%= format_time(@news.created_on) %>

    +
    <%= textilizable auto_link @news.description %> -
    - -
    -

    <%= l(:label_comment_plural) %>

    -<% @news.comments.each do |comment| %> - <% next if comment.new_record? %> -

    <%= format_time(comment.created_on) %> - <%= comment.author.name %>

    -
    - <%= link_to_if_authorized l(:button_delete), {:controller => 'news', :action => 'destroy_comment', :id => @news, :comment_id => comment}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> -
    - <%= simple_format(auto_link(h comment.comment))%> -<% end if @news.comments_count > 0 %> -
    - -<% if authorize_for 'news', 'add_comment' %> -<% form_tag({:action => 'add_comment', :id => @news}) do %> -<%= error_messages_for 'comment' %> -


    -<%= text_area 'comment', 'comment', :cols => 60, :rows => 6 %>

    -<%= submit_tag l(:button_add) %> -<% end %> +
    + +
    +

    <%= l(:label_comment_plural) %>

    +<% @news.comments.each do |comment| %> + <% next if comment.new_record? %> +

    <%= format_time(comment.created_on) %> - <%= comment.author.name %>

    +
    + <%= link_to_if_authorized l(:button_delete), {:controller => 'news', :action => 'destroy_comment', :id => @news, :comment_id => comment}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> +
    + <%= simple_format(auto_link(h comment.comment))%> +<% end if @news.comments_count > 0 %> +
    + +<% if authorize_for 'news', 'add_comment' %> +<% form_tag({:action => 'add_comment', :id => @news}) do %> +<%= error_messages_for 'comment' %> +


    +<%= text_area 'comment', 'comment', :cols => 60, :rows => 6 %>

    +<%= submit_tag l(:button_add) %> +<% end %> <% end %> \ No newline at end of file diff --git a/app/views/projects/_form.rhtml b/app/views/projects/_form.rhtml index 0bb7ebfb..85f3f296 100644 --- a/app/views/projects/_form.rhtml +++ b/app/views/projects/_form.rhtml @@ -11,18 +11,18 @@

    <%= f.text_area :description, :required => true, :cols => 60, :rows => 3 %>

    <%= f.text_field :homepage, :size => 40 %>

    <%= f.check_box :is_public %>

    - + <% for @custom_value in @custom_values %>

    <%= custom_field_tag_with_label @custom_value %>

    -<% end %> +<% end %> <% unless @custom_fields.empty? %>

    <% 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 %> + <%= 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 %>

    -<% end %> +<% end %>
    diff --git a/app/views/projects/activity.rhtml b/app/views/projects/activity.rhtml index 2eef3e7b..80386b9e 100644 --- a/app/views/projects/activity.rhtml +++ b/app/views/projects/activity.rhtml @@ -1,59 +1,59 @@ -

    <%=l(:label_activity)%>: <%= "#{month_name(@month).downcase} #{@year}" %>

    - -
    -
    -<% form_tag do %> -

    <%= select_month(@month, :prefix => "month", :discard_type => true) %> -<%= select_year(@year, :prefix => "year", :discard_type => true) %>

    -

    - <%= check_box_tag 'show_issues', 1, @show_issues %><%= hidden_field_tag 'show_issues', 0, :id => nil %> <%=l(:label_issue_plural)%>
    - <%= check_box_tag 'show_news', 1, @show_news %><%= hidden_field_tag 'show_news', 0, :id => nil %> <%=l(:label_news_plural)%>
    - <%= check_box_tag 'show_files', 1, @show_files %><%= hidden_field_tag 'show_files', 0, :id => nil %> <%=l(:label_attachment_plural)%>
    - <%= check_box_tag 'show_documents', 1, @show_documents %><%= hidden_field_tag 'show_documents', 0, :id => nil %> <%=l(:label_document_plural)%> -

    -

    <%= submit_tag l(:button_apply), :class => 'button-small' %>

    -<% end %> -
    - -<% @events_by_day.keys.sort {|x,y| y <=> x }.each do |day| %> -

    <%= day_name(day.cwday) %> <%= day.day %>

    -
      - <% @events_by_day[day].sort {|x,y| y.created_on <=> x.created_on }.each do |e| %> -
    • - <% 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 %>): <%=h e.subject %>
      - <%= e.author.name %> - <% elsif e.is_a? News %> - <%= e.created_on.strftime("%H:%M") %> <%=l(:label_news)%>: <%= link_to h(e.title), :controller => 'news', :action => 'show', :id => e %>
      - <% unless e.summary.empty? %><%=h e.summary %>
      <% end %> - <%= e.author.name %> - <% elsif (e.is_a? Attachment) and (e.container.is_a? Version) %> - <%= e.created_on.strftime("%H:%M") %> <%=l(:label_attachment)%> (<%=h e.container.name %>): <%= link_to e.filename, :controller => 'projects', :action => 'list_files', :id => @project %>
      - <%= e.author.name %> - <% elsif (e.is_a? Attachment) and (e.container.is_a? Document) %> - <%= e.created_on.strftime("%H:%M") %> <%=l(:label_attachment)%>: <%= e.filename %> (<%= link_to h(e.container.title), :controller => 'documents', :action => 'show', :id => e.container %>)
      - <%= e.author.name %> - <% elsif e.is_a? Document %> - <%= e.created_on.strftime("%H:%M") %> <%=l(:label_document)%>: <%= link_to h(e.title), :controller => 'documents', :action => 'show', :id => e %>
      - <% end %> -

    • - - <% end %> -
    -<% end %> -<% if @events_by_day.empty? %>

    <%= l(:label_no_data) %>

    <% end %> - -
    -<%= link_to_remote ('« ' + (@month==1 ? "#{month_name(12)} #{@year-1}" : "#{month_name(@month-1)}")), - {:update => "content", :url => { :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1) }}, - {:href => url_for(:action => 'activity', :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1))} - %> -
    -
    -<%= link_to_remote ((@month==12 ? "#{month_name(1)} #{@year+1}" : "#{month_name(@month+1)}") + ' »'), - {:update => "content", :url => { :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1) }}, - {:href => url_for(:action => 'activity', :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1))} - %>  -
    -
    +

    <%=l(:label_activity)%>: <%= "#{month_name(@month).downcase} #{@year}" %>

    + +
    +
    +<% form_tag do %> +

    <%= select_month(@month, :prefix => "month", :discard_type => true) %> +<%= select_year(@year, :prefix => "year", :discard_type => true) %>

    +

    + <%= check_box_tag 'show_issues', 1, @show_issues %><%= hidden_field_tag 'show_issues', 0, :id => nil %> <%=l(:label_issue_plural)%>
    + <%= check_box_tag 'show_news', 1, @show_news %><%= hidden_field_tag 'show_news', 0, :id => nil %> <%=l(:label_news_plural)%>
    + <%= check_box_tag 'show_files', 1, @show_files %><%= hidden_field_tag 'show_files', 0, :id => nil %> <%=l(:label_attachment_plural)%>
    + <%= check_box_tag 'show_documents', 1, @show_documents %><%= hidden_field_tag 'show_documents', 0, :id => nil %> <%=l(:label_document_plural)%> +

    +

    <%= submit_tag l(:button_apply), :class => 'button-small' %>

    +<% end %> +
    + +<% @events_by_day.keys.sort {|x,y| y <=> x }.each do |day| %> +

    <%= day_name(day.cwday) %> <%= day.day %>

    +
      + <% @events_by_day[day].sort {|x,y| y.created_on <=> x.created_on }.each do |e| %> +
    • + <% 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 %>): <%=h e.subject %>
      + <%= e.author.name %> + <% elsif e.is_a? News %> + <%= e.created_on.strftime("%H:%M") %> <%=l(:label_news)%>: <%= link_to h(e.title), :controller => 'news', :action => 'show', :id => e %>
      + <% unless e.summary.empty? %><%=h e.summary %>
      <% end %> + <%= e.author.name %> + <% elsif (e.is_a? Attachment) and (e.container.is_a? Version) %> + <%= e.created_on.strftime("%H:%M") %> <%=l(:label_attachment)%> (<%=h e.container.name %>): <%= link_to e.filename, :controller => 'projects', :action => 'list_files', :id => @project %>
      + <%= e.author.name %> + <% elsif (e.is_a? Attachment) and (e.container.is_a? Document) %> + <%= e.created_on.strftime("%H:%M") %> <%=l(:label_attachment)%>: <%= e.filename %> (<%= link_to h(e.container.title), :controller => 'documents', :action => 'show', :id => e.container %>)
      + <%= e.author.name %> + <% elsif e.is_a? Document %> + <%= e.created_on.strftime("%H:%M") %> <%=l(:label_document)%>: <%= link_to h(e.title), :controller => 'documents', :action => 'show', :id => e %>
      + <% end %> +

    • + + <% end %> +
    +<% end %> +<% if @events_by_day.empty? %>

    <%= l(:label_no_data) %>

    <% end %> + +
    +<%= link_to_remote ('« ' + (@month==1 ? "#{month_name(12)} #{@year-1}" : "#{month_name(@month-1)}")), + {:update => "content", :url => { :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1) }}, + {:href => url_for(:action => 'activity', :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1))} + %> +
    +
    +<%= link_to_remote ((@month==12 ? "#{month_name(1)} #{@year+1}" : "#{month_name(@month+1)}") + ' »'), + {:update => "content", :url => { :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1) }}, + {:href => url_for(:action => 'activity', :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1))} + %>  +
    +
    \ No newline at end of file diff --git a/app/views/projects/add_document.rhtml b/app/views/projects/add_document.rhtml index 4beb7a94..dc3103a7 100644 --- a/app/views/projects/add_document.rhtml +++ b/app/views/projects/add_document.rhtml @@ -1,15 +1,15 @@

    <%=l(:label_document_new)%>

    - -<% form_tag( { :action => 'add_document', :id => @project }, :class => "tabular", :multipart => true) do %> + +<% form_tag( { :action => 'add_document', :id => @project }, :class => "tabular", :multipart => true) do %> <%= render :partial => 'documents/form' %> -
    +

    <%= file_field_tag 'attachments[]', :size => 30 %> (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)

    - + <%= submit_tag l(:button_create) %> <% end %> - + diff --git a/app/views/projects/add_file.rhtml b/app/views/projects/add_file.rhtml index 4df71e9d..f39018cc 100644 --- a/app/views/projects/add_file.rhtml +++ b/app/views/projects/add_file.rhtml @@ -1,15 +1,15 @@ -

    <%=l(:label_attachment_new)%>

    - -<%= error_messages_for 'attachment' %> -
    -<% form_tag({ :action => 'add_file', :id => @project }, :multipart => true, :class => "tabular") do %> - -

    -<%= select_tag "version_id", options_from_collection_for_select(@versions, "id", "name") %>

    - -

    -<%= file_field_tag 'attachments[]', :size => 30 %> (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)

    -
    -<%= submit_tag l(:button_add) %> +

    <%=l(:label_attachment_new)%>

    + +<%= error_messages_for 'attachment' %> +
    +<% form_tag({ :action => 'add_file', :id => @project }, :multipart => true, :class => "tabular") do %> + +

    +<%= select_tag "version_id", options_from_collection_for_select(@versions, "id", "name") %>

    + +

    +<%= file_field_tag 'attachments[]', :size => 30 %> (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)

    +
    +<%= submit_tag l(:button_add) %> <% end %> \ No newline at end of file diff --git a/app/views/projects/add_issue.rhtml b/app/views/projects/add_issue.rhtml index f35bb415..1c51f1fc 100644 --- a/app/views/projects/add_issue.rhtml +++ b/app/views/projects/add_issue.rhtml @@ -1,5 +1,5 @@

    <%=l(:label_issue_new)%>: <%= @tracker.name %>

    - + <% labelled_tabular_form_for :issue, @issue, :url => {:action => 'add_issue'}, :html => {:multipart => true} do |f| %> <%= error_messages_for 'issue' %>
    @@ -7,9 +7,9 @@ <%= hidden_field_tag 'tracker_id', @tracker.id %>
    -

    <%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), :required => true %>

    -

    <%= f.select :assigned_to_id, (@issue.project.members.collect {|m| [m.name, m.user_id]}), :include_blank => true %>

    -

    <%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %>

    +

    <%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), :required => true %>

    +

    <%= f.select :assigned_to_id, (@issue.project.members.collect {|m| [m.name, m.user_id]}), :include_blank => true %>

    +

    <%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %>

    <%= f.text_field :start_date, :size => 10 %><%= calendar_for('issue_start_date') %>

    @@ -20,11 +20,11 @@

    <%= f.text_field :subject, :size => 80, :required => true %>

    <%= f.text_area :description, :cols => 60, :rows => 10, :required => true, :class => 'wiki-edit' %>

    - + <% for @custom_value in @custom_values %>

    <%= custom_field_tag_with_label @custom_value %>

    -<% end %> - +<% end %> +

    <%= file_field_tag 'attachments[]', :size => 30 %> (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)

    @@ -32,7 +32,7 @@
    -<%= submit_tag l(:button_create) %> +<%= submit_tag l(:button_create) %> <% end %> <% if Setting.text_formatting == 'textile' %> diff --git a/app/views/projects/add_query.rhtml b/app/views/projects/add_query.rhtml index 5dbf881d..1de027a4 100644 --- a/app/views/projects/add_query.rhtml +++ b/app/views/projects/add_query.rhtml @@ -1,6 +1,6 @@ -

    <%= l(:label_query_new) %>

    - -<% form_tag({:action => 'add_query', :id => @project}) do %> - <%= render :partial => 'queries/form', :locals => {:query => @query} %> - <%= submit_tag l(:button_create) %> +

    <%= l(:label_query_new) %>

    + +<% form_tag({:action => 'add_query', :id => @project}) do %> + <%= render :partial => 'queries/form', :locals => {:query => @query} %> + <%= 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 index ec7d485e..154c5618 100644 --- a/app/views/projects/calendar.rhtml +++ b/app/views/projects/calendar.rhtml @@ -1,74 +1,74 @@ -

    <%= l(:label_calendar) %>

    - -<% form_tag({:action => 'calendar', :id => @project}) do %> - - - - - - -
    - <%= link_to_remote ('« ' + (@month==1 ? "#{month_name(12)} #{@year-1}" : "#{month_name(@month-1)}")), - {: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))} - %> - - <%= select_month(@month, :prefix => "month", :discard_type => true) %> - <%= select_year(@year, :prefix => "year", :discard_type => true) %> - <%= submit_tag l(:button_submit), :class => "button-small" %> - - <%= link_to_remote ((@month==12 ? "#{month_name(1)} #{@year+1}" : "#{month_name(@month+1)}") + ' »'), - {: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))} - %>  -
    -<% end %> -
    - - - - - -<% 1.upto(7) do |d| %> - -<% end %> - - - - -<% day = @date_from -while day <= @date_to - if day.cwday == 1 %> - - <% end %> - - <%= '' if day.cwday >= 7 and day!=@date_to %> - <% - day = day + 1 -end %> - - -
    <%= day_name(d) %>
    <%= day.cweek %>" style="width:14%; <%= Date.today == day ? 'background:#FDFED0;' : '' %>"> -

    <%= day==Date.today ? "#{day.day}" : day.day %>

    - <% 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.png') - elsif day == i.start_date - image_tag('arrow_from.png') - elsif day == i.due_date - image_tag('arrow_to.png') - end %> - <%= link_to "#{i.tracker.name} ##{i.id}", { :controller => 'issues', :action => 'show', :id => i } %>: <%=h i.subject.sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)') %> - - <%= render :partial => "issues/tooltip", :locals => { :issue => i }%> - -
    - <% end %> -
    - -<%= image_tag 'arrow_from.png' %>  <%= l(:text_tip_task_begin_day) %>
    -<%= image_tag 'arrow_to.png' %>  <%= l(:text_tip_task_end_day) %>
    +

    <%= l(:label_calendar) %>

    + +<% form_tag({:action => 'calendar', :id => @project}) do %> + + + + + + +
    + <%= link_to_remote ('« ' + (@month==1 ? "#{month_name(12)} #{@year-1}" : "#{month_name(@month-1)}")), + {: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))} + %> + + <%= select_month(@month, :prefix => "month", :discard_type => true) %> + <%= select_year(@year, :prefix => "year", :discard_type => true) %> + <%= submit_tag l(:button_submit), :class => "button-small" %> + + <%= link_to_remote ((@month==12 ? "#{month_name(1)} #{@year+1}" : "#{month_name(@month+1)}") + ' »'), + {: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))} + %>  +
    +<% end %> +
    + + + + + +<% 1.upto(7) do |d| %> + +<% end %> + + + + +<% day = @date_from +while day <= @date_to + if day.cwday == 1 %> + + <% end %> + + <%= '' if day.cwday >= 7 and day!=@date_to %> + <% + day = day + 1 +end %> + + +
    <%= day_name(d) %>
    <%= day.cweek %>" style="width:14%; <%= Date.today == day ? 'background:#FDFED0;' : '' %>"> +

    <%= day==Date.today ? "#{day.day}" : day.day %>

    + <% 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.png') + elsif day == i.start_date + image_tag('arrow_from.png') + elsif day == i.due_date + image_tag('arrow_to.png') + end %> + <%= link_to "#{i.tracker.name} ##{i.id}", { :controller => 'issues', :action => 'show', :id => i } %>: <%=h i.subject.sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)') %> + + <%= render :partial => "issues/tooltip", :locals => { :issue => i }%> + +
    + <% end %> +
    + +<%= image_tag 'arrow_from.png' %>  <%= l(:text_tip_task_begin_day) %>
    +<%= image_tag 'arrow_to.png' %>  <%= l(:text_tip_task_end_day) %>
    <%= image_tag 'arrow_bw.png' %>  <%= l(:text_tip_task_begin_end_day) %>
    \ No newline at end of file diff --git a/app/views/projects/changelog.rhtml b/app/views/projects/changelog.rhtml index c2a72763..9cebd409 100644 --- a/app/views/projects/changelog.rhtml +++ b/app/views/projects/changelog.rhtml @@ -1,30 +1,30 @@ -

    <%=l(:label_change_log)%>

    - -
    - -
    -<% form_tag do %> -

    <%=l(:label_tracker_plural)%>

    -<% @trackers.each do |tracker| %> - <%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %> - <%= tracker.name %>
    -<% end %> -

    <%= submit_tag l(:button_apply), :class => 'button-small' %>

    -<% end %> -
    - -<% if @fixed_issues.empty? %>

    <%= l(:label_no_data) %>

    <% end %> - -<% ver_id = nil - @fixed_issues.each do |issue| %> - <% unless ver_id == issue.fixed_version_id %> - <% if ver_id %><% end %> -

    <%= issue.fixed_version.name %>

    -

    <%= format_date(issue.fixed_version.effective_date) %>
    - <%=h issue.fixed_version.description %>

    -
      - <% ver_id = issue.fixed_version_id - end %> -
    • <%= link_to "#{issue.tracker.name} #{issue.id}", :controller => 'issues', :action => 'show', :id => issue %>: <%=h issue.subject %>
    • -<% end %> +

      <%=l(:label_change_log)%>

      + +
      + +
      +<% form_tag do %> +

      <%=l(:label_tracker_plural)%>

      +<% @trackers.each do |tracker| %> + <%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %> + <%= tracker.name %>
      +<% end %> +

      <%= submit_tag l(:button_apply), :class => 'button-small' %>

      +<% end %> +
      + +<% if @fixed_issues.empty? %>

      <%= l(:label_no_data) %>

      <% end %> + +<% ver_id = nil + @fixed_issues.each do |issue| %> + <% unless ver_id == issue.fixed_version_id %> + <% if ver_id %>
    <% end %> +

    <%= issue.fixed_version.name %>

    +

    <%= format_date(issue.fixed_version.effective_date) %>
    + <%=h issue.fixed_version.description %>

    +
      + <% ver_id = issue.fixed_version_id + end %> +
    • <%= link_to "#{issue.tracker.name} #{issue.id}", :controller => 'issues', :action => 'show', :id => issue %>: <%=h issue.subject %>
    • +<% end %>
    \ No newline at end of file diff --git a/app/views/projects/destroy.rhtml b/app/views/projects/destroy.rhtml index 22b27e31..cb159216 100644 --- a/app/views/projects/destroy.rhtml +++ b/app/views/projects/destroy.rhtml @@ -1,14 +1,14 @@ -

    <%=l(:label_confirmation)%>

    -
    -
    -

    <%= @project.name %>
    -<%=l(:text_project_destroy_confirmation)%>

    - -

    - <% form_tag({:controller => 'projects', :action => 'destroy', :id => @project}) do %> - <%= hidden_field_tag "confirm", 1 %> - <%= submit_tag l(:button_delete) %> - <% end %> -

    -
    +

    <%=l(:label_confirmation)%>

    +
    +
    +

    <%= @project.name %>
    +<%=l(:text_project_destroy_confirmation)%>

    + +

    + <% form_tag({:controller => 'projects', :action => 'destroy', :id => @project}) do %> + <%= hidden_field_tag "confirm", 1 %> + <%= submit_tag l(:button_delete) %> + <% end %> +

    +
    \ No newline at end of file diff --git a/app/views/projects/gantt.rhtml b/app/views/projects/gantt.rhtml index 18e025f2..a846507a 100644 --- a/app/views/projects/gantt.rhtml +++ b/app/views/projects/gantt.rhtml @@ -1,215 +1,215 @@ -
    -<%= l(:label_export_to) %> -<%= link_to 'PDF', {:zoom => @zoom, :year => @year_from, :month => @month_from, :months => @months, :output => 'pdf'}, :class => 'icon icon-pdf' %> -
    - -

    <%= l(:label_gantt) %>

    - - - - - - -
    -<% form_tag do %> -

    - -<%= 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 %> -
    -<%= if @zoom < 4 - link_to image_tag('zoom_in.png'), {:zoom => (@zoom+1), :year => @year_from, :month => @month_from, :months => @months} - else - image_tag 'zoom_in_g.png' - end %> -<%= if @zoom > 1 - link_to image_tag('zoom_out.png'), :zoom => (@zoom-1), :year => @year_from, :month => @month_from, :months => @months - else - image_tag 'zoom_out_g.png' - end %> -
    -
    - -<% 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)+150, 206].max -t_height = g_height + headers_heigth -%> - - - - - - -
    - -
    -
    -
    -<% -# -# Tasks subjects -# -top = headers_heigth + 8 -@issues.each do |i| %> -
    - <%= link_to "#{i.tracker.name} ##{i.id}", { :controller => 'issues', :action => 'show', :id => i }, :title => "#{i.subject}" %>: - <%=h i.subject.sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)') %> -
    -<% top = top + 20 -end %> -
    -
    - -
    -
     
    -<% -# -# 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 - %> -
    - <%= link_to "#{month_f.year}-#{month_f.month}", { :year => month_f.year, :month => month_f.month, :zoom => @zoom, :months => @months }, :title => "#{month_name(month_f.month)} #{month_f.year}"%> -
    - <% - 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 - %> -
     
    - <% - 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 - %> -
    - <%= week_f.cweek if width >= 16 %> -
    - <% - 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 - %> -
    5 %>" class="gantt_hdr"> - <%= day_name(wday)[0,1] %> -
    - <% - 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 %> -
     
    -<% end %> - -<% -# -# Tasks -# -top = headers_heigth + 10 -@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 - 2 # total width of the issue (- 2 for left and right borders) - d_width = ((i_done_date - i_start_date)*zoom).floor - 2 # done width - l_width = i_late_date ? ((i_late_date - i_start_date+1)*zoom).floor - 2 : 0 # delay width - %> -
     
    - <% if l_width > 0 %> -
     
    - <% end %> - <% if d_width > 0 %> -
     
    - <% end %> -
    - <%= i.status.name %> - <%= (i.done_ratio).to_i %>% -
    - <% # === tooltip === %> -
    - - <%= render :partial => "issues/tooltip", :locals => { :issue => i }%> -
    - <% top = top + 20 -end %> -
    -
    - - - - - - +
    +<%= l(:label_export_to) %> +<%= link_to 'PDF', {:zoom => @zoom, :year => @year_from, :month => @month_from, :months => @months, :output => 'pdf'}, :class => 'icon icon-pdf' %> +
    + +

    <%= l(:label_gantt) %>

    + +
    <%= link_to ('« ' + l(:label_previous)), :year => (@date_from << @months).year, :month => (@date_from << @months).month, :zoom => @zoom, :months => @months %><%= link_to (l(:label_next) + ' »'), :year => (@date_from >> @months).year, :month => (@date_from >> @months).month, :zoom => @zoom, :months => @months %>
    + + + + +
    +<% form_tag do %> +

    + +<%= 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 %> +
    +<%= if @zoom < 4 + link_to image_tag('zoom_in.png'), {:zoom => (@zoom+1), :year => @year_from, :month => @month_from, :months => @months} + else + image_tag 'zoom_in_g.png' + end %> +<%= if @zoom > 1 + link_to image_tag('zoom_out.png'), :zoom => (@zoom-1), :year => @year_from, :month => @month_from, :months => @months + else + image_tag 'zoom_out_g.png' + end %> +
    +
    + +<% 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)+150, 206].max +t_height = g_height + headers_heigth +%> + + + + + + +
    + +
    +
    +
    +<% +# +# Tasks subjects +# +top = headers_heigth + 8 +@issues.each do |i| %> +
    + <%= link_to "#{i.tracker.name} ##{i.id}", { :controller => 'issues', :action => 'show', :id => i }, :title => "#{i.subject}" %>: + <%=h i.subject.sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)') %> +
    +<% top = top + 20 +end %> +
    +
    + +
    +
     
    +<% +# +# 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 + %> +
    + <%= link_to "#{month_f.year}-#{month_f.month}", { :year => month_f.year, :month => month_f.month, :zoom => @zoom, :months => @months }, :title => "#{month_name(month_f.month)} #{month_f.year}"%> +
    + <% + 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 + %> +
     
    + <% + 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 + %> +
    + <%= week_f.cweek if width >= 16 %> +
    + <% + 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 + %> +
    5 %>" class="gantt_hdr"> + <%= day_name(wday)[0,1] %> +
    + <% + 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 %> +
     
    +<% end %> + +<% +# +# Tasks +# +top = headers_heigth + 10 +@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 - 2 # total width of the issue (- 2 for left and right borders) + d_width = ((i_done_date - i_start_date)*zoom).floor - 2 # done width + l_width = i_late_date ? ((i_late_date - i_start_date+1)*zoom).floor - 2 : 0 # delay width + %> +
     
    + <% if l_width > 0 %> +
     
    + <% end %> + <% if d_width > 0 %> +
     
    + <% end %> +
    + <%= i.status.name %> + <%= (i.done_ratio).to_i %>% +
    + <% # === tooltip === %> +
    + + <%= render :partial => "issues/tooltip", :locals => { :issue => i }%> +
    + <% top = top + 20 +end %> +
    +
    + + + + + +
    <%= link_to ('« ' + l(:label_previous)), :year => (@date_from << @months).year, :month => (@date_from << @months).month, :zoom => @zoom, :months => @months %><%= link_to (l(:label_next) + ' »'), :year => (@date_from >> @months).year, :month => (@date_from >> @months).month, :zoom => @zoom, :months => @months %>
    \ No newline at end of file diff --git a/app/views/projects/list.rhtml b/app/views/projects/list.rhtml index 0723a708..5e1a63f9 100644 --- a/app/views/projects/list.rhtml +++ b/app/views/projects/list.rhtml @@ -2,20 +2,20 @@ - <%= sort_header_tag('name', :caption => l(:label_project)) %> - + <%= sort_header_tag('name', :caption => l(:label_project)) %> + <%= sort_header_tag('created_on', :caption => l(:field_created_on)) %> <% for project in @projects %> - "> - - - + "> + + + <% end %> -
    <%=l(:field_description)%><%=l(:field_description)%>
    <%= link_to project.name, :action => 'show', :id => project %><%=h project.description %><%= format_date(project.created_on) %>
    <%= link_to project.name, :action => 'show', :id => project %><%=h project.description %><%= format_date(project.created_on) %>
    - + + <%= 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 index ab48bada..b692808b 100644 --- a/app/views/projects/list_documents.rhtml +++ b/app/views/projects/list_documents.rhtml @@ -1,13 +1,13 @@ -
    -<%= link_to_if_authorized l(:label_document_new), {:controller => 'projects', :action => 'add_document', :id => @project}, :class => 'icon icon-add' %> -
    - -

    <%=l(:label_document_plural)%>

    - -<% if @documents.empty? %>

    <%= l(:label_no_data) %>

    <% end %> - -<% documents = @documents.group_by {|d| d.category } %> -<% documents.each do |category, docs| %> -

    <%= category.name %>

    - <%= render :partial => 'documents/document', :collection => docs %> +
    +<%= link_to_if_authorized l(:label_document_new), {:controller => 'projects', :action => 'add_document', :id => @project}, :class => 'icon icon-add' %> +
    + +

    <%=l(:label_document_plural)%>

    + +<% if @documents.empty? %>

    <%= l(:label_no_data) %>

    <% end %> + +<% documents = @documents.group_by {|d| d.category } %> +<% documents.each do |category, docs| %> +

    <%= category.name %>

    + <%= render :partial => 'documents/document', :collection => docs %> <% end %> \ No newline at end of file diff --git a/app/views/projects/list_files.rhtml b/app/views/projects/list_files.rhtml index 0236b2ea..288afae2 100644 --- a/app/views/projects/list_files.rhtml +++ b/app/views/projects/list_files.rhtml @@ -1,44 +1,44 @@ -
    -<%= link_to_if_authorized l(:label_attachment_new), {:controller => 'projects', :action => 'add_file', :id => @project}, :class => 'icon icon-add' %> -
    - -

    <%=l(:label_attachment_plural)%>

    - -<% delete_allowed = authorize_for('versions', 'destroy_file') %> - - - - - - - - - - <% if delete_allowed %><% end %> - - -<% for version in @versions %> - <% unless version.attachments.empty? %> - +
    +<%= link_to_if_authorized l(:label_attachment_new), {:controller => 'projects', :action => 'add_file', :id => @project}, :class => 'icon icon-add' %> +
    + +

    <%=l(:label_attachment_plural)%>

    + +<% delete_allowed = authorize_for('versions', 'destroy_file') %> + +
    <%=l(:field_version)%><%=l(:field_filename)%><%=l(:label_date)%><%=l(:field_filesize)%>D/LMD5
    <%= version.name %>
    + + + + + + + + <% if delete_allowed %><% end %> + + +<% for version in @versions %> + <% unless version.attachments.empty? %> + <% for file in version.attachments %> - "> - - - - + "> + + + + - - <% if delete_allowed %> - + + <% if delete_allowed %> + <% end %> - <% end - reset_cycle %> - <% end %> -<% end %> - + <% end + reset_cycle %> + <% end %> +<% end %> +
    <%=l(:field_version)%><%=l(:field_filename)%><%=l(:label_date)%><%=l(:field_filesize)%>D/LMD5
    <%= version.name %>
    <%= link_to file.filename, :controller => 'versions', :action => 'download', :id => version, :attachment_id => file %><%= format_date(file.created_on) %><%= number_to_human_size(file.filesize) %>
    <%= link_to file.filename, :controller => 'versions', :action => 'download', :id => version, :attachment_id => file %><%= format_date(file.created_on) %><%= number_to_human_size(file.filesize) %> <%= file.downloads %><%= file.digest %> -
    - <%= link_to_if_authorized '', {:controller => 'versions', :action => 'destroy_file', :id => version, :attachment_id => file}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> -
    -
    <%= file.digest %> +
    + <%= link_to_if_authorized '', {:controller => 'versions', :action => 'destroy_file', :id => version, :attachment_id => file}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> +
    +
    \ No newline at end of file diff --git a/app/views/projects/list_issues.rhtml b/app/views/projects/list_issues.rhtml index c3bd13fe..6f6e031f 100644 --- a/app/views/projects/list_issues.rhtml +++ b/app/views/projects/list_issues.rhtml @@ -1,84 +1,84 @@ -<% if @query.new_record? %> -
    - <%= render :partial => 'issues/add_shortcut', :locals => {:trackers => @trackers } %> -
    -

    <%=l(:label_issue_plural)%>

    - - <% form_tag({:action => 'list_issues'}, :id => 'query_form') do %> - <%= render :partial => 'queries/filters', :locals => {:query => @query} %> - <% end %> -
    - <%= link_to_remote l(:button_apply), - { :url => { :controller => 'projects', :action => 'list_issues', :id => @project, :set_filter => 1 }, - :update => "content", - :with => "Form.serialize('query_form')" - }, :class => 'icon icon-edit' %> - - <%= link_to l(:button_clear), {:controller => 'projects', :action => 'list_issues', :id => @project, :set_filter => 1}, :class => 'icon icon-del' %> - <% if authorize_for('projects', 'add_query') %> - - <%= link_to_remote l(:button_save), - { :url => { :controller => 'projects', :action => "add_query", :id => @project }, - :method => 'get', - :update => "content", - :with => "Form.serialize('query_form')" - }, :class => 'icon icon-save' %> - <% end %> -
    -
    -<% else %> -
    - <%= render :partial => 'issues/add_shortcut', :locals => {:trackers => @trackers } %> - <% if authorize_for('projects', 'add_query') %> - <%= link_to l(:button_edit), {:controller => 'queries', :action => 'edit', :id => @query}, :class => 'icon icon-edit' %> - <%= link_to l(:button_delete), {:controller => 'queries', :action => 'destroy', :id => @query}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> - <% end %> -
    -

    <%= @query.name %>

    -<% end %> -<%= error_messages_for 'query' %> -<% if @query.valid? %> -<% if @issues.empty? %> -

    <%= l(:label_no_data) %>

    -<% else %> -  -<% form_tag({:controller => 'projects', :action => 'move_issues', :id => @project}, :id => 'issues_form' ) do %> - - - - <%= sort_header_tag('issues.id', :caption => '#') %> - <%= sort_header_tag('issues.tracker_id', :caption => l(:field_tracker)) %> - <%= sort_header_tag('issue_statuses.name', :caption => l(:field_status)) %> - <%= sort_header_tag('issues.priority_id', :caption => l(:field_priority)) %> - - <%= sort_header_tag('users.lastname', :caption => l(:field_author)) %> - <%= sort_header_tag('issues.updated_on', :caption => l(:field_updated_on)) %> - - +<% if @query.new_record? %> +
    + <%= render :partial => 'issues/add_shortcut', :locals => {:trackers => @trackers } %> +
    +

    <%=l(:label_issue_plural)%>

    + + <% form_tag({:action => 'list_issues'}, :id => 'query_form') do %> + <%= render :partial => 'queries/filters', :locals => {:query => @query} %> + <% end %> +
    + <%= link_to_remote l(:button_apply), + { :url => { :controller => 'projects', :action => 'list_issues', :id => @project, :set_filter => 1 }, + :update => "content", + :with => "Form.serialize('query_form')" + }, :class => 'icon icon-edit' %> + + <%= link_to l(:button_clear), {:controller => 'projects', :action => 'list_issues', :id => @project, :set_filter => 1}, :class => 'icon icon-del' %> + <% if authorize_for('projects', 'add_query') %> + + <%= link_to_remote l(:button_save), + { :url => { :controller => 'projects', :action => "add_query", :id => @project }, + :method => 'get', + :update => "content", + :with => "Form.serialize('query_form')" + }, :class => 'icon icon-save' %> + <% end %> +
    +
    +<% else %> +
    + <%= render :partial => 'issues/add_shortcut', :locals => {:trackers => @trackers } %> + <% if authorize_for('projects', 'add_query') %> + <%= link_to l(:button_edit), {:controller => 'queries', :action => 'edit', :id => @query}, :class => 'icon icon-edit' %> + <%= link_to l(:button_delete), {:controller => 'queries', :action => 'destroy', :id => @query}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> + <% end %> +
    +

    <%= @query.name %>

    +<% end %> +<%= error_messages_for 'query' %> +<% if @query.valid? %> +<% if @issues.empty? %> +

    <%= l(:label_no_data) %>

    +<% else %> +  +<% form_tag({:controller => 'projects', :action => 'move_issues', :id => @project}, :id => 'issues_form' ) do %> +
    <%=l(:field_subject)%>
    + + + <%= sort_header_tag('issues.id', :caption => '#') %> + <%= sort_header_tag('issues.tracker_id', :caption => l(:field_tracker)) %> + <%= sort_header_tag('issue_statuses.name', :caption => l(:field_status)) %> + <%= sort_header_tag('issues.priority_id', :caption => l(:field_priority)) %> + + <%= sort_header_tag('users.lastname', :caption => l(:field_author)) %> + <%= sort_header_tag('issues.updated_on', :caption => l(:field_updated_on)) %> + + <% for issue in @issues %> - "> - - - - - + "> + + + + + - <% end %> + <% end %> -
    <%=l(:field_subject)%>
    <%= check_box_tag "issue_ids[]", issue.id, false, :id => "issue_#{issue.id}" %><%= link_to issue.id, :controller => 'issues', :action => 'show', :id => issue %><%= issue.tracker.name %>
    <%= issue.status.name %>
    <%= issue.priority.name %>
    <%= check_box_tag "issue_ids[]", issue.id, false, :id => "issue_#{issue.id}" %><%= link_to issue.id, :controller => 'issues', :action => 'show', :id => issue %><%= issue.tracker.name %>
    <%= issue.status.name %>
    <%= issue.priority.name %> <%= link_to h(issue.subject), :controller => 'issues', :action => 'show', :id => issue %> <%= issue.author.display_name %> <%= format_time(issue.updated_on) %>
    -
    -<%= l(:label_export_to) %> -<%= link_to 'CSV', {:action => 'export_issues_csv', :id => @project}, :class => 'icon icon-csv' %>, -<%= link_to 'PDF', {:action => 'export_issues_pdf', :id => @project}, :class => 'icon icon-pdf' %> -
    -

    <%= submit_tag l(:button_move), :class => "button-small" %> -  -<%= pagination_links_full @issue_pages %> -[ <%= @issue_pages.current.first_item %> - <%= @issue_pages.current.last_item %> / <%= @issue_count %> ] -

    -<% end %> -<% end %> + +
    +<%= l(:label_export_to) %> +<%= link_to 'CSV', {:action => 'export_issues_csv', :id => @project}, :class => 'icon icon-csv' %>, +<%= link_to 'PDF', {:action => 'export_issues_pdf', :id => @project}, :class => 'icon icon-pdf' %> +
    +

    <%= submit_tag l(:button_move), :class => "button-small" %> +  +<%= pagination_links_full @issue_pages %> +[ <%= @issue_pages.current.first_item %> - <%= @issue_pages.current.last_item %> / <%= @issue_count %> ] +

    +<% end %> +<% end %> <% end %> \ No newline at end of file diff --git a/app/views/projects/list_members.rhtml b/app/views/projects/list_members.rhtml index e98a8c67..c4d3ec46 100644 --- a/app/views/projects/list_members.rhtml +++ b/app/views/projects/list_members.rhtml @@ -1,13 +1,13 @@ -

    <%=l(:label_member_plural)%>

    - -<% if @members.empty? %>

    <%= l(:label_no_data) %>

    <% end %> - -<% members = @members.group_by {|m| m.role } %> -<% members.keys.sort{|x,y| x.position <=> y.position}.each do |role| %> -

    <%= role.name %>

    -
      -<% members[role].each do |m| %> -
    • <%= link_to m.user.display_name, :controller => 'account', :action => 'show', :id => m.user %> (<%= format_date m.created_on %>)
    • -<% end %> -
    -<% end %> +

    <%=l(:label_member_plural)%>

    + +<% if @members.empty? %>

    <%= l(:label_no_data) %>

    <% end %> + +<% members = @members.group_by {|m| m.role } %> +<% members.keys.sort{|x,y| x.position <=> y.position}.each do |role| %> +

    <%= role.name %>

    +
      +<% members[role].each do |m| %> +
    • <%= link_to m.user.display_name, :controller => 'account', :action => 'show', :id => m.user %> (<%= format_date m.created_on %>)
    • +<% end %> +
    +<% end %> diff --git a/app/views/projects/list_news.rhtml b/app/views/projects/list_news.rhtml index 6cdf75c4..17a78626 100644 --- a/app/views/projects/list_news.rhtml +++ b/app/views/projects/list_news.rhtml @@ -6,4 +6,4 @@ <% if @news.empty? %>

    <%= l(:label_no_data) %>

    <% end %> <%= render :partial => 'news/news', :collection => @news %> -<%= pagination_links_full @news_pages %> +<%= pagination_links_full @news_pages %> diff --git a/app/views/projects/roadmap.rhtml b/app/views/projects/roadmap.rhtml index 2fb1df02..0aac5a7e 100644 --- a/app/views/projects/roadmap.rhtml +++ b/app/views/projects/roadmap.rhtml @@ -1,28 +1,28 @@ -

    <%=l(:label_roadmap)%>

    - -
    - -
    -<% form_tag do %> -

    <%=l(:label_tracker_plural)%>

    -<% @trackers.each do |tracker| %> - <%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %> - <%= tracker.name %>
    -<% end %> -

    <%= submit_tag l(:button_apply), :class => 'button-small' %>

    -<% end %> -
    - -<% if @versions.empty? %>

    <%= l(:label_no_data) %>

    <% end %> - -<% @versions.each do |version| %> -

    <%= version.name %>

    -

    <%= format_date(version.effective_date) %>
    - <%=h version.description %>

    -
      - <% version.fixed_issues.find(:all, :conditions => ["issues.tracker_id in (#{@selected_tracker_ids.join(',')})"]).each do |issue| %> -
    • <%= link_to "#{issue.tracker.name} #{issue.id}", :controller => 'issues', :action => 'show', :id => issue %>: <%=h issue.subject %>
    • - <% end %> -
    -<% end %> +

    <%=l(:label_roadmap)%>

    + +
    + +
    +<% form_tag do %> +

    <%=l(:label_tracker_plural)%>

    +<% @trackers.each do |tracker| %> + <%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %> + <%= tracker.name %>
    +<% end %> +

    <%= submit_tag l(:button_apply), :class => 'button-small' %>

    +<% end %> +
    + +<% if @versions.empty? %>

    <%= l(:label_no_data) %>

    <% end %> + +<% @versions.each do |version| %> +

    <%= version.name %>

    +

    <%= format_date(version.effective_date) %>
    + <%=h version.description %>

    +
      + <% version.fixed_issues.find(:all, :conditions => ["issues.tracker_id in (#{@selected_tracker_ids.join(',')})"]).each do |issue| %> +
    • <%= link_to "#{issue.tracker.name} #{issue.id}", :controller => 'issues', :action => 'show', :id => issue %>: <%=h issue.subject %>
    • + <% end %> +
    +<% end %>
    \ No newline at end of file diff --git a/app/views/projects/search.rhtml b/app/views/projects/search.rhtml index d38cb3b4..056effd4 100644 --- a/app/views/projects/search.rhtml +++ b/app/views/projects/search.rhtml @@ -1,43 +1,43 @@ -

    <%= l(:label_search) %>

    - -
    -<% form_tag({:action => 'search', :id => @project}, :method => :get) do %> -

    <%= text_field_tag 'q', @question, :size => 30 %> -<%= check_box_tag 'scope[]', 'issues', (@scope.include? 'issues') %> -<%= check_box_tag 'scope[]', 'news', (@scope.include? 'news') %> -<%= check_box_tag 'scope[]', 'documents', (@scope.include? 'documents') %> -<% if @project.wiki %> -<%= check_box_tag 'scope[]', 'wiki', (@scope.include? 'wiki') %> -<% end %> -
    -<%= check_box_tag 'all_words', 1, @all_words %> <%= l(:label_all_words) %>

    -<%= submit_tag l(:button_submit), :name => 'submit' %> -<% end %> -
    - -<% if @results %> -

    <%= lwr(:label_result, @results.length) %>

    -
      - <% @results.each do |e| %> -
    • - <% if e.is_a? Issue %> - <%= link_to "#{e.tracker.name} ##{e.id}", :controller => 'issues', :action => 'show', :id => e %>: <%= highlight_tokens(h(e.subject), @tokens) %>
      - <%= highlight_tokens(e.description, @tokens) %>
      - <%= e.author.name %>, <%= format_time(e.created_on) %> - <% elsif e.is_a? News %> - <%=l(:label_news)%>: <%= link_to highlight_tokens(h(e.title), @tokens), :controller => 'news', :action => 'show', :id => e %>
      - <%= highlight_tokens(e.description, @tokens) %>
      - <%= e.author.name %>, <%= format_time(e.created_on) %> - <% elsif e.is_a? Document %> - <%=l(:label_document)%>: <%= link_to highlight_tokens(h(e.title), @tokens), :controller => 'documents', :action => 'show', :id => e %>
      - <%= highlight_tokens(e.description, @tokens) %>
      - <%= format_time(e.created_on) %> - <% elsif e.is_a? WikiPage %> - <%=l(:label_wiki)%>: <%= link_to highlight_tokens(h(e.pretty_title), @tokens), :controller => 'wiki', :action => 'index', :id => @project, :page => e.title %>
      - <%= highlight_tokens(e.content.text, @tokens) %>
      - <%= e.content.author ? e.content.author.name : "Anonymous" %>, <%= format_time(e.content.updated_on) %> - <% end %> -

    • - <% end %> -
    +

    <%= l(:label_search) %>

    + +
    +<% form_tag({:action => 'search', :id => @project}, :method => :get) do %> +

    <%= text_field_tag 'q', @question, :size => 30 %> +<%= check_box_tag 'scope[]', 'issues', (@scope.include? 'issues') %> +<%= check_box_tag 'scope[]', 'news', (@scope.include? 'news') %> +<%= check_box_tag 'scope[]', 'documents', (@scope.include? 'documents') %> +<% if @project.wiki %> +<%= check_box_tag 'scope[]', 'wiki', (@scope.include? 'wiki') %> +<% end %> +
    +<%= check_box_tag 'all_words', 1, @all_words %> <%= l(:label_all_words) %>

    +<%= submit_tag l(:button_submit), :name => 'submit' %> +<% end %> +
    + +<% if @results %> +

    <%= lwr(:label_result, @results.length) %>

    +
      + <% @results.each do |e| %> +
    • + <% if e.is_a? Issue %> + <%= link_to "#{e.tracker.name} ##{e.id}", :controller => 'issues', :action => 'show', :id => e %>: <%= highlight_tokens(h(e.subject), @tokens) %>
      + <%= highlight_tokens(e.description, @tokens) %>
      + <%= e.author.name %>, <%= format_time(e.created_on) %> + <% elsif e.is_a? News %> + <%=l(:label_news)%>: <%= link_to highlight_tokens(h(e.title), @tokens), :controller => 'news', :action => 'show', :id => e %>
      + <%= highlight_tokens(e.description, @tokens) %>
      + <%= e.author.name %>, <%= format_time(e.created_on) %> + <% elsif e.is_a? Document %> + <%=l(:label_document)%>: <%= link_to highlight_tokens(h(e.title), @tokens), :controller => 'documents', :action => 'show', :id => e %>
      + <%= highlight_tokens(e.description, @tokens) %>
      + <%= format_time(e.created_on) %> + <% elsif e.is_a? WikiPage %> + <%=l(:label_wiki)%>: <%= link_to highlight_tokens(h(e.pretty_title), @tokens), :controller => 'wiki', :action => 'index', :id => @project, :page => e.title %>
      + <%= highlight_tokens(e.content.text, @tokens) %>
      + <%= e.content.author ? e.content.author.name : "Anonymous" %>, <%= format_time(e.content.updated_on) %> + <% end %> +

    • + <% end %> +
    <% end %> \ No newline at end of file diff --git a/app/views/projects/settings.rhtml b/app/views/projects/settings.rhtml index d5f9fab4..aaa4e652 100644 --- a/app/views/projects/settings.rhtml +++ b/app/views/projects/settings.rhtml @@ -10,7 +10,7 @@
    -<% if authorize_for('projects', 'edit') %> +<% 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) %> @@ -18,98 +18,98 @@ <% end %>
    - + + +<%= link_to_if_authorized l(:label_version_new), :controller => 'projects', :action => 'add_version', :id => @project %> +
    + <%= submit_tag l(:button_create) %> + <% end %> +<% end %> +
    <%= tab = params[:tab] ? h(params[:tab]) : 'info' javascript_tag "showTab('#{tab}');" %> \ No newline at end of file diff --git a/app/views/projects/show.rhtml b/app/views/projects/show.rhtml index 4c9e4e04..b38eceaa 100644 --- a/app/views/projects/show.rhtml +++ b/app/views/projects/show.rhtml @@ -1,55 +1,55 @@ -

    <%=l(:label_overview)%>

    - -
    - <%= simple_format(auto_link(h(@project.description))) %> -
      - <% unless @project.homepage.empty? %>
    • <%=l(:field_homepage)%>: <%= auto_link @project.homepage %>
    • <% end %> -
    • <%=l(:field_created_on)%>: <%= format_date(@project.created_on) %>
    • - <% for custom_value in @custom_values %> - <% if !custom_value.value.empty? %> -
    • <%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %>
    • - <% end %> - <% end %> -
    - -
    -
    - <%= render :partial => 'issues/add_shortcut', :locals => {:trackers => @trackers } %> -
    -

    <%=l(:label_tracker_plural)%>

    -
      - <% for tracker in @trackers %> -
    • <%= link_to tracker.name, :controller => 'projects', :action => 'list_issues', :id => @project, - :set_filter => 1, - "tracker_id" => tracker.id %>: - <%= @open_issues_by_tracker[tracker] || 0 %> <%= lwr(:label_open_issues, @open_issues_by_tracker[tracker] || 0) %> - <%= l(:label_on) %> <%= @total_issues_by_tracker[tracker] || 0 %>
    • - <% end %> -
    -

    <%= link_to l(:label_issue_view_all), :controller => 'projects', :action => 'list_issues', :id => @project, :set_filter => 1 %>

    +

    <%=l(:label_overview)%>

    + +
    + <%= simple_format(auto_link(h(@project.description))) %> +
      + <% unless @project.homepage.empty? %>
    • <%=l(:field_homepage)%>: <%= auto_link @project.homepage %>
    • <% end %> +
    • <%=l(:field_created_on)%>: <%= format_date(@project.created_on) %>
    • + <% for custom_value in @custom_values %> + <% if !custom_value.value.empty? %> +
    • <%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %>
    • + <% end %> + <% end %> +
    + +
    +
    + <%= render :partial => 'issues/add_shortcut', :locals => {:trackers => @trackers } %> +
    +

    <%=l(:label_tracker_plural)%>

    +
      + <% for tracker in @trackers %> +
    • <%= link_to tracker.name, :controller => 'projects', :action => 'list_issues', :id => @project, + :set_filter => 1, + "tracker_id" => tracker.id %>: + <%= @open_issues_by_tracker[tracker] || 0 %> <%= lwr(:label_open_issues, @open_issues_by_tracker[tracker] || 0) %> + <%= l(:label_on) %> <%= @total_issues_by_tracker[tracker] || 0 %>
    • + <% end %> +
    +

    <%= link_to l(:label_issue_view_all), :controller => 'projects', :action => 'list_issues', :id => @project, :set_filter => 1 %>

    -
    - -
    -
    -

    <%=l(:label_member_plural)%>

    - <% for member in @members %> - <%= link_to_user member.user %> (<%= member.role.name %>)
    - <% end %> -
    - - <% if @subprojects %> -
    -

    <%=l(:label_subproject_plural)%>

    - <% for subproject in @subprojects %> - <%= link_to subproject.name, :action => 'show', :id => subproject %>
    - <% end %> -
    - <% end %> - -
    -

    <%=l(:label_news_latest)%>

    +
    + +
    +
    +

    <%=l(:label_member_plural)%>

    + <% for member in @members %> + <%= link_to_user member.user %> (<%= member.role.name %>)
    + <% end %> +
    + + <% if @subprojects %> +
    +

    <%=l(:label_subproject_plural)%>

    + <% for subproject in @subprojects %> + <%= link_to subproject.name, :action => 'show', :id => subproject %>
    + <% end %> +
    + <% end %> + +
    +

    <%=l(:label_news_latest)%>

    <%= render :partial => 'news/news', :collection => @news %> -

    <%= link_to l(:label_news_view_all), :controller => 'projects', :action => 'list_news', :id => @project %>

    -
    +

    <%= link_to l(:label_news_view_all), :controller => 'projects', :action => 'list_news', :id => @project %>

    +
    \ No newline at end of file diff --git a/app/views/queries/_filters.rhtml b/app/views/queries/_filters.rhtml index 3b73a9d7..aa64dbb8 100644 --- a/app/views/queries/_filters.rhtml +++ b/app/views/queries/_filters.rhtml @@ -1,100 +1,100 @@ - - -
    <%= l(:label_filter_plural) %> - - - - - -
    - -<% query.available_filters.sort{|a,b| a[1][:order]<=>b[1][:order]}.each do |filter| %> - <% field = filter[0] - options = filter[1] %> - id="tr_<%= field %>"> - - - - -<% end %> -
    - <%= check_box_tag 'fields[]', field, query.has_filter?(field), :onclick => "toggle_filter('#{field}');", :id => "cb_#{field}" %> - - - <%= select_tag "operators[#{field}]", options_for_select(operators_for_select(options[:type]), query.operator_for(field)), :id => "operators_#{field}", :onchange => "toggle_operator('#{field}');", :class => "select-small", :style => "vertical-align: top;" %> - -
    - <% case options[:type] - when :list, :list_optional, :list_status %> - - <%= link_to_function image_tag('expand.png'), "toggle_multi_select('#{field}');" %> - <% when :date, :date_past %> - <%= text_field_tag "values[#{field}][]", query.values_for(field), :id => "values_#{field}", :size => 3, :class => "select-small" %> <%= l(:label_day_plural) %> - <% when :text %> - <%= text_field_tag "values[#{field}][]", query.values_for(field), :id => "values_#{field}", :size => 30, :class => "select-small" %> - <% end %> -
    - -
    -
    -<%= l(:label_filter_add) %>: -<%= select_tag 'add_filter_select', options_for_select([["",""]] + query.available_filters.sort{|a,b| a[1][:order]<=>b[1][:order]}.collect{|field| [l(("field_"+field[0].to_s.gsub(/\_id$/, "")).to_sym), field[0]] unless query.has_filter?(field[0])}.compact), :onchange => "add_filter();", :class => "select-small" %> -
    + + +
    <%= l(:label_filter_plural) %> + + + + + +
    + +<% query.available_filters.sort{|a,b| a[1][:order]<=>b[1][:order]}.each do |filter| %> + <% field = filter[0] + options = filter[1] %> + id="tr_<%= field %>"> + + + + +<% end %> +
    + <%= check_box_tag 'fields[]', field, query.has_filter?(field), :onclick => "toggle_filter('#{field}');", :id => "cb_#{field}" %> + + + <%= select_tag "operators[#{field}]", options_for_select(operators_for_select(options[:type]), query.operator_for(field)), :id => "operators_#{field}", :onchange => "toggle_operator('#{field}');", :class => "select-small", :style => "vertical-align: top;" %> + +
    + <% case options[:type] + when :list, :list_optional, :list_status %> + + <%= link_to_function image_tag('expand.png'), "toggle_multi_select('#{field}');" %> + <% when :date, :date_past %> + <%= text_field_tag "values[#{field}][]", query.values_for(field), :id => "values_#{field}", :size => 3, :class => "select-small" %> <%= l(:label_day_plural) %> + <% when :text %> + <%= text_field_tag "values[#{field}][]", query.values_for(field), :id => "values_#{field}", :size => 30, :class => "select-small" %> + <% end %> +
    + +
    +
    +<%= l(:label_filter_add) %>: +<%= select_tag 'add_filter_select', options_for_select([["",""]] + query.available_filters.sort{|a,b| a[1][:order]<=>b[1][:order]}.collect{|field| [l(("field_"+field[0].to_s.gsub(/\_id$/, "")).to_sym), field[0]] unless query.has_filter?(field[0])}.compact), :onchange => "add_filter();", :class => "select-small" %> +
    \ No newline at end of file diff --git a/app/views/reports/_details.rhtml b/app/views/reports/_details.rhtml index e52538f7..323816a1 100644 --- a/app/views/reports/_details.rhtml +++ b/app/views/reports/_details.rhtml @@ -1,48 +1,48 @@ -<% if @statuses.empty? or rows.empty? %> -

    <%=l(:label_no_data)%>

    -<% else %> -<% col_width = 70 / (@statuses.length+3) %> - - - -<% for status in @statuses %> - -<% end %> - - - - - -<% for row in rows %> -"> - - <% for status in @statuses %> - - <% end %> - - - - -<% end %> - -
    <%= status.name %>
    <%=l(:label_open_issues_plural)%><%=l(:label_closed_issues_plural)%><%=l(:label_total)%>
    <%= link_to row.name, :controller => 'projects', :action => 'list_issues', :id => @project, - :set_filter => 1, - "#{field_name}" => row.id %><%= 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 %><%= 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" %><%= 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" %><%= link_to (aggregate data, { field_name => row.id }), - :controller => 'projects', :action => 'list_issues', :id => @project, - :set_filter => 1, - "#{field_name}" => row.id, - "status_id" => "*" %>
    -<% end +<% if @statuses.empty? or rows.empty? %> +

    <%=l(:label_no_data)%>

    +<% else %> +<% col_width = 70 / (@statuses.length+3) %> + + + +<% for status in @statuses %> + +<% end %> + + + + + +<% for row in rows %> +"> + + <% for status in @statuses %> + + <% end %> + + + + +<% end %> + +
    <%= status.name %>
    <%=l(:label_open_issues_plural)%><%=l(:label_closed_issues_plural)%><%=l(:label_total)%>
    <%= link_to row.name, :controller => 'projects', :action => 'list_issues', :id => @project, + :set_filter => 1, + "#{field_name}" => row.id %><%= 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 %><%= 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" %><%= 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" %><%= link_to (aggregate data, { field_name => row.id }), + :controller => 'projects', :action => 'list_issues', :id => @project, + :set_filter => 1, + "#{field_name}" => row.id, + "status_id" => "*" %>
    +<% end reset_cycle %> \ No newline at end of file diff --git a/app/views/reports/_simple.rhtml b/app/views/reports/_simple.rhtml index 1e66210f..0e580fe7 100644 --- a/app/views/reports/_simple.rhtml +++ b/app/views/reports/_simple.rhtml @@ -1,37 +1,37 @@ -<% if @statuses.empty? or rows.empty? %> -

    <%=l(:label_no_data)%>

    -<% else %> - - - - - - - - -<% for row in rows %> -"> - - - - - -<% end %> - -
    <%=l(:label_open_issues_plural)%><%=l(:label_closed_issues_plural)%><%=l(:label_total)%>
    <%= link_to row.name, :controller => 'projects', :action => 'list_issues', :id => @project, - :set_filter => 1, - "#{field_name}" => row.id %><%= 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" %><%= 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" %><%= link_to (aggregate data, { field_name => row.id }), - :controller => 'projects', :action => 'list_issues', :id => @project, - :set_filter => 1, - "#{field_name}" => row.id, - "status_id" => "*" %>
    -<% end +<% if @statuses.empty? or rows.empty? %> +

    <%=l(:label_no_data)%>

    +<% else %> + + + + + + + + +<% for row in rows %> +"> + + + + + +<% end %> + +
    <%=l(:label_open_issues_plural)%><%=l(:label_closed_issues_plural)%><%=l(:label_total)%>
    <%= link_to row.name, :controller => 'projects', :action => 'list_issues', :id => @project, + :set_filter => 1, + "#{field_name}" => row.id %><%= 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" %><%= 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" %><%= link_to (aggregate data, { field_name => row.id }), + :controller => 'projects', :action => 'list_issues', :id => @project, + :set_filter => 1, + "#{field_name}" => row.id, + "status_id" => "*" %>
    +<% 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 index ebb815a5..8ad45afc 100644 --- a/app/views/reports/issue_report.rhtml +++ b/app/views/reports/issue_report.rhtml @@ -1,32 +1,32 @@ -

    <%=l(:label_report_plural)%>

    - -
    -<%= link_to_if_authorized l(:label_query_new), {:controller => 'projects', :action => 'add_query', :id => @project}, :class => 'icon icon-add' %> -
    -

    <%= l(:label_query_plural) %>

    - -<% if @queries.empty? %>

    <%=l(:label_no_data)%>

    <% end %> -
      -<% @queries.each do |query| %> -
    • <%= link_to query.name, :controller => 'projects', :action => 'list_issues', :id => @project, :query_id => query %>
    • -<% end %> -
    - -
    -

    <%=l(:field_tracker)%>  <%= link_to image_tag('zoom_in.png'), :detail => 'tracker' %>

    -<%= render :partial => 'simple', :locals => { :data => @issues_by_tracker, :field_name => "tracker_id", :rows => @trackers } %> -
    -

    <%=l(:field_author)%>  <%= link_to image_tag('zoom_in.png'), :detail => 'author' %>

    -<%= render :partial => 'simple', :locals => { :data => @issues_by_author, :field_name => "author_id", :rows => @authors } %> -
    -
    - -
    -

    <%=l(:field_priority)%>  <%= link_to image_tag('zoom_in.png'), :detail => 'priority' %>

    -<%= render :partial => 'simple', :locals => { :data => @issues_by_priority, :field_name => "priority_id", :rows => @priorities } %> -
    -

    <%=l(:field_category)%>  <%= link_to image_tag('zoom_in.png'), :detail => 'category' %>

    -<%= render :partial => 'simple', :locals => { :data => @issues_by_category, :field_name => "category_id", :rows => @categories } %> -
    -
    - +

    <%=l(:label_report_plural)%>

    + +
    +<%= link_to_if_authorized l(:label_query_new), {:controller => 'projects', :action => 'add_query', :id => @project}, :class => 'icon icon-add' %> +
    +

    <%= l(:label_query_plural) %>

    + +<% if @queries.empty? %>

    <%=l(:label_no_data)%>

    <% end %> +
      +<% @queries.each do |query| %> +
    • <%= link_to query.name, :controller => 'projects', :action => 'list_issues', :id => @project, :query_id => query %>
    • +<% end %> +
    + +
    +

    <%=l(:field_tracker)%>  <%= link_to image_tag('zoom_in.png'), :detail => 'tracker' %>

    +<%= render :partial => 'simple', :locals => { :data => @issues_by_tracker, :field_name => "tracker_id", :rows => @trackers } %> +
    +

    <%=l(:field_author)%>  <%= link_to image_tag('zoom_in.png'), :detail => 'author' %>

    +<%= render :partial => 'simple', :locals => { :data => @issues_by_author, :field_name => "author_id", :rows => @authors } %> +
    +
    + +
    +

    <%=l(:field_priority)%>  <%= link_to image_tag('zoom_in.png'), :detail => 'priority' %>

    +<%= render :partial => 'simple', :locals => { :data => @issues_by_priority, :field_name => "priority_id", :rows => @priorities } %> +
    +

    <%=l(:field_category)%>  <%= link_to image_tag('zoom_in.png'), :detail => 'category' %>

    +<%= render :partial => 'simple', :locals => { :data => @issues_by_category, :field_name => "category_id", :rows => @categories } %> +
    +
    + diff --git a/app/views/reports/issue_report_details.rhtml b/app/views/reports/issue_report_details.rhtml index e37d3864..6b4b4223 100644 --- a/app/views/reports/issue_report_details.rhtml +++ b/app/views/reports/issue_report_details.rhtml @@ -1,7 +1,7 @@ -

    <%=l(:label_report_plural)%>

    - -

    <%=@report_title%>

    -<%= render :partial => 'details', :locals => { :data => @data, :field_name => @field, :rows => @rows } %> -
    -<%= link_to l(:button_back), :action => 'issue_report' %> - +

    <%=l(:label_report_plural)%>

    + +

    <%=@report_title%>

    +<%= render :partial => 'details', :locals => { :data => @data, :field_name => @field, :rows => @rows } %> +
    +<%= link_to l(:button_back), :action => 'issue_report' %> + diff --git a/app/views/repositories/_dir_list.rhtml b/app/views/repositories/_dir_list.rhtml index 332987f3..9a785f8f 100644 --- a/app/views/repositories/_dir_list.rhtml +++ b/app/views/repositories/_dir_list.rhtml @@ -1,23 +1,23 @@ - - - - - - - - - -<% total_size = 0 -@entries.each do |entry| %> - - - - - - - -<% total_size += entry.size -end %> - -
    <%= l(:field_name) %><%= l(:field_filesize) %><%= l(:label_revision) %><%= l(:field_author) %><%= l(:label_date) %>
    <%= link_to h(entry.name), { :action => (entry.is_dir? ? 'browse' : 'revisions'), :id => @project, :path => entry.path, :rev => @rev }, :class => ("icon " + (entry.is_dir? ? 'icon-folder' : 'icon-file')) %><%= number_to_human_size(entry.size) unless entry.is_dir? %><%= link_to entry.lastrev.identifier, :action => 'revision', :id => @project, :rev => entry.lastrev.identifier %><%=h entry.lastrev.author %><%= format_time(entry.lastrev.time) %>
    + + + + + + + + + +<% total_size = 0 +@entries.each do |entry| %> + + + + + + + +<% total_size += entry.size +end %> + +
    <%= l(:field_name) %><%= l(:field_filesize) %><%= l(:label_revision) %><%= l(:field_author) %><%= l(:label_date) %>
    <%= link_to h(entry.name), { :action => (entry.is_dir? ? 'browse' : 'revisions'), :id => @project, :path => entry.path, :rev => @rev }, :class => ("icon " + (entry.is_dir? ? 'icon-folder' : 'icon-file')) %><%= number_to_human_size(entry.size) unless entry.is_dir? %><%= link_to entry.lastrev.identifier, :action => 'revision', :id => @project, :rev => entry.lastrev.identifier %><%=h entry.lastrev.author %><%= format_time(entry.lastrev.time) %>

    <%= l(:label_total) %>: <%= number_to_human_size(total_size) %>

    \ No newline at end of file diff --git a/app/views/repositories/_navigation.rhtml b/app/views/repositories/_navigation.rhtml index 3ae0f761..efc0b9ff 100644 --- a/app/views/repositories/_navigation.rhtml +++ b/app/views/repositories/_navigation.rhtml @@ -1,18 +1,18 @@ -<%= link_to 'root', :action => 'browse', :id => @project, :path => '', :rev => @rev %> -<% -dirs = path.split('/') -if 'file' == kind - filename = dirs.pop -end -link_path = '' -dirs.each do |dir| - link_path << '/' unless link_path.empty? - link_path << "#{dir}" - %> - / <%= link_to h(dir), :action => 'browse', :id => @project, :path => link_path, :rev => @rev %> -<% end %> -<% if filename %> - / <%= link_to h(filename), :action => 'revisions', :id => @project, :path => "#{link_path}/#{filename}", :rev => @rev %> -<% end %> - +<%= link_to 'root', :action => 'browse', :id => @project, :path => '', :rev => @rev %> +<% +dirs = path.split('/') +if 'file' == kind + filename = dirs.pop +end +link_path = '' +dirs.each do |dir| + link_path << '/' unless link_path.empty? + link_path << "#{dir}" + %> + / <%= link_to h(dir), :action => 'browse', :id => @project, :path => link_path, :rev => @rev %> +<% end %> +<% if filename %> + / <%= link_to h(filename), :action => 'revisions', :id => @project, :path => "#{link_path}/#{filename}", :rev => @rev %> +<% end %> + <%= "@ #{revision}" if revision %> \ No newline at end of file diff --git a/app/views/repositories/browse.rhtml b/app/views/repositories/browse.rhtml index 828082e8..dffbe545 100644 --- a/app/views/repositories/browse.rhtml +++ b/app/views/repositories/browse.rhtml @@ -1,14 +1,14 @@ -
    -<% form_tag do %> -

    <%= l(:label_revision) %>: <%= text_field_tag 'rev', @rev, :size => 5 %> -<%= submit_tag 'OK' %>

    -<% end %> -
    - -

    <%= render :partial => 'navigation', :locals => { :path => @path, :kind => 'dir', :revision => @rev } %>

    - -<%= render :partial => 'dir_list' %> - -<% content_for :header_tags do %> -<%= stylesheet_link_tag "scm" %> +
    +<% form_tag do %> +

    <%= l(:label_revision) %>: <%= text_field_tag 'rev', @rev, :size => 5 %> +<%= submit_tag 'OK' %>

    +<% end %> +
    + +

    <%= render :partial => 'navigation', :locals => { :path => @path, :kind => 'dir', :revision => @rev } %>

    + +<%= render :partial => 'dir_list' %> + +<% content_for :header_tags do %> +<%= stylesheet_link_tag "scm" %> <% end %> \ No newline at end of file diff --git a/app/views/repositories/diff.rhtml b/app/views/repositories/diff.rhtml index 90fbb602..eb8777de 100644 --- a/app/views/repositories/diff.rhtml +++ b/app/views/repositories/diff.rhtml @@ -1,67 +1,67 @@ -

    <%= render :partial => 'navigation', :locals => { :path => @path, :kind => 'file', :revision => @rev } %>

    - -<% parsing = false -line_num_l = 0 -line_num_r = 0 %> -<% @diff.each do |line| %> -<% - if line =~ /^Index: (.*)$/ - if parsing %> - - <% - end - parsing = false %> - - - - - <% - next - elsif line =~ /^@@ (\+|\-)(\d+)(,\d+)? (\+|\-)(\d+)(,\d+)? @@/ - line_num_l = $2.to_i - line_num_r = $5.to_i - parsing = true - next - elsif line =~ /^_+$/ - # We have reached the 'Properties' section. - parsing = false - next - end - next unless parsing -%> - - - -<% case line[0, 1] - when " " %> - - - - - - - - -<% end %> - -
    <%= l(:label_attachment) %>: <%= $1 %>
    @<%= @rev %>@<%= @rev_to %>
    <%= line_num_l %><%= line_num_r %> -<% line_num_l = line_num_l + 1 - line_num_r = line_num_r + 1 - - when "-" %> -<%= line_num_r %> -<% line_num_r = line_num_r + 1 - - when "+" %> -<%= line_num_l %> -<% line_num_l = line_num_l + 1 - - else - next - end %> - -<%= h(line[1..-1]).gsub(/\s/, " ") %>
    - -<% content_for :header_tags do %> -<%= stylesheet_link_tag "scm" %> -<% end %> +

    <%= render :partial => 'navigation', :locals => { :path => @path, :kind => 'file', :revision => @rev } %>

    + +<% parsing = false +line_num_l = 0 +line_num_r = 0 %> +<% @diff.each do |line| %> +<% + if line =~ /^Index: (.*)$/ + if parsing %> + + <% + end + parsing = false %> + + + + + <% + next + elsif line =~ /^@@ (\+|\-)(\d+)(,\d+)? (\+|\-)(\d+)(,\d+)? @@/ + line_num_l = $2.to_i + line_num_r = $5.to_i + parsing = true + next + elsif line =~ /^_+$/ + # We have reached the 'Properties' section. + parsing = false + next + end + next unless parsing +%> + + + +<% case line[0, 1] + when " " %> + + + + + + + + +<% end %> + +
    <%= l(:label_attachment) %>: <%= $1 %>
    @<%= @rev %>@<%= @rev_to %>
    <%= line_num_l %><%= line_num_r %> +<% line_num_l = line_num_l + 1 + line_num_r = line_num_r + 1 + + when "-" %> +<%= line_num_r %> +<% line_num_r = line_num_r + 1 + + when "+" %> +<%= line_num_l %> +<% line_num_l = line_num_l + 1 + + else + next + end %> + +<%= h(line[1..-1]).gsub(/\s/, " ") %>
    + +<% content_for :header_tags do %> +<%= stylesheet_link_tag "scm" %> +<% end %> diff --git a/app/views/repositories/revision.rhtml b/app/views/repositories/revision.rhtml index e32de5df..d017a79f 100644 --- a/app/views/repositories/revision.rhtml +++ b/app/views/repositories/revision.rhtml @@ -1,38 +1,38 @@ -
    -<% form_tag do %> -

    <%= l(:label_revision) %>: <%= text_field_tag 'rev', @rev, :size => 5 %> -<%= submit_tag 'OK' %>

    -<% end %> -
    - -

    <%= l(:label_revision) %> <%= @revision.identifier %>

    - -

    <%= @revision.author %>, <%= format_time(@revision.time) %>

    -<%= textilizable @revision.message %> - -
    -
    <%= l(:label_added) %> 
    -
    <%= l(:label_modified) %> 
    -
    <%= l(:label_deleted) %> 
    -
    - -

    <%= l(:label_attachment_plural) %>

    - - -<% @revision.paths.each do |path| %> - - - - -<% end %> - -
    <%= path[:path] %>
    -<% if path[:action] == "M" %> -<%= link_to 'View diff', :action => 'diff', :id => @project, :path => path[:path].gsub(/^\//, ''), :rev => @revision.identifier %> -<% end %> -
    -

    <%= lwr(:label_modification, @revision.paths.length) %>

    - -<% content_for :header_tags do %> -<%= stylesheet_link_tag "scm" %> +
    +<% form_tag do %> +

    <%= l(:label_revision) %>: <%= text_field_tag 'rev', @rev, :size => 5 %> +<%= submit_tag 'OK' %>

    +<% end %> +
    + +

    <%= l(:label_revision) %> <%= @revision.identifier %>

    + +

    <%= @revision.author %>, <%= format_time(@revision.time) %>

    +<%= textilizable @revision.message %> + +
    +
    <%= l(:label_added) %> 
    +
    <%= l(:label_modified) %> 
    +
    <%= l(:label_deleted) %> 
    +
    + +

    <%= l(:label_attachment_plural) %>

    + + +<% @revision.paths.each do |path| %> + + + + +<% end %> + +
    <%= path[:path] %>
    +<% if path[:action] == "M" %> +<%= link_to 'View diff', :action => 'diff', :id => @project, :path => path[:path].gsub(/^\//, ''), :rev => @revision.identifier %> +<% end %> +
    +

    <%= lwr(:label_modification, @revision.paths.length) %>

    + +<% content_for :header_tags do %> +<%= stylesheet_link_tag "scm" %> <% end %> \ No newline at end of file diff --git a/app/views/repositories/revisions.rhtml b/app/views/repositories/revisions.rhtml index bc5a192b..8e300a9d 100644 --- a/app/views/repositories/revisions.rhtml +++ b/app/views/repositories/revisions.rhtml @@ -1,41 +1,41 @@ -
    -<% form_tag do %> -

    <%= l(:label_revision) %>: <%= text_field_tag 'rev', @rev, :size => 5 %> -<%= submit_tag 'OK' %>

    -<% end %> -
    - -

    <%= render :partial => 'navigation', :locals => { :path => @path, :kind => @entry.kind, :revision => @rev } %>

    - -<% if @entry.is_file? %> -

    <%=h @entry.name %>

    -

    <%= link_to 'Download', {:action => 'entry', :id => @project, :path => @path, :rev => @rev, :format => 'raw' }, :class => "icon file" %> (<%= number_to_human_size @entry.size %>)

    -<% end %> - -

    Revisions

    - - - - - - - - - - -<% @revisions.each do |revision| %> - - - - - - - -<% end %> - -
    #<%= l(:field_author) %><%= l(:label_date) %><%= l(:field_description) %>
    <%= link_to revision.identifier, :action => 'revision', :id => @project, :rev => revision.identifier %><%=h revision.author %><%= format_time(revision.time) %><%= textilizable(revision.message) %><%= link_to 'Diff', :action => 'diff', :id => @project, :path => @path, :rev => revision.identifier if @entry.is_file? && revision != @revisions.last %>
    -

    <%= lwr(:label_modification, @revisions.length) %>

    - -<% content_for :header_tags do %> -<%= stylesheet_link_tag "scm" %> +
    +<% form_tag do %> +

    <%= l(:label_revision) %>: <%= text_field_tag 'rev', @rev, :size => 5 %> +<%= submit_tag 'OK' %>

    +<% end %> +
    + +

    <%= render :partial => 'navigation', :locals => { :path => @path, :kind => @entry.kind, :revision => @rev } %>

    + +<% if @entry.is_file? %> +

    <%=h @entry.name %>

    +

    <%= link_to 'Download', {:action => 'entry', :id => @project, :path => @path, :rev => @rev, :format => 'raw' }, :class => "icon file" %> (<%= number_to_human_size @entry.size %>)

    +<% end %> + +

    Revisions

    + + + + + + + + + + +<% @revisions.each do |revision| %> + + + + + + + +<% end %> + +
    #<%= l(:field_author) %><%= l(:label_date) %><%= l(:field_description) %>
    <%= link_to revision.identifier, :action => 'revision', :id => @project, :rev => revision.identifier %><%=h revision.author %><%= format_time(revision.time) %><%= textilizable(revision.message) %><%= link_to 'Diff', :action => 'diff', :id => @project, :path => @path, :rev => revision.identifier if @entry.is_file? && revision != @revisions.last %>
    +

    <%= lwr(:label_modification, @revisions.length) %>

    + +<% content_for :header_tags do %> +<%= stylesheet_link_tag "scm" %> <% end %> \ No newline at end of file diff --git a/app/views/roles/_form.rhtml b/app/views/roles/_form.rhtml index 7cd83fd4..a80d990f 100644 --- a/app/views/roles/_form.rhtml +++ b/app/views/roles/_form.rhtml @@ -1,21 +1,21 @@ <%= error_messages_for 'role' %>
    - -

    <%= f.text_field :name, :required => true %>

    - -

    <%=l(:label_permissions)%>

    -<% permissions = @permissions.group_by {|p| p.group_id } %> + +

    <%= f.text_field :name, :required => true %>

    + +

    <%=l(:label_permissions)%>

    +<% permissions = @permissions.group_by {|p| p.group_id } %> <% permissions.keys.sort.each do |group_id| %> -
    <%= l(Permission::GROUPS[group_id]) %> -<% permissions[group_id].each do |p| %> -
    <%= check_box_tag "permission_ids[]", p.id, (@role.permissions.include? p) %> - <%= l(p.description.to_sym) %> -
    +
    <%= l(Permission::GROUPS[group_id]) %> +<% permissions[group_id].each do |p| %> +
    <%= check_box_tag "permission_ids[]", p.id, (@role.permissions.include? p) %> + <%= l(p.description.to_sym) %> +
    +<% end %> +
    +
    <% end %> -
    -
    -<% end %>
    -<%= check_all_links 'role_form' %> +<%= check_all_links 'role_form' %>
    diff --git a/app/views/roles/edit.rhtml b/app/views/roles/edit.rhtml index ffe117ce..4a591e3e 100644 --- a/app/views/roles/edit.rhtml +++ b/app/views/roles/edit.rhtml @@ -3,4 +3,4 @@ <% 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 %> +<% end %> diff --git a/app/views/roles/list.rhtml b/app/views/roles/list.rhtml index c6c4492b..872c62ee 100644 --- a/app/views/roles/list.rhtml +++ b/app/views/roles/list.rhtml @@ -21,10 +21,10 @@ <%= link_to image_tag('2downarrow.png', :alt => l(:label_sort_lowest)), {:action => 'move', :id => role, :position => 'lowest'}, :method => :post, :title => l(:label_sort_lowest) %> - <%= button_to l(:button_delete), { :action => 'destroy', :id => role }, :confirm => l(:text_are_you_sure), :class => "button-small" %> + <%= button_to l(:button_delete), { :action => 'destroy', :id => role }, :confirm => l(:text_are_you_sure), :class => "button-small" %> <% end %> - + <%= pagination_links_full @role_pages %> \ No newline at end of file diff --git a/app/views/roles/new.rhtml b/app/views/roles/new.rhtml index a73c36cb..8f03aefa 100644 --- a/app/views/roles/new.rhtml +++ b/app/views/roles/new.rhtml @@ -1,5 +1,5 @@

    <%=l(:label_role_new)%>

    - + <% 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) %> diff --git a/app/views/roles/workflow.rhtml b/app/views/roles/workflow.rhtml index 620b3700..f62cca50 100644 --- a/app/views/roles/workflow.rhtml +++ b/app/views/roles/workflow.rhtml @@ -1,69 +1,69 @@ -

    <%=l(:label_workflow)%>

    - -

    <%=l(:text_workflow_edit)%>:

    - -<% form_tag ({:action => 'workflow'}, :method => 'get') do %> -
    -


    -

    -
    - -
    -


    - - -<%= submit_tag l(:button_edit) %> -

    -
    -<% end %> - - - -<% unless @tracker.nil? or @role.nil? %> -
    - <% form_tag ({:action => 'workflow', :role_id => @role, :tracker_id => @tracker }, :id => 'workflow_form' ) do %> - - - - - - - - <% for new_status in @statuses %> - - <% end %> - - - <% for old_status in @statuses %> - - - <% for new_status in @statuses %> - - <% end %> - - - <% end %> -
    <%=l(:label_current_status)%><%=l(:label_new_statuses_allowed)%>
    <%= new_status.name %>
    <%= old_status.name %>
    - - checked="checked"<%end%> - <%if old_status==new_status%>disabled<%end%> - > -
    -
    -

    -<%=l(:button_check_all)%> | -<%=l(:button_uncheck_all)%> -

    -
    +

    <%=l(:label_workflow)%>

    + +

    <%=l(:text_workflow_edit)%>:

    + +<% form_tag ({:action => 'workflow'}, :method => 'get') do %> +
    +


    +

    +
    + +
    +


    + + +<%= submit_tag l(:button_edit) %> +

    +
    +<% end %> + + + +<% unless @tracker.nil? or @role.nil? %> +
    + <% form_tag ({:action => 'workflow', :role_id => @role, :tracker_id => @tracker }, :id => 'workflow_form' ) do %> + + + + + + + + <% for new_status in @statuses %> + + <% end %> + + + <% for old_status in @statuses %> + + + <% for new_status in @statuses %> + + <% end %> + + + <% end %> +
    <%=l(:label_current_status)%><%=l(:label_new_statuses_allowed)%>
    <%= new_status.name %>
    <%= old_status.name %>
    + + checked="checked"<%end%> + <%if old_status==new_status%>disabled<%end%> + > +
    +
    +

    +<%=l(:button_check_all)%> | +<%=l(:button_uncheck_all)%> +

    +
    <%= submit_tag l(:button_save) %> -<% end %> - -<% end %> +<% end %> + +<% end %>
    \ No newline at end of file diff --git a/app/views/trackers/_form.rhtml b/app/views/trackers/_form.rhtml index fd79bf5f..3dea238d 100644 --- a/app/views/trackers/_form.rhtml +++ b/app/views/trackers/_form.rhtml @@ -1,8 +1,8 @@ <%= error_messages_for 'tracker' %>
    -

    <%= f.text_field :name, :required => true %>

    +

    <%= f.text_field :name, :required => true %>

    <%= f.check_box :is_in_chlog %>

    -

    <%= f.check_box :is_in_roadmap %>

    +

    <%= f.check_box :is_in_roadmap %>

    diff --git a/app/views/trackers/list.rhtml b/app/views/trackers/list.rhtml index a12e5084..05408a1c 100644 --- a/app/views/trackers/list.rhtml +++ b/app/views/trackers/list.rhtml @@ -6,7 +6,7 @@ - + @@ -21,11 +21,11 @@ <%= link_to image_tag('2downarrow.png', :alt => l(:label_sort_lowest)), {:action => 'move', :id => tracker, :position => 'lowest'}, :method => :post, :title => l(:label_sort_lowest) %> <% end %>
    <%=l(:label_tracker)%><%=l(:label_tracker)%> <%=l(:button_sort)%>
    - <%= button_to l(:button_delete), { :action => 'destroy', :id => tracker }, :confirm => l(:text_are_you_sure), :class => "button-small" %> + <%= button_to l(:button_delete), { :action => 'destroy', :id => tracker }, :confirm => l(:text_are_you_sure), :class => "button-small" %>
    - + <%= pagination_links_full @tracker_pages %> \ No newline at end of file diff --git a/app/views/users/_form.rhtml b/app/views/users/_form.rhtml index e486c104..18c84925 100644 --- a/app/views/users/_form.rhtml +++ b/app/views/users/_form.rhtml @@ -4,17 +4,17 @@

    <%=l(:label_information_plural)%>

    <%= f.text_field :login, :required => true, :size => 25 %>

    -

    <%= f.text_field :firstname, :required => true %>

    +

    <%= f.text_field :firstname, :required => true %>

    <%= f.text_field :lastname, :required => true %>

    -

    <%= f.text_field :mail, :required => true %>

    -

    <%= f.select :language, lang_options_for_select %>

    - +

    <%= f.text_field :mail, :required => true %>

    +

    <%= f.select :language, lang_options_for_select %>

    + <% for @custom_value in @custom_values %>

    <%= custom_field_tag_with_label @custom_value %>

    -<% end if @custom_values%> - -

    <%= f.check_box :admin %>

    -

    <%= f.check_box :mail_notification %>

    +<% end if @custom_values%> + +

    <%= f.check_box :admin %>

    +

    <%= f.check_box :mail_notification %>

    diff --git a/app/views/users/_memberships.rhtml b/app/views/users/_memberships.rhtml index 098ba83b..2499ba38 100644 --- a/app/views/users/_memberships.rhtml +++ b/app/views/users/_memberships.rhtml @@ -1,29 +1,29 @@ -
    -

    <%= l(:label_project_plural) %>

    - -<% @user.memberships.each do |membership| %> -<% form_tag({ :action => 'edit_membership', :id => @user, :membership_id => membership }, :class => "tabular") do %> -

    - - - <%= submit_tag l(:button_change), :class => "button-small" %> - <%= link_to l(:button_delete), {:action => 'destroy_membership', :id => @user, :membership_id => membership }, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> -

    -<% end %> -<% end %> -
    -

    -
    -<% form_tag({ :action => 'edit_membership', :id => @user }) do %> - - -<%= submit_tag l(:button_add) %> -<% end %> -

    +
    +

    <%= l(:label_project_plural) %>

    + +<% @user.memberships.each do |membership| %> +<% form_tag({ :action => 'edit_membership', :id => @user, :membership_id => membership }, :class => "tabular") do %> +

    + + + <%= submit_tag l(:button_change), :class => "button-small" %> + <%= link_to l(:button_delete), {:action => 'destroy_membership', :id => @user, :membership_id => membership }, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> +

    +<% end %> +<% end %> +
    +

    +
    +<% form_tag({ :action => 'edit_membership', :id => @user }) do %> + + +<%= submit_tag l(:button_add) %> +<% end %> +

    \ No newline at end of file diff --git a/app/views/users/list.rhtml b/app/views/users/list.rhtml index 36d0c438..87d42391 100644 --- a/app/views/users/list.rhtml +++ b/app/views/users/list.rhtml @@ -3,49 +3,49 @@

    <%=l(:label_user_plural)%>

    - - + +
    - <%= sort_header_tag('login', :caption => l(:field_login)) %> - <%= sort_header_tag('firstname', :caption => l(:field_firstname)) %> - <%= sort_header_tag('lastname', :caption => l(:field_lastname)) %> - - <%= 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)) %> - + <%= sort_header_tag('login', :caption => l(:field_login)) %> + <%= sort_header_tag('firstname', :caption => l(:field_firstname)) %> + <%= sort_header_tag('lastname', :caption => l(:field_lastname)) %> + + <%= 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)) %> + <% for user in @users %> - "> - - - - - - - - - "> + + + + + + + + + <% end %>
    <%=l(:field_mail)%><%=l(:field_mail)%>
    <%= link_to user.login, :action => 'edit', :id => user %><%= user.firstname %><%= user.lastname %><%= user.mail %><%= image_tag 'true.png' if user.admin? %><%= image_tag 'locked.png' if user.locked? %><%= image_tag 'user_new.png' if user.registered? %><%= format_time(user.created_on) %><%= format_time(user.last_login_on) unless user.last_login_on.nil? %> - <% form_tag({:action => 'edit', :id => user}) do %> - <% if user.locked? %> - <%= hidden_field_tag 'user[status]', User::STATUS_ACTIVE %> - <%= submit_tag l(:button_unlock), :class => "button-small" %> +
    <%= link_to user.login, :action => 'edit', :id => user %><%= user.firstname %><%= user.lastname %><%= user.mail %><%= image_tag 'true.png' if user.admin? %><%= image_tag 'locked.png' if user.locked? %><%= image_tag 'user_new.png' if user.registered? %><%= format_time(user.created_on) %><%= format_time(user.last_login_on) unless user.last_login_on.nil? %> + <% form_tag({:action => 'edit', :id => user}) do %> + <% if user.locked? %> + <%= hidden_field_tag 'user[status]', User::STATUS_ACTIVE %> + <%= submit_tag l(:button_unlock), :class => "button-small" %> <% elsif user.registered? %> <%= hidden_field_tag 'user[status]', User::STATUS_ACTIVE %> <%= submit_tag l(:button_activate), :class => "button-small" %> - <% else %> - <%= hidden_field_tag 'user[status]', User::STATUS_LOCKED %> - <%= submit_tag l(:button_lock), :class => "button-small" %> - <% end %> - <% end %> + <% else %> + <%= hidden_field_tag 'user[status]', User::STATUS_LOCKED %> + <%= submit_tag l(:button_lock), :class => "button-small" %> + <% end %> + <% end %>
    - -

    <%= pagination_links_full @user_pages %> -[ <%= @user_pages.current.first_item %> - <%= @user_pages.current.last_item %> / <%= @user_count %> ] + +

    <%= pagination_links_full @user_pages %> +[ <%= @user_pages.current.first_item %> - <%= @user_pages.current.last_item %> / <%= @user_count %> ]

    \ No newline at end of file diff --git a/app/views/welcome/index.rhtml b/app/views/welcome/index.rhtml index 95683c84..9c73ab86 100644 --- a/app/views/welcome/index.rhtml +++ b/app/views/welcome/index.rhtml @@ -1,27 +1,27 @@ -

    <%= l(:label_home) %>

    - -
    -

    <%= Setting.welcome_text %>

    -
    +

    <%= l(:label_home) %>

    + +
    +

    <%= Setting.welcome_text %>

    +

    <%=l(:label_news_latest)%>

    - <%= render :partial => 'news/news', :collection => @news %> -
    -
    - -
    -
    -

    <%=l(:label_project_latest)%>

    + <%= render :partial => 'news/news', :collection => @news %> +
    +
    + +
    +
    +

    <%=l(:label_project_latest)%>

      - <% for project in @projects %> -
    • - <%= link_to project.name, :controller => 'projects', :action => 'show', :id => project %> (<%= format_time(project.created_on) %>)
      - <%=h project.description %> -
    • - <% end %> -
    -
    -
    - -<% content_for :header_tags do %> -<%= auto_discovery_link_tag(:rss, {:controller => 'feeds' , :action => 'news' }) %> + <% for project in @projects %> +
  • + <%= link_to project.name, :controller => 'projects', :action => 'show', :id => project %> (<%= format_time(project.created_on) %>)
    + <%=h project.description %> +
  • + <% end %> + +
    +
    + +<% content_for :header_tags do %> +<%= auto_discovery_link_tag(:rss, {:controller => 'feeds' , :action => 'news' }) %> <% end %> \ No newline at end of file diff --git a/app/views/wiki/_preview.rhtml b/app/views/wiki/_preview.rhtml index c17200ab..7865d915 100644 --- a/app/views/wiki/_preview.rhtml +++ b/app/views/wiki/_preview.rhtml @@ -1,3 +1,3 @@ -
    <%= l(:label_preview) %> -<%= textilizable @text %> -
    +
    <%= l(:label_preview) %> +<%= textilizable @text %> +
    diff --git a/app/views/wiki/edit.rhtml b/app/views/wiki/edit.rhtml index 1fc79bdc..48025b36 100644 --- a/app/views/wiki/edit.rhtml +++ b/app/views/wiki/edit.rhtml @@ -1,44 +1,44 @@ -
    -<%= link_to(l(:label_page_index), {:action => 'special', :page => 'Page_index'}, :class => 'icon icon-index') %> -
    - -

    <%= @page.pretty_title %>

    - -<% form_for :content, @content, :url => {:action => 'edit', :page => @page.title}, :html => {:id => 'wiki_form'} do |f| %> -<%= error_messages_for 'content' %> -
    -<%= l(:setting_text_formatting) %>: -<%= link_to l(:label_help), {:controller => 'help', :ctrl => 'wiki', :page => 'syntax' }, - :onclick => "window.open('#{ url_for :controller => 'help', :ctrl => 'wiki', :page => 'syntax' }', '', 'resizable=yes, location=no, width=300, height=500, menubar=no, status=no, scrollbars=yes'); return false;" %> -
    -

    <%= f.text_area :text, :cols => 100, :rows => 25, :class => 'wiki-edit' %>

    -


    <%= f.text_field :comment, :size => 120 %>

    -

    <%= submit_tag l(:button_save) %> - <%= link_to_remote l(:label_preview), - { :url => { :controller => 'wiki', :action => 'preview', :id => @project }, - :method => 'get', - :update => 'preview', - :with => "Form.serialize('wiki_form')", - :loading => "Element.show('indicator')", - :loaded => "Element.hide('indicator')" - } %> - -

    - -<% end %> - -<% if Setting.text_formatting == 'textile' %> -<%= javascript_include_tag 'jstoolbar' %> - -<% end %> - +
    +<%= link_to(l(:label_page_index), {:action => 'special', :page => 'Page_index'}, :class => 'icon icon-index') %> +
    + +

    <%= @page.pretty_title %>

    + +<% form_for :content, @content, :url => {:action => 'edit', :page => @page.title}, :html => {:id => 'wiki_form'} do |f| %> +<%= error_messages_for 'content' %> +
    +<%= l(:setting_text_formatting) %>: +<%= link_to l(:label_help), {:controller => 'help', :ctrl => 'wiki', :page => 'syntax' }, + :onclick => "window.open('#{ url_for :controller => 'help', :ctrl => 'wiki', :page => 'syntax' }', '', 'resizable=yes, location=no, width=300, height=500, menubar=no, status=no, scrollbars=yes'); return false;" %> +
    +

    <%= f.text_area :text, :cols => 100, :rows => 25, :class => 'wiki-edit' %>

    +


    <%= f.text_field :comment, :size => 120 %>

    +

    <%= submit_tag l(:button_save) %> + <%= link_to_remote l(:label_preview), + { :url => { :controller => 'wiki', :action => 'preview', :id => @project }, + :method => 'get', + :update => 'preview', + :with => "Form.serialize('wiki_form')", + :loading => "Element.show('indicator')", + :loaded => "Element.hide('indicator')" + } %> + +

    + +<% end %> + +<% if Setting.text_formatting == 'textile' %> +<%= javascript_include_tag 'jstoolbar' %> + +<% end %> +
    \ No newline at end of file diff --git a/app/views/wiki/export.rhtml b/app/views/wiki/export.rhtml index c3156824..561e9b00 100644 --- a/app/views/wiki/export.rhtml +++ b/app/views/wiki/export.rhtml @@ -1,14 +1,14 @@ - - - -<%=h @page.pretty_title %> - - - - -<%= textilizable @content.text, :wiki_links => :local %> - - + + + +<%=h @page.pretty_title %> + + + + +<%= textilizable @content.text, :wiki_links => :local %> + + diff --git a/app/views/wiki/export_multiple.rhtml b/app/views/wiki/export_multiple.rhtml index cecb40b4..fe3e87e7 100644 --- a/app/views/wiki/export_multiple.rhtml +++ b/app/views/wiki/export_multiple.rhtml @@ -1,26 +1,26 @@ - - - -<%=h @wiki.project.name %> - - - - - -<%= l(:label_page_index) %> - - -<% @pages.each do |page| %> -
    -<%= textilizable page.content.text, :wiki_links => :anchor %> -<% end %> - - - + + + +<%=h @wiki.project.name %> + + + + + +<%= l(:label_page_index) %> + + +<% @pages.each do |page| %> +
    +<%= textilizable page.content.text, :wiki_links => :anchor %> +<% end %> + + + diff --git a/app/views/wiki/history.rhtml b/app/views/wiki/history.rhtml index e44a0816..dd9e590b 100644 --- a/app/views/wiki/history.rhtml +++ b/app/views/wiki/history.rhtml @@ -1,28 +1,28 @@ -
    -<%= link_to(l(:label_page_index), {:action => 'special', :page => 'Page_index'}, :class => 'icon icon-index') %> -
    - -

    <%= @page.pretty_title %>

    - -

    <%= l(:label_history) %>

    - - - - - - - - - -<% @versions.each do |ver| %> -"> - - - - - -<% end %> - -
    #<%= l(:field_updated_on) %><%= l(:field_author) %><%= l(:field_comment) %>
    <%= link_to ver.version, :action => 'index', :page => @page.title, :version => ver.version %><%= format_time(ver.updated_on) %><%= ver.author ? ver.author.name : "anonyme" %><%=h ver.comment %>
    - +
    +<%= link_to(l(:label_page_index), {:action => 'special', :page => 'Page_index'}, :class => 'icon icon-index') %> +
    + +

    <%= @page.pretty_title %>

    + +

    <%= l(:label_history) %>

    + + + + + + + + + +<% @versions.each do |ver| %> +"> + + + + + +<% end %> + +
    #<%= l(:field_updated_on) %><%= l(:field_author) %><%= l(:field_comment) %>
    <%= link_to ver.version, :action => 'index', :page => @page.title, :version => ver.version %><%= format_time(ver.updated_on) %><%= ver.author ? ver.author.name : "anonyme" %><%=h ver.comment %>
    +

    <%= link_to l(:button_back), :action => 'index', :page => @page.title %>

    \ No newline at end of file diff --git a/app/views/wiki/show.rhtml b/app/views/wiki/show.rhtml index e0369ed3..2e8ee408 100644 --- a/app/views/wiki/show.rhtml +++ b/app/views/wiki/show.rhtml @@ -1,30 +1,30 @@ -
    -<%= link_to(l(:button_edit), {:action => 'edit', :page => @page.title}, :class => 'icon icon-edit') if @content.version == @page.content.version %> -<%= link_to(l(:label_history), {:action => 'history', :page => @page.title}, :class => 'icon icon-history') %> -<%= link_to(l(:label_page_index), {:action => 'special', :page => 'Page_index'}, :class => 'icon icon-index') %> -
    - -<% if @content.version != @page.content.version %> -

    - <%= link_to(('« ' + l(:label_previous)), :action => 'index', :page => @page.title, :version => (@content.version - 1)) + " - " if @content.version > 1 %> - <%= "#{l(:label_version)} #{@content.version}/#{@page.content.version}" %> - - <%= link_to((l(:label_next) + ' »'), :action => 'index', :page => @page.title, :version => (@content.version + 1)) + " - " if @content.version < @page.content.version %> - <%= link_to(l(:label_current_version), :action => 'index', :page => @page.title) %> -
    - <%= @content.author ? @content.author.name : "anonyme" %>, <%= format_time(@content.updated_on) %>
    - <%=h @content.comment %> -

    -
    -<% end %> - -
    -<% cache "wiki/show/#{@page.id}/#{@content.version}" do %> -<%= textilizable @content.text %> -<% end %> -
    - -
    -<%= l(:label_export_to) %> -<%= link_to 'HTML', {:export => 'html', :version => @content.version}, :class => 'icon icon-html' %>, -<%= link_to 'TXT', {:export => 'txt', :version => @content.version}, :class => 'icon icon-txt' %> +
    +<%= link_to(l(:button_edit), {:action => 'edit', :page => @page.title}, :class => 'icon icon-edit') if @content.version == @page.content.version %> +<%= link_to(l(:label_history), {:action => 'history', :page => @page.title}, :class => 'icon icon-history') %> +<%= link_to(l(:label_page_index), {:action => 'special', :page => 'Page_index'}, :class => 'icon icon-index') %> +
    + +<% if @content.version != @page.content.version %> +

    + <%= link_to(('« ' + l(:label_previous)), :action => 'index', :page => @page.title, :version => (@content.version - 1)) + " - " if @content.version > 1 %> + <%= "#{l(:label_version)} #{@content.version}/#{@page.content.version}" %> - + <%= link_to((l(:label_next) + ' »'), :action => 'index', :page => @page.title, :version => (@content.version + 1)) + " - " if @content.version < @page.content.version %> + <%= link_to(l(:label_current_version), :action => 'index', :page => @page.title) %> +
    + <%= @content.author ? @content.author.name : "anonyme" %>, <%= format_time(@content.updated_on) %>
    + <%=h @content.comment %> +

    +
    +<% end %> + +
    +<% cache "wiki/show/#{@page.id}/#{@content.version}" do %> +<%= textilizable @content.text %> +<% end %> +
    + +
    +<%= l(:label_export_to) %> +<%= link_to 'HTML', {:export => 'html', :version => @content.version}, :class => 'icon icon-html' %>, +<%= link_to 'TXT', {:export => 'txt', :version => @content.version}, :class => 'icon icon-txt' %>
    \ No newline at end of file diff --git a/app/views/wiki/special_page_index.rhtml b/app/views/wiki/special_page_index.rhtml index e6e3e702..ba3cfeed 100644 --- a/app/views/wiki/special_page_index.rhtml +++ b/app/views/wiki/special_page_index.rhtml @@ -1,13 +1,13 @@ -
    -<% unless @pages.empty? %> -<%= l(:label_export_to) %> <%= link_to 'HTML', {:action => 'special', :page => 'export'}, :class => 'icon icon-html' %> -<% end %> -
    - -

    <%= l(:label_page_index) %>

    - -<% if @pages.empty? %>

    <%= l(:label_no_data) %>

    <% end %> -
      <% @pages.each do |page| %> -
    • <%= link_to page.pretty_title, :action => 'index', :page => page.title %> - - <%= l(:label_last_updates) %>: <%= format_time(page.updated_on) %>
    • +
      +<% unless @pages.empty? %> +<%= l(:label_export_to) %> <%= link_to 'HTML', {:action => 'special', :page => 'export'}, :class => 'icon icon-html' %> +<% end %> +
      + +

      <%= l(:label_page_index) %>

      + +<% if @pages.empty? %>

      <%= l(:label_no_data) %>

      <% end %> +
        <% @pages.each do |page| %> +
      • <%= link_to page.pretty_title, :action => 'index', :page => page.title %> - + <%= l(:label_last_updates) %>: <%= format_time(page.updated_on) %>
      • <% end %>
      \ No newline at end of file