spunQ_User Class Reference

A user of the application. More...

Inheritance diagram for spunQ_User:

spunQ_StorableObject spunQ_IDatabaseInstantiationListener spunQ_DataObject

List of all members.

Public Member Functions

 setUsername ($username)
 Overriden getter to set lower username.
 inGroup ($group)
 Checks if the user is in given group.
 inEitherGroup ($groups)
 Checks if the user is in either of the given groups.
 getGroupNames ()
 Gets the names of the groups this user is in.
 _getDisplayString ()
 Returns the object name to be used for human readable output.
 creatingDatabaseInstance ($name)
 Called when the database is about to be created by the factory.
 createdDatabaseInstance ($name, spunQ_IDatabaseConnection $connection)
 Called when the database connection has been established.
 getOwnGroup ()
 returns the spunQ_Group of this user
 setId ($id)
 Setter for the id.
 getId ()
 Getter for the id.
 store ()
 Will either insert or update a row in the database.
 insert ()
 Will insert this object into the database.
 delete ()
 Will remove this object from the database.
 update ()
 Will Update the members of this object in the database.
 assureExists ()
 Throws an exception if this object does not exist in the database.
 setConnection (spunQ_IDatabaseConnection $connection)
 Sets the connection that is persisting this object.
 getConnection ()
 Gets the connection that is persisting this object.
 handleSet ($memberName, $arguments, $functionName)
 Overridden to mark the member as locally modified.
 _loadRemoteValues (array $values, $checkValues=true)
 Loads members that have been fetched with a query.
 _invalidateRemoteValues (array $memberNames)
 _remoteValueLoaded ($memberName)
 Cheks whether a remote value for given member was loaded.
 referencingObjects ($otherType, $otherMember, $order=NULL, $limit=NULL)
 Gets the objects having the current one associated.
 referencingObjectIds ($otherType, $otherMember, $order=NULL, $limit=NULL)
 Gets the objects having the current one associated.
 countReferencingObjects ($otherType, $otherMember)
 Counts the objects having the current one associated.
 __call ($functionName, $arguments)
 Overloaded to provide automatic getters and setters.
 __sleep ()
 Replaces $_type with the type's name.
 _verifyMembers ($omittedMembers=array(), $throwException=true)
 Verifies that all members are valid.
 _getMember ($name)
 Gets the value of a member of this object.
 _setMember ($name, $value)
 Sets the value of a member of this object.
 _getType ($throwException=true)
 Gets the type of this object.

Static Public Member Functions

static setCurrent (spunQ_User $new)
 Sets the currently active user.
static getCurrent ()
 Gets the currently active user.
static getGuest ()
 Retrieves the guest user.
static create ($username, $groups=array(), $store=true)
static insertMultiple (array $objects, spunQ_IDatabaseConnection $connection=NULL)
 Updates multiple objects at once.
static updateMultiple (array $objects)
 Updates multiple objects at once.
static deleteMultiple (array $objects)
 Deletes multiple objects at once.
static sortByDisplayString ($objects)
 Sorts storable objects by their object names.
static valueByProperty ($value, $path)
 Transforms a value using a property path.
static propertyOfValue ($value, $property)
 Gets a single property of a value.

Static Public Attributes

static $guest = NULL
 The guest user.

Protected Member Functions

 loadMember ($memberName)
 Fetches the value of a member of this object from the database.
 handleGet ($memberName, $arguments, $functionName)
 Overridden to possibly retrieve the value from the database.
 handleAdd ($memberName, $arguments, $functionName)
 Overridden to fetch data before manipulation.
 handleRemove ($memberName, $arguments, $functionName)
 Overridden to fetch data before manipulation.
 handleGetUntranslated ($memberName, $arguments, $functionName)
 Overridden to fetch data.
 handleGetFromArray ($memberName, $arguments, $functionName)
 Overridden to fetch data.
 initLocalizedMember ($memberName)
 Makes sure a localized member contains a spunQ_Map.

Static Protected Member Functions

static loadInjectedMember ($connection, spunQ_InjectedMember $injectedMember)
 Loads injected members for several objects.

Protected Attributes

 $username
 User's login name.
 $usernameLower
 User's login name in lower case letters.
 $locale
 The locale to use for this user.
 $groups = array()
 The groups this user is a member of.
 $id
 The unique id of this object.
 $remoteValues = array()
 Members that have been loaded from the database.
 $locallyModifiedMembers = array()
 
 $connection = NULL
 The connection that is persisting this object.
 $_type
 The actual type of this object.

