allow to sync expiration date (RFE 3147751)

This commit is contained in:
Roland Gruber 2011-02-24 19:30:00 +00:00
parent a162f9f654
commit 8fa551882b
3 changed files with 64 additions and 7 deletions

View File

@ -3,6 +3,7 @@ April 2011 3.4.0
- Personal: added additional options for account profiles - Personal: added additional options for account profiles
- Mail aliases: sort receipients (RFE 3170336) - Mail aliases: sort receipients (RFE 3170336)
- Asterisk: support AstAccountType attribute - Asterisk: support AstAccountType attribute
- Samba 3/Shadow: allow to sync expiration date (RFE 3147751)
- LAM Pro: - LAM Pro:
-> support automount entries -> support automount entries
-> Zarafa groups: allow combination with group of names -> Zarafa groups: allow combination with group of names

View File

@ -4,7 +4,7 @@ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2006 Tilo Lutz Copyright (C) 2003 - 2006 Tilo Lutz
2005 - 2010 Roland Gruber 2005 - 2011 Roland Gruber
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -970,12 +970,19 @@ class sambaSamAccount extends baseModule implements passwordService {
// determine action // determine action
if (strpos($buttonName, '_change') !== false) { if (strpos($buttonName, '_change') !== false) {
// set new time // set new time
$this->attributes[$attr][0] = gmmktime(0, 0, 0, intval($_POST['expire_mon']), intval($_POST['expire_day']), $this->setExpirationDate($_POST['expire_yea'], $_POST['expire_mon'], $_POST['expire_day']);
intval($_POST['expire_yea'])); if (isset($_POST['syncShadow']) && ($_POST['syncShadow'] == 'on')) {
$this->getAccountContainer()->getAccountModule('shadowAccount')->setExpirationDate(
$_POST['expire_yea'], $_POST['expire_mon'], $_POST['expire_day']);
}
} }
elseif (strpos($buttonName, '_del') !== false) { elseif (strpos($buttonName, '_del') !== false) {
// remove attribute value // remove attribute value
unset($this->attributes[$attr]); unset($this->attributes[$attr]);
if (isset($_POST['syncShadow']) && ($_POST['syncShadow'] == 'on')) {
$this->getAccountContainer()->getAccountModule('shadowAccount')->setExpirationDate(
null, null, null);
}
} }
return $return; return $return;
} }
@ -1352,12 +1359,16 @@ class sambaSamAccount extends baseModule implements passwordService {
$date = getdate($time); $date = getdate($time);
for ( $i=1; $i<=31; $i++ ) $mday[] = $i; for ( $i=1; $i<=31; $i++ ) $mday[] = $i;
for ( $i=1; $i<=12; $i++ ) $mon[] = $i; for ( $i=1; $i<=12; $i++ ) $mon[] = $i;
for ( $i=2003; $i<=2030; $i++ ) $year[] = $i; for ( $i=2003; $i<=2050; $i++ ) $year[] = $i;
$return->addElement(new htmlOutputText($text)); $return->addElement(new htmlOutputText($text));
$return->addElement(new htmlSelect('expire_day', $mday, array($date['mday']))); $return->addElement(new htmlSelect('expire_day', $mday, array($date['mday'])));
$return->addElement(new htmlSelect('expire_mon', $mon, array($date['mon']))); $return->addElement(new htmlSelect('expire_mon', $mon, array($date['mon'])));
$return->addElement(new htmlSelect('expire_yea', $year, array($date['year']))); $return->addElement(new htmlSelect('expire_yea', $year, array($date['year'])));
$return->addElement(new htmlHelpLink($help), true); $return->addElement(new htmlHelpLink($help), true);
if ($this->getAccountContainer()->getAccountModule('shadowAccount') != null) {
$return->addElement(new htmlTableExtendedInputCheckbox('syncShadow', false, _('Set also for Shadow')), true);
}
$return->addElement(new htmlSpacer(null, '10px'), true);
$buttons = new htmlTable(); $buttons = new htmlTable();
$buttons->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'change' . $attr, _('Change'))); $buttons->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'change' . $attr, _('Change')));
if (isset($this->attributes[$attr][0])) { if (isset($this->attributes[$attr][0])) {
@ -2237,6 +2248,23 @@ class sambaSamAccount extends baseModule implements passwordService {
return $this->cachedDomainList; return $this->cachedDomainList;
} }
/**
* Sets the expiration date of this account.
* If all parameters are null the expiration date will be removed.
*
* @param String $year year (e.g. 2040)
* @param String $month month (e.g. 8)
* @param String $day day (e.g. 27)
*/
public function setExpirationDate($year, $month, $day) {
if (($year == null) && ($month == null) && ($day == null)) {
unset($this->attributes['sambaKickoffTime']);
return;
}
$this->attributes['sambaKickoffTime'][0] = gmmktime(0, 0, 0, intval($month), intval($day),
intval($year));
}
} }
?> ?>

