Aimeos\Shop\Base\Support::checkGroup PHP 메소드

checkGroup() 공개 메소드

Checks if the user with the given ID is in the specified group
public checkGroup ( string $userid, string | array $groupcodes ) : boolean
$userid string Unique user ID
$groupcodes string | array Unique user/customer group codes that are allowed
리턴 boolean True if user is part of the group, false if not
    public function checkGroup($userid, $groupcodes)
    {
        $site = Route::current() ? Route::input('site', Input::get('site', 'default')) : 'default';
        $context = $this->context->get(false);
        $context->setLocale($this->locale->getBackend($context, $site));
        $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/group');
        $search = $manager->createSearch();
        $search->setConditions($search->compare('==', 'customer.group.code', (array) $groupcodes));
        $groupItems = $manager->searchItems($search);
        $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists');
        $search = $manager->createSearch();
        $expr = array($search->compare('==', 'customer.lists.parentid', $userid), $search->compare('==', 'customer.lists.refid', array_keys($groupItems)), $search->compare('==', 'customer.lists.domain', 'customer/group'));
        $search->setConditions($search->combine('&&', $expr));
        $search->setSlice(0, 1);
        return (bool) count($manager->searchItems($search));
    }