This file provides almost all functions used for the usermanagement. More...
Go to the source code of this file.
This file provides almost all functions used for the usermanagement.
This file provides the vast majority of functions used for usermanagement and its interaction with the sponsormanagement part.
For more details please consider reading the documentation of the certain function you're interestend in.
This file is based on funcs.php from UserCake Version: 2.0.2 with modifications by Alexander Vorndran and Daniel Seichter
This file depends on inc/common.php and inc/libs/usercake/config_usercake.php.
Definition in file functions_usercake.php.
acceptPasswordRequest | ( | $token) |
Does token validation and sends a new password to the user via email
string | $token | alphanumerical token to identify the user |
Definition at line 2144 of file functions_usercake.php.
References $errors, $successes, fetchUserDetails(), flagPassword(), generateImprovedHash(), getUniqueCode(), lang(), updatePasswordFromToken(), and validateActivationToken().
accessGranted | ( | $uri) |
Checks if the current user has access to the given resource
string | $uri | uniform resource identifier of the website |
Definition at line 1837 of file functions_usercake.php.
References $db, $errors, $mysqli, createPages(), fetchPageIdForName(), isUserAdministrator(), isUserLoggedIn(), isUserRoot(), PAGE_LOCK, PAGE_PRIVATE, PAGE_PUBLIC, and updatePageState().
addPermission | ( | $permissionId, | |
$userId | |||
) |
Match permission level(s) with user(s)
array | $permissionId | the id of the permission |
array | $userId | the id of the user |
Definition at line 1479 of file functions_usercake.php.
Referenced by User\userCakeAddUser().
countUserReferences | ( | $userId) |
Returns the number of changes the user is responsible for
integer | $userId | the id of the user |
Definition at line 2053 of file functions_usercake.php.
References $dbBackup, and $mysqli.
Referenced by deleteUsersPermanently().
createPages | ( | $pages) |
Add a page to the DB
array | $pages | the names of the pages that should be added to the database |
Definition at line 1669 of file functions_usercake.php.
References $db, $mysqli, and STANDARD_PAGE_ACCESS.
Referenced by accessGranted().
createPermission | ( | $permissionName) |
Create a permission level in DB
string | $permissionName | the name of the new permission |
Definition at line 1312 of file functions_usercake.php.
deletePages | ( | $pages) |
Delete a page from the DB
array | $pages | the page-ids of the pages that should be deleted from the database |
Definition at line 1695 of file functions_usercake.php.
deletePermission | ( | $permissionId) |
deleteUsers | ( | $userId) |
Marks a defined array of users as deleted
array | $userId | the ids of the users |
Definition at line 343 of file functions_usercake.php.
References $db, $mysqli, DEFAULT_ADMIN_ACCOUNT, and isUserAdministrator().
deleteUsersPermanently | ( | $users) |
Delete a defined array of users permanentaly Permits deletion if the user is responsible for changes
array | $users | the array of users that should be deleted from the database |
Definition at line 392 of file functions_usercake.php.
References $db, $errors, $mysqli, countUserReferences(), DEFAULT_ADMIN_ACCOUNT, fetchUsername(), isUserAdministrator(), and isUserRoot().
denyPasswordRequest | ( | $token) |
Resets the state of the password request
string | $token | alphanumerical token to identify the user |
Definition at line 2186 of file functions_usercake.php.
References $errors, $successes, fetchUserDetails(), flagPassword(), lang(), and validateActivationToken().
destroySession | ( | $name) |
Destroy a session as part of logout
string | $name | the name of the session variable that should be unset |
Definition at line 74 of file functions_usercake.php.
Referenced by isUserLoggedIn(), and LoggedInUser\userLogOut().
emailExists | ( | $email) |
Check if an email exists in the DB
string | The email-address to check |
Definition at line 459 of file functions_usercake.php.
Referenced by User\__construct().
emailUsernameLinked | ( | $email, | |
$username | |||
) |
Check if a user name and email belong to the same user
string | the email-address of the user | |
string | $username | the username of the user |
Definition at line 513 of file functions_usercake.php.
fetchAllMatches | ( | ) |
Retrieve information for all user/permission level matches
Definition at line 1516 of file functions_usercake.php.
fetchAllPages | ( | ) |
Fetch information on all pages
Definition at line 1711 of file functions_usercake.php.
fetchAllPermissions | ( | ) |
Retrieve information for all permission levels
Definition at line 1360 of file functions_usercake.php.
fetchAllUsers | ( | ) |
Retrieve information for all users
Definition at line 541 of file functions_usercake.php.
fetchPageDetails | ( | $pageId) |
Fetch information for a specific page
integer | $pageId |
Definition at line 1736 of file functions_usercake.php.
fetchPageIdForName | ( | $page) |
Fetch the id for given page
string | $page | the name of the page |
Definition at line 1976 of file functions_usercake.php.
Referenced by accessGranted().
fetchPermissionDetails | ( | $permissionId) |
Retrieve information for a single permission level
integer | $permissionId |
Definition at line 1381 of file functions_usercake.php.
fetchPermissionUsers | ( | $permission_id) |
Retrieve list of users who have a permission level
integer | $permission_id |
Definition at line 1564 of file functions_usercake.php.
fetchUserDetails | ( | $username = NULL , |
|
$token = NULL , |
|||
$userId = NULL |
|||
) |
Retrieve complete user information by username, token or ID
string | $username | |
string | $token | |
integer | $userId |
Definition at line 583 of file functions_usercake.php.
Referenced by acceptPasswordRequest(), denyPasswordRequest(), and LoggedInUser\getFullName().
fetchUsername | ( | $userId) |
Fetches the username for a given userid
integer | $userId | the userid of the user |
Definition at line 648 of file functions_usercake.php.
Referenced by deleteUsersPermanently(), fetchAllDeletedSponsorCarsForSponsor(), fetchAllDeletedSponsors(), fetchDeletedSponsorCars(), fetchSponsorEditDataForEditSections(), and fetchSponsorLatestEditData().
fetchUserPermissions | ( | $userId) |
Retrieve list of permission levels a user has
integer | $userId | the id of the user |
Definition at line 1538 of file functions_usercake.php.
flagPassword | ( | $userId, | |
$value | |||
) |
Toggle lost password request flag on or off
integer | $userId | the id of the user |
integer | $value | the value of the password flag
|
Definition at line 709 of file functions_usercake.php.
Referenced by acceptPasswordRequest(), and denyPasswordRequest().
generateActivationToken | ( | ) |
Generate an activation key
Definition at line 103 of file functions_usercake.php.
References validateActivationToken().
Referenced by updatePasswordFromToken(), and User\userCakeAddUser().
generateImprovedHash | ( | $password, | |
$hash = NULL , |
|||
$rounds = WORKING_FACTOR |
|||
) |
Generates a hash from the given password using bcrypt with a random salt. If salt is NULL the salt from the given hash is used.
mixed | $password | the password to hash |
mixed | $hash | [optional]
|
integer | $rounds | [optional]
|
Definition at line 126 of file functions_usercake.php.
Referenced by acceptPasswordRequest(), LoggedInUser\updatePassword(), and User\userCakeAddUser().
generateSessionId | ( | ) |
Generate a unique session id
Definition at line 295 of file functions_usercake.php.
References sessionIdExists().
getLanguageFiles | ( | ) |
Retrieve a list of all .php files in languages
Definition at line 35 of file functions_usercake.php.
References ABS_PATH.
getLastActivity | ( | $userId) |
returns the timestamp for the last sign in
Definition at line 915 of file functions_usercake.php.
Referenced by hasSessionTimedOut().
getPageFiles | ( | ) |
Retrieve a list of all .php files in root files folder
Definition at line 59 of file functions_usercake.php.
getStoredSession | ( | $user_id) |
Returns the session that is saved in the database
integer | $user_id | identifies the user from whom we want to get the stored session |
Definition at line 670 of file functions_usercake.php.
Referenced by hasSessionTimedOut(), and isUserLoggedIn().
getTemplateFiles | ( | ) |
Retrieve a list of all .css files in site-templates
Definition at line 47 of file functions_usercake.php.
References ABS_PATH.
getUniqueCode | ( | $length = "" ) |
Generate a unique code
string | $length | the length of the generated unique code |
Definition at line 89 of file functions_usercake.php.
Referenced by acceptPasswordRequest().
hasOnetimePassword | ( | $userId) |
Checks wheter the user has a onetime password
integer | $userId | the id of the user that should be checked |
Definition at line 2000 of file functions_usercake.php.
hasOnetimePasswordExpired | ( | $userId) |
Checks if the user has an expired onetime password
integer | $userId | the id of the user that should be checked |
Definition at line 2026 of file functions_usercake.php.
hasSecurityHeader | ( | $filename) |
Checks if a given file has the UserCake-typical security header
string | $filename | the name of the file to check |
Definition at line 1638 of file functions_usercake.php.
References $filename.
hasSessionTimedOut | ( | $user_id) |
Check if the current session has timed out
Definition at line 895 of file functions_usercake.php.
References AUTO_TIMEOUT, getLastActivity(), getStoredSession(), and RESET_SESSION_ID.
hasValidMail | ( | $userId) |
Checks if the user has a validated email-address
integer | $userId | the id of the user |
Definition at line 1908 of file functions_usercake.php.
isAdministrator | ( | $id) |
Check if a certain user is an administrator
integer | $id | the user id of the user whose rights should be checked |
Definition at line 843 of file functions_usercake.php.
References $db, $mysqli, ADMIN_PERMISSION, DEFAULT_ADMIN_ACCOUNT, and MASTER_ACCOUNT.
isRoot | ( | $userId) |
Checks wheter or not a user has root priviliges
integer | $userId |
Definition at line 884 of file functions_usercake.php.
References DEFAULT_ADMIN_ACCOUNT, and MASTER_ACCOUNT.
isUserAdministrator | ( | ) |
Checks if the current user is an administrator
Definition at line 779 of file functions_usercake.php.
References $db, $mysqli, ADMIN_PERMISSION, isUserLoggedIn(), and isUserRoot().
Referenced by accessGranted(), deleteSponsorCarPermanently(), deleteUsers(), and deleteUsersPermanently().
isUserLoggedIn | ( | ) |
Check if the current user is logged in if his session isn't valid any more destroy it
Definition at line 730 of file functions_usercake.php.
References $db, $mysqli, destroySession(), and getStoredSession().
Referenced by accessGranted(), deleteSponsor(), deleteSponsorCar(), isUserAdministrator(), isUserRoot(), and writeCsvFile().
isUserRoot | ( | ) |
Checks if the current user is the root-user
Definition at line 823 of file functions_usercake.php.
References DEFAULT_ADMIN_ACCOUNT, isUserLoggedIn(), and MASTER_ACCOUNT.
Referenced by accessGranted(), deleteSponsorPermanently(), deleteUsersPermanently(), and isUserAdministrator().
isValidName | ( | $name) |
Checks whether the name only contains alphabetical values and values that might be allowed by prepare... functions
string | $name | the name to check |
Definition at line 285 of file functions_usercake.php.
Referenced by usernameExists().
lang | ( | $key, | |
$markers = NULL |
|||
) |
Inputs language strings from selected language.
string | $key | The key of the language string in the corresponding language file |
array | $markers | Replacements for gaps in the language string |
Definition at line 153 of file functions_usercake.php.
References $lang.
Referenced by acceptPasswordRequest(), deletePermission(), denyPasswordRequest(), and User\userCakeAddUser().
minMaxRange | ( | $min, | |
$max, | |||
$what | |||
) |
Checks if a (trimed) string is within a min and max length
integer | $min | the minimal length |
integer | $max | the maximal length |
string | $what | the string to check |
Definition at line 185 of file functions_usercake.php.
mobileExists | ( | $mobile) |
Check whether a mobile number is already in the database
string | $mobile | the mobile number to check |
Definition at line 485 of file functions_usercake.php.
Referenced by User\__construct().
pageIdExists | ( | $pageId) |
Check if a page ID exists
integer | $pageId | the id to check |
Definition at line 1764 of file functions_usercake.php.
permissionIdExists | ( | $permissionId) |
Check if a permission level ID exists in the DB
integer | $permissionId | the permission-id to check |
Definition at line 1405 of file functions_usercake.php.
permissionNameExists | ( | $permission) |
Check if a permission level name exists in the DB
string | $permission | the name of the permission to check |
Definition at line 1430 of file functions_usercake.php.
prepareNameForDatabase | ( | $name) |
Prepares names for the database e.g. removes trailing and leading whitespace, reduces multiple whitespace to a single one and so on
string | $name | the name to prepare |
Definition at line 259 of file functions_usercake.php.
prepareNamesForUsername | ( | $str) |
Prepares first- and lastname to be used as usernames e.g. replaces whitespace with '-'
string | $str | the input string |
Definition at line 223 of file functions_usercake.php.
removePermission | ( | $permissionId, | |
$userId | |||
) |
Unmatch permission level(s) from user(s)
mixed | $permissionId | |
mixed | $userId |
Definition at line 1589 of file functions_usercake.php.
References $db, $mysqli, ADMIN_PERMISSION, and DEFAULT_ADMIN_ACCOUNT.
replaceDefaultHook | ( | $str) |
Replaces hooks with specified text
string | $str | the string containing the detault hooks |
Definition at line 200 of file functions_usercake.php.
References $default_hooks, and $default_replace.
Referenced by UserCakeMail\newTemplateMsg().
resetStoredSession | ( | $userId) |
Resets the session-id to default value forces logout of the corresponding user
integer | $userId |
Definition at line 1814 of file functions_usercake.php.
References $db, $mysqli, and RESET_SESSION_ID.
Referenced by LoggedInUser\userLogOut().
resetValidMail | ( | $token) |
Resets the valid mail status
string | $token | the alphanumerical token to identify the user |
Definition at line 1934 of file functions_usercake.php.
Referenced by User\userCakeAddUser().
sanitize | ( | $str) |
Makes the string lowercase, removes trailing/leading whitespace and strips tags
string | $str | input string |
Definition at line 211 of file functions_usercake.php.
Referenced by User\__construct().
sessionIdExists | ( | $sessionId) |
Checks if a sessionid exists in the database
string | $sessionId |
Definition at line 311 of file functions_usercake.php.
Referenced by generateSessionId().
setMailValid | ( | $token) |
Change the valid_email-flag to valid
string | $token | the alphanumerical token |
Definition at line 964 of file functions_usercake.php.
setUserActive | ( | $token) |
Change a user from inactive to active
string | $token | the alphanumerical activation token |
Definition at line 944 of file functions_usercake.php.
setUserIDIncrement | ( | ) |
Sets the autoincrement value for user ids to 1000
Definition at line 444 of file functions_usercake.php.
Referenced by User\userCakeAddUser().
setUserLocked | ( | $userId) |
Change a user from active to locked
mixed | $userId | the id of the user who should get locked |
Definition at line 983 of file functions_usercake.php.
References $db, $mysqli, and DEFAULT_ADMIN_ACCOUNT.
setValidMail | ( | $token) |
Sets the email valid for a given token
string | $token | defines the user |
Definition at line 1955 of file functions_usercake.php.
updateEmail | ( | $userId, | |
$newEmail | |||
) |
Update a user's email
mixed | $userId | |
string | $newEmail | the new email-address |
Definition at line 1075 of file functions_usercake.php.
updateFirstname | ( | $userId, | |
$newFirstname | |||
) |
Change a user's firstname
mixed | $userId | |
string | $newFirstname | the new firstname of the user |
Definition at line 1009 of file functions_usercake.php.
updateLastActivationRequest | ( | $newActivationToken, | |
$username, | |||
) |
Input new activation token, and update the time of the most recent activation request
string | $newActivationToken | the new alphanumerical activation token |
string | $username | the username of the user |
string | the email-address of the user |
Definition at line 1120 of file functions_usercake.php.
updateLastname | ( | $userId, | |
$newLastname | |||
) |
Change a user's lastname
mixed | $userId | |
string | $newLastname |
Definition at line 1053 of file functions_usercake.php.
updateMailConfirmationToken | ( | $new_confirm_token, | |
$username | |||
) |
Sets a new token for the confirmation of the email-adress
string | $new_confirm_token | the new token |
string | $username | the username of the user where the token should be set |
Definition at line 1143 of file functions_usercake.php.
updateMobile | ( | $userId, | |
$mobile | |||
) |
Update a user's mobilephone number
mixed | $userId | |
string | $mobile | the new email-address |
Definition at line 1097 of file functions_usercake.php.
updatePageState | ( | $pageId, | |
$state | |||
) |
Toggle private/public/locked setting of a page
integer | $pageId | |
integer | $state | PAGE_PUBLIC, PAGE_PRIVATE, PAGE_LOCK |
Definition at line 1792 of file functions_usercake.php.
Referenced by accessGranted().
updatePasswordFromToken | ( | $newPasswordHash, | |
$oldToken | |||
) |
Generate a random password and new token
type | $newPasswordHash | |
type | $oldToken |
Definition at line 1165 of file functions_usercake.php.
References $db, $mysqli, and generateActivationToken().
Referenced by acceptPasswordRequest().
updatePermissionName | ( | $permissionId, | |
$newName | |||
) |
Change a permission level's name
integer | $permissionId | |
type | $newName |
Definition at line 1456 of file functions_usercake.php.
updateTitle | ( | $userId, | |
$title | |||
) |
Update a user's title
integer | $userId | the user-id of the user whos title is changed |
string | $title | the new title of the user |
Definition at line 1188 of file functions_usercake.php.
updateUsername | ( | $userId, | |
$newUsername | |||
) |
Change a user's username
mixed | $userId | |
string | $newUsername |
Definition at line 1031 of file functions_usercake.php.
userIdExists | ( | $userId) |
Check if a user ID exists in the DB
integer | $userId | the user-id to check |
Definition at line 1209 of file functions_usercake.php.
usernameExists | ( | $username) |
Checks if a username exists in the DB
string | $username | the username to check |
Definition at line 1237 of file functions_usercake.php.
References $db, $mysqli, and isValidName().
Referenced by User\__construct().
validateActivationToken | ( | $token, | |
$lostpass = FALSE |
|||
) |
Check if activation token exists in DB
string | $token | the token that should be validated |
mixed | $lostpass | [optional]
|
Definition at line 1272 of file functions_usercake.php.
Referenced by acceptPasswordRequest(), denyPasswordRequest(), and generateActivationToken().