plugindeleteform.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. // This file is part of GNU social - https://www.gnu.org/software/social
  3. //
  4. // GNU social is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Affero General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // GNU social is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Affero General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Affero General Public License
  15. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  16. defined('STATUSNET') || die();
  17. /**
  18. * Form for deleting a plugin
  19. *
  20. * @category Form
  21. * @package GNUsocial
  22. * @author Diogo Cordeiro <diogo@fc.up.pt>
  23. * @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
  24. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  25. */
  26. class PluginDeleteForm extends PluginEnableForm
  27. {
  28. /**
  29. * Plugin to delete
  30. */
  31. public $plugin = null;
  32. /**
  33. * Constructor
  34. *
  35. * @param HTMLOutputter $out output channel
  36. * @param string $plugin plugin to delete
  37. */
  38. public function __construct($out = null, $plugin = null)
  39. {
  40. parent::__construct($out);
  41. $this->plugin = $plugin;
  42. }
  43. /**
  44. * ID of the form
  45. *
  46. * @return string ID of the form
  47. */
  48. public function id()
  49. {
  50. return 'plugin-delete-' . $this->plugin;
  51. }
  52. /**
  53. * class of the form
  54. *
  55. * @return string of the form class
  56. */
  57. public function formClass()
  58. {
  59. return 'form_plugin_delete';
  60. }
  61. /**
  62. * Action of the form
  63. *
  64. * @return string URL of the action
  65. */
  66. public function action()
  67. {
  68. return common_local_url(
  69. 'plugindelete',
  70. ['plugin' => $this->plugin]
  71. );
  72. }
  73. public function show()
  74. {
  75. if (!is_writable(INSTALLDIR . '/local/plugins/'.$this->plugin) || // We can only delete third party plugins
  76. PluginList::isPluginLoaded($this->plugin)) { // We can't delete a plugin that has been loaded in config.php
  77. return;
  78. }
  79. parent::show();
  80. }
  81. /**
  82. * Action elements
  83. *
  84. * @return void
  85. * @throws Exception
  86. */
  87. public function formActions()
  88. {
  89. // TRANS: Plugin admin panel controls
  90. $this->out->submit('submit', _m('plugin', 'Delete'));
  91. }
  92. }