.

DAOUsers Class Reference
[Usermanagement]

Table Definition for users. More...

Inheritance diagram for DAOUsers:
DataObjectTimestampedCached IStatusHolder ISelfDescribing DataObjectCached ITimeStamped DataObjectBase IDataObject IActionSource ISearchAdapter IDBTable IDBWhereHolder DAOSystemUsers

List of all members.

Public Member Functions

  confirm ()
  Confirm user (set status to ACTIVE).
  confirmed_email ()
  Returns true if the email is confirmed.
  confirmed_tos ()
  Returns true, if the user confirmed the latest tos.
  create_token ($creator, $data)
  Create a user (and seed ) specific token.
  get_description ()
  Get description for this instance.
  get_filters ()
  Return array of user status filters.
  get_role_names ()
  Returns array of role names.
  get_roles ()
  Return roles of this user.
  get_sort_default_column ()
  Get the column to sort by default.
  get_sortable_columns ()
  Return array of sortable columns.
  get_status ()
  Returns status.
  get_title ()
  Get title for this class.
  has_role ($role)
  Returns true, if user has given role.
  is_active ()
  Returns true, if status is active.
  is_deleted ()
  Returns true, if status is deleted.
  is_disabled ()
  Returns true, if status is disabled.
  is_unconfirmed ()
  Returns true, if status is unconfirmed.
  password_match ($pwd)
  Check if password matches the user's one.
  set_status ($status)
  Set status.

Public Attributes

  $email
  $emailconfirmationdate
  $emailstatus
  $hash_type
  $id
  $name
  $password
  $status
  $tos_version

Protected Member Functions

  create_table_object ()
  do_get_role_names ($params)
  Returns array of role names.
  do_get_roles ($params)
  Return roles of this user (worker).
  get_actions_for_context ($context, $user, $params)
  To be overloaded.
  get_allowed_status ()
  Return array of allowed status for table description.

Detailed Description

Table Definition for users.

Author:
Gerd Riesselmann

Definition at line 10 of file users.model.php.


Member Function Documentation

DAOUsers::confirm (  ) 

Confirm user (set status to ACTIVE).

Definition at line 245 of file users.model.php.

00245                                   {
00246                 $this->status = Users::STATUS_ACTIVE;
00247         }
DAOUsers::confirmed_email (  ) 

Returns true if the email is confirmed.

Returns:
bool

Definition at line 104 of file users.model.php.

00104                                           {
00105                 return $this->emailstatus == Users::EMAIL_STATUS_CONFIRMED;
00106         }
DAOUsers::confirmed_tos (  ) 

Returns true, if the user confirmed the latest tos.

Returns:
bool

Definition at line 95 of file users.model.php.

00095                                         {
00096                 return $this->tos_version >= Config::get_value(ConfigUsermanagement::TOS_VERSION);
00097         }
DAOUsers::create_table_object (  )  [protected]

Reimplemented from DataObjectBase.

Definition at line 23 of file users.model.php.

00023                                                  {
00024                 return new DBTable(
00025                         'users',
00026                         array_merge(array(
00027                                 new DBFieldInt('id', null, DBFieldInt::AUTOINCREMENT | DBFieldInt::UNSIGNED | DBField::NOT_NULL),
00028                                 new DBFieldText('name', 100, null, DBField::NOT_NULL),
00029                                 new DBFieldTextEmail('email', null, DBField::NOT_NULL),
00030                                 new DBFieldText('password', 100, null, DBField::NOT_NULL),
00031                                 new DBFieldText('hash_type', 5, 'md5', DBField::NOT_NULL | DBField::INTERNAL),
00032                                 new DBFieldDateTime('emailconfirmationdate', null, DBField::NONE | DBField::INTERNAL), 
00033                                 new DBFieldEnum('emailstatus', array_keys(Users::get_email_statuses()), Users::EMAIL_STATUS_UNCONFIRMED, DBField::NOT_NULL | DBField::INTERNAL),
00034                                 new DBFieldInt('tos_version', 0, DBFieldInt::UNSIGNED | DBField::NOT_NULL | DBField::INTERNAL), 
00035                                 new DBFieldEnum('status', array_keys($this->get_allowed_status()), Users::STATUS_UNCONFIRMED, DBField::NOT_NULL | DBField::INTERNAL),
00036                                 ), $this->get_timestamp_field_declarations()
00037                         ),
00038                         'id'
00039                 );
00040         }
DAOUsers::create_token ( creator,
data  
)

Create a user (and seed ) specific token.

