support Samba 4
This commit is contained in:
parent
a3a911f4ed
commit
f665ef3425
|
@ -91,8 +91,8 @@ abstract class baseModule {
|
|||
// initialize module
|
||||
$this->scope = $scope;
|
||||
$this->load_Messages();
|
||||
$this->meta = $this->get_metaData();
|
||||
$this->autoAddObjectClasses = true;
|
||||
$this->meta = $this->get_metaData();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -169,6 +169,7 @@ class posixGroup extends baseModule implements passwordService {
|
|||
*/
|
||||
function display_html_attributes() {
|
||||
$return = new htmlTable();
|
||||
if ($this->autoAddObjectClasses || (isset($this->attributes['objectClass']) && in_array('posixGroup', $this->attributes['objectClass']))) {
|
||||
// group name
|
||||
if ($this->manageCnAttribute) {
|
||||
$cn = '';
|
||||
|
@ -235,6 +236,18 @@ class posixGroup extends baseModule implements passwordService {
|
|||
natcasesort($members);
|
||||
$members = array_map('htmlspecialchars', $members);
|
||||
$return->addElement(new htmlOutputText(implode('<br>', $members), false), true);
|
||||
// remove button
|
||||
if (!$this->autoAddObjectClasses) {
|
||||
$return->addElement(new htmlSpacer(null, '20px'), true);
|
||||
$remButton = new htmlButton('remObjectClass', _('Remove Unix extension'));
|
||||
$remButton->colspan = 5;
|
||||
$return->addElement($remButton);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// add button
|
||||
$return->addElement(new htmlButton('addObjectClass', _('Add Unix extension')));
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
@ -357,6 +370,12 @@ class posixGroup extends baseModule implements passwordService {
|
|||
$return['LDAPaliases'] = array('commonName' => 'cn');
|
||||
// managed attributes
|
||||
$return['attributes'] = array('cn', 'gidNumber', 'userPassword', 'memberUid', 'description');
|
||||
// profile options
|
||||
if (!$this->autoAddObjectClasses) {
|
||||
$profileContainer = new htmlTable();
|
||||
$profileContainer->addElement(new htmlTableExtendedInputCheckbox('posixGroup_addExt', false, _('Automatically add this extension'), 'autoAdd'), true);
|
||||
$return['profile_options'] = $profileContainer;
|
||||
}
|
||||
// configuration options
|
||||
$configContainer = new htmlTable();
|
||||
$configContainer->addElement(new htmlSubTitle(_("Groups")), true);
|
||||
|
@ -485,6 +504,10 @@ class posixGroup extends baseModule implements passwordService {
|
|||
"Text" => _("Here you can enter a filter value. Only entries which contain the filter text will be shown.")
|
||||
. ' ' . _('Possible wildcards are: "*" = any character, "^" = line start, "$" = line end')
|
||||
),
|
||||
'autoAdd' => array(
|
||||
"Headline" => _("Automatically add this extension"),
|
||||
"Text" => _("This will enable the extension automatically if this profile is loaded.")
|
||||
),
|
||||
);
|
||||
|
||||
return $return;
|
||||
|
@ -606,6 +629,29 @@ class posixGroup extends baseModule implements passwordService {
|
|||
*/
|
||||
function process_attributes() {
|
||||
$errors = array();
|
||||
if (isset($_POST['addObjectClass'])) {
|
||||
if (!isset($this->attributes['objectClass'])) {
|
||||
$this->attributes['objectClass'] = array();
|
||||
}
|
||||
if (!in_array('posixGroup', $this->attributes['objectClass'])) {
|
||||
$this->attributes['objectClass'][] = 'posixGroup';
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
if (isset($_POST['remObjectClass'])) {
|
||||
$this->attributes['objectClass'] = array_delete(array('posixGroup'), $this->attributes['objectClass']);
|
||||
$attrs = $this->getManagedAttributes();
|
||||
foreach ($attrs as $name) {
|
||||
if (isset($this->attributes[$name])) {
|
||||
unset($this->attributes[$name]);
|
||||
}
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
// skip processing if object class is not set
|
||||
if (!$this->autoAddObjectClasses && (!isset($this->attributes['objectClass']) || !in_array('posixGroup', $this->attributes['objectClass']))) {
|
||||
return $errors;
|
||||
}
|
||||
if ($this->manageDescriptionAttribute) {
|
||||
$this->attributes['description'][0] = $_POST['description'];
|
||||
}
|
||||
|
@ -759,7 +805,11 @@ class posixGroup extends baseModule implements passwordService {
|
|||
*/
|
||||
function save_attributes() {
|
||||
// skip saving if account is based on another structural object class
|
||||
if (!$this->getAccountContainer()->isNewAccount && !in_array('posixGroup', $this->getAccountContainer()->attributes_orig['objectClass'])) {
|
||||
if ($this->is_base_module() && !$this->getAccountContainer()->isNewAccount && !in_array('posixGroup', $this->getAccountContainer()->attributes_orig['objectClass'])) {
|
||||
return array();
|
||||
}
|
||||
if (!in_array('posixGroup', $this->attributes['objectClass']) && !in_array('posixGroup', $this->orig['objectClass'])) {
|
||||
// skip saving if the extension was not added/modified
|
||||
return array();
|
||||
}
|
||||
$return = $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig);
|
||||
|
@ -776,6 +826,22 @@ class posixGroup extends baseModule implements passwordService {
|
|||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the values of an account profile into internal variables.
|
||||
*
|
||||
* @param array $profile hash array with profile values (identifier => value)
|
||||
*/
|
||||
function load_profile($profile) {
|
||||
// profile mappings in meta data
|
||||
parent::load_profile($profile);
|
||||
// add extension
|
||||
if (isset($profile['posixGroup_addExt'][0]) && ($profile['posixGroup_addExt'][0] == "true")) {
|
||||
if (!in_array('posixGroup', $this->attributes['objectClass'])) {
|
||||
$this->attributes['objectClass'][] = 'posixGroup';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks input values of module settings.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue