Validates if the zone is allowed for current user.
@param CNabuSiteTarget $nb_site_target Site Target to grant zone access.
@return bool Return true if the zone is allowed for requested Site Target.
167106
public function validateZone(CNabuSiteTarget $nb_site_target)
    {
        $nb_engine = CNabuEngine::getEngine();

        if (!(($nb_site = $nb_site_target->getSite()) instanceof CNabuSite)) {
            throw new ENabuCoreException(ENabuCoreException::ERROR_SITE_NOT_FOUND);
        }

        $this->zone = ($this->nb_user !== null ? 'P' : 'O');
        $nb_engine->traceLog("Request Zone", ($this->zone === 'P' ? 'Private' : 'Public'));

        $site_target_zone = $nb_site_target->getZone();
        $nb_engine->traceLog(
                "Page Zone",
                ($site_target_zone === 'P' ? 'Private' : ($site_target_zone === 'O' ? 'Public' : 'Both'))
        );

        $retval = ($site_target_zone === 'B') ||
                  ($site_target_zone !== null && $site_target_zone === $this->zone);

        if ($retval && $this->zone === 'P' && $nb_site->getRequirePoliciesAfterLogin() === 'T') {
            if ($this->nb_user->getPoliciesAccepted() === 'T') {
                $nb_engine->traceLog('Policies', 'Accepted');
            } else {
                $nb_engine->traceLog('Policies', 'Not accepted');
                if ($nb_site_target->getIgnorePolicies() === 'F' &&
                    ($link = $nb_site->getPoliciesTargetLink())->isLinkable() &&
                    !($link->matchTarget($nb_site_target))
                ) {
                    throw new ENabuRedirectionException(428, new CNabuHTTPRedirection(428, $link->getBestQualifiedURL()));
                }
            }
        }

        return $retval;
    }
650725
public function canAccess()
    {
        // Admin can access everything, no point in checking.
        $member = Security::getCurrentUser();
        if ($member
            && (Permission::checkMember($member, [
                'ADMIN', // Full administrative rights
                'CMS_ACCESS_LeftAndMain', // Access to all CMS sections
                'CMS_ACCESS_CMSMain', // Access to CMS controllers
            ]))
        ) {
            return true;
        }

        // Check if we have access to current section on the current subsite.
        $accessibleSites = $this->owner->sectionSites(true, 'Main site', $member);
        return $accessibleSites->count() && $accessibleSites->find('ID', SubsiteState::singleton()->getSubsiteId());
    }
1241272
protected function validateStoreTimezoneInstall()
    {
        $field = 'store.timezone';

        if ($this->isExcluded($field)) {
            return null;
        }

        $value = $this->getSubmitted($field);

        if (empty($value)) {
            $this->setSubmitted($field, date_default_timezone_get());
            return true;
        }

        $timezones = gplcart_timezones();

        if (empty($timezones[$value])) {
            $this->setErrorInvalid($field, $this->translation->text('Timezone'));
            return false;
        }

        return true;
    }
513621
public function getUser($nb_user)
    {
        $retval = null;

        $nb_user_id = nb_getMixedValue($nb_user, NABU_USER_FIELD_ID);
        if (is_numeric($nb_user_id)) {
            $nb_new_user = new CNabuUser($nb_user_id);
            if ($nb_new_user->isFetched() && $nb_new_user->validateCustomer($this)) {
                $nb_new_user->setCustomer($this);
                $retval = $nb_new_user;
            }
        }

        return $retval;
    }
981264
def _is_target_valid(self, cfg, target):  # pylint:disable=no-self-use
        

        if self.base_state is not None:
            try:
                if self.base_state.solver.is_true((self.base_state.memory.permissions(target) & 4) == 4):
                    return True
            except SimMemoryError:
                pass
            return False

        if cfg._addr_in_exec_memory_regions(target):
            # the jump target is executable
            return True
        if self.project.is_hooked(target):
            # the jump target is hooked
            return True
        return False
