merged with SVN to get friends stuff

This commit is contained in:
Doug Bell 2007-10-26 00:50:05 +00:00
commit 7e12c6c2f0
73 changed files with 3262 additions and 424 deletions

View file

@ -19,7 +19,7 @@ use base 'WebGUI::Asset::File';
use WebGUI::Storage::Image;
use WebGUI::HTMLForm;
use WebGUI::Utility;
use WebGUI::Form::Image;
=head1 NAME

View file

@ -91,7 +91,7 @@ sub definition {
#----------------------------------------------------------------------------
=head2 appendTemplateVarsForCommentForm ( vars )
=head2 appendTemplateVarsForCommentForm ( var )
Add the template variables necessary for the comment form to the given hash
reference. Returns the hash reference for convenience.
@ -100,11 +100,11 @@ reference. Returns the hash reference for convenience.
sub appendTemplateVarsForCommentForm {
my $self = shift;
my $vars = shift;
my $var = shift;
# ...
return $vars;
return $var;
}
#----------------------------------------------------------------------------
@ -151,9 +151,27 @@ sub canEdit {
Returns true if the user can view this asset. C<userId> is a WebGUI user ID.
If no user is passed, checks the current user.
Users can view this photo if they can view the parent asset. If this is a
C<friendsOnly> photo, then they must also be in the owners friends list.
=cut
# Inherited from superclass
sub canView {
my $self = shift;
my $userId = shift || $self->session->user->userId;
my $album = $self->getParent;
return 0 unless $album->canView($userId);
if ($self->isFriendsOnly) {
# ...
}
# Passed all checks
return 1;
}
#----------------------------------------------------------------------------
@ -321,6 +339,19 @@ sub i18n {
#----------------------------------------------------------------------------
=head2 isFriendsOnly ( )
Returns true if this Photo is friends only. Returns false otherwise.
=cut
sub isFriendsOnly {
my $self = shift;
return $self->get("friendsOnly");
}
#----------------------------------------------------------------------------
=head2 makeResolutions ( [resolutions] )
Create the specified resolutions for this Photo. If resolutions is not

View file

@ -72,16 +72,12 @@ sub addRevision {
my $now = time();
if ($threadId eq "") { # new post
if ($newSelf->getParent->isa("WebGUI::Asset::Wobject::Collaboration")) {
$newSelf->update({threadId=>$newSelf->getId, dateSubmitted=>$now});
$newSelf->update({threadId=>$newSelf->getId});
} else {
$newSelf->update({threadId=>$newSelf->getParent->get("threadId"), dateSubmitted=>$now});
$newSelf->update({threadId=>$newSelf->getParent->get("threadId")});
}
delete $newSelf->{_thread};
}
$newSelf->update({
dateUpdated=>$now,
});
$newSelf->getThread->unmarkRead;
return $newSelf;
@ -99,7 +95,7 @@ sub canEdit {
my $self = shift;
return (($self->session->form->process("func") eq "add" || ($self->session->form->process("assetId") eq "new" && $self->session->form->process("func") eq "editSave" && $self->session->form->process("class","className") eq "WebGUI::Asset::Post")) && $self->getThread->getParent->canPost) || # account for new posts
($self->isPoster && $self->getThread->getParent->get("editTimeout") > ($self->session->datetime->time() - $self->get("dateUpdated"))) ||
($self->isPoster && $self->getThread->getParent->get("editTimeout") > ($self->session->datetime->time() - $self->get("revisionDate"))) ||
$self->getThread->getParent->canEdit;
}
@ -150,7 +146,7 @@ sub commit {
my $u = WebGUI::User->new($self->session, $self->get("ownerUserId"));
$u->karma($self->getThread->getParent->get("karmaPerPost"), $self->getId, "Collaboration post");
}
$self->getThread->incrementReplies($self->get("dateUpdated"),$self->getId) if ($self->isReply);
$self->getThread->incrementReplies($self->get("revisionDate"),$self->getId) if ($self->isReply);
}
}
@ -176,15 +172,6 @@ sub definition {
fieldType=>"hidden",
defaultValue=>undef
},
dateSubmitted => {
noFormPost=>1,
fieldType=>"hidden",
defaultValue=>$session->datetime->time()
},
dateUpdated => {
fieldType=>"hidden",
defaultValue=>$session->datetime->time()
},
username => {
fieldType=>"hidden",
defaultValue=>$session->form->process("visitorUsername") || $session->user->profileField("alias") || $session->user->username
@ -311,6 +298,12 @@ sub formatContent {
return $msg;
}
#-------------------------------------------------------------------
# Too slow to try to find out children, just always assume new data
sub getContentLastModified {
return time();
}
#-------------------------------------------------------------------
sub getAutoCommitWorkflowId {
my $self = shift;
@ -511,8 +504,8 @@ sub getTemplateVars {
$var{"user.isPoster"} = $self->isPoster;
$var{"avatar.url"} = $self->getAvatarUrl;
$var{"userProfile.url"} = $self->getUrl("op=viewProfile;uid=".$self->get("ownerUserId"));
$var{"dateSubmitted.human"} =$self->session->datetime->epochToHuman($self->get("dateSubmitted"));
$var{"dateUpdated.human"} =$self->session->datetime->epochToHuman($self->get("dateUpdated"));
$var{"dateSubmitted.human"} =$self->session->datetime->epochToHuman($self->get("creationDate"));
$var{"dateUpdated.human"} =$self->session->datetime->epochToHuman($self->get("revisionDate"));
$var{'title.short'} = $self->chopTitle;
$var{content} = $self->formatContent if ($self->getThread);
$var{'user.canEdit'} = $self->canEdit if ($self->getThread);
@ -689,7 +682,7 @@ Returns a boolean indicating whether this post is new (not an edit).
sub isNew {
my $self = shift;
return $self->get("dateSubmitted") eq $self->get("dateUpdated");
return $self->get("creationDate") == $self->get("revisionDate");
}
#-------------------------------------------------------------------
@ -1021,19 +1014,23 @@ Moves post to the trash and updates reply counter on thread.
=cut
sub trash {
my $self = shift;
$self->SUPER::trash;
$self->getThread->sumReplies if ($self->isReply);
if ($self->getThread->get("lastPostId") eq $self->getId) {
my $threadLineage = $self->getThread->get("lineage");
my ($id, $date) = $self->session->db->quickArray("select Post.assetId, Post.dateSubmitted from Post, asset where asset.lineage like ".$self->session->db->quote($threadLineage.'%')." and Post.assetId<>".$self->session->db->quote($self->getId)." and asset.assetId=Post.assetId and asset.state='published' order by Post.dateSubmitted desc");
$self->getThread->update({lastPostId=>$id, lastPostDate=>$date});
}
if ($self->getThread->getParent->get("lastPostId") eq $self->getId) {
my $forumLineage = $self->getThread->getParent->get("lineage");
my ($id, $date) = $self->session->db->quickArray("select Post.assetId, Post.dateSubmitted from Post, asset where asset.lineage like ".$self->session->db->quote($forumLineage.'%')." and Post.assetId<>".$self->session->db->quote($self->getId)." and asset.assetId=Post.assetId and asset.state='published' order by Post.dateSubmitted desc");
$self->getThread->getParent->update({lastPostId=>$id, lastPostDate=>$date});
}
my $self = shift;
$self->SUPER::trash;
$self->getThread->sumReplies if ($self->isReply);
if ($self->getThread->get("lastPostId") eq $self->getId) {
my $threadLineage = $self->getThread->get("lineage");
my ($id, $date) = $self->session->db->quickArray("select assetId, creationDate from asset where
lineage like ? and assetId<>? and asset.state='published' and className like 'WebGUI::Asset::Post%'
order by creationDate desc",[$threadLineage.'%', $self->getId]);
$self->getThread->update({lastPostId=>$id, lastPostDate=>$date});
}
if ($self->getThread->getParent->get("lastPostId") eq $self->getId) {
my $forumLineage = $self->getThread->getParent->get("lineage");
my ($id, $date) = $self->session->db->quickArray("select assetId, creationDate from asset where
lineage like ? and assetId<>? and asset.state='published' and className like 'WebGUI::Asset::Post%'
order by creationDate desc",[$forumLineage.'%', $self->getId]);
$self->getThread->getParent->update({lastPostId=>$id, lastPostDate=>$date});
}
}
#-------------------------------------------------------------------

View file

@ -63,7 +63,7 @@ sub commit {
my $self = shift;
$self->SUPER::commit;
if ($self->isNew) {
$self->getParent->incrementThreads($self->get("dateUpdated"),$self->getId);
$self->getParent->incrementThreads($self->get("revisionDate"),$self->getId);
}
}
@ -623,6 +623,7 @@ sub setLastPost {
$self->getParent->setLastPost($id,$date);
}
#-------------------------------------------------------------------
sub normalizeLastPost {
my $self = shift;
# Hmm. Is this right?
@ -704,14 +705,21 @@ Moves thread to the trash and updates reply counter on thread.
=cut
sub trash {
my $self = shift;
$self->SUPER::trash;
$self->getParent->sumReplies;
if ($self->getParent->get("lastPostId") eq $self->getId) {
my $parentLineage = $self->getThread->get("lineage");
my ($id, $date) = $self->session->db->quickArray("select Post.assetId, Post.dateSubmitted from Post, asset where asset.lineage like ".$self->session->db->quote($parentLineage.'%')." and Post.assetId<>".$self->session->db->quote($self->getId)." and Post.assetId=asset.assetId and asset.state='published' order by Post.dateSubmitted desc");
$self->getParent->setLastPost('','') ? $self->getParent->setLastPost($id,$date) : $id;
my $self = shift;
$self->SUPER::trash;
$self->getParent->sumReplies;
if ($self->getParent->get("lastPostId") eq $self->getId) {
my $parentLineage = $self->getThread->get("lineage");
my ($id, $date) = $self->session->db->quickArray("select assetId, creationDate from asset where
lineage like ? and assetId<>? and asset.state='published' and className like 'WebGUI::Asset::Post%'
order by creationDate desc",[$parentLineage.'%', $self->getId]);
if (defined $id) {
$self->getParent->setLastPost($id,$date);
}
else {
$self->getParent->setLastPost('','');
}
}
}
@ -884,10 +892,9 @@ sub view {
my $p = WebGUI::Paginator->new($self->session,$self->getUrl,$self->getParent->get("postsPerPage"));
my $sql = "select asset.assetId, asset.className, assetData.revisionDate as revisionDate, assetData.url as url 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 ".$self->session->db->quote($self->get("lineage").'%')
." and asset.state='published'
and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId
and assetData.revisionDate=(SELECT max(assetData.revisionDate) from assetData where assetData.assetId=asset.assetId
and (
assetData.status in ('approved','archived')
or assetData.tagId=".$self->session->db->quote($self->session->scratch->get("versionTag"));
@ -898,7 +905,7 @@ sub view {
order by ";
if ($layout eq "flat") {
$sql .= "Post.dateSubmitted";
$sql .= "asset.creationDate";
} else {
$sql .= "asset.lineage";
}

View file

@ -119,7 +119,7 @@ sub www_view {
$subvar = {};
@$subvar{'title', 'link', 'description'} = $self->_tlsOfAsset($item);
$subvar->{guid} = $subvar->{link};
$subvar->{pubDate} = _escapeXml($self->session->datetime->epochToMail($item->get('dateUpdated')));
$subvar->{pubDate} = _escapeXml($self->session->datetime->epochToMail($item->get('revisionDate')));
} elsif (ref $item eq 'HASH') {
foreach my $key (keys %$item) {
$subvar->{$key} = _escapeXml($item->{$key});

View file

@ -191,7 +191,7 @@ sub getEditForm {
#-------------------------------------------------------------------
=head2 getList ( session, namespace )
=head2 getList ( session, namespace [,clause] )
Returns a hash reference containing template ids and template names of all the templates in the specified namespace.
@ -203,7 +203,12 @@ A reference to the current session.
=head3 namespace
Specify the namespace to build the list for.
Specify the namespace to build the list for. If no namespace is specified,
then an empty hash reference will be returned.
=head3 clause
An extra clause that can be used to further limit the list, such as "assetData.status='approved'
=cut
@ -211,8 +216,15 @@ sub getList {
my $class = shift;
my $session = shift;
my $namespace = shift;
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=".$session->db->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=".$session->db->quote($session->scratch->get("versionTag")).")) order by assetData.title";
my $sth = $session->dbSlave->read($sql);
my $clause = shift;
if ($clause) {
$clause = ' and ' . $clause;
}
else {
$clause = '';
}
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=? 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=?)) $clause order by assetData.title";
my $sth = $session->dbSlave->read($sql, [$namespace, $session->scratch->get("versionTag")]);
my %templates;
tie %templates, 'Tie::IxHash';
while (my ($id, $version) = $sth->array) {

View file

@ -44,7 +44,6 @@ sub addRevision {
my $now = time();
$newSelf->update({
isHidden => 1,
dateUpdated=>$now,
});
return $newSelf;
}
@ -227,17 +226,21 @@ sub processPropertiesFromFormPost {
my $self = shift;
$self->SUPER::processPropertiesFromFormPost(@_);
my $actionTaken = ($self->session->form->process("assetId") eq "new") ? "Created" : "Edited";
$self->update({ groupIdView => $self->getWiki->get('groupIdView'),
groupIdEdit => $self->getWiki->get('groupToAdminister'),
my $wiki = $self->getWiki;
$self->update({ groupIdView => $wiki->get('groupIdView'),
groupIdEdit => $wiki->get('groupToAdminister'),
actionTakenBy => $self->session->user->userId,
actionTaken => $actionTaken,
});
if ($self->getWiki->canAdminister) {
if ($wiki->canAdminister) {
$self->update({isProtected => $self->session->form("isProtected")});
}
my $options = {
maxImageSize => $wiki->get('maxImageSize'),
thumbnailSize => $wiki->get('thumbnailSize'),
};
# deal with attachments from the attachments form control
my @attachments = $self->session->form->param("attachments");
my @tags = ();
@ -252,6 +255,7 @@ sub processPropertiesFromFormPost {
groupIdView => $self->get("groupIdView"),
});
}
$asset->applyConstraints($options);
push(@tags, $asset->get("tagId"));
$asset->setVersionTag($self->get("tagId"));
}

View file

@ -975,7 +975,7 @@ sub view {
$var->{"urlSearch"} = $self->getSearchUrl;
$var->{"urlPrint"} = $self->getUrl("type=".$params->{type}.";start=".$params->{start}.";print=1");
$var->{"urlIcal"} = $self->getUrl(
sprintf "func=ical;type=%s;start=%d",
sprintf "func=ical;type=%s;start=%s",
$params->{type},
$params->{start},
);
@ -1510,7 +1510,7 @@ sub www_ical {
#}
#else
#{
$dt_start = WebGUI::DateTime->new($self->session, time-60*60*24*30)->set_time_zone($session->user->profileField("timeZone"));
$dt_start = WebGUI::DateTime->new($self->session, time)->set_time_zone($session->user->profileField("timeZone"));
#}
}
else {
@ -1667,7 +1667,7 @@ sub www_search {
keywords => $keywords,
classes => ['WebGUI::Asset::Event'],
lineage => [$self->get("lineage")],
join => "join Event on assetIndex.assetId=Event.assetId",
join => "join Event on assetIndex.assetId=Event.assetId and assetIndex.revisionDate=Event.revisionDate",
columns => ['Event.startDate','Event.startTime'],
);

View file

@ -93,15 +93,17 @@ sub appendPostListTemplateVars {
my $p = shift;
my $page = $p->getPageData;
my $i = 0;
my ($icon, $datetime) = $self->session->quick(qw(icon datetime));
foreach my $row (@$page) {
my $post = WebGUI::Asset->new($self->session,$row->{assetId}, $row->{className}, $row->{revisionDate});
$post->{_parent} = $self; # caching parent for efficiency
my $controls = $self->session->icon->delete('func=delete',$post->get("url"),"Delete").$self->session->icon->edit('func=edit',$post->get("url"));
my $controls = $icon->delete('func=delete',$post->get("url"),"Delete") . $icon->edit('func=edit',$post->get("url"));
if ($self->get("sortBy") eq "lineage") {
if ($self->get("sortOrder") eq "desc") {
$controls .= $self->session->icon->moveUp('func=demote',$post->get("url")).$self->session->icon->moveDown('func=promote',$post->get("url"));
} else {
$controls .= $self->session->icon->moveUp('func=promote',$post->get("url")).$self->session->icon->moveDown('func=demote',$post->get("url"));
$controls .= $icon->moveUp('func=demote',$post->get("url")).$icon->moveDown('func=promote',$post->get("url"));
}
else {
$controls .= $icon->moveUp('func=promote',$post->get("url")).$icon->moveDown('func=demote',$post->get("url"));
}
}
my @rating_loop;
@ -114,13 +116,13 @@ sub appendPostListTemplateVars {
if ($self->get("displayLastReply")) {
my $lastPost = $post->getLastPost();
%lastReply = (
"lastReply.url"=>$lastPost->getUrl.'#'.$lastPost->getId,
"lastReply.title"=>$lastPost->get("title"),
"lastReply.user.isVisitor"=>$lastPost->get("ownerUserId") eq "1",
"lastReply.username"=>$lastPost->get("username"),
"lastReply.userProfile.url"=>$lastPost->WebGUI::Asset::Post::getPosterProfileUrl(),
"lastReply.dateSubmitted.human"=>$self->session->datetime->epochToHuman($lastPost->get("dateSubmitted"),"%z"),
"lastReply.timeSubmitted.human"=>$self->session->datetime->epochToHuman($lastPost->get("dateSubmitted"),"%Z")
"lastReply.url" => $lastPost->getUrl.'#'.$lastPost->getId,
"lastReply.title" => $lastPost->get("title"),
"lastReply.user.isVisitor" => $lastPost->get("ownerUserId") eq "1",
"lastReply.username" => $lastPost->get("username"),
"lastReply.userProfile.url" => $lastPost->getPosterProfileUrl(),
"lastReply.dateSubmitted.human" => $datetime->epochToHuman($lastPost->get("creationDate"),"%z"),
"lastReply.timeSubmitted.human" => $datetime->epochToHuman($lastPost->get("creationDate"),"%Z"),
);
}
$hasRead = $post->isMarkedRead;
@ -133,32 +135,32 @@ sub appendPostListTemplateVars {
}
my %postVars = (
%{$post->get},
"id"=>$post->getId,
"url"=>$url,
rating_loop=>\@rating_loop,
"content"=>$post->formatContent,
"status"=>$post->getStatus,
"thumbnail"=>$post->getThumbnailUrl,
"image.url"=>$post->getImageUrl,
"dateSubmitted.human"=>$self->session->datetime->epochToHuman($post->get("dateSubmitted"),"%z"),
"dateUpdated.human"=>$self->session->datetime->epochToHuman($post->get("dateUpdated"),"%z"),
"timeSubmitted.human"=>$self->session->datetime->epochToHuman($post->get("dateSubmitted"),"%Z"),
"timeUpdated.human"=>$self->session->datetime->epochToHuman($post->get("dateUpdated"),"%Z"),
"userProfile.url"=>$post->getPosterProfileUrl,
"user.isVisitor"=>$post->get("ownerUserId") eq "1",
"edit.url"=>$post->getEditUrl,
'controls'=>$controls,
"isSecond"=>(($i+1)%2==0),
"isThird"=>(($i+1)%3==0),
"isFourth"=>(($i+1)%4==0),
"isFifth"=>(($i+1)%5==0),
"user.hasRead" => $hasRead,
"user.isPoster"=>$post->isPoster,
"avatar.url"=>$post->getAvatarUrl,
"id" => $post->getId,
"url" => $url,
rating_loop => \@rating_loop,
"content" => $post->formatContent,
"status" => $post->getStatus,
"thumbnail" => $post->getThumbnailUrl,
"image.url" => $post->getImageUrl,
"dateSubmitted.human" => $datetime->epochToHuman($post->get("creationDate"),"%z"),
"dateUpdated.human" => $datetime->epochToHuman($post->get("revisionDate"),"%z"),
"timeSubmitted.human" => $datetime->epochToHuman($post->get("creationDate"),"%Z"),
"timeUpdated.human" => $datetime->epochToHuman($post->get("revisionDate"),"%Z"),
"userProfile.url" => $post->getPosterProfileUrl,
"user.isVisitor" => $post->get("ownerUserId") eq "1",
"edit.url" => $post->getEditUrl,
'controls' => $controls,
"isSecond" => (($i+1)%2==0),
"isThird" => (($i+1)%3==0),
"isFourth" => (($i+1)%4==0),
"isFifth" => (($i+1)%5==0),
"user.hasRead" => $hasRead,
"user.isPoster" => $post->isPoster,
"avatar.url" => $post->getAvatarUrl,
%lastReply
);
$post->getTemplateMetadataVars(\%postVars);
if ($row->{className} eq 'WebGUI::Asset::Post::Thread') {
if ($row->{className} =~ m/^WebGUI::Asset::Post::Thread/) {
$postVars{'rating'} = $post->get('threadRating');
}
push(@{$var->{post_loop}}, \%postVars );
@ -363,8 +365,8 @@ sub definition {
my %sortByOptions;
tie %sortByOptions, 'Tie::IxHash';
%sortByOptions = (lineage=>$i18n->get('sequence'),
dateUpdated=>$i18n->get('date updated'),
dateSubmitted=>$i18n->get('date submitted'),
"assetData.revisionDate"=>$i18n->get('date updated'),
creationDate=>$i18n->get('date submitted'),
title=>$i18n->get('title'),
userDefined1=>$i18n->get('user defined 1'),
userDefined2=>$i18n->get('user defined 2'),
@ -611,7 +613,7 @@ sub definition {
},
sortBy =>{
fieldType=>"selectBox",
defaultValue=>'dateUpdated',
defaultValue=>'assetData.revisionDate',
tab=>'display',
options=>\%sortByOptions,
label=>$i18n->get('sort by'),
@ -753,6 +755,12 @@ sub duplicate {
return $newAsset;
}
#-------------------------------------------------------------------
# Too slow to try to find out children, just always assume new data
sub getContentLastModified {
return time();
}
#-------------------------------------------------------------------
sub getEditTabs {
my $self = shift;
@ -781,7 +789,8 @@ sub getRssItems {
# XXX copied and reformatted this query from www_viewRSS, but why is it constructed like this?
# And it's duplicated inside view, too! Eeeagh! And it uses the versionTag scratch var...
my ($sortBy, $sortOrder) = ($self->getValue('sortBy'), $self->getValue('sortOrder'));
my @postIds = $self->session->db->buildArray(<<"SQL", [$self->getId, $self->session->scratch->get('versionTag')]);
my @postIds = $self->session->db->buildArray(<<"SQL", [$self->getId, $self->session->scratch->get('versionTag')]);
SELECT asset.assetId
FROM Thread
LEFT JOIN asset ON Thread.assetId = asset.assetId
@ -823,7 +832,7 @@ SQL
'link' => $postUrl,
guid => $postUrl,
description => $post->get('synopsis'),
pubDate => $datetime->epochToMail($post->get('dateUpdated')),
pubDate => $datetime->epochToMail($post->get('revisionDate')),
attachmentLoop => $attachmentLoop,
userDefined1 => $post->get("userDefined1"),
userDefined2 => $post->get("userDefined2"),
@ -925,7 +934,7 @@ sub getThreadsPaginator {
my $scratchSortBy = $self->getId."_sortBy";
my $scratchSortOrder = $self->getId."_sortDir";
my $sortBy = $self->session->form->process("sortBy") || $self->session->scratch->get($scratchSortBy) || $self->get("sortBy");
my $sortOrder = $self->session->scratch->get($scratchSortOrder) || $self->get("sortOrder");
my $sortOrder = $self->session->scratch->get($scratchSortOrder) || $self->get("sortOrder");
if ($sortBy ne $self->session->scratch->get($scratchSortBy) && $self->session->form->process("func") ne "editSave") {
$self->session->scratch->set($scratchSortBy,$self->session->form->process("sortBy"));
} elsif ($self->session->form->process("sortBy") && $self->session->form->process("func") ne "editSave") {
@ -936,13 +945,13 @@ sub getThreadsPaginator {
}
$self->session->scratch->set($scratchSortOrder, $sortOrder);
}
$sortBy ||= "dateUpdated";
$sortBy ||= "assetData.revisionDate";
$sortOrder ||= "desc";
# Sort by the thread rating instead of the post rating. other places don't care about threads.
if ($sortBy eq 'rating') {
$sortBy = 'threadRating';
}
$sortBy = $self->session->db->dbh->quote_identifier($sortBy);
my $sql = "
select
asset.assetId,
@ -1007,7 +1016,7 @@ sub getViewTemplateVars {
$var{'sortby.username.url'} = $self->getSortByUrl("username");
$var{'karmaIsEnabled'} = $self->session->setting->get("useKarma");
$var{'sortby.karmaRank.url'} = $self->getSortByUrl("karmaRank");
$var{'sortby.date.url'} = $self->getSortByUrl("dateSubmitted");
$var{'sortby.date.url'} = $self->getSortByUrl("creationDate");
$var{'sortby.lastreply.url'} = $self->getSortByUrl("lastPostDate");
$var{'sortby.views.url'} = $self->getSortByUrl("views");
$var{'sortby.replies.url'} = $self->getSortByUrl("replies");

View file

@ -95,15 +95,29 @@ sub definition {
return $class->SUPER::definition($session, $definition);
}
#-------------------------------------------------------------------
sub discernUserId {
my $self = shift;
return ($self->canManage && $self->session->var->isAdminOn) ? '1' : $self->session->user->userId;
}
#-------------------------------------------------------------------
sub getContentPositions {
my $self = shift;
my $dummy = $self->initialize unless $self->get("isInitialized");
my $u = WebGUI::User->new($self->session, $self->discernUserId);
return $u->profileField($self->getId.'contentPositions')
return $u->profileField($self->getContentPositionsId)
|| $self->getContentPositionsDefault;
}
#-------------------------------------------------------------------
sub getContentPositionsId {
my $self = shift;
my $id = "contentPositions".$self->getId;
$id =~ s/-/_/g;
return $id;
}
#-------------------------------------------------------------------
=head2 getContentPositionsDefault ( )
@ -117,13 +131,7 @@ sub getContentPositionsDefault {
my $dummy = $self->initialize unless $self->get("isInitialized");
# The default positions are saved under the "Visitor" user
my $u = WebGUI::User->new($self->session, 1);
return $u->profileField($self->getId.'contentPositions');
}
#-------------------------------------------------------------------
sub discernUserId {
my $self = shift;
return ($self->canManage && $self->session->var->isAdminOn) ? '1' : $self->session->user->userId;
return $u->profileField($self->getContentPositionsId);
}
#-------------------------------------------------------------------
@ -154,13 +162,13 @@ sub getEditForm {
#-------------------------------------------------------------------
sub initialize {
my $self = shift;
my $userPrefField = WebGUI::ProfileField->create($self->session,$self->getId.'contentPositions',{
my $userPrefField = WebGUI::ProfileField->create($self->session,$self->getContentPositionsId,{
label=>'\'Dashboard User Preference - Content Positions\'',
visible=>0,
protected=>1,
editable=>0,
required=>0,
fieldType=>'text'
fieldType=>'textarea'
});
$self->update({isInitialized=>1});
}
@ -201,6 +209,17 @@ sub processPropertiesFromFormPost {
}
}
#-------------------------------------------------------------------
sub purge {
my $self = shift;
my $userPrefField = WebGUI::ProfileField->new($self->session,$self->getContentPositionsId);
if (defined $userPrefField) {
$userPrefField->delete;
}
$self->SUPER::purge(@_);
}
#-------------------------------------------------------------------
sub view {
my $self = shift;
@ -309,7 +328,7 @@ sub www_setContentPositions {
return 'empty' unless $self->get("isInitialized");
my $dummy = $self->initialize unless $self->get("isInitialized");
my $u = WebGUI::User->new($self->session, $self->discernUserId);
my $success = $u->profileField($self->getId.'contentPositions',$self->session->form->process("map")) eq $self->session->form->process("map");
my $success = $u->profileField($self->getContentPositionsId,$self->session->form->process("map")) eq $self->session->form->process("map");
return "Map set: ".$self->session->form->process("map") if $success;
return "Map failed to set.";
}

View file

@ -503,6 +503,8 @@ sub getRecordTemplateVars {
$where .= " and b.DataForm_entryId=".$self->session->db->quote($var->{entryId});
$join = "left join DataForm_entryData as b on a.DataForm_fieldId=b.DataForm_fieldId";
$select .= ", b.value";
$var->{"delete.url"} = $self->getUrl('func=deleteEntry;entryId='.$var->{entryId});
$var->{"delete.label"} = $i18n->get(90);
}
my %data;
tie %data, 'Tie::CPHash';
@ -628,8 +630,6 @@ sub getTemplateVars {
$var->{"entryList.label"} = $i18n->get(86);
$var->{"export.tab.url"} = $self->getUrl('func=exportTab');
$var->{"export.tab.label"} = $i18n->get(84);
$var->{"delete.url"} = $self->getUrl('func=deleteEntry;entryId='.$var->{entryId});
$var->{"delete.label"} = $i18n->get(90);
$var->{"addField.url"} = $self->getUrl('func=editField');
$var->{"addField.label"} = $i18n->get(76);
$var->{"deleteAllEntries.url"} = $self->getUrl("func=deleteAllEntriesConfirm");
@ -816,7 +816,7 @@ sub sendEmail {
sentBy => $self->session->user->userId,
subject=>$subject,
message=>$message,
status=>'complete'
status=>'unread'
});
if ($cc) {
my $mail = WebGUI::Mail::Send->create($self->session,{to=>$cc, replyTo=>$from, subject=>$subject, from=>$from});

View file

@ -281,6 +281,14 @@ sub www_compare {
unless (scalar(@cmsList)) {
@cmsList = $self->session->form->checkList("listingId");
}
my ($style, $url) = ($self->session->style, $self->session->url);
$style->setLink($url->extras('/yui/build/container/assets/container.css'),{ type=>'text/css', rel=>"stylesheet" });
$style->setLink($url->extras('/hoverhelp.css'),{ type=>'text/css', rel=>"stylesheet" });
$style->setScript($url->extras('/yui/build/yahoo/yahoo-min.js'),{ type=>'text/javascript' });
$style->setScript($url->extras('/yui/build/dom/dom-min.js'),{ type=>'text/javascript' });
$style->setScript($url->extras('/yui/build/event/event-min.js'),{ type=>'text/javascript' });
$style->setScript($url->extras('/yui/build/container/container-min.js'),{ type=>'text/javascript' });
$style->setScript($url->extras('/hoverhelp.js'),{ type=>'text/javascript' });
my ( %var, @prodcol, @datecol);
my $max = $self->session->user->isInGroup($self->get("privilegedGroup")) ? $self->get("maxComparisonsPrivileged") : $self->get("maxComparisons");
$var{isTooMany} = (scalar(@cmsList)>$max);
@ -303,12 +311,20 @@ sub www_compare {
lastUpdated=>$self->session->datetime->epochToHuman($data->{lastUpdated},"%z")
});
}
my $i18n = WebGUI::International->new($self->session,'Asset_Matrix');
my %goodBad = (
"No" => $i18n->get("no"),
"Yes" => $i18n->get("yes"),
"Free Add On" => $i18n->get("free"),
"Costs Extra" => $i18n->get("extra"),
"Limited" => $i18n->get("limited"),
);
$var{product_loop} = \@prodcol;
$var{lastupdated_loop} = \@datecol;
my @categoryloop;
foreach my $category ($self->getCategories()) {
my @rowloop;
my $select = "select a.label, a.description";
my $select = "select a.fieldType, a.label, a.description";
my $from = "from Matrix_field a";
my $tableCount = "b";
foreach my $cms (@cmsList) {
@ -321,17 +337,17 @@ sub www_compare {
while (my @row = $sth->array) {
my @columnloop;
my $first = 1;
my $type = shift @row;
foreach my $value (@row) {
my $desc = "";
if ($first) {
$desc = $row[1];
shift(@row);
$desc =~ s/\n//g;
$desc =~ s/\r//g;
$desc =~ s/'/\\\'/g;
$desc =~ s/"/\&quot;/g;
$first = 0;
}
elsif ($type eq 'goodBad') {
$value = $goodBad{$value};
}
my $class = lc($value);
$class =~ s/\s/_/g;
$class =~ s/\W//g;
@ -729,7 +745,7 @@ sub www_editListingSave {
addEditStampToPosts => 0,
usePreview => 1,
sortOrder => 'desc',
sortBy => 'dateUpdated',
sortBy => 'assetData.revisionDate',
rssTemplateId=>'PBtmpl0000000000000142',
notificationTemplateId=>'PBtmpl0000000000000027',
searchTemplateId=>'PBtmpl0000000000000031',
@ -972,10 +988,6 @@ sub www_search {
my $sth = $self->session->db->read("select name, fieldType, label, description from Matrix_field where category = ".$self->session->db->quote($category)." order by label");
my @loop;
while (my $data = $sth->hashRef) {
$data->{description} =~ s/\n//g;
$data->{description} =~ s/\r//g;
$data->{description} =~ s/'/\\\'/g;
$data->{description} =~ s/"/\&quot;/g;
if ($data->{fieldType} ne "goodBad") {
$data->{form} = WebGUI::Form::text($self->session,{
name=>$data->{name},
@ -1214,16 +1226,22 @@ sub www_viewDetail {
$var{views} = $listing->{views};
$var{compares} = $listing->{compares};
$var{clicks} = $listing->{clicks};
my $sth = $self->session->db->read("select a.value, b.name, b.label, b.description, category from Matrix_listingData a left join
my $sth = $self->session->db->read("select a.value, b.name, b.label, b.description, category, fieldType from Matrix_listingData a left join
Matrix_field b on a.fieldId=b.fieldId and b.assetId=? where listingId=? order by b.label",[$self->getId, $listingId]);
while (my $data = $sth->hashRef) {
$data->{description} =~ s/\n//g;
$data->{description} =~ s/\r//g;
$data->{description} =~ s/'/\\\'/g;
$data->{description} =~ s/"/\&quot;/g;
$data->{class} = lc($data->{value});
my %goodBad = (
"No" => $i18n->get("no"),
"Yes" => $i18n->get("yes"),
"Free Add On" => $i18n->get("free"),
"Costs Extra" => $i18n->get("extra"),
"Limited" => $i18n->get("limited"),
);
while (my $data = $sth->hashRef) {
$data->{class} = lc($data->{value});
$data->{class} =~ s/\s/_/g;
$data->{class} =~ s/\W//g;
if ($data->{fieldType} eq 'goodBad') {
$data->{value} = $goodBad{$data->{value}};
}
my $cat = $self->session->url->urlize($data->{category})."_loop";
push(@{$var{$cat}},$data);
}

View file

@ -119,9 +119,9 @@ sub view {
if (defined $lastPost) {
%lastPostVars = (
'forum.lastPost.url' => $lastPost->getUrl,
'forum.lastPost.date' => $self->session->datetime->epochToHuman($lastPost->get("dateSubmitted"),"%z"),
'forum.lastPost.time' => $self->session->datetime->epochToHuman($lastPost->get("dateSubmitted"),"%Z"),
'forum.lastPost.epoch' => $lastPost->get("dateSubmitted"),
'forum.lastPost.date' => $self->session->datetime->epochToHuman($lastPost->get("creationDate"),"%z"),
'forum.lastPost.time' => $self->session->datetime->epochToHuman($lastPost->get("creationDate"),"%Z"),
'forum.lastPost.epoch' => $lastPost->get("creationDate"),
'forum.lastPost.subject' => $lastPost->get("title"),
'forum.lastPost.user.hasRead' => $lastPost->getThread->isMarkedRead,
'forum.lastPost.user.id' => $lastPost->get("ownerUserId"),

View file

@ -1055,14 +1055,14 @@ sub www_editProject {
my $hpdLabel = $i18n->get('hours per day label');
my $hpdHoverHelp = $i18n->get('hours per day hoverhelp');
$hpdHoverHelp =~ s/'/\\'/g;
my $hpdValue = $form->get("hoursPerDay") || $project->{hoursPerDay} || "8.0";
my $hpdStyle = ($dunitValue eq "days"?"display:none":"");
my $html = qq|
<tr id="hoursper" style="$hpdStyle">
<td class="formDescription" onmouseover="return escape('$hpdHoverHelp')" valign="top" style="width: 180px;">
<label for="hoursPerDay_formId">$hpdLabel</label>
<td class="formDescription" valign="top" style="width: 180px;">
<div class="wg-hoverhelp">$hpdHoverHelp</div>
<label for="hoursPerDay_formId">$hpdLabel</label>
</td>
<td valign="top" class="tableData" style="width: *;">
<input id="hoursPerDay_formId" type="text" name="hoursPerDay" value="$hpdValue" size="11" maxlength="14" />

View file

@ -40,12 +40,16 @@ sub appendRecentChanges {
my $self = shift;
my $var = shift;
my $limit = shift || $self->get("recentChangesCount") || 50;
foreach my $asset (@{$self->getLineage(["children"], {
returnObjects => 1,
limit => $limit,
includeOnlyClasses =>["WebGUI::Asset::WikiPage"],
orderByClause => "assetData.revisionDate desc"
})}) {
my $revisions = $self->session->db->read("select asset.assetId, assetData.revisionDate, asset.className
from asset left join assetData using (assetId) where asset.parentId=? and asset.className
like ? order by assetData.revisionDate desc limit ?", [$self->getId,
"WebGUI::Asset::WikiPage%", $limit]);
while (my ($id, $version, $class) = $revisions->array) {
my $asset = WebGUI::Asset->new($self->session, $id, $class, $version);
unless (defined $asset) {
$self->session->errorHandler->error("Asset $id $class $version could not be instanciated.");
next;
}
my $user = WebGUI::User->new($self->session, $asset->get("actionTakenBy"));
my $specialAction = '';
my $isAvailable = 1;