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


PHP User::get方法代码示例

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


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

示例1: registerEventHooks

 function registerEventHooks()
 {
     \Idno\Core\site()->template()->extendTemplate('account/settings/notifications/methods', 'subscriptions/settings');
     \Idno\Core\site()->addEventHook('saved', function (\Idno\Core\Event $event) {
         if (!empty($event->data()['object'])) {
             $object = $event->data()['object'];
             if (!$object instanceof ActivityStreamPost) {
                 /* @var Idno\Common\Entity $object ; */
                 $owner = $object->getOwner();
                 if ($users = User::get([], [], 9999)) {
                     //$email = new Email();
                     //$email->setSubject($object->getTitle());
                     //$email->setHTMLBodyFromTemplate('subscriptions/email', ['object' => $object, 'owner' => $owner]);
                     $title = implode(' ', array_slice(explode(' ', $object->getTitle()), 0, 10));
                     foreach ($users as $user) {
                         if (!empty($user->email) && $user->email != $owner->email && $user->notifications['subscriptions'] != 'none') {
                             $email = new Email();
                             $email->setSubject($title);
                             $email->setHTMLBodyFromTemplate('subscriptions/email', ['object' => $object, 'owner' => $owner]);
                             $email->addTo($user->email);
                             $email->send();
                         }
                     }
                 }
             }
         }
     });
 }
开发者ID:sensiblemn,项目名称:Subscriptions,代码行数:28,代码来源:Main.php

示例2: getContent

 function getContent()
 {
     $this->adminGatekeeper();
     // Admins only
     $users = User::get(array('admin' => true));
     $t = \Idno\Core\Idno::site()->template();
     $t->body = $t->__(array('users' => $users))->draw('admin/cherwell');
     $t->title = 'Theme Settings';
     $t->drawPage();
 }
开发者ID:sintoris,项目名称:Known,代码行数:10,代码来源:Admin.php

示例3: getContent

 function getContent()
 {
     $this->adminGatekeeper();
     // Admins only
     $users = User::get(array(), array(), 99999, 0);
     // TODO: make this more complete / efficient
     $remoteusers = RemoteUser::get(array(), array(), 99999, 0);
     $users = array_merge($users, $remoteusers);
     $t = \Idno\Core\site()->template();
     $t->body = $t->__(array('users' => $users))->draw('admin/users');
     $t->title = 'User Management';
     $t->drawPage();
 }
开发者ID:uniteddiversity,项目名称:Known,代码行数:13,代码来源:Users.php

示例4: getContent

 function getContent()
 {
     $results = [];
     $username = $this->getInput('username');
     if ($users = User::get([], [], 9999)) {
         //User::getByHandle($username)) {
         foreach ($users as $user) {
             /* @var \Idno\Entities\User $user */
             $results[] = ['username' => $user->getHandle(), 'name' => $user->getTitle(), 'image' => $user->getIcon()];
         }
     }
     header('Content-type: text/json');
     echo json_encode($results);
 }
开发者ID:avewrigley,项目名称:idno,代码行数:14,代码来源:Mentions.php

示例5: findUserForToken

 static function findUserForToken($token)
 {
     // find a user by their code
     for ($offset = 0;; $offset += 10) {
         $users = \Idno\Entities\User::get(array(), array(), 10, $offset);
         if (empty($users)) {
             break;
         }
         foreach ($users as $user) {
             $indieauth_tokens = $user->indieauth_tokens;
             if (!empty($indieauth_tokens) && isset($indieauth_tokens[$token])) {
                 return array('user' => $user, 'data' => $indieauth_tokens[$token]);
             }
         }
     }
     return array();
 }
开发者ID:pierreozoux,项目名称:Known,代码行数:17,代码来源:Token.php

