Module: SharkApps::InstanceMethods

Defined in:
lib/sharkapps.rb

Instance Method Summary collapse

Instance Method Details

#check_account_authorizedObject

redirect to the not_subscribed path if not authorized



74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/sharkapps.rb', line 74

def 
  return true if SharkApps.debug_mode
  res = @account.approval_status
  need_check = @account.last_approval_check.nil? ? true : ((Time.now.to_i - @account.last_approval_check.to_i) > 5.minutes.to_i)
  if need_check
    #get the account
    AppformaAccount.(@account)
    res = @account.approval_status
  end
  if res == Subscription::EXPIRED || res == Subscription::UNAUTHORIZED
    redirect_to not_subscribed_path(:id => @account.acc_hash)
  end 
end

#check_adminObject



101
102
103
# File 'lib/sharkapps.rb', line 101

def check_admin
  redirect_to not_authorized_url(:id => @account.acc_hash) unless is_admin
end

#is_adminObject



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/sharkapps.rb', line 105

def is_admin
  return true if SharkApps.debug_mode
  
  if fb_load_facebook_params['page']
    fb_load_facebook_params['page']['admin']
  else
    
    #go by the facebook user ID and make an API call. might need to store it in the session
    sym = ("auth_admin_" + @account.fbid).to_sym
    puts "symbol: #{sym}"
    puts "symbol value: #{session[sym]}"
    puts "symbol checking for false: #{session[sym] == false}"
    need_check = (session[sym].nil? or session[sym] == false)
    puts "need check: = #{need_check}"
    if need_check #need_check
      return false if current_facebook_user.nil?
      session[sym] = AppformaAccount.check_admin_authorized(@account, current_facebook_user.id)
    end
    return session[sym]
  end    
end

#set_tab_current_accountObject



88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/sharkapps.rb', line 88

def 
  #hack for fbml 
  temp = fb_load_facebook_params 
  page_id = temp["page"]["id"]
  @account = Account.find_or_create_by_fbid(page_id)
  #set the default locale if supported, and if the account doesn't have a locale set
  if @account.respond_to? :locale and @account.locale.blank?
    @account.locale = "il"
    @account.save
  end
  @isliked = temp["page"]["liked"]
end