Commits

jplang  committed 108d863

Initial commit

  • Participants

Comments (0)

Files changed (284)

File redmine/Rakefile

+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/switchtower.rake, and they will automatically be available to Rake.
+
+require(File.join(File.dirname(__FILE__), 'config', 'boot'))
+
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+require 'tasks/rails'

File redmine/app/controllers/account_controller.rb

+# redMine - project management software
+# Copyright (C) 2006  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+class AccountController < ApplicationController
+	layout 'base'	
+  # prevents login action to be filtered by check_if_login_required application scope filter
+  skip_before_filter :check_if_login_required, :only => :login
+	before_filter :require_login, :except => [:show, :login]
+
+	def show
+		@user = User.find(params[:id])
+	end
+  
+	# Login request and validation
+	def login
+		if request.get?
+			session[:user] = nil
+			@user = User.new
+		else
+			@user = User.new(params[:user])
+			logged_in_user = @user.try_to_login
+			if logged_in_user
+				session[:user] = logged_in_user
+				redirect_back_or_default :controller => 'account', :action => 'my_page'
+			else
+				flash[:notice] = _('Invalid user/password')
+			end
+		end
+	end
+	
+	# Log out current user and redirect to welcome page
+	def logout
+		session[:user] = nil
+		redirect_to(:controller => '')
+	end
+
+	def my_page
+		@user = session[:user]		
+		@reported_issues = Issue.find(:all, :conditions => ["author_id=?", @user.id], :limit => 10, :include => [ :status, :project, :tracker ], :order => 'issues.updated_on DESC')
+		@assigned_issues = Issue.find(:all, :conditions => ["assigned_to_id=?", @user.id], :limit => 10, :include => [ :status, :project, :tracker ], :order => 'issues.updated_on DESC')
+	end
+  
+	# Edit current user's account
+	def my_account
+		@user = User.find(session[:user].id)
+		if request.post? and @user.update_attributes(@params[:user])
+			flash[:notice] = 'Account was successfully updated.'
+      session[:user] = @user
+      set_localization
+		end
+	end
+	
+	# Change current user's password
+	def change_password
+		@user = User.find(session[:user].id)		
+		if @user.check_password?(@params[:old_password])		
+			if @params[:new_password] == @params[:new_password_confirmation]
+				if @user.change_password(@params[:old_password], @params[:new_password])
+					flash[:notice] = 'Password was successfully updated.'
+				end
+			else
+				flash[:notice] = 'Password confirmation doesn\'t match!'
+			end
+		else
+			flash[:notice] = 'Wrong password'
+		end
+		render :action => 'my_account'
+	end
+end

File redmine/app/controllers/admin_controller.rb

+# 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 'projects.name', 'asc'
+		sort_update		
+    @project_pages, @projects = paginate :projects, :per_page => 15, :order => sort_clause
+  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[:notice] = "Mail options were successfully updated."
+    end
+  end
+  
+  def info
+    @adapter_name = ActiveRecord::Base.connection.adapter_name
+  end
+  
+end

File redmine/app/controllers/application.rb

