Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/edavis10/redmine
Browse files Browse the repository at this point in the history
(as of 19/01 13:25 Moscow time)

Conflicts resolved:

	app/controllers/attachments_controller.rb
	app/controllers/issues_controller.rb
	app/controllers/timelog_controller.rb
	app/helpers/application_helper.rb
	app/helpers/sort_helper.rb
	app/models/issue.rb
	app/models/query.rb
	app/models/time_entry.rb
	app/models/user.rb
	app/models/version.rb
	app/views/account/show.rhtml
	app/views/issues/show.rfpdf
	app/views/issues/show.rhtml
	app/views/layouts/base.rhtml
	app/views/my/account.rhtml
	app/views/timelog/_list.rhtml
	app/views/timelog/edit.rhtml
	config/routes.rb
	lang/da.yml
	lang/de.yml
	lang/en.yml
	lang/es.yml
	lang/fi.yml
	lang/he.yml
	lang/hu.yml
	lang/ja.yml
	lang/ko.yml
	lang/lt.yml
	lang/nl.yml
	lang/pl.yml
	lang/pt-br.yml
	lang/pt.yml
	lang/ru.yml
	lang/sv.yml
	lang/zh-tw.yml
	lang/zh.yml
	lib/tasks/trac/trac0.8.4/migrate_from_trac.rake
	test/fixtures/issues.yml
	test/fixtures/members.yml
	test/functional/issues_controller_test.rb
	test/functional/versions_controller_test.rb
	test/unit/issue_test.rb
	test/unit/user_test.rb
	test/unit/version_test.rb
  • Loading branch information
Artem Vasiliev committed Jan 20, 2009
2 parents c8d4236 + dacddd9 commit 10baff4
Show file tree
Hide file tree
Showing 349 changed files with 17,798 additions and 8,572 deletions.
14 changes: 11 additions & 3 deletions app/apis/sys_api.rb
Expand Up @@ -15,11 +15,19 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

class AWSProjectWithRepository < ActionWebService::Struct
member :id, :int
member :identifier, :string
member :name, :string
member :is_public, :bool
member :repository, Repository
end

class SysApi < ActionWebService::API::Base
api_method :projects,
api_method :projects_with_repository_enabled,
:expects => [],
:returns => [[Project]]
:returns => [[AWSProjectWithRepository]]
api_method :repository_created,
:expects => [:string, :string],
:expects => [:string, :string, :string],
:returns => [:int]
end
10 changes: 7 additions & 3 deletions app/controllers/account_controller.rb
@@ -1,5 +1,5 @@
# redMine - project management software
# Copyright (C) 2006-2007 Jean-Philippe Lang
# Redmine - project management software
# Copyright (C) 2006-2008 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
Expand All @@ -24,13 +24,17 @@ class AccountController < ApplicationController

# Show user's account
def show
@user = User.find_active(params[:id])
@user = User.active.find(params[:id])
@custom_values = @user.custom_values

# show only public projects and private projects that the logged in user is also a member of
@memberships = @user.memberships.select do |membership|
membership.project.is_public? || (User.current.member_of?(membership.project))
end

events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 10)
@events_by_day = events.group_by(&:event_date)

rescue ActiveRecord::RecordNotFound
render_404
end
Expand Down
22 changes: 15 additions & 7 deletions app/controllers/admin_controller.rb
Expand Up @@ -27,24 +27,32 @@ def index

def projects
sort_init 'name', 'asc'
sort_update
sort_update %w(name is_public created_on)

@status = params[:status] ? params[:status].to_i : 0
conditions = nil
conditions = ["status=?", @status] unless @status == 0
@status = params[:status] ? params[:status].to_i : 1
c = ARCondition.new(@status == 0 ? "status <> 0" : ["status = ?", @status])

@project_count = Project.count(:conditions => conditions)
unless params[:name].blank?
name = "%#{params[:name].strip.downcase}%"
c << ["LOWER(identifier) LIKE ? OR LOWER(name) LIKE ?", name, name]
end

@project_count = Project.count(:conditions => c.conditions)
@project_pages = Paginator.new self, @project_count,
per_page_option,
params['page']
@projects = Project.find :all, :order => sort_clause,
:conditions => conditions,
:conditions => c.conditions,
:limit => @project_pages.items_per_page,
:offset => @project_pages.current.offset

