Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
core\hub\registration Class Reference

Methods to use when registering the site at the moodle sites directory. More...

Static Public Member Functions

static confirm_registration ($token, $newtoken, $hubname)
 Confirms registration by the sites directory.
 
static get_last_updated ()
 When was the registration last updated.
 
static get_moodlenet_info ()
 Returns information about the sites directory.
 
static get_new_registration_fields ()
 Returns the list of the fields in the registration form that were added since registration or last manual update.
 
static get_site_info ($defaults=[])
 Calculates and prepares site information to send to the sites directory as a part of registration.
 
static get_stats_summary ($siteinfo)
 Human-readable summary of data that will be sent to the sites directory.
 
static get_token ($strictness=IGNORE_MISSING)
 Returns registration token.
 
static is_registered ()
 Checks if site is registered.
 
static register ($returnurl)
 Registers a site.
 
static registration_reminder ($url)
 Redirect to the site registration form if it's a new install, upgrade or registration needs updating.
 
static require_registration ()
 Same as get_registration except it throws exception if site not registered.
 
static reset_site_identifier ($token)
 Generate a new token for the site that is not registered.
 
static reset_token ()
 Resets the registration token without changing site identifier so site can be re-registered.
 
static save_site_info ($formdata)
 Save registration info locally so it can be retrieved when registration needs to be updated.
 
static show_after_install ($markasviewed=null)
 Does admin need to be redirected to the registration page after install?
 
static site_privacy_options ()
 Retrieve the options for site privacy form element to use in registration form.
 
static unregister ($unpublishalladvertisedcourses, $unpublishalluploadedcourses)
 Unregister site.
 
static update_cron ()
 Updates site registration via cron.
 
static update_manual ()
 Updates site registration when "Update reigstration" button is clicked by admin.
 

Public Attributes

array const CONFIRM_NEW_FIELDS
 List of new FORM_FIELDS or siteinfo fields added indexed by the version when they were added.
 
array const FORM_FIELDS
 Fields used in a site registration form.
 
string const HUB_SITELINKPUBLISHED = 'linked'
 Site privacy: public and global.
 
string const HUB_SITENAMEPUBLISHED = 'named'
 Site privacy: public.
 
string const HUB_SITENOTPUBLISHED = 'notdisplayed'
 Site privacy: not displayed.
 

Static Protected Member Functions

static get_registration ($confirmed=true)
 Get site registration.
 

Static Protected Attributes

static stdClass $registration = null
 cached site registration information
 

Detailed Description

Methods to use when registering the site at the moodle sites directory.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ confirm_registration()

static core\hub\registration::confirm_registration ( $token,
$newtoken,
$hubname )
static

Confirms registration by the sites directory.

Parameters
string$token
string$newtoken
string$hubname
Exceptions
moodle_exception

◆ get_last_updated()

static core\hub\registration::get_last_updated ( )
static

When was the registration last updated.

Return values
int|nulltimestamp or null if site is not registered

◆ get_moodlenet_info()

static core\hub\registration::get_moodlenet_info ( )
static

Returns information about the sites directory.

Example of the return array: { "courses": 384, "description": "Official moodle sites directory", "downloadablecourses": 0, "enrollablecourses": 0, "hublogo": 1, "language": "en", "name": "moodle", "sites": 274175, "url": "https://stats.moodle.org", "imgurl": "https://stats.moodle.org/local/hub/webservice/download.php?filetype=hubscreenshot" }

Return values
array|null

◆ get_new_registration_fields()

static core\hub\registration::get_new_registration_fields ( )
static

Returns the list of the fields in the registration form that were added since registration or last manual update.

If this list is not empty the scheduled task will be paused and admin will be reminded to update registration manually.

Return values
array

◆ get_registration()

static core\hub\registration::get_registration ( $confirmed = true)
staticprotected

Get site registration.

Parameters
bool$confirmed
Return values
stdClass|null

◆ get_site_info()

static core\hub\registration::get_site_info ( $defaults = [])
static

Calculates and prepares site information to send to the sites directory as a part of registration.

Parameters
array$defaultsdefault values for inputs in the registration form (if site was never registered before)
Return values
arraysite info

◆ get_stats_summary()