+# redMine - project management software
+# Copyright (C) 2006  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+class ApplicationController < ActionController::Base
+  before_filter :check_if_login_required, :set_localization
+  
+  # check if login is globally required to access the application
+  def check_if_login_required
+    require_login if RDM_LOGIN_REQUIRED
+  end 
+  
+  def set_localization
+    Localization.lang = session[:user].nil? ? RDM_DEFAULT_LANG : (session[:user].language || RDM_DEFAULT_LANG)
+  end
+  
+	def require_login
+		unless session[:user]
+			store_location
+			redirect_to(:controller => "account", :action => "login")
+		end
+	end
+
+	def require_admin
+		if session[:user].nil?
+			store_location
+			redirect_to(:controller => "account", :action => "login")
+		else
+			unless session[:user].admin?
+				flash[:notice] = "Acces not allowed"
+				redirect_to(:controller => "projects", :action => "list")
+			end
+		end
+	end
+
+	# authorizes the user for the requested action.
+	def authorize
+    # check if action is allowed on public projects
+    if @project.public? and Permission.allowed_to_public "%s/%s" % [ @params[:controller], @params[:action] ]
+      return true
+    end  
+    # if user is not logged in, he is redirect to login form
+		unless session[:user]
+			store_location
+			redirect_to(:controller => "account", :action => "login")
+			return false
+		end
+    # check if user is authorized    
+    if session[:user].admin? or Permission.allowed_to_role( "%s/%s" % [ @params[:controller], @params[:action] ], session[:user].role_for_project(@project.id)  )    
+      return true		
+		end		
+    flash[:notice] = "Acces denied"
+    redirect_to(:controller => "")
+    return false
+	end
+	
+	# store current uri in  the session.
+	# we can return to this location by calling redirect_back_or_default
+	def store_location
+		session[:return_to] = @request.request_uri
+	end
+	
+	# move to the last store_location call or to the passed default one
+	def redirect_back_or_default(default)
+		if session[:return_to].nil?
+			redirect_to default
+		else
+			redirect_to_url session[:return_to]
+			session[:return_to] = nil
+		end
+	end
+  
+end

File redmine/app/controllers/custom_fields_controller.rb

+# redMine - project management software
+# Copyright (C) 2006  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+class CustomFieldsController < ApplicationController
+	layout 'base'		
+	before_filter :require_admin
+	
+  def index
+    list
+    render :action => 'list'
+  end
+
+  def list
+    @custom_field_pages, @custom_fields = paginate :custom_fields, :per_page => 10
+  end
+
+  def new
+    if request.get?
+      @custom_field = CustomField.new
+    else
+      @custom_field = CustomField.new(params[:custom_field])
+      if @custom_field.save
+        flash[:notice] = 'CustomField was successfully created.'
+        redirect_to :action => 'list'
+      end
+    end
+  end
+
+  def edit
+    @custom_field = CustomField.find(params[:id])
+    if request.post? and @custom_field.update_attributes(params[:custom_field])
+      flash[:notice] = 'CustomField was successfully updated.'
+      redirect_to :action => 'list'
+    end
+  end
+
+  def destroy
+    CustomField.find(params[:id]).destroy
+    redirect_to :action => 'list'
+  rescue
+    flash[:notice] = "Unable to delete custom field"
+    redirect_to :action => 'list'
+  end
+end

File redmine/app/controllers/documents_controller.rb

+# redMine - project management software
+# Copyright (C) 2006  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+class DocumentsController < ApplicationController
+	layout 'base'
+	before_filter :find_project, :authorize
+  
+  def show
+  end
+
+  def edit
+    @categories = Enumeration::get_values('DCAT')
+    if request.post? and @document.update_attributes(params[:document])
+      flash[:notice] = 'Document was successfully updated.'
+      redirect_to :action => 'show', :id => @document
+    end
+  end  
+
+  def destroy
+    @document.destroy
+    redirect_to :controller => 'projects', :action => 'list_documents', :id => @project
+  end
+
+  def download
+    @attachment = @document.attachments.find(params[:attachment_id])
+    @attachment.increment_download
+    send_file @attachment.diskfile, :filename => @attachment.filename
+  end 
+  
+  def add_attachment
+    # Save the attachment
+    if params[:attachment][:file].size > 0
+      @attachment = @document.attachments.build(params[:attachment])      
+      @attachment.author_id = session[:user].id unless session[:user].nil?
+      @attachment.save
+    end
+    render :action => 'show'
+  end
+  
+  def destroy_attachment
+    @document.attachments.find(params[:attachment_id]).destroy
+    render :action => 'show'
+  end
+
+private
+	def find_project
+    @document = Document.find(params[:id])
+		@project = @document.project
+	end  
+  
+end

File redmine/app/controllers/enumerations_controller.rb

