taskbar_controller.rb 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
  2. class TaskbarController < ApplicationController
  3. before_filter :authentication_check
  4. def index
  5. current_user_tasks = Taskbar.where( :user_id => current_user.id )
  6. model_index_render_result(current_user_tasks)
  7. end
  8. def show
  9. taskbar = Taskbar.find( params[:id] )
  10. return if !access(taskbar)
  11. model_show_render_item(taskbar)
  12. end
  13. def create
  14. model_create_render(Taskbar,params)
  15. end
  16. def update
  17. taskbar = Taskbar.find( params[:id] )
  18. return if !access(taskbar)
  19. taskbar.update_attributes!( Taskbar.param_cleanup(params) )
  20. model_update_render_item(taskbar)
  21. end
  22. def destroy
  23. taskbar = Taskbar.find( params[:id] )
  24. return if !access(taskbar)
  25. taskbar.destroy
  26. model_destory_render_item()
  27. end
  28. private
  29. def access(taskbar)
  30. if taskbar.user_id != current_user.id
  31. render :json => { :error => 'Not allowed to access this task.' }, :status => :unprocessable_entity
  32. return false
  33. end
  34. return true
  35. end
  36. end