当前位置: 首页>>代码示例>>PHP>>正文


PHP Subscription::cancel方法代码示例

本文整理汇总了PHP中Subscription::cancel方法的典型用法代码示例。如果您正苦于以下问题:PHP Subscription::cancel方法的具体用法?PHP Subscription::cancel怎么用?PHP Subscription::cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Subscription的用法示例。


在下文中一共展示了Subscription::cancel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: subs_unsubscribe_to

function subs_unsubscribe_to($user, $other)
{
    try {
        Subscription::cancel($user->getProfile(), $other);
        return true;
    } catch (Exception $e) {
        return $e->getMessage();
    }
}
开发者ID:himmelex,项目名称:NTW,代码行数:9,代码来源:subs.php

示例2: handle

 function handle($args)
 {
     parent::handle($args);
     if (!common_logged_in()) {
         // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
         $this->clientError(_('Not logged in.'));
     }
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         common_redirect(common_local_url('subscriptions', array('nickname' => $this->scoped->nickname)));
     }
     /* Use a session token for CSRF protection. */
     $token = $this->trimmed('token');
     if (!$token || $token != common_session_token()) {
         // TRANS: Client error displayed when the session token does not match or is not given.
         $this->clientError(_('There was a problem with your session token. ' . 'Try again, please.'));
     }
     $other_id = $this->arg('unsubscribeto');
     if (!$other_id) {
         // TRANS: Client error displayed when trying to unsubscribe without providing a profile ID.
         $this->clientError(_('No profile ID in request.'));
     }
     $other = Profile::getKV('id', $other_id);
     if (!$other instanceof Profile) {
         // TRANS: Client error displayed when trying to unsubscribe while providing a non-existing profile ID.
         $this->clientError(_('No profile with that ID.'));
     }
     try {
         Subscription::cancel($this->scoped, $other);
     } catch (Exception $e) {
         $this->clientError($e->getMessage());
     }
     if ($this->boolean('ajax')) {
         $this->startHTML('text/xml;charset=utf-8');
         $this->elementStart('head');
         // TRANS: Page title for page to unsubscribe.
         $this->element('title', null, _('Unsubscribed'));
         $this->elementEnd('head');
         $this->elementStart('body');
         $subscribe = new SubscribeForm($this, $other);
         $subscribe->show();
         $this->elementEnd('body');
         $this->endHTML();
     } else {
         common_redirect(common_local_url('subscriptions', array('nickname' => $this->scoped->nickname)), 303);
     }
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:46,代码来源:unsubscribe.php

示例3: execute

 function execute($channel)
 {
     if (!$this->other) {
         $channel->error($this->user, _('Specify the name of the user to unsubscribe from'));
         return;
     }
     $result = Subscription::cancel($this->getProfile($this->other), $this->user->getProfile());
     if ($result) {
         $channel->output($this->user, sprintf(_('Unsubscribed  %s'), $this->other));
     } else {
         $channel->error($this->user, $result);
     }
 }
开发者ID:sukhjindersingh,项目名称:PHInest-Solutions,代码行数:13,代码来源:command.php

