Version: current

     1 <?php
     2 /**
     3  * Extension for the Group object to add subsites support
     4  *
     5  * @package subsites
     6  */
     7 class MemberSubsites extends DataObjectDecorator {
     8
     9     /* Only allow adding to groups we can edit */
    10     public function saveGroups( $groups ) {
    11         $groups = explode( ',', $groups ) ;
    12         $filtered = array() ;
    13         foreach( $groups as $groupID ) {
    14             $group = DataObject::get_by_id('Group', $groupID) ;
    15             if ( $group && $group->canEdit() ) $filtered[] = $groupID ;
    16         }
    17         $this->owner->Groups()->setByIDList( $filtered ) ;
    18     }
    19
    20 }

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -