$remote_displayname = $remote_username;
if (NULL !== ($remote_userid = getUserIDByUsername ($remote_username)))
{
- $user_given_tags = loadEntityTags ('user', $remote_userid);
// Always set $remote_displayname, if a local account exists and has one.
// This can be overloaded from LDAP later though.
- $userinfo = getUserInfo ($remote_userid);
+ $userinfo = spotEntity ('user', $remote_userid);
+ $user_given_tags = $userinfo['etags'];
if (!empty ($userinfo['user_realname']))
$remote_displayname = $userinfo['user_realname'];
}
{
if (NULL === ($userid = getUserIDByUsername ($username))) // user not found
return FALSE;
- if (NULL === ($userinfo = getUserInfo ($userid))) // user found, DB error
+ // FIXME: consider avoiding this DB call, because user data should be already
+ // available in authenticate().
+ if (NULL === ($userinfo = spotEntity ('user', $userid))) // user found, DB error
{
showError ('Cannot load user data', __FUNCTION__);
die();
case 'user':
$page = 'user';
$id_name = 'user_id';
- $userinfo = getUserInfo ($row['entity_id']);
- $name = $userinfo['user_name'];
+ $parent = spotEntity ($row['entity_type'], $row['entity_id']);
+ $name = $parent['user_name'];
break;
}
return NULL;
}
-function getUserInfo ($user_id)
-{
- $query = "select 'user' as realm, user_id, user_name, user_password_hash, user_realname from UserAccount where user_id = ${user_id}";
- if (($result = useSelectBlade ($query, __FUNCTION__)) == NULL)
- {
- showError ('SQL query failed', __FUNCTION__);
- die;
- }
- if ($row = $result->fetch (PDO::FETCH_ASSOC))
- return $row;
- return NULL;
-}
-
?>
function renderUser ($user_id)
{
global $target_given_tags;
- $userinfo = getUserInfo ($user_id);
+ $userinfo = spotEntity ('user', $user_id);
startPortlet ('summary');
echo '<table border=0 align=center>';
switch ($link['entity_type'])
{
case 'user':
- if (NULL === ($userinfo = getUserInfo ($link['entity_id'])))
- echo "Internal error: user id ${link['entity_id']} not found";
- else
- renderCell ($userinfo);
- break;
case 'ipv4net':
renderCell (spotEntity ($link['entity_type'], $link['entity_id']));
break;
);
case 'user':
assertUIntArg ('user_id', __FUNCTION__);
- $userinfo = getUserInfo ($_REQUEST['user_id']);
+ $userinfo = spotEntity ('user', $_REQUEST['user_id']);
return array
(
'name' => "Local user '" . $userinfo['user_name'] . "'",
assertStringArg ('password', __FUNCTION__);
$username = $_REQUEST['username'];
$new_password = $_REQUEST['password'];
- if (NULL == ($userinfo = getUserInfo ($_REQUEST['user_id'])))
+ if (NULL == ($userinfo = spotEntity ('user', $_REQUEST['user_id'])))
return buildRedirectURL (__FUNCTION__, 'ERR1');
// Update user password only if provided password is not the same as current password hash.
if ($new_password != $userinfo['user_password_hash'])
assertStringArg ('newpassword1', __FUNCTION__);
assertStringArg ('newpassword2', __FUNCTION__);
$remote_userid = getUserIDByUsername ($remote_username);
- $userinfo = getUserInfo ($remote_userid);
+ $userinfo = spotEntity ('user', $remote_userid);
if ($userinfo['user_password_hash'] != sha1 ($_REQUEST['oldpassword']))
return buildRedirectURL (__FUNCTION__, 'ERR2');
if ($_REQUEST['newpassword1'] != $_REQUEST['newpassword2'])