Differences Between: [Versions 310 and 402] [Versions 39 and 402]
This library includes all the necessary stuff to execute some standard tests of required versions and libraries to run Moodle. It can be used from the admin interface, and both at install and upgrade. All the info is stored in the admin/environment.xml file, supporting to have an updated version in dataroot/environment
Copyright: | (C) 2001-3001 Eloy Lafuente (stronk7) {@link http://contiento.com} |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 1688 lines (59 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
environment_results:: (2 methods):
__construct()
environment_results()
name:: (32 methods):
setStatus()
setErrorCode()
setLevel()
setCurrentVersion()
setNeededVersion()
setInfo()
setFeedbackStr()
setBypassStr()
setRestrictStr()
getStatus()
getErrorCode()
getLevel()
getCurrentVersion()
getNeededVersion()
getInfo()
getPart()
getFeedbackStr()
getBypassStr()
getRestrictStr()
strToReport()
getPluginName()
get_level()
process_environment_result()
restrict_php_version_7()
restrict_php_version()
restrict_php_version_71()
restrict_php_version_72()
restrict_php_version_73()
restrict_php_version_74()
restrict_php_version_80()
restrict_php_version_81()
restrict_php_version_82()
Class: environment_results - X-Ref
Helper Class to return results to caller__construct($part) X-Ref |
Constructor of the environment_result class. Just set default values param: string $part |
environment_results($part) X-Ref |
Old syntax of class constructor. Deprecated in PHP7. |
setStatus($testpassed) X-Ref |
Set the status param: bool $testpassed true means the test passed and all is OK. false means it failed. |
setErrorCode($error_code) X-Ref |
Set the error_code param: integer $error_code the error code (see constants above) |
setLevel($level) X-Ref |
Set the level param: string $level the level (required, optional) |
setCurrentVersion($current_version) X-Ref |
Set the current version param: string $current_version the current version |
setNeededVersion($needed_version) X-Ref |
Set the needed version param: string $needed_version the needed version |
setInfo($info) X-Ref |
Set the auxiliary info param: string $info the auxiliary info |
setFeedbackStr($str) X-Ref |
Set the feedback string param: mixed $str the feedback string that will be fetched from the admin lang file. |
setBypassStr($str) X-Ref |
Set the bypass string param: string $str the bypass string that will be fetched from the admin lang file. |
setRestrictStr($str) X-Ref |
Set the restrict string param: string $str the restrict string that will be fetched from the admin lang file. |
getStatus() X-Ref |
Get the status return: bool true means the test passed and all is OK. false means it failed. |
getErrorCode() X-Ref |
Get the error code return: integer error code |
getLevel() X-Ref |
Get the level return: string level |
getCurrentVersion() X-Ref |
Get the current version return: string current version |
getNeededVersion() X-Ref |
Get the needed version return: string needed version |
getInfo() X-Ref |
Get the aux info return: string info |
getPart() X-Ref |
Get the part this result belongs to return: string part |
getFeedbackStr() X-Ref |
Get the feedback string return: mixed feedback string (can be an array of params for get_string or a single string to fetch from |
getBypassStr() X-Ref |
Get the bypass string return: mixed bypass string (can be an array of params for get_string or a single string to fetch from |
getRestrictStr() X-Ref |
Get the restrict string return: mixed restrict string (can be an array of params for get_string or a single string to fetch from |
strToReport($string, $class) X-Ref |
param: mixed $string params for get_string, either a string to fetch from admin.php or an array of param: string $class css class(es) for message. return: string feedback string fetched from lang file wrapped in p tag with class $class or returns |
getPluginName() X-Ref |
Get plugin name. return: string plugin name |
get_level($element) X-Ref |
param: array $element the element from the environment.xml file that should have return: string "required" or "optional". |
process_environment_result($element, &$result) X-Ref |
Once the result has been determined, look in the XML for any messages, or other things that should be done depending on the outcome. param: array $element the element from the environment.xml file which param: object $result the result of the test, which may be modified by |
restrict_php_version_7(&$result) X-Ref |
Check if the current PHP version is greater than or equal to PHP version 7. param: object $result an environment_results instance return: bool result of version check |
restrict_php_version(&$result, $version) X-Ref |
Check if the current PHP version is greater than or equal to an unsupported version. param: object $result an environment_results instance param: string $version the version of PHP that can't be used return: bool result of version check |
restrict_php_version_71(&$result) X-Ref |
Check if the current PHP version is greater than or equal to PHP version 7.1. param: object $result an environment_results instance return: bool result of version check |
restrict_php_version_72(&$result) X-Ref |
Check if the current PHP version is greater than or equal to PHP version 7.2. param: object $result an environment_results instance return: bool result of version check |
restrict_php_version_73(&$result) X-Ref |
Check if the current PHP version is greater than or equal to PHP version 7.3. param: object $result an environment_results instance return: bool result of version check |
restrict_php_version_74(&$result) X-Ref |
Check if the current PHP version is greater than or equal to PHP version 7.4. param: object $result an environment_results instance return: bool result of version check |
restrict_php_version_80($result) X-Ref |
Check if the current PHP version is greater than or equal to PHP version 8.0 param: object $result an environment_results instance return: bool result of version check |
restrict_php_version_81($result) X-Ref |
Check if the current PHP version is greater than or equal to PHP version 8.1 param: object $result an environment_results instance return: bool result of version check |
restrict_php_version_82($result) X-Ref |
Check if the current PHP version is greater than or equal to PHP version 8.2 param: object $result an environment_results instance return: bool result of version check |
check_moodle_environment($version, $env_select = ENV_SELECT_NEWER) X-Ref |
This function checks all the requirements defined in environment.xml. param: string $version version to check. param: int $env_select one of ENV_SELECT_NEWER | ENV_SELECT_DATAROOT | ENV_SELECT_RELEASE decide xml to use. Default ENV_SELECT_NEWER (BC) return: array with two elements. The first element true/false, depending on |
environment_get_errors($environment_results) X-Ref |
Returns array of critical errors in plain text format param: array $environment_results array of results gathered return: array errors |
normalize_version($version) X-Ref |
This function will normalize any version to just a serie of numbers separated by dots. Everything else will be removed. param: string $version the original version return: string the normalized version |
load_environment_xml($env_select=ENV_SELECT_NEWER) X-Ref |
This function will load the environment.xml file and xmlize it param: int|string $env_select one of ENV_SELECT_NEWER | ENV_SELECT_DATAROOT | ENV_SELECT_RELEASE decide xml to use. String means plugin name. return: mixed the xmlized structure or false on error |
get_list_of_environment_versions($contents) X-Ref |
This function will return the list of Moodle versions available return: array of versions |
get_latest_version_available($version, $env_select) X-Ref |
This function will return the most recent version in the environment.xml file previous or equal to the version requested param: string $version top version from which we start to look backwards param: int $env_select one of ENV_SELECT_NEWER | ENV_SELECT_DATAROOT | ENV_SELECT_RELEASE decide xml to use. return: string|bool string more recent version or false if not found |
get_environment_for_version($version, $env_select) X-Ref |
This function will return the xmlized data belonging to one Moodle version param: string $version top version from which we start to look backwards param: int|string $env_select one of ENV_SELECT_NEWER | ENV_SELECT_DATAROOT | ENV_SELECT_RELEASE decide xml to use. String means plugin name. return: mixed the xmlized structure or false on error |
environment_verify_plugin($plugin, $pluginxml) X-Ref |
Checks if a plugin tag has a name attribute and it matches the plugin being tested. param: string $plugin the name of the plugin. param: array $pluginxml the xmlised structure for the plugin tag being tested. return: boolean true if the name attribute exists and matches the plugin being tested. |
environment_check($version, $env_select) X-Ref |
This function will check for everything (DB, PHP and PHP extensions for now) returning an array of environment_result objects. param: string $version xml version we are going to use to test this server param: int $env_select one of ENV_SELECT_NEWER | ENV_SELECT_DATAROOT | ENV_SELECT_RELEASE decide xml to use. return: environment_results[] array of results encapsulated in one environment_result object |
environment_check_php_extensions($version, $env_select) X-Ref |
This function will check if php extensions requirements are satisfied param: string $version xml version we are going to use to test this server param: int|string $env_select one of ENV_SELECT_NEWER | ENV_SELECT_DATAROOT | ENV_SELECT_RELEASE decide xml to use. String means plugin name. return: array array of results encapsulated in one environment_result object |
environment_check_php_settings($version, $env_select) X-Ref |
This function will check if php extensions requirements are satisfied param: string $version xml version we are going to use to test this server param: int|string $env_select one of ENV_SELECT_NEWER | ENV_SELECT_DATAROOT | ENV_SELECT_RELEASE decide xml to use. String means plugin name. return: array array of results encapsulated in one environment_result object |
environment_custom_checks($version, $env_select) X-Ref |
This function will do the custom checks. param: string $version xml version we are going to use to test this server. param: int|string $env_select one of ENV_SELECT_NEWER | ENV_SELECT_DATAROOT | ENV_SELECT_RELEASE decide xml to use. String means plugin name. return: array array of results encapsulated in environment_result objects. |
environment_check_moodle($version, $env_select) X-Ref |
This function will check if Moodle requirements are satisfied param: string $version xml version we are going to use to test this server param: int|string $env_select one of ENV_SELECT_NEWER | ENV_SELECT_DATAROOT | ENV_SELECT_RELEASE decide xml to use. String means plugin name. return: object results encapsulated in one environment_result object |
environment_check_php($version, $env_select) X-Ref |
This function will check if php requirements are satisfied param: string $version xml version we are going to use to test this server param: int|string $env_select one of ENV_SELECT_NEWER | ENV_SELECT_DATAROOT | ENV_SELECT_RELEASE decide xml to use. String means plugin name. return: object results encapsulated in one environment_result object |
environment_check_pcre_unicode($version, $env_select) X-Ref |
Looks for buggy PCRE implementation, we need unicode support in Moodle... param: string $version xml version we are going to use to test this server param: int|string $env_select one of ENV_SELECT_NEWER | ENV_SELECT_DATAROOT | ENV_SELECT_RELEASE decide xml to use. String means plugin name. return: stdClass results encapsulated in one environment_result object, null if irrelevant |
environment_check_unicode($version, $env_select) X-Ref |
This function will check if unicode database requirements are satisfied param: string $version xml version we are going to use to test this server param: int|string $env_select one of ENV_SELECT_NEWER | ENV_SELECT_DATAROOT | ENV_SELECT_RELEASE decide xml to use. String means plugin name. return: object results encapsulated in one environment_result object |
environment_check_database($version, $env_select) X-Ref |
This function will check if database requirements are satisfied param: string $version xml version we are going to use to test this server param: int|string $env_select one of ENV_SELECT_NEWER | ENV_SELECT_DATAROOT | ENV_SELECT_RELEASE decide xml to use. String means plugin name. return: object results encapsulated in one environment_result object |
process_environment_bypass($xml, &$result) X-Ref |
This function will post-process the result record by executing the specified function, modifying it as necessary, also a custom message will be added to the result object to be printed by the display layer. Every bypass function must be defined in this file and it'll return true/false to decide if the original test is bypassed or no. Also such bypass functions are able to directly handling the result object although it should be only under exceptional conditions. param: string xmldata containing the bypass data param: object result object to be updated return: void |
process_environment_restrict($xml, &$result) X-Ref |
This function will post-process the result record by executing the specified function, modifying it as necessary, also a custom message will be added to the result object to be printed by the display layer. Every restrict function must be defined in this file and it'll return true/false to decide if the original test is restricted or no. Also such restrict functions are able to directly handling the result object although it should be only under exceptional conditions. param: string xmldata containing the restrict data param: object result object to be updated return: void |
process_environment_messages($xml, &$result) X-Ref |
This function will detect if there is some message available to be added to the result in order to clarify enviromental details. param: string xmldata containing the feedback data param: object reult object to be updated |