+# redMine - project management software
+# Copyright (C) 2006  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+class EnumerationsController < ApplicationController
+  layout 'base'
+  before_filter :require_admin
+  
+  def index
+    list
+    render :action => 'list'
+  end
+
+  # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
+  verify :method => :post, :only => [ :destroy, :create, :update ],
+         :redirect_to => { :action => :list }
+
+  def list
+  end
+
+  def new
+    @enumeration = Enumeration.new(:opt => params[:opt])
+  end
+
+  def create
+    @enumeration = Enumeration.new(params[:enumeration])
+    if @enumeration.save
+      flash[:notice] = 'Enumeration was successfully created.'
+      redirect_to :action => 'list', :opt => @enumeration.opt
+    else
+      render :action => 'new'
+    end
+  end
+
+  def edit
+    @enumeration = Enumeration.find(params[:id])
+  end
+
+  def update
+    @enumeration = Enumeration.find(params[:id])
+    if @enumeration.update_attributes(params[:enumeration])
+      flash[:notice] = 'Enumeration was successfully updated.'
+      redirect_to :action => 'list', :opt => @enumeration.opt
+    else
+      render :action => 'edit'
+    end
+  end
+
+  def destroy
+    Enumeration.find(params[:id]).destroy
+    redirect_to :action => 'list'
+  rescue
+    flash[:notice] = "Unable to delete enumeration"
+    redirect_to :action => 'list'
+  end
+end

File redmine/app/controllers/help_controller.rb

+# 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
+
+	def index	
+		if @params[:ctrl] and @help_config[@params[:ctrl]]
+			if @params[:page] and @help_config[@params[:ctrl]][@params[:page]]
+				template = @help_config[@params[:ctrl]][@params[:page]]
+			else
+				template = @help_config[@params[:ctrl]]['index']
+			end
+		end
+		
+    if template
+      redirect_to "/manual/#{template}"
+    else
+      redirect_to "/manual/"
+    end
+	end
+
+private
+	def load_help_config
+		@help_config = YAML::load(File.open("#{RAILS_ROOT}/config/help.yml"))
+	end	
+end

File redmine/app/controllers/issue_categories_controller.rb

+# redMine - project management software
+# Copyright (C) 2006  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+class IssueCategoriesController < ApplicationController
+	layout 'base'
+	before_filter :find_project, :authorize
+	
+  def edit
+    if request.post? and @category.update_attributes(params[:category])
+      flash[:notice] = 'Issue category was successfully updated.'
+      redirect_to :controller => 'projects', :action => 'settings', :id => @project
+    end
+  end
+
+  def destroy
+    @category.destroy
+    redirect_to :controller => 'projects', :action => 'settings', :id => @project
+  rescue
+    flash[:notice] = "Categorie can't be deleted"
+    redirect_to :controller => 'projects', :action => 'settings', :id => @project
+  end
+
+private
+	def find_project
+    @category = IssueCategory.find(params[:id])
+		@project = @category.project
+	end    
+end

File redmine/app/controllers/issue_statuses_controller.rb

+# redMine - project management software
+# Copyright (C) 2006  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+class IssueStatusesController < ApplicationController
+	layout 'base'	
+	before_filter :require_admin
+	
+  def index
+    list
+    render :action => 'list'
+  end
+
+  def list
+    @issue_status_pages, @issue_statuses = paginate :issue_statuses, :per_page => 10
+  end
+
+  def new
+    @issue_status = IssueStatus.new
+  end
+
+  def create
+    @issue_status = IssueStatus.new(params[:issue_status])
+    if @issue_status.save
+      flash[:notice] = 'IssueStatus was successfully created.'
+      redirect_to :action => 'list'
+    else
+      render :action => 'new'
+    end
+  end
+
+  def edit
+    @issue_status = IssueStatus.find(params[:id])
+  end
+
+  def update
+    @issue_status = IssueStatus.find(params[:id])
+    if @issue_status.update_attributes(params[:issue_status])
+      flash[:notice] = 'IssueStatus was successfully updated.'
+      redirect_to :action => 'list'
+    else
+      render :action => 'edit'
+    end
+  end
+
+  def destroy
+    IssueStatus.find(params[:id]).destroy
+    redirect_to :action => 'list'
+  rescue
+    flash[:notice] = "Unable to delete issue status"
+    redirect_to :action => 'list'
+  end
+  
+  	
+end

