[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/classes/ -> user.php (summary)

User class

Copyright: 2013 Rajesh Taneja <rajesh@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 632 lines (28 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

core_user:: (19 methods):
  get_user()
  get_user_by_username()
  get_dummy_user_record()
  get_noreply_user()
  get_support_user()
  reset_internal_users()
  is_real_user()
  require_active_user()
  update_picture()
  fill_properties_cache()
  get_property_definition()
  validate()
  reset_caches()
  clean_data()
  clean_field()
  get_property_type()
  get_property_null()
  get_property_choices()
  get_property_default()


Class: core_user  - X-Ref

User class to access user details.

get_user($userid, $fields = '*', $strictness = IGNORE_MISSING)   X-Ref
Return user object from db or create noreply or support user,
if userid matches corse_user::NOREPLY_USER or corse_user::SUPPORT_USER
respectively. If userid is not found, then return false.

param: int $userid user id
param: string $fields A comma separated list of user fields to be returned, support and noreply user
param: int $strictness IGNORE_MISSING means compatible mode, false returned if user not found, debug message if more found;
return: stdClass|bool user record if found, else false.

get_user_by_username($username, $fields = '*', $mnethostid = null, $strictness = IGNORE_MISSING)   X-Ref
Return user object from db based on their username.

param: string $username The username of the user searched.
param: string $fields A comma separated list of user fields to be returned, support and noreply user.
param: int $mnethostid The id of the remote host.
param: int $strictness IGNORE_MISSING means compatible mode, false returned if user not found, debug message if more found;
return: stdClass|bool user record if found, else false.

get_dummy_user_record()   X-Ref
Helper function to return dummy noreply user record.

return: stdClass

get_noreply_user()   X-Ref
Return noreply user record, this is currently used in messaging
system only for sending messages from noreply email.
It will return record of $CFG->noreplyuserid if set else return dummy
user object with hard-coded $user->emailstop = 1 so noreply can be sent to user.

return: stdClass user record.

get_support_user()   X-Ref
Return support user record, this is currently used in messaging
system only for sending messages to support email.
$CFG->supportuserid is set then returns user record
$CFG->supportemail is set then return dummy record with $CFG->supportemail
else return admin user record with hard-coded $user->emailstop = 0, so user
gets support message.

return: stdClass user record.

reset_internal_users()   X-Ref
Reset self::$noreplyuser and self::$supportuser.
This is only used by phpunit, and there is no other use case for this function.
Please don't use it outside phpunit.


is_real_user($userid, $checkdb = false)   X-Ref
Return true is user id is greater than self::NOREPLY_USER and
alternatively check db.

param: int $userid user id.
param: bool $checkdb if true userid will be checked in db. By default it's false, and
return: bool true is real user else false.

require_active_user($user, $checksuspended = false, $checknologin = false)   X-Ref
Check if the given user is an active user in the site.

param: stdClass  $user         user object
param: boolean $checksuspended whether to check if the user has the account suspended
param: boolean $checknologin   whether to check if the user uses the nologin auth method

update_picture(stdClass $usernew, $filemanageroptions = array()   X-Ref
Updates the provided users profile picture based upon the expected fields returned from the edit or edit_advanced forms.

param: stdClass $usernew An object that contains some information about the user being updated
param: array $filemanageroptions
return: bool True if the user was updated, false if it stayed the same.

fill_properties_cache()   X-Ref
Definition of user profile fields and the expected parameter type for data validation.

array(
'property_name' => array(       // The user property to be checked. Should match the field on the user table.
'null' => NULL_ALLOWED,    // Defaults to NULL_NOT_ALLOWED. Takes NULL_NOT_ALLOWED or NULL_ALLOWED.
'type' => PARAM_TYPE,      // Expected parameter type of the user field.
'choices' => array(1, 2..) // An array of accepted values of the user field.
'default' => $CFG->setting // An default value for the field.
)
)

The fields choices and default are optional.

return: void

get_property_definition($property)   X-Ref
Get properties of a user field.

param: string $property property name to be retrieved.
return: array the property definition.

validate($data)   X-Ref
Validate user data.

This method just validates each user field and return an array of errors. It doesn't clean the data,
the methods clean() and clean_field() should be used for this purpose.

param: stdClass|array $data user data object or array to be validated.
return: array|true $errors array of errors found on the user object, true if the validation passed.

reset_caches()   X-Ref
Clean the properties cache.

During unit tests we need to be able to reset all caches so that each new test starts in a known state.
Intended for use only for testing, phpunit calls this before every test.

clean_data($user)   X-Ref
Clean the user data.

param: stdClass|array $user the user data to be validated against properties definition.
return: stdClass $user the cleaned user data.

clean_field($data, $field)   X-Ref
Clean a specific user field.

param: string $data the user field data to be cleaned.
param: string $field the user field name on the property definition cache.
return: string the cleaned user data.

get_property_type($property)   X-Ref
Get the parameter type of the property.

param: string $property property name to be retrieved.
return: int the property parameter type.

get_property_null($property)   X-Ref
Discover if the property is NULL_ALLOWED or NULL_NOT_ALLOWED.

param: string $property property name to be retrieved.
return: bool true if the property is NULL_ALLOWED, false otherwise.

get_property_choices($property)   X-Ref
Get the choices of the property.

This is a helper method to validate a value against a list of acceptable choices.
For instance: country, language, themes and etc.

param: string $property property name to be retrieved.
return: array the property parameter type.

get_property_default($property)   X-Ref
Get the property default.

This method gets the default value of a field (if exists).

param: string $property property name to be retrieved.
return: string the property default value.



Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1