- •Утвержден
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •Исходный код шаблонов видов
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
- •02070743.00569-01 12 01
2002070743.00569-01 12 01
redirect_to :action => "view_tickets"
end
else
flash[:message]= "Login unsuccessful"
@msg = "Login Failed!<br>"
end
end
end
def open_ticket
@user = User.find(:first :conditions => {:id => session[:user][:id]}, :limit => 1)
@categories = Category.find(:all,:limit => 100)
#@statuses = Ticketstatus.find(:all)#not implemented yet
end
def save_post
if request.post?
flash[:message]= ""
#----------Add Post to Ticket----------------------
#add the ticket text to the tick
@ticket_text = Tickettext.new()
@ticket_text.text_content = params[:ticket][:text_content]
@ticket_text.user_id = session[:user][:id]
@ticket_text.ticket_id = params[:ticket][:ticket_id]
@ticket_text.post_type = "user-post"
if @ticket_text.save#save the text
flash[:message] << "<font color=green><image src=\"/images/icon_success.png\"> Your post was added successfully!</font><br>"
else
flash[:message] << "<font color=red><image src=\"/images/icon_failure.png\"> There was а problem saving your post!</font><br>"
end
#--------------------------------------------------
#flash[:message] << "#{params.inspect} <br><br><br> #{@ticket.inspect} <br><br>@ticket.id: #{@ticket.id}<br>params[:ticket][:ticket_id]: #{params[:ticket][:ticket_id]}<br>params[:ticket][:status]: #{params[:ticket][:status]} "#for debugging
redirect_to :action => "view_tickets"
end
end
def update_ticket_status
@ticket = Ticket.find(params[:ticket][:ticket_id] :limit => 1)
flash[:message]= ""
if(@ticket.ticketstatus_id == params[:ticket][:ticketstatus_id]) #they didn't actually select а new status
flash[:message] << "<font color=red><image src=\"/images/icon_failure.png\"> You must choose а NEW ticket status!</font><br>"
109
2102070743.00569-01 12 01
if(@ticket.update_attribute(:ticketstatus_id,
params[:ticket][:ticketstatus_id]))
flash[:message] << "<font color=green><image src=\"/images/icon_success.png\"> Your ticket status has been changed successfully!</font><br>"
end
redirect_to :action => "view_tickets"
end
end
def view_tickets
@user = User.find(:first :conditions => {:id => session[:user][:id]} )
@categories = Category.find(:all)
@tickets = Ticket.find(:all :conditions => { :user_id => session[:user][:id]}, :limit => "100")
end
end
#----------------------------------------------------------------------------------------------tech_controller.rb
class TechController < ApplicationController
before_filter :authenticate_user, :except => [:index :login, :create_new_user] #make sure the user is supposed to be here
#I'm adding individual make_log's to whatever controller should have them instead.
#after_filter :make_log, :only => [:create_ticket :update_ticket_status, :update_account, :change_password, :save_post] #log the action
def ajax_post_box
render :layout => false
end
def test
end
def authenticate_user
if session[:user].nil? #There's definitely no user logged in
flash[:message]= "<font color=red><image src=\"/images/icon_failure.png\">You are not logged in or а tech!</font><br>"
redirect_to :action => "index"
else #there's а user logged in, but what type is he?
@user = User.find(session[:user][:id]) # make sure user is in db, make sure they're not spoofing а session id
if(@user.type_id == 2)
# They are cool. Let them through.
else
flash[:message]= "<font color=red><image src=\"/images/icon_failure.png\"> You are not logged in as а Tech!</font>"
redirect_to :action => "index"
end
end
end
def index
110