Static Protected Attributes

static $current = NULL
 The user that is currently active.


Detailed Description

A user of the application.

Definition at line 6 of file User.type.php.


Member Function Documentation

spunQ_DataObject::__call ( functionName,
arguments 
) [inherited]

Overloaded to provide automatic getters and setters.

Parameters:
$functionName The function that was called.
$arguments Array containing the arguments that were passed to the function.
Exceptions:
spunQ_BadArgumentCountError 

Definition at line 148 of file DataObject.type.php.

spunQ_DataObject::__sleep (  )  [inherited]

Replaces $_type with the type's name.

Returns:
array<string>

Reimplemented in spunQ_ArrayType, spunQ_MapType, and spunQ_SetType.

Definition at line 178 of file DataObject.type.php.

spunQ_User::_getDisplayString (  ) 

Returns the object name to be used for human readable output.

Returns:
strung

Reimplemented from spunQ_StorableObject.

Definition at line 147 of file User.type.php.

spunQ_DataObject::_getMember ( name  )  [inherited]

Gets the value of a member of this object.

Will check if the object has a getter for the member and will use that method for getting the value. Otherwise, the value of the object member is returned.

Parameters:
$name The name of the member.
Returns:
any Whatever type the member has.

Definition at line 478 of file DataObject.type.php.

spunQ_DataObject::_getType ( throwException = true  )  [inherited]

Gets the type of this object.

Returns:
spunQ_Type

Definition at line 507 of file DataObject.type.php.

spunQ_StorableObject::_loadRemoteValues ( array $  values,
checkValues = true 
) [inherited]

Loads members that have been fetched with a query.

This function is only intended to process the objects own members. It will handle concatenated member names incorrectly (i.e. origin.country.name will not work as expected.) This behaviour is expected to change in future releases, though.

Parameters:
$values An entry in an array that was returned by spunQ_ISelectQuery::execute() with a return mode of RETURN_ARRAY.
$checkValues Whether the values should be run through the check() functions of the members types. This value will be ignored in deployment mode, so it is generally advised to leave this as-is. Its purpose is to speed up the framework in development mode.
Returns:
spunQ_StorableObject $this

Definition at line 394 of file StorableObject.type.php.

spunQ_StorableObject::_remoteValueLoaded ( memberName  )  [inherited]

Cheks whether a remote value for given member was loaded.

A remote value can only be loaded using _loadRemoteValues().

Returns:
boolean

Definition at line 453 of file StorableObject.type.php.

spunQ_DataObject::_setMember ( name,
value 
) [inherited]

Sets the value of a member of this object.

Will check if the object has a setter for the member and will use that method for setting the value. Otherwise, the object member is set directly.

Parameters:
$name The name of the member.
$value The value to set it to.
Returns:
spunQ_DataObject $this

Definition at line 495 of file DataObject.type.php.

spunQ_DataObject::_verifyMembers ( omittedMembers = array(),
throwException = true 
) [inherited]

Verifies that all members are valid.

This function is called from various modules prior to critical actions requiring a complete object - like inserting into a database.

Parameters:
$omittedMembers Do not perform checks on these member names.
$throwException Whether an exception should be thrown if a member does not have a valid value.
Returns:
boolean
Exceptions:
spunQ_IllegalValueException 

Definition at line 458 of file DataObject.type.php.

spunQ_StorableObject::assureExists (  )  [inherited]

Throws an exception if this object does not exist in the database.

Will try to fetch some members for this object. Note that one should not rely on the result of this method. The entry in the database could be deleted even before this function returns (a typical race condition).

Returns:
spunQ.db.StorableObject $this
Todo:
implement me

Definition at line 336 of file StorableObject.type.php.

spunQ_User::createdDatabaseInstance ( name,
spunQ_IDatabaseConnection connection 
)

Called when the database connection has been established.

Parameters:
$name Name of the connection.
$connection The connection object that was created.
Returns:
void

Implements spunQ_IDatabaseInstantiationListener.

Definition at line 164 of file User.type.php.

spunQ_User::creatingDatabaseInstance ( name  ) 

Called when the database is about to be created by the factory.

Parameters:
$name Name of the connection.
Returns:
void

Implements spunQ_IDatabaseInstantiationListener.

Definition at line 157 of file User.type.php.

