topposterssection.php 2.2 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. * 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 $widgetOpts;
  38. public $scoped;
  39. public function getProfiles()
  40. {
  41. $limit = PROFILES_PER_SECTION;
  42. $qry = sprintf(
  43. <<<'END'
  44. SELECT *
  45. FROM profile INNER JOIN (
  46. SELECT profile_id AS id, COUNT(profile_id) AS value
  47. FROM notice
  48. %1$sGROUP BY profile_id
  49. ) AS t1 USING (id)
  50. ORDER BY value DESC LIMIT %2$d;
  51. END,
  52. (common_config('public', 'localonly') ? 'WHERE notice.is_local = 1 ' : ''),
  53. $limit
  54. );
  55. $profile = Memcached_DataObject::cachedQuery('Profile', $qry, 6 * 3600);
  56. return $profile;
  57. }
  58. public function title()
  59. {
  60. // TRANS: Title for top posters section.
  61. return _('Top posters');
  62. }
  63. public function divId()
  64. {
  65. return 'top_posters';
  66. }
  67. }