src/Pages/MemberProfileViewer.php
public function handleList($request)
    {
        $parent = $this->getParent();
        $fields  = $parent->Fields()->filter('MemberListVisible', true);

        $groups = $parent->Groups();
        if ($groups->count() > 0) {
            $members = $groups->relation('Members');
        } else {
            $members = Member::get();
            // NOTE(Jake): 2018-05-02
            //
            // We may want to enable a flag so that ADMIN users are automatically omitted from this list
            // by default.
            //
            //$members = $members->filter('ID:not', Permission::get_members_by_permission('ADMIN')->map('ID', 'ID')->toArray());
        }
        $members = PaginatedList::create($members, $request);

        $list = new ArrayList();
        foreach ($members as $member) {
            $cols   = new ArrayList();
            $public = $member->getPublicFields();
            $link   = $this->Link($member->ID);

            foreach ($fields as $field) {
                if ($field->PublicVisibility == 'MemberChoice'
                    && !in_array($field->MemberField, $public)
                ) {
                    $value =  null;
                } else {
                    $value = $member->{$field->MemberField};
                }

                $cols->push(new ArrayData(array(
                    'Name'     => $field->MemberField,
                    'Title'    => $field->Title,
                    'Value'    => $value,
                    'Sortable' => $member->hasDatabaseField($field->MemberField),
                    'Link'     => $link
                )));
            }

            $list->push($member->customise(array(
                'Fields' => $cols
            )));
        }
        $list = PaginatedList::create($list, $request);
        $list->setLimitItems(false);
        $list->setTotalItems($members->getTotalItems());

        $this->data()->Title  = _t('MemberProfiles.MEMBERLIST', 'Member List');
        $this->data()->Parent = $this->getParent();

        $controller = $this->customise(array(
            'Type'    => 'List',
            'Members' => $list
        ));

        return $controller;
    }
public function handleList($request)
    {
        $parent = $this->getParent();
        $fields  = $parent->Fields()->filter('MemberListVisible', true);

        $groups = $parent->Groups();
        if ($groups->count() > 0) {
            $members = $groups->relation('Members');
        } else {
            $members = Member::get();
            // NOTE(Jake): 2018-05-02
            //
            // We may want to enable a flag so that ADMIN users are automatically omitted from this list
            // by default.
            //
            //$members = $members->filter('ID:not', Permission::get_members_by_permission('ADMIN')->map('ID', 'ID')->toArray());
        }
        $members = PaginatedList::create($members, $request);

        $list = new ArrayList();
        foreach ($members as $member) {
            $cols   = new ArrayList();
            $public = $member->getPublicFields();
            $link   = $this->Link($member->ID);

            foreach ($fields as $field) {
                if ($field->PublicVisibility == 'MemberChoice'
                    && !in_array($field->MemberField, $public)
                ) {
                    $value =  null;
                } else {
                    $value = $member->{$field->MemberField};
                }

                $cols->push(new ArrayData(array(
                    'Name'     => $field->MemberField,
                    'Title'    => $field->Title,
                    'Value'    => $value,
                    'Sortable' => $member->hasDatabaseField($field->MemberField),
                    'Link'     => $link
                )));
            }

            $list->push($member->customise(array(
                'Fields' => $cols
            )));
        }
        $list = PaginatedList::create($list, $request);
        $list->setLimitItems(false);
        $list->setTotalItems($members->getTotalItems());

        $this->data()->Title  = _t('MemberProfiles.MEMBERLIST', 'Member List');
        $this->data()->Parent = $this->getParent();

        $controller = $this->customise(array(
            'Type'    => 'List',
            'Members' => $list
        ));

        return $controller;
    }
public function handleList ( $ request ) { $ parent = $ this -> getParent ( ) ; $ fields = $ parent -> Fields ( ) -> filter ( 'MemberListVisible' , true ) ; $ groups = $ parent -> Groups ( ) ; if ( $ groups -> count ( ) > 0 ) { $ members = $ groups -> relation ( 'Members' ) ; } else { $ members = Member :: get ( ) ; // NOTE(Jake): 2018-05-02 // // We may want to enable a flag so that ADMIN users are automatically omitted from this list // by default. // //$members = $members->filter('ID:not', Permission::get_members_by_permission('ADMIN')->map('ID', 'ID')->toArray()); } $ members = PaginatedList :: create ( $ members , $ request ) ; $ list = new ArrayList ( ) ; foreach ( $ members as $ member ) { $ cols = new ArrayList ( ) ; $ public = $ member -> getPublicFields ( ) ; $ link = $ this -> Link ( $ member -> ID ) ; foreach ( $ fields as $ field ) { if ( $ field -> PublicVisibility == 'MemberChoice' && ! in_array ( $ field -> MemberField , $ public ) ) { $ value = null ; } else { $ value = $ member -> { $ field -> MemberField } ; } $ cols -> push ( new ArrayData ( array ( 'Name' => $ field -> MemberField , 'Title' => $ field -> Title , 'Value' => $ value , 'Sortable' => $ member -> hasDatabaseField ( $ field -> MemberField ) , 'Link' => $ link ) ) ) ; } $ list -> push ( $ member -> customise ( array ( 'Fields' => $ cols ) ) ) ; } $ list = PaginatedList :: create ( $ list , $ request ) ; $ list -> setLimitItems ( false ) ; $ list -> setTotalItems ( $ members -> getTotalItems ( ) ) ; $ this -> data ( ) -> Title = _t ( 'MemberProfiles.MEMBERLIST' , 'Member List' ) ; $ this -> data ( ) -> Parent = $ this -> getParent ( ) ; $ controller = $ this -> customise ( array ( 'Type' => 'List' , 'Members' => $ list ) ) ; return $ controller ; }
Displays a list of all members on the site that belong to the selected
groups.

@return ViewableData
Displays a list of all members on the site that belong to the selected groups .