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


PHP UserModel::GetByUsername方法代码示例

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


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

示例1: Add

 /**
  * Start a new conversation.
  *
  * @since 2.0.0
  * @access public
  *
  * @param string $Recipient Username of the recipient.
  */
 public function Add($Recipient = '')
 {
     $this->Form->SetModel($this->ConversationModel);
     if ($this->Form->AuthenticatedPostBack()) {
         $RecipientUserIDs = array();
         $To = explode(',', $this->Form->GetFormValue('To', ''));
         $UserModel = new UserModel();
         foreach ($To as $Name) {
             if (trim($Name) != '') {
                 $User = $UserModel->GetByUsername(trim($Name));
                 if (is_object($User)) {
                     $RecipientUserIDs[] = $User->UserID;
                 }
             }
         }
         $this->Form->SetFormValue('RecipientUserID', $RecipientUserIDs);
         $ConversationID = $this->Form->Save($this->ConversationMessageModel);
         if ($ConversationID !== FALSE) {
             $Target = $this->Form->GetFormValue('Target', 'messages/' . $ConversationID);
             $this->RedirectUrl = Url($Target);
         }
     } else {
         if ($Recipient != '') {
             $this->Form->SetValue('To', $Recipient);
         }
     }
     if ($Target = Gdn::Request()->Get('Target')) {
         $this->Form->AddHidden('Target', $Target);
     }
     $this->Title(T('New Conversation'));
     $this->SetData('Breadcrumbs', array(array('Name' => T('Inbox'), 'Url' => '/messages/inbox'), array('Name' => $this->Data('Title'), 'Url' => 'messages/add')));
     $this->Render();
 }
开发者ID:rnovino,项目名称:Garden,代码行数:41,代码来源:class.messagescontroller.php

示例2: Add

 /**
  * Add a new conversations.
  */
 public function Add($Recipient = '')
 {
     $this->Form->SetModel($this->ConversationModel);
     if ($this->Form->AuthenticatedPostBack()) {
         $RecipientUserIDs = array();
         $To = explode(',', $this->Form->GetFormValue('To', ''));
         $UserModel = new UserModel();
         foreach ($To as $Name) {
             if (trim($Name) != '') {
                 $User = $UserModel->GetByUsername(trim($Name));
                 if (is_object($User)) {
                     $RecipientUserIDs[] = $User->UserID;
                 }
             }
         }
         $this->Form->SetFormValue('RecipientUserID', $RecipientUserIDs);
         $ConversationID = $this->Form->Save($this->ConversationMessageModel);
         if ($ConversationID !== FALSE) {
             $this->RedirectUrl = Url('messages/' . $ConversationID);
         }
     } else {
         if ($Recipient != '') {
             $this->Form->SetFormValue('To', $Recipient);
         }
     }
     $this->Render();
 }
开发者ID:tautomers,项目名称:knoopvszombies,代码行数:30,代码来源:class.messagescontroller.php

