src/Extensions/CommentsExtension.php
public function canPostComment($member = null)
    {
        // Deny if not enabled for this object
        if (!$this->owner->CommentsEnabled) {
            return false;
        }

        if (!$this->owner->canView($member)) {
            // deny if current user cannot view the underlying record.
            return false;
        }

        // Check if member is required
        $requireLogin = $this->owner->CommentsRequireLogin;
        if (!$requireLogin) {
            return true;
        }

        // Check member is logged in
        $member = $member ?: Security::getCurrentUser();
        if (!$member) {
            return false;
        }

        // If member required check permissions
        $requiredPermission = $this->owner->PostingRequiredPermission;
        if ($requiredPermission && !Permission::checkMember($member, $requiredPermission)) {
            return false;
        }

        return true;
    }
public function canPostComment($member = null)
    {
        // Deny if not enabled for this object
        if (!$this->owner->CommentsEnabled) {
            return false;
        }

        if (!$this->owner->canView($member)) {
            // deny if current user cannot view the underlying record.
            return false;
        }

        // Check if member is required
        $requireLogin = $this->owner->CommentsRequireLogin;
        if (!$requireLogin) {
            return true;
        }

        // Check member is logged in
        $member = $member ?: Security::getCurrentUser();
        if (!$member) {
            return false;
        }

        // If member required check permissions
        $requiredPermission = $this->owner->PostingRequiredPermission;
        if ($requiredPermission && !Permission::checkMember($member, $requiredPermission)) {
            return false;
        }

        return true;
    }
public function canPostComment ( $ member = null ) { // Deny if not enabled for this object if ( ! $ this -> owner -> CommentsEnabled ) { return false ; } if ( ! $ this -> owner -> canView ( $ member ) ) { // deny if current user cannot view the underlying record. return false ; } // Check if member is required $ requireLogin = $ this -> owner -> CommentsRequireLogin ; if ( ! $ requireLogin ) { return true ; } // Check member is logged in $ member = $ member ? : Security :: getCurrentUser ( ) ; if ( ! $ member ) { return false ; } // If member required check permissions $ requiredPermission = $ this -> owner -> PostingRequiredPermission ; if ( $ requiredPermission && ! Permission :: checkMember ( $ member , $ requiredPermission ) ) { return false ; } return true ; }
Determine if a user can post comments on this item

@param Member $member Member to check

@return boolean
Determine if a user can post comments on this item