spunQ_StorableObject::delete (  )  [inherited]

Will remove this object from the database.

Returns:
spunQ.db.StorableObject $this

Definition at line 294 of file StorableObject.type.php.

static spunQ_StorableObject::deleteMultiple ( array $  objects  )  [static, inherited]

Deletes multiple objects at once.

Using this function instead of calling delete() on all objects can lead to a performance increase.

Parameters:
$objects The objects to delete.
Returns:
void
Exceptions:
spunQ_InvalidArgumentError If the objects are managed by different connections.

Definition at line 107 of file StorableObject.type.php.

spunQ_StorableObject::getConnection (  )  [inherited]

Gets the connection that is persisting this object.

Returns:
spunQ_IDatabaseConnection

Definition at line 364 of file StorableObject.type.php.

static spunQ_User::getCurrent (  )  [static]

Gets the currently active user.

Returns:
spunQ.user.User

Definition at line 28 of file User.type.php.

spunQ_User::getGroupNames (  ) 

Gets the names of the groups this user is in.

Returns:
array<string>

Definition at line 139 of file User.type.php.

static spunQ_User::getGuest (  )  [static]

Retrieves the guest user.

Returns:
spunQ.user.User

Definition at line 45 of file User.type.php.

spunQ_StorableObject::getId (  )  [inherited]

Getter for the id.

Returns:
integer

Definition at line 265 of file StorableObject.type.php.

spunQ_User::inEitherGroup ( groups  ) 

Checks if the user is in either of the given groups.

Parameters:
$group Array with combinations of group names and/or spunQ_Group objects.
Returns:
boolean True if the user is in at least one of the groups.

Definition at line 124 of file User.type.php.

spunQ_User::inGroup ( group  ) 

Checks if the user is in given group.

Parameters:
$group Either the name of the group or a spunQ_Group object.
Returns:
boolean

Definition at line 111 of file User.type.php.

spunQ_DataObject::initLocalizedMember ( memberName  )  [protected, inherited]

Makes sure a localized member contains a spunQ_Map.

Parameters:
$memberName The name of the member. This member must have the option 'localized'.
Returns:
void

Definition at line 245 of file DataObject.type.php.

spunQ_StorableObject::insert (  )  [inherited]

Will insert this object into the database.

Returns:
spunQ.db.StorableObject $this

Definition at line 285 of file StorableObject.type.php.

static spunQ_StorableObject::insertMultiple ( array $  objects,
spunQ_IDatabaseConnection connection = NULL 
) [static, inherited]

Updates multiple objects at once.

Using this function instead of calling insert() on all objects can lead to a performance increase.
WARNING: The objects passed as first parameter must have the same type. WARNING: This function will set the objects' $connection attribute to the given value.

Parameters:
$objects The objects to insert.
$connection The database connection to use for persisting the objects. The default connection will be used if omitted.
Returns:
void

Definition at line 37 of file StorableObject.type.php.

static spunQ_StorableObject::loadInjectedMember ( connection,
spunQ_InjectedMember $  injectedMember 
) [static, protected, inherited]

Loads injected members for several objects.

Parameters:
$connection Connection to use for queries.
$injectedMember The member to load. return void

Definition at line 181 of file StorableObject.type.php.

spunQ_StorableObject::loadMember ( memberName  )  [protected, inherited]

Fetches the value of a member of this object from the database.

Parameters:
$memberName The name of the member to load.
Returns:
spunQ.db.StorableObject $this

Definition at line 491 of file StorableObject.type.php.

static spunQ_DataObject::propertyOfValue ( value,
property 
) [static, inherited]

Gets a single property of a value.

See also:
valueByProperty()
Parameters:
$value The value to fetch property for.
$property The property to fetch.
Returns:
any

Definition at line 74 of file DataObject.type.php.

spunQ_StorableObject::setConnection ( spunQ_IDatabaseConnection connection  )  [inherited]

Sets the connection that is persisting this object.

Parameters:
$connection The connection managing $this.
Returns:
spunQ_StorableObject $this

Definition at line 349 of file StorableObject.type.php.

static spunQ_User::setCurrent ( spunQ_User new  )  [static]

Sets the currently active user.

Parameters:
$new The new active user.
Returns:
spunQ.user.User

Definition at line 19 of file User.type.php.

spunQ_StorableObject::setId ( id  )  [inherited]

Setter for the id.

