Returns the list of websites ID with the 'view' or 'admin' access for the current user.
For the superUser it returns all the websites in the database.

@param bool $_restrictSitesToLogin
@return array list of websites ID
976805
public function getSitesIdWithAtLeastViewAccess($_restrictSitesToLogin = false)
    {
        /** @var Scheduler $scheduler */
        $scheduler = StaticContainer::getContainer()->get('Piwik\Scheduler\Scheduler');

        if (Piwik::hasUserSuperUserAccess() && !$scheduler->isRunningTask()) {
            return Access::getInstance()->getSitesIdWithAtLeastViewAccess();
        }

        if (!empty($_restrictSitesToLogin)
            // Only Super User or logged in user can see viewable sites for a specific login,
            // but during scheduled task execution, we sometimes want to restrict sites to
            // a different login than the superuser.
            && (Piwik::hasUserSuperUserAccessOrIsTheUser($_restrictSitesToLogin)
                || $scheduler->isRunningTask())
        ) {

            if (Piwik::hasTheUserSuperUserAccess($_restrictSitesToLogin)) {
                return Access::getInstance()->getSitesIdWithAtLeastViewAccess();
            }

            $accessRaw = Access::getInstance()->getRawSitesWithSomeViewAccess($_restrictSitesToLogin);
            $sitesId   = array();

            foreach ($accessRaw as $access) {
                $sitesId[] = $access['idsite'];
            }

            return $sitesId;
        } else {
            return Access::getInstance()->getSitesIdWithAtLeastViewAccess();
        }
    }
382610
public function getExcludeUserIds()
    {
        $userIds = array();
        $currentGroupId = -1;
        //First of all we need to test if subject is group or user
        //In case of group we need to exclude all these users that already exist in role
        if ($this->receiverGroup !== null) {
            $currentGroupId = $this->receiverGroup->getId();
            $roleUsers = $this->role->getUsers();
            foreach ($roleUsers as $user) {
                array_push($userIds, $user->getId());
            }
        }

        //For both cases (user or group) we need to exclude all users already enrolled in other groups
        $roleGroups = $this->role->getGroups();

        if ($roleGroups) {
            foreach ($roleGroups as $group) {
                if ($group->getId() != $currentGroupId) {
                    $userIds = array_merge($userIds, $group->getUserIds());
                }
            }
        }
        $userIds = array_unique($userIds);

        return $userIds;
    }
