當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。