Sha256: 0051a6975c734fa182a5b48d49b6f83e85920789ca88740d7e66413fd536097e

Contents?: true

Size: 1.52 KB

Versions: 4

Compression:

Stored size: 1.52 KB

Contents

class Admin::BlocksController < AdminController
  layout "cms-boxed"
  
  def index
    @blocks = Block.sys(_sid).order(:name)
    @blocks = @blocks.where('name like "%' + params[:for] + '%" or body like "%' + params[:for] + '%" or description like "%' + params[:for] + '%"') if params[:for].not_blank?
    @blocks = @blocks.page(params[:page]).per(25)
  end

  def show
    @block = Block.find_sys_id(_sid,params[:id])
  end

  def new
    @block = Block.new
  end

  def create
    params[:block][:system_id] = _sid
    @block = Block.new(params[:block])
    @block.user_id = current_user.id
    if @block.save
      redirect_to [:admin, @block], :notice => "Successfully created block"
    else
      render :action => 'new'
    end
  end

  def edit
    @block = Block.find_sys_id(_sid,params[:id])
  end

  def update
    @block = Block.find_sys_id(_sid,params[:id])
    @block.user_id = current_user.id

    if @block.update_attributes(params[:block])
      Activity.add(_sid, "Update block '#{@block.name}'", current_user.id, "Block")

      if params[:submit_button]=="save-and-edit-again"
        redirect_to "/admin/blocks/#{@block.id}/edit#editor"
      else
        redirect_to "/admin/blocks/#{@block.id}"
      end
      
      return
    else
      render :action => 'edit'
    end
  end

  def destroy
    Activity.add(_sid, "Deleted block '#{@block.name}'", current_user.id, "Block")
    @block = Block.find_sys_id(_sid, params[:id])
    @block.destroy
    redirect_to admin_blocks_url, :notice => "Successfully destroyed block"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kit_cms-2.3.9 app/controllers/admin/blocks_controller.rb
kit_cms-2.3.8 app/controllers/admin/blocks_controller.rb
kit_cms-2.3.7 app/controllers/admin/blocks_controller.rb
kit_cms-2.3.6 app/controllers/admin/blocks_controller.rb