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


PHP Gdn::UserModel方法代码示例

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


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

示例1: GetUserModel

 /**
  * @return UserModel
  */
 public function GetUserModel()
 {
     if ($this->_UserModel === null) {
         $this->_UserModel = Gdn::UserModel();
     }
     return $this->_UserModel;
 }
开发者ID:stinie,项目名称:Garden,代码行数:10,代码来源:class.passwordauthenticator.php

示例2: AfterImport

 public function AfterImport()
 {
     // Set up the routes to redirect from their older counterparts.
     $Router = Gdn::Router();
     // Categories
     $Router->SetRoute('forumdisplay\\.php\\?f=(\\d+)', 'categories/$1', 'Permanent');
     $Router->SetRoute('archive\\.php/f-(\\d+)\\.html', 'categories/$1', 'Permanent');
     // Discussions & Comments
     $Router->SetRoute('showthread\\.php\\?t=(\\d+)', 'discussion/$1', 'Permanent');
     //$Router->SetRoute('showthread\.php\?p=(\d+)', 'discussion/comment/$1#Comment_$1', 'Permanent');
     //$Router->SetRoute('showpost\.php\?p=(\d+)', 'discussion/comment/$1#Comment_$1', 'Permanent');
     $Router->SetRoute('archive\\.php/t-(\\d+)\\.html', 'discussion/$1', 'Permanent');
     // Profiles
     $Router->SetRoute('member\\.php\\?u=(\\d+)', 'profile/$1/x', 'Permanent');
     $Router->SetRoute('usercp\\.php', 'profile', 'Permanent');
     $Router->SetRoute('profile\\.php', 'profile', 'Permanent');
     // Other
     $Router->SetRoute('attachment\\.php\\?attachmentid=(\\d+)', 'discussion/download/$1', 'Permanent');
     $Router->SetRoute('search\\.php', 'discussions', 'Permanent');
     $Router->SetRoute('private\\.php', 'messages/all', 'Permanent');
     $Router->SetRoute('subscription\\.php', 'discussions/bookmarked', 'Permanent');
     // Make different sizes of avatars
     $this->ProcessAvatars();
     // Prep config for ProfileExtender plugin based on imported fields
     $this->ProfileExtenderPrep();
     // Set guests to System user to prevent security issues
     $SystemUserID = Gdn::UserModel()->GetSystemUserID();
     $this->SQL->Update('Discussion')->Set('InsertUserID', $SystemUserID)->Where('InsertUserID', 0)->Put();
     $this->SQL->Update('Comment')->Set('InsertUserID', $SystemUserID)->Where('InsertUserID', 0)->Put();
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:30,代码来源:class.vbulletinimportmodel.php

示例3: GetUserInfo

 protected function GetUserInfo($UserReference = '', $Username = '', $UserID = '')
 {
     // If a UserID was provided as a querystring parameter, use it over anything else:
     if ($UserID) {
         $UserReference = $UserID;
         $Username = 'Unknown';
         // Fill this with a value so the $UserReference is assumed to be an integer/userid.
     }
     if ($UserReference == '') {
         $User = Gdn::UserModel()->Get(Gdn::Session()->UserID);
     } else {
         if (is_numeric($UserReference) && $Username != '') {
             $User = Gdn::UserModel()->Get($UserReference);
         } else {
             $User = Gdn::UserModel()->GetByUsername($UserReference);
         }
     }
     if ($User === FALSE) {
         throw NotFoundException();
     } else {
         if ($this->User->Deleted == 1) {
             throw NotFoundException();
         } else {
             if (GetValue('UserID', $User) == Gdn::Session()->UserID) {
                 throw NotFoundException();
             } else {
                 return $User;
             }
         }
     }
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:31,代码来源:class.block.plugin.php

示例4: ProfileController_Quotes_Create

 public function ProfileController_Quotes_Create($Sender)
 {
     $Sender->Permission('Garden.SignIn.Allow');
     $Sender->Title("Quotes Settings");
     $Args = $Sender->RequestArgs;
     if (sizeof($Args) < 2) {
         $Args = array_merge($Args, array(0, 0));
     } elseif (sizeof($Args) > 2) {
         $Args = array_slice($Args, 0, 2);
     }
     list($UserReference, $Username) = $Args;
     $Sender->GetUserInfo($UserReference, $Username);
     $UserPrefs = Gdn_Format::Unserialize($Sender->User->Preferences);
     if (!is_array($UserPrefs)) {
         $UserPrefs = array();
     }
     $UserID = $ViewingUserID = Gdn::Session()->UserID;
     if ($Sender->User->UserID != $ViewingUserID) {
         $Sender->Permission('Garden.Users.Edit');
         $UserID = $Sender->User->UserID;
     }
     $Sender->SetData('ForceEditing', $UserID == Gdn::Session()->UserID ? FALSE : $Sender->User->Name);
     $QuoteFolding = GetValue('Quotes.Folding', $UserPrefs, '1');
     $Sender->Form->SetValue('QuoteFolding', $QuoteFolding);
     $Sender->SetData('QuoteFoldingOptions', array('None' => "Don't ever fold quotes", '1' => 'One level deep', '2' => 'Two levels deep', '3' => 'Three levels deep', '4' => 'Four levels deep', '5' => 'Five levels deep'));
     // If seeing the form for the first time...
     if ($Sender->Form->IsPostBack()) {
         $NewFoldingLevel = $Sender->Form->GetValue('QuoteFolding', '1');
         if ($NewFoldingLevel != $QuoteFolding) {
             Gdn::UserModel()->SavePreference($UserID, 'Quotes.Folding', $NewFoldingLevel);
             $Sender->InformMessage(T("Your changes have been saved."));
         }
     }
     $Sender->Render('quotes', '', 'plugins/Quotes');
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:35,代码来源:class.quotes.plugin.php

示例5: _AttachPostCount

 protected function _AttachPostCount($Sender)
 {
     $User = Gdn::UserModel()->GetID($Sender->EventArguments['Author']->UserID);
     if ($User) {
         $Posts = GetValue('CountComments', $User, 0) + GetValue('CountDiscussions', $User, 0);
         echo '<span class="MItem PostCount">' . Plural(number_format($Posts), '@' . T('Posts.Singular: %s', 'Posts: <b>%s</b>'), '@' . T('Posts.Plural: %s', 'Posts: <b>%s</b>')) . '</span>';
     }
 }
开发者ID:vanilla,项目名称:addons,代码行数:8,代码来源:class.postcount.plugin.php

示例6: CheckForSpam

 /**
  * Checks to see if the user is spamming. Returns TRUE if the user is spamming.
  */
 public function CheckForSpam($Type)
 {
     $Spam = FALSE;
     if (!in_array($Type, array('Comment', 'Discussion'))) {
         trigger_error(ErrorMessage(sprintf('Spam check type unknown: %s', $Type), 'VanillaModel', 'CheckForSpam'), E_USER_ERROR);
     }
     $Session = Gdn::Session();
     $CountSpamCheck = $Session->GetAttribute('Count' . $Type . 'SpamCheck', 0);
     $DateSpamCheck = $Session->GetAttribute('Date' . $Type . 'SpamCheck', 0);
     $SecondsSinceSpamCheck = time() - Format::ToTimestamp($DateSpamCheck);
     $SpamCount = Gdn::Config('Vanilla.' . $Type . '.SpamCount');
     if (!is_numeric($SpamCount) || $SpamCount < 2) {
         $SpamCount = 2;
     }
     // 2 spam minimum
     $SpamTime = Gdn::Config('Vanilla.' . $Type . '.SpamTime');
     if (!is_numeric($SpamTime) || $SpamTime < 0) {
         $SpamTime = 30;
     }
     // 30 second minimum spam span
     $SpamLock = Gdn::Config('Vanilla.' . $Type . '.SpamLock');
     if (!is_numeric($SpamLock) || $SpamLock < 30) {
         $SpamLock = 30;
     }
     // 30 second minimum lockout
     // Definition:
     // Users cannot post more than $SpamCount comments within $SpamTime
     // seconds or their account will be locked for $SpamLock seconds.
     // Apply a spam lock if necessary
     $Attributes = array();
     if ($SecondsSinceSpamCheck < $SpamLock && $CountSpamCheck >= $SpamCount && $DateSpamCheck !== FALSE) {
         // TODO: REMOVE DEBUGGING INFO AFTER THIS IS WORKING PROPERLY
         /*
         echo '<div>SecondsSinceSpamCheck: '.$SecondsSinceSpamCheck.'</div>';
         echo '<div>SpamLock: '.$SpamLock.'</div>';
         echo '<div>CountSpamCheck: '.$CountSpamCheck.'</div>';
         echo '<div>SpamCount: '.$SpamCount.'</div>';
         echo '<div>DateSpamCheck: '.$DateSpamCheck.'</div>';
         echo '<div>SpamTime: '.$SpamTime.'</div>';
         */
         $Spam = TRUE;
         $this->Validation->AddValidationResult('Body', sprintf(T('You have posted %1$s times within %2$s seconds. A spam block is now in effect on your account. You must wait at least %3$s seconds before attempting to post again.'), $SpamCount, $SpamTime, $SpamLock));
         // Update the 'waiting period' every time they try to post again
         $Attributes['Date' . $Type . 'SpamCheck'] = Format::ToDateTime();
     } else {
         if ($SecondsSinceSpamCheck > $SpamTime) {
             $Attributes['Count' . $Type . 'SpamCheck'] = 1;
             $Attributes['Date' . $Type . 'SpamCheck'] = Format::ToDateTime();
         } else {
             $Attributes['Count' . $Type . 'SpamCheck'] = $CountSpamCheck + 1;
         }
     }
     // Update the user profile after every comment
     $UserModel = Gdn::UserModel();
     $UserModel->SaveAttribute($Session->UserID, $Attributes);
     return $Spam;
 }
开发者ID:nbudin,项目名称:Garden,代码行数:60,代码来源:class.vanillamodel.php

示例7: ClearPermissions

 public function ClearPermissions()
 {
     static $PermissionsCleared = FALSE;
     if (!$PermissionsCleared) {
         // Remove the cached permissions for all users.
         Gdn::UserModel()->ClearPermissions();
         $PermissionsCleared = TRUE;
     }
 }
开发者ID:rnovino,项目名称:Garden,代码行数:9,代码来源:class.permissionmodel.php

示例8: LoadData

 public function LoadData()
 {
     $UserID = Gdn::Controller()->Data('Profile.UserID', Gdn::Session()->UserID);
     $this->User = Gdn::UserModel()->GetID($UserID);
     $this->Roles = Gdn::UserModel()->GetRoles($UserID)->ResultArray();
     // Hide personal info roles
     if (!CheckPermission('Garden.PersonalInfo.View')) {
         $this->Roles = array_filter($this->Roles, 'RoleModel::FilterPersonalInfo');
     }
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:10,代码来源:class.userinfomodule.php

示例9: EntryController_RegisterBasic_Create

 public function EntryController_RegisterBasic_Create($Sender)
 {
     // print_r($Values);
     // die('ok');
     Gdn::UserModel()->AddPasswordStrength($Sender);
     if ($Sender->Form->IsPostBack() === TRUE) {
         // Add validation rules that are not enforced by the model
         $Sender->UserModel->DefineSchema();
         $Sender->UserModel->Validation->ApplyRule('Name', 'Username', $Sender->UsernameError);
         $Sender->UserModel->Validation->ApplyRule('TermsOfService', 'Required', T('You must agree to the terms of service.'));
         $Sender->UserModel->Validation->ApplyRule('Password', 'Required');
         $Sender->UserModel->Validation->ApplyRule('Password', 'Strength');
         $Sender->UserModel->Validation->ApplyRule('Password', 'Match');
         // $Sender->UserModel->Validation->ApplyRule('DateOfBirth', 'MinimumAge');
         $Sender->FireEvent('RegisterValidation');
         try {
             $Values = $Sender->Form->FormValues();
             unset($Values['Roles']);
             $AuthUserID = $Sender->UserModel->Register($Values);
             if ($AuthUserID == UserModel::REDIRECT_APPROVE) {
                 $Sender->Form->SetFormValue('Target', '/entry/registerthanks');
                 $Sender->_SetRedirect();
                 return;
             } elseif (!$AuthUserID) {
                 $Sender->Form->SetValidationResults($Sender->UserModel->ValidationResults());
             } else {
                 // The user has been created successfully, so sign in now.
                 Gdn::Session()->Start($AuthUserID);
                 if ($Sender->Form->GetFormValue('RememberMe')) {
                     Gdn::Authenticator()->SetIdentity($AuthUserID, TRUE);
                 }
                 try {
                     $Sender->UserModel->SendWelcomeEmail($AuthUserID, '', 'Register');
                 } catch (Exception $Ex) {
                 }
                 $Sender->FireEvent('RegistrationSuccessful');
                 // ... and redirect them appropriately
                 $Route = $Sender->RedirectTo();
                 if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
                     $Sender->RedirectUrl = Url($Route);
                 } else {
                     if ($Route !== FALSE) {
                         Redirect($Route);
                     }
                 }
             }
         } catch (Exception $Ex) {
             $Sender->Form->AddError($Ex);
         }
     }
     $Sender->Render();
 }
开发者ID:er0k,项目名称:trickno,代码行数:52,代码来源:class.chat.plugin.php

示例10: toString

 public function toString()
 {
     $users = Gdn::UserModel()->GetIDs($this->getBirthdays());
     if (!$users) {
         return;
     }
     $return = '<div class="Box BirthdayModule"><h4>' . plural(count($users), T("Today's Birthday"), T("Today's Birthdays")) . '</h4><p>';
     foreach ($users as $user) {
         $return .= userPhoto($user, 'Medium') . ' ';
     }
     $return .= '</p></div>';
     return $return;
 }
开发者ID:bleistivt,项目名称:BirthdayModule,代码行数:13,代码来源:class.birthdaymodule.php

示例11: IsSpam

 /**
  * Check whether or not the record is spam.
  * @param string $RecordType By default, this should be one of the following:
  *  - Comment: A comment.
  *  - Discussion: A discussion.
  *  - User: A user registration.
  * @param array $Data The record data.
  * @param array $Options Options for fine-tuning this method call.
  *  - Log: Log the record if it is found to be spam.
  */
 public static function IsSpam($RecordType, $Data, $Options = array())
 {
     if (self::$Disabled) {
         return FALSE;
     }
     // Set some information about the user in the data.
     if ($RecordType == 'Registration') {
         TouchValue('Username', $Data, $Data['Name']);
     } else {
         TouchValue('InsertUserID', $Data, Gdn::Session()->UserID);
         $User = Gdn::UserModel()->GetID(GetValue('InsertUserID', $Data), DATASET_TYPE_ARRAY);
         if ($User) {
             if (GetValue('Verified', $User)) {
                 // The user has been verified and isn't a spammer.
                 return FALSE;
             }
             TouchValue('Username', $Data, $User['Name']);
             TouchValue('Email', $Data, $User['Email']);
             TouchValue('IPAddress', $Data, $User['LastIPAddress']);
         }
     }
     if (!isset($Data['Body']) && isset($Data['Story'])) {
         $Data['Body'] = $Data['Story'];
     }
     TouchValue('IPAddress', $Data, Gdn::Request()->IpAddress());
     $Sp = self::_Instance();
     $Sp->EventArguments['RecordType'] = $RecordType;
     $Sp->EventArguments['Data'] =& $Data;
     $Sp->EventArguments['Options'] =& $Options;
     $Sp->EventArguments['IsSpam'] = FALSE;
     $Sp->FireEvent('CheckSpam');
     $Spam = $Sp->EventArguments['IsSpam'];
     // Log the spam entry.
     if ($Spam && GetValue('Log', $Options, TRUE)) {
         $LogOptions = array();
         switch ($RecordType) {
             case 'Registration':
                 $LogOptions['GroupBy'] = array('RecordIPAddress');
                 break;
             case 'Comment':
             case 'Discussion':
             case 'Activity':
             case 'ActivityComment':
                 $LogOptions['GroupBy'] = array('RecordID');
                 break;
         }
         LogModel::Insert('Spam', $RecordType, $Data, $LogOptions);
     }
     return $Spam;
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:60,代码来源:class.spammodel.php

示例12: Dismiss

 public function Dismiss($MessageID = '', $TransientKey = FALSE)
 {
     $Session = Gdn::Session();
     if ($TransientKey !== FALSE && $Session->ValidateTransientKey($TransientKey)) {
         $Prefs = $Session->GetPreference('DismissedMessages', array());
         $Prefs[] = $MessageID;
         $UserModel = Gdn::UserModel();
         $UserModel->SavePreference($Session->UserID, 'DismissedMessages', $Prefs);
     }
     if ($this->_DeliveryType === DELIVERY_TYPE_ALL) {
         Redirect(GetIncomingValue('Target', '/vanilla/discussions'));
     }
     $this->Render();
 }
开发者ID:Beyzie,项目名称:Garden,代码行数:14,代码来源:message.php

示例13: DeleteUserData

 /**
  * Delete all of the Vanilla related information for a specific user.
  * @param int $UserID The ID of the user to delete.
  * @param array $Options An array of options:
  *  - DeleteMethod: One of delete, wipe, or NULL
  * @since 2.1
  */
 public function DeleteUserData($UserID, $Options = array(), &$Data = NULL)
 {
     $SQL = Gdn::SQL();
     // Remove discussion watch records and drafts.
     $SQL->Delete('UserDiscussion', array('UserID' => $UserID));
     Gdn::UserModel()->GetDelete('Draft', array('InsertUserID' => $UserID), $Data);
     // Comment deletion depends on method selected
     $DeleteMethod = GetValue('DeleteMethod', $Options, 'delete');
     if ($DeleteMethod == 'delete') {
         // Clear out the last posts to the categories.
         $SQL->Update('Category c')->Join('Discussion d', 'd.DiscussionID = c.LastDiscussionID')->Where('d.InsertUserID', $UserID)->Set('c.LastDiscussionID', NULL)->Set('c.LastCommentID', NULL)->Put();
         $SQL->Update('Category c')->Join('Comment d', 'd.CommentID = c.LastCommentID')->Where('d.InsertUserID', $UserID)->Set('c.LastDiscussionID', NULL)->Set('c.LastCommentID', NULL)->Put();
         // Grab all of the discussions that the user has engaged in.
         $DiscussionIDs = $SQL->Select('DiscussionID')->From('Comment')->Where('InsertUserID', $UserID)->GroupBy('DiscussionID')->Get()->ResultArray();
         $DiscussionIDs = ConsolidateArrayValuesByKey($DiscussionIDs, 'DiscussionID');
         Gdn::UserModel()->GetDelete('Comment', array('InsertUserID' => $UserID), $Data);
         // Update the comment counts.
         $CommentCounts = $SQL->Select('DiscussionID')->Select('CommentID', 'count', 'CountComments')->Select('CommentID', 'max', 'LastCommentID')->WhereIn('DiscussionID', $DiscussionIDs)->GroupBy('DiscussionID')->Get('Comment')->ResultArray();
         foreach ($CommentCounts as $Row) {
             $SQL->Put('Discussion', array('CountComments' => $Row['CountComments'] + 1, 'LastCommentID' => $Row['LastCommentID']), array('DiscussionID' => $Row['DiscussionID']));
         }
         // Update the last user IDs.
         $SQL->Update('Discussion d')->Join('Comment c', 'd.LastCommentID = c.CommentID', 'left')->Set('d.LastCommentUserID', 'c.InsertUserID', FALSE, FALSE)->Set('d.DateLastComment', 'c.DateInserted', FALSE, FALSE)->WhereIn('d.DiscussionID', $DiscussionIDs)->Put();
         // Update the last posts.
         $Discussions = $SQL->WhereIn('DiscussionID', $DiscussionIDs)->Where('LastCommentUserID', $UserID)->Get('Discussion');
         // Delete the user's dicussions
         Gdn::UserModel()->GetDelete('Discussion', array('InsertUserID' => $UserID), $Data);
         // Update the appropriat recent posts in the categories.
         $CategoryModel = new CategoryModel();
         $Categories = $CategoryModel->GetWhere(array('LastDiscussionID' => NULL))->ResultArray();
         foreach ($Categories as $Category) {
             $CategoryModel->SetRecentPost($Category['CategoryID']);
         }
     } else {
         if ($DeleteMethod == 'wipe') {
             // Erase the user's dicussions
             $SQL->Update('Discussion')->Set('Body', T('The user and all related content has been deleted.'))->Set('Format', 'Deleted')->Where('InsertUserID', $UserID)->Put();
             // Erase the user's comments
             $SQL->From('Comment')->Join('Discussion d', 'c.DiscussionID = d.DiscussionID')->Delete('Comment c', array('d.InsertUserID' => $UserID));
             $SQL->Update('Comment')->Set('Body', T('The user and all related content has been deleted.'))->Set('Format', 'Deleted')->Where('InsertUserID', $UserID)->Put();
         } else {
             // Leave comments
         }
     }
     // Remove the user's profile information related to this application
     $SQL->Update('User')->Set(array('CountDiscussions' => 0, 'CountUnreadDiscussions' => 0, 'CountComments' => 0, 'CountDrafts' => 0, 'CountBookmarks' => 0))->Where('UserID', $UserID)->Put();
 }
开发者ID:remobjects,项目名称:Garden,代码行数:54,代码来源:class.hooks.php

示例14: DiscussionController_BeforeDiscussionRender_Handler

 public function DiscussionController_BeforeDiscussionRender_Handler($Sender, $Args)
 {
     if (!isset($_GET['noiseless'])) {
         return;
     }
     $Discussion = $Sender->Data('Discussion');
     $Sql = Gdn::SQL();
     $Sql->Select('*')->From('Comment c')->Where('c.DiscussionID', $Discussion->DiscussionID, TRUE, FALSE)->Where('c.InsertUserID', $Discussion->InsertUserID, TRUE, FALSE)->OrderBy('c.DateInserted', 'asc');
     $Result = $Sql->Get();
     Gdn::UserModel()->JoinUsers($Result, array('InsertUserID', 'UpdateUserID'));
     if (self::checkVersion('2.0')) {
         $Sender->SetData('CommentData', $Result, TRUE);
     }
     $Sender->SetData('Comments', $Result);
     $Sender->Pager->Configure(0, 0, 0, '', TRUE);
     $Sender->Offset = 0;
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:17,代码来源:default.php

示例15: GetUserEmails

 protected function GetUserEmails($FormValues)
 {
     $SQL = Gdn::SQL();
     $UserModel = Gdn::UserModel();
     if (ArrayValue('SendMeOnly', $FormValues)) {
         $Session = Gdn::Session();
         $UserID = GetValueR('User.UserID', $Session);
         $User = $UserModel->Get($UserID);
         $Result[$User->Email] = $User->Name;
         return $Result;
     }
     $Roles = ArrayValue('Roles', $FormValues);
     if (is_array($Roles) && count($Roles) > 0) {
         $DataSet = $SQL->Select('u.Name, u.Email')->From('UserRole r')->Join('User u', 'u.UserID = r.UserID')->WhereIn('r.RoleID', $Roles)->Get();
     } else {
         $DataSet = $SQL->Select('u.Name, u.Email')->From('User u')->Get();
     }
     $Result = ConsolidateArrayValuesByKey($DataSet->ResultArray(), 'Email', 'Name');
     return $Result;
 }
开发者ID:unlight,项目名称:MassDelivery,代码行数:20,代码来源:massdelivery.plugin.php


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