searchunsub.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * StatusNet - the distributed open-source microblogging tool
  4. * Copyright (C) 2008-2011, StatusNet, Inc.
  5. *
  6. * Search subscription action.
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. * PHP version 5
  22. *
  23. * @category Action
  24. * @package StatusNet
  25. * @author Brion Vibber <brion@status.net>
  26. * @author Evan Prodromou <evan@status.net>
  27. * @copyright 2008-2010 StatusNet, Inc.
  28. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
  29. * @link http://status.net/
  30. */
  31. if (!defined('STATUSNET')) {
  32. exit(1);
  33. }
  34. /**
  35. * Search unsubscription action
  36. *
  37. * Takes parameters:
  38. *
  39. * - token: session token to prevent CSRF attacks
  40. * - ajax: boolean; whether to return Ajax or full-browser results
  41. *
  42. * Only works if the current user is logged in.
  43. *
  44. * @category Action
  45. * @package StatusNet
  46. * @author Evan Prodromou <evan@status.net>
  47. * @author Brion Vibber <brion@status.net>
  48. * @copyright 2008-2011 StatusNet, Inc.
  49. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
  50. * @link http://status.net/
  51. */
  52. class SearchunsubAction extends SearchsubAction
  53. {
  54. /**
  55. * Handle request
  56. *
  57. * Does the subscription and returns results.
  58. *
  59. * @param Array $args unused.
  60. *
  61. * @return void
  62. */
  63. function handle($args)
  64. {
  65. // Throws exception on error
  66. SearchSub::cancel($this->user->getProfile(),
  67. $this->search);
  68. if ($this->boolean('ajax')) {
  69. $this->startHTML('text/xml;charset=utf-8');
  70. $this->elementStart('head');
  71. // TRANS: Page title when search unsubscription succeeded.
  72. $this->element('title', null, _m('Unsubscribed'));
  73. $this->elementEnd('head');
  74. $this->elementStart('body');
  75. $subscribe = new SearchSubForm($this, $this->search);
  76. $subscribe->show();
  77. $this->elementEnd('body');
  78. $this->endHTML();
  79. } else {
  80. $url = common_local_url('search',
  81. array('search' => $this->search));
  82. common_redirect($url, 303);
  83. }
  84. }
  85. }