diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index b0a5b42a7..5fa56b167 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -83,9 +83,9 @@ class AccountController < ApplicationController else @user = User.new(params[:user]) @user.admin = false - @user.status = User::STATUS_REGISTERED + @user.register if session[:auth_source_registration] - @user.status = User::STATUS_ACTIVE + @user.activate @user.login = session[:auth_source_registration][:login] @user.auth_source_id = session[:auth_source_registration][:auth_source_id] if @user.save @@ -116,8 +116,8 @@ class AccountController < ApplicationController token = Token.find_by_action_and_value('register', params[:token]) redirect_to(home_url) && return unless token and !token.expired? user = token.user - redirect_to(home_url) && return unless user.status == User::STATUS_REGISTERED - user.status = User::STATUS_ACTIVE + redirect_to(home_url) && return unless user.registered? + user.activate if user.save token.destroy flash[:notice] = l(:notice_account_activated) @@ -170,7 +170,7 @@ class AccountController < ApplicationController user.mail = registration['email'] unless registration['email'].nil? user.firstname, user.lastname = registration['fullname'].split(' ') unless registration['fullname'].nil? user.random_password - user.status = User::STATUS_REGISTERED + user.register case Setting.self_registration when '1' @@ -241,7 +241,7 @@ class AccountController < ApplicationController # Pass a block for behavior when a user fails to save def register_automatically(user, &block) # Automatic activation - user.status = User::STATUS_ACTIVE + user.activate user.last_login_on = Time.now if user.save self.logged_user = user diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6e5634dbc..c00b6ba42 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -218,6 +218,10 @@ class ApplicationController < ActionController::Base end end + def back_url + params[:back_url] || request.env['HTTP_REFERER'] + end + def redirect_back_or_default(default) back_url = CGI.unescape(params[:back_url].to_s) if !back_url.blank? diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 8b5d73fa3..7fb4148ed 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -20,7 +20,7 @@ class IssuesController < ApplicationController default_search_scope :issues before_filter :find_issue, :only => [:show, :edit, :update, :reply] - before_filter :find_issues, :only => [:bulk_edit, :move, :destroy] + before_filter :find_issues, :only => [:bulk_edit, :move, :perform_move, :destroy] before_filter :find_project, :only => [:new, :create, :update_form, :preview, :auto_complete] before_filter :authorize, :except => [:index, :changes, :preview, :context_menu] before_filter :find_optional_project, :only => [:index, :changes] @@ -264,15 +264,9 @@ class IssuesController < ApplicationController moved_issues = [] @issues.each do |issue| issue.reload - changed_attributes = {} - [:assigned_to_id, :status_id, :start_date, :due_date].each do |valid_attribute| - unless params[valid_attribute].blank? - changed_attributes[valid_attribute] = (params[valid_attribute] == 'none' ? nil : params[valid_attribute]) - end - end issue.init_journal(User.current) call_hook(:controller_issues_move_before_save, { :params => params, :issue => issue, :target_project => @target_project, :copy => !!@copy }) - if r = issue.move_to_project(@target_project, new_tracker, {:copy => @copy, :attributes => changed_attributes}) + if r = issue.move_to_project(@target_project, new_tracker, {:copy => @copy, :attributes => extract_changed_attributes_for_move(params)}) moved_issues << r else unsaved_issue_ids << issue.id @@ -293,6 +287,11 @@ class IssuesController < ApplicationController end render :layout => false if request.xhr? end + + # TODO: more descriptive name? move to separate controller like IssueMovesController? + def perform_move + move + end def destroy @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f @@ -349,7 +348,7 @@ class IssuesController < ApplicationController @priorities = IssuePriority.all.reverse @statuses = IssueStatus.find(:all, :order => 'position') - @back = params[:back_url] || request.env['HTTP_REFERER'] + @back = back_url render :layout => false end @@ -485,4 +484,14 @@ private return false end end + + def extract_changed_attributes_for_move(params) + changed_attributes = {} + [:assigned_to_id, :status_id, :start_date, :due_date].each do |valid_attribute| + unless params[valid_attribute].blank? + changed_attributes[valid_attribute] = (params[valid_attribute] == 'none' ? nil : params[valid_attribute]) + end + end + changed_attributes + end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e40758969..2c334b7f0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -103,6 +103,23 @@ module ApplicationHelper link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => revision}, :title => l(:label_revision_id, revision)) end + # Generates a link to a project if active + # Examples: + # + # link_to_project(project) # => link to the specified project overview + # link_to_project(project, :action=>'settings') # => link to project settings + # link_to_project(project, {:only_path => false}, :class => "project") # => 3rd arg adds html options + # link_to_project(project, {}, :class => "project") # => html options with default url (project overview) + # + def link_to_project(project, options={}, html_options = nil) + if project.active? + url = {:controller => 'projects', :action => 'show', :id => project}.merge(options) + link_to(h(project), url, html_options) + else + h(project) + end + end + def toggle_link(name, id, options={}) onclick = "Element.toggle('#{id}'); " onclick << (options[:focus] ? "Form.Element.focus('#{options[:focus]}'); " : "this.blur(); ") @@ -368,12 +385,12 @@ module ApplicationHelper ancestors = (@project.root? ? [] : @project.ancestors.visible) if ancestors.any? root = ancestors.shift - b << link_to(h(root), {:controller => 'projects', :action => 'show', :id => root, :jump => current_menu_item}, :class => 'root') + b << link_to_project(root, {:jump => current_menu_item}, :class => 'root') if ancestors.size > 2 b << '…' ancestors = ancestors[-2, 2] end - b += ancestors.collect {|p| link_to(h(p), {:controller => 'projects', :action => 'show', :id => p, :jump => current_menu_item}, :class => 'ancestor') } + b += ancestors.collect {|p| link_to_project(p, {:jump => current_menu_item}, :class => 'ancestor') } end b << h(@project) b.join(' » ') @@ -393,6 +410,19 @@ module ApplicationHelper end end + # Returns the theme, controller name, and action as css classes for the + # HTML body. + def body_css_classes + css = [] + if theme = Redmine::Themes.theme(Setting.ui_theme) + css << 'theme-' + theme.name + end + + css << 'controller-' + params[:controller] + css << 'action-' + params[:action] + css.join(' ') + end + def accesskey(s) Redmine::AccessKeys.key_for s end @@ -592,8 +622,7 @@ module ApplicationHelper end when 'project' if p = Project.visible.find_by_id(oid) - link = link_to h(p.name), {:only_path => only_path, :controller => 'projects', :action => 'show', :id => p}, - :class => 'project' + link = link_to_project(p, {:only_path => only_path}, :class => 'project') end end elsif sep == ':' @@ -635,8 +664,7 @@ module ApplicationHelper end when 'project' if p = Project.visible.find(:first, :conditions => ["identifier = :s OR LOWER(name) = :s", {:s => name.downcase}]) - link = link_to h(p.name), {:only_path => only_path, :controller => 'projects', :action => 'show', :id => p}, - :class => 'project' + link = link_to_project(p, {:only_path => only_path}, :class => 'project') end end end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 044ccfb77..3b089c111 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -72,7 +72,7 @@ module ProjectsHelper end classes = (ancestors.empty? ? 'root' : 'child') s << "