new User - jcobban/Genealogy GitHub Wiki

new User($parms)

Up: class User

The constructor for an instance of User takes one parameter:

parameter description
$parms identifies the database record to be associated with this instance. This is an associative array.

$parms may be:

  • An associative array containing all of the fields in a record as obtained by a database SELECT, or
  • array('id' => integer) specifies the unique numeric key of the existing record in the table that is to be used to initialize the new instance. This is deprecated: use 'username', or 'email', or 'persistence' to obtain a unique record, or
  • array('username' => string) specifies the unique user name key of the existing record in the table that is to be used to initialize the new instance, or
  • array('email' => string) specifies the unique email address key of the existing record in the table that is to be used to initialize the new instance, or
  • array('persistence' => string) specifies the session persistence key of the existing record in the table that is to be used to initialize the new instance, or
  • array('username' => string, 'password' => string, 'email' => string) creates a new instance of User. The password value is hashed and stored in 'shapassword', the 'auth' field is set to 'pending', and an e-mail is sent to the user to authenticate the e-mail address.

The constructor adds error messages to $record->msg if it is unable to complete due to bad parameters. In particular if the supplied email address matches any already existing record an error message is added identifying the other user name. If there are any such messages $user->save() will fail.

Next: $user->can($action)