Skip to content
Marcus edited this page Feb 27, 2017 · 1 revision

Snippets

<?php

/**
 * Shows _just_ sites that users are explicitly bound to
 *
 * @author marcus
 */
class MySiteHierarchyExtension extends Extension
{
    public function augmentStageChildren(&$staged, $showAll) {
        if (Permission::check('ADMIN')) {
            return;
        }
        if (!$this->owner->ID && Controller::curr() instanceof LeftAndMain) {

            if ($this->owner instanceof SiteTree) {
                $myGroups = Member::currentUser()->Groups();
                $ids = $myGroups->column('ID');

                $staged = Site::get()->filter('EditorGroups.ID', $ids);
            }
        }
    }
}
Clone this wiki locally