Parameters:
string  $creator Module or class (or more wider: name of) creating the token. Is is part of the seed
string|array  $data Data passed into seed

Definition at line 75 of file users.model.php.

00075                                                       {
00076                 $src = '';
00077                 $src .= $this->email;
00078                 $src .= $this->password;
00079                 $src .= $creator;
00080                 $src .= $this->id;
00081                 if (is_array($data)) {
00082                         $data = Arr::implode('ยง', $data, '~');
00083                 }
00084                 $src .= $data;
00085                 $src .= $this->get_creation_date(); // modificationdate ist not that stable
00086                 $src .= $this->name;
00087                 return sha1($src);
00088         }
DAOUsers::do_get_role_names ( params  )  [protected]

Returns array of role names.

Returns:
array

Definition at line 232 of file users.model.php.

00232                                                       {
00233                 $ret = array();
00234                 foreach($this->get_roles() as $role) {
00235                         $t = trim($role->name);
00236                         $ret[$t] = $t;
00237                 }
00238                 return $ret;
00239         }
DAOUsers::do_get_roles ( params  )  [protected]

Return roles of this user (worker).

Returns:
array

Definition at line 56 of file users.model.php.

00056                                                  {
00057                 return UserRoles::get_for_user($this->id);
00058         }       
DAOUsers::get_actions_for_context ( context,
user,
params  
) [protected]

To be overloaded.

Returns array of actions with action title as key and action description as value

Subclasses can return array of actions, this class will detect if they are commands or actions.

Optionally, params can be added in brackets like 'status[DISABLED]' => 'Disable this item'.

Parameters:
string  $context
mixed  $user
mixed  $params
Returns:
array

Reimplemented from DataObjectBase.

Definition at line 313 of file users.model.php.

00313                                                                              {
00314                 $ret = array();
00315                 $ret['edit'] = tr('Edit user', 'users');
00316                 
00317                 $arrStates = array(
00318                         Users::STATUS_ACTIVE,
00319                         Users::STATUS_DISABLED,
00320                         Users::STATUS_DELETED
00321                 );
00322                 foreach($arrStates as $state) {
00323                         $cmd = 'status[' . $state . ']';
00324                         $desc = tr('Set ' . $state); 
00325                         $ret[$cmd] = $desc;
00326                 }
00327                 return $ret;
00328         }
DAOUsers::get_allowed_status (  )  [protected]

Return array of allowed status for table description.

Returns:
array

Definition at line 65 of file users.model.php.

00065                                                 {
00066                 return Users::get_statuses();   
00067         }
DAOUsers::get_description (  ) 

Get description for this instance.

Returns:
string

Implements ISelfDescribing.

Definition at line 134 of file users.model.php.

00134                                           {
00135                 return '';      
00136         }
DAOUsers::get_filters (  ) 

Return array of user status filters.

Array has filter as key and a readable description as value

Reimplemented from DataObjectBase.

Definition at line 256 of file users.model.php.

00256                                       {
00257                 return array(
00258                         new DBFilterGroup(
00259                                 'status',
00260                                 tr('Status'),
00261                                 array(
00262                                         'unconfirmed' => new DBFilterColumn('users.status', Users::STATUS_UNCONFIRMED, tr('Unconfirmed', 'users')),
00263                                         'disabled' => new DBFilterColumn('users.status', Users::STATUS_DISABLED, tr('Disabled', 'users')),
00264                                         'deleted' => new DBFilterColumn('users.status', Users::STATUS_DELETED, tr('Deleted', 'users')),
00265                                         'active' => new DBFilterColumn('users.status', Users::STATUS_ACTIVE, tr('Active', 'users')),
00266                                 )
00267                         ),
00268                         // TODO Rewrite
00269                         /*
00270                         new DBFilterGroup(
00271                                 'role',
00272                                 tr('User Role', 'users'),
00273                                 array(
00274                                         'admin' => new DBFilterColumn('users.role', USER_ROLE_ADMIN, tr('Admin', 'users')),
00275                                         'user' => new DBFilterColumn('users.role', USER_ROLE_USER, tr('User', 'users')),
00276                                         'editor' => new DBFilterColumn('users.role', USER_ROLE_EDITOR, tr('Editor', 'users')),
00277                                 )
00278                         )
00279                         */
00280                 );
00281         }
DAOUsers::get_role_names (  ) 

Returns array of role names.

Returns:
array

Reimplemented in DAOSystemUsers.

Definition at line 223 of file users.model.php.

00223                                          {
00224                 return $this->get_from_cache('userrolenames', 'do_get_role_names');
00225         }
DAOUsers::get_roles (  ) 

