add: User profile data table is now a flat table.

This commit is contained in:
Doug Bell 2007-05-28 21:35:34 +00:00
parent 8590ef89d5
commit 07a40788bb
41 changed files with 493 additions and 164 deletions

View file

@ -31,14 +31,10 @@ sub _fetchNames {
my $self = shift;
my @userIds = @_;
my %nameHash;
my $sql = "select users.username,
users.userId,
a.fieldData as firstName,
b.fieldData as lastName
from users
left join userProfileData a on users.userId=a.userId and a.fieldName='firstName'
left join userProfileData b on users.userId=b.userId and b.fieldName='lastName'
where users.userId=?";
my $sql = "SELECT users.username, users.userId, firstName, lastName
FROM users
LEFT JOIN userProfileData ON users.userId=userProfileData.userId
WHERE users.userId=?";
my $sth = $self->session->db->prepare($sql);
foreach my $userId (@userIds) {
$sth->execute([ $userId ]);
@ -51,7 +47,7 @@ where users.userId=?";
#-------------------------------------------------------------------
sub _fetchDepartments {
my $self = shift;
return $self->session->db->buildArray("select fieldData from userProfileData where fieldName='department' GROUP by fieldData");
return $self->session->db->buildArray("SELECT department FROM userProfileData GROUP BY department");
}
@ -244,19 +240,17 @@ sub view {
my $sql = "select users.username,
users.userId,
a.fieldData as firstName,
firstName,
InOutBoard_status.message,
b.fieldData as lastName,
lastName,
InOutBoard_status.status,
InOutBoard_status.dateStamp,
c.fieldData as department,
department,
groupings.groupId
from users
left join groupings on groupings.userId=users.userId
left join InOutBoard on groupings.groupId=InOutBoard.inOutGroup
left join userProfileData a on users.userId=a.userId and a.fieldName='firstName'
left join userProfileData b on users.userId=b.userId and b.fieldName='lastName'
left join userProfileData c on users.userId=c.userId and c.fieldName='department'
left join userProfileData on users.userId=userProfileData.userId
left join InOutBoard_status on users.userId=InOutBoard_status.userId and InOutBoard_status.assetId=".$self->session->db->quote($self->getId())."
where users.userId<>'1' and InOutBoard.inOutGroup=".$self->session->db->quote($self->get("inOutGroup"))."
group by userId
@ -312,14 +306,12 @@ sub www_selectDelegates {
"select
users.username,
users.userId,
a.fieldData as firstName,
b.fieldData as lastName
firstName,
lastName
from users
left join groupings on users.userId=groupings.userId
left join InOutBoard on groupings.groupId=InOutBoard.inOutGroup
left join userProfileData a on users.userId=a.userId and a.fieldName='firstName'
left join userProfileData b on users.userId=b.userId and b.fieldName='lastName'
left join userProfileData c on users.userId=c.userId and c.fieldName='department'
left join userProfileData on users.userId=userProfileData.userId
left join InOutBoard_status on users.userId=InOutBoard_status.userId and InOutBoard_status.assetId=?
where
users.userId<>'1'
@ -465,19 +457,17 @@ sub www_viewReport {
my $sql = "select users.username,
users.userId,
a.fieldData as firstName,
firstName,
InOutBoard_statusLog.message,
b.fieldData as lastName,
lastName,
InOutBoard_statusLog.status,
InOutBoard_statusLog.dateStamp,
InOutBoard_statusLog.createdBy,
c.fieldData as department,
department,
groupings.groupId
from users
left join groupings on groupings.userId=users.userId
left join userProfileData a on users.userId=a.userId and a.fieldName='firstName'
left join userProfileData b on users.userId=b.userId and b.fieldName='lastName'
left join userProfileData c on users.userId=c.userId and c.fieldName='department'
left join userProfileData on users.userId=userProfileData.userId
left join InOutBoard_statusLog on users.userId=InOutBoard_statusLog.userId and InOutBoard_statusLog.assetId=".$self->session->db->quote($self->getId())."
where users.userId<>'1' and
groupings.groupId=".$self->session->db->quote($self->getValue("inOutGroup"))." and

View file

@ -270,13 +270,10 @@ sub _userSearchQuery {
my $query = <<"SQL";
SELECT 'user' AS resourceKind, users.userId AS resourceId
FROM users
LEFT JOIN userProfileData AS lastName ON users.userId = lastName.userId
AND lastName.fieldName = 'lastName'
LEFT JOIN userProfileData AS firstName ON users.userId = firstName.userId
AND firstName.fieldName = 'firstName'
WHERE (LOWER(lastName.fieldData) LIKE ? OR LOWER(firstName.fieldData) LIKE ?
LEFT JOIN userProfileData ON users.userId = userProfileData.userId
WHERE (LOWER(lastName) LIKE ? OR LOWER(firstName) LIKE ?
OR LOWER(users.username) LIKE ?) AND (users.userId NOT IN $excludePlaceholders)
ORDER BY lastName.fieldData, firstName.fieldData
ORDER BY lastName, firstName
SQL
my @placeholders = (($searchPattern) x 3, @exclude);
return ($query, \@placeholders);