Class: Plugins::PostReorder::AdminController

Inherits:
Apps::PluginsAdminController
  • Object
show all
Defined in:
app/controllers/plugins/post_reorder/admin_controller.rb

Overview

Camaleon CMS is a content management system

Copyright (C) 2015 by Owen Peredo Diaz
Email: owenperedo@gmail.com
This program is free software: you can redistribute it and/or modify   it under the terms of the GNU Affero General Public License as  published by the Free Software Foundation, either version 3 of the  License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the  GNU Affero General Public License (GPLv3) for more details.

Instance Method Summary collapse

Instance Method Details

#reorder_postsObject

This updates the position of the elements in the database.



12
13
14
15
16
17
18
19
20
# File 'app/controllers/plugins/post_reorder/admin_controller.rb', line 12

def reorder_posts
  if params[:values].present?
    params[:values].each_with_index do |value,index |
      post = current_site.posts.find(value)
      post.update_column("post_order", index)
    end
  end
  render inline: "correct"
end

#save_settingsObject

This saves the settings plugin.



28
29
30
31
32
33
34
# File 'app/controllers/plugins/post_reorder/admin_controller.rb', line 28

def save_settings
  @plugin = current_site.plugins.find_by_slug("post_reorder")
  @plugin.set_meta("_reorder_objects", params[:object] || {})
  flash[:notice] = "#{t('plugin.post_reorder.updated_changes')}"

  redirect_to admin_plugins_path
end

#settingsObject

show plugin settings.



23
24
25
# File 'app/controllers/plugins/post_reorder/admin_controller.rb', line 23

def settings

end