TheFreeNetworkModule.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. /**
  17. * TheFreeNetwork, "automagic" migration of internal remote profiles
  18. * between different federation protocols.
  19. *
  20. * @package GNUsocial
  21. * @author Bruno Casteleiro <brunoccast@fc.up.pt>
  22. * @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
  23. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  24. */
  25. defined('GNUSOCIAL') || die();
  26. /**
  27. * Class TheFreeNetworkModule
  28. * This module ensures that multiple protocols serving the same purpose won't result in duplicated data.
  29. * This class is not to be extended but a developer implementing a new protocol should be aware of it and notify the
  30. * StartTFNCensus event.
  31. *
  32. * @category Module
  33. * @package GNUsocial
  34. * @author Bruno Casteleiro <brunoccast@fc.up.pt>
  35. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  36. */
  37. class TheFreeNetworkModule extends Module
  38. {
  39. const MODULE_VERSION = '0.1.0alpha0';
  40. private $free_network = []; // name of the profile classes of the active federation protocols
  41. /**
  42. * Called when all plugins have been initialized
  43. * We'll populate the $free_network array here
  44. *
  45. * @return boolean hook value
  46. */
  47. public function onInitializePlugin()
  48. {
  49. Event::handle('StartTFNCensus', [&$this->free_network]);
  50. return true;
  51. }
  52. /**
  53. * Plugin version information
  54. *
  55. * @param array $versions
  56. * @return bool hook true
  57. */
  58. public function onPluginVersion(array &$versions): bool
  59. {
  60. $versions[] = [
  61. 'name' => 'TheFreeNetwork',
  62. 'version' => self::MODULE_VERSION,
  63. 'author' => 'Bruno Casteleiro',
  64. 'homepage' => 'https://notabug.org/diogo/gnu-social/src/nightly/plugins/TheFreeNetwork',
  65. // TRANS: Module description.
  66. 'rawdescription' => '"Automagically" migrate internal remote profiles between different federation protocols'
  67. ];
  68. return true;
  69. }
  70. }