ModPlusPlugin.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /*
  3. * StatusNet - the distributed open-source microblogging tool
  4. * Copyright (C) 2010, StatusNet, Inc.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. if (!defined('GNUSOCIAL')) { exit(1); }
  20. /**
  21. * Some UI extras for now...
  22. *
  23. * @package ModPlusPlugin
  24. * @maintainer Brion Vibber <brion@status.net>
  25. */
  26. class ModPlusPlugin extends Plugin
  27. {
  28. const PLUGIN_VERSION = '2.0.0';
  29. public function onPluginVersion(array &$versions): bool
  30. {
  31. $versions[] = array('name' => 'ModPlus',
  32. 'version' => self::PLUGIN_VERSION,
  33. 'author' => 'Brion Vibber',
  34. 'homepage' => 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/ModPlus',
  35. 'rawdescription' =>
  36. // TRANS: Plugin description.
  37. _m('UI extension for profile moderation actions.'));
  38. return true;
  39. }
  40. /**
  41. * Load JS at runtime.
  42. *
  43. * @param Action $action
  44. * @return boolean hook result
  45. */
  46. function onEndShowScripts(Action $action)
  47. {
  48. $action->script($this->path('js/modplus.js'));
  49. return true;
  50. }
  51. public function onEndShowStylesheets(Action $action) {
  52. $action->cssLink($this->path('css/modplus.css'));
  53. return true;
  54. }
  55. /**
  56. * Add per-profile info popup menu for author on notice lists.
  57. *
  58. * @param NoticeListItem $item
  59. * @return boolean hook value
  60. */
  61. function onEndShowNoticeItemAuthor(Profile $profile, HTMLOutputter $out)
  62. {
  63. $this->showProfileOptions($out, $profile);
  64. return true;
  65. }
  66. /**
  67. * Add per-profile info popup menu on profile lists.
  68. *
  69. * @param ProfileListItem $item
  70. */
  71. function onStartProfileListItemProfile($item)
  72. {
  73. $this->showProfileOptions($item->out, $item->profile->getProfile());
  74. return true;
  75. }
  76. /**
  77. * Build common remote-profile options structure.
  78. * Currently only adds output for remote profiles, nothing for local users.
  79. *
  80. * @param HTMLOutputter $out
  81. * @param Profile $profile
  82. */
  83. protected function showProfileOptions(HTMLOutputter $out, Profile $profile)
  84. {
  85. if (!$profile->isGroup() && !$profile->isLocal()) {
  86. $target = common_local_url('userbyid', array('id' => $profile->getID()));
  87. // TRANS: Label for access to remote profile options.
  88. $label = _m('Remote profile options...');
  89. $out->elementStart('div', 'remote-profile-options');
  90. $out->element('a', array('href' => $target), $label);
  91. $out->elementEnd('div');
  92. }
  93. }
  94. }