1 | class AdmincontactgroupController < ApplicationController |
---|
2 | layout 'standard' |
---|
3 | |
---|
4 | # get all contactgroups |
---|
5 | before_filter :authorize |
---|
6 | |
---|
7 | def index |
---|
8 | list |
---|
9 | render :action => 'list' |
---|
10 | end |
---|
11 | |
---|
12 | # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) |
---|
13 | verify :method => :post, :only => [ :destroy, :create, :update ], |
---|
14 | :redirect_to => { :action => :list } |
---|
15 | |
---|
16 | def list |
---|
17 | @contactgroups = Contactgroup.find(:all) |
---|
18 | end |
---|
19 | |
---|
20 | def show |
---|
21 | @contactgroup = Contactgroup.find(params[:id]) |
---|
22 | end |
---|
23 | |
---|
24 | def new |
---|
25 | @contactgroup = Contactgroup.new |
---|
26 | end |
---|
27 | |
---|
28 | def send_email_to_contacts_from_group |
---|
29 | @contactgroup = Contactgroup.find(params[:id]) |
---|
30 | flash_email = String.new |
---|
31 | if request.post? |
---|
32 | @contactsfromgroup = Contact.get_contactsfrom @contactgroup.groupname |
---|
33 | @contactsfromgroup.each do |contact| |
---|
34 | unless contact.email.empty? |
---|
35 | logger.info("Send email to contact #{contact.email}") |
---|
36 | Contactmailer.deliver_send_mail_to_contact(params[:subject], params[:body], contact.email, params[:from]) |
---|
37 | flash_email += "email send to #{contact.email}<br />" |
---|
38 | end |
---|
39 | flash[:notice] = flash_email |
---|
40 | # redirect_to :action => 'show', :id => @contactgroup |
---|
41 | end |
---|
42 | end |
---|
43 | end |
---|
44 | |
---|
45 | def create |
---|
46 | @contactgroup = Contactgroup.new(params[:contactgroup]) |
---|
47 | if @contactgroup.save |
---|
48 | flash[:notice] = 'Contactgroup was successfully created.' |
---|
49 | redirect_to :action => 'list' |
---|
50 | else |
---|
51 | render :action => 'new' |
---|
52 | end |
---|
53 | end |
---|
54 | |
---|
55 | def edit |
---|
56 | @contactgroup = Contactgroup.find(params[:id]) |
---|
57 | end |
---|
58 | |
---|
59 | def update |
---|
60 | @contactgroup = Contactgroup.find(params[:id]) |
---|
61 | if @contactgroup.update_attributes(params[:contactgroup]) |
---|
62 | flash[:notice] = 'Contactgroup was successfully updated.' |
---|
63 | redirect_to :action => 'show', :id => @contactgroup |
---|
64 | else |
---|
65 | render :action => 'edit' |
---|
66 | end |
---|
67 | end |
---|
68 | |
---|
69 | def destroy |
---|
70 | Contactgroup.find(params[:id]).destroy |
---|
71 | redirect_to :action => 'list' |
---|
72 | end |
---|
73 | end |
---|