Skip to content

User.php

Strongbeard edited this page Nov 13, 2014 · 6 revisions

User.php

A User class that serves as a middle-man between the database and the front-end and other back-end scripts.

Functions

  • fromDatabase
  • withValues
  • getEmail
  • getIsAdmin
  • getIsStudent
  • getIsTA
  • getIsTutor
  • getUserId
  • getUsername
  • setEmail
  • setIsAdmin
  • setIsStudent
  • setIsTA
  • setIsTutor
  • setPassword
  • setUserId
  • setUsername
  • login
  • logout
  • store

fromDatabase

Constructor that draws user information from the database using a unique column key and value.

Parameters

  • $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.

withValues

Constructor that builds a new user from the provided parameters. Does NOT add the user to the database.

Parameters

  • $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.

login

Creates a user session and adds the user object to the $_SESSION['user'] variable.

logout

Destroys the current user session.

store

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.

Clone this wiki locally