better timezone handling
This commit is contained in:
parent
d9824cda40
commit
ffb7933bda
|
@ -1283,6 +1283,16 @@ function getTimeZone() {
|
||||||
return new DateTimeZone($timeZone);
|
return new DateTimeZone($timeZone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current time in formatted form.
|
||||||
|
*
|
||||||
|
* @param unknown $format format to use (e.g. 'Y-m-d H:i:s,00')
|
||||||
|
*/
|
||||||
|
function getFormattedTime($format) {
|
||||||
|
$time = new DateTime(null, getTimeZone());
|
||||||
|
return $time->format($format);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats a number of seconds to a more human readable format with minutes, hours, etc.
|
* Formats a number of seconds to a more human readable format with minutes, hours, etc.
|
||||||
* E.g. 70 seconds will return 1m10s.
|
* E.g. 70 seconds will return 1m10s.
|
||||||
|
|
|
@ -123,7 +123,7 @@ class lamPDF extends UFPDF {
|
||||||
$this->Line(10,282,200,282);
|
$this->Line(10,282,200,282);
|
||||||
$this->SetY(286);
|
$this->SetY(286);
|
||||||
$this->SetFont($this->fontName,"",7);
|
$this->SetFont($this->fontName,"",7);
|
||||||
$this->Cell(0,5,_("This document was automatically created by LDAP Account Manager") . ' (' . date('Y-m-d H:i:s T') . ')',0,0,"C",0);
|
$this->Cell(0,5,_("This document was automatically created by LDAP Account Manager") . ' (' . getFormattedTime('Y-m-d H:i:s T') . ')',0,0,"C",0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -551,7 +551,7 @@ class pykotaUser extends baseModule {
|
||||||
$errors[] = $this->messages['pykotaPayments'][0];
|
$errors[] = $this->messages['pykotaPayments'][0];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$this->attributes['pykotaPayments'][] = date('Y-m-d H:i:s,00', time()) . ' # ' . $amount . ' # ' . $comment;
|
$this->attributes['pykotaPayments'][] = getFormattedTime('Y-m-d H:i:s,00') . ' # ' . $amount . ' # ' . $comment;
|
||||||
// new balance
|
// new balance
|
||||||
$newBalance = 0.0;
|
$newBalance = 0.0;
|
||||||
if (!empty($this->attributes['pykotaBalance'][0])) {
|
if (!empty($this->attributes['pykotaBalance'][0])) {
|
||||||
|
@ -754,7 +754,7 @@ class pykotaUser extends baseModule {
|
||||||
}
|
}
|
||||||
$this->attributes['pykotaBalance'][0] = $amount;
|
$this->attributes['pykotaBalance'][0] = $amount;
|
||||||
$this->attributes['pykotaLifeTimePaid'][0] = $amount;
|
$this->attributes['pykotaLifeTimePaid'][0] = $amount;
|
||||||
$this->attributes['pykotaPayments'][] = date('Y-m-d H:i:s,00', time()) . ' # ' . $amount . ' # ';
|
$this->attributes['pykotaPayments'][] = getFormattedTime('Y-m-d H:i:s,00') . ' # ' . $amount . ' # ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -873,7 +873,7 @@ class pykotaUser extends baseModule {
|
||||||
if (!empty($rawAccounts[$i][$ids['pykotaUser_pykotaBalanceComment']])) {
|
if (!empty($rawAccounts[$i][$ids['pykotaUser_pykotaBalanceComment']])) {
|
||||||
$comment = base64_encode($rawAccounts[$i][$ids['pykotaUser_pykotaBalanceComment']]);
|
$comment = base64_encode($rawAccounts[$i][$ids['pykotaUser_pykotaBalanceComment']]);
|
||||||
}
|
}
|
||||||
$partialAccounts[$i]['pykotaPayments'][0] = date('Y-m-d H:i:s,00', time()) . ' # ' . $balance . ' # ' . $comment;
|
$partialAccounts[$i]['pykotaPayments'][0] = getFormattedTime('Y-m-d H:i:s,00') . ' # ' . $balance . ' # ' . $comment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1133,7 +1133,8 @@ class sambaSamAccount extends baseModule implements passwordService {
|
||||||
if (!$this->isBooleanConfigOptionSet('sambaSamAccount_hideSambaPwdLastSet')) {
|
if (!$this->isBooleanConfigOptionSet('sambaSamAccount_hideSambaPwdLastSet')) {
|
||||||
$sambaPwdLastSet = '';
|
$sambaPwdLastSet = '';
|
||||||
if (!empty($this->attributes['sambaPwdLastSet'][0])) {
|
if (!empty($this->attributes['sambaPwdLastSet'][0])) {
|
||||||
$sambaPwdLastSet = date('d.m.Y H:i', $this->attributes['sambaPwdLastSet'][0]);
|
$time = new DateTime('@' . $this->attributes['sambaPwdLastSet'][0], getTimeZone());
|
||||||
|
$sambaPwdLastSet = $time->format('d.m.Y H:i');
|
||||||
}
|
}
|
||||||
$return->addElement(new htmlOutputText(_('Last password change')));
|
$return->addElement(new htmlOutputText(_('Last password change')));
|
||||||
$return->addElement(new htmlOutputText($sambaPwdLastSet));
|
$return->addElement(new htmlOutputText($sambaPwdLastSet));
|
||||||
|
@ -2251,7 +2252,8 @@ class sambaSamAccount extends baseModule implements passwordService {
|
||||||
if (in_array('sambaPwdLastSet', $fields)) {
|
if (in_array('sambaPwdLastSet', $fields)) {
|
||||||
$sambaPwdLastSet = '';
|
$sambaPwdLastSet = '';
|
||||||
if (isset($attributes['sambaPwdLastSet'][0])) {
|
if (isset($attributes['sambaPwdLastSet'][0])) {
|
||||||
$sambaPwdLastSet = date('d.m.Y H:i', $attributes['sambaPwdLastSet'][0]);
|
$time = new DateTime('@' . $attributes['sambaPwdLastSet'][0], getTimeZone());
|
||||||
|
$sambaPwdLastSet = $time->format('d.m.Y H:i');
|
||||||
}
|
}
|
||||||
$row = new htmlResponsiveRow();
|
$row = new htmlResponsiveRow();
|
||||||
$row->addLabel(new htmlOutputText($this->getSelfServiceLabel('sambaPwdLastSet', _('Last password change'))));
|
$row->addLabel(new htmlOutputText($this->getSelfServiceLabel('sambaPwdLastSet', _('Last password change'))));
|
||||||
|
@ -2434,8 +2436,9 @@ class sambaSamAccount extends baseModule implements passwordService {
|
||||||
if (!isset($domains[$i]->maxPwdAge) || ($domains[$i]->maxPwdAge < 0)) {
|
if (!isset($domains[$i]->maxPwdAge) || ($domains[$i]->maxPwdAge < 0)) {
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
$time = $this->attributes['sambaPwdLastSet'][0] + $domains[$i]->maxPwdAge;
|
$timeVal = $this->attributes['sambaPwdLastSet'][0] + $domains[$i]->maxPwdAge;
|
||||||
return date('d.m.Y H:i', $time);
|
$time = new DateTime('@' . $timeVal, getTimeZone());
|
||||||
|
return $time->format('d.m.Y H:i');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
|
@ -2462,8 +2465,9 @@ class sambaSamAccount extends baseModule implements passwordService {
|
||||||
if (!isset($domains[$i]->minPwdAge) || ($domains[$i]->minPwdAge < 0)) {
|
if (!isset($domains[$i]->minPwdAge) || ($domains[$i]->minPwdAge < 0)) {
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
$time = $this->attributes['sambaPwdLastSet'][0] + $domains[$i]->minPwdAge;
|
$timeVal = $this->attributes['sambaPwdLastSet'][0] + $domains[$i]->minPwdAge;
|
||||||
return date('d.m.Y H:i', $time);
|
$time = new DateTime('@' . $timeVal, getTimeZone());
|
||||||
|
return $time->format('d.m.Y H:i');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
|
|
|
@ -167,7 +167,7 @@ class shadowAccount extends baseModule implements passwordService {
|
||||||
'shadowLastChange' => _('Last password change'),
|
'shadowLastChange' => _('Last password change'),
|
||||||
'shadowWarning' => _('Password warning'),
|
'shadowWarning' => _('Password warning'),
|
||||||
'shadowInactive' => _('Account inactive'),
|
'shadowInactive' => _('Account inactive'),
|
||||||
'shadowExpire' => _('Password expiration'),
|
'shadowExpire' => _('Account expiration date'),
|
||||||
'shadowMinAge' => _('Minimum password age'),
|
'shadowMinAge' => _('Minimum password age'),
|
||||||
'shadowMaxAge' => _('Maximum password age'),
|
'shadowMaxAge' => _('Maximum password age'),
|
||||||
);
|
);
|
||||||
|
@ -542,13 +542,16 @@ class shadowAccount extends baseModule implements passwordService {
|
||||||
* @return list of PDF entries (array(<PDF key> => <PDF lines>))
|
* @return list of PDF entries (array(<PDF key> => <PDF lines>))
|
||||||
*/
|
*/
|
||||||
function get_pdfEntries($pdfKeys) {
|
function get_pdfEntries($pdfKeys) {
|
||||||
|
$timeZone = new DateTimeZone($_SESSION['config']->getTimeZone());
|
||||||
$shadowLastChange = '';
|
$shadowLastChange = '';
|
||||||
if (isset($this->attributes['shadowLastChange'][0])) {
|
if (!empty($this->attributes['shadowLastChange'][0])) {
|
||||||
$shadowLastChange = date('d. m. Y',$this->attributes['shadowLastChange'][0]*24*3600);
|
$time = new DateTime('@' . $this->attributes['shadowLastChange'][0]*24*3600, $timeZone);
|
||||||
|
$shadowLastChange = $time->format('d. m. Y');
|
||||||
}
|
}
|
||||||
$shadowExpire = '';
|
$shadowExpire = '';
|
||||||
if (isset($this->attributes['shadowExpire'][0])) {
|
if (!empty($this->attributes['shadowExpire'][0])) {
|
||||||
$shadowExpire = date('d. m. Y',$this->attributes['shadowExpire'][0]*24*3600);
|
$time = new DateTime('@' . $this->attributes['shadowExpire'][0]*24*3600);
|
||||||
|
$shadowExpire = $time->format('d. m. Y');
|
||||||
}
|
}
|
||||||
$return = array();
|
$return = array();
|
||||||
$this->addPDFKeyValue($return, 'shadowLastChange', _('Last password change'), $shadowLastChange);
|
$this->addPDFKeyValue($return, 'shadowLastChange', _('Last password change'), $shadowLastChange);
|
||||||
|
|
|
@ -646,12 +646,13 @@ class lamUserList extends lamList {
|
||||||
}
|
}
|
||||||
// expire dates
|
// expire dates
|
||||||
elseif ($attribute == 'shadowexpire') {
|
elseif ($attribute == 'shadowexpire') {
|
||||||
if (isset($entry[$attribute][0]) && ($entry[$attribute][0] != '')) {
|
if (!empty($entry[$attribute][0])) {
|
||||||
echo date('d. m. Y', $entry[$attribute][0] * 24 * 3600);
|
$time = new DateTime('@' . $entry[$attribute][0] * 24 * 3600, new DateTimeZone($_SESSION['config']->getTimeZone()));
|
||||||
|
echo $time->format('d.m.Y');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($attribute == 'sambakickofftime') {
|
elseif ($attribute == 'sambakickofftime') {
|
||||||
if (isset($entry[$attribute][0]) && ($entry[$attribute][0] != '')) {
|
if (!empty($entry[$attribute][0])) {
|
||||||
if ($entry[$attribute][0] > 2147483648) {
|
if ($entry[$attribute][0] > 2147483648) {
|
||||||
echo "∞";
|
echo "∞";
|
||||||
}
|
}
|
||||||
|
|
|
@ -486,7 +486,13 @@ parseHtml(null, $globalFieldset, array(), false, $tabindex, 'user');
|
||||||
function formatSSLTimestamp($time) {
|
function formatSSLTimestamp($time) {
|
||||||
$matches = array();
|
$matches = array();
|
||||||
if (!empty($time)) {
|
if (!empty($time)) {
|
||||||
return date('d.m.Y', $time);
|
$timeZone = 'UTC';
|
||||||
|
$sysTimeZone = @date_default_timezone_get();
|
||||||
|
if (!empty($sysTimeZone)) {
|
||||||
|
$timeZone = $sysTimeZone;
|
||||||
|
}
|
||||||
|
$date = new DateTime('@' . $time, new DateTimeZone($timeZone));
|
||||||
|
return $date->format('d.m.Y');
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue