class AdmincontactgroupController < ApplicationController layout 'standard' # get all contactgroups before_filter :authorize def index list render :action => 'list' end # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list } def list @contactgroups = Contactgroup.find(:all) end def show @contactgroup = Contactgroup.find(params[:id]) end def new @contactgroup = Contactgroup.new end def send_email_to_contacts_from_group @contactgroup = Contactgroup.find(params[:id]) flash_email = String.new if request.post? @contactsfromgroup = Contact.get_contactsfrom @contactgroup.groupname @contactsfromgroup.each do |contact| unless contact.email.empty? logger.info("Send email to contact #{contact.email}") Contactmailer.deliver_send_mail_to_contact(params[:subject], params[:body], contact.email, params[:from]) flash_email += "email send to #{contact.email}
" end flash[:notice] = flash_email # redirect_to :action => 'show', :id => @contactgroup end end end def create @contactgroup = Contactgroup.new(params[:contactgroup]) if @contactgroup.save flash[:notice] = 'Contactgroup was successfully created.' redirect_to :action => 'list' else render :action => 'new' end end def edit @contactgroup = Contactgroup.find(params[:id]) end def update @contactgroup = Contactgroup.find(params[:id]) if @contactgroup.update_attributes(params[:contactgroup]) flash[:notice] = 'Contactgroup was successfully updated.' redirect_to :action => 'show', :id => @contactgroup else render :action => 'edit' end end def destroy Contactgroup.find(params[:id]).destroy redirect_to :action => 'list' end end