support subtypes

This commit is contained in:
Roland Gruber 2018-02-25 10:32:06 +01:00
parent 596355e959
commit 351735e073
1 changed files with 22 additions and 21 deletions

View File

@ -58,6 +58,7 @@ class posixGroup extends baseModule implements passwordService {
*/ */
function get_uploadColumns($selectedModules, &$type) { function get_uploadColumns($selectedModules, &$type) {
$return = parent::get_uploadColumns($selectedModules, $type); $return = parent::get_uploadColumns($selectedModules, $type);
$typeId = $type->getId();
if ($this->manageCnAndDescription($selectedModules)) { if ($this->manageCnAndDescription($selectedModules)) {
array_unshift($return, array_unshift($return,
array( array(
@ -78,6 +79,14 @@ class posixGroup extends baseModule implements passwordService {
) )
); );
} }
if (!$this->isBooleanConfigOptionSet('posixGroup_' . $typeId . '_hidememberUid')) {
$return[] = array(
'name' => 'posixGroup_members',
'description' => _('Group members'),
'help' => 'upload_members',
'example' => _('user01,user02,user03')
);
}
return $return; return $return;
} }
@ -88,6 +97,7 @@ class posixGroup extends baseModule implements passwordService {
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules, &$type) { function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules, &$type) {
$error_messages = array(); $error_messages = array();
$needAutoGID = array(); $needAutoGID = array();
$typeId = $type->getId();
for ($i = 0; $i < sizeof($rawAccounts); $i++) { for ($i = 0; $i < sizeof($rawAccounts); $i++) {
if (!in_array("posixGroup", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "posixGroup"; if (!in_array("posixGroup", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "posixGroup";
if ($this->manageCnAndDescription($selectedModules)) { if ($this->manageCnAndDescription($selectedModules)) {
@ -117,7 +127,7 @@ class posixGroup extends baseModule implements passwordService {
} }
} }
// group members // group members
if (!$this->isBooleanConfigOptionSet('posixGroup_hidememberUid') && ($rawAccounts[$i][$ids['posixGroup_members']] != "")) { if (!$this->isBooleanConfigOptionSet('posixGroup_' . $typeId . '_hidememberUid') && ($rawAccounts[$i][$ids['posixGroup_members']] != "")) {
if (get_preg($rawAccounts[$i][$ids['posixGroup_members']], 'usernameList')) { if (get_preg($rawAccounts[$i][$ids['posixGroup_members']], 'usernameList')) {
$partialAccounts[$i]['memberUid'] = explode(",", $rawAccounts[$i][$ids['posixGroup_members']]); $partialAccounts[$i]['memberUid'] = explode(",", $rawAccounts[$i][$ids['posixGroup_members']]);
} }
@ -187,9 +197,10 @@ class posixGroup extends baseModule implements passwordService {
function display_html_attributes() { function display_html_attributes() {
$return = new htmlTable(); $return = new htmlTable();
$modules = $this->getAccountContainer()->get_type()->getModules(); $modules = $this->getAccountContainer()->get_type()->getModules();
$typeId = $this->getAccountContainer()->get_type()->getId();
if ($this->autoAddObjectClasses || (isset($this->attributes['objectClass']) && in_array('posixGroup', $this->attributes['objectClass']))) { if ($this->autoAddObjectClasses || (isset($this->attributes['objectClass']) && in_array('posixGroup', $this->attributes['objectClass']))) {
// auto sync group members // auto sync group members
if ($this->isBooleanConfigOptionSet('posixGroup_autoSyncGon')) { if ($this->isBooleanConfigOptionSet('posixGroup_' . $typeId . '_autoSyncGon')) {
$this->syncGon(); $this->syncGon();
} }
// group name // group name
@ -238,9 +249,9 @@ class posixGroup extends baseModule implements passwordService {
$return->addElement(new htmlTableExtendedInputCheckbox('changegids', $this->changegids, _('Change GID number of users and hosts'), 'changegids'), true); $return->addElement(new htmlTableExtendedInputCheckbox('changegids', $this->changegids, _('Change GID number of users and hosts'), 'changegids'), true);
} }
// group members // group members
if (!$this->isBooleanConfigOptionSet('posixGroup_hidememberUid')) { if (!$this->isBooleanConfigOptionSet('posixGroup_' . $typeId . '_hidememberUid')) {
$return->addElement(new htmlOutputText(_("Group members"))); $return->addElement(new htmlOutputText(_("Group members")));
if (!$this->isBooleanConfigOptionSet('posixGroup_autoSyncGon')) { if (!$this->isBooleanConfigOptionSet('posixGroup_' . $typeId . '_autoSyncGon')) {
$return->addElement(new htmlAccountPageButton(get_class($this), 'user', 'open', _('Edit members'))); $return->addElement(new htmlAccountPageButton(get_class($this), 'user', 'open', _('Edit members')));
} }
else { else {
@ -418,10 +429,7 @@ class posixGroup extends baseModule implements passwordService {
// LDAP aliases // LDAP aliases
$return['LDAPaliases'] = array('commonName' => 'cn'); $return['LDAPaliases'] = array('commonName' => 'cn');
// managed attributes // managed attributes
$return['attributes'] = array('gidNumber', $this->passwordAttrName); $return['attributes'] = array('gidNumber', $this->passwordAttrName, 'memberUid');
if (!$this->isBooleanConfigOptionSet('posixGroup_hidememberUid')) {
$return['attributes'][] = 'memberUid';
}
// profile options // profile options
if (!$this->autoAddObjectClasses) { if (!$this->autoAddObjectClasses) {
$profileContainer = new htmlTable(); $profileContainer = new htmlTable();
@ -432,10 +440,6 @@ class posixGroup extends baseModule implements passwordService {
$return['PDF_fields'] = array( $return['PDF_fields'] = array(
'gidNumber' => _('GID number'), 'gidNumber' => _('GID number'),
); );
if (!$this->isBooleanConfigOptionSet('posixGroup_hidememberUid')) {
$return['PDF_fields']['memberUid'] = _('Group members');
$return['PDF_fields']['memberUidPrimary'] = _('Group members (incl. primary members)');
}
// upload fields // upload fields
$return['upload_columns'] = array( $return['upload_columns'] = array(
array( array(
@ -451,14 +455,6 @@ class posixGroup extends baseModule implements passwordService {
'example' => _('secret') 'example' => _('secret')
) )
); );
if (!$this->isBooleanConfigOptionSet('posixGroup_hidememberUid')) {
$return['upload_columns'][] = array(
'name' => 'posixGroup_members',
'description' => _('Group members'),
'help' => 'upload_members',
'example' => _('user01,user02,user03')
);
}
// help Entries // help Entries
$return['help'] = array( $return['help'] = array(
'gidNumber' => array( 'gidNumber' => array(
@ -683,6 +679,10 @@ class posixGroup extends baseModule implements passwordService {
$fields['cn'] = _('Group name'); $fields['cn'] = _('Group name');
$fields['description'] = _('Description'); $fields['description'] = _('Description');
} }
if (!$this->isBooleanConfigOptionSet('posixGroup_' . $typeId . '_hidememberUid')) {
$fields['memberUid'] = _('Group members');
$fields['memberUidPrimary'] = _('Group members (incl. primary members)');
}
return $fields; return $fields;
} }
@ -1047,7 +1047,8 @@ class posixGroup extends baseModule implements passwordService {
return array(); return array();
} }
// auto sync group members // auto sync group members
if ($this->isBooleanConfigOptionSet('posixGroup_autoSyncGon')) { $typeId = $this->getAccountContainer()->get_type()->getId();
if ($this->isBooleanConfigOptionSet('posixGroup_' . $typeId . '_autoSyncGon')) {
$this->syncGon(); $this->syncGon();
} }
$return = $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig); $return = $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig);