123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- require_once INSTALLDIR . '/lib/togglepeopletag.php';
- class AddpeopletagAction extends Action
- {
- var $user;
- var $tagged;
- var $peopletag;
-
- function prepare(array $args = array())
- {
- parent::prepare($args);
-
- $token = $this->trimmed('token');
- if (!$token || $token != common_session_token()) {
-
- $this->clientError(_('There was a problem with your session token.'.
- ' Try again, please.'));
- }
-
- $this->user = common_current_user();
- if (empty($this->user)) {
-
- $this->clientError(_('Not logged in.'));
- }
-
- $tagged_id = $this->arg('tagged');
- $this->tagged = Profile::getKV('id', $tagged_id);
- if (empty($this->tagged)) {
-
- $this->clientError(_('No such profile.'));
- }
- $id = $this->arg('peopletag_id');
- $this->peopletag = Profile_list::getKV('id', $id);
- if (empty($this->peopletag)) {
-
- $this->clientError(_('No such list.'));
- }
- return true;
- }
-
- function handle()
- {
-
- $ptag = Profile_tag::setTag($this->user->id, $this->tagged->id,
- $this->peopletag->tag);
- if (!$ptag) {
- $user = User::getKV('id', $id);
- if ($user) {
- $this->clientError(
-
-
- sprintf(_('There was an unexpected error while listing %s.'),
- $user->nickname));
- } else {
-
-
- $this->clientError(sprintf(_('There was a problem listing %s. ' .
- 'The remote server is probably not responding correctly. ' .
- 'Please try retrying later.'), $this->profile->profileurl));
- }
- }
- if ($this->boolean('ajax')) {
- $this->startHTML('text/xml;charset=utf-8');
- $this->elementStart('head');
-
- $this->element('title', null, _m('TITLE','Listed'));
- $this->elementEnd('head');
- $this->elementStart('body');
- $unsubscribe = new UntagButton($this, $this->tagged, $this->peopletag);
- $unsubscribe->show();
- $this->elementEnd('body');
- $this->endHTML();
- } else {
- $url = common_local_url('subscriptions',
- array('nickname' => $this->user->nickname));
- common_redirect($url, 303);
- }
- }
- }
|