mirror of
https://github.com/redmine/redmine.git
synced 2026-03-05 12:01:23 +01:00
Merged trunk r1773.
git-svn-id: http://redmine.rubyforge.org/svn/branches/work@1774 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class AccountController < ApplicationController
|
||||
layout 'base'
|
||||
helper :custom_fields
|
||||
include CustomFieldsHelper
|
||||
|
||||
@@ -26,7 +25,7 @@ class AccountController < ApplicationController
|
||||
# Show user's account
|
||||
def show
|
||||
@user = User.find_active(params[:id])
|
||||
@custom_values = @user.custom_values.find(:all, :include => :custom_field)
|
||||
@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|
|
||||
@@ -44,7 +43,16 @@ class AccountController < ApplicationController
|
||||
else
|
||||
# Authenticate user
|
||||
user = User.try_to_login(params[:username], params[:password])
|
||||
if user
|
||||
if user.nil?
|
||||
# Invalid credentials
|
||||
flash.now[:error] = l(:notice_account_invalid_creditentials)
|
||||
elsif user.new_record?
|
||||
# Onthefly creation failed, display the registration form to fill/fix attributes
|
||||
@user = user
|
||||
session[:auth_source_registration] = {:login => user.login, :auth_source_id => user.auth_source_id }
|
||||
render :action => 'register'
|
||||
else
|
||||
# Valid user
|
||||
self.logged_user = user
|
||||
# generate a key and set cookie if autologin
|
||||
if params[:autologin] && Setting.autologin?
|
||||
@@ -52,12 +60,8 @@ class AccountController < ApplicationController
|
||||
cookies[:autologin] = { :value => token.value, :expires => 1.year.from_now }
|
||||
end
|
||||
redirect_back_or_default :controller => 'my', :action => 'page'
|
||||
else
|
||||
flash.now[:error] = l(:notice_account_invalid_creditentials)
|
||||
end
|
||||
end
|
||||
rescue User::OnTheFlyCreationFailure
|
||||
flash.now[:error] = 'Redmine could not retrieve the required information from the LDAP to create your account. Please, contact your Redmine administrator.'
|
||||
end
|
||||
|
||||
# Log out current user and redirect to welcome page
|
||||
@@ -107,43 +111,52 @@ class AccountController < ApplicationController
|
||||
|
||||
# User self-registration
|
||||
def register
|
||||
redirect_to(home_url) && return unless Setting.self_registration?
|
||||
redirect_to(home_url) && return unless Setting.self_registration? || session[:auth_source_registration]
|
||||
if request.get?
|
||||
session[:auth_source_registration] = nil
|
||||
@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"] ? params["custom_fields"][x.id.to_s] : nil)) }
|
||||
@user.custom_values = @custom_values
|
||||
case Setting.self_registration
|
||||
when '1'
|
||||
# Email activation
|
||||
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 :action => 'login'
|
||||
end
|
||||
when '3'
|
||||
# Automatic activation
|
||||
if session[:auth_source_registration]
|
||||
@user.status = User::STATUS_ACTIVE
|
||||
@user.login = session[:auth_source_registration][:login]
|
||||
@user.auth_source_id = session[:auth_source_registration][:auth_source_id]
|
||||
if @user.save
|
||||
session[:auth_source_registration] = nil
|
||||
self.logged_user = @user
|
||||
flash[:notice] = l(:notice_account_activated)
|
||||
redirect_to :action => 'login'
|
||||
redirect_to :controller => 'my', :action => 'account'
|
||||
end
|
||||
else
|
||||
# Manual activation by the administrator
|
||||
if @user.save
|
||||
# Sends an email to the administrators
|
||||
Mailer.deliver_account_activation_request(@user)
|
||||
flash[:notice] = l(:notice_account_pending)
|
||||
redirect_to :action => 'login'
|
||||
@user.login = params[:user][:login]
|
||||
@user.password, @user.password_confirmation = params[:password], params[:password_confirmation]
|
||||
case Setting.self_registration
|
||||
when '1'
|
||||
# Email activation
|
||||
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 :action => 'login'
|
||||
end
|
||||
when '3'
|
||||
# Automatic activation
|
||||
@user.status = User::STATUS_ACTIVE
|
||||
if @user.save
|
||||
self.logged_user = @user
|
||||
flash[:notice] = l(:notice_account_activated)
|
||||
redirect_to :controller => 'my', :action => 'account'
|
||||
end
|
||||
else
|
||||
# Manual activation by the administrator
|
||||
if @user.save
|
||||
# Sends an email to the administrators
|
||||
Mailer.deliver_account_activation_request(@user)
|
||||
flash[:notice] = l(:notice_account_pending)
|
||||
redirect_to :action => 'login'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class AdminController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :require_admin
|
||||
|
||||
helper :sort
|
||||
|
||||
@@ -15,7 +15,11 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require 'uri'
|
||||
|
||||
class ApplicationController < ActionController::Base
|
||||
layout 'base'
|
||||
|
||||
before_filter :user_setup, :check_if_login_required, :set_localization
|
||||
filter_parameter_logging :password
|
||||
|
||||
@@ -61,11 +65,11 @@ class ApplicationController < ActionController::Base
|
||||
def set_localization
|
||||
User.current.language = nil unless User.current.logged?
|
||||
lang = begin
|
||||
if !User.current.language.blank? and GLoc.valid_languages.include? User.current.language.to_sym
|
||||
if !User.current.language.blank? && GLoc.valid_language?(User.current.language)
|
||||
User.current.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 = parse_qvalues(request.env['HTTP_ACCEPT_LANGUAGE']).first.downcase
|
||||
if !accept_lang.blank? && (GLoc.valid_language?(accept_lang) || GLoc.valid_language?(accept_lang = accept_lang.split('-').first))
|
||||
User.current.language = accept_lang
|
||||
end
|
||||
end
|
||||
@@ -77,8 +81,7 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
def require_login
|
||||
if !User.current.logged?
|
||||
store_location
|
||||
redirect_to :controller => "account", :action => "login"
|
||||
redirect_to :controller => "account", :action => "login", :back_url => request.request_uri
|
||||
return false
|
||||
end
|
||||
true
|
||||
@@ -115,20 +118,16 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
end
|
||||
|
||||
# store current uri in session.
|
||||
# return to this location by calling redirect_back_or_default
|
||||
def store_location
|
||||
session[:return_to_params] = params
|
||||
end
|
||||
|
||||
# move to the last store_location call or to the passed default one
|
||||
def redirect_back_or_default(default)
|
||||
if session[:return_to_params].nil?
|
||||
redirect_to default
|
||||
else
|
||||
redirect_to session[:return_to_params]
|
||||
session[:return_to_params] = nil
|
||||
back_url = params[:back_url]
|
||||
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
|
||||
end
|
||||
end
|
||||
redirect_to default
|
||||
end
|
||||
|
||||
def render_403
|
||||
|
||||
@@ -16,24 +16,40 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class AttachmentsController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :find_project, :check_project_privacy
|
||||
before_filter :find_project
|
||||
|
||||
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
|
||||
download
|
||||
end
|
||||
end
|
||||
|
||||
def download
|
||||
@attachment.increment_download if @attachment.container.is_a?(Version)
|
||||
|
||||
# images are sent inline
|
||||
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
|
||||
:type => @attachment.content_type,
|
||||
:disposition => (@attachment.image? ? 'inline' : 'attachment')
|
||||
rescue
|
||||
# in case the disk file was deleted
|
||||
render_404
|
||||
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
|
||||
rescue
|
||||
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
|
||||
end
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class AuthSourcesController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :require_admin
|
||||
|
||||
def index
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class BoardsController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :find_project, :authorize
|
||||
|
||||
helper :messages
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class CustomFieldsController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :require_admin
|
||||
|
||||
def index
|
||||
@@ -32,18 +31,20 @@ class CustomFieldsController < ApplicationController
|
||||
|
||||
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 "GroupCustomField"
|
||||
@custom_field = GroupCustomField.new(params[:custom_field])
|
||||
else
|
||||
render_404
|
||||
return
|
||||
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])
|
||||
when "GroupCustomField"
|
||||
@custom_field = GroupCustomField.new(params[:custom_field])
|
||||
else
|
||||
redirect_to :action => 'list'
|
||||
return
|
||||
end
|
||||
if request.post? and @custom_field.save
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class DocumentsController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :find_project, :only => [:index, :new]
|
||||
before_filter :find_document, :except => [:index, :new]
|
||||
before_filter :authorize
|
||||
@@ -65,15 +64,6 @@ class DocumentsController < ApplicationController
|
||||
@document.destroy
|
||||
redirect_to :controller => 'documents', :action => 'index', :project_id => @project
|
||||
end
|
||||
|
||||
def download
|
||||
@attachment = @document.attachments.find(params[:attachment_id])
|
||||
@attachment.increment_download
|
||||
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
|
||||
:type => @attachment.content_type
|
||||
rescue
|
||||
render_404
|
||||
end
|
||||
|
||||
def add_attachment
|
||||
attachments = attach_files(@document, params[:attachments])
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class EnumerationsController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :require_admin
|
||||
|
||||
def index
|
||||
@@ -75,11 +74,20 @@ class EnumerationsController < ApplicationController
|
||||
end
|
||||
|
||||
def destroy
|
||||
Enumeration.find(params[:id]).destroy
|
||||
flash[:notice] = l(:notice_successful_delete)
|
||||
redirect_to :action => 'list'
|
||||
rescue
|
||||
flash[:error] = "Unable to delete enumeration"
|
||||
redirect_to :action => 'list'
|
||||
@enumeration = Enumeration.find(params[:id])
|
||||
if !@enumeration.in_use?
|
||||
# No associated objects
|
||||
@enumeration.destroy
|
||||
redirect_to :action => 'index'
|
||||
elsif params[:reassign_to_id]
|
||||
if reassign_to = Enumeration.find_by_opt_and_id(@enumeration.opt, params[:reassign_to_id])
|
||||
@enumeration.destroy(reassign_to)
|
||||
redirect_to :action => 'index'
|
||||
end
|
||||
end
|
||||
@enumerations = Enumeration.get_values(@enumeration.opt) - [@enumeration]
|
||||
#rescue
|
||||
# flash[:error] = 'Unable to delete enumeration'
|
||||
# redirect_to :action => 'index'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class IssueCategoriesController < ApplicationController
|
||||
layout 'base'
|
||||
menu_item :settings
|
||||
before_filter :find_project, :authorize
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class IssueRelationsController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :find_project, :authorize
|
||||
|
||||
def new
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# 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 ],
|
||||
|
||||
@@ -16,10 +16,9 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class IssuesController < ApplicationController
|
||||
layout 'base'
|
||||
menu_item :new_issue, :only => :new
|
||||
|
||||
before_filter :find_issue, :only => [:show, :edit, :destroy_attachment]
|
||||
before_filter :find_issue, :only => [:show, :edit, :reply, :destroy_attachment]
|
||||
before_filter :find_issues, :only => [:bulk_edit, :move, :destroy]
|
||||
before_filter :find_project, :only => [:new, :update_form, :preview]
|
||||
before_filter :authorize, :except => [:index, :changes, :preview, :update_form, :context_menu]
|
||||
@@ -43,6 +42,7 @@ class IssuesController < ApplicationController
|
||||
helper :sort
|
||||
include SortHelper
|
||||
include IssuesHelper
|
||||
helper :timelog
|
||||
|
||||
def index
|
||||
sort_init "#{Issue.table_name}.id", "desc"
|
||||
@@ -65,7 +65,7 @@ class IssuesController < ApplicationController
|
||||
:offset => @issue_pages.current.offset
|
||||
respond_to do |format|
|
||||
format.html { render :template => 'issues/index.rhtml', :layout => !request.xhr? }
|
||||
format.atom { render_feed(@issues, :title => l(:label_issue_plural)) }
|
||||
format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
|
||||
format.csv { send_data(issues_to_csv(@issues, @project).read, :type => 'text/csv; header=present', :filename => 'export.csv') }
|
||||
format.pdf { send_data(render(:template => 'issues/index.rfpdf', :layout => false), :type => 'application/pdf', :filename => 'export.pdf') }
|
||||
end
|
||||
@@ -94,14 +94,13 @@ class IssuesController < ApplicationController
|
||||
end
|
||||
|
||||
def show
|
||||
@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) }
|
||||
@journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC")
|
||||
@journals.each_with_index {|j,i| j.indice = i+1}
|
||||
@journals.reverse! if User.current.wants_comments_in_reverse_order?
|
||||
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
|
||||
@edit_allowed = User.current.allowed_to?(:edit_issues, @project)
|
||||
@activities = Enumeration::get_values('ACTI')
|
||||
@priorities = Enumeration::get_values('IPRI')
|
||||
@time_entry = TimeEntry.new
|
||||
respond_to do |format|
|
||||
format.html { render :template => 'issues/show.rhtml' }
|
||||
format.atom { render :action => 'changes', :layout => false, :content_type => 'application/atom+xml' }
|
||||
@@ -112,15 +111,18 @@ class IssuesController < ApplicationController
|
||||
# Add a new issue
|
||||
# The new issue will be created from an existing one if copy_from parameter is given
|
||||
def new
|
||||
@issue = params[:copy_from] ? Issue.new.copy_from(params[:copy_from]) : Issue.new(params[:issue])
|
||||
@issue = Issue.new
|
||||
@issue.copy_from(params[:copy_from]) if params[:copy_from]
|
||||
@issue.project = @project
|
||||
@issue.author = User.current
|
||||
@issue.tracker ||= @project.trackers.find(params[:tracker_id] ? params[:tracker_id] : :first)
|
||||
# Tracker must be set before custom field values
|
||||
@issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first)
|
||||
if @issue.tracker.nil?
|
||||
flash.now[:error] = 'No tracker is associated to this project. Please check the Project settings.'
|
||||
render :nothing => true, :layout => true
|
||||
return
|
||||
end
|
||||
@issue.attributes = params[:issue]
|
||||
@issue.author = User.current
|
||||
|
||||
default_status = IssueStatus.default
|
||||
unless default_status
|
||||
@@ -133,22 +135,15 @@ class IssuesController < ApplicationController
|
||||
|
||||
if request.get? || request.xhr?
|
||||
@issue.start_date ||= Date.today
|
||||
@custom_values = @issue.custom_values.empty? ?
|
||||
@project.custom_fields_for_issues(@issue.tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) } :
|
||||
@issue.custom_values
|
||||
else
|
||||
requested_status = (params[:issue] && params[:issue][:status_id] ? IssueStatus.find_by_id(params[:issue][:status_id]) : default_status)
|
||||
# Check that the user is allowed to apply the requested status
|
||||
@issue.status = (@allowed_statuses.include? requested_status) ? requested_status : default_status
|
||||
@custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| CustomValue.new(:custom_field => x,
|
||||
:customized => @issue,
|
||||
:value => (params[:custom_fields] ? params[:custom_fields][x.id.to_s] : nil)) }
|
||||
@issue.custom_values = @custom_values
|
||||
if @issue.save
|
||||
attach_files(@issue, params[:attachments])
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
Mailer.deliver_issue_add(@issue) if Setting.notified_events.include?('issue_added')
|
||||
redirect_to :controller => 'issues', :action => 'show', :id => @issue, :project_id => @project
|
||||
redirect_to :controller => 'issues', :action => 'show', :id => @issue
|
||||
return
|
||||
end
|
||||
end
|
||||
@@ -162,10 +157,9 @@ class IssuesController < ApplicationController
|
||||
|
||||
def edit
|
||||
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
|
||||
@activities = Enumeration::get_values('ACTI')
|
||||
@priorities = Enumeration::get_values('IPRI')
|
||||
@custom_values = []
|
||||
@edit_allowed = User.current.allowed_to?(:edit_issues, @project)
|
||||
@time_entry = TimeEntry.new
|
||||
|
||||
@notes = params[:notes]
|
||||
journal = @issue.init_journal(User.current, @notes)
|
||||
@@ -177,21 +171,14 @@ class IssuesController < ApplicationController
|
||||
@issue.attributes = attrs
|
||||
end
|
||||
|
||||
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
|
||||
# Update custom fields if user has :edit permission
|
||||
if @edit_allowed && params[:custom_fields]
|
||||
@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
|
||||
end
|
||||
if request.post?
|
||||
@time_entry = TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => Date.today)
|
||||
@time_entry.attributes = params[:time_entry]
|
||||
attachments = attach_files(@issue, params[:attachments])
|
||||
attachments.each {|a| journal.details << JournalDetail.new(:property => 'attachment', :prop_key => a.id, :value => a.filename)}
|
||||
if @issue.save
|
||||
if (@time_entry.hours.nil? || @time_entry.valid?) && @issue.save
|
||||
# Log spend time
|
||||
if current_role.allowed_to?(:log_time)
|
||||
@time_entry = TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => Date.today)
|
||||
@time_entry.attributes = params[:time_entry]
|
||||
@time_entry.save
|
||||
end
|
||||
if !journal.new_record?
|
||||
@@ -207,6 +194,26 @@ class IssuesController < ApplicationController
|
||||
flash.now[:error] = l(:notice_locking_conflict)
|
||||
end
|
||||
|
||||
def reply
|
||||
journal = Journal.find(params[:journal_id]) if params[:journal_id]
|
||||
if journal
|
||||
user = journal.user
|
||||
text = journal.notes
|
||||
else
|
||||
user = @issue.author
|
||||
text = @issue.description
|
||||
end
|
||||
content = "#{ll(Setting.default_language, :text_user_wrote, user)}\\n> "
|
||||
content << text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]').gsub('"', '\"').gsub(/(\r?\n|\r\n?)/, "\\n> ") + "\\n\\n"
|
||||
render(:update) { |page|
|
||||
page.<< "$('notes').value = \"#{content}\";"
|
||||
page.show 'update'
|
||||
page << "Form.Element.focus('notes');"
|
||||
page << "Element.scrollTo('update');"
|
||||
page << "$('notes').scrollTop = $('notes').scrollHeight - $('notes').clientHeight;"
|
||||
}
|
||||
end
|
||||
|
||||
# Bulk edit a set of issues
|
||||
def bulk_edit
|
||||
if request.post?
|
||||
@@ -240,7 +247,7 @@ class IssuesController < ApplicationController
|
||||
else
|
||||
flash[:error] = l(:notice_failed_to_save_issues, unsaved_issue_ids.size, @issues.size, '#' + unsaved_issue_ids.join(', #'))
|
||||
end
|
||||
redirect_to :controller => 'issues', :action => 'index', :project_id => @project
|
||||
redirect_to(params[:back_to] || {:controller => 'issues', :action => 'index', :project_id => @project})
|
||||
return
|
||||
end
|
||||
# Find potential statuses the user could be allowed to switch issues to
|
||||
@@ -264,6 +271,7 @@ class IssuesController < ApplicationController
|
||||
new_tracker = params[:new_tracker_id].blank? ? nil : @target_project.trackers.find_by_id(params[:new_tracker_id])
|
||||
unsaved_issue_ids = []
|
||||
@issues.each do |issue|
|
||||
issue.init_journal(User.current)
|
||||
unsaved_issue_ids << issue.id unless issue.move_to(@target_project, new_tracker)
|
||||
end
|
||||
if unsaved_issue_ids.empty?
|
||||
@@ -318,19 +326,22 @@ class IssuesController < ApplicationController
|
||||
if (@issues.size == 1)
|
||||
@issue = @issues.first
|
||||
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
|
||||
@assignables = @issue.assignable_users
|
||||
@assignables << @issue.assigned_to if @issue.assigned_to && !@assignables.include?(@issue.assigned_to)
|
||||
end
|
||||
projects = @issues.collect(&:project).compact.uniq
|
||||
@project = projects.first if projects.size == 1
|
||||
|
||||
@can = {:edit => (@project && User.current.allowed_to?(:edit_issues, @project)),
|
||||
:update => (@issue && (User.current.allowed_to?(:edit_issues, @project) || (User.current.allowed_to?(:change_status, @project) && !@allowed_statuses.empty?))),
|
||||
:log_time => (@project && User.current.allowed_to?(:log_time, @project)),
|
||||
:update => (@project && (User.current.allowed_to?(:edit_issues, @project) || (User.current.allowed_to?(:change_status, @project) && @allowed_statuses && !@allowed_statuses.empty?))),
|
||||
:move => (@project && User.current.allowed_to?(:move_issues, @project)),
|
||||
:copy => (@issue && @project.trackers.include?(@issue.tracker) && User.current.allowed_to?(:add_issues, @project)),
|
||||
:delete => (@project && User.current.allowed_to?(:delete_issues, @project))
|
||||
}
|
||||
|
||||
if @project
|
||||
@assignables = @project.assignable_users
|
||||
@assignables << @issue.assigned_to if @issue && @issue.assigned_to && !@assignables.include?(@issue.assigned_to)
|
||||
end
|
||||
|
||||
@priorities = Enumeration.get_values('IPRI').reverse
|
||||
@statuses = IssueStatus.find(:all, :order => 'position')
|
||||
@back = request.env['HTTP_REFERER']
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class JournalsController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :find_journal
|
||||
|
||||
def edit
|
||||
|
||||
44
groups/app/controllers/mail_handler_controller.rb
Normal file
44
groups/app/controllers/mail_handler_controller.rb
Normal file
@@ -0,0 +1,44 @@
|
||||
# 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
|
||||
# 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 MailHandlerController < ActionController::Base
|
||||
before_filter :check_credential
|
||||
|
||||
verify :method => :post,
|
||||
:only => :index,
|
||||
:render => { :nothing => true, :status => 405 }
|
||||
|
||||
# Submits an incoming email to MailHandler
|
||||
def index
|
||||
options = params.dup
|
||||
email = options.delete(:email)
|
||||
if MailHandler.receive(email, options)
|
||||
render :nothing => true, :status => :created
|
||||
else
|
||||
render :nothing => true, :status => :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_credential
|
||||
User.current = nil
|
||||
unless Setting.mail_handler_api_enabled? && params[:key] == Setting.mail_handler_api_key
|
||||
render :nothing => true, :status => 403
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -16,7 +16,6 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class MembersController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :find_member, :except => :new
|
||||
before_filter :find_project, :only => :new
|
||||
before_filter :authorize
|
||||
|
||||
@@ -16,14 +16,15 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class MessagesController < ApplicationController
|
||||
layout 'base'
|
||||
menu_item :boards
|
||||
before_filter :find_board, :only => [:new, :preview]
|
||||
before_filter :find_message, :except => [:new, :preview]
|
||||
before_filter :authorize, :except => :preview
|
||||
|
||||
verify :method => :post, :only => [ :reply, :destroy ], :redirect_to => { :action => :show }
|
||||
verify :xhr => true, :only => :quote
|
||||
|
||||
|
||||
helper :attachments
|
||||
include AttachmentsHelper
|
||||
|
||||
@@ -83,6 +84,20 @@ class MessagesController < ApplicationController
|
||||
{ :action => 'show', :id => @message.parent }
|
||||
end
|
||||
|
||||
def quote
|
||||
user = @message.author
|
||||
text = @message.content
|
||||
content = "#{ll(Setting.default_language, :text_user_wrote, user)}\\n> "
|
||||
content << text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]').gsub('"', '\"').gsub(/(\r?\n|\r\n?)/, "\\n> ") + "\\n\\n"
|
||||
render(:update) { |page|
|
||||
page.<< "$('message_content').value = \"#{content}\";"
|
||||
page.show 'reply'
|
||||
page << "Form.Element.focus('message_content');"
|
||||
page << "Element.scrollTo('reply');"
|
||||
page << "$('message_content').scrollTop = $('message_content').scrollHeight - $('message_content').clientHeight;"
|
||||
}
|
||||
end
|
||||
|
||||
def preview
|
||||
message = @board.messages.find_by_id(params[:id])
|
||||
@attachements = message.attachments if message
|
||||
|
||||
@@ -16,11 +16,10 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class MyController < ApplicationController
|
||||
helper :issues
|
||||
|
||||
layout 'base'
|
||||
before_filter :require_login
|
||||
|
||||
helper :issues
|
||||
|
||||
BLOCKS = { 'issuesassignedtome' => :label_assigned_to_me_issues,
|
||||
'issuesreportedbyme' => :label_reported_issues,
|
||||
'issueswatched' => :label_watched_issues,
|
||||
|
||||
@@ -16,9 +16,8 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class NewsController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :find_news, :except => [:new, :index, :preview]
|
||||
before_filter :find_project, :only => :new
|
||||
before_filter :find_project, :only => [:new, :preview]
|
||||
before_filter :authorize, :except => [:index, :preview]
|
||||
before_filter :find_optional_project, :only => :index
|
||||
accept_key_auth :index
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class ProjectsController < ApplicationController
|
||||
layout 'base'
|
||||
menu_item :overview
|
||||
menu_item :activity, :only => :activity
|
||||
menu_item :roadmap, :only => :roadmap
|
||||
@@ -44,37 +43,36 @@ class ProjectsController < ApplicationController
|
||||
include RepositoriesHelper
|
||||
include ProjectsHelper
|
||||
|
||||
def index
|
||||
list
|
||||
render :action => 'list' unless request.xhr?
|
||||
end
|
||||
|
||||
# Lists visible projects
|
||||
def list
|
||||
def index
|
||||
projects = Project.find :all,
|
||||
:conditions => Project.visible_by(User.current),
|
||||
:include => :parent
|
||||
@project_tree = projects.group_by {|p| p.parent || p}
|
||||
@project_tree.each_key {|p| @project_tree[p] -= [p]}
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
@project_tree = projects.group_by {|p| p.parent || p}
|
||||
@project_tree.keys.each {|p| @project_tree[p] -= [p]}
|
||||
}
|
||||
format.atom {
|
||||
render_feed(projects.sort_by(&:created_on).reverse.slice(0, Setting.feeds_limit.to_i),
|
||||
:title => "#{Setting.app_title}: #{l(:label_project_latest)}")
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
# Add a new project
|
||||
def add
|
||||
@custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
|
||||
@issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
|
||||
@trackers = Tracker.all
|
||||
@root_projects = Project.find(:all,
|
||||
:conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}",
|
||||
:order => 'name')
|
||||
@project = Project.new(params[:project])
|
||||
if request.get?
|
||||
@custom_values = ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| CustomValue.new(:custom_field => x, :customized => @project) }
|
||||
@project.trackers = Tracker.all
|
||||
@project.is_public = Setting.default_projects_public?
|
||||
@project.enabled_module_names = Redmine::AccessControl.available_project_modules
|
||||
else
|
||||
@project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids]
|
||||
@custom_values = ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => (params[:custom_fields] ? params["custom_fields"][x.id.to_s] : nil)) }
|
||||
@project.custom_values = @custom_values
|
||||
@project.enabled_module_names = params[:enabled_modules]
|
||||
if @project.save
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
@@ -85,8 +83,7 @@ class ProjectsController < ApplicationController
|
||||
|
||||
# Show @project
|
||||
def show
|
||||
@custom_values = @project.custom_values.find(:all, :include => :custom_field, :order => "#{CustomField.table_name}.position")
|
||||
@subprojects = @project.active_children
|
||||
@subprojects = @project.children.find(:all, :conditions => Project.visible_by(User.current))
|
||||
@news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC")
|
||||
@trackers = @project.rolled_up_trackers
|
||||
|
||||
@@ -111,11 +108,10 @@ class ProjectsController < ApplicationController
|
||||
@root_projects = Project.find(:all,
|
||||
:conditions => ["parent_id IS NULL AND status = #{Project::STATUS_ACTIVE} AND id <> ?", @project.id],
|
||||
:order => 'name')
|
||||
@custom_fields = IssueCustomField.find(:all)
|
||||
@issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
|
||||
@issue_category ||= IssueCategory.new
|
||||
@member ||= @project.members.new
|
||||
@trackers = Tracker.all
|
||||
@custom_values ||= ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
|
||||
@repository ||= @project.repository
|
||||
@wiki ||= @project.wiki
|
||||
end
|
||||
@@ -123,10 +119,6 @@ class ProjectsController < ApplicationController
|
||||
# Edit @project
|
||||
def edit
|
||||
if request.post?
|
||||
if params[:custom_fields]
|
||||
@custom_values = ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
|
||||
@project.custom_values = @custom_values
|
||||
end
|
||||
@project.attributes = params[:project]
|
||||
if @project.save
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
@@ -232,91 +224,23 @@ class ProjectsController < ApplicationController
|
||||
|
||||
@date_to ||= Date.today + 1
|
||||
@date_from = @date_to - @days
|
||||
@with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
|
||||
|
||||
@event_types = %w(issues news files documents changesets wiki_pages messages)
|
||||
if @project
|
||||
@event_types.delete('wiki_pages') unless @project.wiki
|
||||
@event_types.delete('changesets') unless @project.repository
|
||||
@event_types.delete('messages') unless @project.boards.any?
|
||||
# only show what the user is allowed to view
|
||||
@event_types = @event_types.select {|o| User.current.allowed_to?("view_#{o}".to_sym, @project)}
|
||||
@with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
|
||||
end
|
||||
@scope = @event_types.select {|t| params["show_#{t}"]}
|
||||
# default events if none is specified in parameters
|
||||
@scope = (@event_types - %w(wiki_pages messages))if @scope.empty?
|
||||
|
||||
@events = []
|
||||
|
||||
if @scope.include?('issues')
|
||||
cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_issues, :project => @project, :with_subprojects => @with_subprojects))
|
||||
cond.add(["#{Issue.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to])
|
||||
@events += Issue.find(:all, :include => [:project, :author, :tracker], :conditions => cond.conditions)
|
||||
|
||||
cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_issues, :project => @project, :with_subprojects => @with_subprojects))
|
||||
cond.add(["#{Journal.table_name}.journalized_type = 'Issue' AND #{JournalDetail.table_name}.prop_key = 'status_id' AND #{Journal.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to])
|
||||
@events += Journal.find(:all, :include => [{:issue => :project}, :details, :user], :conditions => cond.conditions)
|
||||
end
|
||||
|
||||
if @scope.include?('news')
|
||||
cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_news, :project => @project, :with_subprojects => @with_subprojects))
|
||||
cond.add(["#{News.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to])
|
||||
@events += News.find(:all, :include => [:project, :author], :conditions => cond.conditions)
|
||||
end
|
||||
|
||||
if @scope.include?('files')
|
||||
cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_files, :project => @project, :with_subprojects => @with_subprojects))
|
||||
cond.add(["#{Attachment.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to])
|
||||
@events += Attachment.find(:all, :select => "#{Attachment.table_name}.*",
|
||||
:joins => "LEFT JOIN #{Version.table_name} ON #{Attachment.table_name}.container_type='Version' AND #{Version.table_name}.id = #{Attachment.table_name}.container_id " +
|
||||
"LEFT JOIN #{Project.table_name} ON #{Version.table_name}.project_id = #{Project.table_name}.id",
|
||||
:conditions => cond.conditions)
|
||||
end
|
||||
|
||||
if @scope.include?('documents')
|
||||
cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_documents, :project => @project, :with_subprojects => @with_subprojects))
|
||||
cond.add(["#{Document.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to])
|
||||
@events += Document.find(:all, :include => :project, :conditions => cond.conditions)
|
||||
|
||||
cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_documents, :project => @project, :with_subprojects => @with_subprojects))
|
||||
cond.add(["#{Attachment.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to])
|
||||
@events += Attachment.find(:all, :select => "#{Attachment.table_name}.*",
|
||||
:joins => "LEFT JOIN #{Document.table_name} ON #{Attachment.table_name}.container_type='Document' AND #{Document.table_name}.id = #{Attachment.table_name}.container_id " +
|
||||
"LEFT JOIN #{Project.table_name} ON #{Document.table_name}.project_id = #{Project.table_name}.id",
|
||||
:conditions => cond.conditions)
|
||||
end
|
||||
|
||||
if @scope.include?('wiki_pages')
|
||||
select = "#{WikiContent.versioned_table_name}.updated_on, #{WikiContent.versioned_table_name}.comments, " +
|
||||
"#{WikiContent.versioned_table_name}.#{WikiContent.version_column}, #{WikiPage.table_name}.title, " +
|
||||
"#{WikiContent.versioned_table_name}.page_id, #{WikiContent.versioned_table_name}.author_id, " +
|
||||
"#{WikiContent.versioned_table_name}.id"
|
||||
joins = "LEFT JOIN #{WikiPage.table_name} ON #{WikiPage.table_name}.id = #{WikiContent.versioned_table_name}.page_id " +
|
||||
"LEFT JOIN #{Wiki.table_name} ON #{Wiki.table_name}.id = #{WikiPage.table_name}.wiki_id " +
|
||||
"LEFT JOIN #{Project.table_name} ON #{Project.table_name}.id = #{Wiki.table_name}.project_id"
|
||||
@activity = Redmine::Activity::Fetcher.new(User.current, :project => @project, :with_subprojects => @with_subprojects)
|
||||
@activity.scope_select {|t| !params["show_#{t}"].nil?}
|
||||
@activity.default_scope! if @activity.scope.empty?
|
||||
|
||||
cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_wiki_pages, :project => @project, :with_subprojects => @with_subprojects))
|
||||
cond.add(["#{WikiContent.versioned_table_name}.updated_on BETWEEN ? AND ?", @date_from, @date_to])
|
||||
@events += WikiContent.versioned_class.find(:all, :select => select, :joins => joins, :conditions => cond.conditions)
|
||||
end
|
||||
|
||||
if @scope.include?('changesets')
|
||||
cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_changesets, :project => @project, :with_subprojects => @with_subprojects))
|
||||
cond.add(["#{Changeset.table_name}.committed_on BETWEEN ? AND ?", @date_from, @date_to])
|
||||
@events += Changeset.find(:all, :include => {:repository => :project}, :conditions => cond.conditions)
|
||||
end
|
||||
|
||||
if @scope.include?('messages')
|
||||
cond = ARCondition.new(Project.allowed_to_condition(User.current, :view_messages, :project => @project, :with_subprojects => @with_subprojects))
|
||||
cond.add(["#{Message.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to])
|
||||
@events += Message.find(:all, :include => [{:board => :project}, :author], :conditions => cond.conditions)
|
||||
end
|
||||
|
||||
@events_by_day = @events.group_by(&:event_date)
|
||||
events = @activity.events(@date_from, @date_to)
|
||||
|
||||
respond_to do |format|
|
||||
format.html { render :layout => false if request.xhr? }
|
||||
format.atom { render_feed(@events, :title => "#{@project || Setting.app_title}: #{l(:label_activity)}") }
|
||||
format.html {
|
||||
@events_by_day = events.group_by(&:event_date)
|
||||
render :layout => false if request.xhr?
|
||||
}
|
||||
format.atom {
|
||||
title = (@activity.scope.size == 1) ? l("label_#{@activity.scope.first.singularize}_plural") : l(:label_activity)
|
||||
render_feed(events, :title => "#{@project || Setting.app_title}: #{title}")
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -381,11 +305,18 @@ class ProjectsController < ApplicationController
|
||||
|
||||
@events = []
|
||||
@project.issues_with_subprojects(@with_subprojects) do
|
||||
# Issues that have start and due dates
|
||||
@events += Issue.find(:all,
|
||||
:order => "start_date, due_date",
|
||||
:include => [:tracker, :status, :assigned_to, :priority, :project],
|
||||
:conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_date<? and due_date>?)) and start_date is not null and due_date is not null and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')}))", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to]
|
||||
) unless @selected_tracker_ids.empty?
|
||||
# Issues that don't have a due date but that are assigned to a version with a date
|
||||
@events += Issue.find(:all,
|
||||
:order => "start_date, effective_date",
|
||||
:include => [:tracker, :status, :assigned_to, :priority, :project, :fixed_version],
|
||||
:conditions => ["(((start_date>=? and start_date<=?) or (effective_date>=? and effective_date<=?) or (start_date<? and effective_date>?)) and start_date is not null and due_date is null and effective_date is not null and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')}))", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to]
|
||||
) unless @selected_tracker_ids.empty?
|
||||
@events += Version.find(:all, :include => :project,
|
||||
:conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to])
|
||||
end
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class QueriesController < ApplicationController
|
||||
layout 'base'
|
||||
menu_item :issues
|
||||
before_filter :find_query, :except => :new
|
||||
before_filter :find_optional_project, :only => :new
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class ReportsController < ApplicationController
|
||||
layout 'base'
|
||||
menu_item :issues
|
||||
before_filter :find_project, :authorize
|
||||
|
||||
|
||||
@@ -23,20 +23,21 @@ class ChangesetNotFound < Exception; end
|
||||
class InvalidRevisionParam < Exception; end
|
||||
|
||||
class RepositoriesController < ApplicationController
|
||||
layout 'base'
|
||||
menu_item :repository
|
||||
before_filter :find_repository, :except => :edit
|
||||
before_filter :find_project, :only => :edit
|
||||
before_filter :authorize
|
||||
accept_key_auth :revisions
|
||||
|
||||
rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed
|
||||
|
||||
def edit
|
||||
@repository = @project.repository
|
||||
if !@repository
|
||||
@repository = Repository.factory(params[:repository_scm])
|
||||
@repository.project = @project
|
||||
@repository.project = @project if @repository
|
||||
end
|
||||
if request.post?
|
||||
if request.post? && @repository
|
||||
@repository.attributes = params[:repository]
|
||||
@repository.save
|
||||
end
|
||||
@@ -56,8 +57,6 @@ class RepositoriesController < ApplicationController
|
||||
# latest changesets
|
||||
@changesets = @repository.changesets.find(:all, :limit => 10, :order => "committed_on DESC")
|
||||
show_error_not_found unless @entries || @changesets.any?
|
||||
rescue Redmine::Scm::Adapters::CommandFailed => e
|
||||
show_error_command_failed(e.message)
|
||||
end
|
||||
|
||||
def browse
|
||||
@@ -66,18 +65,16 @@ class RepositoriesController < ApplicationController
|
||||
@entries ? render(:partial => 'dir_list_content') : render(:nothing => true)
|
||||
else
|
||||
show_error_not_found and return unless @entries
|
||||
@properties = @repository.properties(@path, @rev)
|
||||
render :action => 'browse'
|
||||
end
|
||||
rescue Redmine::Scm::Adapters::CommandFailed => e
|
||||
show_error_command_failed(e.message)
|
||||
end
|
||||
|
||||
def changes
|
||||
@entry = @repository.scm.entry(@path, @rev)
|
||||
@entry = @repository.entry(@path, @rev)
|
||||
show_error_not_found and return unless @entry
|
||||
@changesets = @repository.changesets_for_path(@path)
|
||||
rescue Redmine::Scm::Adapters::CommandFailed => e
|
||||
show_error_command_failed(e.message)
|
||||
@properties = @repository.properties(@path, @rev)
|
||||
end
|
||||
|
||||
def revisions
|
||||
@@ -96,13 +93,13 @@ class RepositoriesController < ApplicationController
|
||||
end
|
||||
|
||||
def entry
|
||||
@entry = @repository.scm.entry(@path, @rev)
|
||||
@entry = @repository.entry(@path, @rev)
|
||||
show_error_not_found and return unless @entry
|
||||
|
||||
# If the entry is a dir, show the browser
|
||||
browse and return if @entry.is_dir?
|
||||
|
||||
@content = @repository.scm.cat(@path, @rev)
|
||||
@content = @repository.cat(@path, @rev)
|
||||
show_error_not_found and return unless @content
|
||||
if 'raw' == params[:format] || @content.is_binary_data?
|
||||
# Force the download if it's a binary file
|
||||
@@ -110,16 +107,12 @@ class RepositoriesController < ApplicationController
|
||||
else
|
||||
# Prevent empty lines when displaying a file with Windows style eol
|
||||
@content.gsub!("\r\n", "\n")
|
||||
end
|
||||
rescue Redmine::Scm::Adapters::CommandFailed => e
|
||||
show_error_command_failed(e.message)
|
||||
end
|
||||
end
|
||||
|
||||
def annotate
|
||||
@annotate = @repository.scm.annotate(@path, @rev)
|
||||
render_error l(:error_scm_annotate) and return if @annotate.nil? || @annotate.empty?
|
||||
rescue Redmine::Scm::Adapters::CommandFailed => e
|
||||
show_error_command_failed(e.message)
|
||||
end
|
||||
|
||||
def revision
|
||||
@@ -137,27 +130,33 @@ class RepositoriesController < ApplicationController
|
||||
end
|
||||
rescue ChangesetNotFound
|
||||
show_error_not_found
|
||||
rescue Redmine::Scm::Adapters::CommandFailed => e
|
||||
show_error_command_failed(e.message)
|
||||
end
|
||||
|
||||
def diff
|
||||
@diff_type = params[:type] || User.current.pref[:diff_type] || 'inline'
|
||||
@diff_type = 'inline' unless %w(inline sbs).include?(@diff_type)
|
||||
|
||||
# Save diff type as user preference
|
||||
if User.current.logged? && @diff_type != User.current.pref[:diff_type]
|
||||
User.current.pref[:diff_type] = @diff_type
|
||||
User.current.preference.save
|
||||
if params[:format] == 'diff'
|
||||
@diff = @repository.diff(@path, @rev, @rev_to)
|
||||
show_error_not_found and return unless @diff
|
||||
filename = "changeset_r#{@rev}"
|
||||
filename << "_r#{@rev_to}" if @rev_to
|
||||
send_data @diff.join, :filename => "#{filename}.diff",
|
||||
:type => 'text/x-patch',
|
||||
:disposition => 'attachment'
|
||||
else
|
||||
@diff_type = params[:type] || User.current.pref[:diff_type] || 'inline'
|
||||
@diff_type = 'inline' unless %w(inline sbs).include?(@diff_type)
|
||||
|
||||
# Save diff type as user preference
|
||||
if User.current.logged? && @diff_type != User.current.pref[:diff_type]
|
||||
User.current.pref[:diff_type] = @diff_type
|
||||
User.current.preference.save
|
||||
end
|
||||
|
||||
@cache_key = "repositories/diff/#{@repository.id}/" + Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}")
|
||||
unless read_fragment(@cache_key)
|
||||
@diff = @repository.diff(@path, @rev, @rev_to)
|
||||
show_error_not_found unless @diff
|
||||
end
|
||||
end
|
||||
|
||||
@cache_key = "repositories/diff/#{@repository.id}/" + Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}")
|
||||
unless read_fragment(@cache_key)
|
||||
@diff = @repository.diff(@path, @rev, @rev_to, @diff_type)
|
||||
show_error_not_found unless @diff
|
||||
end
|
||||
rescue Redmine::Scm::Adapters::CommandFailed => e
|
||||
show_error_command_failed(e.message)
|
||||
end
|
||||
|
||||
def stats
|
||||
@@ -207,8 +206,9 @@ private
|
||||
render_error l(:error_scm_not_found)
|
||||
end
|
||||
|
||||
def show_error_command_failed(msg)
|
||||
render_error l(:error_scm_command_failed, msg)
|
||||
# Handler for Redmine::Scm::Adapters::CommandFailed exception
|
||||
def show_error_command_failed(exception)
|
||||
render_error l(:error_scm_command_failed, exception.message)
|
||||
end
|
||||
|
||||
def graph_commits_per_month(repository)
|
||||
@@ -229,7 +229,7 @@ private
|
||||
|
||||
graph = SVG::Graph::Bar.new(
|
||||
:height => 300,
|
||||
:width => 500,
|
||||
:width => 800,
|
||||
:fields => fields.reverse,
|
||||
:stack => :side,
|
||||
:scale_integers => true,
|
||||
@@ -271,8 +271,8 @@ private
|
||||
fields = fields.collect {|c| c.gsub(%r{<.+@.+>}, '') }
|
||||
|
||||
graph = SVG::Graph::BarHorizontal.new(
|
||||
:height => 300,
|
||||
:width => 500,
|
||||
:height => 400,
|
||||
:width => 800,
|
||||
:fields => fields,
|
||||
:stack => :side,
|
||||
:scale_integers => true,
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# 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 ],
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class SearchController < ApplicationController
|
||||
layout 'base'
|
||||
|
||||
before_filter :find_optional_project
|
||||
|
||||
helper :messages
|
||||
@@ -29,6 +27,18 @@ class SearchController < ApplicationController
|
||||
@all_words = params[:all_words] || (params[:submit] ? false : true)
|
||||
@titles_only = !params[:titles_only].nil?
|
||||
|
||||
projects_to_search =
|
||||
case params[:scope]
|
||||
when 'all'
|
||||
nil
|
||||
when 'my_projects'
|
||||
User.current.memberships.collect(&:project)
|
||||
when 'subprojects'
|
||||
@project ? ([ @project ] + @project.active_children) : nil
|
||||
else
|
||||
@project
|
||||
end
|
||||
|
||||
offset = nil
|
||||
begin; offset = params[:offset].to_time if params[:offset]; rescue; end
|
||||
|
||||
@@ -38,16 +48,16 @@ class SearchController < ApplicationController
|
||||
return
|
||||
end
|
||||
|
||||
if @project
|
||||
@object_types = %w(issues news documents changesets wiki_pages messages projects)
|
||||
if projects_to_search.is_a? Project
|
||||
# don't search projects
|
||||
@object_types.delete('projects')
|
||||
# only show what the user is allowed to view
|
||||
@object_types = %w(issues news documents changesets wiki_pages messages)
|
||||
@object_types = @object_types.select {|o| User.current.allowed_to?("view_#{o}".to_sym, @project)}
|
||||
|
||||
@scope = @object_types.select {|t| params[t]}
|
||||
@scope = @object_types if @scope.empty?
|
||||
else
|
||||
@object_types = @scope = %w(projects)
|
||||
@object_types = @object_types.select {|o| User.current.allowed_to?("view_#{o}".to_sym, projects_to_search)}
|
||||
end
|
||||
|
||||
@scope = @object_types.select {|t| params[t]}
|
||||
@scope = @object_types if @scope.empty?
|
||||
|
||||
# extract tokens from the question
|
||||
# eg. hello "bye bye" => ["hello", "bye bye"]
|
||||
@@ -60,39 +70,34 @@ class SearchController < ApplicationController
|
||||
@tokens.slice! 5..-1 if @tokens.size > 5
|
||||
# strings used in sql like statement
|
||||
like_tokens = @tokens.collect {|w| "%#{w.downcase}%"}
|
||||
|
||||
@results = []
|
||||
@results_by_type = Hash.new {|h,k| h[k] = 0}
|
||||
|
||||
limit = 10
|
||||
if @project
|
||||
@scope.each do |s|
|
||||
@results += s.singularize.camelcase.constantize.search(like_tokens, @project,
|
||||
:all_words => @all_words,
|
||||
:titles_only => @titles_only,
|
||||
:limit => (limit+1),
|
||||
:offset => offset,
|
||||
:before => params[:previous].nil?)
|
||||
end
|
||||
@results = @results.sort {|a,b| b.event_datetime <=> a.event_datetime}
|
||||
if params[:previous].nil?
|
||||
@pagination_previous_date = @results[0].event_datetime if offset && @results[0]
|
||||
if @results.size > limit
|
||||
@pagination_next_date = @results[limit-1].event_datetime
|
||||
@results = @results[0, limit]
|
||||
end
|
||||
else
|
||||
@pagination_next_date = @results[-1].event_datetime if offset && @results[-1]
|
||||
if @results.size > limit
|
||||
@pagination_previous_date = @results[-(limit)].event_datetime
|
||||
@results = @results[-(limit), limit]
|
||||
end
|
||||
@scope.each do |s|
|
||||
r, c = s.singularize.camelcase.constantize.search(like_tokens, projects_to_search,
|
||||
:all_words => @all_words,
|
||||
:titles_only => @titles_only,
|
||||
:limit => (limit+1),
|
||||
:offset => offset,
|
||||
:before => params[:previous].nil?)
|
||||
@results += r
|
||||
@results_by_type[s] += c
|
||||
end
|
||||
@results = @results.sort {|a,b| b.event_datetime <=> a.event_datetime}
|
||||
if params[:previous].nil?
|
||||
@pagination_previous_date = @results[0].event_datetime if offset && @results[0]
|
||||
if @results.size > limit
|
||||
@pagination_next_date = @results[limit-1].event_datetime
|
||||
@results = @results[0, limit]
|
||||
end
|
||||
else
|
||||
operator = @all_words ? ' AND ' : ' OR '
|
||||
@results += Project.find(:all,
|
||||
:limit => limit,
|
||||
:conditions => [ (["(#{Project.visible_by(User.current)}) AND (LOWER(name) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort]
|
||||
) if @scope.include? 'projects'
|
||||
# if only one project is found, user is redirected to its overview
|
||||
redirect_to :controller => 'projects', :action => 'show', :id => @results.first and return if @results.size == 1
|
||||
@pagination_next_date = @results[-1].event_datetime if offset && @results[-1]
|
||||
if @results.size > limit
|
||||
@pagination_previous_date = @results[-(limit)].event_datetime
|
||||
@results = @results[-(limit), limit]
|
||||
end
|
||||
end
|
||||
else
|
||||
@question = ""
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class SettingsController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :require_admin
|
||||
|
||||
def index
|
||||
@@ -39,6 +38,7 @@ class SettingsController < ApplicationController
|
||||
end
|
||||
@options = {}
|
||||
@options[:user_format] = User::USER_FORMATS.keys.collect {|f| [User.current.name(f), f.to_s] }
|
||||
@deliveries = ActionMailer::Base.perform_deliveries
|
||||
end
|
||||
|
||||
def plugin
|
||||
@@ -49,7 +49,7 @@ class SettingsController < ApplicationController
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to :action => 'plugin', :id => params[:id]
|
||||
end
|
||||
@partial = "../../vendor/plugins/#{plugin_id}/app/views/" + @plugin.settings[:partial]
|
||||
@partial = @plugin.settings[:partial]
|
||||
@settings = Setting["plugin_#{plugin_id}"]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class TimelogController < ApplicationController
|
||||
layout 'base'
|
||||
menu_item :issues
|
||||
before_filter :find_project, :authorize
|
||||
|
||||
@@ -54,8 +53,15 @@ class TimelogController < ApplicationController
|
||||
}
|
||||
|
||||
# Add list and boolean custom fields as available criterias
|
||||
@project.all_custom_fields.select {|cf| %w(list bool).include? cf.field_format }.each do |cf|
|
||||
@available_criterias["cf_#{cf.id}"] = {:sql => "(SELECT c.value FROM custom_values c WHERE c.custom_field_id = #{cf.id} AND c.customized_type = 'Issue' AND c.customized_id = issues.id)",
|
||||
@project.all_issue_custom_fields.select {|cf| %w(list bool).include? cf.field_format }.each do |cf|
|
||||
@available_criterias["cf_#{cf.id}"] = {:sql => "(SELECT c.value FROM #{CustomValue.table_name} c WHERE c.custom_field_id = #{cf.id} AND c.customized_type = 'Issue' AND c.customized_id = #{Issue.table_name}.id)",
|
||||
:format => cf.field_format,
|
||||
:label => cf.name}
|
||||
end
|
||||
|
||||
# Add list and boolean time entry custom fields
|
||||
TimeEntryCustomField.find(:all).select {|cf| %w(list bool).include? cf.field_format }.each do |cf|
|
||||
@available_criterias["cf_#{cf.id}"] = {:sql => "(SELECT c.value FROM #{CustomValue.table_name} c WHERE c.custom_field_id = #{cf.id} AND c.customized_type = 'TimeEntry' AND c.customized_id = #{TimeEntry.table_name}.id)",
|
||||
:format => cf.field_format,
|
||||
:label => cf.name}
|
||||
end
|
||||
@@ -154,6 +160,14 @@ class TimelogController < ApplicationController
|
||||
|
||||
render :layout => !request.xhr?
|
||||
}
|
||||
format.atom {
|
||||
entries = TimeEntry.find(:all,
|
||||
:include => [:project, :activity, :user, {:issue => :tracker}],
|
||||
:conditions => cond.conditions,
|
||||
:order => "#{TimeEntry.table_name}.created_on DESC",
|
||||
:limit => Setting.feeds_limit.to_i)
|
||||
render_feed(entries, :title => l(:label_spent_time))
|
||||
}
|
||||
format.csv {
|
||||
# Export all entries
|
||||
@entries = TimeEntry.find(:all,
|
||||
@@ -172,10 +186,9 @@ class TimelogController < ApplicationController
|
||||
@time_entry.attributes = params[:time_entry]
|
||||
if request.post? and @time_entry.save
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to(params[:back_url] || {:action => 'details', :project_id => @time_entry.project})
|
||||
redirect_to(params[:back_url].blank? ? {:action => 'details', :project_id => @time_entry.project} : params[:back_url])
|
||||
return
|
||||
end
|
||||
@activities = Enumeration::get_values('ACTI')
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class TrackersController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :require_admin
|
||||
|
||||
def index
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class UsersController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :require_admin
|
||||
|
||||
helper :sort
|
||||
@@ -53,15 +52,12 @@ class UsersController < ApplicationController
|
||||
def add
|
||||
if request.get?
|
||||
@user = User.new(:language => Setting.default_language)
|
||||
@custom_values = UserCustomField.find(:all, :order => "#{CustomField.table_name}.position").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
|
||||
@user.group_id = params[:user][:group_id]
|
||||
@custom_values = UserCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| CustomValue.new(:custom_field => x, :customized => @user, :value => (params[:custom_fields] ? params["custom_fields"][x.id.to_s] : nil)) }
|
||||
@user.custom_values = @custom_values
|
||||
if @user.save
|
||||
Mailer.deliver_account_information(@user, params[:password]) if params[:send_information]
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
@@ -74,17 +70,11 @@ class UsersController < ApplicationController
|
||||
|
||||
def edit
|
||||
@user = User.find(params[:id])
|
||||
if request.get?
|
||||
@custom_values = UserCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| @user.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
|
||||
else
|
||||
if request.post?
|
||||
@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
|
||||
@user.group_id = params[:user][:group_id] if params[:user][:group_id]
|
||||
if params[:custom_fields]
|
||||
@custom_values = UserCustomField.find(:all, :order => "#{CustomField.table_name}.position").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)
|
||||
# Give a string to redirect_to otherwise it would use status param as the response code
|
||||
@@ -96,16 +86,15 @@ class UsersController < ApplicationController
|
||||
@roles = Role.find_all_givable
|
||||
@projects = Project.find(:all, :order => 'name', :conditions => "status=#{Project::STATUS_ACTIVE}") - @user.projects
|
||||
@membership ||= Member.new
|
||||
@memberships = @user.memberships.select {|m| m.inherited_from.nil? }
|
||||
end
|
||||
|
||||
def edit_membership
|
||||
@user = User.find(params[:id])
|
||||
@membership = params[:membership_id] ? Member.find(params[:membership_id], :conditions => 'inherited_from IS NULL') : Member.new(:principal => @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
|
||||
@membership.save if request.post?
|
||||
redirect_to :action => 'edit', :id => @user, :tab => 'memberships'
|
||||
end
|
||||
|
||||
def destroy_membership
|
||||
@@ -113,6 +102,6 @@ class UsersController < ApplicationController
|
||||
if request.post? and Member.find(params[:membership_id], :conditions => 'inherited_from IS NULL').destroy
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
end
|
||||
redirect_to :action => 'edit', :id => @user and return
|
||||
redirect_to :action => 'edit', :id => @user, :tab => 'memberships'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class VersionsController < ApplicationController
|
||||
layout 'base'
|
||||
menu_item :roadmap
|
||||
before_filter :find_project, :authorize
|
||||
|
||||
@@ -37,15 +36,6 @@ class VersionsController < ApplicationController
|
||||
flash[:error] = "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 => filename_for_content_disposition(@attachment.filename),
|
||||
:type => @attachment.content_type
|
||||
rescue
|
||||
render_404
|
||||
end
|
||||
|
||||
def destroy_file
|
||||
@version.attachments.find(params[:attachment_id]).destroy
|
||||
|
||||
@@ -16,27 +16,38 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class WatchersController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :require_login, :find_project, :check_project_privacy
|
||||
before_filter :find_project
|
||||
before_filter :require_login, :check_project_privacy, :only => [:watch, :unwatch]
|
||||
before_filter :authorize, :only => :new
|
||||
|
||||
def add
|
||||
user = User.current
|
||||
@watched.add_watcher(user)
|
||||
respond_to do |format|
|
||||
format.html { render :text => 'Watcher added.', :layout => true }
|
||||
format.js { render(:update) {|page| page.replace_html 'watcher', watcher_link(@watched, user)} }
|
||||
end
|
||||
verify :method => :post,
|
||||
:only => [ :watch, :unwatch ],
|
||||
:render => { :nothing => true, :status => :method_not_allowed }
|
||||
|
||||
def watch
|
||||
set_watcher(User.current, true)
|
||||
end
|
||||
|
||||
def remove
|
||||
user = User.current
|
||||
@watched.remove_watcher(user)
|
||||
respond_to do |format|
|
||||
format.html { render :text => 'Watcher removed.', :layout => true }
|
||||
format.js { render(:update) {|page| page.replace_html 'watcher', watcher_link(@watched, user)} }
|
||||
end
|
||||
def unwatch
|
||||
set_watcher(User.current, false)
|
||||
end
|
||||
|
||||
|
||||
def new
|
||||
@watcher = Watcher.new(params[:watcher])
|
||||
@watcher.watchable = @watched
|
||||
@watcher.save if request.post?
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :back }
|
||||
format.js do
|
||||
render :update do |page|
|
||||
page.replace_html 'watchers', :partial => 'watchers/watchers', :locals => {:watched => @watched}
|
||||
end
|
||||
end
|
||||
end
|
||||
rescue ::ActionController::RedirectBackError
|
||||
render :text => 'Watcher added.', :layout => true
|
||||
end
|
||||
|
||||
private
|
||||
def find_project
|
||||
klass = Object.const_get(params[:object_type].camelcase)
|
||||
@@ -46,4 +57,14 @@ private
|
||||
rescue
|
||||
render_404
|
||||
end
|
||||
|
||||
def set_watcher(user, watching)
|
||||
@watched.set_watcher(user, watching)
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :back }
|
||||
format.js { render(:update) {|page| page.replace_html 'watcher', watcher_link(@watched, user)} }
|
||||
end
|
||||
rescue ::ActionController::RedirectBackError
|
||||
render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class WelcomeController < ApplicationController
|
||||
layout 'base'
|
||||
|
||||
def index
|
||||
@news = News.latest User.current
|
||||
|
||||
@@ -18,10 +18,9 @@
|
||||
require 'diff'
|
||||
|
||||
class WikiController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :find_wiki, :authorize
|
||||
|
||||
verify :method => :post, :only => [:destroy, :destroy_attachment], :redirect_to => { :action => :index }
|
||||
verify :method => :post, :only => [:destroy, :destroy_attachment, :protect], :redirect_to => { :action => :index }
|
||||
|
||||
helper :attachments
|
||||
include AttachmentsHelper
|
||||
@@ -48,12 +47,14 @@ class WikiController < ApplicationController
|
||||
send_data(@content.text, :type => 'text/plain', :filename => "#{@page.title}.txt")
|
||||
return
|
||||
end
|
||||
@editable = editable?
|
||||
render :action => 'show'
|
||||
end
|
||||
|
||||
# edit an existing page or a new one
|
||||
def edit
|
||||
@page = @wiki.find_or_new_page(params[:page])
|
||||
return render_403 unless editable?
|
||||
@page.content = WikiContent.new(:page => @page) if @page.new_record?
|
||||
|
||||
@content = @page.content_for_version(params[:version])
|
||||
@@ -82,7 +83,8 @@ class WikiController < ApplicationController
|
||||
|
||||
# rename a page
|
||||
def rename
|
||||
@page = @wiki.find_page(params[:page])
|
||||
@page = @wiki.find_page(params[:page])
|
||||
return render_403 unless editable?
|
||||
@page.redirect_existing_links = true
|
||||
# used to display the *original* title if some AR validation errors occur
|
||||
@original_title = @page.pretty_title
|
||||
@@ -92,6 +94,12 @@ class WikiController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def protect
|
||||
page = @wiki.find_page(params[:page])
|
||||
page.update_attribute :protected, params[:protected]
|
||||
redirect_to :action => 'index', :id => @project, :page => page.title
|
||||
end
|
||||
|
||||
# show page history
|
||||
def history
|
||||
@page = @wiki.find_page(params[:page])
|
||||
@@ -122,6 +130,7 @@ class WikiController < ApplicationController
|
||||
# remove a wiki page and its history
|
||||
def destroy
|
||||
@page = @wiki.find_page(params[:page])
|
||||
return render_403 unless editable?
|
||||
@page.destroy if @page
|
||||
redirect_to :action => 'special', :id => @project, :page => 'Page_index'
|
||||
end
|
||||
@@ -137,6 +146,7 @@ class WikiController < ApplicationController
|
||||
:joins => "LEFT JOIN #{WikiContent.table_name} ON #{WikiContent.table_name}.page_id = #{WikiPage.table_name}.id",
|
||||
:order => 'title'
|
||||
@pages_by_date = @pages.group_by {|p| p.updated_on.to_date}
|
||||
@pages_by_parent_id = @pages.group_by(&:parent_id)
|
||||
# export wiki to a single html file
|
||||
when 'export'
|
||||
@pages = @wiki.pages.find :all, :order => 'title'
|
||||
@@ -152,19 +162,26 @@ class WikiController < ApplicationController
|
||||
|
||||
def preview
|
||||
page = @wiki.find_page(params[:page])
|
||||
@attachements = page.attachments if page
|
||||
# page is nil when previewing a new page
|
||||
return render_403 unless page.nil? || editable?(page)
|
||||
if page
|
||||
@attachements = page.attachments
|
||||
@previewed = page.content
|
||||
end
|
||||
@text = params[:content][:text]
|
||||
render :partial => 'common/preview'
|
||||
end
|
||||
|
||||
def add_attachment
|
||||
@page = @wiki.find_page(params[:page])
|
||||
return render_403 unless editable?
|
||||
attach_files(@page, params[:attachments])
|
||||
redirect_to :action => 'index', :page => @page.title
|
||||
end
|
||||
|
||||
def destroy_attachment
|
||||
@page = @wiki.find_page(params[:page])
|
||||
return render_403 unless editable?
|
||||
@page.attachments.find(params[:attachment_id]).destroy
|
||||
redirect_to :action => 'index', :page => @page.title
|
||||
end
|
||||
@@ -178,4 +195,9 @@ private
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
# Returns true if the current user is allowed to edit the page, otherwise false
|
||||
def editable?(page = @page)
|
||||
page.editable_by?(User.current)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class WikisController < ApplicationController
|
||||
layout 'base'
|
||||
menu_item :settings
|
||||
before_filter :find_project, :authorize
|
||||
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require 'coderay'
|
||||
require 'coderay/helpers/file_type'
|
||||
|
||||
module ApplicationHelper
|
||||
include Redmine::WikiFormatting::Macros::Definitions
|
||||
|
||||
@@ -31,6 +34,12 @@ module ApplicationHelper
|
||||
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] || params[:controller], options[:action])
|
||||
end
|
||||
|
||||
# Display a link to remote if user is authorized
|
||||
def link_to_remote_if_authorized(name, options = {}, html_options = nil)
|
||||
url = options[:url] || {}
|
||||
link_to_remote(name, options, html_options) if authorize_for(url[:controller] || params[:controller], url[:action])
|
||||
end
|
||||
|
||||
# Display a link to user's account page
|
||||
def link_to_user(user)
|
||||
@@ -38,9 +47,23 @@ module ApplicationHelper
|
||||
end
|
||||
|
||||
def link_to_issue(issue, options={})
|
||||
options[:class] ||= ''
|
||||
options[:class] << ' issue'
|
||||
options[:class] << ' closed' if issue.closed?
|
||||
link_to "#{issue.tracker.name} ##{issue.id}", {:controller => "issues", :action => "show", :id => issue}, options
|
||||
end
|
||||
|
||||
# Generates a link to an attachment.
|
||||
# Options:
|
||||
# * :text - Link text (default to attachment filename)
|
||||
# * :download - Force download (default: false)
|
||||
def link_to_attachment(attachment, options={})
|
||||
text = options.delete(:text) || attachment.filename
|
||||
action = options.delete(:download) ? 'download' : 'show'
|
||||
|
||||
link_to(h(text), {:controller => 'attachments', :action => action, :id => attachment, :filename => attachment.filename }, options)
|
||||
end
|
||||
|
||||
def toggle_link(name, id, options={})
|
||||
onclick = "Element.toggle('#{id}'); "
|
||||
onclick << (options[:focus] ? "Form.Element.focus('#{options[:focus]}'); " : "this.blur(); ")
|
||||
@@ -48,14 +71,6 @@ module ApplicationHelper
|
||||
link_to(name, "#", :onclick => onclick)
|
||||
end
|
||||
|
||||
def show_and_goto_link(name, id, options={})
|
||||
onclick = "Element.show('#{id}'); "
|
||||
onclick << (options[:focus] ? "Form.Element.focus('#{options[:focus]}'); " : "this.blur(); ")
|
||||
onclick << "Element.scrollTo('#{id}'); "
|
||||
onclick << "return false;"
|
||||
link_to(name, "#", options.merge(:onclick => onclick))
|
||||
end
|
||||
|
||||
def image_to_function(name, function, html_options = {})
|
||||
html_options.symbolize_keys!
|
||||
tag(:input, html_options.merge({
|
||||
@@ -80,23 +95,25 @@ module ApplicationHelper
|
||||
return nil unless time
|
||||
time = time.to_time if time.is_a?(String)
|
||||
zone = User.current.time_zone
|
||||
if time.utc?
|
||||
local = zone ? zone.adjust(time) : time.getlocal
|
||||
else
|
||||
local = zone ? zone.adjust(time.getutc) : time
|
||||
end
|
||||
local = zone ? time.in_time_zone(zone) : (time.utc? ? time.utc_to_local : time)
|
||||
@date_format ||= (Setting.date_format.blank? || Setting.date_format.size < 2 ? l(:general_fmt_date) : Setting.date_format)
|
||||
@time_format ||= (Setting.time_format.blank? ? l(:general_fmt_time) : Setting.time_format)
|
||||
include_date ? local.strftime("#{@date_format} #{@time_format}") : local.strftime(@time_format)
|
||||
end
|
||||
|
||||
# Truncates and returns the string as a single line
|
||||
def truncate_single_line(string, *args)
|
||||
truncate(string, *args).gsub(%r{[\r\n]+}m, ' ')
|
||||
end
|
||||
|
||||
def html_hours(text)
|
||||
text.gsub(%r{(\d+)\.(\d+)}, '<span class="hours hours-int">\1</span><span class="hours hours-dec">.\2</span>')
|
||||
end
|
||||
|
||||
def authoring(created, author)
|
||||
time_tag = content_tag('acronym', distance_of_time_in_words(Time.now, created), :title => format_time(created))
|
||||
l(:label_added_time_by, author || 'Anonymous', time_tag)
|
||||
author_tag = (author.is_a?(User) && !author.anonymous?) ? link_to(h(author), :controller => 'account', :action => 'show', :id => author) : h(author || 'Anonymous')
|
||||
l(:label_added_time_by, author_tag, time_tag)
|
||||
end
|
||||
|
||||
def l_or_humanize(s)
|
||||
@@ -111,6 +128,15 @@ module ApplicationHelper
|
||||
l(:actionview_datehelper_select_month_names).split(',')[month-1]
|
||||
end
|
||||
|
||||
def syntax_highlight(name, content)
|
||||
type = CodeRay::FileType[name]
|
||||
type ? CodeRay.scan(content, type).html : h(content)
|
||||
end
|
||||
|
||||
def to_path_param(path)
|
||||
path.to_s.split(%r{[/\\]}).select {|p| !p.blank?}
|
||||
end
|
||||
|
||||
def pagination_links_full(paginator, count=nil, options={})
|
||||
page_param = options.delete(:page_param) || :page
|
||||
url_param = params.dup
|
||||
@@ -157,7 +183,8 @@ module ApplicationHelper
|
||||
end
|
||||
|
||||
def breadcrumb(*args)
|
||||
content_tag('p', args.join(' » ') + ' » ', :class => 'breadcrumb')
|
||||
elements = args.flatten
|
||||
elements.any? ? content_tag('p', args.join(' » ') + ' » ', :class => 'breadcrumb') : nil
|
||||
end
|
||||
|
||||
def html_title(*args)
|
||||
@@ -185,7 +212,7 @@ module ApplicationHelper
|
||||
options = args.last.is_a?(Hash) ? args.pop : {}
|
||||
case args.size
|
||||
when 1
|
||||
obj = nil
|
||||
obj = options[:object]
|
||||
text = args.shift
|
||||
when 2
|
||||
obj = args.shift
|
||||
@@ -225,12 +252,12 @@ module ApplicationHelper
|
||||
case options[:wiki_links]
|
||||
when :local
|
||||
# used for local links to html files
|
||||
format_wiki_link = Proc.new {|project, title| "#{title}.html" }
|
||||
format_wiki_link = Proc.new {|project, title, anchor| "#{title}.html" }
|
||||
when :anchor
|
||||
# used for single-file wiki export
|
||||
format_wiki_link = Proc.new {|project, title| "##{title}" }
|
||||
format_wiki_link = Proc.new {|project, title, anchor| "##{title}" }
|
||||
else
|
||||
format_wiki_link = Proc.new {|project, title| url_for(:only_path => only_path, :controller => 'wiki', :action => 'index', :id => project, :page => title) }
|
||||
format_wiki_link = Proc.new {|project, title, anchor| url_for(:only_path => only_path, :controller => 'wiki', :action => 'index', :id => project, :page => title, :anchor => anchor) }
|
||||
end
|
||||
|
||||
project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil)
|
||||
@@ -256,9 +283,14 @@ module ApplicationHelper
|
||||
end
|
||||
|
||||
if link_project && link_project.wiki
|
||||
# extract anchor
|
||||
anchor = nil
|
||||
if page =~ /^(.+?)\#(.+)$/
|
||||
page, anchor = $1, $2
|
||||
end
|
||||
# check if page exists
|
||||
wiki_page = link_project.wiki.find_page(page)
|
||||
link_to((title || page), format_wiki_link.call(link_project, Wiki.titleize(page)),
|
||||
link_to((title || page), format_wiki_link.call(link_project, Wiki.titleize(page), anchor),
|
||||
:class => ('wiki-page' + (wiki_page ? '' : ' new')))
|
||||
else
|
||||
# project or wiki doesn't exist
|
||||
@@ -293,7 +325,9 @@ module ApplicationHelper
|
||||
# source:some/file#L120 -> Link to line 120 of the file
|
||||
# source:some/file@52#L120 -> Link to line 120 of the file's revision 52
|
||||
# export:some/file -> Force the download of the file
|
||||
text = text.gsub(%r{([\s\(,-^])(!)?(attachment|document|version|commit|source|export)?((#|r)(\d+)|(:)([^"\s<>][^\s<>]*|"[^"]+"))(?=[[:punct:]]|\s|<|$)}) do |m|
|
||||
# Forum messages:
|
||||
# message#1218 -> Link to message with id 1218
|
||||
text = text.gsub(%r{([\s\(,\-\>]|^)(!)?(attachment|document|version|commit|source|export|message)?((#|r)(\d+)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]]\W)|\s|<|$)}) do |m|
|
||||
leading, esc, prefix, sep, oid = $1, $2, $3, $5 || $7, $6 || $8
|
||||
link = nil
|
||||
if esc.nil?
|
||||
@@ -301,7 +335,7 @@ module ApplicationHelper
|
||||
if project && (changeset = project.changesets.find_by_revision(oid))
|
||||
link = link_to("r#{oid}", {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => oid},
|
||||
:class => 'changeset',
|
||||
:title => truncate(changeset.comments, 100))
|
||||
:title => truncate_single_line(changeset.comments, 100))
|
||||
end
|
||||
elsif sep == '#'
|
||||
oid = oid.to_i
|
||||
@@ -323,6 +357,16 @@ module ApplicationHelper
|
||||
link = link_to h(version.name), {:only_path => only_path, :controller => 'versions', :action => 'show', :id => version},
|
||||
:class => 'version'
|
||||
end
|
||||
when 'message'
|
||||
if message = Message.find_by_id(oid, :include => [:parent, {:board => :project}], :conditions => Project.visible_by(User.current))
|
||||
link = link_to h(truncate(message.subject, 60)), {:only_path => only_path,
|
||||
:controller => 'messages',
|
||||
:action => 'show',
|
||||
:board_id => message.board,
|
||||
:id => message.root,
|
||||
:anchor => (message.parent ? "message-#{message.id}" : nil)},
|
||||
:class => 'message'
|
||||
end
|
||||
end
|
||||
elsif sep == ':'
|
||||
# removes the double quotes if any
|
||||
@@ -340,13 +384,16 @@ module ApplicationHelper
|
||||
end
|
||||
when 'commit'
|
||||
if project && (changeset = project.changesets.find(:first, :conditions => ["scmid LIKE ?", "#{name}%"]))
|
||||
link = link_to h("#{name}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => changeset.revision}, :class => 'changeset', :title => truncate(changeset.comments, 100)
|
||||
link = link_to h("#{name}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => changeset.revision},
|
||||
:class => 'changeset',
|
||||
:title => truncate_single_line(changeset.comments, 100)
|
||||
end
|
||||
when 'source', 'export'
|
||||
if project && project.repository
|
||||
name =~ %r{^[/\\]*(.*?)(@([0-9a-f]+))?(#(L\d+))?$}
|
||||
path, rev, anchor = $1, $3, $5
|
||||
link = link_to h("#{prefix}:#{name}"), {:controller => 'repositories', :action => 'entry', :id => project, :path => path,
|
||||
link = link_to h("#{prefix}:#{name}"), {:controller => 'repositories', :action => 'entry', :id => project,
|
||||
:path => to_path_param(path),
|
||||
:rev => rev,
|
||||
:anchor => anchor,
|
||||
:format => (prefix == 'export' ? 'raw' : nil)},
|
||||
@@ -428,7 +475,8 @@ module ApplicationHelper
|
||||
end
|
||||
|
||||
def back_url_hidden_field_tag
|
||||
hidden_field_tag 'back_url', (params[:back_url] || request.env['HTTP_REFERER'])
|
||||
back_url = params[:back_url] || request.env['HTTP_REFERER']
|
||||
hidden_field_tag('back_url', back_url) unless back_url.blank?
|
||||
end
|
||||
|
||||
def check_all_links(form_name)
|
||||
|
||||
@@ -22,4 +22,8 @@ module AttachmentsHelper
|
||||
render :partial => 'attachments/links', :locals => {:attachments => attachments, :options => options}
|
||||
end
|
||||
end
|
||||
|
||||
def to_utf8(str)
|
||||
str
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,6 +19,7 @@ module CustomFieldsHelper
|
||||
|
||||
def custom_fields_tabs
|
||||
tabs = [{:name => 'IssueCustomField', :label => :label_issue_plural},
|
||||
{:name => 'TimeEntryCustomField', :label => :label_spent_time},
|
||||
{:name => 'ProjectCustomField', :label => :label_project_plural},
|
||||
{:name => 'UserCustomField', :label => :label_user_plural},
|
||||
{:name => 'GroupCustomField', :label => :label_group_plural}
|
||||
@@ -26,37 +27,40 @@ module CustomFieldsHelper
|
||||
end
|
||||
|
||||
# Return custom field html tag corresponding to its format
|
||||
def custom_field_tag(custom_value)
|
||||
def custom_field_tag(name, custom_value)
|
||||
custom_field = custom_value.custom_field
|
||||
field_name = "custom_fields[#{custom_field.id}]"
|
||||
field_id = "custom_fields_#{custom_field.id}"
|
||||
field_name = "#{name}[custom_field_values][#{custom_field.id}]"
|
||||
field_id = "#{name}_custom_field_values_#{custom_field.id}"
|
||||
|
||||
case custom_field.field_format
|
||||
when "date"
|
||||
text_field('custom_value', 'value', :name => field_name, :id => field_id, :size => 10) +
|
||||
text_field_tag(field_name, custom_value.value, :id => field_id, :size => 10) +
|
||||
calendar_for(field_id)
|
||||
when "text"
|
||||
text_area 'custom_value', 'value', :name => field_name, :id => field_id, :rows => 3, :style => 'width:99%'
|
||||
text_area_tag(field_name, custom_value.value, :id => field_id, :rows => 3, :style => 'width:90%')
|
||||
when "bool"
|
||||
check_box 'custom_value', 'value', :name => field_name, :id => field_id
|
||||
check_box_tag(field_name, '1', custom_value.true?, :id => field_id) + hidden_field_tag(field_name, '0')
|
||||
when "list"
|
||||
select 'custom_value', 'value', custom_field.possible_values, { :include_blank => true }, :name => field_name, :id => field_id
|
||||
blank_option = custom_field.is_required? ?
|
||||
(custom_field.default_value.blank? ? "<option value=\"\">--- #{l(:actionview_instancetag_blank_option)} ---</option>" : '') :
|
||||
'<option></option>'
|
||||
select_tag(field_name, blank_option + options_for_select(custom_field.possible_values, custom_value.value), :id => field_id)
|
||||
else
|
||||
text_field 'custom_value', 'value', :name => field_name, :id => field_id
|
||||
text_field_tag(field_name, custom_value.value, :id => field_id)
|
||||
end
|
||||
end
|
||||
|
||||
# Return custom field label tag
|
||||
def custom_field_label_tag(custom_value)
|
||||
def custom_field_label_tag(name, custom_value)
|
||||
content_tag "label", custom_value.custom_field.name +
|
||||
(custom_value.custom_field.is_required? ? " <span class=\"required\">*</span>" : ""),
|
||||
:for => "custom_fields_#{custom_value.custom_field.id}",
|
||||
:for => "#{name}_custom_field_values_#{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)
|
||||
def custom_field_tag_with_label(name, custom_value)
|
||||
custom_field_label_tag(name, custom_value) + custom_field_tag(name, custom_value)
|
||||
end
|
||||
|
||||
# Return a string used to display a custom value
|
||||
|
||||
@@ -54,9 +54,15 @@ module IssuesHelper
|
||||
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 'project_id'
|
||||
p = Project.find_by_id(detail.value) and value = p.name if detail.value
|
||||
p = Project.find_by_id(detail.old_value) and old_value = p.name 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 'tracker_id'
|
||||
t = Tracker.find_by_id(detail.value) and value = t.name if detail.value
|
||||
t = Tracker.find_by_id(detail.old_value) and old_value = t.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
|
||||
@@ -69,6 +75,9 @@ module IssuesHelper
|
||||
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
|
||||
when 'estimated_hours'
|
||||
value = "%0.02f" % detail.value.to_f unless detail.value.blank?
|
||||
old_value = "%0.02f" % detail.old_value.to_f unless detail.old_value.blank?
|
||||
end
|
||||
when 'cf'
|
||||
custom_field = CustomField.find_by_id(detail.prop_key)
|
||||
@@ -89,9 +98,9 @@ module IssuesHelper
|
||||
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?)
|
||||
if detail.property == 'attachment' && !value.blank? && Attachment.find_by_id(detail.prop_key)
|
||||
if detail.property == 'attachment' && !value.blank? && a = Attachment.find_by_id(detail.prop_key)
|
||||
# Link to the attachment if it has not been removed
|
||||
value = link_to(value, :controller => 'attachments', :action => 'download', :id => detail.prop_key)
|
||||
value = link_to_attachment(a)
|
||||
else
|
||||
value = content_tag("i", h(value)) if value
|
||||
end
|
||||
@@ -120,6 +129,7 @@ module IssuesHelper
|
||||
|
||||
def issues_to_csv(issues, project = nil)
|
||||
ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
|
||||
decimal_separator = l(:general_csv_decimal_separator)
|
||||
export = StringIO.new
|
||||
CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
|
||||
# csv header fields
|
||||
@@ -142,7 +152,7 @@ module IssuesHelper
|
||||
]
|
||||
# Export project custom fields if project is given
|
||||
# otherwise export custom fields marked as "For all projects"
|
||||
custom_fields = project.nil? ? IssueCustomField.for_all : project.all_custom_fields
|
||||
custom_fields = project.nil? ? IssueCustomField.for_all : project.all_issue_custom_fields
|
||||
custom_fields.each {|f| headers << f.name}
|
||||
# Description in the last column
|
||||
headers << l(:field_description)
|
||||
@@ -162,7 +172,7 @@ module IssuesHelper
|
||||
format_date(issue.start_date),
|
||||
format_date(issue.due_date),
|
||||
issue.done_ratio,
|
||||
issue.estimated_hours,
|
||||
issue.estimated_hours.to_s.gsub('.', decimal_separator),
|
||||
format_time(issue.created_on),
|
||||
format_time(issue.updated_on)
|
||||
]
|
||||
|
||||
@@ -19,13 +19,16 @@ module JournalsHelper
|
||||
def render_notes(journal, options={})
|
||||
content = ''
|
||||
editable = journal.editable_by?(User.current)
|
||||
if editable && !journal.notes.blank?
|
||||
links = []
|
||||
links = []
|
||||
if !journal.notes.blank?
|
||||
links << link_to_remote(image_tag('comment.png'),
|
||||
{ :url => {:controller => 'issues', :action => 'reply', :id => journal.journalized, :journal_id => journal} },
|
||||
:title => l(:button_quote)) if options[:reply_links]
|
||||
links << link_to_in_place_notes_editor(image_tag('edit.png'), "journal-#{journal.id}-notes",
|
||||
{ :controller => 'journals', :action => 'edit', :id => journal },
|
||||
:title => l(:button_edit))
|
||||
content << content_tag('div', links.join(' '), :class => 'contextual')
|
||||
:title => l(:button_edit)) if editable
|
||||
end
|
||||
content << content_tag('div', links.join(' '), :class => 'contextual') unless links.empty?
|
||||
content << textilizable(journal, :notes)
|
||||
content_tag('div', content, :id => "journal-#{journal.id}-notes", :class => (editable ? 'wiki editable' : 'wiki'))
|
||||
end
|
||||
|
||||
19
groups/app/helpers/mail_handler_helper.rb
Normal file
19
groups/app/helpers/mail_handler_helper.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
# 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
|
||||
# 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 MailHandlerHelper
|
||||
end
|
||||
@@ -21,18 +21,22 @@ module ProjectsHelper
|
||||
link_to h(version.name), { :controller => 'versions', :action => 'show', :id => version }, options
|
||||
end
|
||||
|
||||
def format_activity_title(text)
|
||||
h(truncate_single_line(text, 100))
|
||||
end
|
||||
|
||||
def format_activity_day(date)
|
||||
date == Date.today ? l(:label_today).titleize : format_date(date)
|
||||
end
|
||||
|
||||
def format_activity_description(text)
|
||||
h(truncate(text, 250))
|
||||
h(truncate(text.to_s, 250).gsub(%r{<(pre|code)>.*$}m, '...'))
|
||||
end
|
||||
|
||||
# Renders the member list displayed on project overview
|
||||
def render_member_list(project)
|
||||
parts = []
|
||||
memberships_by_role = project.memberships.find(:all, :include => :role, :order => 'position').group_by {|m| m.role}
|
||||
memberships_by_role = project.memberships.find(:all, :include => :role, :order => "#{Role.table_name}.position").group_by {|m| m.role}
|
||||
memberships_by_role.keys.sort.each do |role|
|
||||
role_parts = []
|
||||
# Display group name (with its 5 first users) or user name
|
||||
|
||||
@@ -15,20 +15,23 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require 'coderay'
|
||||
require 'coderay/helpers/file_type'
|
||||
require 'iconv'
|
||||
|
||||
module RepositoriesHelper
|
||||
def syntax_highlight(name, content)
|
||||
type = CodeRay::FileType[name]
|
||||
type ? CodeRay.scan(content, type).html : h(content)
|
||||
end
|
||||
|
||||
def format_revision(txt)
|
||||
txt.to_s[0,8]
|
||||
end
|
||||
|
||||
def render_properties(properties)
|
||||
unless properties.nil? || properties.empty?
|
||||
content = ''
|
||||
properties.keys.sort.each do |property|
|
||||
content << content_tag('li', "<b>#{h property}</b>: <span>#{h properties[property]}</span>")
|
||||
end
|
||||
content_tag('ul', content, :class => 'properties')
|
||||
end
|
||||
end
|
||||
|
||||
def to_utf8(str)
|
||||
return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
|
||||
@encodings ||= Setting.repositories_encodings.split(',').collect(&:strip)
|
||||
@@ -48,10 +51,13 @@ module RepositoriesHelper
|
||||
end
|
||||
|
||||
def scm_select_tag(repository)
|
||||
container = [[]]
|
||||
REDMINE_SUPPORTED_SCM.each {|scm| container << ["Repository::#{scm}".constantize.scm_name, scm]}
|
||||
scm_options = [["--- #{l(:actionview_instancetag_blank_option)} ---", '']]
|
||||
REDMINE_SUPPORTED_SCM.each do |scm|
|
||||
scm_options << ["Repository::#{scm}".constantize.scm_name, scm] if Setting.enabled_scm.include?(scm) || (repository && repository.class.name.demodulize == scm)
|
||||
end
|
||||
|
||||
select_tag('repository_scm',
|
||||
options_for_select(container, repository.class.name.demodulize),
|
||||
options_for_select(scm_options, repository.class.name.demodulize),
|
||||
:disabled => (repository && !repository.new_record?),
|
||||
:onchange => remote_function(:url => { :controller => 'repositories', :action => 'edit', :id => @project }, :method => :get, :with => "Form.serialize(this.form)")
|
||||
)
|
||||
@@ -95,4 +101,8 @@ module RepositoriesHelper
|
||||
def bazaar_field_tags(form, repository)
|
||||
content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.new_record?)))
|
||||
end
|
||||
|
||||
def filesystem_field_tags(form, repository)
|
||||
content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?)))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
module SearchHelper
|
||||
def highlight_tokens(text, tokens)
|
||||
return text unless text && tokens && !tokens.empty?
|
||||
regexp = Regexp.new "(#{tokens.join('|')})", Regexp::IGNORECASE
|
||||
re_tokens = tokens.collect {|t| Regexp.escape(t)}
|
||||
regexp = Regexp.new "(#{re_tokens.join('|')})", Regexp::IGNORECASE
|
||||
result = ''
|
||||
text.split(regexp).each_with_index do |words, i|
|
||||
if result.length > 1200
|
||||
@@ -35,4 +36,28 @@ module SearchHelper
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
def type_label(t)
|
||||
l("label_#{t.singularize}_plural")
|
||||
end
|
||||
|
||||
def project_select_tag
|
||||
options = [[l(:label_project_all), 'all']]
|
||||
options << [l(:label_my_projects), 'my_projects'] unless User.current.memberships.empty?
|
||||
options << [l(:label_and_its_subprojects, @project.name), 'subprojects'] unless @project.nil? || @project.active_children.empty?
|
||||
options << [@project.name, ''] unless @project.nil?
|
||||
select_tag('scope', options_for_select(options, params[:scope].to_s)) if options.size > 1
|
||||
end
|
||||
|
||||
def render_results_by_type(results_by_type)
|
||||
links = []
|
||||
# Sorts types by results count
|
||||
results_by_type.keys.sort {|a, b| results_by_type[b] <=> results_by_type[a]}.each do |t|
|
||||
c = results_by_type[t]
|
||||
next if c == 0
|
||||
text = "#{type_label(t)} (#{c})"
|
||||
links << link_to(text, :q => params[:q], :titles_only => params[:title_only], :all_words => params[:all_words], :scope => params[:scope], t => 1)
|
||||
end
|
||||
('<ul>' + links.map {|link| content_tag('li', link)}.join(' ') + '</ul>') unless links.empty?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -21,6 +21,7 @@ module SettingsHelper
|
||||
{:name => 'authentication', :partial => 'settings/authentication', :label => :label_authentication},
|
||||
{:name => 'issues', :partial => 'settings/issues', :label => :label_issue_tracking},
|
||||
{:name => 'notifications', :partial => 'settings/notifications', :label => l(:field_mail_notification)},
|
||||
{:name => 'mail_handler', :partial => 'settings/mail_handler', :label => l(:label_incoming_emails)},
|
||||
{:name => 'repositories', :partial => 'settings/repositories', :label => :label_repository_plural}
|
||||
]
|
||||
end
|
||||
|
||||
@@ -83,7 +83,7 @@ module SortHelper
|
||||
# Use this to sort the controller's table items collection.
|
||||
#
|
||||
def sort_clause()
|
||||
session[@sort_name][:key] + ' ' + session[@sort_name][:order]
|
||||
session[@sort_name][:key] + ' ' + (session[@sort_name][:order] || 'ASC')
|
||||
end
|
||||
|
||||
# Returns a link which sorts by the named column.
|
||||
|
||||
@@ -16,6 +16,14 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module TimelogHelper
|
||||
def activity_collection_for_select_options
|
||||
activities = Enumeration::get_values('ACTI')
|
||||
collection = []
|
||||
collection << [ "--- #{l(:actionview_instancetag_blank_option)} ---", '' ] unless activities.detect(&:is_default)
|
||||
activities.each { |a| collection << [a.name, a.id] }
|
||||
collection
|
||||
end
|
||||
|
||||
def select_hours(data, criteria, value)
|
||||
data.select {|row| row[criteria] == value}
|
||||
end
|
||||
@@ -44,6 +52,8 @@ module TimelogHelper
|
||||
|
||||
def entries_to_csv(entries)
|
||||
ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
|
||||
decimal_separator = l(:general_csv_decimal_separator)
|
||||
custom_fields = TimeEntryCustomField.find(:all)
|
||||
export = StringIO.new
|
||||
CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
|
||||
# csv header fields
|
||||
@@ -57,6 +67,9 @@ module TimelogHelper
|
||||
l(:field_hours),
|
||||
l(:field_comments)
|
||||
]
|
||||
# Export custom fields
|
||||
headers += custom_fields.collect(&:name)
|
||||
|
||||
csv << headers.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
|
||||
# csv lines
|
||||
entries.each do |entry|
|
||||
@@ -67,9 +80,11 @@ module TimelogHelper
|
||||
(entry.issue ? entry.issue.id : nil),
|
||||
(entry.issue ? entry.issue.tracker : nil),
|
||||
(entry.issue ? entry.issue.subject : nil),
|
||||
entry.hours,
|
||||
entry.hours.to_s.gsub('.', decimal_separator),
|
||||
entry.comments
|
||||
]
|
||||
fields += custom_fields.collect {|f| show_value(entry.custom_value_for(f)) }
|
||||
|
||||
csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,11 +16,26 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module UsersHelper
|
||||
def status_options_for_select(selected)
|
||||
def users_status_options_for_select(selected)
|
||||
user_count_by_status = User.count(:group => 'status').to_hash
|
||||
options_for_select([[l(:label_all), ''],
|
||||
[l(:status_active), 1],
|
||||
[l(:status_registered), 2],
|
||||
[l(:status_locked), 3]], selected)
|
||||
["#{l(:status_active)} (#{user_count_by_status[1].to_i})", 1],
|
||||
["#{l(:status_registered)} (#{user_count_by_status[2].to_i})", 2],
|
||||
["#{l(:status_locked)} (#{user_count_by_status[3].to_i})", 3]], selected)
|
||||
end
|
||||
|
||||
# Options for the new membership projects combo-box
|
||||
def projects_options_for_select(projects)
|
||||
options = content_tag('option', "--- #{l(:actionview_instancetag_blank_option)} ---")
|
||||
projects_by_root = projects.group_by(&:root)
|
||||
projects_by_root.keys.sort.each do |root|
|
||||
options << content_tag('option', h(root.name), :value => root.id, :disabled => (!projects.include?(root)))
|
||||
projects_by_root[root].sort.each do |project|
|
||||
next if project == root
|
||||
options << content_tag('option', '» ' + h(project.name), :value => project.id)
|
||||
end
|
||||
end
|
||||
options
|
||||
end
|
||||
|
||||
def change_status_link(user)
|
||||
@@ -30,8 +45,14 @@ module UsersHelper
|
||||
link_to l(:button_unlock), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :post, :class => 'icon icon-unlock'
|
||||
elsif user.registered?
|
||||
link_to l(:button_activate), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :post, :class => 'icon icon-unlock'
|
||||
else
|
||||
elsif user != User.current
|
||||
link_to l(:button_lock), url.merge(:user => {:status => User::STATUS_LOCKED}), :method => :post, :class => 'icon icon-lock'
|
||||
end
|
||||
end
|
||||
|
||||
def user_settings_tabs
|
||||
tabs = [{:name => 'general', :partial => 'users/general', :label => :label_general},
|
||||
{:name => 'memberships', :partial => 'users/memberships', :label => :label_project_plural}
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -24,7 +24,7 @@ module WatchersHelper
|
||||
return '' unless user && user.logged? && object.respond_to?('watched_by?')
|
||||
watched = object.watched_by?(user)
|
||||
url = {:controller => 'watchers',
|
||||
:action => (watched ? 'remove' : 'add'),
|
||||
:action => (watched ? 'unwatch' : 'watch'),
|
||||
:object_type => object.class.to_s.underscore,
|
||||
:object_id => object.id}
|
||||
link_to_remote((watched ? l(:button_unwatch) : l(:button_watch)),
|
||||
@@ -33,4 +33,9 @@ module WatchersHelper
|
||||
:class => (watched ? 'icon icon-fav' : 'icon icon-fav-off'))
|
||||
|
||||
end
|
||||
|
||||
# Returns a comma separated list of users watching the given object
|
||||
def watchers_list(object)
|
||||
object.watcher_users.collect {|u| content_tag('span', link_to_user(u), :class => 'user') }.join(",\n")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,6 +17,22 @@
|
||||
|
||||
module WikiHelper
|
||||
|
||||
def render_page_hierarchy(pages, node=nil)
|
||||
content = ''
|
||||
if pages[node]
|
||||
content << "<ul class=\"pages-hierarchy\">\n"
|
||||
pages[node].each do |page|
|
||||
content << "<li>"
|
||||
content << link_to(h(page.pretty_title), {:action => 'index', :page => page.title},
|
||||
:title => (page.respond_to?(:updated_on) ? l(:label_updated_time, distance_of_time_in_words(Time.now, page.updated_on)) : nil))
|
||||
content << "\n" + render_page_hierarchy(pages, page.id) if pages[page.id]
|
||||
content << "</li>\n"
|
||||
end
|
||||
content << "</ul>\n"
|
||||
end
|
||||
content
|
||||
end
|
||||
|
||||
def html_diff(wdiff)
|
||||
words = wdiff.words.collect{|word| h(word)}
|
||||
words_add = 0
|
||||
|
||||
@@ -26,7 +26,19 @@ class Attachment < ActiveRecord::Base
|
||||
validates_length_of :disk_filename, :maximum => 255
|
||||
|
||||
acts_as_event :title => :filename,
|
||||
:url => Proc.new {|o| {:controller => 'attachments', :action => 'download', :id => o.id}}
|
||||
:url => Proc.new {|o| {:controller => 'attachments', :action => 'download', :id => o.id, :filename => o.filename}}
|
||||
|
||||
acts_as_activity_provider :type => 'files',
|
||||
:permission => :view_files,
|
||||
:find_options => {:select => "#{Attachment.table_name}.*",
|
||||
:joins => "LEFT JOIN #{Version.table_name} ON #{Attachment.table_name}.container_type='Version' AND #{Version.table_name}.id = #{Attachment.table_name}.container_id " +
|
||||
"LEFT JOIN #{Project.table_name} ON #{Version.table_name}.project_id = #{Project.table_name}.id"}
|
||||
|
||||
acts_as_activity_provider :type => 'documents',
|
||||
:permission => :view_documents,
|
||||
:find_options => {:select => "#{Attachment.table_name}.*",
|
||||
:joins => "LEFT JOIN #{Document.table_name} ON #{Attachment.table_name}.container_type='Document' AND #{Document.table_name}.id = #{Attachment.table_name}.container_id " +
|
||||
"LEFT JOIN #{Project.table_name} ON #{Document.table_name}.project_id = #{Project.table_name}.id"}
|
||||
|
||||
cattr_accessor :storage_path
|
||||
@@storage_path = "#{RAILS_ROOT}/files"
|
||||
@@ -40,7 +52,7 @@ class Attachment < ActiveRecord::Base
|
||||
@temp_file = incoming_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.disk_filename = Attachment.disk_filename(filename)
|
||||
self.content_type = @temp_file.content_type.to_s.chomp
|
||||
self.filesize = @temp_file.size
|
||||
end
|
||||
@@ -68,9 +80,7 @@ class Attachment < ActiveRecord::Base
|
||||
|
||||
# Deletes file on the disk
|
||||
def after_destroy
|
||||
if self.filename?
|
||||
File.delete(diskfile) if File.exist?(diskfile)
|
||||
end
|
||||
File.delete(diskfile) if !filename.blank? && File.exist?(diskfile)
|
||||
end
|
||||
|
||||
# Returns file's location on disk
|
||||
@@ -90,6 +100,14 @@ class Attachment < ActiveRecord::Base
|
||||
self.filename =~ /\.(jpe?g|gif|png)$/i
|
||||
end
|
||||
|
||||
def is_text?
|
||||
Redmine::MimeType.is_type?('text', filename)
|
||||
end
|
||||
|
||||
def is_diff?
|
||||
self.filename =~ /\.(patch|diff)$/i
|
||||
end
|
||||
|
||||
private
|
||||
def sanitize_filename(value)
|
||||
# get only the filename, not the whole path
|
||||
@@ -100,4 +118,17 @@ private
|
||||
# Finally, replace all non alphanumeric, hyphens or periods with underscore
|
||||
@filename = just_filename.gsub(/[^\w\.\-]/,'_')
|
||||
end
|
||||
|
||||
# Returns an ASCII or hashed filename
|
||||
def self.disk_filename(filename)
|
||||
df = DateTime.now.strftime("%y%m%d%H%M%S") + "_"
|
||||
if filename =~ %r{^[a-zA-Z0-9_\.\-]*$}
|
||||
df << filename
|
||||
else
|
||||
df << Digest::MD5.hexdigest(filename)
|
||||
# keep the extension if any
|
||||
df << $1 if filename =~ %r{(\.[a-zA-Z0-9]+)$}
|
||||
end
|
||||
df
|
||||
end
|
||||
end
|
||||
|
||||
@@ -20,10 +20,7 @@ class AuthSource < ActiveRecord::Base
|
||||
|
||||
validates_presence_of :name
|
||||
validates_uniqueness_of :name
|
||||
validates_length_of :name, :host, :maximum => 60
|
||||
validates_length_of :account_password, :maximum => 60, :allow_nil => true
|
||||
validates_length_of :account, :base_dn, :maximum => 255
|
||||
validates_length_of :attr_login, :attr_firstname, :attr_lastname, :attr_mail, :maximum => 30
|
||||
validates_length_of :name, :maximum => 60
|
||||
|
||||
def authenticate(login, password)
|
||||
end
|
||||
|
||||
@@ -20,7 +20,10 @@ require 'iconv'
|
||||
|
||||
class AuthSourceLdap < AuthSource
|
||||
validates_presence_of :host, :port, :attr_login
|
||||
validates_presence_of :attr_firstname, :attr_lastname, :attr_mail, :if => Proc.new { |a| a.onthefly_register? }
|
||||
validates_length_of :name, :host, :account_password, :maximum => 60, :allow_nil => true
|
||||
validates_length_of :account, :base_dn, :maximum => 255, :allow_nil => true
|
||||
validates_length_of :attr_login, :attr_firstname, :attr_lastname, :attr_mail, :maximum => 30, :allow_nil => true
|
||||
validates_numericality_of :port, :only_integer => true
|
||||
|
||||
def after_initialize
|
||||
self.port = 389 if self.port == 0
|
||||
|
||||
@@ -19,4 +19,8 @@ class Change < ActiveRecord::Base
|
||||
belongs_to :changeset
|
||||
|
||||
validates_presence_of :changeset_id, :action, :path
|
||||
|
||||
def relative_path
|
||||
changeset.repository.relative_path(path)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
# 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'
|
||||
|
||||
class Changeset < ActiveRecord::Base
|
||||
belongs_to :repository
|
||||
has_many :changes, :dependent => :delete_all
|
||||
@@ -27,9 +29,12 @@ class Changeset < ActiveRecord::Base
|
||||
:url => Proc.new {|o| {:controller => 'repositories', :action => 'revision', :id => o.repository.project_id, :rev => o.revision}}
|
||||
|
||||
acts_as_searchable :columns => 'comments',
|
||||
:include => :repository,
|
||||
:include => {:repository => :project},
|
||||
:project_key => "#{Repository.table_name}.project_id",
|
||||
:date_column => 'committed_on'
|
||||
|
||||
acts_as_activity_provider :timestamp => "#{table_name}.committed_on",
|
||||
:find_options => {:include => {:repository => :project}}
|
||||
|
||||
validates_presence_of :repository_id, :revision, :committed_on, :commit_date
|
||||
validates_uniqueness_of :revision, :scope => :repository_id
|
||||
@@ -40,7 +45,7 @@ class Changeset < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def comments=(comment)
|
||||
write_attribute(:comments, comment.strip)
|
||||
write_attribute(:comments, Changeset.normalize_comments(comment))
|
||||
end
|
||||
|
||||
def committed_on=(date)
|
||||
@@ -75,7 +80,7 @@ class Changeset < ActiveRecord::Base
|
||||
if ref_keywords.delete('*')
|
||||
# find any issue ID in the comments
|
||||
target_issue_ids = []
|
||||
comments.scan(%r{([\s\(,-^])#(\d+)(?=[[:punct:]]|\s|<|$)}).each { |m| target_issue_ids << m[1] }
|
||||
comments.scan(%r{([\s\(,-]|^)#(\d+)(?=[[:punct:]]|\s|<|$)}).each { |m| target_issue_ids << m[1] }
|
||||
referenced_issues += repository.project.issues.find_all_by_id(target_issue_ids)
|
||||
end
|
||||
|
||||
@@ -128,4 +133,24 @@ class Changeset < ActiveRecord::Base
|
||||
def next
|
||||
@next ||= Changeset.find(:first, :conditions => ['id > ? AND repository_id = ?', self.id, self.repository_id], :order => 'id ASC')
|
||||
end
|
||||
|
||||
# Strips and reencodes a commit log before insertion into the database
|
||||
def self.normalize_comments(str)
|
||||
to_utf8(str.to_s.strip)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def self.to_utf8(str)
|
||||
return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
|
||||
encoding = Setting.commit_logs_encoding.to_s.strip
|
||||
unless encoding.blank? || encoding == 'UTF-8'
|
||||
begin
|
||||
return Iconv.conv('UTF-8', encoding, str)
|
||||
rescue Iconv::Failure
|
||||
# do nothing here
|
||||
end
|
||||
end
|
||||
str
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,9 +30,9 @@ class CustomField < ActiveRecord::Base
|
||||
}.freeze
|
||||
|
||||
validates_presence_of :name, :field_format
|
||||
validates_uniqueness_of :name
|
||||
validates_uniqueness_of :name, :scope => :type
|
||||
validates_length_of :name, :maximum => 30
|
||||
validates_format_of :name, :with => /^[\w\s\'\-]*$/i
|
||||
validates_format_of :name, :with => /^[\w\s\.\'\-]*$/i
|
||||
validates_inclusion_of :field_format, :in => FIELD_FORMATS.keys
|
||||
|
||||
def initialize(attributes = nil)
|
||||
@@ -66,7 +66,7 @@ class CustomField < ActiveRecord::Base
|
||||
|
||||
# to move in project_custom_field
|
||||
def self.for_all
|
||||
find(:all, :conditions => ["is_for_all=?", true])
|
||||
find(:all, :conditions => ["is_for_all=?", true], :order => 'position')
|
||||
end
|
||||
|
||||
def type_name
|
||||
|
||||
@@ -25,6 +25,11 @@ class CustomValue < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
# Returns true if the boolean custom value is true
|
||||
def true?
|
||||
self.value == '1'
|
||||
end
|
||||
|
||||
protected
|
||||
def validate
|
||||
if value.blank?
|
||||
|
||||
@@ -20,11 +20,12 @@ class Document < ActiveRecord::Base
|
||||
belongs_to :category, :class_name => "Enumeration", :foreign_key => "category_id"
|
||||
has_many :attachments, :as => :container, :dependent => :destroy
|
||||
|
||||
acts_as_searchable :columns => ['title', 'description']
|
||||
acts_as_searchable :columns => ['title', "#{table_name}.description"], :include => :project
|
||||
acts_as_event :title => Proc.new {|o| "#{l(:label_document)}: #{o.title}"},
|
||||
:author => Proc.new {|o| (a = o.attachments.find(:first, :order => "#{Attachment.table_name}.created_on ASC")) ? a.author : nil },
|
||||
:url => Proc.new {|o| {:controller => 'documents', :action => 'show', :id => o.id}}
|
||||
|
||||
acts_as_activity_provider :find_options => {:include => :project}
|
||||
|
||||
validates_presence_of :project, :title, :category
|
||||
validates_length_of :title, :maximum => 60
|
||||
end
|
||||
|
||||
@@ -23,12 +23,12 @@ class Enumeration < ActiveRecord::Base
|
||||
validates_presence_of :opt, :name
|
||||
validates_uniqueness_of :name, :scope => [:opt]
|
||||
validates_length_of :name, :maximum => 30
|
||||
validates_format_of :name, :with => /^[\w\s\'\-]*$/i
|
||||
|
||||
# Single table inheritance would be an option
|
||||
OPTIONS = {
|
||||
"IPRI" => :enumeration_issue_priorities,
|
||||
"DCAT" => :enumeration_doc_categories,
|
||||
"ACTI" => :enumeration_activities
|
||||
"IPRI" => {:label => :enumeration_issue_priorities, :model => Issue, :foreign_key => :priority_id},
|
||||
"DCAT" => {:label => :enumeration_doc_categories, :model => Document, :foreign_key => :category_id},
|
||||
"ACTI" => {:label => :enumeration_activities, :model => TimeEntry, :foreign_key => :activity_id}
|
||||
}.freeze
|
||||
|
||||
def self.get_values(option)
|
||||
@@ -40,13 +40,32 @@ class Enumeration < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def option_name
|
||||
OPTIONS[self.opt]
|
||||
OPTIONS[self.opt][:label]
|
||||
end
|
||||
|
||||
def before_save
|
||||
Enumeration.update_all("is_default = #{connection.quoted_false}", {:opt => opt}) if is_default?
|
||||
end
|
||||
|
||||
def objects_count
|
||||
OPTIONS[self.opt][:model].count(:conditions => "#{OPTIONS[self.opt][:foreign_key]} = #{id}")
|
||||
end
|
||||
|
||||
def in_use?
|
||||
self.objects_count != 0
|
||||
end
|
||||
|
||||
alias :destroy_without_reassign :destroy
|
||||
|
||||
# Destroy the enumeration
|
||||
# If a enumeration is specified, objects are reassigned
|
||||
def destroy(reassign_to = nil)
|
||||
if reassign_to && reassign_to.is_a?(Enumeration)
|
||||
OPTIONS[self.opt][:model].update_all("#{OPTIONS[self.opt][:foreign_key]} = #{reassign_to.id}", "#{OPTIONS[self.opt][:foreign_key]} = #{id}")
|
||||
end
|
||||
destroy_without_reassign
|
||||
end
|
||||
|
||||
def <=>(enumeration)
|
||||
position <=> enumeration.position
|
||||
end
|
||||
@@ -55,13 +74,6 @@ class Enumeration < ActiveRecord::Base
|
||||
|
||||
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])
|
||||
when "ACTI"
|
||||
raise "Can't delete enumeration" if TimeEntry.find(:first, :conditions => ["activity_id=?", self.id])
|
||||
end
|
||||
raise "Can't delete enumeration" if self.in_use?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -28,23 +28,26 @@ class Issue < ActiveRecord::Base
|
||||
has_many :journals, :as => :journalized, :dependent => :destroy
|
||||
has_many :attachments, :as => :container, :dependent => :destroy
|
||||
has_many :time_entries, :dependent => :delete_all
|
||||
has_many :custom_values, :dependent => :delete_all, :as => :customized
|
||||
has_many :custom_fields, :through => :custom_values
|
||||
has_and_belongs_to_many :changesets, :order => "revision ASC"
|
||||
has_and_belongs_to_many :changesets, :order => "#{Changeset.table_name}.committed_on ASC, #{Changeset.table_name}.id ASC"
|
||||
|
||||
has_many :relations_from, :class_name => 'IssueRelation', :foreign_key => 'issue_from_id', :dependent => :delete_all
|
||||
has_many :relations_to, :class_name => 'IssueRelation', :foreign_key => 'issue_to_id', :dependent => :delete_all
|
||||
|
||||
acts_as_customizable
|
||||
acts_as_watchable
|
||||
acts_as_searchable :columns => ['subject', 'description'], :with => {:journal => :issue}
|
||||
acts_as_searchable :columns => ['subject', "#{table_name}.description", "#{Journal.table_name}.notes"],
|
||||
:include => [:project, :journals],
|
||||
# sort by id so that limited eager loading doesn't break with postgresql
|
||||
:order_column => "#{table_name}.id"
|
||||
acts_as_event :title => Proc.new {|o| "#{o.tracker.name} ##{o.id}: #{o.subject}"},
|
||||
:url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.id}}
|
||||
|
||||
acts_as_activity_provider :find_options => {:include => [:project, :author, :tracker]}
|
||||
|
||||
validates_presence_of :subject, :description, :priority, :project, :tracker, :author, :status
|
||||
validates_length_of :subject, :maximum => 255
|
||||
validates_inclusion_of :done_ratio, :in => 0..100
|
||||
validates_numericality_of :estimated_hours, :allow_nil => true
|
||||
validates_associated :custom_values, :on => :update
|
||||
|
||||
def after_initialize
|
||||
if new_record?
|
||||
@@ -54,6 +57,11 @@ class Issue < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
# Overrides Redmine::Acts::Customizable::InstanceMethods#available_custom_fields
|
||||
def available_custom_fields
|
||||
(project && tracker) ? project.all_issue_custom_fields.select {|c| tracker.custom_fields.include? c } : []
|
||||
end
|
||||
|
||||
def copy_from(arg)
|
||||
issue = arg.is_a?(Issue) ? arg : Issue.find(arg)
|
||||
self.attributes = issue.attributes.dup
|
||||
@@ -71,7 +79,9 @@ class Issue < ActiveRecord::Base
|
||||
self.relations_to.clear
|
||||
end
|
||||
# issue is moved to another project
|
||||
self.category = nil
|
||||
# reassign to the category with same name if any
|
||||
new_category = category.nil? ? nil : new_project.issue_categories.find_by_name(category.name)
|
||||
self.category = new_category
|
||||
self.fixed_version = nil
|
||||
self.project = new_project
|
||||
end
|
||||
@@ -168,17 +178,14 @@ class Issue < ActiveRecord::Base
|
||||
end
|
||||
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
|
||||
@issue_before_change.status = self.status
|
||||
@custom_values_before_change = {}
|
||||
self.custom_values.each {|c| @custom_values_before_change.store c.custom_field_id, c.value }
|
||||
# Make sure updated_on is updated when adding a note.
|
||||
updated_on_will_change!
|
||||
@current_journal
|
||||
end
|
||||
|
||||
@@ -225,9 +232,15 @@ class Issue < ActiveRecord::Base
|
||||
dependencies
|
||||
end
|
||||
|
||||
# Returns an array of the duplicate issues
|
||||
# Returns an array of issues that duplicate this one
|
||||
def duplicates
|
||||
relations.select {|r| r.relation_type == IssueRelation::TYPE_DUPLICATES}.collect {|r| r.other_issue(self)}
|
||||
relations_to.select {|r| r.relation_type == IssueRelation::TYPE_DUPLICATES}.collect {|r| r.issue_from}
|
||||
end
|
||||
|
||||
# Returns the due date or the target due date if any
|
||||
# Used on gantt chart
|
||||
def due_before
|
||||
due_date || (fixed_version ? fixed_version.effective_date : nil)
|
||||
end
|
||||
|
||||
def duration
|
||||
|
||||
@@ -25,7 +25,7 @@ class IssueRelation < ActiveRecord::Base
|
||||
TYPE_PRECEDES = "precedes"
|
||||
|
||||
TYPES = { TYPE_RELATES => { :name => :label_relates_to, :sym_name => :label_relates_to, :order => 1 },
|
||||
TYPE_DUPLICATES => { :name => :label_duplicates, :sym_name => :label_duplicates, :order => 2 },
|
||||
TYPE_DUPLICATES => { :name => :label_duplicates, :sym_name => :label_duplicated_by, :order => 2 },
|
||||
TYPE_BLOCKS => { :name => :label_blocks, :sym_name => :label_blocked_by, :order => 3 },
|
||||
TYPE_PRECEDES => { :name => :label_precedes, :sym_name => :label_follows, :order => 4 },
|
||||
}.freeze
|
||||
|
||||
@@ -25,17 +25,18 @@ class Journal < ActiveRecord::Base
|
||||
has_many :details, :class_name => "JournalDetail", :dependent => :delete_all
|
||||
attr_accessor :indice
|
||||
|
||||
acts_as_searchable :columns => 'notes',
|
||||
:include => :issue,
|
||||
:project_key => "#{Issue.table_name}.project_id",
|
||||
:date_column => "#{Issue.table_name}.created_on"
|
||||
|
||||
acts_as_event :title => Proc.new {|o| "#{o.issue.tracker.name} ##{o.issue.id}: #{o.issue.subject}" + ((s = o.new_status) ? " (#{s})" : '') },
|
||||
acts_as_event :title => Proc.new {|o| status = ((s = o.new_status) ? " (#{s})" : nil); "#{o.issue.tracker} ##{o.issue.id}#{status}: #{o.issue.subject}" },
|
||||
:description => :notes,
|
||||
:author => :user,
|
||||
:type => Proc.new {|o| (s = o.new_status) && s.is_closed? ? 'issue-closed' : 'issue-edit' },
|
||||
:type => Proc.new {|o| (s = o.new_status) ? (s.is_closed? ? 'issue-closed' : 'issue-edit') : 'issue-note' },
|
||||
:url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.issue.id, :anchor => "change-#{o.id}"}}
|
||||
|
||||
acts_as_activity_provider :type => 'issues',
|
||||
:permission => :view_issues,
|
||||
:find_options => {:include => [{:issue => :project}, :details, :user],
|
||||
:conditions => "#{Journal.table_name}.journalized_type = 'Issue' AND" +
|
||||
" (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')"}
|
||||
|
||||
def save
|
||||
# Do not save an empty journal
|
||||
(details.empty? && notes.blank?) ? false : super
|
||||
|
||||
@@ -16,25 +16,138 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class MailHandler < ActionMailer::Base
|
||||
|
||||
class UnauthorizedAction < StandardError; end
|
||||
class MissingInformation < StandardError; end
|
||||
|
||||
attr_reader :email, :user
|
||||
|
||||
def self.receive(email, options={})
|
||||
@@handler_options = options.dup
|
||||
|
||||
@@handler_options[:issue] ||= {}
|
||||
|
||||
@@handler_options[:allow_override] = @@handler_options[:allow_override].split(',').collect(&:strip) if @@handler_options[:allow_override].is_a?(String)
|
||||
@@handler_options[:allow_override] ||= []
|
||||
# Project needs to be overridable if not specified
|
||||
@@handler_options[:allow_override] << 'project' unless @@handler_options[:issue].has_key?(:project)
|
||||
# Status needs to be overridable if not specified
|
||||
@@handler_options[:allow_override] << 'status' unless @@handler_options[:issue].has_key?(:status)
|
||||
super email
|
||||
end
|
||||
|
||||
# Processes incoming emails
|
||||
# Currently, it only supports adding a note to an existing issue
|
||||
# by replying to the initial notification message
|
||||
def receive(email)
|
||||
# find related issue by parsing the subject
|
||||
m = email.subject.match %r{\[.*#(\d+)\]}
|
||||
return unless m
|
||||
issue = Issue.find_by_id(m[1])
|
||||
return unless issue
|
||||
|
||||
# find user
|
||||
user = User.find_active(:first, :conditions => {:mail => email.from.first})
|
||||
return unless user
|
||||
@email = email
|
||||
@user = User.find_active(:first, :conditions => {:mail => email.from.first})
|
||||
unless @user
|
||||
# Unknown user => the email is ignored
|
||||
# TODO: ability to create the user's account
|
||||
logger.info "MailHandler: email submitted by unknown user [#{email.from.first}]" if logger && logger.info
|
||||
return false
|
||||
end
|
||||
User.current = @user
|
||||
dispatch
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
ISSUE_REPLY_SUBJECT_RE = %r{\[[^\]]+#(\d+)\]}
|
||||
|
||||
def dispatch
|
||||
if m = email.subject.match(ISSUE_REPLY_SUBJECT_RE)
|
||||
receive_issue_update(m[1].to_i)
|
||||
else
|
||||
receive_issue
|
||||
end
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
# TODO: send a email to the user
|
||||
logger.error e.message if logger
|
||||
false
|
||||
rescue MissingInformation => e
|
||||
logger.error "MailHandler: missing information from #{user}: #{e.message}" if logger
|
||||
false
|
||||
rescue UnauthorizedAction => e
|
||||
logger.error "MailHandler: unauthorized attempt from #{user}" if logger
|
||||
false
|
||||
end
|
||||
|
||||
# Creates a new issue
|
||||
def receive_issue
|
||||
project = target_project
|
||||
tracker = (get_keyword(:tracker) && project.trackers.find_by_name(get_keyword(:tracker))) || project.trackers.find(:first)
|
||||
category = (get_keyword(:category) && project.issue_categories.find_by_name(get_keyword(:category)))
|
||||
priority = (get_keyword(:priority) && Enumeration.find_by_opt_and_name('IPRI', get_keyword(:priority)))
|
||||
status = (get_keyword(:status) && IssueStatus.find_by_name(get_keyword(:status))) || IssueStatus.default
|
||||
|
||||
# check permission
|
||||
return unless user.allowed_to?(:add_issue_notes, issue.project)
|
||||
raise UnauthorizedAction unless user.allowed_to?(:add_issues, project)
|
||||
issue = Issue.new(:author => user, :project => project, :tracker => tracker, :category => category, :priority => priority, :status => status)
|
||||
issue.subject = email.subject.chomp
|
||||
issue.description = email.plain_text_body.chomp
|
||||
issue.save!
|
||||
add_attachments(issue)
|
||||
logger.info "MailHandler: issue ##{issue.id} created by #{user}" if logger && logger.info
|
||||
Mailer.deliver_issue_add(issue) if Setting.notified_events.include?('issue_added')
|
||||
issue
|
||||
end
|
||||
|
||||
def target_project
|
||||
# TODO: other ways to specify project:
|
||||
# * parse the email To field
|
||||
# * specific project (eg. Setting.mail_handler_target_project)
|
||||
target = Project.find_by_identifier(get_keyword(:project))
|
||||
raise MissingInformation.new('Unable to determine target project') if target.nil?
|
||||
target
|
||||
end
|
||||
|
||||
# Adds a note to an existing issue
|
||||
def receive_issue_update(issue_id)
|
||||
status = (get_keyword(:status) && IssueStatus.find_by_name(get_keyword(:status)))
|
||||
|
||||
issue = Issue.find_by_id(issue_id)
|
||||
return unless issue
|
||||
# check permission
|
||||
raise UnauthorizedAction unless user.allowed_to?(:add_issue_notes, issue.project) || user.allowed_to?(:edit_issues, issue.project)
|
||||
raise UnauthorizedAction unless status.nil? || user.allowed_to?(:edit_issues, issue.project)
|
||||
|
||||
# add the note
|
||||
issue.init_journal(user, email.body.chomp)
|
||||
issue.save
|
||||
journal = issue.init_journal(user, email.plain_text_body.chomp)
|
||||
add_attachments(issue)
|
||||
issue.status = status unless status.nil?
|
||||
issue.save!
|
||||
logger.info "MailHandler: issue ##{issue.id} updated by #{user}" if logger && logger.info
|
||||
Mailer.deliver_issue_edit(journal) if Setting.notified_events.include?('issue_updated')
|
||||
journal
|
||||
end
|
||||
|
||||
def add_attachments(obj)
|
||||
if email.has_attachments?
|
||||
email.attachments.each do |attachment|
|
||||
Attachment.create(:container => obj,
|
||||
:file => attachment,
|
||||
:author => user,
|
||||
:content_type => attachment.content_type)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def get_keyword(attr)
|
||||
if @@handler_options[:allow_override].include?(attr.to_s) && email.plain_text_body =~ /^#{attr}:[ \t]*(.+)$/i
|
||||
$1.strip
|
||||
elsif !@@handler_options[:issue][attr].blank?
|
||||
@@handler_options[:issue][attr]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class TMail::Mail
|
||||
# Returns body of the first plain text part found if any
|
||||
def plain_text_body
|
||||
return @plain_text_body unless @plain_text_body.nil?
|
||||
p = self.parts.collect {|c| (c.respond_to?(:parts) && !c.parts.empty?) ? c.parts : c}.flatten
|
||||
plain = p.detect {|c| c.content_type == 'text/plain'}
|
||||
@plain_text_body = plain.nil? ? self.body : plain.body
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -51,6 +51,15 @@ class Mailer < ActionMailer::Base
|
||||
:issue_url => url_for(:controller => 'issues', :action => 'show', :id => issue)
|
||||
end
|
||||
|
||||
def reminder(user, issues, days)
|
||||
set_language_if_valid user.language
|
||||
recipients user.mail
|
||||
subject l(:mail_subject_reminder, issues.size)
|
||||
body :issues => issues,
|
||||
:days => days,
|
||||
:issues_url => url_for(:controller => 'issues', :action => 'index', :set_filter => 1, :assigned_to_id => user.id, :sort_key => 'issues.due_date', :sort_order => 'asc')
|
||||
end
|
||||
|
||||
def document_added(document)
|
||||
redmine_headers 'Project' => document.project.identifier
|
||||
recipients document.project.recipients
|
||||
@@ -144,6 +153,30 @@ class Mailer < ActionMailer::Base
|
||||
(bcc.nil? || bcc.empty?)
|
||||
super
|
||||
end
|
||||
|
||||
# Sends reminders to issue assignees
|
||||
# Available options:
|
||||
# * :days => how many days in the future to remind about (defaults to 7)
|
||||
# * :tracker => id of tracker for filtering issues (defaults to all trackers)
|
||||
# * :project => id or identifier of project to process (defaults to all projects)
|
||||
def self.reminders(options={})
|
||||
days = options[:days] || 7
|
||||
project = options[:project] ? Project.find(options[:project]) : nil
|
||||
tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil
|
||||
|
||||
s = ARCondition.new ["#{IssueStatus.table_name}.is_closed = ? AND #{Issue.table_name}.due_date <= ?", false, days.day.from_now.to_date]
|
||||
s << "#{Issue.table_name}.assigned_to_id IS NOT NULL"
|
||||
s << "#{Project.table_name}.status = #{Project::STATUS_ACTIVE}"
|
||||
s << "#{Issue.table_name}.project_id = #{project.id}" if project
|
||||
s << "#{Issue.table_name}.tracker_id = #{tracker.id}" if tracker
|
||||
|
||||
issues_by_assignee = Issue.find(:all, :include => [:status, :assigned_to, :project, :tracker],
|
||||
:conditions => s.conditions
|
||||
).group_by(&:assigned_to)
|
||||
issues_by_assignee.each do |assignee, issues|
|
||||
deliver_reminder(assignee, issues, days) unless assignee.nil?
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def initialize_defaults(method_name)
|
||||
|
||||
@@ -23,14 +23,17 @@ class Message < ActiveRecord::Base
|
||||
belongs_to :last_reply, :class_name => 'Message', :foreign_key => 'last_reply_id'
|
||||
|
||||
acts_as_searchable :columns => ['subject', 'content'],
|
||||
:include => :board,
|
||||
:include => {:board, :project},
|
||||
:project_key => 'project_id',
|
||||
:date_column => 'created_on'
|
||||
:date_column => "#{table_name}.created_on"
|
||||
acts_as_event :title => Proc.new {|o| "#{o.board.name}: #{o.subject}"},
|
||||
:description => :content,
|
||||
:type => Proc.new {|o| o.parent_id.nil? ? 'message' : 'reply'},
|
||||
:url => Proc.new {|o| {:controller => 'messages', :action => 'show', :board_id => o.board_id, :id => o.id}}
|
||||
|
||||
:url => Proc.new {|o| {:controller => 'messages', :action => 'show', :board_id => o.board_id}.merge(o.parent_id.nil? ? {:id => o.id} :
|
||||
{:id => o.parent_id, :anchor => "message-#{o.id}"})}
|
||||
|
||||
acts_as_activity_provider :find_options => {:include => [{:board => :project}, :author]}
|
||||
|
||||
attr_protected :locked, :sticky
|
||||
validates_presence_of :subject, :content
|
||||
validates_length_of :subject, :maximum => 255
|
||||
|
||||
@@ -24,9 +24,10 @@ class News < ActiveRecord::Base
|
||||
validates_length_of :title, :maximum => 60
|
||||
validates_length_of :summary, :maximum => 255
|
||||
|
||||
acts_as_searchable :columns => ['title', 'description']
|
||||
acts_as_searchable :columns => ['title', "#{table_name}.description"], :include => :project
|
||||
acts_as_event :url => Proc.new {|o| {:controller => 'news', :action => 'show', :id => o.id}}
|
||||
|
||||
acts_as_activity_provider :find_options => {:include => [:project, :author]}
|
||||
|
||||
# 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.table_name}.created_on DESC")
|
||||
|
||||
@@ -23,7 +23,6 @@ class Project < ActiveRecord::Base
|
||||
has_many :members, :include => :user, :conditions => "#{Member.table_name}.principal_type='User' AND #{User.table_name}.status=#{User::STATUS_ACTIVE}"
|
||||
has_many :memberships, :class_name => 'Member'
|
||||
has_many :users, :through => :members, :uniq => true
|
||||
has_many :custom_values, :dependent => :delete_all, :as => :customized
|
||||
has_many :enabled_modules, :dependent => :delete_all
|
||||
has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position"
|
||||
has_many :issues, :dependent => :destroy, :order => "#{Issue.table_name}.created_on DESC", :include => [:status, :tracker]
|
||||
@@ -39,7 +38,7 @@ class Project < ActiveRecord::Base
|
||||
has_many :changesets, :through => :repository
|
||||
has_one :wiki, :dependent => :destroy
|
||||
# Custom field for the project issues
|
||||
has_and_belongs_to_many :custom_fields,
|
||||
has_and_belongs_to_many :issue_custom_fields,
|
||||
:class_name => 'IssueCustomField',
|
||||
:order => "#{CustomField.table_name}.position",
|
||||
:join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}",
|
||||
@@ -47,18 +46,19 @@ class Project < ActiveRecord::Base
|
||||
|
||||
acts_as_tree :order => "name", :counter_cache => true
|
||||
|
||||
acts_as_searchable :columns => ['name', 'description'], :project_key => 'id'
|
||||
acts_as_customizable
|
||||
acts_as_searchable :columns => ['name', 'description'], :project_key => 'id', :permission => nil
|
||||
acts_as_event :title => Proc.new {|o| "#{l(:label_project)}: #{o.name}"},
|
||||
:url => Proc.new {|o| {:controller => 'projects', :action => 'show', :id => o.id}}
|
||||
:url => Proc.new {|o| {:controller => 'projects', :action => 'show', :id => o.id}},
|
||||
:author => nil
|
||||
|
||||
attr_protected :status, :enabled_module_names
|
||||
|
||||
validates_presence_of :name, :identifier
|
||||
validates_uniqueness_of :name, :identifier
|
||||
validates_associated :custom_values, :on => :update
|
||||
validates_associated :repository, :wiki
|
||||
validates_length_of :name, :maximum => 30
|
||||
validates_length_of :homepage, :maximum => 60
|
||||
validates_length_of :homepage, :maximum => 255
|
||||
validates_length_of :identifier, :in => 3..20
|
||||
validates_format_of :identifier, :with => /^[a-z0-9\-]*$/
|
||||
|
||||
@@ -74,9 +74,9 @@ class Project < ActiveRecord::Base
|
||||
|
||||
def issues_with_subprojects(include_subprojects=false)
|
||||
conditions = nil
|
||||
if include_subprojects && !active_children.empty?
|
||||
ids = [id] + active_children.collect {|c| c.id}
|
||||
conditions = ["#{Project.table_name}.id IN (#{ids.join(',')})"]
|
||||
if include_subprojects
|
||||
ids = [id] + child_ids
|
||||
conditions = ["#{Project.table_name}.id IN (#{ids.join(',')}) AND #{Project.visible_by}"]
|
||||
end
|
||||
conditions ||= ["#{Project.table_name}.id = ?", id]
|
||||
# Quick and dirty fix for Rails 2 compatibility
|
||||
@@ -94,6 +94,7 @@ class Project < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.visible_by(user=nil)
|
||||
user ||= User.current
|
||||
if user && user.admin?
|
||||
return "#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"
|
||||
elsif user && user.memberships.any?
|
||||
@@ -113,16 +114,18 @@ class Project < ActiveRecord::Base
|
||||
end
|
||||
if user.admin?
|
||||
# no restriction
|
||||
elsif user.logged?
|
||||
statements << "#{Project.table_name}.is_public = #{connection.quoted_true}" if Role.non_member.allowed_to?(permission)
|
||||
allowed_project_ids = user.memberships.select {|m| m.role.allowed_to?(permission)}.collect {|m| m.project_id}
|
||||
statements << "#{Project.table_name}.id IN (#{allowed_project_ids.join(',')})" if allowed_project_ids.any?
|
||||
elsif Role.anonymous.allowed_to?(permission)
|
||||
# anonymous user allowed on public project
|
||||
statements << "#{Project.table_name}.is_public = #{connection.quoted_true}"
|
||||
else
|
||||
# anonymous user is not authorized
|
||||
statements << "1=0"
|
||||
if user.logged?
|
||||
statements << "#{Project.table_name}.is_public = #{connection.quoted_true}" if Role.non_member.allowed_to?(permission)
|
||||
allowed_project_ids = user.memberships.select {|m| m.role.allowed_to?(permission)}.collect {|m| m.project_id}
|
||||
statements << "#{Project.table_name}.id IN (#{allowed_project_ids.join(',')})" if allowed_project_ids.any?
|
||||
elsif Role.anonymous.allowed_to?(permission)
|
||||
# anonymous user allowed on public project
|
||||
statements << "#{Project.table_name}.is_public = #{connection.quoted_true}"
|
||||
else
|
||||
# anonymous user is not authorized
|
||||
end
|
||||
end
|
||||
statements.empty? ? base_statement : "((#{base_statement}) AND (#{statements.join(' OR ')}))"
|
||||
end
|
||||
@@ -144,7 +147,8 @@ class Project < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def to_param
|
||||
identifier
|
||||
# id is used for projects with a numeric identifier (compatibility)
|
||||
@to_param ||= (identifier.to_s =~ %r{^\d*$} ? id : identifier)
|
||||
end
|
||||
|
||||
def active?
|
||||
@@ -194,12 +198,12 @@ class Project < ActiveRecord::Base
|
||||
|
||||
# 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)
|
||||
all_custom_fields.select {|c| tracker.custom_fields.include? c }
|
||||
def all_issue_custom_fields
|
||||
@all_issue_custom_fields ||= (IssueCustomField.for_all + issue_custom_fields).uniq.sort
|
||||
end
|
||||
|
||||
def all_custom_fields
|
||||
@all_custom_fields ||= (IssueCustomField.for_all + custom_fields).uniq
|
||||
def project
|
||||
self
|
||||
end
|
||||
|
||||
def <=>(project)
|
||||
|
||||
@@ -88,7 +88,7 @@ class Query < ActiveRecord::Base
|
||||
:date_past => [ ">t-", "<t-", "t-", "t", "w" ],
|
||||
:string => [ "=", "~", "!", "!~" ],
|
||||
:text => [ "~", "!~" ],
|
||||
:integer => [ "=", ">=", "<=" ] }
|
||||
:integer => [ "=", ">=", "<=", "!*", "*" ] }
|
||||
|
||||
cattr_reader :operators_by_filter_type
|
||||
|
||||
@@ -125,7 +125,7 @@ class Query < ActiveRecord::Base
|
||||
filters.each_key do |field|
|
||||
errors.add label_for(field), :activerecord_error_blank unless
|
||||
# filter requires one or more values
|
||||
(values_for(field) and !values_for(field).first.empty?) or
|
||||
(values_for(field) and !values_for(field).first.blank?) or
|
||||
# filter doesn't require any value
|
||||
["o", "c", "!*", "*", "t", "w"].include? operator_for(field)
|
||||
end if filters
|
||||
@@ -152,7 +152,8 @@ class Query < ActiveRecord::Base
|
||||
"updated_on" => { :type => :date_past, :order => 10 },
|
||||
"start_date" => { :type => :date, :order => 11 },
|
||||
"due_date" => { :type => :date, :order => 12 },
|
||||
"done_ratio" => { :type => :integer, :order => 13 }}
|
||||
"estimated_hours" => { :type => :integer, :order => 13 },
|
||||
"done_ratio" => { :type => :integer, :order => 14 }}
|
||||
|
||||
user_values = []
|
||||
user_values << ["<< #{l(:label_me)} >>", "me"] if User.current.logged?
|
||||
@@ -166,29 +167,20 @@ class Query < ActiveRecord::Base
|
||||
@available_filters["author_id"] = { :type => :list, :order => 5, :values => user_values } unless user_values.empty?
|
||||
|
||||
if project
|
||||
# project specific filters
|
||||
@available_filters["category_id"] = { :type => :list_optional, :order => 6, :values => @project.issue_categories.collect{|s| [s.name, s.id.to_s] } }
|
||||
@available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => @project.versions.sort.collect{|s| [s.name, s.id.to_s] } }
|
||||
# project specific filters
|
||||
unless @project.issue_categories.empty?
|
||||
@available_filters["category_id"] = { :type => :list_optional, :order => 6, :values => @project.issue_categories.collect{|s| [s.name, s.id.to_s] } }
|
||||
end
|
||||
unless @project.versions.empty?
|
||||
@available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => @project.versions.sort.collect{|s| [s.name, s.id.to_s] } }
|
||||
end
|
||||
unless @project.active_children.empty?
|
||||
@available_filters["subproject_id"] = { :type => :list_subprojects, :order => 13, :values => @project.active_children.collect{|s| [s.name, s.id.to_s] } }
|
||||
end
|
||||
@project.all_custom_fields.select(&:is_filter?).each do |field|
|
||||
case field.field_format
|
||||
when "text"
|
||||
options = { :type => :text, :order => 20 }
|
||||
when "list"
|
||||
options = { :type => :list_optional, :values => field.possible_values, :order => 20}
|
||||
when "date"
|
||||
options = { :type => :date, :order => 20 }
|
||||
when "bool"
|
||||
options = { :type => :list, :values => [[l(:general_text_yes), "1"], [l(:general_text_no), "0"]], :order => 20 }
|
||||
else
|
||||
options = { :type => :string, :order => 20 }
|
||||
end
|
||||
@available_filters["cf_#{field.id}"] = options.merge({ :name => field.name })
|
||||
end
|
||||
# remove category filter if no category defined
|
||||
@available_filters.delete "category_id" if @available_filters["category_id"][:values].empty?
|
||||
add_custom_fields_filters(@project.all_issue_custom_fields)
|
||||
else
|
||||
# global filters for cross project issue list
|
||||
add_custom_fields_filters(IssueCustomField.find(:all, :conditions => {:is_filter => true, :is_for_all => true}))
|
||||
end
|
||||
@available_filters
|
||||
end
|
||||
@@ -227,7 +219,7 @@ class Query < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def label_for(field)
|
||||
label = @available_filters[field][:name] if @available_filters.has_key?(field)
|
||||
label = available_filters[field][:name] if available_filters.has_key?(field)
|
||||
label ||= field.gsub(/\_id$/, "")
|
||||
end
|
||||
|
||||
@@ -235,7 +227,7 @@ class Query < ActiveRecord::Base
|
||||
return @available_columns if @available_columns
|
||||
@available_columns = Query.available_columns
|
||||
@available_columns += (project ?
|
||||
project.all_custom_fields :
|
||||
project.all_issue_custom_fields :
|
||||
IssueCustomField.find(:all, :conditions => {:is_for_all => true})
|
||||
).collect {|cf| QueryCustomFieldColumn.new(cf) }
|
||||
end
|
||||
@@ -265,7 +257,7 @@ class Query < ActiveRecord::Base
|
||||
|
||||
def statement
|
||||
# project/subprojects clause
|
||||
clause = ''
|
||||
project_clauses = []
|
||||
if project && !@project.active_children.empty?
|
||||
ids = [project.id]
|
||||
if has_filter?("subproject_id")
|
||||
@@ -277,17 +269,16 @@ class Query < ActiveRecord::Base
|
||||
# main project only
|
||||
else
|
||||
# all subprojects
|
||||
ids += project.active_children.collect{|p| p.id}
|
||||
ids += project.child_ids
|
||||
end
|
||||
elsif Setting.display_subprojects_issues?
|
||||
ids += project.active_children.collect{|p| p.id}
|
||||
ids += project.child_ids
|
||||
end
|
||||
clause << "#{Issue.table_name}.project_id IN (%s)" % ids.join(',')
|
||||
project_clauses << "#{Issue.table_name}.project_id IN (%s)" % ids.join(',')
|
||||
elsif project
|
||||
clause << "#{Issue.table_name}.project_id = %d" % project.id
|
||||
else
|
||||
clause << Project.visible_by(User.current)
|
||||
project_clauses << "#{Issue.table_name}.project_id = %d" % project.id
|
||||
end
|
||||
project_clauses << Project.visible_by(User.current)
|
||||
|
||||
# filters clauses
|
||||
filters_clauses = []
|
||||
@@ -296,11 +287,13 @@ class Query < ActiveRecord::Base
|
||||
v = values_for(field).clone
|
||||
next unless v and !v.empty?
|
||||
|
||||
sql = ''
|
||||
sql = ''
|
||||
is_custom_filter = false
|
||||
if field =~ /^cf_(\d+)$/
|
||||
# custom field
|
||||
db_table = CustomValue.table_name
|
||||
db_field = 'value'
|
||||
is_custom_filter = true
|
||||
sql << "#{Issue.table_name}.id IN (SELECT #{Issue.table_name}.id FROM #{Issue.table_name} LEFT OUTER JOIN #{db_table} ON #{db_table}.customized_type='Issue' AND #{db_table}.customized_id=#{Issue.table_name}.id AND #{db_table}.custom_field_id=#{$1} WHERE "
|
||||
else
|
||||
# regular field
|
||||
@@ -320,9 +313,11 @@ class Query < ActiveRecord::Base
|
||||
when "!"
|
||||
sql = sql + "(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + "))"
|
||||
when "!*"
|
||||
sql = sql + "#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} = ''"
|
||||
sql = sql + "#{db_table}.#{db_field} IS NULL"
|
||||
sql << " OR #{db_table}.#{db_field} = ''" if is_custom_filter
|
||||
when "*"
|
||||
sql = sql + "#{db_table}.#{db_field} IS NOT NULL AND #{db_table}.#{db_field} <> ''"
|
||||
sql = sql + "#{db_table}.#{db_field} IS NOT NULL"
|
||||
sql << " AND #{db_table}.#{db_field} <> ''" if is_custom_filter
|
||||
when ">="
|
||||
sql = sql + "#{db_table}.#{db_field} >= #{v.first.to_i}"
|
||||
when "<="
|
||||
@@ -361,8 +356,28 @@ class Query < ActiveRecord::Base
|
||||
filters_clauses << sql
|
||||
end if filters and valid?
|
||||
|
||||
clause << ' AND ' unless clause.empty?
|
||||
clause << filters_clauses.join(' AND ') unless filters_clauses.empty?
|
||||
clause
|
||||
(project_clauses + filters_clauses).join(' AND ')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def add_custom_fields_filters(custom_fields)
|
||||
@available_filters ||= {}
|
||||
|
||||
custom_fields.select(&:is_filter?).each do |field|
|
||||
case field.field_format
|
||||
when "text"
|
||||
options = { :type => :text, :order => 20 }
|
||||
when "list"
|
||||
options = { :type => :list_optional, :values => field.possible_values, :order => 20}
|
||||
when "date"
|
||||
options = { :type => :date, :order => 20 }
|
||||
when "bool"
|
||||
options = { :type => :list, :values => [[l(:general_text_yes), "1"], [l(:general_text_no), "0"]], :order => 20 }
|
||||
else
|
||||
options = { :type => :string, :order => 20 }
|
||||
end
|
||||
@available_filters["cf_#{field.id}"] = options.merge({ :name => field.name })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,9 +17,16 @@
|
||||
|
||||
class Repository < ActiveRecord::Base
|
||||
belongs_to :project
|
||||
has_many :changesets, :dependent => :destroy, :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC"
|
||||
has_many :changesets, :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC"
|
||||
has_many :changes, :through => :changesets
|
||||
|
||||
|
||||
# Raw SQL to delete changesets and changes in the database
|
||||
# has_many :changesets, :dependent => :destroy is too slow for big repositories
|
||||
before_destroy :clear_changesets
|
||||
|
||||
# Checks if the SCM is enabled when creating a repository
|
||||
validate_on_create { |r| r.errors.add(:type, :activerecord_error_invalid) unless Setting.enabled_scm.include?(r.class.name.demodulize) }
|
||||
|
||||
# Removes leading and trailing whitespace
|
||||
def url=(arg)
|
||||
write_attribute(:url, arg ? arg.to_s.strip : nil)
|
||||
@@ -48,12 +55,24 @@ class Repository < ActiveRecord::Base
|
||||
scm.supports_annotate?
|
||||
end
|
||||
|
||||
def entry(path=nil, identifier=nil)
|
||||
scm.entry(path, identifier)
|
||||
end
|
||||
|
||||
def entries(path=nil, identifier=nil)
|
||||
scm.entries(path, identifier)
|
||||
end
|
||||
|
||||
def diff(path, rev, rev_to, type)
|
||||
scm.diff(path, rev, rev_to, type)
|
||||
def properties(path, identifier=nil)
|
||||
scm.properties(path, identifier)
|
||||
end
|
||||
|
||||
def cat(path, identifier=nil)
|
||||
scm.cat(path, identifier)
|
||||
end
|
||||
|
||||
def diff(path, rev, rev_to)
|
||||
scm.diff(path, rev, rev_to)
|
||||
end
|
||||
|
||||
# Default behaviour: we search in cached changesets
|
||||
@@ -64,6 +83,11 @@ class Repository < ActiveRecord::Base
|
||||
:order => "committed_on DESC, #{Changeset.table_name}.id DESC").collect(&:changeset)
|
||||
end
|
||||
|
||||
# Returns a path relative to the url of the repository
|
||||
def relative_path(path)
|
||||
path
|
||||
end
|
||||
|
||||
def latest_changeset
|
||||
@latest_changeset ||= changesets.find(:first)
|
||||
end
|
||||
@@ -107,4 +131,9 @@ class Repository < ActiveRecord::Base
|
||||
root_url.strip!
|
||||
true
|
||||
end
|
||||
|
||||
def clear_changesets
|
||||
connection.delete("DELETE FROM changes WHERE changes.changeset_id IN (SELECT changesets.id FROM changesets WHERE changesets.repository_id = #{id})")
|
||||
connection.delete("DELETE FROM changesets WHERE changesets.repository_id = #{id}")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -34,6 +34,11 @@ class Repository::Bazaar < Repository
|
||||
if entries
|
||||
entries.each do |e|
|
||||
next if e.lastrev.revision.blank?
|
||||
# Set the filesize unless browsing a specific revision
|
||||
if identifier.nil? && e.is_file?
|
||||
full_path = File.join(root_url, e.path)
|
||||
e.size = File.stat(full_path).size if File.file?(full_path)
|
||||
end
|
||||
c = Change.find(:first,
|
||||
:include => :changeset,
|
||||
:conditions => ["#{Change.table_name}.revision = ? and #{Changeset.table_name}.repository_id = ?", e.lastrev.revision, id],
|
||||
|
||||
@@ -29,9 +29,9 @@ class Repository::Cvs < Repository
|
||||
'CVS'
|
||||
end
|
||||
|
||||
def entry(path, identifier)
|
||||
e = entries(path, identifier)
|
||||
e ? e.first : nil
|
||||
def entry(path=nil, identifier=nil)
|
||||
rev = identifier.nil? ? nil : changesets.find_by_revision(identifier)
|
||||
scm.entry(path, rev.nil? ? nil : rev.committed_on)
|
||||
end
|
||||
|
||||
def entries(path=nil, identifier=nil)
|
||||
@@ -53,7 +53,12 @@ class Repository::Cvs < Repository
|
||||
entries
|
||||
end
|
||||
|
||||
def diff(path, rev, rev_to, type)
|
||||
def cat(path, identifier=nil)
|
||||
rev = identifier.nil? ? nil : changesets.find_by_revision(identifier)
|
||||
scm.cat(path, rev.nil? ? nil : rev.committed_on)
|
||||
end
|
||||
|
||||
def diff(path, rev, rev_to)
|
||||
#convert rev to revision. CVS can't handle changesets here
|
||||
diff=[]
|
||||
changeset_from=changesets.find_by_revision(rev)
|
||||
@@ -76,7 +81,8 @@ class Repository::Cvs < Repository
|
||||
unless revision_to
|
||||
revision_to=scm.get_previous_revision(revision_from)
|
||||
end
|
||||
diff=diff+scm.diff(change_from.path, revision_from, revision_to, type)
|
||||
file_diff = scm.diff(change_from.path, revision_from, revision_to)
|
||||
diff = diff + file_diff unless file_diff.nil?
|
||||
end
|
||||
end
|
||||
return diff
|
||||
@@ -103,7 +109,7 @@ class Repository::Cvs < Repository
|
||||
cs = changesets.find(:first, :conditions=>{
|
||||
:committed_on=>revision.time-time_delta..revision.time+time_delta,
|
||||
:committer=>revision.author,
|
||||
:comments=>revision.message
|
||||
:comments=>Changeset.normalize_comments(revision.message)
|
||||
})
|
||||
|
||||
# create a new changeset....
|
||||
|
||||
@@ -28,6 +28,11 @@ class Repository::Darcs < Repository
|
||||
'Darcs'
|
||||
end
|
||||
|
||||
def entry(path=nil, identifier=nil)
|
||||
patch = identifier.nil? ? nil : changesets.find_by_revision(identifier)
|
||||
scm.entry(path, patch.nil? ? nil : patch.scmid)
|
||||
end
|
||||
|
||||
def entries(path=nil, identifier=nil)
|
||||
patch = identifier.nil? ? nil : changesets.find_by_revision(identifier)
|
||||
entries = scm.entries(path, patch.nil? ? nil : patch.scmid)
|
||||
@@ -46,14 +51,19 @@ class Repository::Darcs < Repository
|
||||
entries
|
||||
end
|
||||
|
||||
def diff(path, rev, rev_to, type)
|
||||
def cat(path, identifier=nil)
|
||||
patch = identifier.nil? ? nil : changesets.find_by_revision(identifier)
|
||||
scm.cat(path, patch.nil? ? nil : patch.scmid)
|
||||
end
|
||||
|
||||
def diff(path, rev, rev_to)
|
||||
patch_from = changesets.find_by_revision(rev)
|
||||
return nil if patch_from.nil?
|
||||
patch_to = changesets.find_by_revision(rev_to) if rev_to
|
||||
if path.blank?
|
||||
path = patch_from.changes.collect{|change| change.path}.join(' ')
|
||||
end
|
||||
patch_from ? scm.diff(path, patch_from.scmid, patch_to ? patch_to.scmid : nil, type) : nil
|
||||
patch_from ? scm.diff(path, patch_from.scmid, patch_to ? patch_to.scmid : nil) : nil
|
||||
end
|
||||
|
||||
def fetch_changesets
|
||||
|
||||
43
groups/app/models/repository/filesystem.rb
Normal file
43
groups/app/models/repository/filesystem.rb
Normal file
@@ -0,0 +1,43 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
||||
#
|
||||
# FileSystem adapter
|
||||
# File written by Paul Rivier, at Demotera.
|
||||
#
|
||||
# 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 'redmine/scm/adapters/filesystem_adapter'
|
||||
|
||||
class Repository::Filesystem < Repository
|
||||
attr_protected :root_url
|
||||
validates_presence_of :url
|
||||
|
||||
def scm_adapter
|
||||
Redmine::Scm::Adapters::FilesystemAdapter
|
||||
end
|
||||
|
||||
def self.scm_name
|
||||
'Filesystem'
|
||||
end
|
||||
|
||||
def entries(path=nil, identifier=nil)
|
||||
scm.entries(path, identifier)
|
||||
end
|
||||
|
||||
def fetch_changesets
|
||||
nil
|
||||
end
|
||||
|
||||
end
|
||||
@@ -44,10 +44,8 @@ class Repository::Git < Repository
|
||||
scm_revision = scm_info.lastrev.scmid
|
||||
|
||||
unless changesets.find_by_scmid(scm_revision)
|
||||
|
||||
revisions = scm.revisions('', db_revision, nil)
|
||||
transaction do
|
||||
revisions.reverse_each do |revision|
|
||||
scm.revisions('', db_revision, nil, :reverse => true) do |revision|
|
||||
transaction do
|
||||
changeset = Changeset.create(:repository => self,
|
||||
:revision => revision.identifier,
|
||||
:scmid => revision.scmid,
|
||||
|
||||
@@ -35,6 +35,11 @@ class Repository::Subversion < Repository
|
||||
revisions ? changesets.find_all_by_revision(revisions.collect(&:identifier), :order => "committed_on DESC") : []
|
||||
end
|
||||
|
||||
# Returns a path relative to the url of the repository
|
||||
def relative_path(path)
|
||||
path.gsub(Regexp.new("^\/?#{Regexp.escape(relative_url)}"), '')
|
||||
end
|
||||
|
||||
def fetch_changesets
|
||||
scm_info = scm.info
|
||||
if scm_info
|
||||
@@ -71,4 +76,14 @@ class Repository::Subversion < Repository
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Returns the relative url of the repository
|
||||
# Eg: root_url = file:///var/svn/foo
|
||||
# url = file:///var/svn/foo/bar
|
||||
# => returns /bar
|
||||
def relative_url
|
||||
@relative_url ||= url.gsub(Regexp.new("^#{Regexp.escape(root_url)}"), '')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -33,6 +33,45 @@ class Setting < ActiveRecord::Base
|
||||
'%H:%M',
|
||||
'%I:%M %p'
|
||||
]
|
||||
|
||||
ENCODINGS = %w(US-ASCII
|
||||
windows-1250
|
||||
windows-1251
|
||||
windows-1252
|
||||
windows-1253
|
||||
windows-1254
|
||||
windows-1255
|
||||
windows-1256
|
||||
windows-1257
|
||||
windows-1258
|
||||
windows-31j
|
||||
ISO-2022-JP
|
||||
ISO-2022-KR
|
||||
ISO-8859-1
|
||||
ISO-8859-2
|
||||
ISO-8859-3
|
||||
ISO-8859-4
|
||||
ISO-8859-5
|
||||
ISO-8859-6
|
||||
ISO-8859-7
|
||||
ISO-8859-8
|
||||
ISO-8859-9
|
||||
ISO-8859-13
|
||||
ISO-8859-15
|
||||
KOI8-R
|
||||
UTF-8
|
||||
UTF-16
|
||||
UTF-16BE
|
||||
UTF-16LE
|
||||
EUC-JP
|
||||
Shift_JIS
|
||||
GB18030
|
||||
GBK
|
||||
ISCII91
|
||||
EUC-KR
|
||||
Big5
|
||||
Big5-HKSCS
|
||||
TIS-620)
|
||||
|
||||
cattr_accessor :available_settings
|
||||
@@available_settings = YAML::load(File.open("#{RAILS_ROOT}/config/settings.yml"))
|
||||
|
||||
@@ -24,11 +24,25 @@ class TimeEntry < ActiveRecord::Base
|
||||
belongs_to :activity, :class_name => 'Enumeration', :foreign_key => :activity_id
|
||||
|
||||
attr_protected :project_id, :user_id, :tyear, :tmonth, :tweek
|
||||
|
||||
acts_as_customizable
|
||||
acts_as_event :title => Proc.new {|o| "#{o.user}: #{lwr(:label_f_hour, o.hours)} (#{(o.issue || o.project).event_title})"},
|
||||
:url => Proc.new {|o| {:controller => 'timelog', :action => 'details', :project_id => o.project}},
|
||||
:author => :user,
|
||||
:description => :comments
|
||||
|
||||
validates_presence_of :user_id, :activity_id, :project_id, :hours, :spent_on
|
||||
validates_numericality_of :hours, :allow_nil => true
|
||||
validates_length_of :comments, :maximum => 255
|
||||
validates_length_of :comments, :maximum => 255, :allow_nil => true
|
||||
|
||||
def after_initialize
|
||||
if new_record? && self.activity.nil?
|
||||
if default_activity = Enumeration.default('ACTI')
|
||||
self.activity_id = default_activity.id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def before_validation
|
||||
self.project = issue.project if issue && project.nil?
|
||||
end
|
||||
|
||||
23
groups/app/models/time_entry_custom_field.rb
Normal file
23
groups/app/models/time_entry_custom_field.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 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
|
||||
# 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 TimeEntryCustomField < CustomField
|
||||
def type_name
|
||||
:label_spent_time
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,8 +19,6 @@ require "digest/sha1"
|
||||
|
||||
class User < ActiveRecord::Base
|
||||
|
||||
class OnTheFlyCreationFailure < Exception; end
|
||||
|
||||
# Account statuses
|
||||
STATUS_ANONYMOUS = 0
|
||||
STATUS_ACTIVE = 1
|
||||
@@ -39,17 +37,17 @@ class User < ActiveRecord::Base
|
||||
:as => :principal,
|
||||
:include => [ :project, :role ],
|
||||
:conditions => "#{Project.table_name}.status=#{Project::STATUS_ACTIVE}",
|
||||
:order => "#{Project.table_name}.name, inherited_from ASC",
|
||||
:dependent => :delete_all
|
||||
|
||||
:order => "#{Project.table_name}.name, inherited_from ASC"
|
||||
has_many :members, :as => :principal, :dependent => :delete_all
|
||||
has_many :projects, :through => :memberships
|
||||
has_many :custom_values, :dependent => :delete_all, :as => :customized
|
||||
has_many :issue_categories, :foreign_key => 'assigned_to_id', :dependent => :nullify
|
||||
has_one :preference, :dependent => :destroy, :class_name => 'UserPreference'
|
||||
has_one :rss_token, :dependent => :destroy, :class_name => 'Token', :conditions => "action='feeds'"
|
||||
belongs_to :auth_source
|
||||
belongs_to :group
|
||||
|
||||
acts_as_customizable
|
||||
|
||||
attr_accessor :password, :password_confirmation
|
||||
attr_accessor :last_before_login_on
|
||||
# Prevents unauthorized assignments
|
||||
@@ -61,13 +59,12 @@ class User < ActiveRecord::Base
|
||||
# Login must contain lettres, numbers, underscores only
|
||||
validates_format_of :login, :with => /^[a-z0-9_\-@\.]*$/i
|
||||
validates_length_of :login, :maximum => 30
|
||||
validates_format_of :firstname, :lastname, :with => /^[\w\s\'\-]*$/i
|
||||
validates_format_of :firstname, :lastname, :with => /^[\w\s\'\-\.]*$/i
|
||||
validates_length_of :firstname, :lastname, :maximum => 30
|
||||
validates_format_of :mail, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :allow_nil => true
|
||||
validates_length_of :mail, :maximum => 60, :allow_nil => true
|
||||
validates_length_of :password, :minimum => 4, :allow_nil => true
|
||||
validates_confirmation_of :password, :allow_nil => true
|
||||
validates_associated :custom_values, :on => :update
|
||||
|
||||
def before_create
|
||||
self.mail_notification = false
|
||||
@@ -96,6 +93,7 @@ class User < ActiveRecord::Base
|
||||
|
||||
def group_id=(gid)
|
||||
@group_changed = true unless gid == group_id
|
||||
group_id_will_change!
|
||||
write_attribute(:group_id, gid)
|
||||
end
|
||||
|
||||
@@ -130,19 +128,16 @@ class User < ActiveRecord::Base
|
||||
# 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])
|
||||
user = new(*attrs)
|
||||
user.login = login
|
||||
user.language = Setting.default_language
|
||||
if user.save
|
||||
user.reload
|
||||
logger.info("User '#{user.login}' created from the LDAP") if logger
|
||||
else
|
||||
logger.error("User '#{onthefly.login}' found in LDAP but could not be created (#{onthefly.errors.full_messages.join(', ')})") if logger
|
||||
raise OnTheFlyCreationFailure.new
|
||||
end
|
||||
end
|
||||
end
|
||||
user.update_attribute(:last_login_on, Time.now) if user
|
||||
user.update_attribute(:last_login_on, Time.now) if user && !user.new_record?
|
||||
user
|
||||
rescue => text
|
||||
raise text
|
||||
@@ -228,6 +223,10 @@ class User < ActiveRecord::Base
|
||||
true
|
||||
end
|
||||
|
||||
def anonymous?
|
||||
!logged?
|
||||
end
|
||||
|
||||
# Return user's role for project
|
||||
def role_for_project(project)
|
||||
# No role on archived projects
|
||||
@@ -285,13 +284,12 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.anonymous
|
||||
return @anonymous_user if @anonymous_user
|
||||
anonymous_user = AnonymousUser.find(:first)
|
||||
if anonymous_user.nil?
|
||||
anonymous_user = AnonymousUser.create(:lastname => 'Anonymous', :firstname => '', :mail => '', :login => '', :status => 0)
|
||||
raise 'Unable to create the anonymous user.' if anonymous_user.new_record?
|
||||
end
|
||||
@anonymous_user = anonymous_user
|
||||
anonymous_user
|
||||
end
|
||||
|
||||
private
|
||||
@@ -308,6 +306,10 @@ class AnonymousUser < User
|
||||
errors.add_to_base 'An anonymous user already exists.' if AnonymousUser.find(:first)
|
||||
end
|
||||
|
||||
def available_custom_fields
|
||||
[]
|
||||
end
|
||||
|
||||
# Overrides a few properties
|
||||
def logged?; false end
|
||||
def admin; false end
|
||||
|
||||
@@ -42,8 +42,10 @@ class UserPreference < ActiveRecord::Base
|
||||
if attribute_present? attr_name
|
||||
super
|
||||
else
|
||||
self.others ||= {}
|
||||
self.others.store attr_name, value
|
||||
h = read_attribute(:others).dup || {}
|
||||
h.update(attr_name => value)
|
||||
write_attribute(:others, h)
|
||||
value
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -19,5 +19,12 @@ class Watcher < ActiveRecord::Base
|
||||
belongs_to :watchable, :polymorphic => true
|
||||
belongs_to :user
|
||||
|
||||
validates_presence_of :user
|
||||
validates_uniqueness_of :user_id, :scope => [:watchable_type, :watchable_id]
|
||||
|
||||
protected
|
||||
|
||||
def validate
|
||||
errors.add :user_id, :activerecord_error_invalid unless user.nil? || user.active?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
class Wiki < ActiveRecord::Base
|
||||
belongs_to :project
|
||||
has_many :pages, :class_name => 'WikiPage', :dependent => :destroy
|
||||
has_many :pages, :class_name => 'WikiPage', :dependent => :destroy, :order => 'title'
|
||||
has_many :redirects, :class_name => 'WikiRedirect', :dependent => :delete_all
|
||||
|
||||
validates_presence_of :start_page
|
||||
|
||||
@@ -35,6 +35,17 @@ class WikiContent < ActiveRecord::Base
|
||||
:type => 'wiki-page',
|
||||
:url => Proc.new {|o| {:controller => 'wiki', :id => o.page.wiki.project_id, :page => o.page.title, :version => o.version}}
|
||||
|
||||
acts_as_activity_provider :type => 'wiki_pages',
|
||||
:timestamp => "#{WikiContent.versioned_table_name}.updated_on",
|
||||
:permission => :view_wiki_pages,
|
||||
:find_options => {:select => "#{WikiContent.versioned_table_name}.updated_on, #{WikiContent.versioned_table_name}.comments, " +
|
||||
"#{WikiContent.versioned_table_name}.#{WikiContent.version_column}, #{WikiPage.table_name}.title, " +
|
||||
"#{WikiContent.versioned_table_name}.page_id, #{WikiContent.versioned_table_name}.author_id, " +
|
||||
"#{WikiContent.versioned_table_name}.id",
|
||||
:joins => "LEFT JOIN #{WikiPage.table_name} ON #{WikiPage.table_name}.id = #{WikiContent.versioned_table_name}.page_id " +
|
||||
"LEFT JOIN #{Wiki.table_name} ON #{Wiki.table_name}.id = #{WikiPage.table_name}.wiki_id " +
|
||||
"LEFT JOIN #{Project.table_name} ON #{Project.table_name}.id = #{Wiki.table_name}.project_id"}
|
||||
|
||||
def text=(plain)
|
||||
case Setting.wiki_compression
|
||||
when 'gzip'
|
||||
|
||||
@@ -22,14 +22,15 @@ class WikiPage < ActiveRecord::Base
|
||||
belongs_to :wiki
|
||||
has_one :content, :class_name => 'WikiContent', :foreign_key => 'page_id', :dependent => :destroy
|
||||
has_many :attachments, :as => :container, :dependent => :destroy
|
||||
|
||||
acts_as_tree :order => 'title'
|
||||
|
||||
acts_as_event :title => Proc.new {|o| "#{l(:label_wiki)}: #{o.title}"},
|
||||
:description => :text,
|
||||
:datetime => :created_on,
|
||||
:url => Proc.new {|o| {:controller => 'wiki', :id => o.wiki.project_id, :page => o.title}}
|
||||
|
||||
acts_as_searchable :columns => ['title', 'text'],
|
||||
:include => [:wiki, :content],
|
||||
:include => [{:wiki => :project}, :content],
|
||||
:project_key => "#{Wiki.table_name}.project_id"
|
||||
|
||||
attr_accessor :redirect_existing_links
|
||||
@@ -105,6 +106,29 @@ class WikiPage < ActiveRecord::Base
|
||||
def text
|
||||
content.text if content
|
||||
end
|
||||
|
||||
# Returns true if usr is allowed to edit the page, otherwise false
|
||||
def editable_by?(usr)
|
||||
!protected? || usr.allowed_to?(:protect_wiki_pages, wiki.project)
|
||||
end
|
||||
|
||||
def parent_title
|
||||
@parent_title || (self.parent && self.parent.pretty_title)
|
||||
end
|
||||
|
||||
def parent_title=(t)
|
||||
@parent_title = t
|
||||
parent_page = t.blank? ? nil : self.wiki.find_page(t)
|
||||
self.parent = parent_page
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def validate
|
||||
errors.add(:parent_title, :activerecord_error_invalid) if !@parent_title.blank? && parent.nil?
|
||||
errors.add(:parent_title, :activerecord_error_circular_dependency) if parent && (parent == self || parent.ancestors.include?(self))
|
||||
errors.add(:parent_title, :activerecord_error_not_same_project) if parent && (parent.wiki_id != wiki_id)
|
||||
end
|
||||
end
|
||||
|
||||
class WikiDiff
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<div id="login-form">
|
||||
<% form_tag({:action=> "login"}) do %>
|
||||
<%= back_url_hidden_field_tag %>
|
||||
<table>
|
||||
<tr>
|
||||
<td align="right"><label for="username"><%=l(:field_login)%>:</label></td>
|
||||
|
||||
@@ -5,8 +5,9 @@
|
||||
|
||||
<div class="box">
|
||||
<!--[form:user]-->
|
||||
<% if @user.auth_source_id.nil? %>
|
||||
<p><label for="user_login"><%=l(:field_login)%> <span class="required">*</span></label>
|
||||
<%= text_field 'user', 'login', :size => 25 %></p>
|
||||
<%= text_field 'user', 'login', :size => 25 %></p>
|
||||
|
||||
<p><label for="password"><%=l(:field_password)%> <span class="required">*</span></label>
|
||||
<%= password_field_tag 'password', nil, :size => 25 %><br />
|
||||
@@ -14,6 +15,7 @@
|
||||
|
||||
<p><label for="password_confirmation"><%=l(:field_password_confirmation)%> <span class="required">*</span></label>
|
||||
<%= password_field_tag 'password_confirmation', nil, :size => 25 %></p>
|
||||
<% end %>
|
||||
|
||||
<p><label for="user_firstname"><%=l(:field_firstname)%> <span class="required">*</span></label>
|
||||
<%= text_field 'user', 'firstname' %></p>
|
||||
@@ -27,8 +29,8 @@
|
||||
<p><label for="user_language"><%=l(:field_language)%></label>
|
||||
<%= select("user", "language", lang_options_for_select) %></p>
|
||||
|
||||
<% for @custom_value in @custom_values %>
|
||||
<p><%= custom_field_tag_with_label @custom_value %></p>
|
||||
<% @user.custom_field_values.each do |value| %>
|
||||
<p><%= custom_field_tag_with_label :user, value %></p>
|
||||
<% end %>
|
||||
<!--[eoform:user]-->
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
<div class="contextual">
|
||||
<%= link_to(l(:button_edit), {:controller => 'users', :action => 'edit', :id => @user}, :class => 'icon icon-edit') if User.current.admin? %>
|
||||
</div>
|
||||
|
||||
<h2><%=h @user.name %></h2>
|
||||
|
||||
<p>
|
||||
<%= mail_to @user.mail unless @user.pref.hide_mail %>
|
||||
<%= mail_to(h(@user.mail)) unless @user.pref.hide_mail %>
|
||||
<ul>
|
||||
<li><%=l(:label_registered_on)%>: <%= format_date(@user.created_on) %></li>
|
||||
<% for custom_value in @custom_values %>
|
||||
@@ -16,8 +20,8 @@
|
||||
<h3><%=l(:label_project_plural)%></h3>
|
||||
<ul>
|
||||
<% for membership in @memberships %>
|
||||
<li><%= link_to membership.project.name, :controller => 'projects', :action => 'show', :id => membership.project %>
|
||||
(<%= membership.role.name %>, <%= format_date(membership.created_on) %>)</li>
|
||||
<li><%= link_to(h(membership.project.name), :controller => 'projects', :action => 'show', :id => membership.project) %>
|
||||
(<%=h membership.role.name %>, <%= format_date(membership.created_on) %>)</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="attachments">
|
||||
<% for attachment in attachments %>
|
||||
<p><%= link_to attachment.filename, {:controller => 'attachments', :action => 'download', :id => attachment }, :class => 'icon icon-attachment' -%>
|
||||
<p><%= link_to_attachment attachment, :class => 'icon icon-attachment' -%>
|
||||
<%= h(" - #{attachment.description}") unless attachment.description.blank? %>
|
||||
<span class="size">(<%= number_to_human_size attachment.filesize %>)</span>
|
||||
<% if options[:delete_url] %>
|
||||
|
||||
15
groups/app/views/attachments/diff.rhtml
Normal file
15
groups/app/views/attachments/diff.rhtml
Normal file
@@ -0,0 +1,15 @@
|
||||
<h2><%=h @attachment.filename %></h2>
|
||||
|
||||
<div class="attachments">
|
||||
<p><%= h("#{@attachment.description} - ") unless @attachment.description.blank? %>
|
||||
<span class="author"><%= @attachment.author %>, <%= format_time(@attachment.created_on) %></span></p>
|
||||
<p><%= link_to_attachment @attachment, :text => l(:button_download), :download => true -%>
|
||||
<span class="size">(<%= number_to_human_size @attachment.filesize %>)</span></p>
|
||||
|
||||
</div>
|
||||
|
||||
<%= render :partial => 'common/diff', :locals => {:diff => @diff, :diff_type => @diff_type} %>
|
||||
|
||||
<% content_for :header_tags do -%>
|
||||
<%= stylesheet_link_tag "scm" -%>
|
||||
<% end -%>
|
||||
15
groups/app/views/attachments/file.rhtml
Normal file
15
groups/app/views/attachments/file.rhtml
Normal file
@@ -0,0 +1,15 @@
|
||||
<h2><%=h @attachment.filename %></h2>
|
||||
|
||||
<div class="attachments">
|
||||
<p><%= h("#{@attachment.description} - ") unless @attachment.description.blank? %>
|
||||
<span class="author"><%= @attachment.author %>, <%= format_time(@attachment.created_on) %></span></p>
|
||||
<p><%= link_to_attachment @attachment, :text => l(:button_download), :download => true -%>
|
||||
<span class="size">(<%= number_to_human_size @attachment.filesize %>)</span></p>
|
||||
|
||||
</div>
|
||||
|
||||
<%= render :partial => 'common/file', :locals => {:content => @content, :filename => @attachment.filename} %>
|
||||
|
||||
<% content_for :header_tags do -%>
|
||||
<%= stylesheet_link_tag "scm" -%>
|
||||
<% end -%>
|
||||
@@ -22,14 +22,12 @@
|
||||
|
||||
<p><label for="auth_source_base_dn"><%=l(:field_base_dn)%> <span class="required">*</span></label>
|
||||
<%= text_field 'auth_source', 'base_dn', :size => 60 %></p>
|
||||
</div>
|
||||
|
||||
<div class="box">
|
||||
<p><label for="auth_source_onthefly_register"><%=l(:field_onthefly)%></label>
|
||||
<%= check_box 'auth_source', 'onthefly_register' %></p>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<fieldset><legend><%=l(:label_attribute_plural)%></legend>
|
||||
<fieldset class="box"><legend><%=l(:label_attribute_plural)%></legend>
|
||||
<p><label for="auth_source_attr_login"><%=l(:field_login)%> <span class="required">*</span></label>
|
||||
<%= text_field 'auth_source', 'attr_login', :size => 20 %></p>
|
||||
|
||||
@@ -42,7 +40,5 @@
|
||||
<p><label for="auth_source_attr_mail"><%=l(:field_mail)%></label>
|
||||
<%= text_field 'auth_source', 'attr_mail', :size => 20 %></p>
|
||||
</fieldset>
|
||||
</p>
|
||||
</div>
|
||||
<!--[eoform:auth_source]-->
|
||||
|
||||
|
||||
@@ -38,3 +38,5 @@
|
||||
<% content_for :header_tags do %>
|
||||
<%= auto_discovery_link_tag(:atom, {:controller => 'projects', :action => 'activity', :id => @project, :format => 'atom', :show_messages => 1, :key => User.current.rss_key}) %>
|
||||
<% end %>
|
||||
|
||||
<% html_title l(:label_board_plural) %>
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<th><%= l(:field_subject) %></th>
|
||||
<th><%= l(:field_author) %></th>
|
||||
<%= sort_header_tag("#{Message.table_name}.created_on", :caption => l(:field_created_on)) %>
|
||||
<th><%= l(:label_reply_plural) %></th>
|
||||
<%= sort_header_tag("#{Message.table_name}.replies_count", :caption => l(:label_reply_plural)) %>
|
||||
<%= sort_header_tag("#{Message.table_name}.updated_on", :caption => l(:label_message_last)) %>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
@@ -57,3 +57,5 @@
|
||||
<% else %>
|
||||
<p class="nodata"><%= l(:label_no_data) %></p>
|
||||
<% end %>
|
||||
|
||||
<% html_title h(@board.name) %>
|
||||
|
||||
64
groups/app/views/common/_diff.rhtml
Normal file
64
groups/app/views/common/_diff.rhtml
Normal file
@@ -0,0 +1,64 @@
|
||||
<% Redmine::UnifiedDiff.new(diff, diff_type).each do |table_file| -%>
|
||||
<div class="autoscroll">
|
||||
<% if diff_type == 'sbs' -%>
|
||||
<table class="filecontent CodeRay">
|
||||
<thead>
|
||||
<tr><th colspan="4" class="filename"><%= table_file.file_name %></th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% prev_line_left, prev_line_right = nil, nil -%>
|
||||
<% table_file.keys.sort.each do |key| -%>
|
||||
<% if prev_line_left && prev_line_right && (table_file[key].nb_line_left != prev_line_left+1) && (table_file[key].nb_line_right != prev_line_right+1) -%>
|
||||
<tr class="spacing">
|
||||
<th class="line-num">...</th><td></td><th class="line-num">...</th><td></td>
|
||||
<% end -%>
|
||||
<tr>
|
||||
<th class="line-num"><%= table_file[key].nb_line_left %></th>
|
||||
<td class="line-code <%= table_file[key].type_diff_left %>">
|
||||
<pre><%=to_utf8 table_file[key].line_left %></pre>
|
||||
</td>
|
||||
<th class="line-num"><%= table_file[key].nb_line_right %></th>
|
||||
<td class="line-code <%= table_file[key].type_diff_right %>">
|
||||
<pre><%=to_utf8 table_file[key].line_right %></pre>
|
||||
</td>
|
||||
</tr>
|
||||
<% prev_line_left, prev_line_right = table_file[key].nb_line_left.to_i, table_file[key].nb_line_right.to_i -%>
|
||||
<% end -%>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<% else -%>
|
||||
<table class="filecontent CodeRay">
|
||||
<thead>
|
||||
<tr><th colspan="3" class="filename"><%= table_file.file_name %></th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% prev_line_left, prev_line_right = nil, nil -%>
|
||||
<% table_file.keys.sort.each do |key, line| %>
|
||||
<% if prev_line_left && prev_line_right && (table_file[key].nb_line_left != prev_line_left+1) && (table_file[key].nb_line_right != prev_line_right+1) -%>
|
||||
<tr class="spacing">
|
||||
<th class="line-num">...</th><th class="line-num">...</th><td></td>
|
||||
</tr>
|
||||
<% end -%>
|
||||
<tr>
|
||||
<th class="line-num"><%= table_file[key].nb_line_left %></th>
|
||||
<th class="line-num"><%= table_file[key].nb_line_right %></th>
|
||||
<% if table_file[key].line_left.empty? -%>
|
||||
<td class="line-code <%= table_file[key].type_diff_right %>">
|
||||
<pre><%=to_utf8 table_file[key].line_right %></pre>
|
||||
</td>
|
||||
<% else -%>
|
||||
<td class="line-code <%= table_file[key].type_diff_left %>">
|
||||
<pre><%=to_utf8 table_file[key].line_left %></pre>
|
||||
</td>
|
||||
<% end -%>
|
||||
</tr>
|
||||
<% prev_line_left = table_file[key].nb_line_left.to_i if table_file[key].nb_line_left.to_i > 0 -%>
|
||||
<% prev_line_right = table_file[key].nb_line_right.to_i if table_file[key].nb_line_right.to_i > 0 -%>
|
||||
<% end -%>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end -%>
|
||||
|
||||
</div>
|
||||
<% end -%>
|
||||
11
groups/app/views/common/_file.rhtml
Normal file
11
groups/app/views/common/_file.rhtml
Normal file
@@ -0,0 +1,11 @@
|
||||
<div class="autoscroll">
|
||||
<table class="filecontent CodeRay">
|
||||
<tbody>
|
||||
<% line_num = 1 %>
|
||||
<% syntax_highlight(filename, to_utf8(content)).each_line do |line| %>
|
||||
<tr><th class="line-num" id="L<%= line_num %>"><%= line_num %></th><td class="line-code"><pre><%= line %></pre></td></tr>
|
||||
<% line_num += 1 %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -1,3 +1,3 @@
|
||||
<fieldset class="preview"><legend><%= l(:label_preview) %></legend>
|
||||
<%= textilizable @text, :attachments => @attachements %>
|
||||
<%= textilizable @text, :attachments => @attachements, :object => @previewed %>
|
||||
</fieldset>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
xml.instruct!
|
||||
xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
|
||||
xml.title @title
|
||||
xml.title truncate_single_line(@title, 100)
|
||||
xml.link "rel" => "self", "href" => url_for(params.merge({:format => nil, :only_path => false}))
|
||||
xml.link "rel" => "alternate", "href" => url_for(:controller => 'welcome', :only_path => false)
|
||||
xml.id url_for(:controller => 'welcome', :only_path => false)
|
||||
@@ -10,11 +10,15 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
|
||||
@items.each do |item|
|
||||
xml.entry do
|
||||
url = url_for(item.event_url(:only_path => false))
|
||||
xml.title truncate(item.event_title, 100)
|
||||
if @project
|
||||
xml.title truncate_single_line(item.event_title, 100)
|
||||
else
|
||||
xml.title truncate_single_line("#{item.project} - #{item.event_title}", 100)
|
||||
end
|
||||
xml.link "rel" => "alternate", "href" => url
|
||||
xml.id url
|
||||
xml.updated item.event_datetime.xmlschema
|
||||
author = item.event_author if item.respond_to?(:author)
|
||||
author = item.event_author if item.respond_to?(:event_author)
|
||||
xml.author do
|
||||
xml.name(author)
|
||||
xml.email(author.mail) if author.respond_to?(:mail) && !author.mail.blank?
|
||||
|
||||
@@ -102,6 +102,9 @@ when "IssueCustomField" %>
|
||||
<% else %>
|
||||
<p><%= f.check_box :is_required %></p>
|
||||
|
||||
<% when "TimeEntryCustomField" %>
|
||||
<p><%= f.check_box :is_required %></p>
|
||||
|
||||
<% end %>
|
||||
</div>
|
||||
<%= javascript_tag "toggle_custom_field_format();" %>
|
||||
|
||||
12
groups/app/views/enumerations/destroy.rhtml
Normal file
12
groups/app/views/enumerations/destroy.rhtml
Normal file
@@ -0,0 +1,12 @@
|
||||
<h2><%= l(@enumeration.option_name) %>: <%=h @enumeration %></h2>
|
||||
|
||||
<% form_tag({}) do %>
|
||||
<div class="box">
|
||||
<p><strong><%= l(:text_enumeration_destroy_question, @enumeration.objects_count) %></strong></p>
|
||||
<p><%= l(:text_enumeration_category_reassign_to) %>
|
||||
<%= select_tag 'reassign_to_id', ("<option>--- #{l(:actionview_instancetag_blank_option)} ---</option>" + options_from_collection_for_select(@enumerations, 'id', 'name')) %></p>
|
||||
</div>
|
||||
|
||||
<%= submit_tag l(:button_apply) %>
|
||||
<%= link_to l(:button_cancel), :controller => 'enumerations', :action => 'index' %>
|
||||
<% end %>
|
||||
@@ -1,14 +1,14 @@
|
||||
<h2><%=l(:label_enumerations)%></h2>
|
||||
|
||||
<% Enumeration::OPTIONS.each do |option, name| %>
|
||||
<h3><%= l(name) %></h3>
|
||||
<% Enumeration::OPTIONS.each do |option, params| %>
|
||||
<h3><%= l(params[:label]) %></h3>
|
||||
|
||||
<% enumerations = Enumeration.get_values(option) %>
|
||||
<% if enumerations.any? %>
|
||||
<table class="list">
|
||||
<% enumerations.each do |enumeration| %>
|
||||
<tr class="<%= cycle('odd', 'even') %>">
|
||||
<td><%= link_to enumeration.name, :action => 'edit', :id => enumeration %></td>
|
||||
<td><%= link_to h(enumeration), :action => 'edit', :id => enumeration %></td>
|
||||
<td style="width:15%;"><%= image_tag('true.png') if enumeration.is_default? %></td>
|
||||
<td style="width:15%;">
|
||||
<%= link_to image_tag('2uparrow.png', :alt => l(:label_sort_highest)), {:action => 'move', :id => enumeration, :position => 'highest'}, :method => :post, :title => l(:label_sort_highest) %>
|
||||
@@ -16,6 +16,9 @@
|
||||
<%= link_to image_tag('1downarrow.png', :alt => l(:label_sort_lower)), {:action => 'move', :id => enumeration, :position => 'lower'}, :method => :post, :title => l(:label_sort_lower) %>
|
||||
<%= link_to image_tag('2downarrow.png', :alt => l(:label_sort_lowest)), {:action => 'move', :id => enumeration, :position => 'lowest'}, :method => :post, :title => l(:label_sort_lowest) %>
|
||||
</td>
|
||||
<td align="center" style="width:10%;">
|
||||
<%= link_to l(:button_delete), { :action => 'destroy', :id => enumeration }, :method => :post, :confirm => l(:text_are_you_sure), :class => "icon icon-del" %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
:class => nil,
|
||||
:multipart => true} do |f| %>
|
||||
<%= error_messages_for 'issue' %>
|
||||
<%= error_messages_for 'time_entry' %>
|
||||
<div class="box">
|
||||
<% if @edit_allowed || !@allowed_statuses.empty? %>
|
||||
<fieldset class="tabular"><legend><%= l(:label_change_properties) %>
|
||||
@@ -21,9 +22,12 @@
|
||||
<p><%= time_entry.text_field :hours, :size => 6, :label => :label_spent_time %> <%= l(:field_hours) %></p>
|
||||
</div>
|
||||
<div class="splitcontentright">
|
||||
<p><%= time_entry.text_field :comments, :size => 40 %></p>
|
||||
<p><%= time_entry.select :activity_id, (@activities.collect {|p| [p.name, p.id]}) %></p>
|
||||
<p><%= time_entry.select :activity_id, activity_collection_for_select_options %></p>
|
||||
</div>
|
||||
<p><%= time_entry.text_field :comments, :size => 60 %></p>
|
||||
<% @time_entry.custom_field_values.each do |value| %>
|
||||
<p><%= custom_field_tag_with_label :time_entry, value %></p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user