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


PHP UserModel::getID方法代码示例

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


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

示例1: getValidUser

 public function getValidUser($user_id, $ret_type = DATASET_TYPE_ARRAY)
 {
     $UserModel = new UserModel();
     $result = $UserModel->getID($user_id, $ret_type);
     return GetValue('Deleted', $result) === '1' ? FALSE : $result;
     // $result can still be false.
 }
开发者ID:Nordic-T,项目名称:vanilla-plugins,代码行数:7,代码来源:class.sociallogin.php

示例2: emailConfirm

 /**
  * Confirm email address is valid via sent code.
  *
  * @access public
  * @since 2.0.0
  *
  * @param int $UserID
  * @param string $EmailKey Authenticate with unique, 1-time code sent via email.
  */
 public function emailConfirm($UserID, $EmailKey = '')
 {
     $User = $this->UserModel->getID($UserID);
     if (!$User) {
         throw notFoundException('User');
     }
     $EmailConfirmed = $this->UserModel->confirmEmail($User, $EmailKey);
     $this->Form->setValidationResults($this->UserModel->validationResults());
     if ($EmailConfirmed) {
         $UserID = val('UserID', $User);
         Gdn::session()->start($UserID);
     }
     $this->setData('EmailConfirmed', $EmailConfirmed);
     $this->setData('Email', $User->Email);
     $this->render();
 }
开发者ID:korelstar,项目名称:vanilla,代码行数:25,代码来源:class.entrycontroller.php

示例3: val

$Session = Gdn::session();
$TagCount = $this->data('RecordCount');
$Tags = $this->data('Tags');
?>
        <tbody>
        <?php 
