本文整理汇总了PHP中UserManager::getUserById方法的典型用法代码示例。如果您正苦于以下问题:PHP UserManager::getUserById方法的具体用法?PHP UserManager::getUserById怎么用?PHP UserManager::getUserById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserManager
的用法示例。
在下文中一共展示了UserManager::getUserById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkToken
/**
* @param Rest_Token $token
* @return PFUser or null if the user is not found
* @throws Rest_Exception_InvalidTokenException
*/
public function checkToken(Rest_Token $token)
{
if ($this->token_factory->doesTokenExist($token->getUserId(), $token->getTokenValue())) {
return $this->user_manager->getUserById($token->getUserId());
}
throw new Rest_Exception_InvalidTokenException();
}
示例2: getUserFromParameters
private function getUserFromParameters()
{
$user = $this->user_manager->getUserById($this->getUserIdFromParameters());
if ($user == null) {
throw new UserNotExistException();
}
return $user;
}
示例3: updateWithUserId
public function updateWithUserId($user_id)
{
$user = $this->user_manager->getUserById($user_id);
if ($user && $user->isAlive()) {
$this->updateWithUser($user);
} else {
$this->logger->warn('Do not write LDAP info about non existant or suspended users ' . $user_id);
}
}
示例4: fetch
/**
*
* @param int $group_id
* @return GenericUser|null
*/
public function fetch($group_id)
{
if ($row = $this->dao->fetch($group_id)->getRow()) {
$pfuser = $this->user_manager->getUserById($row['user_id']);
$generic_user = $this->generateGenericUser($group_id, $pfuser);
return $generic_user;
}
return null;
}
示例5: getAssignees
/**
* Retrieve users who are assigned to a given artifact
*
* @param Tracker_Artifact $artifact
* @return PFUser[]
*/
public function getAssignees(Tracker_Artifact $artifact)
{
$user_collection = array();
foreach ($this->getAssigneeIds($artifact) as $user_id) {
$user = $this->user_manager->getUserById($user_id);
if ($user) {
$user_collection[$user_id] = $user;
}
}
return $user_collection;
}
示例6: buildFieldDataForREST
/**
* Get the field data for artifact submission
* @throws Tracker_Artifact_Attachment_FileNotFoundException
* @throws Tracker_Artifact_Attachment_AlreadyLinkedToAnotherArtifactException
*/
public function buildFieldDataForREST($rest_value, Tracker_Artifact $artifact = null)
{
$field_data = array();
$already_attached_file_ids = array();
if ($artifact) {
$already_attached_file_ids = $this->getAlreadyAttachedFileIds($artifact);
}
$given_rest_file_ids = $rest_value->value;
// Ids given in REST
foreach ($given_rest_file_ids as $file_id) {
$linked_artifact = $this->file_info_factory->getArtifactByFileInfoIdInLastChangeset($file_id);
// Temporary => link
if (!$linked_artifact && $this->isFileIdTemporary($file_id)) {
$temporary_file = $this->getFile($file_id);
$user = $this->user_manager->getUserById($temporary_file->getCreatorId());
if (!$this->exists($user, $temporary_file->getTemporaryName())) {
throw new Tracker_Artifact_Attachment_FileNotFoundException('Temporary file #' . $file_id . ' not found');
}
$field_data[] = $this->file_info_factory->buildFileInfoData($temporary_file, $this->getPath($user, $temporary_file->getTemporaryName()));
} elseif (!$linked_artifact && !$this->isFileIdTemporary($file_id)) {
throw new Tracker_Artifact_Attachment_FileNotFoundException('Temporary file #' . $file_id . ' not found');
// Already attached to another artifact => error
} elseif ($artifact && $artifact->getId() != $linked_artifact->getId() || !$artifact && $linked_artifact) {
throw new Tracker_Artifact_Attachment_AlreadyLinkedToAnotherArtifactException('File #' . $file_id . ' is already linked to artifact #' . $linked_artifact->getId());
}
}
// Already attached file ids
foreach ($already_attached_file_ids as $file_id) {
// Not in given ids => unlink
if (!in_array($file_id, $given_rest_file_ids)) {
$field_data['delete'][] = $file_id;
}
}
return $field_data;
}
示例7: Premium
/**
* Fonction faisant devenir premium le membre connecté.
*/
function Premium()
{
$udm = new User_DroitManager(connexionDb());
$udm->modifDroit($_SESSION['User']->getId(), 3);
$um = new UserManager(connexionDb());
$user = $um->getUserById($_SESSION['User']->getId());
$_SESSION['User'] = $user;
}
示例8: getUser
private function getUser($user_id)
{
$user = $this->user_manager->getUserById($user_id);
if (!$user) {
throw new Tracker_Artifact_MailGateway_RecipientUserDoesNotExistException();
}
return $user;
}
示例9: getAdditionnalValue
/**
* Return the addtionnal value
*
* @return Tracker_FormElement_Field_List_Bind_UsersValue
*/
protected function getAdditionnalValue($value_id)
{
if (!isset($this->additionnal_values[$value_id])) {
$this->additionnal_values[$value_id] = null;
if ($user = $this->userManager->getUserById($value_id)) {
$this->additionnal_values[$value_id] = new Tracker_FormElement_Field_List_Bind_UsersValue($user->getId());
}
}
return $this->additionnal_values[$value_id];
}
示例10: membreExistant
/**
* Fonction servant à vérifier l'existence d'un membre à l'aide de l'ID contenu dans l'url.
* @return bool : true si il existe, false si il n'existe pas.
*/
function membreExistant()
{
$id = $_GET['membre'];
$um = new UserManager(connexionDb());
$user = $um->getUserById($id);
if ($user->getUserName() == NULL) {
return false;
} else {
return true;
}
}
示例11: getFriendByFid
public static function getFriendByFid($_fid)
{
$arr = array();
require "opendb.php";
require "history.php";
require "account.php";
require "user.php";
array_push($arr, array("user" => UserManager::getUserById($_fid), "lastlocation" => HistoryManager::getLastUserHistory($_fid), "state" => UserManager::getAvailable($_fid), "numberlist" => AccountManager::getNumbersById($_fid), "share" => "-1"));
//require("closedb.php");
return $arr[0];
}
示例12: authenticate
/**
* Authenticate user but doesn't verify if they are valid
*
* @param String $name
* @param String $password
* @return PFUser
* @throws User_InvalidPasswordWithUserException
* @throws User_InvalidPasswordException
* @throws User_PasswordExpiredException
*/
public function authenticate($name, $password)
{
$auth_success = false;
$auth_user_id = null;
$auth_user_status = null;
$this->event_manager->processEvent(Event::SESSION_BEFORE_LOGIN, array('loginname' => $name, 'passwd' => $password, 'auth_success' => &$auth_success, 'auth_user_id' => &$auth_user_id, 'auth_user_status' => &$auth_user_status));
if ($auth_success) {
$user = $this->user_manager->getUserById($auth_user_id);
} else {
$user = $this->user_manager->getUserByUserName($name);
if (!is_null($user)) {
$auth_success = $this->authenticateFromDatabase($user, $password);
}
}
if (!$user) {
throw new User_InvalidPasswordException();
} else {
if (!$auth_success) {
throw new User_InvalidPasswordWithUserException($user);
}
}
return $user;
}
示例13: appendDocuments
private function appendDocuments(DOMElement $parent_node, PFUser $admin_user, $doc_group_id)
{
foreach ($this->dao->searchAllDocs($doc_group_id) as $row) {
$creator_name = $admin_user->getUserName();
$creator = $this->user_manager->getUserById($row['created_by']);
if ($creator !== null && ($creator->isActive() || $creator->isRestricted())) {
$creator_name = $creator->getUnixName();
}
$document = $this->createDocument($row['title'], $row['description'], $row['createdate'], $row['updatedate'], $creator_name);
$this->appendPermissions($document, $row['docid'], self::DOCUMENT_PERMISSION_TYPE);
$this->appendFile($document, $row, $creator_name);
$parent_node->appendChild($document);
}
}
示例14: userHavePermissionOnTracker
private function userHavePermissionOnTracker(PFUser $user, Tracker_Artifact $artifact)
{
$permissions = $artifact->getTracker()->getAuthorizedUgroupsByPermissionType();
foreach ($permissions as $permission_type => $ugroups) {
switch ($permission_type) {
case Tracker::PERMISSION_FULL:
foreach ($ugroups as $ugroup) {
if ($this->userBelongsToGroup($user, $artifact, $ugroup)) {
return true;
}
}
break;
case Tracker::PERMISSION_SUBMITTER:
foreach ($ugroups as $ugroup) {
if ($this->userBelongsToGroup($user, $artifact, $ugroup)) {
// check that submitter is also a member
$submitter = $this->user_manager->getUserById($artifact->getSubmittedBy());
if ($this->userBelongsToGroup($submitter, $artifact, $ugroup)) {
return true;
}
}
}
break;
case Tracker::PERMISSION_ASSIGNEE:
foreach ($ugroups as $ugroup) {
if ($this->userBelongsToGroup($user, $artifact, $ugroup)) {
// check that one of the assignees is also a member
$permission_assignee = new Tracker_Permission_PermissionRetrieveAssignee($this->user_manager);
foreach ($permission_assignee->getAssignees($artifact) as $assignee) {
if ($this->userBelongsToGroup($assignee, $artifact, $ugroup)) {
return true;
}
}
}
}
break;
case Tracker::PERMISSION_SUBMITTER_ONLY:
foreach ($ugroups as $ugroup) {
if ($this->userBelongsToGroup($user, $artifact, $ugroup)) {
if ($user->getId() == $artifact->getSubmittedBy()) {
return true;
}
}
}
break;
}
}
return false;
}
示例15: getUserById
public function getUserById($userId, $initObjects = self::INIT_ALL, $cacheMinutes = 0, $cacheTag = null)
{
if ($this->memcache != null) {
$key = $this->memcache->getNamespacedKey(self::USER_TAG . $userId);
$cache = $this->memcache->get($key);
if ($cache !== false and !empty($cache) and is_a($cache, "User") and isset($cache->id) and !empty($cache->id)) {
return $cache;
}
$user = parent::getUserById($userId, self::INIT_ALL);
$this->memcache->set($key, $user, 0);
return $user;
} else {
return parent::getUserById($userId, $initObjects);
}
}