File redmine/app/controllers/issues_controller.rb

+# redMine - project management software
+# Copyright (C) 2006  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+class IssuesController < ApplicationController
+	layout 'base'
+	before_filter :find_project, :authorize
+
+	helper :custom_fields
+	include CustomFieldsHelper
+	
+	def show
+    @status_options = @issue.status.workflows.find(:all, :conditions => ["role_id=? and tracker_id=?", session[:user].role_for_project(@project.id), @issue.tracker.id]).collect{ |w| w.new_status } if session[:user]
+	end
+
+	def edit
+		@trackers = Tracker.find(:all)
+		@priorities = Enumeration::get_values('IPRI')
+		
+		if request.get?
+			@custom_values = @project.custom_fields_for_issues.collect { |x| @issue.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
+		else
+			# Retrieve custom fields and values
+			@custom_values = @project.custom_fields_for_issues.collect { |x| CustomValue.new(:custom_field => x, :value => params["custom_fields"][x.id.to_s]) }
+
+			@issue.custom_values = @custom_values
+			if @issue.update_attributes(params[:issue])
+				flash[:notice] = 'Issue was successfully updated.'
+				redirect_to :action => 'show', :id => @issue
+			end
+		end		
+	end
+	
+	def change_status
+		@history = @issue.histories.build(params[:history])	
+    @status_options = @issue.status.workflows.find(:all, :conditions => ["role_id=? and tracker_id=?", session[:user].role_for_project(@project.id), @issue.tracker.id]).collect{ |w| w.new_status } if session[:user]
+		
+		if params[:confirm]
+			unless session[:user].nil?
+				@history.author = session[:user]
+			end			
+			if @history.save			
+				@issue.status = @history.status
+				@issue.fixed_version_id = (params[:issue][:fixed_version_id])
+				@issue.assigned_to_id = (params[:issue][:assigned_to_id])	
+				if @issue.save
+					flash[:notice] = 'Issue was successfully updated.'
+					Mailer.deliver_issue_change_status(@issue) if Permission.find_by_controller_and_action(@params[:controller], @params[:action]).mail_enabled?
+					redirect_to :action => 'show', :id => @issue
+				end
+			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 attachment
+    if params[:attachment][:file].size > 0
+      @attachment = @issue.attachments.build(params[:attachment])      
+      @attachment.author_id = session[:user].id unless session[:user].nil?
+      @attachment.save
+    end
+    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
+	end
+	
+private
+	def find_project
+    @issue = Issue.find(params[:id])
+		@project = @issue.project
+	end  
+  
+end

File redmine/app/controllers/members_controller.rb

+# redMine - project management software
+# Copyright (C) 2006  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+class MembersController < ApplicationController
+	layout 'base'
+	before_filter :find_project, :authorize
+
+	def edit
+		if request.post? and @member.update_attributes(params[:member])
+			flash[:notice] = 'Member was successfully updated.'
+			redirect_to :controller => 'projects', :action => 'settings', :id => @project
+		end
+	end
+
+	def destroy
+		@member.destroy
+    flash[:notice] = 'Member was successfully removed.'
+		redirect_to :controller => 'projects', :action => 'settings', :id => @project
+	end
+
+private
+	def find_project
+    @member = Member.find(params[:id]) 
+		@project = @member.project
+	end  
+  
+end

File redmine/app/controllers/news_controller.rb

+# redMine - project management software
+# Copyright (C) 2006  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+class NewsController < ApplicationController
+	layout 'base'
+	before_filter :find_project, :authorize
+
+  def show
+  end
+
+  def edit
+    if request.post? and @news.update_attributes(params[:news])
+      flash[:notice] = 'News was successfully updated.'
+      redirect_to :action => 'show', :id => @news
+    end
+  end
+
+	def destroy
+		@news.destroy
+		redirect_to :controller => 'projects', :action => 'list_news', :id => @project
+	end
+  
+private
+	def find_project
+    @news = News.find(params[:id])
+		@project = @news.project
+	end  
+end

File redmine/app/controllers/projects_controller.rb

+# redMine - project management software
+# Copyright (C) 2006  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+class ProjectsController < ApplicationController
+	layout 'base'
+	before_filter :find_project, :authorize, :except => [ :index, :list, :add ]
+  before_filter :require_admin, :only => [ :add, :destroy ]
+
+  helper :sort
+	include SortHelper	
+	helper :search_filter
+	include SearchFilterHelper	
+	helper :custom_fields
+	include CustomFieldsHelper   
+
+	def index
+		list
+		render :action => 'list'
+	end
+
+	# Lists public projects
+	def list
+		sort_init 'projects.name', 'asc'
+		sort_update		
+		@project_count = Project.count(["public=?", true])		
+		@project_pages = Paginator.new self, @project_count,
+								15,
+								@params['page']								
+		@projects = Project.find :all, :order => sort_clause,
+						:conditions => ["public=?", true],
+						:limit  =>  @project_pages.items_per_page,
+						:offset =>  @project_pages.current.offset		
+  end
+          
+  # Add a new project
+	def add
+		@custom_fields = CustomField::find_all
+		@project = Project.new(params[:project])
+		if request.post?
+			@project.custom_fields = CustomField.find(@params[:custom_field_ids]) if @params[:custom_field_ids]
+			if @project.save
+				flash[:notice] = 'Project was successfully created.'
+				redirect_to :controller => 'admin', :action => 'projects'
+			end		
+		end	
+	end
+	
+	# Show @project
+	def show
+    @members = @project.members.find(:all, :include => [:user, :role])
+	end
+
+  def settings
+		@custom_fields = CustomField::find_all
+		@issue_category ||= IssueCategory.new
+    @member ||= @project.members.new
+    @roles = Role.find_all
+    @users = User.find_all - @project.members.find(:all, :include => :user).collect{|m| m.user }
+  end
+  
+	# Edit @project
+	def edit
+		if request.post?
+			@project.custom_fields = CustomField.find(@params[:custom_field_ids]) if @params[:custom_field_ids]
+			if @project.update_attributes(params[:project])
+				flash[:notice] = 'Project was successfully updated.'
+				redirect_to :action => 'settings', :id => @project
+      else
+        settings
+        render :action => 'settings'
+			end
+		end
+  end
+  
+	# Delete @project
+	def destroy
+    if request.post? and params[:confirm]
+      @project.destroy
+      redirect_to :controller => 'admin', :action => 'projects'
+    end
+	end
+	
+	# Add a new issue category to @project
+	def add_issue_category
+		if request.post?
+			@issue_category = @project.issue_categories.build(params[:issue_category])
+			if @issue_category.save
+				redirect_to :action => 'settings', :id => @project
+			else
+        settings
+        render :action => 'settings'
+			end
+		end
+	end	
+	
+	# Add a new version to @project
+	def add_version
+		@version = @project.versions.build(params[:version])
+		if request.post? and @version.save
+      redirect_to :action => 'settings', :id => @project
+		end
+	end
+
+	# Add a new member to @project
+	def add_member
+    @member = @project.members.build(params[:member])
+		if request.post?
+			if @member.save
+        flash[:notice] = 'Member was successfully added.'
+				redirect_to :action => 'settings', :id => @project
+			else		
+        settings
+        render :action => 'settings'
+      end
+		end
+	end
+
+	# Show members list of @project
+	def list_members
+		@members = @project.members
+	end
+
+	# Add a new document to @project
+	def add_document
+		@categories = Enumeration::get_values('DCAT')
+		@document = @project.documents.build(params[:document])    
+		if request.post?			
+      # Save the attachment
+			if params[:attachment][:file].size > 0
+				@attachment = @document.attachments.build(params[:attachment])				
+        @attachment.author_id = session[:user].id unless session[:user].nil?
+			end      
+			if @document.save
+				redirect_to :action => 'list_documents', :id => @project
+			end		
+		end
+	end
+
+	# Show documents list of @project
+	def list_documents
+		@documents = @project.documents
+	end
+
+	# Add a new issue to @project
+	def add_issue
+		@trackers = Tracker.find(:all)
+		@priorities = Enumeration::get_values('IPRI')		
+		if request.get?
+			@issue = @project.issues.build
+			@custom_values = @project.custom_fields_for_issues.collect { |x| CustomValue.new(:custom_field => x) }
+		else
+			# Create the issue and set the author
+			@issue = @project.issues.build(params[:issue])
+      @issue.author = session[:user] unless session[:user].nil?			
+			# Create the document if a file was sent
+			if params[:attachment][:file].size > 0
+				@attachment = @issue.attachments.build(params[:attachment])				
+        @attachment.author_id = session[:user].id unless session[:user].nil?
+			end
+			@custom_values = @project.custom_fields_for_issues.collect { |x| CustomValue.new(:custom_field => x, :value => params["custom_fields"][x.id.to_s]) }
+			@issue.custom_values = @custom_values			
+			if @issue.save
+        flash[:notice] = "Issue was successfully added."
+				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 issues list of @project
+	def list_issues
+		sort_init 'issues.id', 'desc'
+		sort_update
+		
+		search_filter_criteria 'issues.tracker_id', :values => "Tracker.find(:all)"
+		search_filter_criteria 'issues.priority_id', :values => "Enumeration.find(:all, :conditions => ['opt=?','IPRI'])"
+		search_filter_criteria 'issues.category_id', :values => "@project.issue_categories"
+		search_filter_criteria 'issues.status_id', :values => "IssueStatus.find(:all)"
+		search_filter_criteria 'issues.author_id', :values => "User.find(:all)", :label => "display_name"
+		search_filter_update if params[:set_filter] or request.post?
+						
+		@issue_count = @project.issues.count(search_filter_clause)		
+		@issue_pages = Paginator.new self, @issue_count,
+								15,
+								@params['page']								
+		@issues =  @project.issues.find :all, :order => sort_clause,
+						:include => [ :author, :status, :tracker ],
+						:conditions => search_filter_clause,
+						:limit  =>  @issue_pages.items_per_page,
+						:offset =>  @issue_pages.current.offset								
+	end
+
+	# Add a news to @project
+	def add_news
+    @news = @project.news.build(params[:news])
+		if request.post?
+			@news.author = session[:user] unless session[:user].nil?
+			if @news.save
+				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"
+	end
+  
+  def add_file  
+    if request.post?
+      # Save the attachment
+      if params[:attachment][:file].size > 0
+        @attachment = @project.versions.find(params[:version_id]).attachments.build(params[:attachment])      
+        @attachment.author_id = session[:user].id unless session[:user].nil?
+        if @attachment.save
+          redirect_to :controller => 'projects', :action => 'list_files', :id => @project
+        end
+      end
+    end
+    @versions = @project.versions
+  end
+  
+  def list_files
+    @versions = @project.versions
+  end
+  
+	# Show changelog of @project
+	def changelog
+  @fixed_issues = @project.issues.find(:all, 
+                                                        :include => [ :fixed_version, :status, :tracker ], 
+                                                        :conditions => [ "issue_statuses.is_closed=? and trackers.is_in_chlog=? and issues.fixed_version_id is not null", true, true]
+                                                        )
+	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])		
+		rescue
+			flash[:notice] = 'Project not found.'
+			redirect_to :action => 'list'			
+	end
+
+end

