fixed #9851: New Users have blank profile field privacy settings

This commit is contained in:
Yung Han Khoe 2009-06-03 15:24:20 +00:00
parent 8d12d12db0
commit 1ea08936f4
5 changed files with 48 additions and 1 deletions

View file

@ -25,6 +25,7 @@ use WebGUI::Workflow::Instance;
use WebGUI::Shop::AddressBook;
use JSON;
use WebGUI::Exception;
use WebGUI::ProfileField;
=head1 NAME
@ -83,6 +84,19 @@ sub _create {
my $userId = shift || $session->id->generate();
$session->db->write("insert into users (userId,dateCreated) values (?,?)",[$userId, time()]);
$session->db->write("INSERT INTO userProfileData (userId) VALUES (?)",[$userId]);
# Set wg_privacySettings
my @fields = @{WebGUI::ProfileField->getFields($session)};
my $privacy = {};
foreach my $field (@fields) {
#$session->errorHandler->warn('getting privacy setting for field: '.$fieldName);
my $privacySetting = $field->get('defaultPrivacySetting');
next unless (WebGUI::Utility::isIn($privacySetting,qw(all none friends)));
$privacy->{$field->get('fieldName')} = $privacySetting;
}
my $json = JSON->new->encode($privacy);
$session->db->write("update userProfileData set wg_privacySettings=? where userId=?",[$json,$userId]);
WebGUI::Group->new($session,2)->addUsers([$userId]);
WebGUI::Group->new($session,7)->addUsers([$userId]);
return $userId;