Stud.IP  4.0
 All Data Structures Namespaces Files Functions Variables Groups
SmileyFavorites Class Reference

Public Member Functions

 __construct ($user_id)
 
 get ()
 
 set ($favorites=[])
 
 contain ($smiley_id)
 
 toggle ($smiley_id, $favorite=null)
 

Static Public Member Functions

static isEnabled ()
 
static getUsage ()
 
static gc ()
 

Constructor & Destructor Documentation

__construct (   $user_id)

Initializes an user's favorites

Parameters
String$user_idId of the user

Member Function Documentation

contain (   $smiley_id)

Returns whether the smiley with the given id is favored by the user.

Parameters
int$smiley_idId of the smiley
Returns
bool True if the smiley is favored by the user, false otherwise
static gc ( )
static

Garbage collector. Removes all smiley ids from the users' favorites that are no longer in the database.

Returns
int Number of changed records
get ( )

Returns the user's favored smileys' ids.

Returns
Array Ids of the smileys the user has vaored
static getUsage ( )
static

Returns a list of how often a smiley has been favored.

Returns
Array Associative array with smiley name as key and according favored numbers as value
static isEnabled ( )
static

Returns whether the ability to favor smiley is enabled.

Returns
bool
set (   $favorites = [])

Updates the user's favored smileys.

Parameters
Array$favoritesIds of the user's favored smileys
toggle (   $smiley_id,
  $favorite = null 
)

Toggles whether a smiley is favored by the user. You can either provide an acutal state or omit the state to toggle the current state.

Parameters
int$smiley_idId of the smiley to favor/disfavor
mixed$favoriteEither a boolean state or null to toggle current state
Returns
bool True if the smiley is favored by the user, false otherwise

The documentation for this class was generated from the following file: