Minor bug fixes required to make the code run without crashing...

git-svn-id: svn://10.0.0.236/trunk@96276 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
ian%hixie.ch 2001-06-03 16:14:41 +00:00
parent c054620213
commit c77a5c18e0
4 changed files with 25 additions and 30 deletions

View File

@ -45,40 +45,29 @@ sub getUserIDByUsername {
# example, for the field 'contact.icq', the type data field might
# contain the string 'ICQ:' and the user field might be '55378571'
# making the username 'ICQ:55378571'.
my $row = $self->database($app)->execute('SELECT userData.userID
FROM userData, userDataTypes
WHERE userData.fieldID = userDataTypes.fieldID
AND userDataTypes.category = \'contact\'
AND CONCAT(userDataTypes.data, userData.data) = ?', $username)->row;
if (defined($row)) {
return $row->[0];
} else {
return undef;
}
return $self->database($app)->execute('SELECT userData.userID
FROM userData, userDataTypes
WHERE userData.fieldID = userDataTypes.fieldID
AND userDataTypes.category = \'contact\'
AND CONCAT(userDataTypes.data, userData.data) = ?', $username)->row;
# return userID or undef
}
sub getUserIDByContactDetails {
my $self = shift;
my($app, $contactName, $address) = @_;
my $row = $self->database($app)->execute('SELECT userData.userID
FROM userData, userDataTypes
WHERE userData.fieldID = userDataTypes.fieldID
AND userDataTypes.category = \'contact\'
AND userDataTypes.name = ?
AND userData.data = ?', $contactName, $address)->row;
if (defined($row)) {
return $row->[0];
} else {
return undef;
}
return $self->database($app)->execute('SELECT userData.userID
FROM userData, userDataTypes
WHERE userData.fieldID = userDataTypes.fieldID
AND userDataTypes.category = \'contact\'
AND userDataTypes.name = ?
AND userData.data = ?', $contactName, $address)->row;
# return userID or undef
}
sub getUserByID {
my $self = shift;
my($app, $id) = @_;
$self->notImplemented();
my @userData = $self->database($app)->execute('SELECT userID, mode, password, adminMessage, newFieldID, newFieldValue, newFieldKey
FROM user WHERE userID = ?', $id)->row;
if (@userData) {
@ -356,7 +345,7 @@ sub setupInstall {
category varchar(64) NOT NULL,
name varchar(64) NOT NULL,
type varchar(64) NOT NULL,
data text,
data text NOT NULL DEFAULT \'\',
mode integer unsigned NOT NULL DEFAULT 0,
UNIQUE KEY (category, name)
)

View File

@ -41,7 +41,9 @@ $app->run();
# setup everything (automatically called by the constructor, above)
sub init {
my $self = shift;
$self->dump(5, '', '', '*** Started PLIF Application ***', '********************************');
$self->dump(10, '', '', '********************************');
$self->dump(5, '*** Started PLIF Application ***');
$self->dump(10, '********************************');
$self->SUPER::init(@_);
$self->initInput();
}
@ -101,7 +103,7 @@ sub output {
my $self = shift;
my($protocol, $session) = @_;
my $default = 0;
if (not $protocol) {
if (not defined($protocol)) {
if (defined($self->defaultOutput)) {
return $self->defaultOutput;
}
@ -112,6 +114,9 @@ sub output {
$default = 1;
$protocol = $self->selectOutputProtocol();
}
if (not defined($session)) {
$session = $self->getObject('session');
}
# There are two output models in PLIF. The first is the protocol-
# specific-code model, the second is the string-expander
# model. The string expander model is still protocol specific to

View File

@ -49,7 +49,7 @@ sub newPassword {
# password for a one-time sending to the user.
my $password = $self->generatePassword();
my $crypt = $self->crypt($password);
return ($crypt, password);
return ($crypt, $password);
}
sub checkPassword {

View File

@ -126,7 +126,8 @@ sub objectInit {
}
$self->groups({%$groups}); # hash of groupID => groupName
$self->originalGroups({%$groups}); # a backup used to make a comparison when saving the groups
$self->rights(map {$_ => 1} @$rights); # map a list of strings into a hash for easy access
my %rights = map {$_ => 1} @$rights;
$self->rights(\%rights); # map a list of strings into a hash for easy access
$self->{'_DIRTY'}->{'properties'} = 0;
}
@ -226,8 +227,8 @@ sub hash {
$result->{'userID'} = $self->userID,
$result->{'mode'} = $self->mode,
$result->{'adminMessage'} = $self->adminMessage,
$result->{'groups'} = $self->groups,
$result->{'rights'} = keys(%{$self->rights});
$result->{'groups'} = $self->groups;
$result->{'rights'} = [keys(%{$self->rights})];
$result->{'fields'} = {};
foreach my $field (values(%{$self->fieldsByID})) {
# XXX should we also pass the field metadata on? (e.g. typeData)
@ -292,7 +293,7 @@ sub propertyGet {
my $self = shift;
my($name) = @_;
if ($name eq 'groups') {
return {%{$self->groups}};
return {%{$self->{'groups'}}};
# Create new hash so that they can't edit ours. This ensures
# that they can't inadvertently bypass the DIRTY flagging by
# propertySet(), above. This does mean that internally we have