1242247
public function setSiteTargetCTAId(int $nb_site_target_cta_id) : CNabuDataObject
    {
        if ($nb_site_target_cta_id === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$nb_site_target_cta_id")
            );
        }
        $this->setValue('nb_site_target_cta_id', $nb_site_target_cta_id);
        
        return $this;
    }
614766
def is_valid_sites(self):
        
        if 'site_model' in self.inputs and 'sites' in self.inputs:
            return False
        elif 'site_model' in self.inputs and self.sites:
            return False
        elif 'sites' in self.inputs and self.sites:
            return False
        elif self.sites and self.region and self.region_grid_spacing:
            return False
        else:
            return True
1132943
public function IsValidForCurrentUser()
    {
        $bIsValidForUser = false;
        $bIsValidGroup = false;

        $shippingGroupDataAccess = $this->getShippingGroupDataAccess();
        $aUserGroups = $shippingGroupDataAccess->getPermittedUserGroupIds($this->id);
        if (!is_array($aUserGroups) || count($aUserGroups) < 1) {
            $bIsValidGroup = true;
        } else {
            $oUser = TdbDataExtranetUser::GetInstance();
            $bIsValidGroup = $oUser->InUserGroups($aUserGroups);
        }

        // now check user id
        if ($bIsValidGroup) {
            $aUserList = $shippingGroupDataAccess->getPermittedUserIds($this->id);
            if (!is_array($aUserList) || count($aUserList) < 1) {
                $bIsValidForUser = true;
            } else {
                $oUser = TdbDataExtranetUser::GetInstance();
                $bIsValidForUser = in_array($oUser->id, $aUserList);
            }
        }

        return $bIsValidForUser && $bIsValidGroup;
    }
1326341
public function setSiteAliasId(int $nb_site_alias_id) : CNabuDataObject
    {
        if ($nb_site_alias_id === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$nb_site_alias_id")
            );
        }
        $this->setValue('nb_site_alias_id', $nb_site_alias_id);
        
        return $this;
    }
317626
public function allows($resource = null, $privilege = null, $profile = null)
    {
        if($profile === null)
            $profile = auth()->guard('pulsar')->user()->profile_id_010;

        try
        {
            return parent::isAllowed($profile, $resource, $privilege);
        }
        catch(Exception\InvalidArgumentException $e)
        {
            return false;
        }
    }
1059633
public function getProfiles(bool $force = false) : CNabuSiteUserList
    {
        if ($this->nb_site_user_list->isEmpty() || $force) {
            $this->nb_site_user_list->clear();
            $this->nb_site_user_list->merge(CNabuSiteUser::getSitesForUser($this));
        }

        return $this->nb_site_user_list;
    }
921324
public function isValid($target)
    {
        if (mb_strlen($target, $this->charset) < $this->length) {
            $this->violate(sprintf($this->message, $this->length));
            return false;
        } else {
            return true;
        }
    }
177295
public function setSiteId(int $nb_site_id) : CNabuDataObject
    {
        if ($nb_site_id === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$nb_site_id")
            );
        }
        $this->setValue('nb_site_id', $nb_site_id);
        
        return $this;
    }
598211
protected function isAllowed()
    {
        /** @var  \Arcanesoft\Contracts\Auth\Models\User  $user */
        if (is_null($user = auth()->user()))
            return false;

        return $user->isAdmin() || $user->isModerator();
    }
1039617
public function isValid($target)
    {
        if ($target >= $this->start && $target <= $this->end) {
            return true;
        } else {
            $this->violate(sprintf($this->message, $this->start, $this->end));
            return false;
        }
    }
657996
public function canPublishTarget(DataObject $target)
    {
        $absolute = $this->BaseAction()->canPublishTarget($target);
        if (!is_null($absolute)) {
            return $absolute;
        }
        return false;
    }
1065641
public function canAdministrate()
    {
        $user = $this->getUser();
        if ($user->name == 'Guest' && $user->email == 'guest@example.com') {
            return false;
        }
        if (method_exists($user, 'isAdmin')) {
            return $user->isAdmin();
        }
        if (method_exists($user, 'can')) {
            return $user->can('administrate') || $user->can('admin');
        }
        // If no method of authorizing return false;
        return false;
    }