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
42
43
44
45
46
47
48
49
|
# File 'app/controllers/muck/email_shares_controller.rb', line 17
def create
if params[:emails].blank?
@result = t('muck.shares.emails_empty')
elsif params[:message].blank?
@result = t('muck.shares.message_empty')
else
@emails = params[:emails]
@emails = @emails.join(', ') if @emails.is_a?(Array)
@emails = @emails.split(/[, ]/) if !@emails.is_a?(Array)
@emails = @emails.find_all { |email| !email.blank? }
@emails = @emails.flatten.collect { |email| email.strip }
check_emails = []
subject = params[:subject]
message = params[:message]
@emails.each do |email|
if !check_emails.include?(email)
check_emails << email
response = ShareMailer.share_email(current_user, email, subject, message).deliver
end
end
@emails = @emails.join(',')
@result = t('muck.shares.share_email_success', :emails => @emails)
@success = true
end
respond_to do |format|
format.html do
flash[:notice] = @result
render :template => 'email_shares/new', :layout => 'popup'
end
format.pjs { render :template => 'email_shares/create', :layout => false }
format.js { render :template => 'email_shares/create', :layout => false }
end
end
|