taskbar_controller.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # Copyright (C) 2012-2013 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. params[:user_id] = current_user.id
  15. model_create_render(Taskbar,params)
  16. end
  17. def update
  18. taskbar = Taskbar.find( params[:id] )
  19. return if !access(taskbar)
  20. params[:user_id] = current_user.id
  21. taskbar.update_attributes!( Taskbar.param_cleanup(params) )
  22. model_update_render_item(taskbar)
  23. end
  24. def destroy
  25. taskbar = Taskbar.find( params[:id] )
  26. return if !access(taskbar)
  27. taskbar.destroy
  28. model_destory_render_item()
  29. end
  30. private
  31. def access(taskbar)
  32. if taskbar.user_id != current_user.id
  33. render :json => { :error => 'Not allowed to access this task.' }, :status => :unprocessable_entity
  34. return false
  35. end
  36. return true
  37. end
  38. end