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


PHP User::getByUUID方法代码示例

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


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

示例1: postContent

 function postContent()
 {
     $this->adminGatekeeper();
     // Admins only
     $action = $this->getInput('action');
     switch ($action) {
         case 'add_rights':
             $uuid = $this->getInput('user');
             if ($user = User::getByUUID($uuid)) {
                 $user->setAdmin(true);
                 $user->save();
                 \Idno\Core\site()->session()->addMessage($user->getTitle() . " was given administration rights.");
             }
             break;
         case 'remove_rights':
             $uuid = $this->getInput('user');
             if ($user = User::getByUUID($uuid)) {
                 $user->setAdmin(false);
                 $user->save();
                 \Idno\Core\site()->session()->addMessage($user->getTitle() . " was stripped of their administration rights.");
             }
             break;
         case 'delete':
             $uuid = $this->getInput('user');
             if ($user = User::getByUUID($uuid)) {
                 if ($user->delete()) {
                     \Idno\Core\site()->session()->addMessage($user->getTitle() . " was removed from your site.");
                 }
             }
             break;
         case 'invite_users':
             $emails = $this->getInput('invitation_emails');
             preg_match_all('/[a-z\\d._%+-]+@[a-z\\d.-]+\\.[a-z]{2,4}\\b/i', $emails, $matches);
             $invitation_count = 0;
             if (!empty($matches[0])) {
                 if (is_array($matches[0])) {
                     foreach ($matches[0] as $email) {
                         if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
                             if (!($user = User::getByEmail($email))) {
                                 if ((new Invitation())->sendToEmail($email) !== 0) {
                                     $invitation_count++;
                                 }
                             }
                         }
                     }
                 }
             }
             if ($invitation_count > 1) {
                 \Idno\Core\site()->session()->addMessage("{$invitation_count} invitations were sent.");
             } else {
                 if ($invitation_count == 1) {
                     \Idno\Core\site()->session()->addMessage("Your invitation was sent.");
                 } else {
                     \Idno\Core\site()->session()->addMessage("No email addresses were found or all the people you invited are already members of this site.");
                 }
             }
             break;
     }
     $this->forward(\Idno\Core\site()->config()->getURL() . 'admin/users');
 }
开发者ID:uniteddiversity,项目名称:Known,代码行数:60,代码来源:Users.php

示例2: post

 function post()
 {
     $this->flushBrowser();
     \Idno\Core\site()->logging->log("Loading the user registration callback", LOGLEVEL_DEBUG);
     $contents = $this->getInput('content');
     $auth_token = $this->getInput('auth_token');
     $time = $this->getInput('time');
     $signature = $this->getInput('signature');
     $secret = \Idno\Core\site()->hub()->secret;
     $hmac = hash_hmac('sha1', $contents . $time . $auth_token, $secret);
     if ($hmac == $signature) {
         if ($contents = json_decode($contents)) {
             if (!empty($contents->user)) {
                 if ($user = \Idno\Entities\User::getByUUID($contents->user)) {
                     $user->hub_settings = array('token' => $contents->auth_token, 'secret' => $contents->secret);
                     $user->save();
                     $result = array('status' => 'ok', 'message' => 'Credentials were stored.');
                 } else {
                     $result = array('status' => 'fail', 'message' => 'Couldn\'t find user: ' . $contents->user);
                 }
             } else {
                 $result = array('status' => 'fail', 'message' => 'No user was sent');
             }
         } else {
             $result = array('status' => 'fail', 'message' => 'Contents were invalid');
         }
     }
     if (empty($result)) {
         $result = array('status' => 'fail', 'message' => 'Signature does not match: ' . $signature . ', ' . $hmac);
     }
     echo json_encode($result);
     exit;
 }
开发者ID:hank,项目名称:Known,代码行数:33,代码来源:User.php

示例3: getActor

 function getActor()
 {
     if (is_string($this->actor)) {
         return User::getByUUID($this->actor);
     }
     return $this->actor;
 }
