added option to manage description attribute

This commit is contained in:
Roland Gruber 2008-12-17 20:30:56 +00:00
parent 4e6fbcc839
commit 90eea5c331
1 changed files with 38 additions and 26 deletions

View File

@ -44,6 +44,8 @@ class posixGroup extends baseModule {
/** specifies if the cn attribute should be managed by this module */ /** specifies if the cn attribute should be managed by this module */
protected $manageCnAttribute = true; protected $manageCnAttribute = true;
/** specifies if the description attribute should be managed by this module */
protected $manageDescriptionAttribute = true;
/** /**
@ -83,6 +85,7 @@ class posixGroup extends baseModule {
array_push($errMsg, array($i)); array_push($errMsg, array($i));
$error_messages[] = $errMsg; $error_messages[] = $errMsg;
} }
if ($this->manageDescriptionAttribute) {
// description (UTF-8, no regex check needed) // description (UTF-8, no regex check needed)
if ($rawAccounts[$i][$ids['posixGroup_description']] == "") { if ($rawAccounts[$i][$ids['posixGroup_description']] == "") {
$partialAccounts[$i]['description'] = $partialAccounts[$i]['cn']; $partialAccounts[$i]['description'] = $partialAccounts[$i]['cn'];
@ -90,6 +93,7 @@ class posixGroup extends baseModule {
else { else {
$partialAccounts[$i]['description'] = $rawAccounts[$i][$ids['posixGroup_description']]; $partialAccounts[$i]['description'] = $rawAccounts[$i][$ids['posixGroup_description']];
} }
}
// group members // group members
if ($rawAccounts[$i][$ids['posixGroup_members']] != "") { if ($rawAccounts[$i][$ids['posixGroup_members']] != "") {
if (get_preg($rawAccounts[$i][$ids['posixGroup_members']], 'usernameList')) { if (get_preg($rawAccounts[$i][$ids['posixGroup_members']], 'usernameList')) {
@ -168,10 +172,12 @@ class posixGroup extends baseModule {
array('kind' => 'text', 'text' => _('GID number').'*'), array('kind' => 'text', 'text' => _('GID number').'*'),
array('kind' => 'input', 'name' => 'gidNumber', 'type' => 'text', 'size' => '30', 'maxlength' => '20', 'value' => $this->attributes['gidNumber'][0]), array('kind' => 'input', 'name' => 'gidNumber', 'type' => 'text', 'size' => '30', 'maxlength' => '20', 'value' => $this->attributes['gidNumber'][0]),
array('kind' => 'help', 'value' => 'gidNumber')); array('kind' => 'help', 'value' => 'gidNumber'));
if ($this->manageDescriptionAttribute) {
$return[] = array( $return[] = array(
array('kind' => 'text', 'text' => _('Description')), array('kind' => 'text', 'text' => _('Description')),
array('kind' => 'input', 'name' => 'description', 'type' => 'text', 'size' => '30', 'maxlength' => '255', 'value' => $this->attributes['description'][0]), array('kind' => 'input', 'name' => 'description', 'type' => 'text', 'size' => '30', 'maxlength' => '255', 'value' => $this->attributes['description'][0]),
array ('kind' => 'help', 'value' => 'description')); array ('kind' => 'help', 'value' => 'description'));
}
$return[] = array( $return[] = array(
array('kind' => 'text', 'text' => _("Group members")), array('kind' => 'text', 'text' => _("Group members")),
array('kind' => 'input', 'name' => 'form_subpage_' . get_class($this) . '_user_open', 'type' => 'submit', 'value' => _('Edit 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 // available PDF fields
$return['PDF_fields'] = array( $return['PDF_fields'] = array(
'gidNumber', 'gidNumber',
'memberUid', 'memberUid'
'description'
); );
if ($this->manageCnAttribute) { if ($this->manageCnAttribute) {
array_unshift($return['PDF_fields'], 'cn'); array_unshift($return['PDF_fields'], 'cn');
} }
if ($this->manageDescriptionAttribute) {
$return['PDF_fields'][] = 'description';
}
// upload fields // upload fields
$return['upload_columns'] = array( $return['upload_columns'] = array(
array( array(
@ -359,12 +367,6 @@ class posixGroup extends baseModule {
'help' => 'gidNumber', 'help' => 'gidNumber',
'example' => '2034' 'example' => '2034'
), ),
array(
'name' => 'posixGroup_description',
'description' => _('Group description'),
'help' => 'description',
'example' => _('Administrators group')
),
array( array(
'name' => 'posixGroup_members', 'name' => 'posixGroup_members',
'description' => _('Group 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 // help Entries
$return['help'] = array( $return['help'] = array(
'gidNumber' => array( 'gidNumber' => array(
@ -419,14 +431,12 @@ class posixGroup extends baseModule {
'pwdHash' => array( 'pwdHash' => array(
"Headline" => _("Password hash type"), "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.") "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.")
) ),
); 'cn' => array(
if ($this->manageCnAttribute) {
$return['help']['cn'] = array(
"Headline" => _("Group name"), "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.") "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; return $return;
} }
@ -544,7 +554,9 @@ class posixGroup extends baseModule {
*/ */
function process_attributes() { function process_attributes() {
$errors = array(); $errors = array();
if ($this->manageDescriptionAttribute) {
$this->attributes['description'][0] = $_POST['description']; $this->attributes['description'][0] = $_POST['description'];
}
if (isset($_POST['form_subpage_' . get_class($this) . '_attributes_lockPassword'])) { if (isset($_POST['form_subpage_' . get_class($this) . '_attributes_lockPassword'])) {
$this->attributes['userPassword'][0] = pwd_disable($this->attributes['userPassword'][0]); $this->attributes['userPassword'][0] = pwd_disable($this->attributes['userPassword'][0]);
} }