tagunsub.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * StatusNet - the distributed open-source microblogging tool
  4. * Copyright (C) 2008-2011, StatusNet, Inc.
  5. *
  6. * Tag 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. * Tag 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 TagunsubAction extends TagsubAction
  53. {
  54. /**
  55. * Handle request
  56. *
  57. * Does the subscription and returns results.
  58. *
  59. * @return void
  60. * @throws ClientException
  61. */
  62. public function handle()
  63. {
  64. // Throws exception on error
  65. TagSub::cancel(
  66. $this->user->getProfile(),
  67. $this->tag
  68. );
  69. if ($this->boolean('ajax')) {
  70. $this->startHTML('text/xml;charset=utf-8');
  71. $this->elementStart('head');
  72. // TRANS: Page title when tag unsubscription succeeded.
  73. $this->element('title', null, _m('Unsubscribed'));
  74. $this->elementEnd('head');
  75. $this->elementStart('body');
  76. $subscribe = new TagSubForm($this, $this->tag);
  77. $subscribe->show();
  78. $this->elementEnd('body');
  79. $this->endHTML();
  80. } else {
  81. $url = common_local_url(
  82. 'tag',
  83. array('tag' => $this->tag)
  84. );
  85. common_redirect($url, 303);
  86. }
  87. }
  88. }