better timezone handling

This commit is contained in:
Roland Gruber 2015-08-23 17:56:27 +00:00
parent d9824cda40
commit ffb7933bda
7 changed files with 117 additions and 93 deletions

View File

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

View File

@ -25,7 +25,7 @@ $Id$
* LDAP Account Manager PDF printing library. It consists of lamPDF class, * LDAP Account Manager PDF printing library. It consists of lamPDF class,
* the createModulePDF() function that may be called by other pages * the createModulePDF() function that may be called by other pages
* and furthermore some helper functions. * and furthermore some helper functions.
* *
* @author Michael Duergner * @author Michael Duergner
* @author Roland Gruber * @author Roland Gruber
* @package PDF * @package PDF
@ -33,23 +33,23 @@ $Id$
/** /**
* Creates a LAM information page in PDF format. * Creates a LAM information page in PDF format.
* *
* @package PDF * @package PDF
* @author Michael Duergner * @author Michael Duergner
* @author Roland Gruber * @author Roland Gruber
*/ */
class lamPDF extends UFPDF { class lamPDF extends UFPDF {
/** /**
* format settings for page layout * format settings for page layout
*/ */
private $page_definitions; private $page_definitions;
/** /**
* current active font name * current active font name
*/ */
private $fontName; private $fontName;
/** /**
* list of supported fonts * list of supported fonts
* format: <font name> => array(<file for default font style>, <file for bold>, <italic>, <bold italic>) * format: <font name> => array(<file for default font style>, <file for bold>, <italic>, <bold italic>)
@ -60,7 +60,7 @@ class lamPDF extends UFPDF {
/** /**
* Creates a new lamPDF object. * Creates a new lamPDF object.
* *
* @param array $page_definitions page settings * @param array $page_definitions page settings
* @param String $fontName font name * @param String $fontName font name
*/ */
@ -71,9 +71,9 @@ class lamPDF extends UFPDF {
} }
// Call constructor of superclass // Call constructor of superclass
$this->FPDF('P','mm','A4'); $this->FPDF('P','mm','A4');
$this->page_definitions = $page_definitions; $this->page_definitions = $page_definitions;
// Open PDF file and write some basic information // Open PDF file and write some basic information
$this->Open(); $this->Open();
$this->AddFont($this->fontName, '', $this->fontList[$this->fontName][0]); $this->AddFont($this->fontName, '', $this->fontList[$this->fontName][0]);
@ -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);
} }
} }

View File

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

View File

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

View File

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

View File