File redmine/app/controllers/reports_controller.rb

+# 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
+    @trackers = Tracker.find_all
+    @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, t.id")
+    @priorities = Enumeration::get_values('IPRI')
+    @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, p.id")
+    @categories = @project.issue_categories
+    @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, c.id")
+  end
+  
+  
+private
+	# Find project of id params[:id]
+	def find_project
+		@project = Project.find(params[:id])		
+	end
+end

File redmine/app/controllers/roles_controller.rb

+# redMine - project management software
+# Copyright (C) 2006  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+class RolesController < ApplicationController
+	layout 'base'	
+	before_filter :require_admin
+	
+  def index
+    list
+    render :action => 'list'
+  end
+
+  def list
+    @role_pages, @roles = paginate :roles, :per_page => 10
+  end
+
+  def new
+    @role = Role.new(params[:role])
+    if request.post?
+      @role.permissions = Permission.find(@params[:permission_ids]) if @params[:permission_ids]
+      if @role.save
+        flash[:notice] = 'Role was successfully created.'
+        redirect_to :action => 'list'
+      end
+    end
+    @permissions = Permission.find(:all, :order => 'sort ASC')
+  end
+
+  def edit
+    @role = Role.find(params[:id])
+    if request.post? and @role.update_attributes(params[:role])
+      @role.permissions = Permission.find(@params[:permission_ids] || [])
+      Permission.allowed_to_role_expired
+      flash[:notice] = 'Role was successfully updated.'
+      redirect_to :action => 'list'
+    end
+    @permissions = Permission.find(:all, :order => 'sort ASC')
+  end
+
+  def destroy
+    @role = Role.find(params[:id])
+    unless @role.members.empty?
+      flash[:notice] = 'Some members have this role. Can\'t delete it.'
+    else
+      @role.destroy
+    end
+    redirect_to :action => 'list'
+  end
+  
+  def workflow
+    @roles = Role.find_all
+    @trackers = Tracker.find_all
+    @statuses = IssueStatus.find_all
+    
+    @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] = 'Workflow was successfully updated.'
+      end
+    end
+  end
+end

