allow to add a user as memberuid in his primary group
This commit is contained in:
parent
c6c9947dc6
commit
6c40ab33d7
|
@ -178,7 +178,14 @@ class posixAccount extends baseModule {
|
||||||
array('kind' => 'text', 'value' => ' '),
|
array('kind' => 'text', 'value' => ' '),
|
||||||
array('kind' => 'text', 'value' => ' '),
|
array('kind' => 'text', 'value' => ' '),
|
||||||
array('kind' => 'text', 'value' => ' '),
|
array('kind' => 'text', 'value' => ' '),
|
||||||
array('kind' => 'help', 'value' => 'pwdHash'))
|
array('kind' => 'help', 'value' => 'pwdHash')),
|
||||||
|
array(
|
||||||
|
array('kind' => 'text', 'text' => '<b>' . _('Set primary group as memberUid') . ":</b> "),
|
||||||
|
array('kind' => 'input', 'name' => 'posixAccount_primaryGroupAsSecondary', 'type' => 'checkbox'),
|
||||||
|
array('kind' => 'text', 'value' => ' '),
|
||||||
|
array('kind' => 'text', 'value' => ' '),
|
||||||
|
array('kind' => 'text', 'value' => ' '),
|
||||||
|
array('kind' => 'help', 'value' => 'primaryGroupAsSecondary'))
|
||||||
);
|
);
|
||||||
// upload
|
// upload
|
||||||
$return['upload_preDepends'] = array('inetOrgPerson');
|
$return['upload_preDepends'] = array('inetOrgPerson');
|
||||||
|
@ -320,6 +327,10 @@ class posixAccount extends baseModule {
|
||||||
);
|
);
|
||||||
// help Entries
|
// help Entries
|
||||||
$return['help'] = array(
|
$return['help'] = array(
|
||||||
|
'primaryGroupAsSecondary' => array(
|
||||||
|
'Headline' => _('Set primary group as memberUid'),
|
||||||
|
'Text' => _('Usually, users are not added to groups as memberUid if they have this group as primary group. If your application ignores primary groups then you can select this option to override this behaviour.')
|
||||||
|
),
|
||||||
'minMaxUser' => array(
|
'minMaxUser' => array(
|
||||||
'Headline' => _('UID number'),
|
'Headline' => _('UID number'),
|
||||||
'Text' => _('These are the minimum and maximum numbers to use for user IDs when creating new user accounts. The range should be different from that of machines. New user accounts will always get the highest number in use plus one.')
|
'Text' => _('These are the minimum and maximum numbers to use for user IDs when creating new user accounts. The range should be different from that of machines. New user accounts will always get the highest number in use plus one.')
|
||||||
|
@ -488,9 +499,18 @@ class posixAccount extends baseModule {
|
||||||
function save_attributes() {
|
function save_attributes() {
|
||||||
$return = $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig);
|
$return = $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig);
|
||||||
// Remove primary group from additional groups
|
// Remove primary group from additional groups
|
||||||
|
if (!isset($this->moduleSettings['posixAccount_primaryGroupAsSecondary'][0])
|
||||||
|
|| ($this->moduleSettings['posixAccount_primaryGroupAsSecondary'][0] != 'true')) {
|
||||||
for ($i=0; $i<count($this->groups); $i++) {
|
for ($i=0; $i<count($this->groups); $i++) {
|
||||||
if ($this->groups[$i]==$_SESSION['cache']->getgrnam($this->attributes['gidNumber'][0])) unset($this->groups[$i]);
|
if ($this->groups[$i]==$_SESSION['cache']->getgrnam($this->attributes['gidNumber'][0])) unset($this->groups[$i]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// add user as memberuid in primary group
|
||||||
|
if (!in_array($_SESSION['cache']->getgrnam($this->attributes['gidNumber'][0]), $this->groups)) {
|
||||||
|
$this->groups[] = $_SESSION['cache']->getgrnam($this->attributes['gidNumber'][0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Set additional group memberships
|
// Set additional group memberships
|
||||||
if ($this->orig['uid'][0]!='' && $this->attributes['uid'][0]!=$this->orig['uid'][0]) {
|
if ($this->orig['uid'][0]!='' && $this->attributes['uid'][0]!=$this->orig['uid'][0]) {
|
||||||
|
@ -1540,6 +1560,19 @@ class posixAccount extends baseModule {
|
||||||
if (in_array($i, $failed)) continue; // ignore failed accounts
|
if (in_array($i, $failed)) continue; // ignore failed accounts
|
||||||
if ($data[$i][$col] != "") {
|
if ($data[$i][$col] != "") {
|
||||||
$groups = explode(",", $data[$i][$col]);
|
$groups = explode(",", $data[$i][$col]);
|
||||||
|
if (isset($this->moduleSettings['posixAccount_primaryGroupAsSecondary'][0])
|
||||||
|
&& ($this->moduleSettings['posixAccount_primaryGroupAsSecondary'][0] == 'true')) {
|
||||||
|
if (get_preg($data[$i][$ids['posixAccount_group']], 'digit')) {
|
||||||
|
if (!in_array(getgrnam($data[$i][$ids['posixAccount_group']]), $groups)) {
|
||||||
|
$groups[] = getgrnam($data[$i][$ids['posixAccount_group']]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (!in_array(getgrnam($data[$i][$ids['posixAccount_group']]), $groups)) {
|
||||||
|
$groups[] = $data[$i][$ids['posixAccount_group']];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
for ($g = 0; $g < sizeof($groups); $g++) {
|
for ($g = 0; $g < sizeof($groups); $g++) {
|
||||||
if (!in_array($groups[$g], $temp['groups'])) $temp['groups'][] = $groups[$g];
|
if (!in_array($groups[$g], $temp['groups'])) $temp['groups'][] = $groups[$g];
|
||||||
$temp['members'][$groups[$g]][] = $data[$i][$ids['posixAccount_userName']];
|
$temp['members'][$groups[$g]][] = $data[$i][$ids['posixAccount_userName']];
|
||||||
|
|
|
@ -217,35 +217,41 @@ class posixGroup extends baseModule {
|
||||||
// users who can be added have a uid and gidNumber
|
// users who can be added have a uid and gidNumber
|
||||||
if (isset($dn_users[$DNs[$i]]['uid'][0]) && isset($dn_users[$DNs[$i]]['gidNumber'][0]) &&
|
if (isset($dn_users[$DNs[$i]]['uid'][0]) && isset($dn_users[$DNs[$i]]['gidNumber'][0]) &&
|
||||||
// are not already member
|
// are not already member
|
||||||
(!isset($this->attributes['memberUid']) || !in_array($dn_users[$DNs[$i]]['uid'][0], $this->attributes['memberUid'])) &&
|
(!isset($this->attributes['memberUid']) || !in_array($dn_users[$DNs[$i]]['uid'][0], $this->attributes['memberUid']))) {
|
||||||
// and do not have this group as their primary group
|
if ($this->attributes['gidNumber'][0] == $dn_users[$DNs[$i]]['gidNumber'][0]) {
|
||||||
!($this->attributes['gidNumber'][0] == $dn_users[$DNs[$i]]['gidNumber'][0])) {
|
if (isset($this->moduleSettings['posixAccount_primaryGroupAsSecondary'][0])
|
||||||
|
&& ($this->moduleSettings['posixAccount_primaryGroupAsSecondary'][0] == 'true')) {
|
||||||
|
$users[] = $dn_users[$DNs[$i]]['uid'][0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
$users[] = $dn_users[$DNs[$i]]['uid'][0];
|
$users[] = $dn_users[$DNs[$i]]['uid'][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$return[] = array(
|
$return[] = array(
|
||||||
0 => array('kind' => 'fieldset', 'legend' => _("Group members"), 'value' => array (
|
array('kind' => 'fieldset', 'legend' => _("Group members"), 'value' => array (
|
||||||
0 => array(
|
array(
|
||||||
0 => array('kind' => 'fieldset', 'td' => array ('valign' => 'top'), 'legend' => _("Selected users"), 'value' => array (
|
array('kind' => 'fieldset', 'td' => array ('valign' => 'top'), 'legend' => _("Selected users"), 'value' => array (
|
||||||
0 => array(
|
array(
|
||||||
0 => array ( 'kind' => 'select', 'name' => 'removeusers', 'size' => '15', 'multiple' => true, 'options' => $this->attributes['memberUid'])))),
|
array ( 'kind' => 'select', 'name' => 'removeusers', 'size' => '15', 'multiple' => true, 'options' => $this->attributes['memberUid'])))),
|
||||||
1 => array('kind' => 'table', 'value' => array(
|
array('kind' => 'table', 'value' => array(
|
||||||
0 => array(
|
array(
|
||||||
0 => array('kind' => 'input', 'type' => 'submit', 'name' => 'addusers_button', 'value' => '<=', 'td' => array('align' => 'center'))),
|
array('kind' => 'input', 'type' => 'submit', 'name' => 'addusers_button', 'value' => '<=', 'td' => array('align' => 'center'))),
|
||||||
1 => array(
|
array(
|
||||||
0 => array('kind' => 'input', 'type' => 'submit', 'name' => 'removeusers_button', 'value' => '=>', 'td' => array('align' => 'center'))),
|
array('kind' => 'input', 'type' => 'submit', 'name' => 'removeusers_button', 'value' => '=>', 'td' => array('align' => 'center'))),
|
||||||
2 => array(
|
array(
|
||||||
0 => array('kind' => 'help', 'value' => 'members', 'td' => array('align' => 'center'))))),
|
array('kind' => 'help', 'value' => 'members', 'td' => array('align' => 'center'))))),
|
||||||
2 => array('kind' => 'fieldset', 'td' => array('valign' => 'top'), 'legend' => _("Available users"), 'value' => array(
|
array('kind' => 'fieldset', 'td' => array('valign' => 'top'), 'legend' => _("Available users"), 'value' => array(
|
||||||
0 => array(
|
array(
|
||||||
0 => array('kind' => 'select', 'name' => 'addusers', 'size' => '15', 'multiple' => true, 'options' => $users))))
|
array('kind' => 'select', 'name' => 'addusers', 'size' => '15', 'multiple' => true, 'options' => $users))))
|
||||||
))));
|
))));
|
||||||
|
|
||||||
$return[] = array(
|
$return[] = array(
|
||||||
0 => array('kind' => 'input', 'name' => 'form_subpage_posixGroup_attributes_back' ,'type' => 'submit', 'value' => _('Back') ),
|
array('kind' => 'input', 'name' => 'form_subpage_posixGroup_attributes_back' ,'type' => 'submit', 'value' => _('Back') ),
|
||||||
1 => array('kind' => 'text'),
|
array('kind' => 'text'),
|
||||||
2 => array('kind' => 'text'));
|
array('kind' => 'text'));
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue