Unverified Commit b4bd278c authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:sparkles: feat(ogroup) Detect member types from subgroups

This means a group of group of users will have user tabs.
This is not dynamically updated when editing a member, meaning if group1
 contains group2 which contains users, removing all users from group2
 will not update group1 gosaGroupObjects field, which will still
 contain U until group1 is open and saved.
This seems like a small problem as most of the time this type detection
 is mainly useful to know which tabs to show, so when the object is
 open.
It may be added later.

issue #5818
Showing with 29 additions and 1 deletion
+29 -1
......@@ -23,11 +23,13 @@
class GroupMembersAttribute extends ObjectsAttribute
{
protected $typeToCodeMap;
protected $childTypes;
function __construct ($label, $description, $ldapName, $required = FALSE, $defaultValue = [], $store_attr = 'dn', $display_attr = 'cn', array $filterElementDefinitions = NULL, $acl = '')
{
parent::__construct($label, $description, $ldapName, $required, array_values(ogroup::$objectTypes), $defaultValue, $store_attr, $display_attr, $filterElementDefinitions, $acl);
$this->typeToCodeMap = array_flip(array_map('strtolower', ogroup::$objectTypes));
$this->selectManagementParameters[2]['gosaGroupObjects'] = '*';
}
function getFilterBlackList ()
......@@ -50,7 +52,15 @@ class GroupMembersAttribute extends ObjectsAttribute
{
/* Refresh types and displays */
$this->getDisplayValues();
return '['.implode('', array_map([$this, 'typeToCode'], array_unique($this->types))).']';
/* Merge all object types codes and all child types */
$codes = array_unique(
array_merge(
array_map([$this, 'typeToCode'], array_unique($this->types)),
str_split(preg_replace('/[^a-z]/i', '', implode('', $this->childTypes)))
)
);
sort($codes);
return '['.implode('', $codes).']';
}
function getTypedValues ()
......@@ -67,4 +77,22 @@ class GroupMembersAttribute extends ObjectsAttribute
return $ret;
}
protected function fillDisplayValueFrom ($i, $attrs)
{
parent::fillDisplayValueFrom($i, $attrs);
$this->childTypes[$i] = ($attrs['gosaGroupObjects'][0] ?? '');
}
function setValue ($value)
{
$this->childTypes = [];
parent::setValue($value);
}
protected function removeValue ($row)
{
parent::removeValue($row);
unset($this->childTypes[$row]);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment