From The Smartest Wiki
Jump to: navigation, search

SmartestUser is the basic data object class for all authenticating users in Smartest. For system users that log into the Smartest backend, the class is extended with additional system-specific functionalities in SmartestSystemUser.

Standard methods and offsets

  • getId() and setId($id) map onto database field user_id
  • getUsername() and setUsername($username) map onto database field username


As a descendant of SmartestDataObject, SmartestUser has the standard set of get/set functions for its actual database fields. These methods' names are generated from database column names, minus their 'user_' prefix, so that for example user_bio_asset_id becomes getBioAssetId() and setBioAssetId($id) All database fields except username and password have the 'user_' prefix.

Additional methods and offsets

string getFullName() - returns the first name and last name, joined with a space.

array getCreditedItemsOnCurrentSite([$model_id=null[, $mode=default]]) - gets all items credited to the user on the current site. If model_id is specified, then only items belonging to that model will be returned. Mode is one of Smartest's item retrieval modes.

int getProfilePicAssetId() - returns the ID of the SmartestAsset that stores the user's profile picture. If the user has not chosen one yet, the ID of system default profile picture is returned.

int getDefaultProfilePicAssetId() - returns the id of the system default profile picture, creating the asset for it if necessary (older installs of Smartest may not have had this created when they were installed).

SmartestAsset getProfilePic() - returns a profile picture for the user.

SmartestAsset getBioTextAsset() - returns a profile text asset for the user, creating a new blank one if none exists yet.

string getBioForEditor() - returns the profile text sufficiently escaped and formatted such that it can be put in a text area and have TinyMCE applied to it.

SmartestRenderableAsset getBioTextForRender() - returns a profile text asset for the user, creating a new blank one if none exists yet, as a renderable asset, and sets the draft mode of the asset if the call to this function is made while a page preview is being loaded.

void updateBioTextAssetFromEditor(string $content_from_editor) - passes the submitted text through Smartest's post-edit filters and updates the bio text asset with the result.

bool passwordIs(string $password) - checks whether the supplied password, when salted with the user's password hash, matches the user's stored, hashed password.

bool setPasswordWithSalt(string $password, string $salt[, $ignore_repeat_password=false]) salts the clear-text password supplied in $password with $salt and stores the resulting hash. If $ignore_repeat_password is false (which it is by default), the same password cannot be set twice, and false will be returned when this is attempted.

string getInfoField(string $field_name) - retrieves a value stored in the user's info field.