View File

@ -376,12 +376,19 @@ class shadowAccount extends baseModule implements passwordService {
$errors = array(); $errors = array();
// set expiration date // set expiration date
if (isset($_POST['form_subpage_shadowAccount_attributes_change'])) { if (isset($_POST['form_subpage_shadowAccount_attributes_change'])) {
$this->attributes['shadowExpire'][0] = intval(gmmktime(0, 0, 0, intval($_POST['shadowExpire_mon']), intval($_POST['shadowExpire_day']), $this->setExpirationDate($_POST['shadowExpire_yea'], $_POST['shadowExpire_mon'], $_POST['shadowExpire_day']);
intval($_POST['shadowExpire_yea']))/3600/24); if (isset($_POST['syncSamba']) && ($_POST['syncSamba'] == 'on')) {
$this->getAccountContainer()->getAccountModule('sambaSamAccount')->setExpirationDate(
$_POST['shadowExpire_yea'], $_POST['shadowExpire_mon'], $_POST['shadowExpire_day']);
}
} }
// remove expiration date // remove expiration date
elseif (isset($_POST['form_subpage_shadowAccount_attributes_del'])) { elseif (isset($_POST['form_subpage_shadowAccount_attributes_del'])) {
unset($this->attributes['shadowExpire']); unset($this->attributes['shadowExpire']);
if (isset($_POST['syncSamba']) && ($_POST['syncSamba'] == 'on')) {
$this->getAccountContainer()->getAccountModule('sambaSamAccount')->setExpirationDate(
null, null, null);
}
} }
return $errors; return $errors;
} }
@ -400,7 +407,7 @@ class shadowAccount extends baseModule implements passwordService {
$date = getdate($shAccExpirationDate*3600*24); $date = getdate($shAccExpirationDate*3600*24);
for ( $i=1; $i<=31; $i++ ) $mday[] = $i; for ( $i=1; $i<=31; $i++ ) $mday[] = $i;
for ( $i=1; $i<=12; $i++ ) $mon[] = $i; for ( $i=1; $i<=12; $i++ ) $mon[] = $i;
for ( $i=2003; $i<=2030; $i++ ) $year[] = $i; for ( $i=2003; $i<=2050; $i++ ) $year[] = $i;
$return->addElement(new htmlOutputText(_('Account expiration date'))); $return->addElement(new htmlOutputText(_('Account expiration date')));
$expTable = new htmlTable(); $expTable = new htmlTable();
$expTable->addElement(new htmlSelect('shadowExpire_day', $mday, array($date['mday']))); $expTable->addElement(new htmlSelect('shadowExpire_day', $mday, array($date['mday'])));
@ -408,6 +415,10 @@ class shadowAccount extends baseModule implements passwordService {
$expTable->addElement(new htmlSelect('shadowExpire_yea', $year, array($date['year']))); $expTable->addElement(new htmlSelect('shadowExpire_yea', $year, array($date['year'])));
$return->addElement($expTable); $return->addElement($expTable);
$return->addElement(new htmlHelpLink('shadowExpire'), true); $return->addElement(new htmlHelpLink('shadowExpire'), true);
if ($this->getAccountContainer()->getAccountModule('sambaSamAccount') != null) {
$return->addElement(new htmlTableExtendedInputCheckbox('syncSamba', false, _('Set also for Samba 3')), true);
}
$return->addElement(new htmlSpacer(null, '10px'), true);
$buttonTable = new htmlTable(); $buttonTable = new htmlTable();
$buttonTable->addElement(new htmlAccountPageButton('shadowAccount', 'attributes', 'change', _('Change'))); $buttonTable->addElement(new htmlAccountPageButton('shadowAccount', 'attributes', 'change', _('Change')));
if (isset($this->attributes['shadowExpire'][0])) { if (isset($this->attributes['shadowExpire'][0])) {
@ -597,6 +608,23 @@ class shadowAccount extends baseModule implements passwordService {
return array(); return array();
} }
/**
* Sets the expiration date of this account.
* If all parameters are null the expiration date will be removed.
*
* @param String $year year (e.g. 2040)
* @param String $month month (e.g. 8)
* @param String $day day (e.g. 27)
*/
public function setExpirationDate($year, $month, $day) {
if (($year == null) && ($month == null) && ($day == null)) {
unset($this->attributes['shadowExpire']);
return;
}
$this->attributes['shadowExpire'][0] = intval(gmmktime(0, 0, 0, intval($month), intval($day),
intval($year))/3600/24);
}
} }
?> ?>