示例4: moveActivity

 function moveActivity($act, $sink, $user, $remote)
 {
     if (empty($user)) {
         throw new Exception(sprintf(_("No such user %s."), $act->actor->id));
     }
     switch ($act->verb) {
         case ActivityVerb::FAVORITE:
             $this->log(LOG_INFO, "Moving favorite of {$act->objects[0]->id} by " . "{$act->actor->id} to {$remote->nickname}.");
             // push it, then delete local
             $sink->postActivity($act);
             $notice = Notice::staticGet('uri', $act->objects[0]->id);
             if (!empty($notice)) {
                 $fave = Fave::pkeyGet(array('user_id' => $user->id, 'notice_id' => $notice->id));
                 $fave->delete();
             }
             break;
         case ActivityVerb::POST:
             $this->log(LOG_INFO, "Moving notice {$act->objects[0]->id} by " . "{$act->actor->id} to {$remote->nickname}.");
             // XXX: send a reshare, not a post
             $sink->postActivity($act);
             $notice = Notice::staticGet('uri', $act->objects[0]->id);
             if (!empty($notice)) {
                 $notice->delete();
             }
             break;
         case ActivityVerb::JOIN:
             $this->log(LOG_INFO, "Moving group join of {$act->objects[0]->id} by " . "{$act->actor->id} to {$remote->nickname}.");
             $sink->postActivity($act);
             $group = User_group::staticGet('uri', $act->objects[0]->id);
             if (!empty($group)) {
                 Group_member::leave($group->id, $user->id);
             }
             break;
         case ActivityVerb::FOLLOW:
             if ($act->actor->id == $user->uri) {
                 $this->log(LOG_INFO, "Moving subscription to {$act->objects[0]->id} by " . "{$act->actor->id} to {$remote->nickname}.");
                 $sink->postActivity($act);
                 $other = Profile::fromURI($act->objects[0]->id);
                 if (!empty($other)) {
                     Subscription::cancel($user->getProfile(), $other);
                 }
             } else {
                 $otherUser = User::staticGet('uri', $act->actor->id);
                 if (!empty($otherUser)) {
                     $this->log(LOG_INFO, "Changing sub to {$act->objects[0]->id}" . "by {$act->actor->id} to {$remote->nickname}.");
                     $otherProfile = $otherUser->getProfile();
                     Subscription::start($otherProfile, $remote);
                     Subscription::cancel($otherProfile, $user->getProfile());
                 } else {
                     $this->log(LOG_NOTICE, "Not changing sub to {$act->objects[0]->id}" . "by remote {$act->actor->id} " . "to {$remote->nickname}.");
                 }
             }
             break;
     }
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:55,代码来源:activitymover.php

示例5: block

 function block($other)
 {
     // Add a new block record
     // no blocking (and thus unsubbing from) yourself
     if ($this->id == $other->id) {
         common_log(LOG_WARNING, sprintf("Profile ID %d (%s) tried to block themself.", $this->id, $this->nickname));
         return false;
     }
     $block = new Profile_block();
     // Begin a transaction
     $block->query('BEGIN');
     $block->blocker = $this->id;
     $block->blocked = $other->id;
     $result = $block->insert();
     if (!$result) {
         common_log_db_error($block, 'INSERT', __FILE__);
         return false;
     }
     $self = $this->getProfile();
     if (Subscription::exists($other, $self)) {
         Subscription::cancel($other, $self);
     }
     if (Subscription::exists($self, $other)) {
         Subscription::cancel($self, $other);
     }
     $block->query('COMMIT');
     return true;
 }
开发者ID:stevertiqo,项目名称:StatusNet,代码行数:28,代码来源:User.php

示例6: _deleteSubscriptions

 function _deleteSubscriptions()
 {
     $sub = new Subscription();
     $sub->subscriber = $this->id;
     $sub->find();
     while ($sub->fetch()) {
         $other = Profile::staticGet('id', $sub->subscribed);
         if (empty($other)) {
             continue;
         }
         if ($other->id == $this->id) {
             continue;
         }
         Subscription::cancel($this, $other);
     }
     $subd = new Subscription();
     $subd->subscribed = $this->id;
     $subd->find();
     while ($subd->fetch()) {
         $other = Profile::staticGet('id', $subd->subscriber);
         if (empty($other)) {
             continue;
         }
         if ($other->id == $this->id) {
             continue;
         }
         Subscription::cancel($other, $this);
     }
     $self = new Subscription();
     $self->subscriber = $this->id;
     $self->subscribed = $this->id;
     $self->delete();
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:33,代码来源:Profile.php

示例7: handle

 /**
  * Handle the request
  *
  * Check the format and show the user info
  *
  * @return void
  */
 protected function handle()
 {
     parent::handle();
     if (!in_array($this->format, array('xml', 'json'))) {
         $this->clientError(_('API method not found.'), 404);
     }
     if (!$this->other instanceof Profile) {
         $this->clientError(_('Could not unfollow user: User not found.'), 403);
     }
     // Don't allow unsubscribing from yourself!
     if ($this->scoped->id == $this->other->id) {
         $this->clientError(_("You cannot unfollow yourself."), 403);
     }
     // throws an exception on error
     Subscription::cancel($this->scoped, $this->other);
     $this->initDocument($this->format);
     $this->showProfile($this->other, $this->format);
     $this->endDocument($this->format);
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:26,代码来源:apifriendshipsdestroy.php

示例8: get_blocked_subs

function get_blocked_subs()
{
    $query = "SELECT subscription.* " . "FROM subscription " . "INNER JOIN profile_block " . "ON blocker=subscribed " . "AND blocked=subscriber";
    $subscription = new Subscription();
    $subscription->query($query);
    return $subscription;
}
$dry = have_option('dry-run');
$sub = get_blocked_subs();
$count = $sub->N;
while ($sub->fetch()) {
    $subber = Profile::staticGet('id', $sub->subscriber);
    $subbed = Profile::staticGet('id', $sub->subscribed);
    if (!$subber || !$subbed) {
        print "Bogus entry! {$sub->subscriber} subbed to {$sub->subscribed}\n";
        continue;
    }
    print "{$subber->nickname} ({$subber->id}) blocked but subbed to {$subbed->nickname} ({$subbed->id})";
    if ($dry) {
        print ": skipping; dry run\n";
    } else {
        Subscription::cancel($subber, $subbed);
        print ": removed\n";
    }
}
print "\n";
if ($dry && $count > 0) {
    print "Be sure to run without --dry-run to remove the bad entries!\n";
} else {
    print "done.\n";
}
开发者ID:microcosmx,项目名称:experiments,代码行数:31,代码来源:fixup_blocks.php

示例9: updateOStatus

function updateOStatus($user)
{
    if (!have_option('q', 'quiet')) {
        echo "{$user->nickname}...";
    }
    $up = $user->getProfile();
    $sp = $user->getSubscriptions();
    $rps = array();
    while ($sp->fetch()) {
        $remote = Remote_profile::staticGet('id', $sp->id);
        if (!empty($remote)) {
            $rps[] = clone $sp;
        }
    }
    if (!have_option('q', 'quiet')) {
        echo count($rps) . "\n";
    }
    foreach ($rps as $rp) {
        try {
            if (!have_option('q', 'quiet')) {
                echo "Checking {$rp->nickname}...";
            }
            $op = Ostatus_profile::ensureProfileURL($rp->profileurl);
            if (empty($op)) {
                echo "can't convert.\n";
                continue;
            } else {
                if (!have_option('q', 'quiet')) {
                    echo "Converting...";
                }
                Subscription::start($up, $op->localProfile());
                Subscription::cancel($up, $rp);
                if (!have_option('q', 'quiet')) {
                    echo "done.\n";
                }
            }
        } catch (Exception $e) {
            if (!have_option('q', 'quiet')) {
                echo "fail.\n";
            }
            common_log(LOG_NOTICE, "Couldn't convert OMB subscription (" . $up->nickname . ", " . $rp->nickname . ") to OStatus: " . $e->getMessage());
            continue;
        }
    }
}
开发者ID:sukhjindersingh,项目名称:PHInest-Solutions,代码行数:45,代码来源:updateostatus.php

示例10: deleteSubscription

 /**
  * Delete the subscription
  *
  * @return void
  */
 function deleteSubscription()
 {
     if (!$this->scoped instanceof Profile || $this->scoped->id != $this->_subscriber->id) {
         // TRANS: Client exception thrown when trying to delete a subscription of another user.
         throw new ClientException(_("Cannot delete someone else's subscription."), 403);
     }
     Subscription::cancel($this->_subscriber, $this->_subscribed);
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:13,代码来源:atompubshowsubscription.php

示例11: moveActivity

 function moveActivity($act, $sink, $user, $remote)
 {
     if (empty($user)) {
         // TRANS: Exception thrown if a non-existing user is provided. %s is a user ID.
         throw new Exception(sprintf(_('No such user "%s".'), $act->actor->id));
     }
     switch ($act->verb) {
         /*        case ActivityVerb::FAVORITE:
                   $this->log(LOG_INFO,
                              "Moving favorite of {$act->objects[0]->id} by ".
                              "{$act->actor->id} to {$remote->nickname}.");
                   // push it, then delete local
                   $sink->postActivity($act);
                   $notice = Notice::getKV('uri', $act->objects[0]->id);
                   if (!empty($notice)) {
                       $fave = Fave::pkeyGet(array('user_id' => $user->id,
                                                   'notice_id' => $notice->id));
                       $fave->delete();
                   }
                   break;*/
         case ActivityVerb::POST:
             $this->log(LOG_INFO, "Moving notice {$act->objects[0]->id} by " . "{$act->actor->id} to {$remote->nickname}.");
             // XXX: send a reshare, not a post
             $sink->postActivity($act);
             $notice = Notice::getKV('uri', $act->objects[0]->id);
             if (!empty($notice)) {
                 $notice->delete();
             }
             break;
         case ActivityVerb::JOIN:
             $this->log(LOG_INFO, "Moving group join of {$act->objects[0]->id} by " . "{$act->actor->id} to {$remote->nickname}.");
             $sink->postActivity($act);
             $group = User_group::getKV('uri', $act->objects[0]->id);
             if (!empty($group)) {
                 $user->leaveGroup($group);
             }
             break;
         case ActivityVerb::FOLLOW:
             if ($act->actor->id === $user->getUri()) {
                 $this->log(LOG_INFO, "Moving subscription to {$act->objects[0]->id} by " . "{$act->actor->id} to {$remote->nickname}.");
                 $sink->postActivity($act);
                 try {
                     $other = Profile::fromUri($act->objects[0]->id);
                     Subscription::cancel($user->getProfile(), $other);
                 } catch (UnknownUriException $e) {
                     // Can't cancel subscription if we don't know who to alert
                 }
             } else {
                 $otherUser = User::getKV('uri', $act->actor->id);
                 if (!empty($otherUser)) {
                     $this->log(LOG_INFO, "Changing sub to {$act->objects[0]->id}" . "by {$act->actor->id} to {$remote->nickname}.");
                     $otherProfile = $otherUser->getProfile();
                     Subscription::ensureStart($otherProfile, $remote);
                     Subscription::cancel($otherProfile, $user->getProfile());
                 } else {
                     $this->log(LOG_NOTICE, "Not changing sub to {$act->objects[0]->id}" . "by remote {$act->actor->id} " . "to {$remote->nickname}.");
                 }
             }
             break;
     }
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:61,代码来源:activitymover.php

示例12: handleUnfollow

 /**
  * We've gotten an unfollow/unsubscribe notification from a remote user.
  * Check if we have a subscription relationship for them and kill it.
  *
  * @fixme probably catch exceptions on fail?
  */
 function handleUnfollow()
 {
     $oprofile = $this->ensureProfile();
     if ($oprofile) {
         common_log(LOG_INFO, "Canceling subscription from remote {$oprofile->uri} to local {$this->user->nickname}");
         Subscription::cancel($oprofile->localProfile(), $this->user->getProfile());
     } else {
         common_log(LOG_ERR, "Can't cancel subscription from remote, didn't find the profile");
     }
 }
开发者ID:stevertiqo,项目名称:StatusNet,代码行数:16,代码来源:usersalmon.php

示例13: _deleteSubscriptions

 function _deleteSubscriptions()
 {
     $sub = new Subscription();
     $sub->subscriber = $this->getID();
     $sub->find();
     while ($sub->fetch()) {
         try {
             $other = $sub->getSubscribed();
             if (!$other->sameAs($this)) {
                 Subscription::cancel($this, $other);
             }
         } catch (NoResultException $e) {
             // Profile not found
             common_log(LOG_INFO, 'Subscribed profile id==' . $sub->subscribed . ' not found when deleting profile id==' . $this->getID() . ', ignoring...');
         } catch (ServerException $e) {
             // Subscription cancel failed
             common_log(LOG_INFO, 'Subscribed profile id==' . $other->getID() . ' could not be reached for unsubscription notice when deleting profile id==' . $this->getID() . ', ignoring...');
         }
     }
     $sub = new Subscription();
     $sub->subscribed = $this->getID();
     $sub->find();
     while ($sub->fetch()) {
         try {
             $other = $sub->getSubscriber();
             common_log(LOG_INFO, 'Subscriber profile id==' . $sub->subscribed . ' not found when deleting profile id==' . $this->getID() . ', ignoring...');
             if (!$other->sameAs($this)) {
                 Subscription::cancel($other, $this);
             }
         } catch (NoResultException $e) {
             // Profile not found
             common_log(LOG_INFO, 'Subscribed profile id==' . $sub->subscribed . ' not found when deleting profile id==' . $this->getID() . ', ignoring...');
         } catch (ServerException $e) {
             // Subscription cancel failed
             common_log(LOG_INFO, 'Subscriber profile id==' . $other->getID() . ' could not be reached for unsubscription notice when deleting profile id==' . $this->getID() . ', ignoring...');
         }
     }
     // Finally delete self-subscription
     $self = new Subscription();
     $self->subscriber = $this->getID();
     $self->subscribed = $this->getID();
     $self->delete();
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:43,代码来源:Profile.php

示例14: handle

 /**
  * Handle the request
  *
  * Check the format and show the user info
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         $this->clientError(_('This method requires a POST.'), 400, $this->format);
         return;
     }
     if (!in_array($this->format, array('xml', 'json'))) {
         $this->clientError(_('API method not found.'), 404, $this->format);
         return;
     }
     if (empty($this->other)) {
         $this->clientError(_('Could not unfollow user: User not found.'), 403, $this->format);
         return;
     }
     // Don't allow unsubscribing from yourself!
     if ($this->user->id == $this->other->id) {
         $this->clientError(_("You cannot unfollow yourself."), 403, $this->format);
         return;
     }
     // throws an exception on error
     Subscription::cancel($this->user->getProfile(), $this->other);
     $this->initDocument($this->format);
     $this->showProfile($this->other, $this->format);
     $this->endDocument($this->format);
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:35,代码来源:apifriendshipsdestroy.php

示例15: deleteSubscription

 /**
  * Delete the subscription
  *
  * @return void
  */
 function deleteSubscription()
 {
     if (empty($this->auth_user) || $this->auth_user->id != $this->_subscriber->id) {
         // TRANS: Client exception thrown when trying to delete a subscription of another user.
         throw new ClientException(_("Cannot delete someone else's " . "subscription."), 403);
     }
     Subscription::cancel($this->_subscriber, $this->_subscribed);
     return;
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:14,代码来源:atompubshowsubscription.php


注:本文中的Subscription::cancel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。