Data structure representing a user picture.
More...
|
static | fields ($tableprefix='', array $extrafields=NULL, $idalias='id', $fieldprefix='') |
| Returns a list of required user fields, useful when fetching required user info from db.
|
|
static | unalias (stdClass $record, array $extrafields=null, $idalias='id', $fieldprefix='') |
| Extract the aliased user fields from a given record.
|
|
|
bool | $alttext = true |
| Add non-blank alt-text to the image.
|
|
string | $class = 'userpicture' |
| Image class attribute.
|
|
int | $courseid |
| The course id.
|
|
bool | $includefullname = false |
| Whether to include the fullname in the user picture link.
|
|
mixed | $includetoken = false |
| Include user authentication token.
|
|
bool | $link = true |
| Add course profile link to image.
|
|
bool | $popup = false |
| Whether or not to open the link in a popup window.
|
|
int | $size = 35 |
| Size in pixels.
|
|
stdClass | $user |
| A user object with at least fields all columns specified in $fields array constant set.
|
|
bool | $visibletoscreenreaders = true |
| Whether to be visible to screen readers.
|
|
Data structure representing a user picture.
- Copyright
- 2009 Nicolas Connault, 2010 Petr Skoda
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- Since
- Modle 2.0
◆ __construct()
user_picture::__construct |
( |
stdClass | $user | ) |
|
User picture constructor.
- Parameters
-
stdClass | $user | user record with at least id, picture, imagealt, firstname and lastname set. It is recommended to add also contextid of the user for performance reasons. |
◆ fields()
static user_picture::fields |
( |
| $tableprefix = '', |
|
|
array | $extrafields = NULL, |
|
|
| $idalias = 'id', |
|
|
| $fieldprefix = '' ) |
|
static |
Returns a list of required user fields, useful when fetching required user info from db.
In some cases we have to fetch the user data together with some other information, the idalias is useful there because the id would otherwise override the main id of the result record. Please note it has to be converted back to id before rendering.
- Parameters
-
string | $tableprefix | name of database table prefix in query |
array | $extrafields | extra fields to be included in result (do not include TEXT columns because it would break SELECT DISTINCT in MSSQL and ORACLE) |
string | $idalias | alias of id field |
string | $fieldprefix | prefix to add to all columns in their aliases, does not apply to 'id' |
- Return values
-
- Deprecated
- since Moodle 3.11 MDL-45242
- See also
- core_user\fields
◆ get_url()
Works out the URL for the users picture.
This method is recommended as it avoids costly redirects of user pictures if requests are made for non-existent files etc.
- Parameters
-
- Return values
-
◆ unalias()
static user_picture::unalias |
( |
stdClass | $record, |
|
|
array | $extrafields = null, |
|
|
| $idalias = 'id', |
|
|
| $fieldprefix = '' ) |
|
static |
Extract the aliased user fields from a given record.
Given a record that was previously obtained using self::fields() with aliases, this method extracts user related unaliased fields.
- Parameters
-
stdClass | $record | containing user picture fields |
array | $extrafields | extra fields included in the $record |
string | $idalias | alias of the id field |
string | $fieldprefix | prefix added to all columns in their aliases, does not apply to 'id' |
- Return values
-
stdClass | object with unaliased user fields |
◆ $alttext
bool user_picture::$alttext = true |
Add non-blank alt-text to the image.
Default true, set to false when image alt just duplicates text in screenreaders.
◆ $courseid
int user_picture::$courseid |
The course id.
Used when constructing the link to the user's profile, page course id used if not specified.
◆ $includetoken
mixed user_picture::$includetoken = false |
Include user authentication token.
True indicates to generate a token for current user, and integer value indicates to generate a token for the user whose id is the value indicated.
◆ $size
int user_picture::$size = 35 |
Size in pixels.
Special values are (true/1 = 100px) and (false/0 = 35px) for backward compatibility. Recommended values (supporting user initials too): 16, 35, 64 and 100.
The documentation for this class was generated from the following file: