SetInitialValues(); } /** * Sets object to some sane initial values * * @since 0.6.1 */ function SetInitialValues() { $this->id = -1; $this->username = ''; $this->password = ''; $this->firstname = ''; $this->lastname = ''; $this->email = ''; $this->active = false; $this->adminaccess = false; } /** * Encrypts and sets password for the User * * @since 0.6.1 * @param string The plaintext password. */ function SetPassword($password) { $this->password = md5(get_site_preference('sitemask','').$password); } /** * Saves the user to the database. If no user_id is set, then a new record * is created. If the uset_id is set, then the record is updated to all values * in the User object. * * @returns mixed If successful, true. If it fails, false. * @since 0.6.1 */ function Save() { $result = false; if ($this->id > -1) { $gCms = cmsms(); $userops = $gCms->GetUserOperations(); $result = $userops->UpdateUser($this); } else { $gCms = cmsms(); $userops = $gCms->GetUserOperations(); $newid = $userops->InsertUser($this); if ($newid > -1) { $this->id = $newid; $result = true; } } return $result; } /** * Delete the record for this user from the database and resets * all values to their initial values. * * @returns mixed If successful, true. If it fails, false. * @since 0.6.1 */ function Delete() { $result = false; if ($this->id > -1) { $gCms = cmsms(); $userops = $gCms->GetUserOperations(); $result = $userops->DeleteUserByID($this->id); if ($result) { $this->SetInitialValues(); } } return $result; } } # vim:ts=4 sw=4 noet ?>