## Class mr_preferences

Description

MR Preferences

Keeps track of user's course preferences in the session. Feel free to extend this class to provide some alternative storage (EG: store in a database table) but keep the session parts for caching hits.

- author: Mark Nielsen

Located in /preferences.php (line 36)

Variable Summary
int $courseid
string $plugin
Method Summary
mr_preferences __construct (int $courseid, string $plugin)
mr_preferences delete (string $name, [string $plugin = NULL], [int $courseid = NULL])
mixed get (string $name, [mixed $default = NULL], [string $plugin = NULL], [int $courseid = NULL])
int get_courseid ()
string get_plugin ()
mr_preferences load ()
void process_args ( &$courseid, &$plugin, int $courseid, string $plugin)
mr_preferences reload ()
mr_preferences set (string $name, mixed $value, [string $plugin = NULL], [int $courseid = NULL])
Variables
int $courseid = 0 (line 49)

The course ID

- access: protected

string $plugin = '' (line 42)

The plugin that the preferences belong

- access: protected

Methods
Constructor __construct (line 57)

Constructor: set defaults

- access: public

mr_preferences __construct (int $courseid, string $plugin)

- int $courseid: Course ID
- string $plugin: Plugin name, EG: blocks/blockname, block_blockname, etc

delete (line 179)

Delete a preference

- access: public

mr_preferences delete (string $name, [string $plugin = NULL], [int $courseid = NULL])

- string $name: Preference name
- string $plugin: Override plugin name
- int $courseid: Override course ID

get (line 139)

Get a preference

- access: public

mixed get (string $name, [mixed $default = NULL], [string $plugin = NULL], [int $courseid = NULL])

- string $name: Preference name
- mixed $default: Return this value if preference is not found
- string $plugin: Override plugin name
- int $courseid: Override course ID

get_courseid (line 126)

Get current courseid

- access: public

int get_courseid ()
get_plugin (line 117)

Get current plugin value

- access: public

string get_plugin ()
load (line 88)

Load the preferences for a user

- access: public

mr_preferences load ()
process_args (line 71)

Helper method - handle passed courseid and plugin values

- access: protected

void process_args ( &$courseid, &$plugin, int $courseid, string $plugin)

- int $courseid: Course ID
- string $plugin: Plugin name
- &$courseid
- &$plugin

reload (line 102)

Reload preferences

- access: public

mr_preferences reload ()
set (line 160)

Set a preference

- access: public

mr_preferences set (string $name, mixed $value, [string $plugin = NULL], [int $courseid = NULL])

- string $name: Preference name
- mixed $value: Value to save
- string $plugin: Override plugin name
- int $courseid: Override course ID

Documentation generated on Thu, 28 Jun 2012 16:33:50 -0700 by phpDocumentor 1.4.3