@ -34,7 +34,7 @@ $Id$
* @package types * @package types
*/ */
class user extends baseType { class user extends baseType {
/** /**
* Constructs a new user type object. * Constructs a new user type object.
*/ */
@ -43,7 +43,7 @@ class user extends baseType {
$this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another user'); $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another user');
$this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to user list'); $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to user list');
} }
/** /**
* Returns the alias name of this account type. * Returns the alias name of this account type.
* *
@ -52,7 +52,7 @@ class user extends baseType {
function getAlias() { function getAlias() {
return _("Users"); return _("Users");
} }
/** /**
* Returns the description of this account type. * Returns the description of this account type.
* *
@ -61,7 +61,7 @@ class user extends baseType {
function getDescription() { function getDescription() {
return _("User accounts (e.g. Unix, Samba and Kolab)"); return _("User accounts (e.g. Unix, Samba and Kolab)");
} }
/** /**
* Returns the class name for the list object. * Returns the class name for the list object.
* *
@ -70,7 +70,7 @@ class user extends baseType {
function getListClassName() { function getListClassName() {
return "lamUserList"; return "lamUserList";
} }
/** /**
* Returns the default attribute list for this account type. * Returns the default attribute list for this account type.
* *
@ -211,10 +211,10 @@ class user extends baseType {
} }
return $subtitle; return $subtitle;
} }
/** /**
* Builds the HTML code for the icon that shows the account status (locked/unlocked). * Builds the HTML code for the icon that shows the account status (locked/unlocked).
* *
* @param accountContainer $container account container * @param accountContainer $container account container
* @return String HTML code for icon * @return String HTML code for icon
*/ */
@ -304,10 +304,10 @@ class user extends baseType {
} }
return $dialogDiv . '<a href="#"><img id="lam_accountStatus" alt="status" ' . $onClick . ' helptitle="' . _('Account status') . '" helpdata="' . $tipContent . '" height=16 width=16 src="../../graphics/' . $icon . '"></a>&nbsp;&nbsp;&nbsp;'; return $dialogDiv . '<a href="#"><img id="lam_accountStatus" alt="status" ' . $onClick . ' helptitle="' . _('Account status') . '" helpdata="' . $tipContent . '" height=16 width=16 src="../../graphics/' . $icon . '"></a>&nbsp;&nbsp;&nbsp;';
} }
/** /**
* Builds the dialog to (un)lock parts of an account. * Builds the dialog to (un)lock parts of an account.
* *
* @param boolean $unixAvailable Unix part is active * @param boolean $unixAvailable Unix part is active
* @param boolean $unixLocked Unix part is locked * @param boolean $unixLocked Unix part is locked
* @param boolean $sambaAvailable Samba part is active * @param boolean $sambaAvailable Samba part is active
@ -324,9 +324,9 @@ class user extends baseType {
&& (!$sambaAvailable || $sambaLocked) && (!$sambaAvailable || $sambaLocked)
&& (!$ppolicyAvailable || $ppolicyLocked) && (!$ppolicyAvailable || $ppolicyLocked)
&& (!$windowsAvailable || $windowsLocked); && (!$windowsAvailable || $windowsLocked);
$container = new htmlTable(); $container = new htmlTable();
// show radio buttons for lock/unlock // show radio buttons for lock/unlock
$radioDisabled = true; $radioDisabled = true;
$selectedRadio = 'lock'; $selectedRadio = 'lock';
@ -356,13 +356,13 @@ class user extends baseType {
$container->addElement($radio, true); $container->addElement($radio, true);
$container->addElement(new htmlHiddenInput('lam_accountStatusAction', $selectedRadio), true); $container->addElement(new htmlHiddenInput('lam_accountStatusAction', $selectedRadio), true);
} }
$container->addElement(new htmlHiddenInput('lam_accountStatusResult', 'cancel'), true); $container->addElement(new htmlHiddenInput('lam_accountStatusResult', 'cancel'), true);
// locking part // locking part
if (!$fullyLocked) { if (!$fullyLocked) {
$lockContent = new htmlTable(); $lockContent = new htmlTable();
if ($unixAvailable && !$unixLocked) { if ($unixAvailable && !$unixLocked) {
$lockContent->addElement(new htmlImage('../../graphics/tux.png')); $lockContent->addElement(new htmlImage('../../graphics/tux.png'));
$lockContent->addElement(new htmlTableExtendedInputCheckbox('lam_accountStatusLockUnix', true, _('Unix'), null, false), true); $lockContent->addElement(new htmlTableExtendedInputCheckbox('lam_accountStatusLockUnix', true, _('Unix'), null, false), true);
@ -394,7 +394,7 @@ class user extends baseType {
// unlocking part // unlocking part
if ($partiallyLocked) { if ($partiallyLocked) {
$unlockContent = new htmlTable(); $unlockContent = new htmlTable();
if ($unixAvailable && $unixLocked) { if ($unixAvailable && $unixLocked) {
$unlockContent->addElement(new htmlImage('../../graphics/tux.png')); $unlockContent->addElement(new htmlImage('../../graphics/tux.png'));
$unlockContent->addElement(new htmlTableExtendedInputCheckbox('lam_accountStatusUnlockUnix', true, _('Unix'), null, false), true); $unlockContent->addElement(new htmlTableExtendedInputCheckbox('lam_accountStatusUnlockUnix', true, _('Unix'), null, false), true);
@ -411,30 +411,30 @@ class user extends baseType {
$unlockContent->addElement(new htmlImage('../../graphics/samba.png')); $unlockContent->addElement(new htmlImage('../../graphics/samba.png'));
$unlockContent->addElement(new htmlTableExtendedInputCheckbox('lam_accountStatusUnlockWindows', true, _('Windows'), null, false), true); $unlockContent->addElement(new htmlTableExtendedInputCheckbox('lam_accountStatusUnlockWindows', true, _('Windows'), null, false), true);
} }
$unlockDiv = new htmlDiv('lam_accountStatusDialogUnlockDiv', $unlockContent); $unlockDiv = new htmlDiv('lam_accountStatusDialogUnlockDiv', $unlockContent);
if (!$fullyLocked) { if (!$fullyLocked) {
$unlockDiv->setCSSClasses(array('hidden')); $unlockDiv->setCSSClasses(array('hidden'));
} }
$container->addElement($unlockDiv, true); $container->addElement($unlockDiv, true);
} }
$div = new htmlDiv('lam_accountStatusDialog', $container); $div = new htmlDiv('lam_accountStatusDialog', $container);
$div->setCSSClasses(array('hidden')); $div->setCSSClasses(array('hidden'));
$tabindex = 999; $tabindex = 999;
ob_start(); ob_start();
parseHtml(null, $div, array(), false, $tabindex, 'user'); parseHtml(null, $div, array(), false, $tabindex, 'user');
$output = ob_get_contents(); $output = ob_get_contents();
ob_clean(); ob_clean();
return $output; return $output;
} }
/** /**
* This function is called after the edit page is processed and before the page content is generated. * This function is called after the edit page is processed and before the page content is generated.
* This can be used to run custom handlers after each page processing. * This can be used to run custom handlers after each page processing.
* *
* @param accountContainer $container account container * @param accountContainer $container account container
*/ */
public function runEditPagePostAction(&$container) { public function runEditPagePostAction(&$container) {
@ -488,7 +488,7 @@ class user extends baseType {
} }
} }
} }
} }
/** /**
@ -496,37 +496,37 @@ class user extends baseType {
* *
* @package lists * @package lists
* @author Roland Gruber * @author Roland Gruber
* *
*/ */
class lamUserList extends lamList { class lamUserList extends lamList {
/** Controls if GID number is translated to group name */ /** Controls if GID number is translated to group name */
private $trans_primary = false; private $trans_primary = false;
/** Controls if the account status is shown */ /** Controls if the account status is shown */
private $showAccountStatus = false; private $showAccountStatus = false;
/** translates GID to group name */ /** translates GID to group name */
private $trans_primary_hash = array(); private $trans_primary_hash = array();
/** filter value for account status */ /** filter value for account status */
private $accountStatusFilter = null; private $accountStatusFilter = null;
/** ID for config option to translate primary group GIDs to group names */ /** ID for config option to translate primary group GIDs to group names */
const TRANS_PRIMARY_OPTION_NAME = "LU_TP"; const TRANS_PRIMARY_OPTION_NAME = "LU_TP";
/** ID for config option to show account status */ /** ID for config option to show account status */
const ACCOUNT_STATUS_OPTION_NAME = "LU_AS"; const ACCOUNT_STATUS_OPTION_NAME = "LU_AS";
/** virtual attribute name for account status column */ /** virtual attribute name for account status column */
const ATTR_ACCOUNT_STATUS = 'lam_virtual_account_status'; const ATTR_ACCOUNT_STATUS = 'lam_virtual_account_status';
/** filter value for locked accounts */ /** filter value for locked accounts */
const FILTER_LOCKED = 2; const FILTER_LOCKED = 2;
/** filter value for partially locked accounts */ /** filter value for partially locked accounts */
const FILTER_SEMILOCKED = 3; const FILTER_SEMILOCKED = 3;
/** filter value for unlocked accounts */ /** filter value for unlocked accounts */
const FILTER_UNLOCKED = 4; const FILTER_UNLOCKED = 4;
/** /**
* Constructor * Constructor
* *
@ -541,7 +541,7 @@ class lamUserList extends lamList {
'newEntry' => _("New user"), 'newEntry' => _("New user"),
'deleteEntry' => _("Delete selected users")); 'deleteEntry' => _("Delete selected users"));
} }
/** /**
* Sets some internal parameters. * Sets some internal parameters.
*/ */
@ -550,9 +550,9 @@ class lamUserList extends lamList {
// generate hash table for group translation // generate hash table for group translation
if ($this->trans_primary == "on" && !$this->refresh && (sizeof($this->trans_primary_hash) == 0)) { if ($this->trans_primary == "on" && !$this->refresh && (sizeof($this->trans_primary_hash) == 0)) {
$this->refreshPrimaryGroupTranslation(); $this->refreshPrimaryGroupTranslation();
} }
} }
/** /**
* Rereads the entries from LDAP. * Rereads the entries from LDAP.
*/ */
@ -567,7 +567,7 @@ class lamUserList extends lamList {
$this->injectAccountStatusAttributeAndFilterByStatus(); $this->injectAccountStatusAttributeAndFilterByStatus();
} }
} }
/** /**
* Refreshes the GID to group name cache. * Refreshes the GID to group name cache.
*/ */
@ -617,7 +617,7 @@ class lamUserList extends lamList {
} }
} }
} }
$imgNumber = getRandomNumber(); $imgNumber = getRandomNumber();
$jpeg_filename = 'jpg' . $imgNumber . '.jpg'; $jpeg_filename = 'jpg' . $imgNumber . '.jpg';
$outjpeg = @fopen(dirname(__FILE__) . '/../../tmp/' . $jpeg_filename, "wb"); $outjpeg = @fopen(dirname(__FILE__) . '/../../tmp/' . $jpeg_filename, "wb");
fwrite($outjpeg, $entry[$attribute][0]); fwrite($outjpeg, $entry[$attribute][0]);
@ -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 "";
} }
@ -711,7 +712,7 @@ class lamUserList extends lamList {
$this->forceRefresh(); $this->forceRefresh();
} }
} }
/** /**
* Returns an hash array containing with all attributes to be shown and their descriptions. * Returns an hash array containing with all attributes to be shown and their descriptions.
* <br>Format: array(attribute => description) * <br>Format: array(attribute => description)
@ -727,13 +728,13 @@ class lamUserList extends lamList {
} }
return $list; return $list;
} }
/** /**
* Returns if the given attribute can be filtered. * Returns if the given attribute can be filtered.
* If filtering is not possible then no filter box will be displayed. * If filtering is not possible then no filter box will be displayed.
* <br> * <br>
* <br>The user list allows no filtering for account status. * <br>The user list allows no filtering for account status.
* *
* @param String $attr attribute name * @param String $attr attribute name
* @return boolean filtering possible * @return boolean filtering possible
*/ */
@ -743,10 +744,10 @@ class lamUserList extends lamList {
} }
return true; return true;
} }
/** /**
* Prints the content of a single attribute filter area. * Prints the content of a single attribute filter area.
* *
* @param String $attrName attribute name * @param String $attrName attribute name
* @param boolean $clearFilter true if filter value should be cleared * @param boolean $clearFilter true if filter value should be cleared
*/ */
@ -773,10 +774,10 @@ class lamUserList extends lamList {
$filterInput->setOnchangeEvent('document.getElementsByName(\'apply_filter\')[0].click();'); $filterInput->setOnchangeEvent('document.getElementsByName(\'apply_filter\')[0].click();');
parseHtml(null, $filterInput, array(), false, $this->tabindex, $this->type); parseHtml(null, $filterInput, array(), false, $this->tabindex, $this->type);
} }
/** /**
* Builds the LDAP filter based on the filter entries in the GUI. * Builds the LDAP filter based on the filter entries in the GUI.
* *
* @return String LDAP filter * @return String LDAP filter
*/ */
protected function buildLDAPAttributeFilter() { protected function buildLDAPAttributeFilter() {
@ -791,13 +792,13 @@ class lamUserList extends lamList {
} }
return $text; return $text;
} }
/** /**
* Returns a list of additional LDAP attributes that should be read. * Returns a list of additional LDAP attributes that should be read.
* This can be used to show additional data even if the user selected other attributes to show in the list. * This can be used to show additional data even if the user selected other attributes to show in the list.
* <br> * <br>
* <br>The user list reads pwdAccountLockedTime, sambaAcctFlags and userPassword * <br>The user list reads pwdAccountLockedTime, sambaAcctFlags and userPassword
* *
* @return array additional attribute names * @return array additional attribute names
*/ */
protected function getAdditionalLDAPAttributesToRead() { protected function getAdditionalLDAPAttributesToRead() {
@ -811,7 +812,7 @@ class lamUserList extends lamList {
} }
return $attrs; return $attrs;
} }
/** /**
* Injects values for the virtual account status attribute to make it sortable. * Injects values for the virtual account status attribute to make it sortable.
*/ */
@ -829,11 +830,11 @@ class lamUserList extends lamList {
$hasLocked = ($unixAvailable && $unixLocked) $hasLocked = ($unixAvailable && $unixLocked)
|| ($sambaAvailable && $sambaLocked) || ($sambaAvailable && $sambaLocked)
|| ($ppolicyAvailable && $ppolicyLocked) || ($ppolicyAvailable && $ppolicyLocked)
|| ($windowsAvailable && $windowsLocked); || ($windowsAvailable && $windowsLocked);
$hasUnlocked = ($unixAvailable && !$unixLocked) $hasUnlocked = ($unixAvailable && !$unixLocked)
|| ($sambaAvailable && !$sambaLocked) || ($sambaAvailable && !$sambaLocked)
|| ($ppolicyAvailable && !$ppolicyLocked) || ($ppolicyAvailable && !$ppolicyLocked)
|| ($windowsAvailable && !$windowsLocked); || ($windowsAvailable && !$windowsLocked);
$status = self::FILTER_UNLOCKED; $status = self::FILTER_UNLOCKED;
if ($hasLocked && $hasUnlocked) { if ($hasLocked && $hasUnlocked) {
$status = self::FILTER_SEMILOCKED; $status = self::FILTER_SEMILOCKED;
@ -853,10 +854,10 @@ class lamUserList extends lamList {
} }
$this->entries = array_values($this->entries); $this->entries = array_values($this->entries);
} }
/** /**
* Prints the account status. * Prints the account status.
* *
* @param array $attrs LDAP attributes * @param array $attrs LDAP attributes
*/ */
private function printAccountStatus(&$attrs) { private function printAccountStatus(&$attrs) {
@ -930,84 +931,84 @@ class lamUserList extends lamList {
/** /**
* Returns if the Unix part exists. * Returns if the Unix part exists.
* *
* @param array $attrs LDAP attributes * @param array $attrs LDAP attributes
* @return boolean Unix part exists * @return boolean Unix part exists
*/ */
public static function isUnixAvailable(&$attrs) { public static function isUnixAvailable(&$attrs) {
return (isset($attrs['objectclass']) && in_array_ignore_case('posixAccount', $attrs['objectclass']) && isset($attrs['userpassword'][0])); return (isset($attrs['objectclass']) && in_array_ignore_case('posixAccount', $attrs['objectclass']) && isset($attrs['userpassword'][0]));
} }
/** /**
* Returns if the Unix part is locked. * Returns if the Unix part is locked.
* *
* @param array $attrs LDAP attributes * @param array $attrs LDAP attributes
* @return boolean Unix part locked * @return boolean Unix part locked
*/ */
public static function isUnixLocked(&$attrs) { public static function isUnixLocked(&$attrs) {
return ((isset($attrs['userpassword'][0]) && !pwd_is_enabled($attrs['userpassword'][0]))); return ((isset($attrs['userpassword'][0]) && !pwd_is_enabled($attrs['userpassword'][0])));
} }
/** /**
* Returns if the Samba part exists. * Returns if the Samba part exists.
* *
* @param array $attrs LDAP attributes * @param array $attrs LDAP attributes
* @return boolean Samba part exists * @return boolean Samba part exists
*/ */
public static function isSambaAvailable(&$attrs) { public static function isSambaAvailable(&$attrs) {
return (isset($attrs['objectclass']) && in_array_ignore_case('sambaSamAccount', $attrs['objectclass'])); return (isset($attrs['objectclass']) && in_array_ignore_case('sambaSamAccount', $attrs['objectclass']));
} }
/** /**
* Returns if the Samba part is locked. * Returns if the Samba part is locked.
* *
* @param array $attrs LDAP attributes * @param array $attrs LDAP attributes
* @return boolean Samba part is locked * @return boolean Samba part is locked
*/ */
public static function isSambaLocked(&$attrs) { public static function isSambaLocked(&$attrs) {
return (isset($attrs['sambaacctflags'][0]) && strpos($attrs['sambaacctflags'][0], "D")); return (isset($attrs['sambaacctflags'][0]) && strpos($attrs['sambaacctflags'][0], "D"));
} }
/** /**
* Returns if the PPolicy part exists. * Returns if the PPolicy part exists.
* *
* @param array $attrs LDAP attributes * @param array $attrs LDAP attributes
* @return boolean PPolicy part exists * @return boolean PPolicy part exists
*/ */
public static function isPPolicyAvailable(&$attrs) { public static function isPPolicyAvailable(&$attrs) {
return in_array('ppolicyUser', $_SESSION['config']->get_AccountModules('user')); return in_array('ppolicyUser', $_SESSION['config']->get_AccountModules('user'));
} }
/** /**
* Returns if the PPolicy part is locked. * Returns if the PPolicy part is locked.
* *
* @param array $attrs LDAP attributes * @param array $attrs LDAP attributes
* @return boolean PPolicy part is locked * @return boolean PPolicy part is locked
*/ */
public static function isPPolicyLocked(&$attrs) { public static function isPPolicyLocked(&$attrs) {
return (isset($attrs['pwdaccountlockedtime'][0]) && ($attrs['pwdaccountlockedtime'][0] != '')); return (isset($attrs['pwdaccountlockedtime'][0]) && ($attrs['pwdaccountlockedtime'][0] != ''));
} }
/** /**
* Returns if the Windows part exists. * Returns if the Windows part exists.
* *
* @param array $attrs LDAP attributes * @param array $attrs LDAP attributes
* @return boolean Windows part exists * @return boolean Windows part exists
*/ */
public static function isWindowsAvailable(&$attrs) { public static function isWindowsAvailable(&$attrs) {
return (isset($attrs['objectclass']) && in_array_ignore_case('user', $attrs['objectclass']) && isset($attrs['useraccountcontrol'][0])); return (isset($attrs['objectclass']) && in_array_ignore_case('user', $attrs['objectclass']) && isset($attrs['useraccountcontrol'][0]));
} }
/** /**
* Returns if the Windows part is locked. * Returns if the Windows part is locked.
* *
* @param array $attrs LDAP attributes * @param array $attrs LDAP attributes
* @return boolean Windows part is locked * @return boolean Windows part is locked
*/ */
public static function isWindowsLocked(&$attrs) { public static function isWindowsLocked(&$attrs) {
return windowsUser::isDeactivated($attrs); return windowsUser::isDeactivated($attrs);
} }
} }
?> ?>

View File

@ -228,7 +228,7 @@ echo $_SESSION['header'];
echo _("Edit general settings"); echo _("Edit general settings");
?> ?>
</title> </title>
<?php <?php
// include all CSS files // include all CSS files
$cssDirName = dirname(__FILE__) . '/../../style'; $cssDirName = dirname(__FILE__) . '/../../style';
$cssDir = dir($cssDirName); $cssDir = dir($cssDirName);
@ -479,14 +479,20 @@ parseHtml(null, $globalFieldset, array(), false, $tabindex, 'user');
/** /**
* Formats an LDAP time string (e.g. from createTimestamp). * Formats an LDAP time string (e.g. from createTimestamp).
* *
* @param String $time LDAP time value * @param String $time LDAP time value
* @return String formated time * @return String formated time
*/ */
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 '';
} }