plugindeleteform.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. public $widgetOpts;
  29. public $scoped;
  30. /**
  31. * Plugin to delete
  32. */
  33. public $plugin = null;
  34. /**
  35. * Constructor
  36. *
  37. * @param HTMLOutputter $out output channel
  38. * @param string $plugin plugin to delete
  39. */
  40. public function __construct($out = null, $plugin = null)
  41. {
  42. parent::__construct($out);
  43. $this->plugin = $plugin;
  44. }
  45. /**
  46. * ID of the form
  47. *
  48. * @return string ID of the form
  49. */
  50. public function id()
  51. {
  52. return 'plugin-delete-' . $this->plugin;
  53. }
  54. /**
  55. * class of the form
  56. *
  57. * @return string of the form class
  58. */
  59. public function formClass()
  60. {
  61. return 'form_plugin_delete';
  62. }
  63. /**
  64. * Action of the form
  65. *
  66. * @return string URL of the action
  67. */
  68. public function action()
  69. {
  70. return common_local_url(
  71. 'plugindelete',
  72. ['plugin' => $this->plugin]
  73. );
  74. }
  75. public function show()
  76. {
  77. if (!is_writable(INSTALLDIR . '/local/plugins/'.$this->plugin) || // We can only delete third party plugins
  78. PluginList::isPluginLoaded($this->plugin)) { // We can't delete a plugin that has been loaded in config.php
  79. return;
  80. }
  81. parent::show();
  82. }
  83. /**
  84. * Action elements
  85. *
  86. * @return void
  87. * @throws Exception
  88. */
  89. public function formActions()
  90. {
  91. // TRANS: Plugin admin panel controls
  92. $this->out->submit('submit', _m('plugin', 'Delete'));
  93. }
  94. }