packages_controller.rb 798 B

12345678910111213141516171819202122232425262728293031323334353637
  1. # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
  2. class PackagesController < ApplicationController
  3. before_filter :authentication_check
  4. # GET /api/v1/packages
  5. def index
  6. return if deny_if_not_role('Admin')
  7. packages = Package.all().order('name')
  8. render :json => {
  9. :packages => packages
  10. }
  11. end
  12. # POST /api/v1/packages
  13. def install
  14. return if deny_if_not_role('Admin')
  15. Package.install( :string => params[:file_upload].read )
  16. redirect_to '/#system/package'
  17. end
  18. # DELETE /api/v1/packages
  19. def uninstall
  20. return if deny_if_not_role('Admin')
  21. package = Package.find( params[:id] )
  22. Package.uninstall( :name => package.name, :version => package.version )
  23. render :json => {
  24. :success => true
  25. }
  26. end
  27. end