This function is called very frequently - this implemetation is in fact an optimization (otherwise we'd run through spunQ_DataObject::__call() each time).

Returns:
spunQ_StorableObject $this

Definition at line 256 of file StorableObject.type.php.

static spunQ_StorableObject::sortByDisplayString ( objects  )  [static, inherited]

Sorts storable objects by their object names.

Parameters:
$objects an array of storable objects.
Returns:
string

Definition at line 158 of file StorableObject.type.php.

spunQ_StorableObject::store (  )  [inherited]

Will either insert or update a row in the database.

Returns:
spunQ.db.StorableObject $this

Definition at line 273 of file StorableObject.type.php.

spunQ_StorableObject::update (  )  [inherited]

Will Update the members of this object in the database.

Returns:
spunQ.db.StorableObject $this

Definition at line 303 of file StorableObject.type.php.

static spunQ_StorableObject::updateMultiple ( array $  objects  )  [static, inherited]

Updates multiple objects at once.

Using this function instead of calling update() on all objects can lead to a performance increase.

Parameters:
$objects The objects to update.
Returns:
void
Exceptions:
spunQ_InvalidArgumentError If the objects are managed by different connections.

Definition at line 77 of file StorableObject.type.php.

static spunQ_DataObject::valueByProperty ( value,
path 
) [static, inherited]

Transforms a value using a property path.

Some types are considered to have properties within spunQ. These properties can be referred to using property path definitions. The most simple case for properties is the user type, for which every member is considered a property. Concatenations of these paths with dots as separators are called property path. The list of all users in the primary group of a given user can be described using this method in a string: 'primaryGroup.users'.
Different types have different properties:

  • UserType: As already mentioned, every member of a user type is a property of an object of that type.
  • Map:
    • _keys: An array of the keys of the map.
    • _values: An array of the values of the map. Note that _keys and _values are guaranteed to return arrays where the index of a key matches the index of its value in the according result.
    • _key: The first entry of the _keys property. This is handy for referencing the key of single key/value pairs.
    • _value: The first entry of the _values property.
    • _count: The amount of items in the map.
  • Array:
    • _keys: The array of keys of the array. Note that the difference between arrays and maps in spunQ is that arrays are always numerically indexed! So this will always return an array containing a range of integers.
    • _values: Array of values in this array. This essentially returns the array as-is and is a NOOP.
    • _key: The first entry of the _keys property.
    • _value: The first entry of the _values property.
    • _count: The amount of items in the array.
  • String:
    • _length: The length of the string.
Parameters:
$value The value to transform
$path The property path to use for the transformation. This can either be a string as described, or an array, each entry holding a property name.
Returns:
any The described value.
Todo:
refactor

Definition at line 54 of file DataObject.type.php.


Member Data Documentation

spunQ_DataObject::$_type [protected, inherited]

The actual type of this object.

Type:
spunQ.Type

Definition at line 129 of file DataObject.type.php.

spunQ_StorableObject::$connection = NULL [protected, inherited]

The connection that is persisting this object.

spunQ_IDatabaseConnection

Definition at line 247 of file StorableObject.type.php.

spunQ_User::$current = NULL [static, protected]

The user that is currently active.

Type:
spunQ.user.User

Definition at line 12 of file User.type.php.

spunQ_User::$groups = array() [protected]

The groups this user is a member of.

Type:
array<spunQ.user.Group>

Definition at line 96 of file User.type.php.

spunQ_User::$guest = NULL [static]

The guest user.

Type:
spunQ.user.User

Definition at line 39 of file User.type.php.

spunQ_StorableObject::$id [protected, inherited]

The unique id of this object.

Having a base class for all storable objects which holds an id has an important side effect: The id is unique across all tables. integer

Definition at line 228 of file StorableObject.type.php.

spunQ_User::$locale [protected]

The locale to use for this user.

Type:
spunQ.language.Locale

Definition at line 90 of file User.type.php.

spunQ_StorableObject::$remoteValues = array() [protected, inherited]

Members that have been loaded from the database.

map<string,any>

Definition at line 235 of file StorableObject.type.php.

spunQ_User::$username [protected]

User's login name.

Type:
string

Definition at line 74 of file User.type.php.

spunQ_User::$usernameLower [protected]

User's login name in lower case letters.

Type:
string

Definition at line 83 of file User.type.php.


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

Generated on Fri Jul 1 11:12:44 2011 for spunQ3 by  doxygen 1.5.9