mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT Member->DirectGroups() (to complement Group->DirectMembers(), and aid with relationship saving through Member->getCMSFields())
This commit is contained in:
parent
301c6801a4
commit
79d420f941
@ -939,8 +939,9 @@ class Member extends DataObject {
|
||||
|
||||
|
||||
/**
|
||||
* Get a "many-to-many" map that holds for all members their group
|
||||
* memberships
|
||||
* Get a "many-to-many" map that holds for all members their group memberships,
|
||||
* including any parent groups where membership is implied.
|
||||
* Use {@link DirectGroups()} to only retrieve the group relations without inheritance.
|
||||
*
|
||||
* @todo Push all this logic into Member_GroupSet's getIterator()?
|
||||
*/
|
||||
@ -953,6 +954,13 @@ class Member extends DataObject {
|
||||
return $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ManyManyList
|
||||
*/
|
||||
public function DirectGroups() {
|
||||
return $this->getManyManyComponents('Groups');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get member SQLMap
|
||||
@ -1138,7 +1146,7 @@ class Member extends DataObject {
|
||||
$groupsMap = DataList::create('Group')->map('ID', 'Breadcrumbs')->toArray();
|
||||
asort($groupsMap);
|
||||
$fields->addFieldToTab('Root.Main',
|
||||
Object::create('ListboxField', 'Groups', singleton('Group')->i18n_plural_name())
|
||||
Object::create('ListboxField', 'DirectGroups', singleton('Group')->i18n_plural_name())
|
||||
->setMultiple(true)->setSource($groupsMap)
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user