Class: DmForum::Admin::ForumsController

Inherits:
AdminController
  • Object
show all
Includes:
PermittedParams
Defined in:
app/controllers/dm_forum/admin/forums_controller.rb

Instance Method Summary collapse

Methods included from PermittedParams

#forum_category_params, #forum_comment_params, #forum_params, #forum_site_params, #forum_topic_params

Instance Method Details

#createObject

POST /admin/fms/forums




36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/dm_forum/admin/forums_controller.rb', line 36

def create
  @forum = @forum_category.forums.new(forum_params)
  @forum.forum_site = ForumSite.site
  
  if @forum.save
    redirect_to admin_forum_category_url(@forum_category), notice: 'Forum was successfully created.'
  else
    render action: :new
  end
end

#destroyObject

DELETE /admin/fms/forums/1




59
60
61
62
63
# File 'app/controllers/dm_forum/admin/forums_controller.rb', line 59

def destroy
  @forum.destroy

  redirect_to admin_forum_category_url(@forum.forum_category)
end

#editObject

GET /admin/fms/forums/1/edit




31
32
# File 'app/controllers/dm_forum/admin/forums_controller.rb', line 31

def edit
end

#forum_add_memberObject

Add user(s) to forum.

> user_id: add a single user




83
84
85
86
87
88
89
90
91
# File 'app/controllers/dm_forum/admin/forums_controller.rb', line 83

def forum_add_member
  if !params[:user_id].blank?
    user = User.find(params[:user_id])
    @forum.add_member(user)
    redirect_to admin_forum_url(@forum), notice: "Forum access granted for #{user.full_name}"
  else
    redirect_to admin_forum_url(@forum), alert: "Incorrect parameters supplied"
  end
end

#forum_delete_memberObject




94
95
96
97
98
# File 'app/controllers/dm_forum/admin/forums_controller.rb', line 94

def forum_delete_member
  user = User.find(params[:user_id])
  @forum.remove_member(user)
  redirect_to admin_forum_url(@forum), notice: "Forum access removed for #{user.full_name}"
end

#forum_usersObject




74
75
76
77
78
# File 'app/controllers/dm_forum/admin/forums_controller.rb', line 74

def forum_users
  respond_to do |format|
    format.json { render json: ForumUserDatatable.new(view_context, @forum) }
  end
end

#indexObject

GET /admin/fms/forums




10
11
12
13
14
15
16
# File 'app/controllers/dm_forum/admin/forums_controller.rb', line 10

def index
  if ForumSite.first
    @forums = @forum_category.forums.ordered
  else
    redirect_to admin_forum_site_path, notice: "Please configure the Forum system first"
  end
end

#newObject

GET /admin/fms/forums/new




25
26
27
# File 'app/controllers/dm_forum/admin/forums_controller.rb', line 25

def new
  @forum = @forum_category.forums.build
end

#showObject




19
20
21
# File 'app/controllers/dm_forum/admin/forums_controller.rb', line 19

def show
  
end

#sortObject




66
67
68
69
70
71
# File 'app/controllers/dm_forum/admin/forums_controller.rb', line 66

def sort
  @forum.update_attribute(:row_order_position, params[:item][:row_order_position])

  #--- this action will be called via ajax
  render nothing: true
end

#updateObject

PUT /admin/fms/forums/1




49
50
51
52
53
54
55
# File 'app/controllers/dm_forum/admin/forums_controller.rb', line 49

def update
  if @forum.update_attributes(forum_params)
    redirect_to admin_forum_url(@forum), notice: 'Forum was successfully updated.'
  else
    render action: :edit
  end
end