lots of small bug fixes

This commit is contained in:
JT Smith 2005-02-16 03:48:23 +00:00
parent d361711600
commit 03adaddb81
3 changed files with 859 additions and 846 deletions

View file

@ -145,7 +145,17 @@ WebGUI::SQL->write("alter table EventsCalendar_event drop primary key");
WebGUI::SQL->write("alter table Navigation rename tempoldnav"); WebGUI::SQL->write("alter table Navigation rename tempoldnav");
WebGUI::SQL->write("create table Navigation (assetId varchar(22) not null primary key, assetsToInclude text, startType varchar(35), startPoint varchar(255), endPoint varchar(35), showSystemPages int not null default 0, showHiddenPages int not null default 0, showUnprivilegedPages int not null default 0, templateId varchar(22) not null)"); WebGUI::SQL->write("create table Navigation (assetId varchar(22) not null primary key, assetsToInclude text, startType varchar(35), startPoint varchar(255), endPoint varchar(35), showSystemPages int not null default 0, showHiddenPages int not null default 0, showUnprivilegedPages int not null default 0, templateId varchar(22) not null)");
my @wobjects = qw(SiteMap Article Poll Survey USS WSClient DataForm FileManager EventsCalendar HttpProxy IndexedSearch MessageBoard Product SQLReport SyndicatedContent WobjectProxy); my @wobjects = qw(SiteMap Article Poll Survey USS WSClient DataForm FileManager EventsCalendar HttpProxy IndexedSearch MessageBoard Product SQLReport SyndicatedContent WobjectProxy);
my @otherWobjects = WebGUI::SQL->buildArray("select distinct(namespace) from wobject where namespace not in (".quoteAndJoin(\@wobjects).")"); my @otherWobjects = ();
my @temp = WebGUI::SQL->buildArray("select distinct(namespace) from wobject where namespace not in (".quoteAndJoin(\@wobjects).")");
foreach my $other (@temp) {
my $test = WebGUI::SQL->unconditionalRead("select * from $other");
if ($test->errorCode < 1) {
push(@otherWobjects,$other);
} else {
print "\t\t WARNING: A wobject instance of $other exists in your database without a namespace table.\n" unless ($quiet);
}
$test->finish;
}
my @allWobjects = (@wobjects,@otherWobjects); my @allWobjects = (@wobjects,@otherWobjects);
foreach my $namespace (@allWobjects) { foreach my $namespace (@allWobjects) {
WebGUI::SQL->write("alter table ".$namespace." add column assetId varchar(22) not null"); WebGUI::SQL->write("alter table ".$namespace." add column assetId varchar(22) not null");
@ -513,7 +523,7 @@ while (my $data = $sth->hashRef) {
my $url = fixUrl($collateralId,$data->{name}); my $url = fixUrl($collateralId,$data->{name});
$macroCache{$data->{name}} = $macroCache{$data->{collateralId}} = $url; $macroCache{$data->{name}} = $macroCache{$data->{collateralId}} = $url;
WebGUI::SQL->write("insert into asset (assetId, parentId, lineage, className, state, title, menuTitle, WebGUI::SQL->write("insert into asset (assetId, parentId, lineage, className, state, title, menuTitle,
url, ownerUserId, groupIdView, groupIdEdit, fileSize, lastUpdated) values (". url, ownerUserId, groupIdView, groupIdEdit, assetSize, lastUpdated) values (".
quote($collateralId).", ".quote($parentId).", ".quote($baseLineage.sprintf("%06d",$rank)).", quote($collateralId).", ".quote($parentId).", ".quote($baseLineage.sprintf("%06d",$rank)).",
'".$class."','published',".quote($data->{name}).", ". '".$class."','published',".quote($data->{name}).", ".
quote($data->{name}).", ".quote($url).", ".quote($data->{userId}).", quote($data->{name}).", ".quote($url).", ".quote($data->{userId}).",
@ -1382,20 +1392,20 @@ sub walkTree {
WebGUI::SQL->write("insert into asset (assetId, parentId, lineage, className, state, title, menuTitle, url, startDate, WebGUI::SQL->write("insert into asset (assetId, parentId, lineage, className, state, title, menuTitle, url, startDate,
endDate, synopsis, newWindow, isHidden, ownerUserId, groupIdView, groupIdEdit, encryptPage, assetSize, endDate, synopsis, newWindow, isHidden, ownerUserId, groupIdView, groupIdEdit, encryptPage, assetSize,
extraHeadTags ) values (".quote($pageId).", extraHeadTags ) values (".quote($pageId).",
".quote($newParentId).", ".quote($pageLineage).", ".quote($className).",'published',".quote($page->{title}).", ".quote($newParentId).", ".quote($pageLineage).", ".quote($className).",'published',".quote($page->{title}||"Untitled").",
".quote($page->{menuTitle}).", ".quote($pageUrl).", ".quote($page->{startDate}).", ".quote($page->{endDate}).", ".quote($page->{menuTitle}||"Untitled").", ".quote($pageUrl).", ".quote($page->{startDate}).", ".quote($page->{endDate}).",
".quote($page->{synopsis}).", ".quote($page->{newWindow}).", ".quote($page->{hideFromNavigation}).", ".quote($page->{ownerId}).", ".quote($page->{synopsis}).", ".quote($page->{newWindow}).", ".quote($page->{hideFromNavigation}).", ".quote($page->{ownerId}||'3').",
".quote($page->{groupIdView}).", ".quote($page->{groupIdEdit}).", ".quote($page->{encryptPage}).", ".quote($page->{groupIdView}||'7').", ".quote($page->{groupIdEdit}.'3').", ".quote($page->{encryptPage}).",
".length($page->{title}.$page->{menuTitle}.$page->{synopsis}.$page->{urlizedTitle}).", ".quote($page->{metaTags}).")"); ".length($page->{title}.$page->{menuTitle}.$page->{synopsis}.$page->{urlizedTitle}).", ".quote($page->{metaTags}).")");
if ($page->{redirectURL} ne "") { if ($page->{redirectURL} ne "") {
WebGUI::SQL->write("insert into redirect (assetId, redirectUrl) values (".quote($pageId).",".quote($page->{redirectURL}).")"); WebGUI::SQL->write("insert into redirect (assetId, redirectUrl) values (".quote($pageId).",".quote($page->{redirectURL}).")");
} else { } else {
WebGUI::SQL->write("insert into wobject (assetId, styleTemplateId, printableStyleTemplateId, WebGUI::SQL->write("insert into wobject (assetId, styleTemplateId, printableStyleTemplateId,
cacheTimeout, cacheTimeoutVisitor, displayTitle, namespace) values ( cacheTimeout, cacheTimeoutVisitor, displayTitle, namespace) values (
".quote($pageId).", ".quote($page->{styleId}).", ".quote($pageId).", ".quote($page->{styleId}||'1').",
".quote($page->{printableStyleId}).", ".quote($page->{cacheTimeout}).",".quote($page->{cacheTimeoutVisitor}).", ".quote($page->{printableStyleId}||'1').", ".quote($page->{cacheTimeout}).",".quote($page->{cacheTimeoutVisitor}).",
0,'Layout')"); 0,'Layout')");
WebGUI::SQL->write("insert into Layout (assetId,templateId) values (".quote($pageId).", ".quote($page->{templateId}).")"); WebGUI::SQL->write("insert into Layout (assetId,templateId) values (".quote($pageId).", ".quote($page->{templateId}||'1').")");
} }
my $rank = 1; my $rank = 1;
print "\t\tFinding wobjects on page ".$page->{pageId}."\n" unless ($quiet); print "\t\tFinding wobjects on page ".$page->{pageId}."\n" unless ($quiet);
@ -1431,34 +1441,33 @@ sub walkTree {
print "\t\t\tMigrating attachments for Article ".$wobject->{wobjectId}."\n" unless ($quiet); print "\t\t\tMigrating attachments for Article ".$wobject->{wobjectId}."\n" unless ($quiet);
if ($namespace->{attachment}) { if ($namespace->{attachment}) {
my $attachmentId = WebGUI::Id::generate(); my $attachmentId = WebGUI::Id::generate();
my $storageId = copyFile($namespace->{attachment},$wobject->{wobjectId});
WebGUI::SQL->write("insert into asset (assetId, parentId, lineage, className, state, title, menuTitle, WebGUI::SQL->write("insert into asset (assetId, parentId, lineage, className, state, title, menuTitle,
url, startDate, endDate, isHidden, ownerUserId, groupIdView, groupIdEdit) values (". url, startDate, endDate, isHidden, ownerUserId, groupIdView, groupIdEdit,assetSize) values (".
quote($attachmentId).", ".quote($wobjectId).", ".quote($wobjectLineage.sprintf("%06d",1)).", quote($attachmentId).", ".quote($wobjectId).", ".quote($wobjectLineage.sprintf("%06d",1)).",
'WebGUI::Asset::File','published',".quote($namespace->{attachment}).", ". 'WebGUI::Asset::File','published',".quote($namespace->{attachment}).", ".
quote($namespace->{attachment}).", ".quote(fixUrl($attachmentId,$wobjectUrl.'/'.$namespace->{attachment})).", quote($namespace->{attachment}).", ".quote(fixUrl($attachmentId,$wobjectUrl.'/'.$namespace->{attachment})).",
".quote($wobject->{startDate}).", ".quote($wobject->{endDate}).", 1, ".quote($ownerId).", ".quote($wobject->{startDate}).", ".quote($wobject->{endDate}).", 1, ".quote($ownerId).",
".quote($groupIdView).", ".quote($groupIdEdit).")"); ".quote($groupIdView).", ".quote($groupIdEdit).","
my $storageId = copyFile($namespace->{attachment},$wobject->{wobjectId}); .quote(getFileSize($storageId,$namespace->{attachment})).")");
WebGUI::SQL->write("insert into FileAsset (assetId, filename, storageId, fileSize) values ( WebGUI::SQL->write("insert into FileAsset (assetId, filename, storageId) values (
".quote($attachmentId).", ".quote($namespace->{attachment}).", ".quote($storageId).", ".quote($attachmentId).", ".quote($namespace->{attachment}).", ".quote($storageId).")");
".quote(getFileSize($storageId,$namespace->{attachment})).")");
} }
if ($namespace->{image}) { if ($namespace->{image}) {
my $rank = 1; my $rank = 1;
$rank ++ if ($namespace->{attachment}); $rank ++ if ($namespace->{attachment});
my $imageId = WebGUI::Id::generate(); my $imageId = WebGUI::Id::generate();
my $storageId = copyFile($namespace->{image},$wobject->{wobjectId});
copyFile('thumb-'.$namespace->{image},$wobject->{wobjectId},$storageId);
WebGUI::SQL->write("insert into asset (assetId, parentId, lineage, className, state, title, menuTitle, WebGUI::SQL->write("insert into asset (assetId, parentId, lineage, className, state, title, menuTitle,
url, startDate, endDate, isHidden, ownerUserId, groupIdView, groupIdEdit) values (". url, startDate, endDate, isHidden, ownerUserId, groupIdView, groupIdEdit,assetSize) values (".
quote($imageId).", ".quote($wobjectId).", ".quote($wobjectLineage.sprintf("%06d",$rank)).", quote($imageId).", ".quote($wobjectId).", ".quote($wobjectLineage.sprintf("%06d",$rank)).",
'WebGUI::Asset::File::Image','published',".quote($namespace->{image}).", ". 'WebGUI::Asset::File::Image','published',".quote($namespace->{image}).", ".
quote($namespace->{image}).", ".quote(fixUrl($imageId,$wobjectUrl.'/'.$namespace->{image})).", quote($namespace->{image}).", ".quote(fixUrl($imageId,$wobjectUrl.'/'.$namespace->{image})).",
".quote($wobject->{startDate}).", ".quote($wobject->{endDate}).", 1, ".quote($ownerId).", ".quote($wobject->{startDate}).", ".quote($wobject->{endDate}).", 1, ".quote($ownerId).",
".quote($groupIdView).", ".quote($groupIdEdit).")"); ".quote($groupIdView).", ".quote($groupIdEdit).",".quote(getFileSize($storageId,$namespace->{image})).")");
my $storageId = copyFile($namespace->{image},$wobject->{wobjectId}); WebGUI::SQL->write("insert into FileAsset (assetId, filename, storageId) values (
copyFile('thumb-'.$namespace->{image},$wobject->{wobjectId},$storageId); ".quote($imageId).", ".quote($namespace->{image}).", ".quote($storageId).")");
WebGUI::SQL->write("insert into FileAsset (assetId, filename, storageId, fileSize) values (
".quote($imageId).", ".quote($namespace->{image}).", ".quote($storageId).",
".quote(getFileSize($storageId,$namespace->{image})).")");
WebGUI::SQL->write("insert into ImageAsset (assetId, thumbnailSize) values (".quote($imageId).", WebGUI::SQL->write("insert into ImageAsset (assetId, thumbnailSize) values (".quote($imageId).",
".quote($session{setting}{thumbnailSize}).")"); ".quote($session{setting}{thumbnailSize}).")");
} }
@ -1508,10 +1517,10 @@ sub walkTree {
} else { } else {
$class = 'WebGUI::Asset::File'; $class = 'WebGUI::Asset::File';
} }
WebGUI::SQL->write("insert into FileAsset (assetId, filename, storageId, fileSize) values ( WebGUI::SQL->write("insert into FileAsset (assetId, filename, storageId) values (
".quote($newId).", ".quote($data->{$field}).", ".quote($storageId).")"); ".quote($newId).", ".quote($data->{$field}).", ".quote($storageId).")");
WebGUI::SQL->write("insert into asset (assetId, parentId, lineage, className, state, title, menuTitle, WebGUI::SQL->write("insert into asset (assetId, parentId, lineage, className, state, title, menuTitle,
url, startDate, endDate, isHidden, ownerUserId, groupIdView, groupIdEdit, synopsis, fileSize url, startDate, endDate, isHidden, ownerUserId, groupIdView, groupIdEdit, synopsis, assetSize
) values (". ) values (".
quote($newId).", ".quote($wobjectId).", ".quote($wobjectLineage.sprintf("%06d",1)).", quote($newId).", ".quote($wobjectId).", ".quote($wobjectLineage.sprintf("%06d",1)).",
'".$class."','published',".quote($data->{fileTitle}).", ". '".$class."','published',".quote($data->{fileTitle}).", ".
@ -2060,12 +2069,16 @@ sub copyFile {
mkdir($node); mkdir($node);
$node .= $session{os}{slash}.$id; $node .= $session{os}{slash}.$id;
mkdir($node); mkdir($node);
print "Moving File".$session{config}{uploadsPath}.$session{os}{slash}.$oldPath.$session{os}{slash}.$filename."\n";
my $a = FileHandle->new($session{config}{uploadsPath}.$session{os}{slash}.$oldPath.$session{os}{slash}.$filename,"r"); my $a = FileHandle->new($session{config}{uploadsPath}.$session{os}{slash}.$oldPath.$session{os}{slash}.$filename,"r");
binmode($a); if (defined $a) {
my $b = FileHandle->new(">".$node.$session{os}{slash}.$filename); binmode($a);
binmode($b); my $b = FileHandle->new(">".$node.$session{os}{slash}.$filename);
copy($a,$b); if (defined $b) {
print "Moving File".$session{config}{uploadsPath}.$session{os}{slash}.$oldPath.$session{os}{slash}.$filename."\n";
binmode($b);
copy($a,$b);
}
}
return $id; return $id;
} }

View file

@ -43,7 +43,7 @@ sub definition {
my $class = shift; my $class = shift;
my $definition = shift; my $definition = shift;
push(@{$definition}, { push(@{$definition}, {
tableName=>'eventscalendar', tableName=>'EventsCalendar',
className=>'WebGUI::Asset::Wobject::EventsCalendar', className=>'WebGUI::Asset::Wobject::EventsCalendar',
properties=>{ properties=>{
templateId =>{ templateId =>{