Permalink
Browse files

ENHANCEMENT Member->DirectGroups() (to complement Group->DirectMember…

…s(), and aid with relationship saving through Member->getCMSFields())
  • Loading branch information...
1 parent 301c680 commit 79d420f941ec79c9f481c5d4bdeac7913eb7a89c @chillu chillu committed Mar 6, 2012
Showing with 11 additions and 3 deletions.
  1. +11 −3 security/Member.php
View
14 security/Member.php
@@ -939,8 +939,9 @@ public function getTimeFormat() {
/**
- * 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 @@ public function Groups() {
return $groups;
}
+ /**
+ * @return ManyManyList
+ */
+ public function DirectGroups() {
+ return $this->getManyManyComponents('Groups');
+ }
+
/**
* Get member SQLMap
@@ -1138,7 +1146,7 @@ public function getCMSFields() {
$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)
);

0 comments on commit 79d420f

Please sign in to comment.