Piwik\Plugins\UsersManager\Model::getSitesAccessFromUser PHP Method

getSitesAccessFromUser() public method

If the user doesn't have any access to a website ('noaccess'), this website will not be in the returned array. If the user doesn't have any access, the returned array will be an empty array.
public getSitesAccessFromUser ( string $userLogin ) : array
$userLogin string User that has to be valid
return array The returned array has the format array( idsite1 => 'view', idsite2 => 'admin', idsite3 => 'view', ... )
    public function getSitesAccessFromUser($userLogin)
    {
        $db = $this->getDb();
        $users = $db->fetchAll("SELECT idsite,access FROM " . Common::prefixTable("access") . " WHERE login = ?", $userLogin);
        $return = array();
        foreach ($users as $user) {
            $return[] = array('site' => $user['idsite'], 'access' => $user['access']);
        }
        return $return;
    }

Usage Example

Example #1
0
 /**
  * For each website ID, returns the access level of the given $userLogin.
  * If the user doesn't have any access to a website ('noaccess'),
  * this website will not be in the returned array.
  * If the user doesn't have any access, the returned array will be an empty array.
  *
  * @param string $userLogin User that has to be valid
  *
  * @return array    The returned array has the format
  *                    array(
  *                        idsite1 => 'view',
  *                        idsite2 => 'admin',
  *                        idsite3 => 'view',
  *                        ...
  *                    )
  */
 public function getSitesAccessFromUser($userLogin)
 {
     Piwik::checkUserHasSuperUserAccess();
     $this->checkUserExists($userLogin);
     $this->checkUserHasNotSuperUserAccess($userLogin);
     return $this->model->getSitesAccessFromUser($userLogin);
 }
All Usage Examples Of Piwik\Plugins\UsersManager\Model::getSitesAccessFromUser