Class User

Description

The representation of a user

The representation of a user, outside of Authentification purposes, which are handled by PEAR Auth.

Note: this class assumes that the prefs field is a serialized value. It needs to be manipulated through set_pref(), get_pref() and others instead of the plain set() and get(), which still deal with the serialized data. Failure to use the proper API might lead to corruption of the prefs field.

Located in /User.php (line 61)

Storable
   |
   --User
Variable Summary
Method Summary
Customer allowed_customers (string $username)
void construct_prefs ()
void generateTimeSheet ([mixed $bounds = null])
void get_pref (string $pref)
void is_allowed (mixed $customer)
void listTimeEntries ([mixed $bounds = null], [mixed $project = null], [mixed $offset = null], [mixed $count = null])
void next ()
mixed punch ()
mixed punch_in (int $project, [mixed $comment = null])
mixed punch_out ([boolean $entry = true])
void push_pref (string $pref, [mixed $next_val = null])
void rate (mixed $customer)
void save ()
void set_pref (string $pref, [mixed $val = null])
Variables
mixed $_allowed_users_cache = null (line 72)
Array $_prefs (line 70)

The Object representation of the 'prefs' columns, which is normally a serialized value.

  • access: protected

Inherited Variables

Inherited from Storable

Storable::$_count
Storable::$_data
Storable::$_data_orig
Storable::$_db
Storable::$_dsn
Storable::$_exists
Storable::$_join
Storable::$_match
Storable::$_num_rows
Storable::$_num_rows_unlimited
Storable::$_offset
Storable::$_order
Storable::$_res
Storable::$_select
Methods
allowed_customers (line 288)

the customers a user has access to

WARNING!!!

The Customer object created uses a JOIN and might cause problems when saved. You have been warned.

Customer allowed_customers (string $username)
  • string $username: the user to check, the logged in user by default
allowed_customers_arr (line 310)

the list of allowed customers, as an array

Array allowed_customers_arr ()
construct_prefs (line 122)

unserialize the prefs data

Make the prefs member a valid member by unserializing the data stored in the database.

Backup the data array before doing so, because we can't back it up later on.

void construct_prefs ()
generateTimeSheet (line 267)
void generateTimeSheet ([mixed $bounds = null])
get_pref (line 154)

fetch the given preference

void get_pref (string $pref)
  • string $pref: the preference to get
is_allowed (line 331)

wether the customer is allowed for the user

void is_allowed (mixed $customer)
listTimeEntries (line 250)
void listTimeEntries ([mixed $bounds = null], [mixed $project = null], [mixed $offset = null], [mixed $count = null])
next (line 79)

Override the parent next()

This is done to have a consistent 'prefs' array

void next ()

Redefinition of:
Storable::next()
Load the next row available in this object.
punch (line 240)

The current punch.

  • return: a list made of the project id, the punch UNIX timestamp, and the punch comment or FALSE if there is no punch set.
  • usedby: User::punch_out()
  • uses: User::get_pref()
mixed punch ()
punch_in (line 191)

"punch in" in the given project

Note: this function immediatly save()s the data structure as not doing so will lead to inconsistency between the TimeEntry and the punch.

Sets the "punch" and "punchtime" preferences for later use by punch() and punch_out() the previous punch.

mixed punch_in (int $project, [mixed $comment = null])
  • int $project: the project id to punch into
punch_out (line 211)

Punch out.

Note: this function immediatly save()s the data structure as not doing so will lead to inconsistency between the TimeEntry and the punch.

Stop "counting" time for this project and add a related time entry, if necessary.

mixed punch_out ([boolean $entry = true])
  • boolean $entry: add a time entry
push_pref (line 140)

stack a preference in a preference array

  • todo: Warning: will reset the preference if it is not an array. We might want to change that.
void push_pref (string $pref, [mixed $next_val = null])
  • string $pref: the preference to set
  • mixed $next_val: the value to push into the preference array
rate (line 269)
void rate (mixed $customer)
save (line 96)

override the parent save()

Again, this is done to have a consistent 'prefs' value. We check here if the prefs were modified, and backup_data() if so.

void save ()

Redefinition of:
Storable::save()
Save the object in underlying storage.
set_pref (line 164)

set the given preference

void set_pref (string $pref, [mixed $val = null])
  • string $pref: the preference to set
  • mixed $val: the value to set it to

Inherited Methods

Inherited From Storable

Storable::Storable()
Storable::backup_data()
Storable::connect()
Storable::count()
Storable::disconnect()
Storable::exists()
Storable::feed_hash()
Storable::get()
Storable::get_data()
Storable::handle_result()
Storable::is_limited()
Storable::next()
Storable::num_rows()
Storable::num_rows_unlimited()
Storable::offset()
Storable::remove()
Storable::save()
Storable::set()
Storable::set_data()
Storable::start_request()
Storable::tablename()
Storable::where_clause()

Documentation generated on Tue, 11 Jan 2005 01:38:35 -0500 by phpDocumentor 1.3.0RC3