static core\hub\registration::get_stats_summary ( $siteinfo)
static

Human-readable summary of data that will be sent to the sites directory.

Parameters
array$siteinforesult of get_site_info()
Return values
string

◆ get_token()

static core\hub\registration::get_token ( $strictness = IGNORE_MISSING)
static

Returns registration token.

Parameters
int$strictnessif set to MUST_EXIST and site is not registered will throw an exception
Return values
null
Exceptions
moodle_exception

◆ is_registered()

static core\hub\registration::is_registered ( )
static

Checks if site is registered.

Return values
bool

◆ register()

static core\hub\registration::register ( $returnurl)
static

Registers a site.

This method will make sure that unconfirmed registration record is created and then redirect to registration script on the sites directory. The sites directory will check that the site is accessible, register it and redirect back to /admin/registration/confirmregistration.php

Parameters
string$returnurl
Exceptions
coding_exception

◆ registration_reminder()

static core\hub\registration::registration_reminder ( $url)
static

Redirect to the site registration form if it's a new install, upgrade or registration needs updating.

Parameters
string | moodle_url$url

◆ require_registration()

static core\hub\registration::require_registration ( )
static

Same as get_registration except it throws exception if site not registered.

Return values
stdClass
Exceptions
moodle_exception

◆ reset_site_identifier()

static core\hub\registration::reset_site_identifier ( $token)
static

Generate a new token for the site that is not registered.

Parameters
string$token
Exceptions
moodle_exception

◆ reset_token()

static core\hub\registration::reset_token ( )
static

Resets the registration token without changing site identifier so site can be re-registered.

Return values
bool

◆ save_site_info()

static core\hub\registration::save_site_info ( $formdata)
static

Save registration info locally so it can be retrieved when registration needs to be updated.

Parameters
stdClass$formdatadata from site_registration_form

◆ show_after_install()

static core\hub\registration::show_after_install ( $markasviewed = null)
static

Does admin need to be redirected to the registration page after install?

Parameters
bool | null$markasviewedif set to true will mark the registration form as viewed and admin will not be redirected to the registration form again (regardless of whether the site was registered or not).
Return values
bool

◆ site_privacy_options()

static core\hub\registration::site_privacy_options ( )
static

Retrieve the options for site privacy form element to use in registration form.

Return values
array

◆ unregister()

static core\hub\registration::unregister ( $unpublishalladvertisedcourses,
$unpublishalluploadedcourses )
static

Unregister site.

Parameters
bool$unpublishalladvertisedcourses
bool$unpublishalluploadedcourses
Return values
bool

◆ update_cron()

static core\hub\registration::update_cron ( )
static

Updates site registration via cron.

Exceptions
moodle_exception

Member Data Documentation

◆ CONFIRM_NEW_FIELDS

array const core\hub\registration::CONFIRM_NEW_FIELDS
Initial value:
= [
2017092200 => [
'commnews',
'mobileservicesenabled', 'mobilenotificationsenabled', 'registereduserdevices', 'registeredactiveuserdevices'
],
2019022200 => ['analyticsenabledmodels', 'analyticspredictions', 'analyticsactions', 'analyticsactionsnotuseful'],
2020022600 => ['activeusers', 'activeparticipantnumberaverage'],
2023021700 => ['dbtype', 'coursesnodates', 'sitetheme', 'primaryauthtype'],
]

List of new FORM_FIELDS or siteinfo fields added indexed by the version when they were added.

If site was already registered, admin will be promted to confirm new registration data manually. Until registration is manually confirmed, the scheduled task updating registration will be paused. Keys of this array are not important as long as they increment, use current date to avoid confusions.

◆ FORM_FIELDS

array const core\hub\registration::FORM_FIELDS
Initial value:
= ['policyagreed', 'language', 'countrycode', 'privacy',
'contactemail', 'contactable', 'emailalert', 'emailalertemail', 'commnews', 'commnewsemail',
'contactname', 'name', 'description', 'imageurl', 'contactphone', 'regioncode', 'geolocation', 'street']

Fields used in a site registration form.

IMPORTANT: any new fields with non-empty defaults have to be added to CONFIRM_NEW_FIELDS


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