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

@ -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;