Return roles of this user.

Returns:
array

Definition at line 47 of file users.model.php.

00047                                     {
00048                 return $this->get_from_cache('userroles', 'do_get_roles');
00049         }
DAOUsers::get_sort_default_column (  ) 

Get the column to sort by default.

Reimplemented from DataObjectBase.

Definition at line 297 of file users.model.php.

00297                                                   {
00298                 return 'name';
00299         }
DAOUsers::get_sortable_columns (  ) 

Return array of sortable columns.

Array has column name as key and some sort of sort-column-object or an array as values

Reimplemented from DataObjectBase.

Definition at line 286 of file users.model.php.

00286                                                {
00287                 return array(
00288                         'name' => new DBSortColumn('name', tr('Name', 'users'), DBSortColumn::TYPE_TEXT),       
00289                         'email' => new DBSortColumn('email', tr('E-mail', 'users'), DBSortColumn::TYPE_TEXT),
00290                         'creationdate' => new DBSortColumn('creationdate', tr('Registered since', 'users'), DBSortColumn::TYPE_DATE)
00291                 );
00292         }
DAOUsers::get_status (  ) 

Returns status.

Returns:
string

Implements IStatusHolder.

Reimplemented in DAOSystemUsers.

Definition at line 156 of file users.model.php.

00156                                      {
00157                 return $this->status;
00158         }
DAOUsers::get_title (  ) 

Get title for this class.

Returns:
string

Implements ISelfDescribing.

Definition at line 125 of file users.model.php.

00125                                     {
00126                 return $this->name;
00127         }
DAOUsers::has_role ( role  ) 

Returns true, if user has given role.

Parameters:
string|array  $role The role(s) to check for. If param is array, it is checked if user has any of the roles passed
Returns:
bool

Definition at line 206 of file users.model.php.

00206                                         {
00207                 $ret = false;
00208                 $my_roles = $this->get_role_names();
00209                 foreach(Arr::force($role) as $check) {
00210                         if (array_key_exists($check, $my_roles)) {
00211                                 $ret = true;
00212                                 break;
00213                         }
00214                 }
00215                 return $ret;
00216         }
DAOUsers::is_active (  ) 

Returns true, if status is active.

Returns:
bool

Implements IStatusHolder.

Reimplemented in DAOSystemUsers.

Definition at line 165 of file users.model.php.

00165                                     {
00166                 return $this->status == Users::STATUS_ACTIVE;
00167         }
DAOUsers::is_deleted (  ) 

Returns true, if status is deleted.

Returns:
bool

Implements IStatusHolder.

Reimplemented in DAOSystemUsers.

Definition at line 183 of file users.model.php.

00183                                      {
00184                 return $this->status == Users::STATUS_DELETED;
00185         }
DAOUsers::is_disabled (  ) 

Returns true, if status is disabled.

Returns:
bool

Implements IStatusHolder.

Reimplemented in DAOSystemUsers.

Definition at line 192 of file users.model.php.

00192                                       {
00193                 return $this->status == Users::STATUS_DISABLED;
00194         }
DAOUsers::is_unconfirmed (  ) 

Returns true, if status is unconfirmed.

Returns:
bool

Implements IStatusHolder.

Reimplemented in DAOSystemUsers.

Definition at line 174 of file users.model.php.

00174                                          {
00175                 return $this->status == Users::STATUS_UNCONFIRMED;
00176         }
DAOUsers::password_match ( pwd  ) 

Check if password matches the user's one.

Definition at line 111 of file users.model.php.

00111                                              {
00112                 $algo = Users::create_hash_algorithm($this->hash_type);
00113                 return $algo->check($pwd, $this->password);
00114         }
DAOUsers::set_status ( status  ) 

Set status.

Parameters:
string  $status

Implements IStatusHolder.

Definition at line 147 of file users.model.php.

00147                                             {
00148                 $this->status = $status;
00149         }

Member Data Documentation

DAOUsers::$email

Definition at line 15 of file users.model.php.

DAOUsers::$emailconfirmationdate

Definition at line 16 of file users.model.php.

DAOUsers::$emailstatus

Definition at line 17 of file users.model.php.

DAOUsers::$hash_type

Definition at line 14 of file users.model.php.

DAOUsers::$id

Definition at line 11 of file users.model.php.

DAOUsers::$name

Definition at line 12 of file users.model.php.

DAOUsers::$password

Definition at line 13 of file users.model.php.

DAOUsers::$status

Definition at line 19 of file users.model.php.

DAOUsers::$tos_version

Definition at line 18 of file users.model.php.


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