render :action => "projects", :layout => false if request.xhr?
end

def plugins
@plugins = Redmine::Plugin.all
end

# Loads the default configuration
# (roles, trackers, statuses, workflow, enumerations)
def default_configuration
Expand Down Expand Up @@ -78,8 +86,8 @@ def info
@flags = {
:default_admin_changed => User.find(:first, :conditions => ["login=? and hashed_password=?", 'admin', User.hash_password('admin')]).nil?,
:file_repository_writable => File.writable?(Attachment.storage_path),
:plugin_assets_writable => File.writable?(Engines.public_directory),
:rmagick_available => Object.const_defined?(:Magick)
}
@plugins = Redmine::Plugin.registered_plugins
end
end
25 changes: 17 additions & 8 deletions app/controllers/application.rb
Expand Up @@ -16,6 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

require 'uri'
require 'cgi'

class ApplicationController < ActionController::Base
layout 'base'
Expand Down Expand Up @@ -51,7 +52,7 @@ def user_setup
def find_current_user
if session[:user_id]
# existing session
(User.find_active(session[:user_id]) rescue nil)
(User.active.find(session[:user_id]) rescue nil)
elsif cookies[:autologin] && Setting.autologin?
# auto-login feature
User.find_by_autologin_key(cookies[:autologin])
Expand Down Expand Up @@ -87,7 +88,7 @@ def set_localization

def require_login
if !User.current.logged?
redirect_to :controller => "account", :action => "login", :back_url => request.request_uri
redirect_to :controller => "account", :action => "login", :back_url => url_for(params)
return false
end
true
Expand Down Expand Up @@ -131,12 +132,16 @@ def check_project_privacy
end

def redirect_back_or_default(default)
back_url = params[:back_url]
back_url = CGI.unescape(params[:back_url].to_s)
if !back_url.blank?
uri = URI.parse(back_url)
# do not redirect user to another host
if uri.relative? || (uri.host == request.host)
redirect_to(back_url) and return
begin
uri = URI.parse(back_url)
# do not redirect user to another host or to the login or register page
if (uri.relative? || (uri.host == request.host)) && !uri.path.match(%r{/(login|account/register)})
redirect_to(back_url) and return
end
rescue URI::InvalidURIError
# redirect to default
end
end
redirect_to default
Expand Down Expand Up @@ -178,6 +183,7 @@ def accept_key_auth_actions
# TODO: move to model
def attach_files(obj, attachments)
attached = []
unsaved = []
if attachments && attachments.is_a?(Hash)
attachments.each_value do |attachment|
file = attachment['file']
Expand All @@ -186,7 +192,10 @@ def attach_files(obj, attachments)
:file => file,
:description => attachment['description'].to_s.strip,
:author => User.current)
attached << a unless a.new_record?
a.new_record? ? (unsaved << a) : (attached << a)
end
if unsaved.any?
flash[:warning] = l(:warning_attachments_not_saved, unsaved.size)
end
end
attached
Expand Down
38 changes: 29 additions & 9 deletions app/controllers/attachments_controller.rb
@@ -1,5 +1,5 @@
# redMine - project management software
# Copyright (C) 2006-2007 Jean-Philippe Lang
# Redmine - project management software
# Copyright (C) 2006-2008 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
Expand All @@ -17,20 +17,28 @@

class AttachmentsController < ApplicationController
before_filter :find_project

before_filter :read_authorize, :except => :destroy
before_filter :delete_authorize, :only => :destroy

verify :method => :post, :only => :destroy

def show
if @attachment.is_diff?
@diff = File.new(@attachment.diskfile, "rb").read
render :action => 'diff'
elsif @attachment.is_text?
@content = File.new(@attachment.diskfile, "rb").read
render :action => 'file'
elsif
else
download
end
end

def download
if @attachment.container.is_a?(Version) || @attachment.container.is_a?(Project)
@attachment.increment_download
end