开发者ID:kreativmind,项目名称:Known,代码行数:7,代码来源:Notification.php

示例4: canEdit

 function canEdit($user_id = '')
 {
     if (empty($user_id)) {
         $user = \Idno\Core\site()->session()->currentUser();
     } else {
         $user = User::getByUUID($user_id);
     }
     if (!$user instanceof User) {
         return false;
     }
     if (!$user->isAdmin()) {
         return false;
     }
     return true;
 }
开发者ID:emory,项目名称:Known,代码行数:15,代码来源:StaticPage.php

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

示例6: getRemoteLink

 /**
  * Retrieves a link that will allow the current user to log into the hub page at $endpoint
  *
  * @param $endpoint
  * @param $callback
  * @return bool|string
  */
 function getRemoteLink($endpoint, $callback)
 {
     $user = site()->session()->currentUser();
     $user = User::getByUUID($user->getUUID());
     site()->session()->refreshSessionUser($user);
     if ($this->userIsRegistered($user)) {
         if (!empty($user->hub_settings['token'])) {
             $time = time();
             $signature = hash_hmac('sha1', $user->hub_settings['token'] . $time, $user->hub_settings['secret']);
             return $this->server . $endpoint . '?token=' . urlencode($user->hub_settings['token']) . '&time=' . $time . '&signature=' . $signature . '&callback=' . urlencode($callback);
         }
     }
     return false;
 }
开发者ID:johnellison,项目名称:90days,代码行数:21,代码来源:Hub.php

示例7: refreshCurrentSessionuser

 /**
  * If we're logged in, refresh the current session user.
  */
 function refreshCurrentSessionuser()
 {
     if (!$this->currentUser() && !empty($_SESSION['user_uuid'])) {
         $this->user = User::getByUUID($_SESSION['user_uuid']);
     } else {
         if ($this->isLoggedIn()) {
             $user_uuid = $this->currentUserUUID();
             if ($user = User::getByUUID($user_uuid)) {
                 $this->refreshSessionUser($user);
             } else {
                 $this->logUserOff();
             }
         }
     }
 }
开发者ID:benwerd,项目名称:Known,代码行数:18,代码来源:Session.php

