Index: branches/0.8-stable/app/controllers/users_controller.rb
===================================================================
--- branches/0.8-stable/app/controllers/users_controller.rb	(revision 2511)
+++ branches/0.8-stable/app/controllers/users_controller.rb	(revision 2512)
@@ -75,7 +75,11 @@
       @user.admin = params[:user][:admin] if params[:user][:admin]
       @user.login = params[:user][:login] if params[:user][:login]
       @user.password, @user.password_confirmation = params[:password], params[:password_confirmation] unless params[:password].nil? or params[:password].empty? or @user.auth_source_id
-      if @user.update_attributes(params[:user])
+      @user.attributes = params[:user]
+      # Was the account actived ? (do it before User#save clears the change)
+      was_activated = (@user.status_change == [User::STATUS_REGISTERED, User::STATUS_ACTIVE])
+      if @user.save
+        Mailer.deliver_account_activated(@user) if was_activated
         flash[:notice] = l(:notice_successful_update)
         # Give a string to redirect_to otherwise it would use status param as the response code
         redirect_to(url_for(:action => 'list', :status => params[:status], :page => params[:page]))
Index: branches/0.8-stable/app/models/mail_handler.rb
===================================================================
--- branches/0.8-stable/app/models/mail_handler.rb	(revision 2511)
+++ branches/0.8-stable/app/models/mail_handler.rb	(revision 2512)
@@ -163,10 +163,17 @@
   end
   
   def get_keyword(attr, options={})
-    if (options[:override] || @@handler_options[:allow_override].include?(attr.to_s)) && plain_text_body =~ /^#{attr}:[ \t]*(.+)$/i
-      $1.strip
-    elsif !@@handler_options[:issue][attr].blank?
-      @@handler_options[:issue][attr]
+    @keywords ||= {}
+    if @keywords.has_key?(attr)
+      @keywords[attr]
+    else
+      @keywords[attr] = begin
+        if (options[:override] || @@handler_options[:allow_override].include?(attr.to_s)) && plain_text_body.gsub!(/^#{attr}:[ \t]*(.+)\s*$/i, '')
+          $1.strip
+        elsif !@@handler_options[:issue][attr].blank?
+          @@handler_options[:issue][attr]
+        end
+      end
     end
   end
   
Index: branches/0.8-stable/app/models/mailer.rb
===================================================================
--- branches/0.8-stable/app/models/mailer.rb	(revision 2511)
+++ branches/0.8-stable/app/models/mailer.rb	(revision 2512)
@@ -127,6 +127,15 @@
          :url => url_for(:controller => 'users', :action => 'index', :status => User::STATUS_REGISTERED, :sort_key => 'created_on', :sort_order => 'desc')
   end
 
+  # A registered user's account was activated by an administrator
+  def account_activated(user)
+    set_language_if_valid user.language
+    recipients user.mail
+    subject l(:mail_subject_register, Setting.app_title)
+    body :user => user,
+         :login_url => url_for(:controller => 'account', :action => 'login')
+  end
+
   def lost_password(token)
     set_language_if_valid(token.user.language)
     recipients token.user.mail
Index: branches/0.8-stable/app/views/mailer/account_activated.text.html.rhtml
===================================================================
--- branches/0.8-stable/app/views/mailer/account_activated.text.html.rhtml	(nonexistent)
+++ branches/0.8-stable/app/views/mailer/account_activated.text.html.rhtml	(revision 2512)
@@ -0,0 +1,2 @@
+<p><%= l(:notice_account_activated) %></p>
+<p><%= l(:label_login) %>: <%= link_to @login_url, @login_url %></p>

Property changes on: branches/0.8-stable/app/views/mailer/account_activated.text.html.rhtml
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: branches/0.8-stable/app/views/mailer/account_activated.text.plain.rhtml
===================================================================
--- branches/0.8-stable/app/views/mailer/account_activated.text.plain.rhtml	(nonexistent)
+++ branches/0.8-stable/app/views/mailer/account_activated.text.plain.rhtml	(revision 2512)
@@ -0,0 +1,2 @@
+<%= l(:notice_account_activated) %>
+<%= l(:label_login) %>: <%= @login_url %>

Property changes on: branches/0.8-stable/app/views/mailer/account_activated.text.plain.rhtml
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: branches/0.8-stable/doc/CHANGELOG
===================================================================
--- branches/0.8-stable/doc/CHANGELOG	(revision 2511)
+++ branches/0.8-stable/doc/CHANGELOG	(revision 2512)
@@ -5,6 +5,12 @@
 http://www.redmine.org/
 
 
+== 2009-xx-xx v0.8.2
+
+* Send an email to the user when an administrator activates a registered user
+* Strip keywords from received email body
+
+
 == 2009-02-15 v0.8.1
 
 * Select watchers on new issue form
Index: branches/0.8-stable/test/functional/users_controller_test.rb
===================================================================
--- branches/0.8-stable/test/functional/users_controller_test.rb	(revision 2511)
+++ branches/0.8-stable/test/functional/users_controller_test.rb	(revision 2512)
@@ -64,6 +64,22 @@
     assert_equal 2, Member.find(1).role_id
   end
   
+  def test_edit_with_activation_should_send_a_notification
+    u = User.new(:firstname => 'Foo', :lastname => 'Bar', :mail => 'foo.bar@somenet.foo', :language => 'fr')
+    u.login = 'foo'
+    u.status = User::STATUS_REGISTERED
+    u.save!
+    ActionMailer::Base.deliveries.clear
+    Setting.bcc_recipients = '1'
+    
+    post :edit, :id => u.id, :user => {:status => User::STATUS_ACTIVE}
+    assert u.reload.active?
+    mail = ActionMailer::Base.deliveries.last
+    assert_not_nil mail
+    assert_equal ['foo.bar@somenet.foo'], mail.bcc
+    assert mail.body.include?(ll('fr', :notice_account_activated))
+  end
+  
   def test_destroy_membership
     post :destroy_membership, :id => 2, :membership_id => 1
     assert_redirected_to 'users/edit/2'
Index: branches/0.8-stable/test/unit/mail_handler_test.rb
===================================================================
--- branches/0.8-stable/test/unit/mail_handler_test.rb	(revision 2511)
+++ branches/0.8-stable/test/unit/mail_handler_test.rb	(revision 2512)
@@ -47,7 +47,11 @@
     assert_equal 'New ticket on a given project', issue.subject
     assert_equal User.find_by_login('jsmith'), issue.author
     assert_equal Project.find(2), issue.project
+    assert_equal IssueStatus.find_by_name('Resolved'), issue.status
     assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
+    # keywords should be removed from the email body
+    assert !issue.description.match(/^Project:/i)
+    assert !issue.description.match(/^Status:/i)
   end
 
   def test_add_issue_with_status
@@ -111,6 +115,7 @@
     issue.reload
     assert_equal 'New ticket with custom field values', issue.subject
     assert_equal 'Value for a custom field', issue.custom_value_for(CustomField.find_by_name('Searchable field')).value
+    assert !issue.description.match(/^searchable field:/i)
   end
   
   def test_add_issue_with_cc
