當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::isLocalUUID方法代碼示例

本文整理匯總了PHP中Idno\Entities\User::isLocalUUID方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::isLocalUUID方法的具體用法?PHP User::isLocalUUID怎麽用?PHP User::isLocalUUID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Idno\Entities\User的用法示例。


在下文中一共展示了User::isLocalUUID方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: postContent

 function postContent()
 {
     $this->createGatekeeper();
     $user = \Idno\Core\site()->session()->currentUser();
     if ($uuid = $this->getInput('uuid')) {
         if (!($new_user = \Idno\Entities\User::getByUUID($uuid)) && !($new_user = \Idno\Entities\User::getByProfileURL($uuid)) && !($new_user = \Idno\Entities\RemoteUser::getByUUID($uuid)) && !($new_user = \Idno\Entities\RemoteUser::getByProfileURL($uuid))) {
             // No user found, so create it if it's remote
             if (!\Idno\Entities\User::isLocalUUID($uuid)) {
                 \Idno\Core\site()->logging->log("Creating new remote user", LOGLEVEL_DEBUG);
                 $new_user = new \Idno\Entities\RemoteUser();
                 // Populate with data
                 $new_user->setTitle($this->getInput('name'));
                 $new_user->setHandle($this->getInput('nickname'));
                 $new_user->email = $this->getInput('email');
                 $new_user->setUrl($uuid);
                 // TODO: Get a profile URL - get it from passed photo variable, upload to local and treat as avatar.
                 if (!$new_user->save()) {
                     throw new \Exception("There was a problem saving the new remote user.");
                 }
             }
         } else {
             \Idno\Core\site()->logging->log("New user found as " . $new_user->uuid, LOGLEVEL_DEBUG);
         }
         if ($new_user) {
             \Idno\Core\site()->logging->log("Trying a follow", LOGLEVEL_DEBUG);
             if ($user->addFollowing($new_user)) {
                 \Idno\Core\site()->logging->log("User added to following", LOGLEVEL_DEBUG);
                 if ($user->save()) {
                     \Idno\Core\site()->logging->log("Following saved", LOGLEVEL_DEBUG);
                     // Ok, we've saved the new user, now, lets subscribe to their feeds
                     if ($feed = \Idno\Core\site()->reader()->getFeedObject($new_user->getURL())) {
                         \Idno\Core\site()->session()->addMessage("You are now following " . $new_user->getTitle() . ', would you like to subscribe to their feed?');
                         $this->forward(\Idno\Core\site()->config()->getURL() . 'following/confirm/?feed=' . urlencode($new_user->getURL()));
                     }
                     \Idno\Core\site()->session()->addMessage("You are now following " . $new_user->getTitle());
                 }
             } else {
                 \Idno\Core\site()->logging->log('Could not follow user for some reason (probably already following)', LOGLEVEL_DEBUG);
                 \Idno\Core\site()->session()->addErrorMessage('You\'re already following ' . $this->getInput('name'));
             }
         } else {
             throw new \Exception('Sorry, that user doesn\'t exist!');
         }
     } else {
         throw new \Exception("No UUID, please try that again!");
     }
 }
開發者ID:hank,項目名稱:Known,代碼行數:47,代碼來源:Bookmarklet.php

示例2: postContent

 function postContent()
 {
     $this->createGatekeeper();
     $user = \Idno\Core\site()->session()->currentUser();
     if ($uuid = $this->getInput('uuid')) {
         if (!($new_user = \Idno\Entities\User::getByUUID($uuid)) && !($new_user = \Idno\Entities\User::getByProfileURL($uuid)) && !($new_user = \Idno\Entities\RemoteUser::getByUUID($uuid)) && !($new_user = \Idno\Entities\RemoteUser::getByProfileURL($uuid))) {
             // No user found, so create it if it's remote
             if (!\Idno\Entities\User::isLocalUUID($uuid)) {
                 \Idno\Core\site()->logging->log("Creating new remote user", LOGLEVEL_DEBUG);
                 $new_user = new \Idno\Entities\RemoteUser();
                 // Populate with data
                 $new_user->setTitle($this->getInput('name'));
                 $new_user->setHandle($this->getInput('nickname'));
                 $new_user->email = $this->getInput('email');
                 $new_user->setUrl($uuid);
                 if (!$new_user->save()) {
                     throw new \Exception("There was a problem saving the new remote user.");
                 }
             }
         } else {
             \Idno\Core\site()->logging->log("New user found as " . $new_user->uuid, LOGLEVEL_DEBUG);
         }
         if ($new_user) {
             \Idno\Core\site()->logging->log("Trying a follow", LOGLEVEL_DEBUG);
             if ($user->addFollowing($new_user)) {
                 \Idno\Core\site()->logging->log("User added to following", LOGLEVEL_DEBUG);
                 if ($user->save()) {
                     \Idno\Core\site()->logging->log("Following saved", LOGLEVEL_DEBUG);
                     \Idno\Core\site()->session()->addMessage("You are now following " . $new_user->getTitle());
                 }
             } else {
                 \Idno\Core\site()->logging->log('Could not follow user for some reason (probably already following)', LOGLEVEL_DEBUG);
             }
         } else {
             throw new \Exception('Sorry, that user doesn\'t exist!');
         }
     } else {
         throw new \Exception("No UUID, please try that again!");
     }
 }
開發者ID:avewrigley,項目名稱:idno,代碼行數:40,代碼來源:Bookmarklet.php


注:本文中的Idno\Entities\User::isLocalUUID方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。