right publishing
[onlineproject.git] / online / app / controllers / application.rb
blob4ad13756a03670e91ccc600da626c775499088f2
1 # Filters added to this controller apply to all controllers in the application.
2 # Likewise, all the methods added will be available for all controllers.
4 class ApplicationController < ActionController::Base
5   helper :all # include all helpers, all the time
7   # See ActionController::RequestForgeryProtection for details
8   # Uncomment the :secret if you're not using the cookie session store
9   #protect_from_forgery  :secret => '0fcc823b7dcd071c84967c35c10e155c'
10   before_filter :instantiate_controller_and_action_names
12   def instantiate_controller_and_action_names
13     @current_action = action_name
14     @current_controller = controller_name
15   end
17   def debug_message (message,is_not_error = true)
18     if true #Debug_message_on
19       if !is_not_error
20         p "<>" * 25
21         p "> > > DEBUG ERROR:"
22         p "<>" * 25
23       end
24       p " >" * 25
25       p "          " + message
26       p " >" * 25
27     end
28   end
30   def add_stat(uid, action, extra = 0)
31      myParams = {
32                 :uid               => uid,
33                 :action            => action,
34                 :extra             => extra,
35                 }
36       @stat = Stat.new(myParams)
37       @stat.save  
38       
40       case action
41         when INSTALLED
42           debug_message ("STAT UPDATED: #{uid} installed application")
43         when PERMISSION 
44           debug_message ("STAT UPDATED: #{uid} gave permission")
45   
46         when DELETED
47           debug_message ("STAT UPDATED: #{uid} deleted application")
48         when ANSWERED_1QUESTION
49           debug_message ("STAT UPDATED: #{uid} answered on question")
50         when ATTEMPT
51           debug_message ("STAT UPDATED: #{uid} tried to answer")
52         when PHONE_GIVEN
53           debug_message ("STAT UPDATED: #{uid} gave their code")        
54         when VISITED
55           case extra
56             when FROM_FB_ADS
57               @source = "FROM_FB_ADS"
58             when
59               @source = "FROM_PLAY_ADS" 
60             when
61               @source = "FROM_PLAY_SITE"
62             when
63               @source = "FROM_STATUS"
64             when
65               @source = "FROM_RESERVED"
66               
67           end
68         debug_message ("STAT UPDATED: #{uid} came from #{@source}")
69       end
70       
71   end 
73 end