Exemple #1
0
/**
 * Get the latest version info from the XML file https://www.turnitin.com/static/resources/files/moodledirect_latest.xml
 *
 * @return string url of latest if this version is not the latest null if update is not available
 */
function turnitintool_updateavailable($module)
{
    $basedir = "https://www.turnitin.com/static/resources/files/";
    $loaderbar = null;
    // Use the comms class so we can make sure the call is using any proxy in place
    $tii = new turnitintool_commclass('', '', '', '', '', $loaderbar);
    $result = $tii->doRequest("GET", $basedir . "moodledirect_latest.xml", "");
    $tii->xmlToSimple($result, false);
    $moduleversion = isset($module->version) ? $module->version : $module->versiondb;
    if (strlen($result) > 0 and isset($tii->simplexml->version)) {
        $version = $tii->simplexml->version;
        if ($version <= $moduleversion) {
            // No update available
            return null;
        } else {
            // Update available return URL
            return $tii->simplexml->filename;
        }
    }
    // Could not find the xml file can't return URL so return null
    return null;
}
/**
 * Get the latest version info from the XML file https://www.turnitin.com/static/resources/files/moodledirect_latest.xml
 *
 * @return string url of latest if this version is not the latest null if update is not available
 */
function turnitintool_updateavailable($module)
{
    $basedir = "https://www.turnitin.com/static/resources/files/";
    $loaderbar = null;
    // Use the comms class so we can make sure the call is using any proxy in place
    $tii = new turnitintool_commclass('', '', '', '', '', $loaderbar);
    $result = $tii->doRequest("GET", $basedir . "moodledirect_latest.xml", "");
    if (strlen($result) > 0 and $tii->xmlToArray($result)) {
        $version = $tii->_xmlarray["MOODLEDIRECT"][0]["VERSION"]['value'];
        if ($version <= $module->version) {
            // No update available
            return null;
        } else {
            // Update available return URL
            return $basedir . $tii->_xmlarray["MOODLEDIRECT"][0]["FILENAME"]['value'];
        }
    }
    // Could not find the xml file can't return URL so return null
    return null;
}