424826
public function getSitesFromIds($idSites, $limit = false)
    {
        if (count($idSites) === 0) {
            return array();
        }

        if ($limit) {
            $limit = "LIMIT " . (int)$limit;
        } else {
            $limit = '';
        }

        $idSites = array_map('intval', $idSites);

        $db    = $this->getDb();
        $sites = $db->fetchAll("SELECT * FROM " . $this->table . "
                                WHERE idsite IN (" . implode(", ", $idSites) . ")
                                ORDER BY idsite ASC $limit");

        return $sites;
    }
846206
public function getLimitationArrayWithIdentifiers(Limitation $limitation)
    {
        $retValues = array();
        $values = $limitation->limitationValues;

        switch ($limitation->getIdentifier()) {
            case 'Section':
            case 'NewSection':
                foreach ($values as $value) {
                    $section = $this->sectionMatcher->matchOneByKey($value);
                    $retValues[] = $section->identifier;
                }
                break;
            case 'SiteAccess':
                foreach ($values as $value) {
                    $name = "No/unknown SiteAccess Found";
                    if (array_key_exists($value, $this->siteAccessList)) {
                        $name = $this->siteAccessList[$value];
                    }
                    $retValues[] = $name;
                }
                break;
            case 'ParentClass':
            case 'Class':
                foreach ($values as $value) {
                    $contentType = $this->contentTypeMatcher->matchOneByKey($value);
                    $retValues[] = $contentType->identifier;
                }
                break;
            default:
                $retValues = $values;
        }

        return array(
            'identifier' => $limitation->getIdentifier(),
            'values' => $retValues
        );
    }
622533
protected function getRootPagesWithoutDomain()
    {
        $rootPagesWithoutDomain = [];
        $rootPages = $this->getRootPages();

        $rootPageIds = [];
        foreach ($rootPages as $rootPage) {
            $rootPageIds[] = $rootPage['uid'];
        }

        $domainRecords = $this->systemDomainRepository->findDomainRecordsByRootPagesIds($rootPageIds);
        foreach ($rootPageIds as $rootPageId) {
            $hasDomainRecord = true;
            $hasDomainInTypoScript = true;

            if (!array_key_exists($rootPageId, $domainRecords)) {
                $hasDomainRecord = false;
            }

            /** @var $siteService SiteService */
            $siteService = GeneralUtility::makeInstance(SiteService::class);
            $domain = $siteService->getFirstDomainForRootPage($rootPageId);
            if ($domain === '') {
                $hasDomainInTypoScript = false;
            }

            if (!$hasDomainRecord && !$hasDomainInTypoScript) {
                $rootPagesWithoutDomain[$rootPageId] = $rootPages[$rootPageId];
            }
        }
        return $rootPagesWithoutDomain;
    }
1109971
public function getDomains() {
    $domains = array();
    $checks = $this->getChecks();
    foreach ($checks as $check) {
      $domains[$check->id] = $check->hostname;
    }
    return $domains;
  }
1134224
public function getSitesIdWithAtLeastWriteAccess()
    {
        $this->loadSitesIfNeeded();

        return array_unique(array_merge(
                $this->idsitesByAccess['write'],
                $this->idsitesByAccess['admin'],
                $this->idsitesByAccess['superuser'])
        );
    }
542005
public function getPagedResults($limit = 25, $page = 0)
    {
        $template = self::DQL_ALL;
        $dql = sprintf($template, UserPermission::class, User::class);

        return $this->getPaginator($dql, $limit, $page, []);
    }
1337159
public function getPageTypes($dc)
    {
        $options = [];
        $rootAllowed = true;

        if ($dc->activeRecord->pid > 0) {
            $rootAllowed = false;
            $parentType = $this->db->fetchColumn('SELECT type FROM tl_page WHERE id=?', [$dc->activeRecord->pid]);

            // Allow root in second level if the parent is folder
            if ($parentType === 'folder') {
                $rootAllowed = true;
            }
        }

        foreach (array_keys($GLOBALS['TL_PTY']) as $pty) {
            // Root pages are allowed on the first level only (see #6360)
            if ($pty === 'root' && !$rootAllowed) {
                continue;
            }

            // Allow the currently selected option and anything the user has access to
            if ($pty === $dc->value || $this->user->hasAccess($pty, 'alpty')) {
                $options[] = $pty;
            }
        }

        return $options;
    }
1130967
function statusModificationList( $user = false )
    {
        if ( $user === false )
            $user = eZUser::currentUser();
        else if ( is_numeric( $user ) )
            $user = eZUser::fetch( $user );

        if ( !is_object( $user ) )
        {
            eZDebug::writeError( "Cannot calculate status access list without a user", __METHOD__ );
            return false;
        }

        $accessResult = $user->hasAccessTo( 'shop' , 'setstatus' );
        $accessWord = $accessResult['accessWord'];
        $access = false;

        $currentStatusID = $this->attribute( "status_id" );

        $statusList = array();
        if ( $accessWord == 'yes' )
        {
            // We have full access so we return all of them
            $statusList = eZOrderStatus::fetchOrderedList( true, false );
            return $statusList;
        }

        if ( $accessWord == 'limited' )
        {
            $limitationList = $accessResult['policies'];
            $access = true;
            // All 'to' statues will be appended to this array
            $accessList = array();
            foreach ( $limitationList as $pid => $limit )
            {
                $access = true;
                foreach ( $limit as $name => $value )
                {
                    if ( $name == 'FromStatus' )
                    {
                        if ( !in_array( $currentStatusID, $value )  )
                            $access = false;
                    }
                    if ( !$access )
                        break;
                }
                if ( $access )
                {
                    if ( isset( $limit['ToStatus'] ) )
                    {
                        $accessList = array_merge( $accessList, $limit['ToStatus'] );
                    }
                    else
                    {
                        // We have full access for the current status so we return all of them
                        $statusList = eZOrderStatus::fetchOrderedList( true, false );
                        return $statusList;
                    }
                }
            }
            if ( count( $accessList ) > 0 )
            {
                $accessList = array_unique( array_merge( $accessList, array( $currentStatusID ) ) );
                $statuses = eZOrderStatus::fetchOrderedList( true, false );
                foreach ( $statuses as $status )
                {
                    if ( in_array( $status->attribute( 'status_id' ), $accessList ) )
                        $statusList[] = $status;
                }
            }
        }
        return $statusList;
    }
822398
public function allowedUserGroups( $privilege = self::PRIVILEGE_DEFAULT )
    {
        $result = array();

        if ( null === $this->userGroups )
        {
            $this->userGroups = $this->getMapper()
                                     ->findUserGroups();
        }

        foreach ( $this->userGroups as $id => $name )
        {
            if ( $this->isAllowed( 'user.group.' . $id, $privilege ) )
            {
                $result[$id] = $name;
            }
        }

        return $result;
    }
992426
public function getGuests($website, $onlySubscriber = false)
    {
        return $this->getCollection()
            ->getGuests($website->getId(), $onlySubscriber);
    }
324195
public function indexAction()
    {
        $allowed_users = array();
        $users = $this->getDoctrine()->getManager()->createQuery('SELECT r FROM FOMUserBundle:User r')->getResult();

        // ACL access check
        foreach ($users as $index => $user) {
            if ($this->isGranted('VIEW', $user)) {
                $allowed_users[] = $user;
            }
        }

        $oid = new ObjectIdentity('class', 'FOM\UserBundle\Entity\User');

        return array(
            'users'             => $allowed_users,
            'create_permission' => $this->isGranted('CREATE', $oid)
        );
    }
1216798
function GetDSN()
    {
	    return array(
		    'phptype'  => $this->Type,
		    'username' => $this->Username,
		    'password' => $this->Password,
		    'hostspec' => $this->ConnectionString,
		    'database' => $this->DBName,
	    );
	}
304571
public function getAllSegmentsForAllUsers($idSite = false)
    {
        $bind = array();
        $sqlWhereCondition = '';

        if(!empty($idSite)) {
            $bind = array($idSite);
            $sqlWhereCondition = '(enable_only_idsite = ? OR enable_only_idsite = 0) AND';
        }

        $sqlWhereCondition  = $this->buildQuerySortedByName($sqlWhereCondition . ' deleted = 0');
        $segments = $this->getDb()->fetchAll($sqlWhereCondition, $bind);

        return $segments;
    }
520930
public function GetAllowedPermissionNamespaces() {
      $ApplicationManager = new Gdn_ApplicationManager();
      $EnabledApplications = $ApplicationManager->EnabledApplications();
      
      $PluginNamespaces = array();
      foreach(Gdn::PluginManager()->EnabledPlugins() as $Plugin) {
         if(!array_key_exists('RegisterPermissions', $Plugin) || !is_array($Plugin['RegisterPermissions']))
            continue;
         foreach($Plugin['RegisterPermissions'] as $Index => $PermissionName) {
            if (is_string($Index))
               $PermissionName = $Index;
            
            $Namespace = substr($PermissionName, 0, strrpos($PermissionName, '.'));
            $PluginNamespaces[$Namespace] = TRUE;
         }
      }
      
      $Result = array_merge(array_keys($EnabledApplications), array_keys($PluginNamespaces));
		if(in_array('Dashboard', $Result))
			$Result[] = 'Garden';
		return $Result;
   }
1130185
function accessArray( $ignoreLimitIdentifier = false )
    {
        $limitations = $this->limitationList( true, $ignoreLimitIdentifier );
        if ( $this->Disabled === true )
        {
            return array();
        }

        if ( !$limitations )
        {
            return array( $this->attribute( 'module_name' ) => array ( $this->attribute( 'function_name' ) => array( '*' => '*' ) ) );
        }

        $limitArray = array();

        foreach( array_keys( $limitations ) as $limitKey )
        {
            $limitArray = array_merge_recursive( $limitArray, $limitations[$limitKey]->limitArray() );
        }

        $policyName = 'p_' . $this->attribute( 'id' ) . ( isset($this->UserRoleID) ? ( '_' . $this->UserRoleID ) : '' );

        return array( $this->attribute( 'module_name' ) => array ( $this->attribute( 'function_name' ) => array( $policyName => $limitArray ) ) );
    }