blacklistadminpanel.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * Blacklist administration panel
  6. *
  7. * PHP version 5
  8. *
  9. * LICENCE: This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. * @category Settings
  23. * @package StatusNet
  24. * @author Evan Prodromou <evan@status.net>
  25. * @copyright 2010 StatusNet, Inc.
  26. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
  27. * @link http://status.net/
  28. */
  29. if (!defined('GNUSOCIAL')) { exit(1); }
  30. /**
  31. * Administer blacklist
  32. *
  33. * @category Admin
  34. * @package StatusNet
  35. * @author Evan Prodromou <evan@status.net>
  36. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
  37. * @link http://status.net/
  38. */
  39. class BlacklistadminpanelAction extends AdminPanelAction
  40. {
  41. /**
  42. * title of the admin panel
  43. *
  44. * @return string title
  45. */
  46. function title()
  47. {
  48. // TRANS: Title of blacklist plugin administration panel.
  49. return _m('TITLE','Blacklist');
  50. }
  51. /**
  52. * Panel instructions
  53. *
  54. * @return string instructions
  55. */
  56. function getInstructions()
  57. {
  58. // TRANS: Instructions for blacklist plugin administration panel.
  59. return _m('Blacklisted URLs and nicknames');
  60. }
  61. /**
  62. * Show the actual form
  63. *
  64. * @return void
  65. *
  66. * @see BlacklistAdminPanelForm
  67. */
  68. function showForm()
  69. {
  70. $form = new BlacklistAdminPanelForm($this);
  71. $form->show();
  72. return;
  73. }
  74. /**
  75. * Save the form settings
  76. *
  77. * @return void
  78. */
  79. function saveSettings()
  80. {
  81. $nickPatterns = $this->splitPatterns($this->trimmed('blacklist-nicknames'));
  82. Nickname_blacklist::saveNew($nickPatterns);
  83. $urlPatterns = $this->splitPatterns($this->trimmed('blacklist-urls'));
  84. Homepage_blacklist::saveNew($urlPatterns);
  85. return;
  86. }
  87. protected function splitPatterns($text)
  88. {
  89. $patterns = array();
  90. foreach (explode("\n", $text) as $raw) {
  91. $trimmed = trim($raw);
  92. if ($trimmed != '') {
  93. $patterns[] = $trimmed;
  94. }
  95. }
  96. return $patterns;
  97. }
  98. /**
  99. * Validate the values
  100. *
  101. * @param array &$values 2d array of values to check
  102. *
  103. * @return boolean success flag
  104. */
  105. function validate(&$values)
  106. {
  107. return true;
  108. }
  109. }