ExtendedProfilePlugin.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /*
  3. * StatusNet - the distributed open-source microblogging tool
  4. * Copyright (C) 2011, 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('STATUSNET')) {
  20. exit(1);
  21. }
  22. /**
  23. * Extra profile bio-like fields
  24. *
  25. * @package ExtendedProfilePlugin
  26. * @maintainer Brion Vibber <brion@status.net>
  27. */
  28. class ExtendedProfilePlugin extends Plugin
  29. {
  30. function onPluginVersion(array &$versions)
  31. {
  32. $versions[] = array(
  33. 'name' => 'ExtendedProfile',
  34. 'version' => GNUSOCIAL_VERSION,
  35. 'author' => 'Brion Vibber, Samantha Doherty, Zach Copley',
  36. 'homepage' => 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/ExtendedProfile',
  37. // TRANS: Plugin description.
  38. 'rawdescription' => _m('UI extensions for additional profile fields.')
  39. );
  40. return true;
  41. }
  42. /**
  43. * Add paths to the router table
  44. *
  45. * Hook for RouterInitialized event.
  46. *
  47. * @param URLMapper $m URL mapper
  48. *
  49. * @return boolean hook return
  50. */
  51. public function onStartInitializeRouter(URLMapper $m)
  52. {
  53. $m->connect(
  54. ':nickname/detail',
  55. array('action' => 'profiledetail'),
  56. array('nickname' => Nickname::DISPLAY_FMT)
  57. );
  58. $m->connect(
  59. '/settings/profile/finduser',
  60. array('action' => 'Userautocomplete')
  61. );
  62. $m->connect(
  63. 'settings/profile/detail',
  64. array('action' => 'profiledetailsettings')
  65. );
  66. return true;
  67. }
  68. function onCheckSchema()
  69. {
  70. $schema = Schema::get();
  71. $schema->ensureTable('profile_detail', Profile_detail::schemaDef());
  72. return true;
  73. }
  74. function onEndShowAccountProfileBlock(HTMLOutputter $out, Profile $profile) {
  75. $user = User::getKV('id', $profile->id);
  76. if ($user) {
  77. $url = common_local_url('profiledetail', array('nickname' => $user->nickname));
  78. // TRANS: Link text on user profile page leading to extended profile page.
  79. $out->element('a', array('href' => $url, 'class' => 'profiledetail'), _m('More details...'));
  80. }
  81. }
  82. }