Skip to content

Commit

Permalink
BUGFIX Correctly set user timezone in workflow (mostly applies to cus…
Browse files Browse the repository at this point in the history
…tomisations with timezone as a DropdownField rather than a HiddenField, see AIR-92)
  • Loading branch information
chillu committed Jan 24, 2012
1 parent c88bbc4 commit 5319ea1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion code/LeftAndMainCMSWorkflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,22 @@ function cms_setembargoexpiry($data) {

if (isset($data['EmbargoDate'])) {
$embargoField->setValue($data['EmbargoDate']);
$tz = @$data['EmbargoDate']['timezone'];
if($tz) $embargoField->setConfig('usertimezone', $tz);
$embargoDate = $embargoField->Value();
$embargoTimestamp = strtotime($embargoField->Value());
}

if (isset($data['ExpiryDate'])) {
$expiryField->setValue($data['ExpiryDate']);
$tz = @$data['ExpiryDate']['timezone'];
if($tz) $expiryField->setConfig('usertimezone', $tz);
$expiryDate = $expiryField->Value();
$expiryTimestamp = strtotime($expiryField->Value());
}

$embargoField->saveInto($wfRequest);
$expiryField->saveInto($wfRequest->Page());

$embargoTimestamp = strtotime($embargoField->dataValue());
$expiryTimestamp = strtotime($expiryField->dataValue());

Expand Down
4 changes: 2 additions & 2 deletions javascript/LeftAndMainCMSWorkflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ var EmbargoExpiry = {
saveButton: 'saveExpiryButton',
dateField: 'ExpiryDate-date',
timeField: 'ExpiryDate-time',
timezoneField: 'ExpiryDate_TimeZone',
timezoneField: 'ExpiryDate-timezone',
wholeMessage: 'embargoExpiry-expiryStatus',
dateTime: 'expiryDate',
what: 'expiry'
Expand All @@ -244,7 +244,7 @@ var EmbargoExpiry = {
saveButton: 'saveEmbargoButton',
dateField: 'EmbargoDate-date',
timeField: 'EmbargoDate-time',
timezoneField: 'EmbargoDate_TimeZone',
timezoneField: 'EmbargoDate-timezone',
wholeMessage: 'embargoExpiry-embargoStatus',
dateTime: 'embargoDate',
what: 'embargo'
Expand Down
4 changes: 2 additions & 2 deletions templates/SiteTreeCMSWorkflow_workflowtab.ss
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@

<% if EmbargoField %>
<p id="embargoExpiry-embargoStatus" style="display:<% if EmbargoDate %>block<% else %>none<% end_if %>">
This page is currently scheduled to be published at <span id="embargoDate">$EmbargoDate.Nice</span><% if ExpiryField.DefaultTimezoneName %>, $ExpiryField.DefaultTimezoneName time<% end_if %>.
This page is currently scheduled to be published at <span id="embargoDate">$EmbargoDate.Nice</span><% if ExpiryField.TimezoneName %>, $ExpiryField.TimezoneName time<% end_if %>.
<% if Status = Scheduled %><a href="$ViewEmbargoedLink" target="_blank">View site on date</a><% end_if %>
</p>
<% end_if %>

<% if ExpiryField %>
<p id="embargoExpiry-expiryStatus" style="display:<% if ExpiryDate %>block<% else %>none<% end_if %>">
This page is currently scheduled to be unpublished at <span id="expiryDate">$Page.ExpiryDate.Nice</span><% if ExpiryField.DefaultTimezoneName %>, $ExpiryField.DefaultTimezoneName time<% end_if %>.
This page is currently scheduled to be unpublished at <span id="expiryDate">$Page.ExpiryDate.Nice</span><% if ExpiryField.TimezoneName %>, $ExpiryField.TimezoneName time<% end_if %>.
<% if Status = Scheduled %><a href="$ViewExpiredLink" target="_blank">View site on date</a><% end_if %>
</p>
<% end_if %>
Expand Down

0 comments on commit 5319ea1

Please sign in to comment.