topposterssection.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. * Base class for sections showing lists of people
  18. *
  19. * @category Widget
  20. * @package GNUsocial
  21. * @author Evan Prodromou <evan@status.net>
  22. * @copyright 2009 StatusNet, Inc.
  23. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  24. */
  25. defined('GNUSOCIAL') || die();
  26. /**
  27. * Base class for sections
  28. *
  29. * These are the widgets that show interesting data about a person
  30. * group, or site.
  31. *
  32. * @copyright 2009 StatusNet, Inc.
  33. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  34. */
  35. class TopPostersSection extends ProfileSection
  36. {
  37. public function getProfiles()
  38. {
  39. $limit = PROFILES_PER_SECTION;
  40. $qry = sprintf(
  41. <<<'END'
  42. SELECT *
  43. FROM profile INNER JOIN (
  44. SELECT profile_id AS id, COUNT(profile_id) AS value
  45. FROM notice
  46. %1$sGROUP BY profile_id
  47. ) AS t1 USING (id)
  48. ORDER BY value DESC LIMIT %2$d;
  49. END,
  50. (common_config('public', 'localonly') ? 'WHERE notice.is_local = 1 ' : ''),
  51. $limit
  52. );
  53. $profile = Memcached_DataObject::cachedQuery('Profile', $qry, 6 * 3600);
  54. return $profile;
  55. }
  56. public function title()
  57. {
  58. // TRANS: Title for top posters section.
  59. return _('Top posters');
  60. }
  61. public function divId()
  62. {
  63. return 'top_posters';
  64. }
  65. }