Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250711) (9addea9f0ac)
|
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_ai_usage_data () |
Get AI usage data. | |
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_plugin_usage_data () |
Return a list of plugins. | |
static | get_secret () |
Returns registration secret. | |
static | get_site_info ($defaults=[]) |
Calculates and prepares site information to send to the sites directory as a part of registration. | |
static | get_site_organisation_type_options () |
Get the options for organisation type form element to use in registration form. | |
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 | show_ai_usage () |
Displays AI usage data for all providers. | |
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 | |
Methods to use when registering the site at the moodle sites directory.
|
static |
Confirms registration by the sites directory.
string | $token | |
string | $newtoken | |
string | $hubname |
moodle_exception |
|
static |
Get AI usage data.
array |
|
static |
When was the registration last updated.
int|null | timestamp or null if site is not registered |
|
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" }
array|null |
|
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.
array |
|
static |
Return a list of plugins.
Only blocks and activities will include instance counts.
array |
|
staticprotected |
Get site registration.
bool | $confirmed |
stdClass|null |
|
static |
Returns registration secret.
string |
|
static |
Calculates and prepares site information to send to the sites directory as a part of registration.
array | $defaults | default values for inputs in the registration form (if site was never registered before) |
array | site info |
|
static |
Get the options for organisation type form element to use in registration form.
Indexes reference Moodle internal ids and should not be changed.
array |
|
static |
Human-readable summary of data that will be sent to the sites directory.
array | $siteinfo | result of get_site_info() |
string |
|
static |
Returns registration token.
int | $strictness | if set to MUST_EXIST and site is not registered will throw an exception |
null |
moodle_exception |
|
static |
Checks if site is registered.
bool |
|
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
string | $returnurl |
coding_exception |
|
static |
Redirect to the site registration form if it's a new install, upgrade or registration needs updating.
string | moodle_url | $url |
|
static |
Same as get_registration except it throws exception if site not registered.
stdClass |
moodle_exception |
|
static |
Generate a new token for the site that is not registered.
string | $token |
moodle_exception |
|
static |
Resets the registration token without changing site identifier so site can be re-registered.
bool |
|
static |
Save registration info locally so it can be retrieved when registration needs to be updated.
stdClass | $formdata | data from site_registration_form |
|
static |
Does admin need to be redirected to the registration page after install?
bool | null | $markasviewed | if 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). |
bool |
|
static |
Displays AI usage data for all providers.
array | Array containing usage data, grouped by provider |
|
static |
Retrieve the options for site privacy form element to use in registration form.
array |
|
static |
Unregister site.
bool | $unpublishalladvertisedcourses | |
bool | $unpublishalluploadedcourses |
bool |
|
static |
Updates site registration via cron.
moodle_exception |
array const core\hub\registration::CONFIRM_NEW_FIELDS |
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.
array const core\hub\registration::FORM_FIELDS |
Fields used in a site registration form.
IMPORTANT: any new fields with non-empty defaults have to be added to CONFIRM_NEW_FIELDS