PHP 클래스 Piwik\Plugins\UsersManager\API

You can create users via "addUser", update existing users via "updateUser" and delete users via "deleteUser". There are many ways to list users based on their login "getUser" and "getUsers", their email "getUserByEmail", or which users have permission (view or admin) to access the specified websites "getUsersWithSiteAccess". Existing Permissions are listed given a login via "getSitesAccessFromUser", or a website ID via "getUsersAccessFromSite", or you can list all users and websites for a given permission via "getUsersSitesFromAccess". Permissions are set and updated via the method "setUserAccess". See also the documentation about Managing Users in Piwik.
상속: extends Piwik\Plugin\API
파일 보기 프로젝트 열기: piwik/piwik 1 사용 예제들

공개 메소드들

메소드 설명
__construct ( Model $model, Piwik\Plugins\UsersManager\UserAccessFilter $filter, Password $password )
addUser ( $userLogin, $password, $email, $alias = false, $_isPasswordHashed = false ) Add a user in the database.
createTokenAuth ( string $userLogin ) : string Generates a new random authentication token.
deleteUser ( string $userLogin ) : boolean Delete a user and all its access, given its login.
getAllUsersPreferences ( array $preferenceNames ) : array Returns an array of Preferences
getInstance ( ) : API You can create your own Users Plugin to override this class.
getSitesAccessFromUser ( string $userLogin ) : array For each website ID, returns the access level of the given $userLogin.
getTokenAuth ( string $userLogin, string $md5Password ) : string Returns the user's API token.
getUser ( string $userLogin ) : array Returns the user information (login, password hash, alias, email, date_registered, etc.)
getUserByEmail ( string $userEmail ) : array Returns the user information (login, password hash, alias, email, date_registered, etc.)
getUserLoginFromUserEmail ( string $userEmail ) : boolean Returns the first login name of an existing user that has the given email address. If no user can be found for this user an error will be returned.
getUserPreference ( string $userLogin, string $preferenceName ) : boolean | string Gets a user preference
getUsers ( string $userLogins = '' ) : array Returns the list of all the users
getUsersAccessFromSite ( integer $idSite ) : array For each user, returns his access level for the given $idSite.
getUsersHavingSuperUserAccess ( ) : array Returns a list of all Super Users containing there userLogin and email address.
getUsersLogin ( ) : array Returns the list of all the users login
getUsersSitesFromAccess ( $access ) : array For each user, returns the list of website IDs where the user has the supplied $access level.
getUsersWithSiteAccess ( $idSite, $access )
hasSuperUserAccess ( ) : boolean Detect whether the current user has super user access or not.
initUserPreferenceWithDefault ( string $userLogin, string $preferenceName ) Sets a user preference in the DB using the preference's default value.
regenerateTokenAuth ( string $userLogin ) Regenerate the token_auth associated with a user.
setSuperUserAccess ( string $userLogin, boolean | integer $hasSuperUserAccess ) Enable or disable Super user access to the given user login. Note: When granting Super User access all previous permissions of the user will be removed as the user gains access to everything.
setUserAccess ( string $userLogin, string $access, integer | array $idSites ) : boolean Set an access level to a given user for a list of websites ID.
setUserPreference ( string $userLogin, string $preferenceName, string $preferenceValue ) : void Sets a user preference
updateUser ( $userLogin, $password = false, $email = false, $alias = false, $_isPasswordHashed = false ) Updates a user in the database.
userEmailExists ( string $userEmail ) : boolean Returns true if user with given email (userEmail) is known in the database, or the Super User
userExists ( string $userLogin ) : boolean Returns true if the given userLogin is known in the database

비공개 메소드들

메소드 설명
checkAccessType ( $access )
checkEmail ( $email )
checkLogin ( $userLogin )
checkUserEmailExists ( string $userEmail ) Throws an exception is the user email cannot be found
checkUserExists ( string $userLogin ) Throws an exception is the user login doesn't exist
checkUserHasNotSuperUserAccess ( $userLogin )
checkUserIsNotAnonymous ( $userLogin )
enrichUser ( $user )
enrichUsers ( $users )
getCleanAlias ( $alias, $userLogin )
getDefaultUserPreference ( $preferenceName, $login )
getPreferenceId ( $login, $preference )
getPreferenceValue ( $userLogin, $preferenceName )
isUserTheOnlyUserHavingSuperUserAccess ( $userLogin )

메소드 상세

__construct() 공개 메소드

public __construct ( Model $model, Piwik\Plugins\UsersManager\UserAccessFilter $filter, Password $password )
$model Model
$filter Piwik\Plugins\UsersManager\UserAccessFilter
$password Piwik\Auth\Password

addUser() 공개 메소드

A user is defined by - a login that has to be unique and valid - a password that has to be valid - an alias - an email that has to be in a correct format
또한 보기: userExists()
또한 보기: isValidLoginString()
또한 보기: isValidPasswordString()
또한 보기: isValidEmailString()
public addUser ( $userLogin, $password, $email, $alias = false, $_isPasswordHashed = false )

createTokenAuth() 공개 메소드

Generates a new random authentication token.
public createTokenAuth ( string $userLogin ) : string
$userLogin string Login
리턴 string

deleteUser() 공개 메소드

Delete a user and all its access, given its login.
public deleteUser ( string $userLogin ) : boolean
$userLogin string the user login.
리턴 boolean true on success

getAllUsersPreferences() 공개 메소드