示例6: postContent

 function postContent()
 {
     $name = $this->getInput('name');
     $handle = $this->getInput('handle');
     $password = $this->getInput('password');
     $password2 = $this->getInput('password2');
     $email = $this->getInput('email');
     $user = new \Idno\Entities\User();
     if (!empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL)) {
         if (!($emailuser = \Idno\Entities\User::getByEmail($email)) && !($handleuser = \Idno\Entities\User::getByHandle($handle)) && !empty($handle) && $password == $password2 && strlen($password) > 4 && !empty($name)) {
             $user = new \Idno\Entities\User();
             $user->email = $email;
             $user->handle = $handle;
             $user->setPassword($password);
             $user->setTitle($name);
             if (!\Idno\Entities\User::get()) {
                 $user->setAdmin(true);
             }
             $user->save();
         } else {
             if (empty($handle)) {
                 \Idno\Core\site()->session()->addMessage("You can't have an empty handle.");
             } else {
                 if (!empty($handleuser)) {
                     \Idno\Core\site()->session()->addMessage("Unfortunately, a user is already using that handle. Please choose another.");
                 }
             }
             if (!empty($emailuser)) {
                 \Idno\Core\site()->session()->addMessage("Unfortunately, a user is already using that email address. Please choose another.");
             }
             if ($password != $password2 || strlen($password) <= 4) {
                 \Idno\Core\site()->session()->addMessage("Please check that your passwords match and that your password is over four characters long.");
             }
         }
     } else {
         \Idno\Core\site()->session()->addMessage("That doesn't seem to be a valid email address.");
     }
     if (!empty($user->_id)) {
         \Idno\Core\site()->session()->addMessage("You've registered! Well done.");
         \Idno\Core\site()->session()->logUserOn($user);
     } else {
         \Idno\Core\site()->session()->addMessage("We couldn't register you.");
         $this->forward($_SERVER['HTTP_REFERER']);
     }
 }
开发者ID:phpsource,项目名称:idno,代码行数:45,代码来源:Register.php

示例7: findUserForCode

 static function findUserForCode($code)
 {
     // TODO encode user id in the auth code? or otherwise do a reverse lookup
     // to avoid checking every user
     for ($offset = 0;; $offset += 10) {
         $users = \Idno\Entities\User::get(array(), array(), 10, $offset);
         if (empty($users)) {
             break;
         }
         foreach ($users as $user) {
             $indieauth_codes = $user->indieauth_codes;
             if (!empty($indieauth_codes) && isset($indieauth_codes[$code])) {
                 return array('user' => $user, 'data' => $indieauth_codes[$code]);
             }
         }
     }
     return array();
 }
开发者ID:pierreozoux,项目名称:Known,代码行数:18,代码来源:Auth.php

