ExtendedProfilePlugin.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. const PLUGIN_VERSION = '2.0.0';
  31. function onPluginVersion(array &$versions)
  32. {
  33. $versions[] = array(
  34. 'name' => 'ExtendedProfile',
  35. 'version' => self::PLUGIN_VERSION,
  36. 'author' => 'Brion Vibber, Samantha Doherty, Zach Copley',
  37. 'homepage' => 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/ExtendedProfile',
  38. // TRANS: Plugin description.
  39. 'rawdescription' => _m('UI extensions for additional profile fields.')
  40. );
  41. return true;
  42. }
  43. /**
  44. * Add paths to the router table
  45. *
  46. * Hook for RouterInitialized event.
  47. *
  48. * @param URLMapper $m URL mapper
  49. *
  50. * @return boolean hook return
  51. */
  52. public function onStartInitializeRouter(URLMapper $m)
  53. {
  54. $m->connect(
  55. ':nickname/detail',
  56. array('action' => 'profiledetail'),
  57. array('nickname' => Nickname::DISPLAY_FMT)
  58. );
  59. $m->connect(
  60. '/settings/profile/finduser',
  61. array('action' => 'Userautocomplete')
  62. );
  63. $m->connect(
  64. 'settings/profile/detail',
  65. array('action' => 'profiledetailsettings')
  66. );
  67. return true;
  68. }
  69. function onCheckSchema()
  70. {
  71. $schema = Schema::get();
  72. $schema->ensureTable('profile_detail', Profile_detail::schemaDef());
  73. return true;
  74. }
  75. function onEndShowAccountProfileBlock(HTMLOutputter $out, Profile $profile) {
  76. $user = User::getKV('id', $profile->id);
  77. if ($user) {
  78. $url = common_local_url('profiledetail', array('nickname' => $user->nickname));
  79. // TRANS: Link text on user profile page leading to extended profile page.
  80. $out->element('a', array('href' => $url, 'class' => 'profiledetail'), _m('More details...'));
  81. }
  82. }
  83. }