The official, canonical postActiv repository. http://www.postactiv.com

apiuserfriends.php 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /* ============================================================================
  3. * Title: APIUserFriends
  4. * Show a user's friends (subscriptions)
  5. *
  6. * postActiv:
  7. * the micro-blogging software
  8. *
  9. * Copyright:
  10. * Copyright (C) 2016-2018, Maiyannah Bishop
  11. *
  12. * Derived from code copyright various sources:
  13. * o GNU Social (C) 2013-2016, Free Software Foundation, Inc
  14. * o StatusNet (C) 2008-2012, StatusNet, Inc
  15. * ----------------------------------------------------------------------------
  16. * License:
  17. * This program is free software: you can redistribute it and/or modify
  18. * it under the terms of the GNU Affero General Public License as published by
  19. * the Free Software Foundation, either version 3 of the License, or
  20. * (at your option) any later version.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU Affero General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU Affero General Public License
  28. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  29. *
  30. * <https://www.gnu.org/licenses/agpl.html>
  31. * ----------------------------------------------------------------------------
  32. * About:
  33. * Show a user's friends (subscriptions)
  34. *
  35. * PHP version:
  36. * Tested with PHP 7.0
  37. * ----------------------------------------------------------------------------
  38. * File Authors:
  39. * o Zach Copley
  40. * o Evan Prodromou
  41. * o Robin Millette <robin@millette.info>
  42. * o Siebrand Mazeland <s.mazeland@xs4all.nl>
  43. * o Mikael Nordfeldth <mmn@hethane.se>
  44. * o Maiyannah Bishop <maiyannah.bishop@postactiv.com>
  45. *
  46. * Web:
  47. * o postActiv <http://www.postactiv.com>
  48. * o GNU social <https://www.gnu.org/s/social/>
  49. * ============================================================================
  50. */
  51. // This file is formatted so that it provides useful documentation output in
  52. // NaturalDocs. Please be considerate of this before changing formatting.
  53. if (!defined('POSTACTIV')) { exit(1); }
  54. /**
  55. * Ouputs the authenticating user's friends (subscriptions), each with
  56. * current Twitter-style status inline. They are ordered by the date
  57. * in which the user subscribed to them, 100 at a time.
  58. */
  59. class ApiUserFriendsAction extends ApiSubscriptionsAction
  60. {
  61. /**
  62. * Get the user's subscriptions (friends) as an array of profiles
  63. *
  64. * @return array Profiles
  65. */
  66. protected function getProfiles()
  67. {
  68. $offset = ($this->page - 1) * $this->count;
  69. $limit = $this->count + 1;
  70. $subs = null;
  71. if (isset($this->tag)) {
  72. $subs = $this->target->getTaggedSubscriptions(
  73. $this->tag, $offset, $limit
  74. );
  75. } else {
  76. $subs = $this->target->getSubscribed(
  77. $offset,
  78. $limit
  79. );
  80. }
  81. $profiles = array();
  82. while ($subs->fetch()) {
  83. $profiles[] = clone($subs);
  84. }
  85. return $profiles;
  86. }
  87. }
  88. // END OF FILE
  89. // ============================================================================
  90. ?>