made shadowAccount optional
This commit is contained in:
parent
44daea3763
commit
b71e0e12a5
|
@ -37,6 +37,17 @@ $Id$
|
||||||
* @package modules
|
* @package modules
|
||||||
*/
|
*/
|
||||||
class shadowAccount extends baseModule {
|
class shadowAccount extends baseModule {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new shadowAccount object.
|
||||||
|
*
|
||||||
|
* @param string $scope account type (user, group, host)
|
||||||
|
*/
|
||||||
|
function __construct($scope) {
|
||||||
|
// call parent constructor
|
||||||
|
parent::__construct($scope);
|
||||||
|
$this->autoAddObjectClasses = false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function builds up the message array.
|
* This function builds up the message array.
|
||||||
|
@ -223,6 +234,9 @@ class shadowAccount extends baseModule {
|
||||||
* <br>"modify" are attributes which have to been modified in LDAP entry
|
* <br>"modify" are attributes which have to been modified in LDAP entry
|
||||||
*/
|
*/
|
||||||
function save_attributes() {
|
function save_attributes() {
|
||||||
|
if (!in_array('shadowAccount', $this->attributes['objectClass'])) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
$return = $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig);
|
$return = $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig);
|
||||||
// Set shadowLastchange manual.
|
// Set shadowLastchange manual.
|
||||||
$clearPwd = $this->getAccountContainer()->getAccountModule('posixAccount')->getClearTextPassword();
|
$clearPwd = $this->getAccountContainer()->getAccountModule('posixAccount')->getClearTextPassword();
|
||||||
|
@ -242,6 +256,9 @@ class shadowAccount extends baseModule {
|
||||||
* @return array list of info/error messages
|
* @return array list of info/error messages
|
||||||
*/
|
*/
|
||||||
function process_attributes() {
|
function process_attributes() {
|
||||||
|
if (!in_array('shadowAccount', $this->attributes['objectClass'])) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
$errors = array();
|
$errors = array();
|
||||||
// Load attributes
|
// Load attributes
|
||||||
$this->attributes['shadowMin'][0] = $_POST['shadowMin'];
|
$this->attributes['shadowMin'][0] = $_POST['shadowMin'];
|
||||||
|
@ -262,47 +279,58 @@ class shadowAccount extends baseModule {
|
||||||
* @return array meta HTML code
|
* @return array meta HTML code
|
||||||
*/
|
*/
|
||||||
function display_html_attributes() {
|
function display_html_attributes() {
|
||||||
$shWarning = '';
|
if (isset($_POST['form_subpage_shadowAccount_attributes_addObjectClass'])) {
|
||||||
if (isset($this->attributes['shadowWarning'][0])) {
|
$this->attributes['objectClass'][] = 'shadowAccount';
|
||||||
$shWarning = $this->attributes['shadowWarning'][0];
|
|
||||||
}
|
}
|
||||||
$return[] = array(
|
$return = array();
|
||||||
array('kind' => 'text', 'text' => _('Password warning')),
|
if (in_array('shadowAccount', $this->attributes['objectClass'])) {
|
||||||
array('kind' => 'input', 'name' => 'shadowWarning', 'type' => 'text', 'size' => '5', 'maxlength' => '4', 'value' => $shWarning),
|
$shWarning = '';
|
||||||
array('kind' => 'help', 'value' => 'shadowWarning'));
|
if (isset($this->attributes['shadowWarning'][0])) {
|
||||||
$shPwdExpiration = '';
|
$shWarning = $this->attributes['shadowWarning'][0];
|
||||||
if (isset($this->attributes['shadowInactive'][0])) $shPwdExpiration = $this->attributes['shadowInactive'][0];
|
}
|
||||||
$return[] = array(
|
$return[] = array(
|
||||||
array('kind' => 'text', 'text' => _('Password expiration')),
|
array('kind' => 'text', 'text' => _('Password warning')),
|
||||||
array('kind' => 'input', 'name' => 'shadowInactive', 'type' => 'text', 'size' => '5', 'maxlength' => '4', 'value' => $shPwdExpiration),
|
array('kind' => 'input', 'name' => 'shadowWarning', 'type' => 'text', 'size' => '5', 'maxlength' => '4', 'value' => $shWarning),
|
||||||
array('kind' => 'help', 'value' => 'shadowInactive'));
|
array('kind' => 'help', 'value' => 'shadowWarning'));
|
||||||
$shMinAge = '';
|
$shPwdExpiration = '';
|
||||||
if (isset($this->attributes['shadowMin'][0])) $shMinAge = $this->attributes['shadowMin'][0];
|
if (isset($this->attributes['shadowInactive'][0])) $shPwdExpiration = $this->attributes['shadowInactive'][0];
|
||||||
$return[] = array(
|
$return[] = array(
|
||||||
array('kind' => 'text', 'text' => _('Minimum password age')),
|
array('kind' => 'text', 'text' => _('Password expiration')),
|
||||||
array('kind' => 'input', 'name' => 'shadowMin', 'type' => 'text', 'size' => '5', 'maxlength' => '5', 'value' => $shMinAge),
|
array('kind' => 'input', 'name' => 'shadowInactive', 'type' => 'text', 'size' => '5', 'maxlength' => '4', 'value' => $shPwdExpiration),
|
||||||
array('kind' => 'help', 'value' => 'shadowMin'));
|
array('kind' => 'help', 'value' => 'shadowInactive'));
|
||||||
$shMaxAge = '';
|
$shMinAge = '';
|
||||||
if (isset($this->attributes['shadowMax'][0])) $shMaxAge = $this->attributes['shadowMax'][0];
|
if (isset($this->attributes['shadowMin'][0])) $shMinAge = $this->attributes['shadowMin'][0];
|
||||||
$return[] = array(
|
$return[] = array(
|
||||||
array('kind' => 'text', 'text' => _('Maximum password age')),
|
array('kind' => 'text', 'text' => _('Minimum password age')),
|
||||||
array('kind' => 'input', 'name' => 'shadowMax', 'type' => 'text', 'size' => '5', 'maxlength' => '5', 'value' => $shMaxAge),
|
array('kind' => 'input', 'name' => 'shadowMin', 'type' => 'text', 'size' => '5', 'maxlength' => '5', 'value' => $shMinAge),
|
||||||
array('kind' => 'help', 'value' => 'shadowMax'));
|
array('kind' => 'help', 'value' => 'shadowMin'));
|
||||||
|
$shMaxAge = '';
|
||||||
$expirationDate = " - ";
|
if (isset($this->attributes['shadowMax'][0])) $shMaxAge = $this->attributes['shadowMax'][0];
|
||||||
if (isset($this->attributes['shadowExpire'][0])) {
|
$return[] = array(
|
||||||
$shAccExpirationDate = $this->attributes['shadowExpire'][0];
|
array('kind' => 'text', 'text' => _('Maximum password age')),
|
||||||
$date = getdate($shAccExpirationDate*3600*24);
|
array('kind' => 'input', 'name' => 'shadowMax', 'type' => 'text', 'size' => '5', 'maxlength' => '5', 'value' => $shMaxAge),
|
||||||
$expirationDate = $date['mday'] . "." . $date['mon'] . "." . $date['year'];
|
array('kind' => 'help', 'value' => 'shadowMax'));
|
||||||
|
|
||||||
|
$expirationDate = " - ";
|
||||||
|
if (isset($this->attributes['shadowExpire'][0])) {
|
||||||
|
$shAccExpirationDate = $this->attributes['shadowExpire'][0];
|
||||||
|
$date = getdate($shAccExpirationDate*3600*24);
|
||||||
|
$expirationDate = $date['mday'] . "." . $date['mon'] . "." . $date['year'];
|
||||||
|
}
|
||||||
|
$return[] = array(
|
||||||
|
array('kind' => 'text', 'text' => _('Account expiration date')),
|
||||||
|
array('kind' => 'table', 'value' => array(array(
|
||||||
|
array('kind' => 'text', 'text' => $expirationDate),
|
||||||
|
array('kind' => 'input', 'name' => 'form_subpage_shadowAccount_expire_open', 'type' => 'submit', 'value' => _('Change'))
|
||||||
|
))),
|
||||||
|
array('kind' => 'help', 'value' => 'shadowExpire' ));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$return[] = array(
|
||||||
|
array('kind' => 'text', 'text' => ' '),
|
||||||
|
array('kind' => 'input', 'type' => 'submit', 'name' => 'form_subpage_shadowAccount_attributes_addObjectClass', 'value' => _('Add Shadow account'))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$return[] = array(
|
|
||||||
array('kind' => 'text', 'text' => _('Account expiration date')),
|
|
||||||
array('kind' => 'table', 'value' => array(array(
|
|
||||||
array('kind' => 'text', 'text' => $expirationDate),
|
|
||||||
array('kind' => 'input', 'name' => 'form_subpage_shadowAccount_expire_open', 'type' => 'submit', 'value' => _('Change'))
|
|
||||||
))),
|
|
||||||
array('kind' => 'help', 'value' => 'shadowExpire' ));
|
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue