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


PHP Subscription::start方法代码示例

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


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

示例1: subs_subscribe_to

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

示例2: complete

 /**
  * Complete a pending subscription, as we've got approval of some sort.
  *
  * @return Subscription
  */
 public function complete()
 {
     $subscriber = Profile::staticGet('id', $this->subscriber);
     $subscribed = Profile::staticGet('id', $this->subscribed);
     $sub = Subscription::start($subscriber, $subscribed, Subscription::FORCE);
     if ($sub) {
         $this->delete();
     }
     return $sub;
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:15,代码来源:Subscription_queue.php

示例3: complete

 /**
  * Complete a pending subscription, as we've got approval of some sort.
  *
  * @return Subscription
  */
 public function complete()
 {
     $subscriber = Profile::getKV('id', $this->subscriber);
     $subscribed = Profile::getKV('id', $this->subscribed);
     try {
         $sub = Subscription::start($subscriber, $subscribed, Subscription::FORCE);
         $this->delete();
     } catch (AlreadyFulfilledException $e) {
         common_debug('Tried to start a subscription which already existed.');
     }
     return $sub;
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:17,代码来源:Subscription_queue.php

示例4: onEndUserRegister

 /**
  * Called when a new user is registered.
  *
  * We find all users, and try to subscribe them to the new user, and
  * the new user to them. Exceptions (like silenced users or whatever)
  * are caught, logged, and ignored.
  *
  * @param Profile &$newProfile The new user's profile
  * @param User    &$newUser    The new user
  *
  * @return boolean hook value
  *
  */
 function onEndUserRegister(&$newProfile, &$newUser)
 {
     $otherUser = new User();
     $otherUser->whereAdd('id != ' . $newUser->id);
     if ($otherUser->find()) {
         while ($otherUser->fetch()) {
             $otherProfile = $otherUser->getProfile();
             try {
                 if (User_followeveryone_prefs::followEveryone($otherUser->id)) {
                     Subscription::start($otherProfile, $newProfile);
                 }
                 Subscription::start($newProfile, $otherProfile);
             } catch (Exception $e) {
                 common_log(LOG_WARNING, $e->getMessage());
                 continue;
             }
         }
     }
     $ufep = new User_followeveryone_prefs();
     $ufep->user_id = $newUser->id;
     $ufep->followeveryone = true;
     $ufep->insert();
     return true;
 }
开发者ID:ronhuang,项目名称:statusnet,代码行数:37,代码来源:FollowEveryonePlugin.php

示例5: handle

 function handle($channel)
 {
     if (!$this->other) {
         // TRANS: Error text shown when no username was provided when issuing a subscribe command.
         $channel->error($this->user, _('Specify the name of the user to subscribe to.'));
         return;
     }
     $target = $this->getProfile($this->other);
     $remote = Remote_profile::staticGet('id', $target->id);
     if ($remote) {
         // TRANS: Command exception text shown when trying to subscribe to an OMB profile using the subscribe command.
         throw new CommandException(_("Can't subscribe to OMB profiles by command."));
     }
     try {
         Subscription::start($this->user->getProfile(), $target);
         // TRANS: Text shown after having subscribed to another user successfully.
         // TRANS: %s is the name of the user the subscription was requested for.
         $channel->output($this->user, sprintf(_('Subscribed to %s.'), $this->other));
     } catch (Exception $e) {
         $channel->error($this->user, $e->getMessage());
     }
 }
开发者ID:stevertiqo,项目名称:StatusNet,代码行数:22,代码来源:command.php

示例6: 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

示例7: subscribeProfile

function subscribeProfile($user, $subject, $activity)
{
    $profile = $user->getProfile();
    if ($activity->objects[0]->id == $subject->id) {
        $other = $activity->actor;
        $otherUser = User::staticGet('uri', $other->id);
        if (!empty($otherUser)) {
            $otherProfile = $otherUser->getProfile();
        } else {
            throw new Exception("Can't force remote user to subscribe.");
        }
        // XXX: don't do this for untrusted input!
        Subscription::start($otherProfile, $profile);
    } else {
        if (empty($activity->actor) || $activity->actor->id == $subject->id) {
            $other = $activity->objects[0];
            $otherUser = User::staticGet('uri', $other->id);
            if (!empty($otherUser)) {
                $otherProfile = $otherUser->getProfile();
            } else {
                $oprofile = Ostatus_profile::ensureActivityObjectProfile($other);
                $otherProfile = $oprofile->localProfile();
            }
            Subscription::start($profile, $otherProfile);
        } else {
            throw new Exception("This activity seems unrelated to our user.");
        }
    }
}
开发者ID:stevertiqo,项目名称:StatusNet,代码行数:29,代码来源:restoreuser.php

示例8: subscribeTwitterFriends

 function subscribeTwitterFriends($flink)
 {
     $friends = $this->fetchTwitterFriends($flink);
     if (empty($friends)) {
         common_debug($this->name() . ' - Couldn\'t get friends from Twitter for ' . "Twitter user {$flink->foreign_id}.");
         return false;
     }
     $profile = $flink->getProfile();
     foreach ($friends as $friend) {
         $friend_name = $friend->screen_name;
         $friend_id = (int) $friend->id;
         // Update or create the Foreign_user record for each
         // Twitter friend
         if (!save_twitter_user($friend_id, $friend_name)) {
             common_log(LOG_WARNING, $this->name() . " - Couldn't save {$screen_name}'s friend, {$friend_name}.");
             continue;
         }
         // Check to see if there's a related local user
         $friend_flink = Foreign_link::getByForeignID($friend_id, TWITTER_SERVICE);
         if (!empty($friend_flink)) {
             // Get associated user and subscribe her
             $friend_profile = Profile::getKV('id', $friend_flink->user_id);
             if ($friend_profile instanceof Profile) {
                 try {
                     $other = Profile::getKV('id', $invites->user_id);
                     Subscription::start($profile, $friend_profile);
                     common_log(LOG_INFO, $this->name() . ' - Subscribed ' . "{$friend_profile->nickname} to {$profile->nickname}.");
                 } catch (Exception $e) {
                     common_debug($this->name() . ' - Tried and failed subscribing ' . "{$friend_profile->nickname} to {$profile->nickname} - " . $e->getMessage());
                 }
             }
         }
     }
     return true;
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:35,代码来源:synctwitterfriends.php

示例9: handle

 /**
  * Handle request
  *
  * Does the subscription and returns results.
  *
  * @param Array $args unused.
  *
  * @return void
  */
 function handle($args)
 {
     // Throws exception on error
     Subscription::start($this->user->getProfile(), $this->other);
     if ($this->boolean('ajax')) {
         $this->startHTML('text/xml;charset=utf-8');
         $this->elementStart('head');
         $this->element('title', null, _('Subscribed'));
         $this->elementEnd('head');
         $this->elementStart('body');
         $unsubscribe = new UnsubscribeForm($this, $this->other);
         $unsubscribe->show();
         $this->elementEnd('body');
         $this->elementEnd('html');
     } else {
         $url = common_local_url('subscriptions', array('nickname' => $this->user->nickname));
         common_redirect($url, 303);
     }
 }
开发者ID:stevertiqo,项目名称:StatusNet,代码行数:28,代码来源:subscribe.php

示例10: newSub

function newSub($i)
{
    global $userprefix;
    $f = rand(0, $i - 1);
    $fromnick = sprintf('%s%d', $userprefix, $f);
    $from = User::getKV('nickname', $fromnick);
    if (empty($from)) {
        throw new Exception("Can't find user '{$fromnick}'.");
    }
    $t = rand(0, $i - 1);
    if ($t == $f) {
        $t++;
        if ($t > $i - 1) {
            $t = 0;
        }
    }
    $tunic = sprintf('%s%d', $userprefix, $t);
    $to = User::getKV('nickname', $tunic);
    if (!$to instanceof User) {
        throw new Exception("Can't find user '{$tunic}'.");
    }
    Subscription::start($from->getProfile(), $to->getProfile());
    $from->free();
    $to->free();
}
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:25,代码来源:createsim.php

示例11: subscribeTwitterFriends

 function subscribeTwitterFriends(Foreign_link $flink)
 {
     try {
         $profile = $flink->getProfile();
     } catch (NoResultException $e) {
         common_log(LOG_WARNING, 'Foreign_link has no matching local profile for local ID: ' . $flink->user_id);
     }
     $friends = $this->fetchTwitterFriends($flink);
     if (empty($friends)) {
         common_debug($this->name() . ' - Couldn\'t get friends from Twitter for ' . "Twitter user {$flink->foreign_id}.");
         return false;
     }
     foreach ($friends as $friend) {
         $friend_name = $friend->screen_name;
         $friend_id = (int) $friend->id;
         // Update or create the Foreign_user record for each
         // Twitter friend
         if (!save_twitter_user($friend_id, $friend_name)) {
             common_log(LOG_WARNING, $this->name() . " - Couldn't save {$screen_name}'s friend, {$friend_name}.");
             continue;
         }
         // Check to see if there's a related local user and try to subscribe
         try {
             $friend_flink = Foreign_link::getByForeignID($friend_id, TWITTER_SERVICE);
             // Get associated user and subscribe her
             $friend_profile = $friend_flink->getProfile();
             Subscription::start($profile, $friend_profile);
             common_log(LOG_INFO, $this->name() . ' - Subscribed ' . "{$friend_profile->nickname} to {$profile->nickname}.");
         } catch (NoResultException $e) {
             // either no foreign link for this friend's foreign ID or no profile found on local ID.
         } catch (Exception $e) {
             common_debug($this->name() . ' - Tried and failed subscribing ' . "{$friend_profile->nickname} to {$profile->nickname} - " . $e->getMessage());
         }
     }
     return true;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:36,代码来源:synctwitterfriends.php

示例12: handleFollow

 /**
  * We've gotten a follow/subscribe notification from a remote user.
  * Save a subscription relationship for them.
  */
 function handleFollow()
 {
     $oprofile = $this->ensureProfile();
     if ($oprofile) {
         common_log(LOG_INFO, "Setting up subscription from remote {$oprofile->uri} to local {$this->user->nickname}");
         Subscription::start($oprofile->localProfile(), $this->user->getProfile());
     } else {
         common_log(LOG_INFO, "Can't set up subscription from remote; missing profile.");
     }
 }
开发者ID:stevertiqo,项目名称:StatusNet,代码行数:14,代码来源:usersalmon.php

示例13: emailChanged

 function emailChanged()
 {
     $invites = new Invitation();
     $invites->address = $this->email;
     $invites->address_type = 'email';
     if ($invites->find()) {
         while ($invites->fetch()) {
             try {
                 $other = Profile::getKV('id', $invites->user_id);
                 if (!$other instanceof Profile) {
                     // remove when getKV throws exceptions
                     continue;
                 }
                 Subscription::start($other, $this->getProfile());
             } catch (Exception $e) {
                 continue;
             }
         }
     }
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:20,代码来源:User.php

示例14: registerInitialUser

 /**
  * Create the initial admin user account.
  * Side effect: may load portions of StatusNet framework.
  * Side effect: outputs program info
  */
 function registerInitialUser()
 {
     define('STATUSNET', true);
     define('LACONICA', true);
     // compatibility
     require_once INSTALLDIR . '/lib/common.php';
     $data = array('nickname' => $this->adminNick, 'password' => $this->adminPass, 'fullname' => $this->adminNick);
     if ($this->adminEmail) {
         $data['email'] = $this->adminEmail;
     }
     $user = User::register($data);
     if (empty($user)) {
         return false;
     }
     // give initial user carte blanche
     $user->grantRole('owner');
     $user->grantRole('moderator');
     $user->grantRole('administrator');
     // Attempt to do a remote subscribe to update@status.net
     // Will fail if instance is on a private network.
     if ($this->adminUpdates && class_exists('Ostatus_profile')) {
         try {
             $oprofile = Ostatus_profile::ensureProfileURL('http://update.status.net/');
             Subscription::start($user->getProfile(), $oprofile->localProfile());
             $this->updateStatus("Set up subscription to <a href='http://update.status.net/'>update@status.net</a>.");
         } catch (Exception $e) {
             $this->updateStatus("Could not set up subscription to <a href='http://update.status.net/'>update@status.net</a>.", true);
         }
     }
     return true;
 }
开发者ID:sukhjindersingh,项目名称:PHInest-Solutions,代码行数:36,代码来源:installer.php

示例15: 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


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