print_simple_box(get_string($cd->get_error(), 'error'), 'center');
                break;
            case INSTALLED:
                print_simple_box(get_string('componentinstalled', 'admin'), 'center');
                break;
        }
    }
}
/// Start of main box
print_simple_box_start('center');
echo "<div style=\"text-align:center\">" . $stradminhelpenvironment . "</div><br />";
/// Get current Moodle version
$current_version = $CFG->release;
/// Calculate list of versions
$versions = array();
if ($contents = load_environment_xml()) {
    if ($env_versions = get_list_of_environment_versions($contents)) {
        /// Set the current version at the beginning
        $env_version = normalize_version($current_version);
        //We need this later (for the upwards)
        $versions[$env_version] = $current_version;
        /// If no version has been previously selected, default to $current_version
        if (empty($version)) {
            $version = $env_version;
        }
        ///Iterate over each version, adding bigged than current
        foreach ($env_versions as $env_version) {
            if (version_compare(normalize_version($current_version), $env_version, '<')) {
                $versions[$env_version] = $env_version;
            }
        }
/**
 * 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 $env_select one of ENV_SELECT_NEWER | ENV_SELECT_DATAROOT | ENV_SELECT_RELEASE decide xml to use.
 * @return mixed the xmlized structure or false on error
 */
function get_environment_for_version($version, $env_select)
{
    /// Normalize the version requested
    $version = normalize_version($version);
    /// Load xml file
    if (!($contents = load_environment_xml($env_select))) {
        return false;
    }
    /// Detect available versions
    if (!($versions = get_list_of_environment_versions($contents))) {
        return false;
    }
    /// If the version requested is available
    if (!in_array($version, $versions)) {
        return false;
    }
    /// We now we have it. Extract from full contents.
    $fl_arr = array_flip($versions);
    return $contents['COMPATIBILITY_MATRIX']['#']['MOODLE'][$fl_arr[$version]];
}
Example #3
0
/**
 * 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
 */
function get_environment_for_version($version, $env_select)
{
    /// Normalize the version requested
    $version = normalize_version($version);
    /// Load xml file
    if (!($contents = load_environment_xml($env_select))) {
        return false;
    }
    /// Detect available versions
    if (!($versions = get_list_of_environment_versions($contents))) {
        return false;
    }
    // If $env_select is not numeric then this is being called on a plugin, and not the core environment.xml
    // If a version of 'all' is in the arry is also means that the new <PLUGIN> tag was found, this should
    // be matched against any version of Moodle.
    if (!is_numeric($env_select) && in_array('all', $versions) && environment_verify_plugin($env_select, $contents['COMPATIBILITY_MATRIX']['#']['PLUGIN'][0])) {
        return $contents['COMPATIBILITY_MATRIX']['#']['PLUGIN'][0];
    }
    /// If the version requested is available
    if (!in_array($version, $versions)) {
        return false;
    }
    /// We now we have it. Extract from full contents.
    $fl_arr = array_flip($versions);
    return $contents['COMPATIBILITY_MATRIX']['#']['MOODLE'][$fl_arr[$version]];
}