File redmine/app/controllers/trackers_controller.rb

+# redMine - project management software
+# Copyright (C) 2006  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+class TrackersController < ApplicationController
+	layout 'base'
+	before_filter :require_admin
+
+  def index
+    list
+    render :action => 'list'
+  end
+
+  # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
+  verify :method => :post, :only => [ :destroy ], :redirect_to => { :action => :list }
+
+  def list
+    @tracker_pages, @trackers = paginate :trackers, :per_page => 10
+  end
+
+  def new
+    @tracker = Tracker.new(params[:tracker])
+    if request.post? and @tracker.save
+      flash[:notice] = 'Tracker was successfully created.'
+      redirect_to :action => 'list'
+    end
+  end
+
+  def edit
+    @tracker = Tracker.find(params[:id])
+    if request.post? and @tracker.update_attributes(params[:tracker])
+      flash[:notice] = 'Tracker was successfully updated.'
+      redirect_to :action => 'list'
+    end
+  end
+
+  def destroy
+    @tracker = Tracker.find(params[:id])
+    unless @tracker.issues.empty?
+      flash[:notice] = "This tracker contains issues and can\'t be deleted."
+    else
+      @tracker.destroy
+    end
+    redirect_to :action => 'list'
+  end
+  
+end

File redmine/app/controllers/users_controller.rb

