updated for 7.0 api

This commit is contained in:
JT Smith 2006-05-09 21:49:13 +00:00
parent ef036316cc
commit 7f9b081de0
3 changed files with 51 additions and 56 deletions

View file

@ -116,13 +116,13 @@ print "Searching for users with a status of $currentStatus ...\n" unless ($quiet
my $userList; my $userList;
my $now = $session->datetime->time(); my $now = $session->datetime->time();
my $inbox = WebGUI::Inbox->new($session); my $inbox = WebGUI::Inbox->new($session);
my $sth = WebGUI::SQL->read("select userId,assetId from InOutBoard_status where status=?",[$currentStatus]); my $sth = $session->db->read("select userId,assetId from InOutBoard_status where status=?",[$currentStatus]);
while (my ($userId,$assetId) = $sth->array) { while (my ($userId,$assetId) = $sth->array) {
my $user = WebGUI::User->new($session, $userId); my $user = WebGUI::User->new($session, $userId);
print "\tFound user ".$user->username."\n" unless ($quiet); print "\tFound user ".$user->username."\n" unless ($quiet);
$userList .= $user->username." (".$userId.")\n"; $userList .= $user->username." (".$userId.")\n";
WebGUI::SQL->write("update InOutBoard_status set dateStamp=?, message=?, status=? where userId=? and assetId=?",[$now, $whatsHappening, $newStatus, $userId, $assetId]); $session->db->write("update InOutBoard_status set dateStamp=?, message=?, status=? where userId=? and assetId=?",[$now, $whatsHappening, $newStatus, $userId, $assetId]);
WebGUI::SQL->write("insert into InOutBoard_statusLog (userId, createdBy, dateStamp, message, status, assetId) values (?,?,?,?,?,?)", $session->db->write("insert into InOutBoard_statusLog (userId, createdBy, dateStamp, message, status, assetId) values (?,?,?,?,?,?)",
[$userId,3,$now, $whatsHappening, $newStatus, $assetId]); [$userId,3,$now, $whatsHappening, $newStatus, $assetId]);
$inbox->addMessage({ $inbox->addMessage({
userId=>$userId, userId=>$userId,

View file

@ -1,4 +1,5 @@
WebGUI::Cache::Memcached WebGUI::Cache::Memcached
WebGUI::Cache::Database
WebGUI::Auth::LDAP WebGUI::Auth::LDAP
WebGUI::Asset::Wobject::WSClient WebGUI::Asset::Wobject::WSClient
WebGUI::Asset::File::ZipArchive WebGUI::Asset::File::ZipArchive
@ -9,6 +10,12 @@ WebGUI::Asset::Wobject::HttpProxy
WebGUI::Asset::Wobject::Product WebGUI::Asset::Wobject::Product
WebGUI::Asset::Wobject::Survey WebGUI::Asset::Wobject::Survey
WebGUI::Asset::Wobject::InOutBoard WebGUI::Asset::Wobject::InOutBoard
WebGUI::Asset::Wobject::Dashboard
WebGUI::Asset::Wobject::EventsManagementSystem
WebGUI::Asset::Wobject::ProjectManager
WebGUI::Asset::Wobject::SyndicatedContent
WebGUI::Asset::Wobject::WSClient
WebGUI::Asset::Wobject::MultiSearch
WebGUI::Commerce WebGUI::Commerce
WebGUI::Commerce::Item WebGUI::Commerce::Item
WebGUI::Commerce::Item::Product WebGUI::Commerce::Item::Product
@ -25,7 +32,6 @@ WebGUI::Subscription
WebGUI::Operation::TransactionLog WebGUI::Operation::TransactionLog
WebGUI::Operation::Commerce WebGUI::Operation::Commerce
WebGUI::Operation::Subscription WebGUI::Operation::Subscription
WebGUI::Asset::Wobject::IndexedSearch::Search
WebGUI::Macro::AOIHits WebGUI::Macro::AOIHits
WebGUI::Macro::AOIRank WebGUI::Macro::AOIRank
WebGUI::Macro::AdminText WebGUI::Macro::AdminText

View file

@ -18,10 +18,8 @@ BEGIN {
use Digest::MD5; use Digest::MD5;
use Getopt::Long; use Getopt::Long;
use strict; use strict;
use WebGUI::DateTime; use WebGUI::Group;
use WebGUI::Grouping;
use WebGUI::Session; use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::User; use WebGUI::User;
use WebGUI::Utility; use WebGUI::Utility;
@ -198,15 +196,15 @@ if (!($^O =~ /^Win/i) && $> != 0 && !$override) {
print "Starting up..." unless ($quiet); print "Starting up..." unless ($quiet);
WebGUI::Session::open($webguiRoot,$configFile); my $session = WebGUI::Session->open($webguiRoot,$configFile);
WebGUI::Session::refreshUserInfo(3); # The script should run as admin. $session->user({userId=>3});
open(FILE,"<".$usersFile); open(FILE,"<".$usersFile);
print "OK\n" unless ($quiet); print "OK\n" unless ($quiet);
my $first = 1; my $first = 1;
my $lineNumber = 0; my $lineNumber = 0;
my @field; my @field;
my @profileFields = WebGUI::SQL->buildArray("select fieldName from userProfileField"); my @profileFields = $session->db->buildArray("select fieldName from userProfileField");
while(<FILE>) { while(<FILE>) {
$lineNumber++; $lineNumber++;
chomp; chomp;
@ -231,7 +229,6 @@ while(<FILE>) {
$i++; $i++;
} }
# deal with defaults and overridescate) = WebGUI::SQL->quickArray("select userid from users where username=".quote($user{username}));
if ($user{username} eq "" && $user{firstName} ne "" && $user{lastName} ne "") { if ($user{username} eq "" && $user{firstName} ne "" && $user{lastName} ne "") {
$user{username} = $user{firstName}.".".$user{lastName}; $user{username} = $user{firstName}.".".$user{lastName};
} }
@ -254,67 +251,59 @@ while(<FILE>) {
$user{changePassword} = 0; $user{changePassword} = 0;
} }
} }
# process user # process user
my $u; my $u;
my $queryHandler; my $queryHandler;
# my ($duplicate) = WebGUI::SQL->quickArray("select count(*) from users where username=".quote($user{username})); my ($duplicate) = $session->db->quickArray("select userid from users where username=?",[$user{username}]);
my ($duplicate) = WebGUI::SQL->quickArray("select userid from users where username=".quote($user{username})); if ($user{username} eq "") {
print "Skipping line $lineNumber.\n" unless ($quiet);
if ($user{username} eq "") { print "Skipping line $lineNumber.\n" unless ($quiet); } } else {
else
{
# update only # update only
if ($update) if ($update) {
{ if ($duplicate) {
if ($duplicate)
{
print "Updating user $user{username}\n" unless ($quiet); print "Updating user $user{username}\n" unless ($quiet);
$u = WebGUI::User->new($duplicate); $u = WebGUI::User->new($session, $duplicate);
if ($replaceGroups and ($user{groups} ne "")) if ($replaceGroups and ($user{groups} ne "")) {
{ $queryHandler = $session->db->prepare("delete from groupings where userid=?",[$duplicate]);
$queryHandler = WebGUI::SQL->prepare("delete from groupings where userid=".quote($duplicate));
if ($queryHandler) { $queryHandler->execute(); } if ($queryHandler) { $queryHandler->execute(); }
} }
my ($pw) = WebGUI::SQL->quickArray("select authentication.fieldData from authentication,users where authentication.authMethod='WebGUI' and users.username=".quote($user{username})." and users.userId=authentication.userId and authentication.fieldName='identifier'"); my ($pw) = $session->db->quickArray("select authentication.fieldData from authentication,users where authentication.authMethod='WebGUI' and users.username=? and users.userId=authentication.userId and authentication.fieldName='identifier'",[$user{username}]);
$user{identifier} = $pw; $user{identifier} = $pw;
} } else {
else { print "User $user{username} not found. Skipping.\n" unless ($quiet); } print "User $user{username} not found. Skipping.\n" unless ($quiet);
} }
elsif ($updateAdd) # update and add users } elsif ($updateAdd) { # update and add users
{ if ($duplicate) {
if ($duplicate)
{
print "Updating user $user{username}\n" unless ($quiet); print "Updating user $user{username}\n" unless ($quiet);
$u = WebGUI::User->new($duplicate); $u = WebGUI::User->new($session, $duplicate);
if ($replaceGroups and ($user{groups} ne "")) if ($replaceGroups and ($user{groups} ne "")) {
{ $queryHandler = $session->db->prepare("delete from groupings where userid=?",[$duplicate]);
$queryHandler = WebGUI::SQL->prepare("delete from groupings where userid=".quote($duplicate));
if ($queryHandler) { $queryHandler->execute(); } if ($queryHandler) { $queryHandler->execute(); }
} }
my ($pw) = WebGUI::SQL->quickArray("select authentication.fieldData from authentication,users where authentication.authMethod='WebGUI' and users.username=".quote($user{username})." and users.userId=authentication.userId and authentication.fieldName='identifier'"); my ($pw) = $session->db->quickArray("select authentication.fieldData from authentication,users where authentication.authMethod='WebGUI' and users.username=? and users.userId=authentication.userId and authentication.fieldName='identifier'",[$user{username}]);
$user{identifier} = $pw; $user{identifier} = $pw;
} } else {
else { $u = WebGUI::User->new("new"); print "Adding user $user{username}\n" unless ($quiet); } $u = WebGUI::User->new($session, "new");
} print "Adding user $user{username}\n" unless ($quiet);
else # add users only }
{ } else { # add users only
if ($duplicate) { print "User $user{username} already exists. Skipping.\n" unless ($quiet); } if ($duplicate) {
else { $u = WebGUI::User->new("new"); print "Adding user $user{username}\n" unless ($quiet); } print "User $user{username} already exists. Skipping.\n" unless ($quiet);
} else {
$u = WebGUI::User->new($session, "new");
print "Adding user $user{username}\n" unless ($quiet);
}
} }
} }
if ($u) {
if ($u)
{
# my $u = WebGUI::User->new("new");
$u->username($user{username}); $u->username($user{username});
$u->authMethod($user{authMethod}); $u->authMethod($user{authMethod});
$u->status($user{status}); $u->status($user{status});
my $cmd = "WebGUI::Auth::".$authMethod; my $cmd = "WebGUI::Auth::".$authMethod;
my $load = "use ".$cmd; my $load = "use ".$cmd;
WebGUI::ErrorHandler::fatal("Authentication module failed to compile: $cmd.".$@) if($@); $session->errorHandler->fatal("Authentication module failed to compile: $cmd.".$@) if($@);
eval($load); eval($load);
my $auth = eval{$cmd->new($authMethod,$u->userId)}; my $auth = eval{$cmd->new($session, $authMethod,$u->userId)};
$auth->saveParams($u->userId,"WebGUI",{identifier=>$user{identifier}}); $auth->saveParams($u->userId,"WebGUI",{identifier=>$user{identifier}});
$auth->saveParams($u->userId,"LDAP",{ $auth->saveParams($u->userId,"LDAP",{
ldapUrl=>$user{ldapUrl}, ldapUrl=>$user{ldapUrl},
@ -336,8 +325,8 @@ while(<FILE>) {
} }
print "Cleaning up..." unless ($quiet); print "Cleaning up..." unless ($quiet);
close(FILE); close(FILE);
WebGUI::Session::end($session{var}{sessionId}); $session->var->end;
WebGUI::Session::close(); $session->close;
print "OK\n" unless ($quiet); print "OK\n" unless ($quiet);
@ -356,13 +345,13 @@ sub calculateExpireOffset {
} }
} }
if ($units eq "fixed") { if ($units eq "fixed") {
my $seconds = (($offset - WebGUI::DateTime::time())); my $seconds = (($offset - $session->datetime->time()));
if ($seconds < 1) { if ($seconds < 1) {
return undef; return undef;
} else { } else {
return int($seconds); return int($seconds);
} }
} }
return WebGUI::DateTime::intervalToSeconds($offset, $units) return $session->datetime->intervalToSeconds($offset, $units)
} }