# images are sent inline
options = {:filename =>
filename_for_content_disposition(@attachment.filename),
Expand All @@ -39,18 +47,30 @@ def download
options.merge!(:type => @attachment.content_type) if @attachment.content_type
send_file @attachment.diskfile, options
end


def destroy
# Make sure association callbacks are called
@attachment.container.attachments.delete(@attachment)
redirect_to :back
rescue ::ActionController::RedirectBackError
redirect_to :controller => 'projects', :action => 'show', :id => @project
end

private
def find_project
@attachment = Attachment.find(params[:id])
# Show 404 if the filename in the url is wrong
raise ActiveRecord::RecordNotFound if params[:filename] && params[:filename] != @attachment.filename

@project = @attachment.project
permission = @attachment.container.is_a?(Version) ? :view_files : "view_#{@attachment.container.class.name.underscore.pluralize}".to_sym
allowed = User.current.allowed_to?(permission, @project)
allowed ? true : (User.current.logged? ? render_403 : require_login)
rescue ActiveRecord::RecordNotFound
render_404
end

def read_authorize
@attachment.visible? ? true : deny_access
end

def delete_authorize
@attachment.deletable? ? true : deny_access
end
end
8 changes: 5 additions & 3 deletions app/controllers/boards_controller.rb
Expand Up @@ -35,12 +35,14 @@ def index
end

def show
sort_init "#{Message.table_name}.updated_on", "desc"
sort_update
sort_init 'updated_on', 'desc'
sort_update 'created_on' => "#{Message.table_name}.created_on",
'replies' => "#{Message.table_name}.replies_count",
'updated_on' => "#{Message.table_name}.updated_on"

@topic_count = @board.topics.count
@topic_pages = Paginator.new self, @topic_count, per_page_option, params['page']
@topics = @board.topics.find :all, :order => "#{Message.table_name}.sticky DESC, #{sort_clause}",
@topics = @board.topics.find :all, :order => ["#{Message.table_name}.sticky DESC", sort_clause].compact.join(', '),
:include => [:author, {:last_reply => :author}],
:limit => @topic_pages.items_per_page,
:offset => @topic_pages.current.offset
Expand Down
45 changes: 15 additions & 30 deletions app/controllers/custom_fields_controller.rb
@@ -1,5 +1,5 @@
# redMine - project management software
# Copyright (C) 2006 Jean-Philippe Lang
# Redmine - project management software
# Copyright (C) 2006-2009 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
Expand All @@ -19,46 +19,31 @@ class CustomFieldsController < ApplicationController
before_filter :require_admin

def index
list
render :action => 'list' unless request.xhr?
end

def list
@custom_fields_by_type = CustomField.find(:all).group_by {|f| f.class.name }
@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])
when "TimeEntryCustomField"
@custom_field = TimeEntryCustomField.new(params[:custom_field])
else
redirect_to :action => 'list'
return
end
@custom_field = begin
if params[:type].to_s.match(/.+CustomField$/)
params[:type].to_s.constantize.new(params[:custom_field])
end
rescue
end
redirect_to(:action => 'index') and return unless @custom_field.is_a?(CustomField)

if request.post? and @custom_field.save
flash[:notice] = l(:notice_successful_create)
redirect_to :action => 'list', :tab => @custom_field.class.name
redirect_to :action => 'index', :tab => @custom_field.class.name
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.class.name
redirect_to :action => 'index', :tab => @custom_field.class.name
end
@trackers = Tracker.find(:all, :order => 'position')
end
Expand All @@ -75,14 +60,14 @@ def move
when 'lowest'
@custom_field.move_to_bottom
end if params[:position]
redirect_to :action => 'list', :tab => @custom_field.class.name
redirect_to :action => 'index', :tab => @custom_field.class.name
end

def destroy
@custom_field = CustomField.find(params[:id]).destroy
redirect_to :action => 'list', :tab => @custom_field.class.name
redirect_to :action => 'index', :tab => @custom_field.class.name
rescue
flash[:error] = "Unable to delete custom field"
redirect_to :action => 'list'
redirect_to :action => 'index'
end
end
6 changes: 1 addition & 5 deletions app/controllers/documents_controller.rb
Expand Up @@ -35,6 +35,7 @@ def index
else
@grouped = documents.group_by(&:category)
end
@document = @project.documents.build
render :layout => false if request.xhr?
end

Expand Down Expand Up @@ -70,11 +71,6 @@ def add_attachment
Mailer.deliver_attachments_added(attachments) if !attachments.empty? && Setting.notified_events.include?('document_added')
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
Expand Down

0 comments on commit 10baff4

Please sign in to comment.