+# redMine - project management software
+# Copyright (C) 2006  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+class UsersController < ApplicationController
+	layout 'base'	
+	before_filter :require_admin
+  
+	helper :sort
+	include SortHelper
+	
+	def index
+		list
+		render :action => 'list'
+	end
+
+	def list
+		sort_init 'users.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		
+	end
+
+	def add
+		if request.get?
+			@user = User.new
+		else
+			@user = User.new(params[:user])
+			@user.admin = params[:user][:admin]
+			if @user.save
+				flash[:notice] = 'User was successfully created.'
+				redirect_to :action => 'list'
+			end
+		end
+	end
+
+	def edit
+		@user = User.find(params[:id])
+		if request.post?
+			@user.admin = params[:user][:admin] if params[:user][:admin]
+			if @user.update_attributes(params[:user])
+				flash[:notice] = 'User was successfully updated.'
+				redirect_to :action => 'list'
+			end
+		end
+	end
+
+	def destroy
+		User.find(params[:id]).destroy
+		redirect_to :action => 'list'
+  rescue
+    flash[:notice] = "Unable to delete user"
+    redirect_to :action => 'list'
+	end  
+end

File redmine/app/controllers/versions_controller.rb

+# redMine - project management software
+# Copyright (C) 2006  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+class VersionsController < ApplicationController
+	layout 'base'
+	before_filter :find_project, :authorize
+	
+	def edit
+		if request.post? and @version.update_attributes(params[:version])
+      flash[:notice] = 'Version was successfully updated.'
+      redirect_to :controller => 'projects', :action => 'settings', :id => @project
+		end
+	end
+	
+	def destroy
+		@version.destroy
+		redirect_to :controller => 'projects', :action => 'settings', :id => @project
+  rescue
+    flash[:notice] = "Unable to delete version"
+		redirect_to :controller => 'projects', :action => 'settings', :id => @project
+	end
+  
+  def download
+    @attachment = @version.attachments.find(params[:attachment_id])
+    @attachment.increment_download
+    send_file @attachment.diskfile, :filename => @attachment.filename
+  end 
+  
+  def destroy_file
+    @version.attachments.find(params[:attachment_id]).destroy
+    redirect_to :controller => 'projects', :action => 'list_files', :id => @project
+  end
+
+private
+	def find_project
+    @version = Version.find(params[:id])
+		@project = @version.project
+	end  
+end

