123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- <?php
- if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
- }
- class SubscribepeopletagAction extends Action
- {
- var $peopletag = null;
- var $tagger = null;
-
- function prepare($args)
- {
- parent::prepare($args);
- if (!common_logged_in()) {
-
- $this->clientError(_('You must be logged in to unsubscribe from a list.'));
- }
-
- if ($_SERVER['REQUEST_METHOD'] != 'POST') {
-
- $this->clientError(_('This action only accepts POST requests.'));
- }
-
- $token = $this->trimmed('token');
- if (!$token || $token != common_session_token()) {
-
- $this->clientError(_('There was a problem with your session token.'.
- ' Try again, please.'));
- }
- $tagger_arg = $this->trimmed('tagger');
- $tag_arg = $this->trimmed('tag');
- $id = intval($this->arg('id'));
- if ($id) {
- $this->peopletag = Profile_list::getKV('id', $id);
- } else {
-
- $this->clientError(_('No ID given.'), 404);
- }
- if (!$this->peopletag || $this->peopletag->private) {
-
- $this->clientError(_('No such list.'), 404);
- }
- $this->tagger = Profile::getKV('id', $this->peopletag->tagger);
- return true;
- }
-
- function handle($args)
- {
- parent::handle($args);
- $cur = common_current_user();
- try {
- Profile_tag_subscription::add($this->peopletag, $cur);
- } catch (Exception $e) {
-
-
- $this->serverError(sprintf(_('Could not subscribe user %1$s to list %2$s: %3$s'),
- $cur->nickname, $this->peopletag->tag), $e->getMessage());
- }
- if ($this->boolean('ajax')) {
- $this->startHTML('text/xml;charset=utf-8');
- $this->elementStart('head');
-
-
- $this->element('title', null, sprintf(_('%1$s subscribed to list %2$s by %3$s'),
- $cur->nickname,
- $this->peopletag->tag,
- $this->tagger->nickname));
- $this->elementEnd('head');
- $this->elementStart('body');
- $lf = new UnsubscribePeopletagForm($this, $this->peopletag);
- $lf->show();
- $this->elementEnd('body');
- $this->endHTML();
- } else {
- common_redirect(common_local_url('peopletagsubscribers',
- array('tagger' => $this->tagger->nickname,
- 'tag' =>$this->peopletag->tag)),
- 303);
- }
- }
- }
|