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

getUsers() public method

Returns the list of all the users
public getUsers ( array $userLogins ) : array
$userLogins array List of users to select. If empty, will return all users
return array the list of all the users
    public function getUsers(array $userLogins)
    {
        $where = '';
        $bind = array();
        if (!empty($userLogins)) {
            $where = 'WHERE login IN (' . Common::getSqlStringFieldsArray($userLogins) . ')';
            $bind = $userLogins;
        }
        $db = $this->getDb();
        $users = $db->fetchAll("SELECT * FROM " . $this->table . "\n                                {$where}\n                                ORDER BY login ASC", $bind);
        return $users;
    }

Usage Example

Example #1
0
 /**
  * Hooks when a website tracker cache is flushed (website/user updated, cache deleted, or empty cache)
  * Will record in the tracker config file the list of Admin token_auth for this website. This
  * will be used when the Tracking API is used with setIp(), setForceDateTime(), setVisitorId(), etc.
  *
  * @param $attributes
  * @param $idSite
  * @return void
  */
 public function recordAdminUsersInCache(&$attributes, $idSite)
 {
     // add the 'hosts' entry in the website array
     $model = new Model();
     $logins = $model->getUsersLoginWithSiteAccess($idSite, 'admin');
     if (empty($logins)) {
         return;
     }
     $users = $model->getUsers($logins);
     $tokens = array();
     foreach ($users as $user) {
         $tokens[] = $user['token_auth'];
     }
     $attributes['admin_token_auth'] = $tokens;
 }
All Usage Examples Of Piwik\Plugins\UsersManager\Model::getUsers