Methods to use when registering the site at the moodle sites directory.
More...
|
List const | CONFIRM_NEW_FIELDS |
| of new FORM_FIELDS or siteinfo fields added indexed by the version when they were added. More...
|
|
array const | FORM_FIELDS |
| Fields used in a site registration form. More...
|
|
Site const | HUB_SITELINKPUBLISHED = 'linked' |
| privacy: public and global
|
|
Site const | HUB_SITENAMEPUBLISHED = 'named' |
| privacy: public
|
|
Site const | HUB_SITENOTPUBLISHED = 'notdisplayed' |
| privacy: not displayed
|
|
|
static stdClass | $registration = null |
| cached site registration information
|
|
Methods to use when registering the site at the moodle sites directory.
- Copyright
- 2017 Marina Glancy
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
◆ 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
-
◆ get_last_updated()
static core\hub\registration::get_last_updated |
( |
| ) |
|
|
static |
When was the registration last updated.
- Return values
-
int|null | timestamp 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
-
◆ 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
-
◆ get_registration()
static core\hub\registration::get_registration |
( |
|
$confirmed = true | ) |
|
|
staticprotected |
Get site registration.
- Parameters
-
- Return values
-
◆ 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 | $defaults | default values for inputs in the registration form (if site was never registered before) |
- Return values
-
◆ 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
-
- Return values
-
◆ get_token()
static core\hub\registration::get_token |
( |
|
$strictness = IGNORE_MISSING | ) |
|
|
static |
Returns registration token.
- Parameters
-
int | $strictness | if set to MUST_EXIST and site is not registered will throw an exception |
- Return values
-
- Exceptions
-
◆ is_registered()
static core\hub\registration::is_registered |
( |
| ) |
|
|
static |
Checks if site is registered.
- Return values
-
◆ 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
-
- Exceptions
-
◆ registration_reminder()
static core\hub\registration::registration_reminder |
( |
|
$url | ) |
|
|
static |
Redirect to the site registration form if it's a new install or registration needs updating.
- Parameters
-
◆ require_registration()
static core\hub\registration::require_registration |
( |
| ) |
|
|
static |
Same as get_registration except it throws exception if site not registered.
- Return values
-
- Exceptions
-
◆ reset_site_identifier()
static core\hub\registration::reset_site_identifier |
( |
|
$token | ) |
|
|
static |
Generate a new token for the site that is not registered.
- Parameters
-
- Exceptions
-
◆ 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
-
◆ 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
-
◆ 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 | $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). |
- Return values
-
◆ 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
-
◆ unregister()
static core\hub\registration::unregister |
( |
|
$unpublishalladvertisedcourses, |
|
|
|
$unpublishalluploadedcourses |
|
) |
| |
|
static |
Unregister site.
- Parameters
-
bool | $unpublishalladvertisedcourses | |
bool | $unpublishalluploadedcourses | |
- Return values
-
◆ update_cron()
static core\hub\registration::update_cron |
( |
| ) |
|
|
static |
Updates site registration via cron.
- Exceptions
-
◆ CONFIRM_NEW_FIELDS
List const core\hub\registration::CONFIRM_NEW_FIELDS |
Initial value:= [
2017092200 => [
'commnews',
'mobileservicesenabled', 'mobilenotificationsenabled', 'registereduserdevices', 'registeredactiveuserdevices'
],
2019022200 => ['analyticsenabledmodels', 'analyticspredictions', 'analyticsactions', 'analyticsactionsnotuseful'],
2020022600 => ['activeusers', 'activeparticipantnumberaverage'],
]
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: