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


PHP Ostatus_profile::ensureProfileURI方法代码示例

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


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

示例1: handle

 function handle($object)
 {
     list($user, $remote, $password) = $object;
     $remote = Discovery::normalize($remote);
     $oprofile = Ostatus_profile::ensureProfileURI($remote);
     if (empty($oprofile)) {
         // TRANS: Exception thrown when an account could not be located when it should be moved.
         // TRANS: %s is the remote site.
         throw new Exception(sprintf(_("Cannot locate account %s."), $remote));
     }
     list($svcDocUrl, $username) = self::getServiceDocument($remote);
     $sink = new ActivitySink($svcDocUrl, $username, $password);
     $this->log(LOG_INFO, "Moving user {$user->nickname} " . "to {$remote}.");
     $stream = new UserActivityStream($user);
     // Reverse activities to run in correct chron order
     $acts = array_reverse($stream->activities);
     $this->log(LOG_INFO, "Got " . count($acts) . " activities " . "for {$user->nickname}.");
     $qm = QueueManager::get();
     foreach ($acts as $act) {
         $qm->enqueue(array($act, $sink, $user->uri, $remote), 'actmove');
     }
     $this->log(LOG_INFO, "Finished moving user {$user->nickname} " . "to {$remote}.");
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:23,代码来源:accountmover.php

示例2: filterAttention

 protected function filterAttention(array $attn)
 {
     $groups = array();
     // TODO: context->attention
     $replies = array();
     // TODO: context->attention
     foreach ($attn as $recipient => $type) {
         // Is the recipient a local user?
         $user = User::getKV('uri', $recipient);
         if ($user instanceof User) {
             // TODO: @fixme sender verification, spam etc?
             $replies[] = $recipient;
             continue;
         }
         // Is the recipient a remote group?
         $oprofile = Ostatus_profile::ensureProfileURI($recipient);
         if ($oprofile) {
             if (!$oprofile->isGroup()) {
                 // may be canonicalized or something
                 $replies[] = $oprofile->uri;
             }
             continue;
         }
         // Is the recipient a local group?
         // TODO: @fixme uri on user_group isn't reliable yet
         // $group = User_group::getKV('uri', $recipient);
         $id = OStatusPlugin::localGroupFromUrl($recipient);
         if ($id) {
             $group = User_group::getKV('id', $id);
             if ($group) {
                 // Deliver to all members of this local group if allowed.
                 $profile = $sender->localProfile();
                 if ($profile->isMember($group)) {
                     $groups[] = $group->id;
                 } else {
                     common_log(LOG_INFO, "Skipping reply to local group {$group->nickname} as sender {$profile->id} is not a member");
                 }
                 continue;
             } else {
                 common_log(LOG_INFO, "Skipping reply to bogus group {$recipient}");
             }
         }
     }
     return array($groups, $replies);
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:45,代码来源:activityimporter.php

示例3: filterReplies

 /**
  * Filters a list of recipient ID URIs to just those for local delivery.
  * @param Ostatus_profile local profile of sender
  * @param array in/out &$attention_uris set of URIs, will be pruned on output
  * @return array of group IDs
  */
 protected function filterReplies($sender, &$attention_uris)
 {
     common_log(LOG_DEBUG, "Original reply recipients: " . implode(', ', $attention_uris));
     $groups = array();
     $replies = array();
     foreach (array_unique($attention_uris) as $recipient) {
         // Is the recipient a local user?
         $user = User::staticGet('uri', $recipient);
         if ($user) {
             // @todo FIXME: Sender verification, spam etc?
             $replies[] = $recipient;
             continue;
         }
         // Is the recipient a local group?
         // $group = User_group::staticGet('uri', $recipient);
         $id = OStatusPlugin::localGroupFromUrl($recipient);
         if ($id) {
             $group = User_group::staticGet('id', $id);
             if ($group) {
                 // Deliver to all members of this local group if allowed.
                 $profile = $sender->localProfile();
                 if ($profile->isMember($group)) {
                     $groups[] = $group->id;
                 } else {
                     common_log(LOG_DEBUG, "Skipping reply to local group {$group->nickname} as sender {$profile->id} is not a member");
                 }
                 continue;
             } else {
                 common_log(LOG_DEBUG, "Skipping reply to bogus group {$recipient}");
             }
         }
         // Is the recipient a remote user or group?
         try {
             $oprofile = Ostatus_profile::ensureProfileURI($recipient);
             if ($oprofile->isGroup()) {
                 // Deliver to local members of this remote group.
                 // @todo FIXME: Sender verification?
                 $groups[] = $oprofile->group_id;
             } else {
                 // may be canonicalized or something
                 $replies[] = $oprofile->uri;
             }
             continue;
         } catch (Exception $e) {
             // Neither a recognizable local nor remote user!
             common_log(LOG_DEBUG, "Skipping reply to unrecognized profile {$recipient}: " . $e->getMessage());
         }
     }
     $attention_uris = $replies;
     common_log(LOG_DEBUG, "Local reply recipients: " . implode(', ', $replies));
     common_log(LOG_DEBUG, "Local group recipients: " . implode(', ', $groups));
     return $groups;
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:59,代码来源:Ostatus_profile.php

示例4: onStartGetProfileFromURI

 function onStartGetProfileFromURI($uri, &$profile)
 {
     // Don't want to do Web-based discovery on our own server,
     // so we check locally first.
     $user = User::staticGet('uri', $uri);
     if (!empty($user)) {
         $profile = $user->getProfile();
         return false;
     }
     // Now, check remotely
     $oprofile = Ostatus_profile::ensureProfileURI($uri);
     if (!empty($oprofile)) {
         $profile = $oprofile->localProfile();
         return false;
     }
     // Still not a hit, so give up.
     return true;
 }
开发者ID:harriewang,项目名称:InnertieWebsite,代码行数:18,代码来源:OStatusPlugin.php

示例5: onStartGetProfileFromURI

 function onStartGetProfileFromURI($uri, &$profile)
 {
     // Don't want to do Web-based discovery on our own server,
     // so we check locally first.
     $user = User::getKV('uri', $uri);
     if (!empty($user)) {
         $profile = $user->getProfile();
         return false;
     }
     // Now, check remotely
     try {
         $oprofile = Ostatus_profile::ensureProfileURI($uri);
         $profile = $oprofile->localProfile();
         return !$profile instanceof Profile;
         // localProfile won't throw exception but can return null
     } catch (Exception $e) {
         return true;
         // It's not an OStatus profile as far as we know, continue event handling
     }
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:20,代码来源:OStatusPlugin.php

示例6: onStartGetProfileFromURI

 function onStartGetProfileFromURI($uri, &$profile)
 {
     // Don't want to do Web-based discovery on our own server,
     // so we check locally first. This duplicates the functionality
     // in the Profile class, since the plugin always runs before
     // that local lookup, but since we return false it won't run double.
     $user = User::getKV('uri', $uri);
     if ($user instanceof User) {
         $profile = $user->getProfile();
         return false;
     } else {
         $group = User_group::getKV('uri', $uri);
         if ($group instanceof User_group) {
             $profile = $group->getProfile();
             return false;
         }
     }
     // Now, check remotely
     try {
         $oprofile = Ostatus_profile::ensureProfileURI($uri);
         $profile = $oprofile->localProfile();
         return !$profile instanceof Profile;
         // localProfile won't throw exception but can return null
     } catch (Exception $e) {
         return true;
         // It's not an OStatus profile as far as we know, continue event handling
     }
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:28,代码来源:OStatusPlugin.php


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