/** * 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; }
/** * Returns the list of all the users * * @param string $userLogins Comma separated list of users to select. If not specified, will return all users * @return array the list of all the users */ public function getUsers($userLogins = '') { Piwik::checkUserHasSomeAdminAccess(); $logins = array(); if (!empty($userLogins)) { $logins = explode(',', $userLogins); } $users = $this->model->getUsers($logins); // Non Super user can only access login & alias if (!Piwik::hasUserSuperUserAccess()) { foreach ($users as &$user) { $user = array('login' => $user['login'], 'alias' => $user['alias']); } } return $users; }