Class: Goldencobra::ManageController

Inherits:
ApplicationController show all
Defined in:
app/controllers/goldencobra/manage_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#access_denied, #after_sign_in_path_for, #after_sign_out_path_for, #initialize_article, #s, #set_locale

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Goldencobra::ApplicationController

Instance Method Details

#article_visibilityObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/goldencobra/manage_controller.rb', line 17

def article_visibility
  @article_saved = false
  @operator = current_user || current_visitor
  if current_user
    article = Goldencobra::Article.find(params[:id])
    ability = Ability.new(current_user)
    if ability.can?(:update, article)
      article.active = !article.active
      article.save
      @article = article
      @article_saved = true
    end
  end
end

#call_for_supportObject



32
33
34
35
36
37
38
39
# File 'app/controllers/goldencobra/manage_controller.rb', line 32

def call_for_support
  if current_user || current_visitor
    Goldencobra::ConfirmationMailer.send_support_mail(params[:link]).deliver
    render text: "200"
  else
    render text: "401"
  end
end

#render_admin_menueObject



4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/goldencobra/manage_controller.rb', line 4

def render_admin_menue
  user_mod = Goldencobra::Setting.for_key("goldencobra.article.edit_link.user")
  role_mod = Goldencobra::Setting.for_key("goldencobra.article.edit_link.role")
  if user_mod.present? && role_mod.present? && eval("#{user_mod} && #{user_mod}.present? && #{user_mod}.has_role?('#{role_mod}')")
    article = Goldencobra::Article.find_by_id(params[:id])
    @operator = current_user || current_visitor
    a = Ability.new(@operator)
    if a.can?(:manage, article)
      @article = article
    end
  end
end