merging 7.4 changes
This commit is contained in:
parent
5292426cc5
commit
1149fd54ed
19 changed files with 319 additions and 167 deletions
|
|
@ -200,48 +200,53 @@ sub generateRecurringEvents {
|
|||
}
|
||||
|
||||
# Get the distance between the event startDate and endDate
|
||||
# Only days, since event recurrence only changes the Date the event occurs, not
|
||||
# the time.
|
||||
# Include the time, as recurrence can change it when crossing a daylight
|
||||
# savings time border.
|
||||
# TODO: Allow recurrence patterns of less than a single day.
|
||||
my $duration_days = 0;
|
||||
|
||||
my $initialStart
|
||||
= WebGUI::DateTime->new($session, $properties->{startDate} . " "
|
||||
. ($properties->{startTime} || "00:00:00"));
|
||||
my $initialEnd
|
||||
= WebGUI::DateTime->new($session, $properties->{endDate} . " "
|
||||
. ($properties->{endTime} || "00:00:00"));
|
||||
my $duration = $initialEnd->subtract_datetime($initialStart);
|
||||
|
||||
my $event_start
|
||||
= WebGUI::DateTime->new($session, $properties->{startDate}." 00:00:00");
|
||||
my $event_end
|
||||
= WebGUI::DateTime->new($session, $properties->{endDate}." 00:00:00");
|
||||
$duration_days
|
||||
= $event_end->subtract_datetime($event_start)->days;
|
||||
|
||||
my $eventTime;
|
||||
my $localTime;
|
||||
if ($properties->{startTime}) {
|
||||
$eventTime = WebGUI::DateTime->new($session, $properties->{startDate} . " " . $properties->{startTime});
|
||||
$eventTime = $eventTime->set_time_zone($properties->{timeZone})->toMysqlTime;
|
||||
$localTime = $initialStart->clone->set_time_zone($properties->{timeZone})->toMysqlTime;
|
||||
}
|
||||
$properties->{feedUid} = undef;
|
||||
|
||||
my @dates = $self->getRecurrenceDates;
|
||||
|
||||
for my $date (@dates) {
|
||||
my $dt;
|
||||
if ($eventTime) {
|
||||
$dt = WebGUI::DateTime->new($session, mysql => $date . " " . $eventTime, time_zone => $properties->{timeZone});
|
||||
my $startDate;
|
||||
if ($localTime) {
|
||||
$startDate = WebGUI::DateTime->new($session,
|
||||
mysql => $date . " " . $localTime,
|
||||
time_zone => $properties->{timeZone},
|
||||
);
|
||||
}
|
||||
else {
|
||||
$dt = WebGUI::DateTime->new($session, $date." ". "00:00:00");
|
||||
$startDate = WebGUI::DateTime->new($session, $date." 00:00:00");
|
||||
}
|
||||
my $startDate = $dt->toDatabaseDate;
|
||||
my $endDate = $startDate->clone->add($duration);
|
||||
my $dbDate = $startDate->toDatabaseDate;
|
||||
# Only generate if the recurId does not exist on this day
|
||||
my ($exists)
|
||||
= $session->db->quickArray(
|
||||
"select count(*) from Event where recurId=? and startDate=?",
|
||||
[$properties->{recurId}, $startDate],
|
||||
[$properties->{recurId}, $dbDate],
|
||||
);
|
||||
|
||||
if (!$exists) {
|
||||
$properties->{startDate} = $startDate;
|
||||
$properties->{endDate}
|
||||
= $dt->clone->add(days => $duration_days)->toDatabaseDate;
|
||||
|
||||
$properties->{startDate} = $dbDate;
|
||||
$properties->{endDate} = $endDate->toDatabaseDate;
|
||||
if ($localTime) {
|
||||
$properties->{startTime} = $startDate->toDatabaseTime;
|
||||
$properties->{endTime} = $endDate->toDatabaseTime;
|
||||
}
|
||||
my $newEvent = $parent->addChild($properties);
|
||||
$newEvent->requestAutoCommit;
|
||||
}
|
||||
|
|
@ -1802,9 +1807,8 @@ Wrap update so that isHidden is always set to be a 1.
|
|||
|
||||
sub update {
|
||||
my $self = shift;
|
||||
my $properties = shift;
|
||||
$properties->{isHidden} = 1;
|
||||
return $self->SUPER::update($properties);
|
||||
my $properties = shift;
|
||||
return $self->SUPER::update({%$properties, isHidden => 1});
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1041,8 +1041,7 @@ sub update {
|
|||
view => $self->get("groupIdView"),
|
||||
edit => $self->get("groupIdEdit")
|
||||
);
|
||||
$properties->{isHidden} = 1;
|
||||
$self->SUPER::update($properties, @_);
|
||||
$self->SUPER::update({%$properties, isHidden => 1});
|
||||
if ($self->get("ownerUserId") ne $before{owner} || $self->get("groupIdEdit") ne $before{edit} || $self->get("groupIdView") ne $before{view}) {
|
||||
my $storage = $self->getStorageLocation;
|
||||
if (-d $storage->getPath) {
|
||||
|
|
|
|||
|
|
@ -242,35 +242,40 @@ Returns a thread object for the next (newer) thread in the same forum.
|
|||
=cut
|
||||
|
||||
sub getNextThread {
|
||||
my $self = shift;
|
||||
unless (defined $self->{_next}) {
|
||||
my $self = shift;
|
||||
unless (defined $self->{_next}) {
|
||||
my $parent = $self->getParent;
|
||||
my $sortBy = $parent->getSortBy;
|
||||
my $sortByCompare = $sortBy eq 'assetData.revisionDate' ? $self->get('revisionDate') : $self->get($sortBy);
|
||||
$sortBy = join('.', map { $self->session->db->dbh->quote_identifier($_) } split(/\./, $sortBy));
|
||||
my $sortOrder = $parent->getSortOrder;
|
||||
my ($id, $class, $version) = $self->session->dbSlave->quickArray("
|
||||
select asset.assetId,asset.className,max(assetData.revisionDate)
|
||||
from Thread
|
||||
left join asset on asset.assetId=Thread.assetId
|
||||
left join assetData on assetData.assetId=Thread.assetId and assetData.revisionDate=Thread.revisionDate
|
||||
left join Post on Post.assetId=assetData.assetId and assetData.revisionDate=Post.revisionDate
|
||||
where asset.parentId=".$self->session->db->quote($self->get("parentId"))."
|
||||
and asset.state='published'
|
||||
and asset.className='WebGUI::Asset::Post::Thread'
|
||||
and ".$sortBy.($sortOrder eq 'asc' ? '>' : '<').$self->session->db->quote($self->get($sortBy))."
|
||||
and (
|
||||
assetData.status in ('approved','archived')
|
||||
or assetData.tagId=".$self->session->db->quote($self->session->scratch->get("versionTag"))."
|
||||
or (assetData.ownerUserId=".$self->session->db->quote($self->session->user->userId)." and assetData.ownerUserId<>'1')
|
||||
)
|
||||
group by assetData.assetId
|
||||
order by ".$sortBy." ".$sortOrder."
|
||||
");
|
||||
if ($id) {
|
||||
my $sortCompare = lc $sortOrder eq 'asc' ? '>=' : '<=';
|
||||
my ($id, $class, $version) = $self->session->dbSlave->quickArray(<<END_SQL, [$self->get("parentId"), $self->getId, $sortByCompare, $self->session->scratch->get("versionTag"), $self->session->user->userId]);
|
||||
select asset.assetId, asset.className, max(assetData.revisionDate)
|
||||
from Thread
|
||||
left join asset on asset.assetId=Thread.assetId
|
||||
left join assetData on assetData.assetId=Thread.assetId and assetData.revisionDate=Thread.revisionDate
|
||||
left join Post on Post.assetId=assetData.assetId and assetData.revisionDate=Post.revisionDate
|
||||
where
|
||||
asset.parentId=?,
|
||||
and asset.assetId <> ?
|
||||
and asset.state='published'
|
||||
and asset.className='WebGUI::Asset::Post::Thread'
|
||||
and $sortBy $sortCompare ?
|
||||
and (
|
||||
assetData.status in ('approved','archived')
|
||||
or assetData.tagId=?
|
||||
or (assetData.ownerUserId=? and assetData.ownerUserId<>'1')
|
||||
)
|
||||
group by assetData.assetId
|
||||
order by $sortBy $sortOrder, assetData.revisionDate asc
|
||||
limit 1
|
||||
END_SQL
|
||||
if ($id) {
|
||||
$self->{_next} = WebGUI::Asset->new($self->session, $id, $class, $version);
|
||||
}
|
||||
# delete $self->{_next} unless ($self->{_next}->{_properties}{className} =~ /Thread/);
|
||||
};
|
||||
return $self->{_next};
|
||||
};
|
||||
return $self->{_next};
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -297,37 +302,42 @@ Returns a thread object for the previous (older) thread in the same forum.
|
|||
=cut
|
||||
|
||||
sub getPreviousThread {
|
||||
my $self = shift;
|
||||
my $self = shift;
|
||||
unless (defined $self->{_previous}) {
|
||||
my $parent = $self->getParent;
|
||||
my $sortBy = $parent->getSortBy;
|
||||
my $sortByCompare = $sortBy eq 'assetData.revisionDate' ? $self->get('revisionDate') : $self->get($sortBy);
|
||||
$sortBy = join('.', map { $self->session->db->dbh->quote_identifier($_) } split(/\./, $sortBy));
|
||||
my $sortOrder = lc($parent->getSortOrder) eq 'asc' ? 'desc' : 'asc';
|
||||
my ($id, $class, $version) = $self->session->dbSlave->quickArray("
|
||||
select asset.assetId,asset.className,max(assetData.revisionDate)
|
||||
from Thread
|
||||
left join asset on asset.assetId=Thread.assetId
|
||||
left join assetData on assetData.assetId=Thread.assetId and assetData.revisionDate=Thread.revisionDate
|
||||
left join Post on Post.assetId=assetData.assetId and assetData.revisionDate=Post.revisionDate
|
||||
where asset.parentId=".$self->session->db->quote($self->get("parentId"))."
|
||||
and asset.state='published'
|
||||
and asset.className='WebGUI::Asset::Post::Thread'
|
||||
and ".$sortBy.($sortOrder eq 'asc' ? '>' : '<').$self->session->db->quote($self->get($sortBy))."
|
||||
and (
|
||||
assetData.status in ('approved','archived')
|
||||
or assetData.tagId=".$self->session->db->quote($self->session->scratch->get("versionTag"))."
|
||||
or (assetData.ownerUserId=".$self->session->db->quote($self->session->user->userId)." and assetData.ownerUserId<>'1')
|
||||
)
|
||||
group by assetData.assetId
|
||||
order by ".$sortBy." ".$sortOrder.", assetData.revisionDate desc ");
|
||||
if($id) {
|
||||
$self->{_previous} = WebGUI::Asset::Post::Thread->new($self->session, $id,$class,$version);
|
||||
}
|
||||
# delete $self->{_previous} unless ($self->{_previous}->{_properties}{className} =~ /Thread/);
|
||||
}
|
||||
return $self->{_previous};
|
||||
my $sortCompare = lc $sortOrder eq 'asc' ? '>=' : '<=';
|
||||
my ($id, $class, $version) = $self->session->dbSlave->quickArray(<<END_SQL, [$self->get("parentId"), $self->getId, $sortByCompare, $self->session->scratch->get("versionTag"), $self->session->user->userId]);
|
||||
select asset.assetId, asset.className, max(assetData.revisionDate)
|
||||
from Thread
|
||||
left join asset on asset.assetId=Thread.assetId
|
||||
left join assetData on assetData.assetId=Thread.assetId and assetData.revisionDate=Thread.revisionDate
|
||||
left join Post on Post.assetId=assetData.assetId and assetData.revisionDate=Post.revisionDate
|
||||
where
|
||||
asset.parentId=?,
|
||||
asset.assetId <> ?
|
||||
and asset.state='published'
|
||||
and asset.className='WebGUI::Asset::Post::Thread'
|
||||
and $sortBy $sortCompare ?
|
||||
and (
|
||||
assetData.status in ('approved','archived')
|
||||
or assetData.tagId=?
|
||||
or (assetData.ownerUserId=? and assetData.ownerUserId<>'1')
|
||||
)
|
||||
group by assetData.assetId
|
||||
order by $sortBy $sortOrder, assetData.revisionDate desc
|
||||
limit 1
|
||||
END_SQL
|
||||
if ($id) {
|
||||
$self->{_previous} = WebGUI::Asset->new($self->session, $id, $class, $version);
|
||||
}
|
||||
};
|
||||
return $self->{_previous};
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getStickUrl ( )
|
||||
|
|
|
|||
|
|
@ -156,7 +156,12 @@ sub purgeCache {
|
|||
sub view {
|
||||
my $self = shift;
|
||||
my $calledAsWebMethod = shift;
|
||||
if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) {
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($self->session, 1);
|
||||
my $noCache =
|
||||
$self->session->var->isAdminOn
|
||||
|| $self->get("cacheTimeout") <= 10
|
||||
|| ($versionTag && $versionTag->getId eq $self->get("tagId"));
|
||||
unless ($noCache) {
|
||||
my $out = WebGUI::Cache->new($self->session,"view_".$calledAsWebMethod."_".$self->getId)->get;
|
||||
return $out if $out;
|
||||
}
|
||||
|
|
@ -166,7 +171,7 @@ sub view {
|
|||
if ($self->getValue("processAsTemplate")) {
|
||||
$output = WebGUI::Asset::Template->processRaw($self->session, $output, $self->get);
|
||||
}
|
||||
if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) {
|
||||
unless ($noCache) {
|
||||
WebGUI::Cache->new($self->session,"view_".$calledAsWebMethod."_".$self->getId)->set($output,$self->get("cacheTimeout"));
|
||||
}
|
||||
return $output;
|
||||
|
|
|
|||
|
|
@ -311,8 +311,7 @@ Wrap update to force isHidden to be on, all the time.
|
|||
sub update {
|
||||
my $self = shift;
|
||||
my $properties = shift;
|
||||
$properties->{isHidden} = 1;
|
||||
$self->SUPER::update($properties, @_);
|
||||
return $self->SUPER::update({%$properties, isHidden => 1});
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -225,39 +225,29 @@ sub definition {
|
|||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# strip all html tags from the given data structure. This is important to
|
||||
# prevent cross site scripting attacks
|
||||
#my $_stripped_html = {};
|
||||
|
||||
sub _strip_html {
|
||||
#my ($data) = @_;
|
||||
|
||||
if (ref($_[0]) eq 'HASH') {
|
||||
keys(%{$_[0]});
|
||||
while (my ($name, $val) = each (%{$_[0]})) {
|
||||
$_[0]->{$name} = _strip_html($val);
|
||||
}
|
||||
} elsif (ref($_[0]) eq 'ARRAY') {
|
||||
for (my $i = 0; $i < @{$_[0]}; $i++) {
|
||||
$_[0]->[$i] = _strip_html($_[0]->[$i]);
|
||||
}
|
||||
} else {
|
||||
if ($_[0]) {
|
||||
$_[0] =~ s/\</</g;
|
||||
$_[0] =~ s/\>/>/g;
|
||||
$_[0] = WebGUI::HTML::filter($_[0], 'all');
|
||||
##Unencode double encoded entities. This is usually done
|
||||
##by passing XML::RSSLite an already encoded entity.
|
||||
$_[0] =~ s/\&(?=(#[0-9]+|#x[0-9a-fA-F]+|\w+);)/&/g;
|
||||
}
|
||||
unless (ref $_[0]) {
|
||||
return $_[0] = WebGUI::HTML::Filter($_[0], 'all');
|
||||
}
|
||||
my $ref = shift;
|
||||
if (ref $ref eq 'HASH') {
|
||||
if (exists $ref->{description}) {
|
||||
$ref->{description} = HTML::Entities::decode_entities($ref->{description});
|
||||
}
|
||||
|
||||
return $_[0];
|
||||
foreach my $value (values %$ref) {
|
||||
_strip_html($value);
|
||||
}
|
||||
}
|
||||
elsif (ref $ref eq 'ARRAY') {
|
||||
foreach my $value (@$ref) {
|
||||
_strip_html($value);
|
||||
}
|
||||
}
|
||||
return $ref;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -399,7 +389,7 @@ sub _get_rss_data {
|
|||
$rss->{items} = [];
|
||||
}
|
||||
|
||||
_strip_html($rss);
|
||||
_strip_html($rss);
|
||||
$rss->{items} = [ $rss->{items} ] unless (ref $rss->{items} eq 'ARRAY');
|
||||
|
||||
_normalize_items($rss->{items});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue