public function canCreate($member = null, $context = array())
    {
        if (!$member) {
            $member = Security::getCurrentUser();
        }

        // Check parent (custom canCreate option for SiteTree)
        // Block children not allowed for this parent type
        $parent = isset($context['Parent']) ? $context['Parent'] : null;
        $strictParentInstance = ($parent && $parent instanceof SiteTree);
        if ($strictParentInstance && !in_array(static::class, $parent->allowedChildren())) {
            return false;
        }

        // Standard mechanism for accepting permission changes from extensions
        $extended = $this->extendedCan(__FUNCTION__, $member, $context);
        if ($extended !== null) {
            return $extended;
        }

        // Check permission
        if ($member && Permission::checkMember($member, "ADMIN")) {
            return true;
        }

        // Fall over to inherited permissions
        if ($strictParentInstance && $parent->exists()) {
            return $parent->canAddChildren($member);
        } else {
            // This doesn't necessarily mean we are creating a root page, but that
            // we don't know if there is a parent, so default to this permission
            return SiteConfig::current_site_config()->canCreateTopLevel($member);
        }
    }
public function canCreate($member = null, $context = array())
    {
        if (!$member) {
            $member = Security::getCurrentUser();
        }

        // Check parent (custom canCreate option for SiteTree)
        // Block children not allowed for this parent type
        $parent = isset($context['Parent']) ? $context['Parent'] : null;
        $strictParentInstance = ($parent && $parent instanceof SiteTree);
        if ($strictParentInstance && !in_array(static::class, $parent->allowedChildren())) {
            return false;
        }

        // Standard mechanism for accepting permission changes from extensions
        $extended = $this->extendedCan(__FUNCTION__, $member, $context);
        if ($extended !== null) {
            return $extended;
        }

        // Check permission
        if ($member && Permission::checkMember($member, "ADMIN")) {
            return true;
        }

        // Fall over to inherited permissions
        if ($strictParentInstance && $parent->exists()) {
            return $parent->canAddChildren($member);
        } else {
            // This doesn't necessarily mean we are creating a root page, but that
            // we don't know if there is a parent, so default to this permission
            return SiteConfig::current_site_config()->canCreateTopLevel($member);
        }
    }
public function canCreate ( $ member = null , $ context = array ( ) ) { if ( ! $ member ) { $ member = Security :: getCurrentUser ( ) ; } // Check parent (custom canCreate option for SiteTree) // Block children not allowed for this parent type $ parent = isset ( $ context [ 'Parent' ] ) ? $ context [ 'Parent' ] : null ; $ strictParentInstance = ( $ parent && $ parent instanceof SiteTree ) ; if ( $ strictParentInstance && ! in_array ( static :: class , $ parent -> allowedChildren ( ) ) ) { return false ; } // Standard mechanism for accepting permission changes from extensions $ extended = $ this -> extendedCan ( __FUNCTION__ , $ member , $ context ) ; if ( $ extended !== null ) { return $ extended ; } // Check permission if ( $ member && Permission :: checkMember ( $ member , "ADMIN" ) ) { return true ; } // Fall over to inherited permissions if ( $ strictParentInstance && $ parent -> exists ( ) ) { return $ parent -> canAddChildren ( $ member ) ; } else { // This doesn't necessarily mean we are creating a root page, but that // we don't know if there is a parent, so default to this permission return SiteConfig :: current_site_config ( ) -> canCreateTopLevel ( $ member ) ; } }
This function should return true if the current user can create new pages of this class, regardless of class. It
can be overloaded to customise the security model for an application.

By default, permission to create at the root level is based on the SiteConfig configuration, and permission to
create beneath a parent is based on the ability to edit that parent page.

Use {@link canAddChildren()} to control behaviour of creating children under this page.

@uses $can_create
@uses DataExtension->canCreate()

@param Member $member
@param array $context Optional array which may contain array('Parent' => $parentObj)
If a parent page is known, it will be checked for validity.
If omitted, it will be assumed this is to be created as a top level page.
@return bool True if the current user can create pages on this class.
This function should return true if the current user can create new pages of this class regardless of class . It can be overloaded to customise the security model for an application .