searchsubtrackoffcommand.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. class SearchSubTrackoffCommand extends Command
  3. {
  4. function handle($channel)
  5. {
  6. $cur = $this->user;
  7. $all = new SearchSub();
  8. $all->profile_id = $cur->id;
  9. $all->find();
  10. if ($all->N == 0) {
  11. // TRANS: Error text shown a user tries to disable all a search subscriptions with track off command, but has none.
  12. $channel->error($cur, _m('You are not tracking any searches.'));
  13. return;
  14. }
  15. $profile = $cur->getProfile();
  16. while ($all->fetch()) {
  17. try {
  18. SearchSub::cancel($profile, $all->search);
  19. } catch (Exception $e) {
  20. // TRANS: Message given having failed to cancel one of the search subs with 'track off' command.
  21. // TRANS: %s is the search for which the subscription removal failed.
  22. $channel->error($cur, sprintf(_m('Error disabling search subscription for query "%s".'),
  23. $all->search));
  24. return;
  25. }
  26. }
  27. // TRANS: Message given having disabled all search subscriptions with 'track off'.
  28. $channel->output($cur, _m('Disabled all your search subscriptions.'));
  29. }
  30. }