示例8: addAnnotation

 /**
  * Adds an annotation to the entity.
  * @param string $subtype Annotation subtype. 'comment' etc.
  * @param string $owner_name Name of the annotation's owner
  * @param string $owner_url Annotation owner's URL
  * @param string $owner_image Annotation owner's image, if one exists (include a blank string otherwise)
  * @param string $content Content of the annotation
  * @param string|null $annotation_url If included, the existing URL of this annotation
  * @param int $time The UNIX timestamp associated with this annotation (if set to 0, as is default, will be current time)
  * @param string $title The title associated with this annotation (blank by default)
  * @param bool $send_notification Should this call trigger a notifiation? (Default: yes)
  * @return bool Depending on success
  */
 function addAnnotation($subtype, $owner_name, $owner_url, $owner_image, $content, $annotation_url = null, $time = null, $title = '', $send_notification = true)
 {
     if (empty($subtype)) {
         return false;
     }
     if (empty($annotation_url)) {
         $annotation_url = $this->getURL() . '/annotations/' . md5(time() . $content);
         // Invent a URL for this annotation
     }
     $post_existed = false;
     if ($existing_annotations = $this->getAnnotations($subtype)) {
         foreach ($existing_annotations as $existing_local_url => $existing_annotation) {
             if ($existing_annotation['permalink'] == $annotation_url) {
                 $local_url = $existing_local_url;
                 $post_existed = true;
             }
         }
     }
     if (empty($local_url)) {
         $local_url = $this->getURL() . '/annotations/' . md5(time() . $content);
         // Invent a URL for this annotation if we don't have one already
     }
     if (empty($time)) {
         $time = time();
     } else {
         $time = (int) $time;
     }
     $annotation = array('permalink' => $annotation_url, 'owner_name' => $owner_name, 'owner_url' => $owner_url, 'owner_image' => $owner_image, 'content' => $content, 'time' => $time, 'title' => $title);
     $annotations = $this->annotations;
     if (empty($annotations)) {
         $annotations = array();
     }
     if (empty($annotations[$subtype])) {
         $annotations[$subtype] = array();
     }
     // Ask whether it's ok to save this annotation (allows filtering)
     if (!\Idno\Core\Idno::site()->triggerEvent('annotation/save', array('annotation' => $annotation, 'object' => $this))) {
         return false;
         // Something prevented the annotation from being saved.
     }
     $annotations[$subtype][$local_url] = $annotation;
     $this->annotations = $annotations;
     $this->save();
     \Idno\Core\Idno::site()->triggerEvent('annotation/add/' . $subtype, array('annotation' => $annotation, 'object' => $this));
     if ($recipients = $this->getAnnotationOwnerUUIDs(true)) {
         $recipients[] = $this->getOwnerID();
         $recipients = array_unique($recipients);
     } else {
         $recipients = array($this->getOwnerID());
     }
     if ($send_notification) {
         foreach ($recipients as $recipient_uuid) {
             if (Idno::site()->session()->isLoggedIn()) {
                 if ($recipient_uuid == Idno::site()->session()->currentUserUUID()) {
                     // Don't bother sending a notification to the user performing the action
                     // Note: for received webmentions, no user will ever be logged in, so this only applies to local comments
                     continue;
                 }
             }
             // Don't send a notification to the commenter
             if ($recipient_uuid === $owner_url) {
                 continue;
             }
             if ($recipient = User::getByUUID($recipient_uuid)) {
                 $send = true;
                 switch ($subtype) {
                     case 'mention':
                     case 'reply':
                         if ($recipient_uuid == $this->getOwnerID()) {
                             $subject = $owner_name . ' replied to your post!';
                         } else {
                             $subject = $owner_name . ' replied!';
                         }
                         $notification_template = 'content/notification/reply';
                         $context = 'reply';
                         break;
                     case 'like':
                         if ($recipient_uuid == $this->getOwnerID()) {
                             $subject = $owner_name . ' liked your post!';
                         } else {
                             $send = false;
                         }
                         $notification_template = 'content/notification/like';
                         $context = 'like';
                         break;
                     case 'share':
                         if ($recipient_uuid == $this->getOwnerID()) {
//.........这里部分代码省略.........
开发者ID:knownunknowns,项目名称:Known,代码行数:101,代码来源:Entity.php

示例9: canEdit

 /**
  * Can a specified user (either an explicitly specified user ID
  * or the currently logged-in user if this is left blank) edit
  * this entity?
  *
  * @param string $user_id
  * @return true|false
  */
 function canEdit($user_id = '')
 {
     if (!\Idno\Core\site()->session()->isLoggedOn()) {
         return false;
     }
     if (!\Idno\Core\site()->canWrite()) {
         return false;
     }
     if (empty($user_id)) {
         $user_id = \Idno\Core\site()->session()->currentUserUUID();
     }
     if ($user_id = \Idno\Core\site()->session()->currentUserUUID()) {
         $user = \Idno\Core\site()->session()->currentUser();
     } else {
         $user = User::getByUUID($user_id);
     }
     if ($user->isAdmin()) {
         return true;
     }
     if ($this->getOwnerID() == $user_id) {
         return true;
     }
     return \Idno\Core\site()->triggerEvent('canEdit', ['object' => $this, 'user_id' => $user_id], false);
 }
开发者ID:avewrigley,项目名称:idno,代码行数:32,代码来源:Entity.php

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

示例11: canWrite

 /**
  * Can a specified user (either an explicitly specified user ID
  * or the currently logged-in user if this is left blank) publish
  * to the site?
  *
  * @param string $user_id
  * @return true|false
  */
 function canWrite($user_id = '')
 {
     if (!\Idno\Core\Idno::site()->session()->isLoggedOn()) {
         return false;
     }
     if (empty($user_id)) {
         $user_id = \Idno\Core\Idno::site()->session()->currentUserUUID();
     }
     if ($user = \Idno\Entities\User::getByUUID($user_id)) {
         // Remote users can't ever create anything :( - for now
         if ($user instanceof \Idno\Entities\RemoteUser) {
             return false;
         }
         // But local users can
         if ($user instanceof \Idno\Entities\User) {
             if (empty($user->read_only)) {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:jirkadus,项目名称:Known,代码行数:30,代码来源:Idno.php

示例12: refreshSessionUser

 /**
  * Refresh the user currently stored in the session
  * @param \Idno\Entities\User $user
  * @return \Idno\Entities\User
  */
 function refreshSessionUser(\Idno\Entities\User $user)
 {
     if ($user = User::getByUUID($user->getUUID())) {
         $_SESSION['user'] = $user;
         return $user;
     }
     return false;
 }
开发者ID:avewrigley,项目名称:idno,代码行数:13,代码来源:Session.php

示例13: refreshCurrentSessionuser

 /**
  * If we're logged in, refresh the current session user.
  */
 function refreshCurrentSessionuser()
 {
     if (!$this->currentUser() && !empty($_SESSION['user_uuid'])) {
         if ($this->user = User::getByUUID($_SESSION['user_uuid'])) {
             if (\Idno\Core\Idno::site()->config()->emailIsBlocked($this->user->email)) {
                 $this->logUserOff();
             }
         }
     } else {
         if ($this->isLoggedIn()) {
             $user_uuid = $this->currentUserUUID();
             if ($user = User::getByUUID($user_uuid)) {
                 $this->refreshSessionUser($user);
             } else {
                 $this->logUserOff();
             }
         }
     }
 }
开发者ID:d6-9b,项目名称:Known,代码行数:22,代码来源:Session.php

示例14: getExportRSS

 /**
  * Retrieve all posts as an RSS feed
  * @param bool|true $hide_private Should we hide private posts? Default: true.
  * @param string $user_uuid User UUID to export for. Default: all users.
  * @return bool|false|string
  */
 static function getExportRSS($hide_private = true, $user_uuid = '')
 {
     $types = \Idno\Common\ContentType::getRegisteredClasses();
     if ($hide_private) {
         $groups = ['PUBLIC'];
     } else {
         $groups = [];
     }
     if (!empty($user_uuid)) {
         $search = ['owner' => $user_uuid];
         if ($user = User::getByUUID($user_uuid)) {
             $title = $user->getTitle();
             $description = $user->getDescription();
             $base_url = $user_uuid;
         }
     } else {
         $search = [];
         $title = Idno::site()->config()->getTitle();
         $description = Idno::site()->config()->getDescription();
         $base_url = Idno::site()->config()->getDisplayURL();
     }
     if ($feed = \Idno\Common\Entity::getFromX($types, $search, array(), PHP_INT_MAX - 1, 0, $groups)) {
         $rss_theme = new Template();
         $rss_theme->setTemplateType('rss');
         return $rss_theme->__(array('title' => $title, 'description' => $description, 'body' => $rss_theme->__(array('items' => $feed, 'offset' => 0, 'count' => sizeof($feed), 'subject' => [], 'nocdata' => true, 'base_url' => $base_url))->draw('pages/home')))->drawPage(false);
     }
     return false;
 }
开发者ID:kylewm,项目名称:Known,代码行数:34,代码来源:Migration.php

示例15: addAnnotation

 /**
  * Adds an annotation to the entity.
  * @param string $subtype Annotation subtype. 'comment' etc.
  * @param string $owner_name Name of the annotation's owner
  * @param string $owner_url Annotation owner's URL
  * @param string $owner_image Annotation owner's image, if one exists (include a blank string otherwise)
  * @param string $content Content of the annotation
  * @param string|null $annotation_url If included, the existing URL of this annotation
  * @param int $time The UNIX timestamp associated with this annotation (if set to 0, as is default, will be current time)
  * @param string $title The title associated with this annotation (blank by default)
  * @param bool $send_notification Should this call trigger a notifiation? (Default: yes)
  * @return bool Depending on success
  */
 function addAnnotation($subtype, $owner_name, $owner_url, $owner_image, $content, $annotation_url = null, $time = null, $title = '', $send_notification = true)
 {
     if (empty($subtype)) {
         return false;
     }
     if (empty($annotation_url)) {
         $annotation_url = $this->getURL() . '/annotations/' . md5(time() . $content);
         // Invent a URL for this annotation
     }
     $post_existed = false;
     if ($existing_annotations = $this->getAnnotations($subtype)) {
         foreach ($existing_annotations as $existing_local_url => $existing_annotation) {
             if ($existing_annotation['permalink'] == $annotation_url) {
                 $local_url = $existing_local_url;
                 $post_existed = true;
             }
         }
     }
     if (empty($local_url)) {
         $local_url = $this->getURL() . '/annotations/' . md5(time() . $content);
         // Invent a URL for this annotation if we don't have one already
     }
     if (empty($time)) {
         $time = time();
     } else {
         $time = (int) $time;
     }
     $annotation = array('permalink' => $annotation_url, 'owner_name' => $owner_name, 'owner_url' => $owner_url, 'owner_image' => $owner_image, 'content' => $content, 'time' => $time, 'title' => $title);
     $annotations = $this->annotations;
     if (empty($annotations)) {
         $annotations = array();
     }
     if (empty($annotations[$subtype])) {
         $annotations[$subtype] = array();
     }
     $annotations[$subtype][$local_url] = $annotation;
     $this->annotations = $annotations;
     $this->save();
     \Idno\Core\Idno::site()->triggerEvent('annotation/add/' . $subtype, array('annotation' => $annotation, 'object' => $this));
     if ($owners = $this->getAnnotationOwnerUUIDs(true)) {
         $owners[] = $this->getOwnerID();
         $owners = array_unique($owners);
     } else {
         $owners = array($this->getOwnerID());
     }
     if ($send_notification) {
         foreach ($owners as $owner_uuid) {
             if (Idno::site()->session()->isLoggedIn()) {
                 if ($owner_uuid == Idno::site()->session()->currentUserUUID()) {
                     // Don't bother sending a notification to the user performing the action
                     continue;
                 }
             }
             if ($owner = User::getByUUID($owner_uuid)) {
                 $send = true;
                 switch ($subtype) {
                     case 'mention':
                     case 'reply':
                         if ($owner_uuid == $this->getOwnerID()) {
                             $subject = $owner_name . ' replied to your post!';
                         } else {
                             $subject = $owner_name . ' replied!';
                         }
                         $notification_template = 'content/notification/reply';
                         $context = 'reply';
                         break;
                     case 'like':
                         if ($owner_uuid == $this->getOwnerID()) {
                             $subject = $owner_name . ' liked your post!';
                         } else {
                             $send = false;
                         }
                         $notification_template = 'content/notification/like';
                         $context = 'like';
                         break;
                     case 'share':
                         if ($owner_uuid == $this->getOwnerID()) {
                             $subject = $owner_name . ' reshared your post!';
                         } else {
                             $send = false;
                         }
                         $notification_template = 'content/notification/share';
                         $context = 'share';
                         break;
                     case 'rsvp':
                         $subject = $owner_name . ' RSVPed!';
                         $notification_template = 'content/notification/rsvp';
//.........这里部分代码省略.........
开发者ID:sensiblemn,项目名称:Known,代码行数:101,代码来源:Entity.php


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