cirandas.net

ref: master

app/controllers/my_profile/mailconf_controller.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
class MailconfController < MyProfileController

  requires_profile_class Person

  protect 'edit_profile', :profile

  before_filter :check_mail_enabled
  def check_mail_enabled
    unless MailConf.enabled?
      render :text => "Mail is not enabled in noosfero.", :status => 500
    end
  end

  def index
    @user = profile.user
  end

  post_only :enable
  def enable
    @task = EmailActivation.new(:target => environment, :requestor => profile)
    begin
      @task.save!
      session[:notice] = _('Please fill your personal information below in order to get your mailbox approved by one of the administrators')
      redirect_to :controller => 'profile_editor', :action => 'edit'
    rescue Exception => ex
      session[:notice] = _('e-Mail was not enabled successfully.')
      render :action => 'index'
    end
  end
  post_only :disable
  def disable
    if profile.user.disable_email!
      session[:notice] = _('e-Mail disabled successfully.')
      redirect_to :controller => 'profile_editor'
    else
      session[:notice] = _('e-Mail was not disabled successfully.')
      redirect_to :action => 'index'
    end
  end
  
end