示例3: DiscussionController_Author_Create

 /**
  * Handle discussion option menu Change Author action.
  */
 public function DiscussionController_Author_Create($Sender, $Args)
 {
     $DiscussionID = $Sender->Request->Get('discussionid');
     $Discussion = $Sender->DiscussionModel->GetID($DiscussionID);
     if (!$Discussion) {
         throw NotFoundException('Discussion');
     }
     // Check edit permission
     $Sender->Permission('Vanilla.Discussions.Edit', TRUE, 'Category', $Discussion->PermissionCategoryID);
     if ($Sender->Form->AuthenticatedPostBack()) {
         // Change the author
         $Name = $Sender->Form->GetFormValue('Author', '');
         $UserModel = new UserModel();
         if (trim($Name) != '') {
             $User = $UserModel->GetByUsername(trim($Name));
             if (is_object($User)) {
                 if ($Discussion->InsertUserID == $User->UserID) {
                     $Sender->Form->AddError('That user is already the discussion author.');
                 } else {
                     // Change discussion InsertUserID
                     $Sender->DiscussionModel->SetField($DiscussionID, 'InsertUserID', $User->UserID);
                     // Update users' discussion counts
                     $Sender->DiscussionModel->UpdateUserDiscussionCount($Discussion->InsertUserID);
                     $Sender->DiscussionModel->UpdateUserDiscussionCount($User->UserID, TRUE);
                     // Increment
                     // Go to the updated discussion
                     Redirect(DiscussionUrl($Discussion));
                 }
             } else {
                 $Sender->Form->AddError('No user with that name was found.');
             }
         }
     } else {
         // Form to change the author
         $Sender->SetData('Title', $Discussion->Name);
     }
     $Sender->Render('changeauthor', '', 'plugins/AuthorSelector');
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:41,代码来源:class.authorselector.plugin.php

示例4: get_user_id_by_username

 public function get_user_id_by_username($user_login)
 {
     // Read the user_id for this login
     $UserModel = new UserModel();
     $result = $UserModel->GetByUsername($user_login, DATASET_TYPE_ARRAY);
     return GetValue('Deleted', $result) === '1' ? FALSE : GetValue('UserID', $result);
 }
开发者ID:Nordic-T,项目名称:vanilla-plugins,代码行数:7,代码来源:class.sociallogin.php

示例5: Authenticate

 public function Authenticate()
 {
     if (!$this->Request->IsPostBack()) {
         throw ForbiddenException($this->Request->RequestMethod());
     }
     $Args = array_change_key_case($this->Form->FormValues());
     $UserModel = new UserModel();
     // Look up the user.
     $User = NULL;
     if ($Email = GetValue('email', $Args)) {
         $User = $UserModel->GetByEmail($Email);
     } elseif ($Name = GetValue('name', $Args)) {
         $User = $UserModel->GetByUsername($Name);
     } else {
         throw new Gdn_UserException("One of the following parameters required: Email, Name.", 400);
     }
     if (!$User) {
         throw NotFoundException('User');
     }
     // Check the password.
     $PasswordHash = new Gdn_PasswordHash();
     $Password = $this->Form->GetFormValue('Password');
     try {
         $PasswordChecked = $PasswordHash->CheckPassword($Password, GetValue('Password', $User), GetValue('HashMethod', $User));
         // Rate limiting
         Gdn::UserModel()->RateLimit($User, $PasswordChecked);
         if ($PasswordChecked) {
             $this->SetData('User', ArrayTranslate((array) $User, array('UserID', 'Name', 'Email', 'PhotoUrl')));
             if (GetValue('session', $Args)) {
                 Gdn::Session()->Start($this->Data('User.UserID'));
                 $this->SetData('Cookie', array(C('Garden.Cookie.Name') => $_COOKIE[C('Garden.Cookie.Name')]));
             }
         } else {
             throw new Exception(T('Invalid password.'), 401);
             // Can't be a user exception.
         }
     } catch (Gdn_UserException $Ex) {
         $this->Form->AddError($Ex);
     }
     $this->Render();
 }
开发者ID:3marproof,项目名称:vanilla,代码行数:41,代码来源:class.usercontroller.php

示例6: Add

 /**
  * Start a new conversation.
  *
  * @since 2.0.0
  * @access public
  *
  * @param string $Recipient Username of the recipient.
  */
 public function Add($Recipient = '')
 {
     $this->Permission('Conversations.Conversations.Add');
     $this->Form->SetModel($this->ConversationModel);
     // Set recipient limit
     if (!CheckPermission('Garden.Moderation.Manage') && C('Conversations.MaxRecipients')) {
         $this->AddDefinition('MaxRecipients', C('Conversations.MaxRecipients'));
         $this->SetData('MaxRecipients', C('Conversations.MaxRecipients'));
     }
     if ($this->Form->AuthenticatedPostBack()) {
         $RecipientUserIDs = array();
         $To = explode(',', $this->Form->GetFormValue('To', ''));
         $UserModel = new UserModel();
         foreach ($To as $Name) {
             if (trim($Name) != '') {
                 $User = $UserModel->GetByUsername(trim($Name));
                 if (is_object($User)) {
                     $RecipientUserIDs[] = $User->UserID;
                 }
             }
         }
         // Enforce MaxRecipients
         if (!$this->ConversationModel->AddUserAllowed(0, count($RecipientUserIDs))) {
             // Reuse the Info message now as an error.
             $this->Form->AddError(sprintf(Plural($this->Data('MaxRecipients'), "You are limited to %s recipient.", "You are limited to %s recipients."), C('Conversations.MaxRecipients')));
         }
         $this->EventArguments['Recipients'] = $RecipientUserIDs;
         $this->FireEvent('BeforeAddConversation');
         $this->Form->SetFormValue('RecipientUserID', $RecipientUserIDs);
         $ConversationID = $this->Form->Save($this->ConversationMessageModel);
         if ($ConversationID !== FALSE) {
             $Target = $this->Form->GetFormValue('Target', 'messages/' . $ConversationID);
             $this->RedirectUrl = Url($Target);
         }
     } else {
         if ($Recipient != '') {
             $this->Form->SetValue('To', $Recipient);
         }
     }
     if ($Target = Gdn::Request()->Get('Target')) {
         $this->Form->AddHidden('Target', $Target);
     }
     Gdn_Theme::Section('PostConversation');
     $this->Title(T('New Conversation'));
     $this->SetData('Breadcrumbs', array(array('Name' => T('Inbox'), 'Url' => '/messages/inbox'), array('Name' => $this->Data('Title'), 'Url' => 'messages/add')));
     $this->Render();
 }
开发者ID:embo-hd,项目名称:vanilla,代码行数:55,代码来源:class.messagescontroller.php


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