File redmine/app/controllers/welcome_controller.rb

+# redMine - project management software
+# Copyright (C) 2006  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+class WelcomeController < ApplicationController
+	layout 'base'
+	
+	def index
+    @news = News.latest
+    @projects = Project.latest
+	end
+
+end

File redmine/app/helpers/account_helper.rb

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

File redmine/app/helpers/admin_helper.rb

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

File redmine/app/helpers/application_helper.rb

+# redMine - project management software
+# Copyright (C) 2006  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+module ApplicationHelper
+
+	def loggedin?
+		session[:user]
+	end
+
+	def admin_loggedin?
+		session[:user] && session[:user].admin
+	end
+	
+	def authorize_for(controller, action)  
+    # check if action is allowed on public projects
+    if @project.public? and Permission.allowed_to_public "%s/%s" % [ controller, action ]
+      return true
+    end  
+    # check if user is authorized    
+    if session[:user] and (session[:user].admin? or Permission.allowed_to_role( "%s/%s" % [ controller, action ], session[:user].role_for_project(@project.id)  )  )
+			return true
+		end		
+		return false	  
+	end
+	
+	def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference)
+		link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller], options[:action])
+	end
+	
+	# Display a link to user's account page
+	def link_to_user(user)
+		link_to user.display_name, :controller => 'account', :action => 'show', :id => user
+	end
+	
+  def format_date(date)
+    _('(date)', date) if date
+  end
+  
+  def format_time(time)
+    _('(time)', time) if time
+  end
+  
+  def pagination_links_full(paginator, options={}, html_options={})
+    html =''
+    html << link_to(('&#171; ' + _('Previous') ), { :page => paginator.current.previous }) + ' ' if paginator.current.previous
+    html << (pagination_links(paginator, options, html_options) || '')
+    html << ' ' + link_to((_('Next') + ' &#187;'), { :page => paginator.current.next }) if paginator.current.next
+    html  
+  end
+
+end

File redmine/app/helpers/custom_fields_helper.rb

+# 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
+	def custom_field_tag(custom_value)
+	
+		custom_field = custom_value.custom_field
+		
+		field_name = "custom_fields[#{custom_field.id}]"
+		
+		case custom_field.typ
+		when 0 .. 2
+			text_field_tag field_name, custom_value.value
+		when 3
+			check_box field_name