示例8: postContent

 function postContent()
 {
     $name = $this->getInput('name');
     $handle = trim($this->getInput('handle'));
     $password = trim($this->getInput('password'));
     $password2 = trim($this->getInput('password2'));
     $email = trim($this->getInput('email'));
     $code = $this->getInput('code');
     $onboarding = $this->getInput('onboarding');
     if (empty(\Idno\Core\site()->config()->open_registration)) {
         if (!($invitation = \Idno\Entities\Invitation::validate($email, $code))) {
             \Idno\Core\site()->session()->addMessage("Your invitation doesn't seem to be valid or has expired.");
             $this->forward(\Idno\Core\site()->config()->getURL());
         } else {
             // Removing this from here - invitation will be deleted once user is created
             //$invitation->delete(); // Remove the invitation; it's no longer needed
         }
     }
     $user = new \Idno\Entities\User();
     if (empty($handle) && empty($email)) {
         \Idno\Core\site()->session()->addMessage("Please enter a username and email address.");
     } else {
         if (!empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL)) {
             if (!($emailuser = \Idno\Entities\User::getByEmail($email)) && !($handleuser = \Idno\Entities\User::getByHandle($handle)) && !empty($handle) && strlen($handle <= 32) && !substr_count($handle, '/') && $password == $password2 && strlen($password) > 4) {
                 $user = new \Idno\Entities\User();
                 $user->email = $email;
                 $user->handle = strtolower(trim($handle));
                 // Trim the handle and set it to lowercase
                 $user->setPassword($password);
                 if (empty($name)) {
                     $name = $user->handle;
                 }
                 $user->setTitle($name);
                 if (!\Idno\Entities\User::get()) {
                     $user->setAdmin(true);
                     $user->robot_state = 1;
                     // State for our happy robot helper
                     if (\Idno\Core\site()->config()->title == 'New Known site') {
                         if (!empty($_SESSION['set_name'])) {
                             \Idno\Core\site()->config()->title = $_SESSION['set_name'];
                         } else {
                             \Idno\Core\site()->config()->title = $user->getTitle() . '\'s Known';
                         }
                         \Idno\Core\site()->config()->open_registration = false;
                         \Idno\Core\site()->config()->from_email = $user->email;
                         \Idno\Core\site()->config()->save();
                     }
                 }
                 $user->save();
                 \Idno\Core\site()->triggerEvent('site/firstadmin', ['user' => $user]);
                 // Event hook for first admin
                 // Now we can remove the invitation
                 if ($invitation instanceof Invitation) {
                     $invitation->delete();
                     // Remove the invitation; it's no longer needed
                 }
             } else {
                 if (empty($handle)) {
                     \Idno\Core\site()->session()->addMessage("Please create a username.");
                 } else {
                     if (strlen($handle) > 32) {
                         \Idno\Core\site()->session()->addMessage("Your username is too long.");
                     } else {
                         if (substr_count($handle, '/')) {
                             \Idno\Core\site()->session()->addMessage("Usernames can't contain a slash ('/') character.");
                         } else {
                             if (!empty($handleuser)) {
                                 \Idno\Core\site()->session()->addMessage("Unfortunately, someone is already using that username. Please choose another.");
                             }
                         }
                     }
                 }
                 if (!empty($emailuser)) {
                     \Idno\Core\site()->session()->addMessage("Hey, it looks like there's already an account with that email address. Did you forget your login?");
                 }
                 if ($password != $password2 || strlen($password) <= 4) {
                     \Idno\Core\site()->session()->addMessage("Please check that your passwords match and that your password is over four characters long.");
                 }
             }
         } else {
             \Idno\Core\site()->session()->addMessage("That doesn't seem like it's a valid email address.");
         }
     }
     if (!empty($user->_id)) {
         \Idno\Core\site()->session()->addMessage("You've registered! You're ready to get started. Why not add some profile information?");
         \Idno\Core\site()->session()->logUserOn($user);
         if (empty($onboarding)) {
             $this->forward($user->getURL());
         } else {
             $this->forward(\Idno\Core\site()->config()->getURL() . 'begin/profile');
         }
     } else {
         \Idno\Core\site()->session()->addMessageAtStart("We couldn't register you.");
         $this->forward($_SERVER['HTTP_REFERER']);
     }
 }
开发者ID:avewrigley,项目名称:idno,代码行数:96,代码来源:Register.php

