- Converted all the max((assetData.)revisionDate) calls to use mysql5/(4.1)

nested queries.
 - fix [ 1323184 ] CS Submissions Not Sorting on multiple sites
 - fixed some major oversights in the new profile system.
This commit is contained in:
Matthew Wilson 2005-12-12 10:34:39 +00:00
parent d8cea7a566
commit f5f73c1681
16 changed files with 61 additions and 42 deletions

View file

@ -1,4 +1,8 @@
6.8.2
- Converted all the max((assetData.)revisionDate) calls to use mysql5/(4.1)
nested queries.
- fix [ 1323184 ] CS Submissions Not Sorting on multiple sites
- fixed some major oversights in the new profile system.
- Added macro to return the MIME type to a file, FetchMimeType.
- fix [ 1378493 ] 6.7.8 collab post edits (images)
- Fixed bug where viewProfile did not show pretty printed values

View file

@ -24,10 +24,17 @@ start(); # this line required
fixPosts();
fixDataFormMailForm();
fixTZGoof();
finish(); # this line required
#-------------------------------------------------
sub fixTZGoof {
print "\tFixing default timezone.\n" unless ($quiet);
WebGUI::SQL->write("update userProfileField set dataDefault='\\\'America/Chicago\\\'' where fieldName='timeZone'");
}
#-------------------------------------------------
sub fixPosts {
print "\tFixing posts.\n" unless ($quiet);

View file

@ -409,10 +409,10 @@ sub getAssetAdderLinks {
} else {
$constraint = quoteAndJoin($session{config}{assets});
}
my $sth = WebGUI::SQL->read("select asset.className,asset.assetId,max(assetData.revisionDate) from asset left join assetData on asset.assetId=assetData.assetId where assetData.isPrototype=1 and asset.state='published' and asset.className in ($constraint) group by assetData.assetId");
my $sth = WebGUI::SQL->read("select asset.className,asset.assetId,assetData.revisionDate from asset left join assetData on asset.assetId=assetData.assetId where assetData.isPrototype=1 and asset.state='published' and asset.className in ($constraint) and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId) group by assetData.assetId");
while (my ($class,$id,$date) = $sth->array) {
my $asset = WebGUI::Asset->new($id,$class);
next unless ($asset->get("isPrototype") eq '1' && $asset->canView && $asset->canAdd && $asset->getUiLevel <= $session{user}{uiLevel});
my $asset = WebGUI::Asset->new($id,$class,$date);
next unless ($asset->canView && $asset->canAdd && $asset->getUiLevel <= $session{user}{uiLevel});
my $url = $self->getUrl("func=add;class=".$class.";prototype=".$id);
$url = WebGUI::URL::append($url,$addToUrl) if ($addToUrl);
$links{$asset->getTitle}{url} = $url;

View file

@ -648,17 +648,18 @@ sub view {
$var->{'unlock.url'} = $self->getUnlockUrl;
my $p = WebGUI::Paginator->new($self->getUrl,$self->getParent->get("postsPerPage"));
my $sql = "select asset.assetId, asset.className, max(assetData.revisionDate) as revisionDate from asset
my $sql = "select asset.assetId, asset.className, assetData.revisionDate as revisionDate from asset
left join assetData on assetData.assetId=asset.assetId
left join Post on Post.assetId=assetData.assetId and assetData.revisionDate=Post.revisionDate
where asset.lineage like ".quote($self->get("lineage").'%')
." and asset.state='published'
and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId
and (
assetData.status in ('approved','archived')
or assetData.tagId=".quote($session{scratch}{versionTag});
$sql .= " or assetData.status='pending'" if ($self->getParent->canModerate);
$sql .= " or (assetData.ownerUserId=".quote($session{user}{userId})." and assetData.ownerUserId<>'1')
)
))
group by assetData.assetId
order by ";
if ($layout eq "flat") {

View file

@ -199,7 +199,8 @@ Specify the namespace to build the list for.
sub getList {
my $class = shift;
my $namespace = shift;
my $sth = WebGUI::SQL->read("select asset.assetId, max(assetData.revisionDate) from template left join asset on asset.assetId=template.assetId left join assetData on assetData.revisionDate=template.revisionDate and assetData.assetId=template.assetId where template.namespace=".quote($namespace)." and template.showInForms=1 and asset.state='published' and (assetData.status='approved' or assetData.tagId=".quote($session{scratch}{versionTag}).") group by assetData.assetId order by assetData.title",WebGUI::SQL->getSlave);
my $sql = "select asset.assetId, assetData.revisionDate from template left join asset on asset.assetId=template.assetId left join assetData on assetData.revisionDate=template.revisionDate and assetData.assetId=template.assetId where template.namespace=".quote($namespace)." and template.showInForms=1 and asset.state='published' and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId and (assetData.status='approved' or assetData.tagId=".quote($session{scratch}{versionTag}).")) order by assetData.title";
my $sth = WebGUI::SQL->read($sql,WebGUI::SQL->getSlave);
my %templates;
tie %templates, 'Tie::IxHash';
while (my ($id, $version) = $sth->array) {

View file

@ -41,7 +41,7 @@ sub appendPostListTemplateVars {
my $page = $p->getPageData;
my $i = 0;
foreach my $row (@$page) {
my $post = WebGUI::Asset::Wobject::Collaboration->new($row->{assetId}, $row->{className}, $row->{revisionDate});
my $post = WebGUI::Asset->new($row->{assetId}, $row->{className}, $row->{revisionDate});
$post->{_parent} = $self; # caching parent for efficiency
my $controls = deleteIcon('func=delete',$post->get("url"),"Delete").editIcon('func=edit',$post->get("url"));
if ($self->get("sortBy") eq "lineage") {
@ -952,12 +952,12 @@ sub view {
$constraints .= " or assetData.status='pending'";
}
$constraints .= ")";
my $sql = "select asset.assetId,asset.className,max(assetData.revisionDate) as revisionDate
my $sql = "select asset.assetId,asset.className,assetData.revisionDate as revisionDate
from Thread
left join asset on Thread.assetId=asset.assetId
left join Post on Post.assetId=Thread.assetId and Thread.revisionDate = Post.revisionDate
left join assetData on assetData.assetId=Thread.assetId and Thread.revisionDate = assetData.revisionDate
where asset.parentId=".quote($self->getId)." and asset.state='published' and asset.className='WebGUI::Asset::Post::Thread' and $constraints
where asset.parentId=".quote($self->getId)." and asset.state='published' and asset.className='WebGUI::Asset::Post::Thread' and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId) and $constraints
group by assetData.assetId order by Thread.isSticky desc, ".$sortBy." ".$sortOrder;
my $p = WebGUI::Paginator->new($self->getUrl,$self->get("threadsPerPage"));
$self->appendPostListTemplateVars(\%var, $sql, $p);
@ -965,14 +965,6 @@ sub view {
return $self->processTemplate(\%var,$self->get("collaborationTemplateId"));
}
#-------------------------------------------------------------------
#sub www_edit {
# my $self = shift;
# return WebGUI::Privilege::insufficient() unless $self->canEdit;
# $self->getAdminConsole->setHelp("collaboration add/edit", "Asset_Collaboration");
# return $self->getAdminConsole->render($self->getEditForm->print,"Edit Collaboration System");
#}
#-------------------------------------------------------------------
=head2 www_search ( )

View file

@ -114,7 +114,7 @@ sub getAssetsInClipboard {
my $sth = WebGUI::SQL->read("
select
asset.assetId,
max(assetData.revisionDate),
assetData.revisionDate,
asset.className
from
asset
@ -122,6 +122,7 @@ sub getAssetsInClipboard {
assetData on asset.assetId=assetData.assetId
where
asset.state='clipboard'
and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId)
$limit
group by
assetData.assetId

View file

@ -338,7 +338,8 @@ sub getLineage {
$where .= ' and ('.$rules->{whereClause}.')';
}
# based upon all available criteria, let's get some assets
my $columns = "asset.assetId, asset.className, asset.parentId, max(assetData.revisionDate)";
my $columns = "asset.assetId, asset.className, asset.parentId, assetData.revisionDate";
$where .= " and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId and (assetData.status='approved' or assetData.tagId=".quote($session{scratch}{versionTag}).")) ";
my $sortOrder = ($rules->{invertTree}) ? "asset.lineage desc" : "asset.lineage asc";
if (exists $rules->{orderByClause}) {
$sortOrder = $rules->{orderByClause};

View file

@ -47,27 +47,22 @@ Returns an array of hashes containing title, assetId, and className for all asse
sub getPackageList {
my $self = shift;
my @assets;
my $sth = WebGUI::SQL->read("
my $sql = "
select
asset.assetId,
max(assetData.revisionDate),
assetData.revisionDate,
asset.className
from
asset
left join
assetData on asset.assetId=assetData.assetId
where
assetData.isPackage=1 and
(
assetData.status='approved' or
assetData.tagId=".quote($session{scratch}{versionTag})."
) and
asset.state='published'
group by
assetData.assetId
order by
assetData.title desc
");
assetData.isPackage=1
and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId and
(assetData.status='approved'";
$sql .= " or assetData.tagId=".quote($session{scratch}{versionTag}) if ($session{scratch}{versionTag});
$sql .= ")) and asset.state='published' group by assetData.assetId order by assetData.title desc";
my $sth = WebGUI::SQL->read($sql);
while (my ($id, $date, $class) = $sth->array) {
my $asset = WebGUI::Asset->new($id,$class);
push(@assets, $asset) if ($asset->get("isPackage"));

View file

@ -64,7 +64,7 @@ sub getAssetsInTrash {
my $sth = WebGUI::SQL->read("
select
asset.assetId,
max(assetData.revisionDate),
assetData.revisionDate,
asset.className
from
asset
@ -72,6 +72,7 @@ sub getAssetsInTrash {
assetData on asset.assetId=assetData.assetId
where
asset.state='trash'
and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId)
$limit
group by
assetData.assetId

View file

@ -18,6 +18,7 @@ use WebGUI::Auth;
use WebGUI::DateTime;
use WebGUI::FormProcessor;
use WebGUI::HTMLForm;
use WebGUI::HTTP;
use WebGUI::Macro;
use WebGUI::Mail;
use WebGUI::Session;
@ -472,6 +473,7 @@ sub getPasswordRecoveryTemplateId {
sub login {
my $self = shift;
if(!$self->authenticate($session{form}{username},$session{form}{identifier})){
WebGUI::HTTP::setStatus("401","Incorrect Credentials");
WebGUI::ErrorHandler::security("login to account ".$session{form}{username}." with invalid information.");
return $self->displayLogin("<h1>".WebGUI::International::get(70)."</h1>".$self->error);
}

View file

@ -179,6 +179,7 @@ sub fatal {
Apache2::RequestUtil->request->content_type('text/html') if ($WebGUI::Session::session{req});
$logger->fatal($message);
$logger->debug("Stack trace for FATAL ".$message."\n".getStackTrace());
print WebGUI::HTTP::getHeader if ($WebGUI::Session::session{req});
unless (canShowDebug()) {
#NOTE: You can't internationalize this because with some types of errors that would cause an infinite loop.
print "<h1>Problem With Request</h1>
@ -224,7 +225,7 @@ Returns a text message containing all of the session variables.
sub getSessionVars {
my $data;
while (my ($section, $hash) = each %WebGUI::Session::session) {
if ($section eq "debug") {
if ($section eq "debug" || $section eq 'replacements') {
next;
} elsif (ref $hash eq 'HASH') {
while (my ($key, $value) = each %$hash) {

View file

@ -76,7 +76,13 @@ sub validateProfileData {
my $error = "";
my $warning = "";
foreach my $field (@{WebGUI::ProfileField->getEditableFields}) {
$data{$field->getId} = $field->formProcess;
my $fieldValue = $field->formProcess;
use Data::Dumper;print $field->getLabel.' : '.Dumper($fieldValue);
if (ref $fieldValue eq "ARRAY") {
$data{$field->getId} = $$fieldValue[0];
} else {
$data{$field->getId} = $fieldValue;
}
if ($field->isRequired && !$data{$field->getId}) {
$error .= '<li>'.$field->getLabel.' '.WebGUI::International::get(451).'</li>';
} elsif ($field->getId eq "email" && isDuplicateEmail($data{$field->getId})) {

View file

@ -163,7 +163,17 @@ Returns the value retrieved from a form post.
sub formProcess {
my $self = shift;
return WebGUI::HTML::filter(WebGUI::FormProcessor::process($self->getId,$self->get("fieldType"),WebGUI::Operation::Shared::secureEval($self->get("possibleValues"))), "javascript");
my $result = WebGUI::FormProcessor::process($self->getId,$self->get("fieldType"),WebGUI::Operation::Shared::secureEval($self->get("dataDefault")));
if (ref $result eq "ARRAY") {
my @results = @$result;
for (my $count=0;$count<scalar(@results);$count++) {
$results[$count] = WebGUI::HTML::filter($results[$count], "javascript");
}
$result = \@results;
} else {
$result = WebGUI::HTML::filter($result, "javascript");
}
return $result;
}
#-------------------------------------------------------------------

View file

@ -469,10 +469,8 @@ sub prepare {
my $class = shift;
my $sql = shift;
my $dbh = shift || _getDefaultDb();
if (WebGUI::ErrorHandler::canShowDebug()) {
push(@{$WebGUI::Session::session{SQLquery}},$sql);
}
my $sth = $dbh->prepare($sql) or WebGUI::ErrorHandler::fatal("Couldn't prepare statement: ".$sql." : ". DBI->errstr);
push(@{$WebGUI::Session::session{SQLquery}},$sql);
my $sth = $dbh->prepare($sql) or WebGUI::ErrorHandler::fatal("Couldn't prepare statement: ".$sql." : ". DBI->errstr);
bless ({_sth => $sth, _sql => $sql}, $class);
}
@ -638,7 +636,6 @@ The database handler. Defaults to the WebGUI database handler.
sub quote {
my $value = shift;
return "''" unless defined $value;
my $dbh = shift || _getDefaultDb();
return $dbh->quote($value);
}

View file

@ -269,7 +269,7 @@ sub new {
if ($profile{$key} eq "" && $default{$key}) {
$value = eval($default{$key});
if (ref $value eq "ARRAY") {
$profile{$key} = $$value[0];
$profile{$key} = $$value[0];
} else {
$profile{$key} = $value;
}