searchsubtrackingcommand.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. defined('GNUSOCIAL') || die();
  17. class SearchSubTrackingCommand extends Command
  18. {
  19. public function handle($channel)
  20. {
  21. $cur = $this->user;
  22. $all = new SearchSub();
  23. $all->profile_id = $cur->id;
  24. $all->find();
  25. if ($all->N == 0) {
  26. // TRANS: Error text shown a user tries to disable all a search subscriptions with track off command, but has none.
  27. $channel->error($cur, _m('You are not tracking any searches.'));
  28. return;
  29. }
  30. $list = array();
  31. while ($all->fetch()) {
  32. $list[] = $all->search;
  33. }
  34. // TRANS: Separator for list of tracked searches.
  35. $separator = _m('SEPARATOR', '", "');
  36. // TRANS: Message given having disabled all search subscriptions with 'track off'.
  37. // TRANS: %s is a list of searches. Separator default is '", "'.
  38. $channel->output($cur, sprintf(
  39. _m('You are tracking searches for: "%s".'),
  40. implode($separator, $list)
  41. ));
  42. }
  43. }