示例9: postContent

 function postContent()
 {
     $name = $this->getInput('name');
     $handle = trim($this->getInput('handle'));
     $password = trim($this->getInput('password'));
     $password2 = trim($this->getInput('password2'));
     $email = trim($this->getInput('email'));
     $code = $this->getInput('code');
     $onboarding = $this->getInput('onboarding');
     /*if (!\Idno\Common\Page::isSSL() && !\Idno\Core\site()->config()->disable_cleartext_warning) {
           \Idno\Core\site()->session()->addErrorMessage("Warning: Access credentials were sent over a non-secured connection! To disable this warning set disable_cleartext_warning in your config.ini");
       }*/
     if (empty(\Idno\Core\site()->config()->open_registration)) {
         if (!($invitation = \Idno\Entities\Invitation::validate($email, $code))) {
             \Idno\Core\site()->session()->addErrorMessage("Your invitation doesn't seem to be valid, or has expired.");
             $this->forward(\Idno\Core\site()->config()->getURL());
         } else {
             // Removing this from here - invitation will be deleted once user is created
             //$invitation->delete(); // Remove the invitation; it's no longer needed
         }
     }
     $user = new \Idno\Entities\User();
     if (empty($handle) && empty($email)) {
         \Idno\Core\site()->session()->addErrorMessage("Please enter a username and email address.");
     } else {
         if (!empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL)) {
             if (!($emailuser = \Idno\Entities\User::getByEmail($email)) && !($handleuser = \Idno\Entities\User::getByHandle($handle)) && !empty($handle) && strlen($handle) <= 32 && preg_match('/^[a-zA-Z0-9_]{1,}$/', $handle) && !substr_count($handle, '/') && $password == $password2 & \Idno\Entities\User::checkNewPasswordStrength($password)) {
                 $user = new \Idno\Entities\User();
                 $user->email = $email;
                 $user->handle = strtolower(trim($handle));
                 // Trim the handle and set it to lowercase
                 $user->setPassword($password);
                 $user->notifications['email'] = 'all';
                 if (empty($name)) {
                     $name = $user->handle;
                 }
                 $user->setTitle($name);
                 if (!\Idno\Entities\User::get()) {
                     $user->setAdmin(true);
                     $user->robot_state = '1';
                     // State for our happy robot helper
                     if (\Idno\Core\site()->config()->title == 'New Known site') {
                         if (!empty($_SESSION['set_name'])) {
                             \Idno\Core\site()->config()->title = $_SESSION['set_name'];
                         } else {
                             \Idno\Core\site()->config()->title = $user->getTitle() . '\'s Known';
                         }
                         \Idno\Core\site()->config()->theme = 'Solo';
                         \Idno\Core\site()->config()->open_registration = false;
                         \Idno\Core\site()->config()->from_email = $user->email;
                         \Idno\Core\site()->config()->save();
                     }
                     \Idno\Core\site()->triggerEvent('site/firstadmin', array('user' => $user));
                     // Event hook for first admin
                 } else {
                     \Idno\Core\site()->triggerEvent('site/newuser', array('user' => $user));
                     // Event hook for new user
                 }
                 $user->save();
                 // Now we can remove the invitation
                 if (!empty($invitation)) {
                     if ($invitation instanceof Invitation) {
                         $invitation->delete();
                         // Remove the invitation; it's no longer needed
                     }
                 }
             } else {
                 if (empty($handle)) {
                     \Idno\Core\site()->session()->addErrorMessage("Please create a username.");
                 }
                 if (strlen($handle) > 32) {
                     \Idno\Core\site()->session()->addErrorMessage("Your username is too long.");
                 }
                 if (!preg_match('/^[a-zA-Z0-9_]{1,}$/', $handle)) {
                     \Idno\Core\site()->session()->addErrorMessage("Usernames can only have letters, numbers and underscores.");
                 }
                 if (substr_count($handle, '/')) {
                     \Idno\Core\site()->session()->addErrorMessage("Usernames can't contain a slash ('/') character.");
                 }
                 if (!empty($handleuser)) {
                     \Idno\Core\site()->session()->addErrorMessage("Unfortunately, someone is already using that username. Please choose another.");
                 }
                 if (!empty($emailuser)) {
                     \Idno\Core\site()->session()->addErrorMessage("Hey, it looks like there's already an account with that email address. Did you forget your login?");
                 }
                 if (!\Idno\Entities\User::checkNewPasswordStrength($password) || $password != $password2) {
                     \Idno\Core\site()->session()->addErrorMessage("Please check that your passwords match and that your password is at least 7 characters long.");
                 }
             }
         } else {
             \Idno\Core\site()->session()->addErrorMessage("That doesn't seem like it's a valid email address.");
         }
     }
     if (!empty($user->_id)) {
         \Idno\Core\site()->session()->addMessage("You've registered! You're ready to get started. Why not add a status update to say hello?");
         \Idno\Core\site()->session()->logUserOn($user);
         if (empty($onboarding)) {
             $this->forward();
         } else {
             $this->forward(\Idno\Core\site()->config()->getURL() . 'begin/profile');
//.........这里部分代码省略.........
开发者ID:uniteddiversity,项目名称:Known,代码行数:101,代码来源:Register.php

示例10: getAdmins

 /**
  * Retrieves admins for this site
  * @return array
  */
 function getAdmins()
 {
     return User::get(['admin' => true], [], 9999);
 }
开发者ID:jirkadus,项目名称:Known,代码行数:8,代码来源:Idno.php

示例11: getContent

 function getContent()
 {
     $query = $this->getInput('q');
     $offset = (int) $this->getInput('offset');
     $types = $this->getInput('types');
     $friendly_types = array();
     // Check for an empty site
     if (!\Idno\Entities\User::get()) {
         $this->forward(\Idno\Core\Idno::site()->config()->getURL() . 'begin/');
     }
     if (!empty($this->arguments[0])) {
         // If we're on the friendly content-specific URL
         if ($friendly_types = explode('/', $this->arguments[0])) {
             $friendly_types = array_filter($friendly_types);
             if (empty($friendly_types) && !empty($query)) {
                 $friendly_types = array('all');
             }
             $types = array();
             // Run through the URL parameters and set content types appropriately
             foreach ($friendly_types as $friendly_type) {
                 if ($friendly_type == 'all') {
                     $types = \Idno\Common\ContentType::getRegisteredClasses();
                     break;
                 }
                 if ($content_type_class = \Idno\Common\ContentType::categoryTitleToClass($friendly_type)) {
                     $types[] = $content_type_class;
                 }
             }
         }
     } else {
         // If user has content-specific preferences, do something with $friendly_types
         if (empty($query)) {
             $types = \Idno\Core\Idno::site()->config()->getHomepageContentTypes();
         }
     }
     $search = array();
     if (!empty($query)) {
         $search = \Idno\Core\Idno::site()->db()->createSearchArray($query);
     }
     if (empty($types)) {
         $types = \Idno\Common\ContentType::getRegisteredClasses();
     } else {
         if (!is_array($types)) {
             $types = array($types);
         }
         $types[] = '!Idno\\Entities\\ActivityStreamPost';
     }
     $count = \Idno\Entities\ActivityStreamPost::countFromX($types, array());
     $feed = \Idno\Entities\ActivityStreamPost::getFromX($types, $search, array(), \Idno\Core\Idno::site()->config()->items_per_page, $offset);
     if (\Idno\Core\Idno::site()->session()->isLoggedIn()) {
         $create = \Idno\Common\ContentType::getRegistered();
         // If we can't create an object of this type, hide from the button bar
         foreach ($create as $key => $obj) {
             if (!$obj->createable) {
                 unset($create[$key]);
             }
         }
     } else {
         $create = false;
     }
     if (!empty(\Idno\Core\Idno::site()->config()->description)) {
         $description = \Idno\Core\Idno::site()->config()->description;
     } else {
         $description = 'An independent social website, powered by Known.';
     }
     // If we have a feed, set our last modified flag to the time of the latest returned entry
     if (!empty($feed)) {
         if (is_array($feed)) {
             $feed = array_filter($feed);
             $this->setLastModifiedHeader(reset($feed)->updated);
         }
     }
     if (!empty(\Idno\Core\Idno::site()->config()->homepagetitle)) {
         $title = \Idno\Core\Idno::site()->config()->homepagetitle;
     } else {
         $title = \Idno\Core\Idno::site()->config()->title;
     }
     $t = \Idno\Core\Idno::site()->template();
     $t->__(array('title' => $title, 'description' => $description, 'content' => $friendly_types, 'body' => $t->__(array('items' => $feed, 'contentTypes' => $create, 'offset' => $offset, 'count' => $count, 'subject' => $query, 'content' => $friendly_types))->draw('pages/home')))->drawPage();
 }
开发者ID:sintoris,项目名称:Known,代码行数:80,代码来源:Homepage.php


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