Repository navigation
User.php
Strongbeard edited this page Nov 13, 2014
·
6 revisions
A User class that serves as a middle-man between the database and the front-end and other back-end scripts.
- fromDatabase
- withValues
- getEmail
- getIsAdmin
- getIsStudent
- getIsTA
- getIsTutor
- getUserId
- getUsername
- setEmail
- setIsAdmin
- setIsStudent
- setIsTA
- setIsTutor
- setPassword
- setUserId
- setUsername
- login
- logout
- store
Constructor that draws user information from the database using a unique column key and value.
- $unique_column = String. Must be 'userid', 'username', 'email', or 'rin'. Specifies the unique column name in the user table to search for the user with.
- $value = String or unsigned int. Unique id value that identifies the user in the database.
Constructor that builds a new user from the provided parameters. Does NOT add the user to the database.
- $username = Unique username, used to log the user into the system.
- $password = Password in plain-text. The constructor will encrypt it for storage.
- $email = User email address.
- $isStudent = Boolean variable specifying if user is a student or not. Used to determine what content to show the user.
- $isTA = Boolean variable specifying if user is a TA or not. Used to determine what content to show the user.
- $isTutor = Boolean variable specifying if user is a private Tutor or not. Used to determine what content to show the user.
- $isAdmin = Boolean variable specifying if user is a system admin or not. Allows the users to access tools to directly edit the site's data.
Creates a user session and adds the user object to the $_SESSION['user'] variable.
Destroys the current user session.
Adds/Updates the user in the database. If new user to the database, gets a new userid from MYSQL's auto_increment and sets $uid with the value.