foreach ($Tags as $Tag) {
    $CssClass = 'TagAdmin';
    $Title = '';
    $Special = FALSE;
    $type = val('Type', $Tag);
    if (empty($type)) {
        $type = t('Tag');
    }
    $userModel = new UserModel();
    $createdBy = $userModel->getID(val('InsertUserID', $Tag));
    $dateInserted = Gdn_Format::date(val('DateInserted', $Tag), '%e %b %Y');
    $count = val('CountDiscussions', $Tag, 0);
    $displayName = TagFullName($Tag);
    if (val('Type', $Tag)) {
        $Special = TRUE;
        $CssClass .= " Tag-Special Tag-{$Tag['Type']}";
        $Title = t('This is a special tag.');
    }
    ?>
            <tr id="<?php 
    echo "Tag_{$Tag['TagID']}";
    ?>
" class="<?php 
    echo $CssClass;
    ?>
开发者ID:vanilla,项目名称:vanilla,代码行数:31,代码来源:tagging.php

示例4: edit

 /**
  * Edit a user account.
  *
  * @since 2.0.0
  * @access public
  * @param int $UserID Unique ID.
  */
 public function edit($UserID)
 {
     $this->permission('Garden.Users.Edit');
     // Page setup
     $this->addJsFile('user.js');
     $this->title(t('Edit User'));
     $this->addSideMenu('dashboard/user');
     // Only admins can reassign roles
     $RoleModel = new RoleModel();
     $AllRoles = $RoleModel->getArray();
     $RoleData = $RoleModel->getAssignable();
     $UserModel = new UserModel();
     $User = $UserModel->getID($UserID, DATASET_TYPE_ARRAY);
     // Determine if username can be edited
     $CanEditUsername = (bool) c("Garden.Profile.EditUsernames") || Gdn::session()->checkPermission('Garden.Users.Edit');
     $this->setData('_CanEditUsername', $CanEditUsername);
     // Determine if emails can be edited
     $CanEditEmail = Gdn::session()->checkPermission('Garden.Users.Edit');
     $this->setData('_CanEditEmail', $CanEditEmail);
     // Decide if they have ability to confirm users
     $Confirmed = (bool) valr('Confirmed', $User);
     $CanConfirmEmail = UserModel::RequireConfirmEmail() && Gdn::session()->checkPermission('Garden.Users.Edit');
     $this->setData('_CanConfirmEmail', $CanConfirmEmail);
     $this->setData('_EmailConfirmed', $Confirmed);
     $User['ConfirmEmail'] = (int) $Confirmed;
     // Determine whether user being edited is privileged (can escalate permissions)
     $UserModel = new UserModel();
     $EditingPrivilegedUser = $UserModel->checkPermission($User, 'Garden.Settings.Manage');
     // Determine our password reset options
     // Anyone with user editing my force reset over email
     $this->ResetOptions = array(0 => t('Keep current password.'), 'Auto' => t('Force user to reset their password and send email notification.'));
     // Only admins may manually reset passwords for other admins
     if (checkPermission('Garden.Settings.Manage') || !$EditingPrivilegedUser) {
         $this->ResetOptions['Manual'] = t('Manually set user password. No email notification.');
     }
     // Set the model on the form.
     $this->Form->setModel($UserModel);
     // Make sure the form knows which item we are editing.
     $this->Form->addHidden('UserID', $UserID);
     try {
         $AllowEditing = true;
         $this->EventArguments['AllowEditing'] =& $AllowEditing;
         $this->EventArguments['TargetUser'] =& $User;
         // These are all the 'effective' roles for this edit action. This list can
         // be trimmed down from the real list to allow subsets of roles to be
         // edited.
         $this->EventArguments['RoleData'] =& $RoleData;
         $UserRoleData = $UserModel->getRoles($UserID)->resultArray();
         $RoleIDs = array_column($UserRoleData, 'RoleID');
         $RoleNames = array_column($UserRoleData, 'Name');
         $UserRoleData = arrayCombine($RoleIDs, $RoleNames);
         $this->EventArguments['UserRoleData'] =& $UserRoleData;
         $this->fireEvent("BeforeUserEdit");
         $this->setData('AllowEditing', $AllowEditing);
         $this->Form->setData($User);
         if ($this->Form->authenticatedPostBack()) {
             if (!$CanEditUsername) {
                 $this->Form->setFormValue("Name", $User['Name']);
             }
             // Allow mods to confirm/unconfirm emails
             $this->Form->removeFormValue('Confirmed');
             $Confirmation = $this->Form->getFormValue('ConfirmEmail', null);
             $Confirmation = !is_null($Confirmation) ? (bool) $Confirmation : null;
             if ($CanConfirmEmail && is_bool($Confirmation)) {
                 $this->Form->setFormValue('Confirmed', (int) $Confirmation);
             }
             $ResetPassword = $this->Form->getValue('ResetPassword', false);
             // If we're an admin or this isn't a privileged user, allow manual setting of password
             $AllowManualReset = checkPermission('Garden.Settings.Manage') || !$EditingPrivilegedUser;
             if ($ResetPassword == 'Manual' && $AllowManualReset) {
                 // If a new password was specified, add it to the form's collection
                 $NewPassword = $this->Form->getValue('NewPassword', '');
                 $this->Form->setFormValue('Password', $NewPassword);
             }
             // Role changes
             // These are the new roles the editing user wishes to apply to the target
             // user, adjusted for his ability to affect those roles
             $RequestedRoles = $this->Form->getFormValue('RoleID');
             if (!is_array($RequestedRoles)) {
                 $RequestedRoles = array();
             }
             $RequestedRoles = array_flip($RequestedRoles);
             $UserNewRoles = array_intersect_key($RoleData, $RequestedRoles);
             // These roles will stay turned on regardless of the form submission contents
             // because the editing user does not have permission to modify them
             $ImmutableRoles = array_diff_key($AllRoles, $RoleData);
             $UserImmutableRoles = array_intersect_key($ImmutableRoles, $UserRoleData);
             // Apply immutable roles
             foreach ($UserImmutableRoles as $IMRoleID => $IMRoleName) {
                 $UserNewRoles[$IMRoleID] = $IMRoleName;
             }
             // Put the data back into the forum object as if the user had submitted
             // this themselves
//.........这里部分代码省略.........
开发者ID:mcnasby,项目名称:datto-vanilla,代码行数:101,代码来源:class.usercontroller.php

示例5: userBookmarkCount

 public function userBookmarkCount($UserID = false)
 {
     if ($UserID === false) {
         $UserID = Gdn::session()->UserID;
     }
     if (!$UserID) {
         $CountBookmarks = null;
     } else {
         if ($UserID == Gdn::session() && isset(Gdn::session()->User->CountBookmarks)) {
             $CountBookmarks = Gdn::session()->User->CountBookmarks;
         } else {
             $UserModel = new UserModel();
             $User = $UserModel->getID($UserID, DATASET_TYPE_ARRAY);
             $CountBookmarks = $User['CountBookmarks'];
         }
         if ($CountBookmarks === null) {
             $CountBookmarks = Gdn::sql()->select('DiscussionID', 'count', 'CountBookmarks')->from('UserDiscussion')->where('Bookmarked', '1')->where('UserID', $UserID)->get()->value('CountBookmarks', 0);
             Gdn::userModel()->setField($UserID, 'CountBookmarks', $CountBookmarks);
         }
     }
     $this->setData('CountBookmarks', $CountBookmarks);
     $this->setData('_Value', $CountBookmarks);
     $this->xRender('Value', 'utility', 'dashboard');
 }
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:24,代码来源:class.discussionscontroller.php

示例6: discussionController_flag_create

 /**
  * Handle flagging process in a discussion.
  */
 public function discussionController_flag_create($Sender)
 {
     // Signed in users only.
     if (!($UserID = Gdn::session()->UserID)) {
         return;
     }
     $UserName = Gdn::session()->User->Name;
     $Arguments = $Sender->RequestArgs;
     if (sizeof($Arguments) != 5) {
         return;
     }
     list($Context, $ElementID, $ElementAuthorID, $ElementAuthor, $EncodedURL) = $Arguments;
     $URL = htmlspecialchars(base64_decode(str_replace('-', '=', $EncodedURL)));
     $Sender->setData('Plugin.Flagging.Data', array('Context' => $Context, 'ElementID' => $ElementID, 'ElementAuthorID' => $ElementAuthorID, 'ElementAuthor' => $ElementAuthor, 'URL' => $URL, 'UserID' => $UserID, 'UserName' => $UserName));
     if ($Sender->Form->authenticatedPostBack()) {
         $SQL = Gdn::sql();
         $Comment = $Sender->Form->getValue('Plugin.Flagging.Reason');
         $Sender->setData('Plugin.Flagging.Reason', $Comment);
         $CreateDiscussion = c('Plugins.Flagging.UseDiscussions');
         if ($CreateDiscussion) {
             // Category
             $CategoryID = c('Plugins.Flagging.CategoryID');
             // New discussion name
             if ($Context == 'comment') {
                 $Result = $SQL->select('d.Name')->select('c.Body')->from('Comment c')->join('Discussion d', 'd.DiscussionID = c.DiscussionID', 'left')->where('c.CommentID', $ElementID)->get()->firstRow();
             } elseif ($Context == 'discussion') {
                 $DiscussionModel = new DiscussionModel();
                 $Result = $DiscussionModel->getID($ElementID);
             }
             $DiscussionName = val('Name', $Result);
             $PrefixedDiscussionName = t('FlagPrefix', 'FLAG: ') . $DiscussionName;
             // Prep data for the template
             $Sender->setData('Plugin.Flagging.Report', array('DiscussionName' => $DiscussionName, 'FlaggedContent' => val('Body', $Result)));
             // Assume no discussion exists
             $this->DiscussionID = null;
             // Get discussion ID if already flagged
             $FlagResult = Gdn::sql()->select('DiscussionID')->from('Flag fl')->where('ForeignType', $Context)->where('ForeignID', $ElementID)->get()->firstRow();
             if ($FlagResult) {
                 // New comment in existing discussion
                 $DiscussionID = $FlagResult->DiscussionID;
                 $ReportBody = $Sender->fetchView($this->getView('reportcomment.php'));
                 $SQL->insert('Comment', array('DiscussionID' => $DiscussionID, 'InsertUserID' => $UserID, 'Body' => $ReportBody, 'Format' => 'Html', 'DateInserted' => date('Y-m-d H:i:s')));
                 $CommentModel = new CommentModel();
                 $CommentModel->updateCommentCount($DiscussionID);
             } else {
                 // New discussion body
                 $ReportBody = $Sender->fetchView($this->getView('report.php'));
                 $DiscussionID = $SQL->insert('Discussion', array('InsertUserID' => $UserID, 'UpdateUserID' => $UserID, 'CategoryID' => $CategoryID, 'Name' => $PrefixedDiscussionName, 'Body' => $ReportBody, 'Format' => 'Html', 'CountComments' => 1, 'DateInserted' => date('Y-m-d H:i:s'), 'DateUpdated' => date('Y-m-d H:i:s'), 'DateLastComment' => date('Y-m-d H:i:s')));
                 // Update discussion count
                 $DiscussionModel = new DiscussionModel();
                 $DiscussionModel->updateDiscussionCount($CategoryID);
             }
         }
         try {
             // Insert the flag
             $SQL->insert('Flag', array('DiscussionID' => $DiscussionID, 'InsertUserID' => $UserID, 'InsertName' => $UserName, 'AuthorID' => $ElementAuthorID, 'AuthorName' => $ElementAuthor, 'ForeignURL' => $URL, 'ForeignID' => $ElementID, 'ForeignType' => $Context, 'Comment' => $Comment, 'DateInserted' => date('Y-m-d H:i:s')));
         } catch (Exception $e) {
         }
         // Notify users with permission who've chosen to be notified
         if (!$FlagResult) {
             // Only send if this is first time it's being flagged.
             $Sender->setData('Plugin.Flagging.DiscussionID', $DiscussionID);
             $Subject = isset($PrefixedDiscussionName) ? $PrefixedDiscussionName : t('FlagDiscussion', 'A discussion was flagged');
             $EmailBody = $Sender->fetchView($this->getView('reportemail.php'));
             $NotifyUsers = c('Plugins.Flagging.NotifyUsers', array());
             // Send emails
             $UserModel = new UserModel();
             foreach ($NotifyUsers as $UserID) {
                 $User = $UserModel->getID($UserID);
                 $Email = new Gdn_Email();
                 $Email->to($User->Email)->subject(sprintf(t('[%1$s] %2$s'), Gdn::config('Garden.Title'), $Subject))->message($EmailBody);
                 try {
                     $Email->send();
                 } catch (Exception $e) {
                     if (debug()) {
                         throw $e;
                     }
                 }
             }
         }
         $Sender->informMessage(t('FlagSent', "Your complaint has been registered."));
     }
     $Sender->render($this->getView('flag.php'));
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:87,代码来源:class.flagging.plugin.php

示例7: get

 /**
  * Render basic data about user.
  *
  * @since 2.0.?
  * @access public
  * @param int $UserID Unique ID.
  */
 public function get($UserID = false)
 {
     if (!$UserID) {
         $UserID = Gdn::session()->UserID;
     }
     if (($UserID != Gdn::session()->UserID || !Gdn::session()->UserID) && !checkPermission('Garden.Users.Edit')) {
         throw new Exception(t('You do not have permission to view other profiles.'), 401);
     }
     $UserModel = new UserModel();
     // Get the user.
     $User = $UserModel->getID($UserID, DATASET_TYPE_ARRAY);
     if (!$User) {
         throw notFoundException('User');
     }
     $PhotoUrl = $User['Photo'];
     if ($PhotoUrl && strpos($PhotoUrl, '//') == false) {
         $PhotoUrl = url('/uploads/' . changeBasename($PhotoUrl, 'n%s'), true);
     }
     $User['Photo'] = $PhotoUrl;
     // Remove unwanted fields.
     $this->Data = arrayTranslate($User, array('UserID', 'Name', 'Email', 'Photo'));
     $this->render();
 }
开发者ID:korelstar,项目名称:vanilla,代码行数:30,代码来源:class.profilecontroller.php

示例8: setSessionUser

 /**
  * Internally store the uid for the active user
  *
  * @param User $user 
  * @return void
  * @author Craig Ulliott
  */
 public static function setSessionUser(UserModel $user)
 {
     // we use the facebookID for the wib library
     self::$uid = $user->getID();
 }
开发者ID:Tapac,项目名称:hotscot,代码行数:12,代码来源:whereivebeen_wrapper.php

示例9: getAlbums

 /**
  * Return an array of Facebook albums owned by the given user
  *
  * @param User $user 
  * @return array
  */
 public static function getAlbums(UserModel $user)
 {
     // this method requires a session key
     if (!($session_user = self::$user)) {
         return array();
     }
     $albums = array();
     // get facebookID for the given user
     $uid = $user->getID();
     // pull albums for the given user
     try {
         $fql = 'SELECT aid, owner, cover_pid, name, size, link, description, created, modified, location FROM album WHERE owner = ' . $uid;
         $results = self::getClient()->api_client->fql_query($fql);
     } catch (Exception $e) {
         $results = array('error_code' => $e->getCode(), 'error_msg' => $e->getMessage());
     }
     // if an error occred, log it
     if (isset($results['error_code'])) {
         self::log('facebook getPhotos-' . $uid . '-' . $results['error_msg']);
     } elseif ($results) {
         foreach ($results as $row) {
             // if album is empty skip it
             if (isset($row['size']) && $row['size']) {
                 // format data how wib likes it
                 $album = array('albumID' => $row['aid'], 'coverPID' => $row['cover_pid'], 'name' => $row['name'], 'description' => $row['description'], 'location' => $row['location'], 'link' => $row['link'], 'size' => $row['size'], 'created' => $row['created']);
                 $albums[$row['aid']] = $album;
             }
         }
     }
     return $albums;
 }
开发者ID:Tapac,项目名称:hotscot,代码行数:37,代码来源:facebook_wrapper.php


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