made shadowAccount optional

This commit is contained in:
Roland Gruber 2008-10-21 18:47:45 +00:00
parent 44daea3763
commit b71e0e12a5
1 changed files with 67 additions and 39 deletions

View File

@ -38,6 +38,17 @@ $Id$
*/ */
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,6 +279,11 @@ class shadowAccount extends baseModule {
* @return array meta HTML code * @return array meta HTML code
*/ */
function display_html_attributes() { function display_html_attributes() {
if (isset($_POST['form_subpage_shadowAccount_attributes_addObjectClass'])) {
$this->attributes['objectClass'][] = 'shadowAccount';
}
$return = array();
if (in_array('shadowAccount', $this->attributes['objectClass'])) {
$shWarning = ''; $shWarning = '';
if (isset($this->attributes['shadowWarning'][0])) { if (isset($this->attributes['shadowWarning'][0])) {
$shWarning = $this->attributes['shadowWarning'][0]; $shWarning = $this->attributes['shadowWarning'][0];
@ -302,7 +324,13 @@ class shadowAccount extends baseModule {
array('kind' => 'input', 'name' => 'form_subpage_shadowAccount_expire_open', 'type' => 'submit', 'value' => _('Change')) array('kind' => 'input', 'name' => 'form_subpage_shadowAccount_expire_open', 'type' => 'submit', 'value' => _('Change'))
))), ))),
array('kind' => 'help', 'value' => 'shadowExpire' )); array('kind' => 'help', 'value' => 'shadowExpire' ));
}
else {
$return[] = array(
array('kind' => 'text', 'text' => '&nbsp;'),
array('kind' => 'input', 'type' => 'submit', 'name' => 'form_subpage_shadowAccount_attributes_addObjectClass', 'value' => _('Add Shadow account'))
);
}
return $return; return $return;
} }