Reference Manuals


PreferencesMixIn — A user preferences mixin for the User module

PreferencesMixIn is part of the User package.


class PreferencesMixIn extends UserMixIn {
        public         string              $db_preferences
        public         string              $db_user_preferences
        public         array               $preference

        public         void                destroy                   ( void );
        public         void                init                      ( User &$user );
        private        void                load_defaults             ( void );
        public         void                save_preferences          ( void );
        public         void                start                     ( void );

Object Hierarchy



A user preferences mixin for the User module

This extension implements a simple user preferences system for the User module. Preferences can be accessed through the $preferences attribute. This extension requires two database tables. The table names are defined in $db_preferences and $db_user_preferences.

 CREATE TABLE preferences (
   preference_name VARCHAR(64),
   preference_default TEXT

 CREATE TABLE user_preferences (
   preference_name VARCHAR(64),
   preference_value TEXT

Attribute Details


public         string         $db_preferences

The name of the preferences table

Default value: empty string


public         string         $db_user_preferences

The name of the user_preferences table

Default value: empty string


public         array          $preference

An associative array containing all preferences and their values

Default value: empty string

Method Details


public         void           destroy                   ( void );

Set the options back to default when stopping a session


public         void           init                      ( User &$user );

Initialize the extension and load $preference with the default values

A reference to the User object


private        void           load_defaults             ( void );

Load the default options


public         void           save_preferences          ( void );

Save the preferences to the database

This will only save the preferences which exist in the preferences table and which differ from the defaults.


public         void           start                     ( void );

Load a user's specific preferences