From 90eea5c331d0b34777fa58b063e5a5fa1e461747 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Wed, 17 Dec 2008 20:30:56 +0000 Subject: [PATCH] added option to manage description attribute --- lam/lib/modules/posixGroup.inc | 64 ++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/lam/lib/modules/posixGroup.inc b/lam/lib/modules/posixGroup.inc index 989efac0..d6d6d224 100644 --- a/lam/lib/modules/posixGroup.inc +++ b/lam/lib/modules/posixGroup.inc @@ -44,7 +44,9 @@ class posixGroup extends baseModule { /** specifies if the cn attribute should be managed by this module */ protected $manageCnAttribute = true; - + /** specifies if the description attribute should be managed by this module */ + protected $manageDescriptionAttribute = true; + /** * In this function the LDAP account is built up. @@ -83,12 +85,14 @@ class posixGroup extends baseModule { array_push($errMsg, array($i)); $error_messages[] = $errMsg; } - // description (UTF-8, no regex check needed) - if ($rawAccounts[$i][$ids['posixGroup_description']] == "") { - $partialAccounts[$i]['description'] = $partialAccounts[$i]['cn']; - } - else { - $partialAccounts[$i]['description'] = $rawAccounts[$i][$ids['posixGroup_description']]; + if ($this->manageDescriptionAttribute) { + // description (UTF-8, no regex check needed) + if ($rawAccounts[$i][$ids['posixGroup_description']] == "") { + $partialAccounts[$i]['description'] = $partialAccounts[$i]['cn']; + } + else { + $partialAccounts[$i]['description'] = $rawAccounts[$i][$ids['posixGroup_description']]; + } } // group members if ($rawAccounts[$i][$ids['posixGroup_members']] != "") { @@ -168,10 +172,12 @@ class posixGroup extends baseModule { array('kind' => 'text', 'text' => _('GID number').'*'), array('kind' => 'input', 'name' => 'gidNumber', 'type' => 'text', 'size' => '30', 'maxlength' => '20', 'value' => $this->attributes['gidNumber'][0]), array('kind' => 'help', 'value' => 'gidNumber')); - $return[] = array( - array('kind' => 'text', 'text' => _('Description')), - array('kind' => 'input', 'name' => 'description', 'type' => 'text', 'size' => '30', 'maxlength' => '255', 'value' => $this->attributes['description'][0]), - array ('kind' => 'help', 'value' => 'description')); + if ($this->manageDescriptionAttribute) { + $return[] = array( + array('kind' => 'text', 'text' => _('Description')), + array('kind' => 'input', 'name' => 'description', 'type' => 'text', 'size' => '30', 'maxlength' => '255', 'value' => $this->attributes['description'][0]), + array ('kind' => 'help', 'value' => 'description')); + } $return[] = array( array('kind' => 'text', 'text' => _("Group members")), array('kind' => 'input', 'name' => 'form_subpage_' . get_class($this) . '_user_open', 'type' => 'submit', 'value' => _('Edit members')), @@ -345,12 +351,14 @@ class posixGroup extends baseModule { // available PDF fields $return['PDF_fields'] = array( 'gidNumber', - 'memberUid', - 'description' + 'memberUid' ); if ($this->manageCnAttribute) { array_unshift($return['PDF_fields'], 'cn'); } + if ($this->manageDescriptionAttribute) { + $return['PDF_fields'][] = 'description'; + } // upload fields $return['upload_columns'] = array( array( @@ -359,12 +367,6 @@ class posixGroup extends baseModule { 'help' => 'gidNumber', 'example' => '2034' ), - array( - 'name' => 'posixGroup_description', - 'description' => _('Group description'), - 'help' => 'description', - 'example' => _('Administrators group') - ), array( 'name' => 'posixGroup_members', 'description' => _('Group members'), @@ -390,6 +392,16 @@ class posixGroup extends baseModule { ) ); } + if ($this->manageDescriptionAttribute) { + array_unshift($return['upload_columns'], + array( + 'name' => 'posixGroup_description', + 'description' => _('Group description'), + 'help' => 'description', + 'example' => _('Administrators group') + ) + ); + } // help Entries $return['help'] = array( 'gidNumber' => array( @@ -419,14 +431,12 @@ class posixGroup extends baseModule { 'pwdHash' => array( "Headline" => _("Password hash type"), "Text" => _("LAM supports CRYPT, SHA, SSHA, MD5 and SMD5 to generate the hash value of passwords. SSHA and CRYPT are the most common but CRYPT does not support passwords greater than 8 letters. We do not recommend to use plain text passwords.") - ) - ); - if ($this->manageCnAttribute) { - $return['help']['cn'] = array( + ), + 'cn' => array( "Headline" => _("Group name"), "Text" => _("Group name of the group which should be created. Valid characters are: a-z, A-Z, 0-9 and .-_ . LAM does not allow a number as first character because groupadd also does not allow it. If group name is already used group name will be expanded with a number. The next free number will be used.") - ); - } + ) + ); return $return; } @@ -544,7 +554,9 @@ class posixGroup extends baseModule { */ function process_attributes() { $errors = array(); - $this->attributes['description'][0] = $_POST['description']; + if ($this->manageDescriptionAttribute) { + $this->attributes['description'][0] = $_POST['description']; + } if (isset($_POST['form_subpage_' . get_class($this) . '_attributes_lockPassword'])) { $this->attributes['userPassword'][0] = pwd_disable($this->attributes['userPassword'][0]); }