Returns an array of Preferences
public getAllUsersPreferences ( array $preferenceNames ) : array
$preferenceNames array array of preference names
리턴 array

getInstance() 공개 정적인 메소드

Example of how you would overwrite the UsersManager_API with your own class: Call the following in your plugin __construct() for example: StaticContainer::getContainer()->set('UsersManager_API', \Piwik\Plugins\MyCustomUsersManager\API::getInstance());
public static getInstance ( ) : API
리턴 API

getSitesAccessFromUser() 공개 메소드

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
리턴 array The returned array has the format array( idsite1 => 'view', idsite2 => 'admin', idsite3 => 'view', ... )

getTokenAuth() 공개 메소드

If the username/password combination is incorrect an invalid token will be returned.
public getTokenAuth ( string $userLogin, string $md5Password ) : string
$userLogin string Login
$md5Password string hashed string of the password (using current hash function; MD5-named for historical reasons)
리턴 string

getUser() 공개 메소드

Returns the user information (login, password hash, alias, email, date_registered, etc.)
public getUser ( string $userLogin ) : array
$userLogin string the user login
리턴 array the user information

getUserByEmail() 공개 메소드

Returns the user information (login, password hash, alias, email, date_registered, etc.)
public getUserByEmail ( string $userEmail ) : array
$userEmail string the user email
리턴 array the user information

getUserLoginFromUserEmail() 공개 메소드

Returns the first login name of an existing user that has the given email address. If no user can be found for this user an error will be returned.
public getUserLoginFromUserEmail ( string $userEmail ) : boolean
$userEmail string
리턴 boolean true if the user is known

getUserPreference() 공개 메소드

Gets a user preference
public getUserPreference ( string $userLogin, string $preferenceName ) : boolean | string
$userLogin string
$preferenceName string
리턴 boolean | string

getUsers() 공개 메소드

Returns the list of all the users
public getUsers ( string $userLogins = '' ) : array
$userLogins string Comma separated list of users to select. If not specified, will return all users
리턴 array the list of all the users

getUsersAccessFromSite() 공개 메소드

If a user doesn't have any access to the $idSite ('noaccess'), the user will not be in the returned array.
public getUsersAccessFromSite ( integer $idSite ) : array
$idSite integer website ID
리턴 array The returned array has the format array( login1 => 'view', login2 => 'admin', login3 => 'view', ... )

getUsersHavingSuperUserAccess() 공개 메소드

Returns a list of all Super Users containing there userLogin and email address.

getUsersLogin() 공개 메소드

Returns the list of all the users login
public getUsersLogin ( ) : array
리턴 array the list of all the users login

getUsersSitesFromAccess() 공개 메소드

If a user doesn't have the given $access to any website IDs, the user will not be in the returned array.
public getUsersSitesFromAccess ( $access ) : array
리턴 array The returned array has the format array( login1 => array ( idsite1,idsite2), login2 => array(idsite2), ... )

getUsersWithSiteAccess() 공개 메소드

public getUsersWithSiteAccess ( $idSite, $access )

hasSuperUserAccess() 공개 메소드

Detect whether the current user has super user access or not.
public hasSuperUserAccess ( ) : boolean
리턴 boolean

initUserPreferenceWithDefault() 공개 메소드

Sets a user preference in the DB using the preference's default value.
public initUserPreferenceWithDefault ( string $userLogin, string $preferenceName )
$userLogin string
$preferenceName string

regenerateTokenAuth() 공개 메소드

If the user currently logged in regenerates his own token, he will be logged out. His previous token will be rendered invalid.
public regenerateTokenAuth ( string $userLogin )
$userLogin string

setSuperUserAccess() 공개 메소드

Enable or disable Super user access to the given user login. Note: When granting Super User access all previous permissions of the user will be removed as the user gains access to everything.
public setSuperUserAccess ( string $userLogin, boolean | integer $hasSuperUserAccess )
$userLogin string the user login.
$hasSuperUserAccess boolean | integer true or '1' to grant Super User access, false or '0' to remove Super User access.

setUserAccess() 공개 메소드

If access = 'noaccess' the current access (if any) will be deleted. If access = 'view' or 'admin' the current access level is deleted and updated with the new value.
public setUserAccess ( string $userLogin, string $access, integer | array $idSites ) : boolean
$userLogin string The user login
$access string Access to grant. Must have one of the following value : noaccess, view, admin
$idSites integer | array The array of idSites on which to apply the access level for the user. If the value is "all" then we apply the access level to all the websites ID for which the current authentificated user has an 'admin' access.
리턴 boolean true on success

setUserPreference() 공개 메소드

Sets a user preference
public setUserPreference ( string $userLogin, string $preferenceName, string $preferenceValue ) : void
$userLogin string
$preferenceName string
$preferenceValue string
리턴 void

updateUser() 공개 메소드

Only login and password are required (case when we update the password). If the password changes and the user has an old token_auth (legacy MD5 format) associated, the token will be regenerated. This could break a user's API calls.
또한 보기: addUser() for all the parameters
public updateUser ( $userLogin, $password = false, $email = false, $alias = false, $_isPasswordHashed = false )

userEmailExists() 공개 메소드

Returns true if user with given email (userEmail) is known in the database, or the Super User
public userEmailExists ( string $userEmail ) : boolean
$userEmail string
리턴 boolean true if the user is known

userExists() 공개 메소드

Returns true if the given userLogin is known in the database
public userExists ( string $userLogin ) : boolean
$userLogin string
리턴 boolean true if the user is known