added account expiration date to PDF fields

This commit is contained in:
Roland Gruber 2017-04-18 18:28:10 +02:00
parent f4ce9c1299
commit 515a153286
2 changed files with 26 additions and 12 deletions

View File

@ -1,6 +1,7 @@
June 2017 June 2017
- Support multiple configurations for same account type - Support multiple configurations for same account type
- PHP 7.1 compatibility - PHP 7.1 compatibility
- Samba 3: added account expiration date to PDF fields
15.03.2017 5.7 15.03.2017 5.7

View File

@ -208,6 +208,7 @@ class sambaSamAccount extends baseModule implements passwordService {
// available PDF fields // available PDF fields
$return['PDF_fields'] = array( $return['PDF_fields'] = array(
'displayName' => _('Display name'), 'displayName' => _('Display name'),
'sambaKickoffTime' => _('Account expiration date'),
'sambaDomainName' => _('Domain'), 'sambaDomainName' => _('Domain'),
'sambaPrimaryGroupSID' => _('Windows group') 'sambaPrimaryGroupSID' => _('Windows group')
); );
@ -1128,19 +1129,11 @@ class sambaSamAccount extends baseModule implements passwordService {
$return->addElement($tempTable); $return->addElement($tempTable);
$return->addElement(new htmlHelpLink('pwdMustChange'), true); $return->addElement(new htmlHelpLink('pwdMustChange'), true);
// account expiration time // account expiration time
$dateValue = "     -      "; $dateValue = $this->formatAccountExpirationDate();
if (isset($this->attributes['sambaKickoffTime'][0])) {
if ($this->attributes['sambaKickoffTime'][0] > 2147483648) {
$dateValue = "     ∞      ";
}
else {
$date = new DateTime('@' . $this->attributes['sambaKickoffTime'][0], new DateTimeZone('UTC'));
$dateValue = $date->format('d.m.Y');
}
}
$return->addElement(new htmlOutputText(_('Account expiration date'))); $return->addElement(new htmlOutputText(_('Account expiration date')));
$tempTable = new htmlTable(); $tempTable = new htmlTable();
$tempTable->addElement(new htmlOutputText($dateValue, false)); $tempTable->addElement(new htmlOutputText($dateValue, false));
$tempTable->addSpace('5px');
$tempTable->addElement(new htmlAccountPageButton(get_class($this), 'time', 'sambaKickoffTime', _('Change'))); $tempTable->addElement(new htmlAccountPageButton(get_class($this), 'time', 'sambaKickoffTime', _('Change')));
$return->addElement($tempTable); $return->addElement($tempTable);
$return->addElement(new htmlHelpLink('expireDate'), true); $return->addElement(new htmlHelpLink('expireDate'), true);
@ -1265,6 +1258,25 @@ class sambaSamAccount extends baseModule implements passwordService {
return $return; return $return;
} }
/**
* Returns the account expiration date in printable form.
*
* @return string expiration date
*/
private function formatAccountExpirationDate() {
$dateValue = "-";
if (isset($this->attributes['sambaKickoffTime'][0])) {
if ($this->attributes['sambaKickoffTime'][0] > 2147483648) {
$dateValue = "";
}
else {
$date = new DateTime('@' . $this->attributes['sambaKickoffTime'][0], new DateTimeZone('UTC'));
$dateValue = $date->format('d.m.Y');
}
}
return $dateValue;
}
/** /**
* This function will create the HTML page to edit the allowed workstations. * This function will create the HTML page to edit the allowed workstations.
* *
@ -1915,6 +1927,7 @@ class sambaSamAccount extends baseModule implements passwordService {
$this->addSimplePDFField($return, 'sambaUserWorkstations', _('Samba workstations')); $this->addSimplePDFField($return, 'sambaUserWorkstations', _('Samba workstations'));
$this->addSimplePDFField($return, 'sambaDomainName', _('Domain')); $this->addSimplePDFField($return, 'sambaDomainName', _('Domain'));
$this->addSimplePDFField($return, 'sambaPrimaryGroupSID', _('Windows group')); $this->addSimplePDFField($return, 'sambaPrimaryGroupSID', _('Windows group'));
$this->addPDFKeyValue($return, 'sambaKickoffTime', _('Account expiration date'), $this->formatAccountExpirationDate());
// terminal server options // terminal server options
if (isset($this->attributes['sambaMungedDial'][0])) { if (isset($this->attributes['sambaMungedDial'][0])) {
$mDial = new sambaMungedDial(); $mDial = new sambaMungedDial();
@ -2639,7 +2652,7 @@ class sambaSamAccount extends baseModule implements passwordService {
if (is_array($selectedDomain) && (sizeof($selectedDomain) > 0)) { if (is_array($selectedDomain) && (sizeof($selectedDomain) > 0)) {
$selectedDomain = $selectedDomain[0]; $selectedDomain = $selectedDomain[0];
} }
$return = '     -      '; $return = '-';
// check if password expires at all // check if password expires at all
if ($this->noexpire) { if ($this->noexpire) {
return $return; return $return;
@ -2673,7 +2686,7 @@ class sambaSamAccount extends baseModule implements passwordService {
if (is_array($selectedDomain) && (sizeof($selectedDomain) > 0)) { if (is_array($selectedDomain) && (sizeof($selectedDomain) > 0)) {
$selectedDomain = $selectedDomain[0]; $selectedDomain = $selectedDomain[0];
} }
$return = '     -      '; $return = '-';
// check if there is a time set for the last password change // check if there is a time set for the last password change
if (!isset($this->attributes['sambaPwdLastSet'][0])) { if (!isset($this->attributes['sambaPwdLastSet'][0])) {
return $return; return $return;