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

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. Optional. Specifies if user is a student or not. Used to determine what content to show the user.
  • $isTA = Boolean. Optional. Specifies if user is a TA or not. Used to determine what content to show the user.
  • $isTutor = Boolean. Optional. Specifies if user is a private Tutor or not. Used to determine what content to show the user.
  • $isAdmin = Boolean. Optional. Specifies 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.

Parameters

  • $password = String. Plain-text password the user entered to verify their identity. Will be hashed and checked against the hashed password form the database.

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.

verify_password

Password verification. Use Login instead.

Parameters

  • $password = String. Plain-text password the user entered to verify their identity. Will be hashed and checked against the hashed password form the database.

Clone this wiki locally