Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A way to check if a post is at least part of one group #353

Open
bahaa-almahamid opened this issue Mar 22, 2022 · 0 comments
Open

A way to check if a post is at least part of one group #353

bahaa-almahamid opened this issue Mar 22, 2022 · 0 comments

Comments

@bahaa-almahamid
Copy link

Hi, I would like to check if a post is at least a member of one group
currently I'm using a function looks like this, but I feel it is overwhelming

function checkPostAccessibility(int $postId): bool
{
    global $userAccessManager;
    $locked = false;

    if (isset($userAccessManager)) {
        $userAccessManagerGroups = $userAccessManager->getUserGroupHandler()->getFilteredUserGroups();

        if ($userAccessManagerGroups) {
            foreach ($userAccessManagerGroups as $userAccessManagerGroup) {
                if ($userAccessManagerGroup->isObjectMember('post', $postId)) {
                    $locked = true;
                    break;
                }
            }
        }
    }

    return $locked;
}
@bahaa-almahamid bahaa-almahamid changed the title A way to check if a post is a part of on group at least A way to check if a post is at least part of one group Mar 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant