Commit d3af6bc0 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Merge "Bug 1844838: Show more versioning info on site info block"

parents 68facdda 22a6111e
...@@ -323,8 +323,11 @@ $string['statsmaxquotaused1'] = 'Has used about %s of disk quota<br>(<a href="%s ...@@ -323,8 +323,11 @@ $string['statsmaxquotaused1'] = 'Has used about %s of disk quota<br>(<a href="%s
$string['groupcountsbytype'] = 'Number of groups by group type'; $string['groupcountsbytype'] = 'Number of groups by group type';
$string['groupcountsbyjointype'] = 'Number of groups by access type'; $string['groupcountsbyjointype'] = 'Number of groups by access type';
$string['blockcountsbytype'] = 'Most frequently used blocks in portfolio pages'; $string['blockcountsbytype'] = 'Most frequently used blocks in portfolio pages';
$string['uptodate'] = 'up to date'; $string['uptodate'] = 'Your local codebase is up to date with Mahara core.';
$string['latestversionis'] = 'latest version is <a href="%s">%s</a>'; $string['latestversionis'] = 'Most recent major release: <a href="%s">%s</a>';
$string['latestbranchversionis'] = 'Latest minor version of this release: <a href="%s">%s</a>';
$string['versionnotinsupport'] = '%s is out of support.';
$string['versionnotinsupportdev'] = 'Development version not in support';
$string['viewsbytype'] = 'Pages by type'; $string['viewsbytype'] = 'Pages by type';
$string['institutionloginstabletitle'] = 'Active institutions'; $string['institutionloginstabletitle'] = 'Active institutions';
$string['institutionloginstablesubtitle'] = 'For %s - %s'; $string['institutionloginstablesubtitle'] = 'For %s - %s';
......
...@@ -4426,38 +4426,45 @@ function cron_clean_internal_activity_notifications() { ...@@ -4426,38 +4426,45 @@ function cron_clean_internal_activity_notifications() {
* Cronjob to check Launchpad for the latest Mahara version * Cronjob to check Launchpad for the latest Mahara version
*/ */
function cron_check_for_updates() { function cron_check_for_updates() {
$url = 'https://mahara.org/local/versions.php';
$request = array( $request = array(
CURLOPT_URL => 'https://launchpad.net/mahara/+download', CURLOPT_URL => $url,
); );
$result = mahara_http_request($request); $result = mahara_http_request($request);
if (!empty($result->errno)) { if (!empty($result->errno) || $result->info['http_code'] != '200') {
log_debug('Could not retrieve launchpad download page'); log_debug('Could not access Mahara.org for versioning information.');
return; return;
} }
$data = json_decode($result->data);
$page = new DOMDocument(); if ($data->returnCode == 1) {
libxml_use_internal_errors(true); log_debug('Could not retrieve Mahara versions information file from Mahara.org');
$success = $page->loadHTML($result->data);
libxml_use_internal_errors(false);
if (!$success) {
log_debug('Error parsing launchpad download page');
return; return;
} }
$xpath = new DOMXPath($page); $versions = $data->message->versions;
$query = '//div[starts-with(@id,"release-information-")]';
$elements = $xpath->query($query); // Lets record the needed info locally as the cron only fetches the info once a day
$versions = array(); $latestmajorversion = max(array_keys((array)$versions));
foreach ($elements as $e) { $latestversion = $latestmajorversion . '.' . $versions->$latestmajorversion->latest;
if (preg_match('/^release-information-(\d+)-(\d+)-(\d+)$/', $e->getAttribute('id'), $match)) { set_config('latest_version', $latestversion);
$versions[] = "$match[1].$match[2].$match[3]"; if (preg_match('/^(\d+)\.(\d+)\.(\d+).*?$/', get_config('release'), $match)) {
} $currentmajorversion = $match[1] . '.' . $match[2];
$latestseriesversion = $currentmajorversion . '.' . $versions->$currentmajorversion->latest;
set_config('latest_branch_version', $latestseriesversion);
}
else {
set_config('latest_branch_version', '');
} }
if (!empty($versions)) { $supported = array();
usort($versions, 'strnatcmp'); foreach ($versions as $k => $v) {
set_config('latest_version', end($versions)); $insupport = filter_var($v->supported, FILTER_VALIDATE_BOOLEAN);
if ($insupport) {
$supported[] = $k;
}
} }
set_config('supported_versions', implode(',', $supported));
} }
/** /**
......
...@@ -72,13 +72,30 @@ function site_statistics($full=false) { ...@@ -72,13 +72,30 @@ function site_statistics($full=false) {
if ($latestversion = get_config('latest_version')) { if ($latestversion = get_config('latest_version')) {
$data['latest_version'] = $latestversion; $data['latest_version'] = $latestversion;
if ($data['release'] == $latestversion) { if ($data['release'] == $latestversion) {
$data['strlatestversion'] = get_string('uptodate', 'admin'); $data['uptodate'] = get_string('uptodate', 'admin');
} }
else { else {
$download_page = 'https://launchpad.net/mahara/+download'; $download_page = 'https://launchpad.net/mahara/+download';
$data['strlatestversion'] = get_string('latestversionis', 'admin', $download_page, $latestversion); $data['strlatestversion'] = get_string('latestversionis', 'admin', $download_page, $latestversion);
} }
} }
if ($branchlatest = get_config('latest_branch_version')) {
if ($data['release'] != $branchlatest) {
$download_page = 'https://launchpad.net/mahara/+milestone/' . $branchlatest;
$data['strlatestbranchversion'] = get_string('latestbranchversionis', 'admin', $download_page, $branchlatest);
}
}
if ($insupport = get_config('supported_versions')) {
$insupport = explode(',', $insupport);
if (!in_array(get_config('series'), $insupport)) {
if (preg_match('/dev$/', $data['release'])) {
$data['strnotinsupport'] = get_string('versionnotinsupportdev', 'admin');
}
else {
$data['strnotinsupport'] = get_string('versionnotinsupport', 'admin', get_config('series'));
}
}
}
if ($full) { if ($full) {
// Add the other overall graphs here // Add the other overall graphs here
......
...@@ -380,6 +380,7 @@ function upgrade_core($upgrade) { ...@@ -380,6 +380,7 @@ function upgrade_core($upgrade) {
set_config('release', $upgrade->torelease); set_config('release', $upgrade->torelease);
set_config('series', $upgrade->toseries); set_config('series', $upgrade->toseries);
bump_cache_version(); bump_cache_version();
cron_check_for_updates();
if (!empty($upgrade->install)) { if (!empty($upgrade->install)) {
core_postinst(); core_postinst();
......
...@@ -43,8 +43,23 @@ ...@@ -43,8 +43,23 @@
{if $showall} {if $showall}
<tr> <tr>
<th>{str tag=maharaversion section=admin}</th> <th>{str tag=maharaversion section=admin}</th>
<td>{$institutiondata.release}{if $institutiondata.strlatestversion} ({$institutiondata.strlatestversion|clean_html|safe}){/if}</td> <td>{$institutiondata.release}</td>
</tr> </tr>
{if $institutiondata.strlatestbranchversion || $institutiondata.strnotinsupport || $institutiondata.strlatestversion || $institutiondata.uptodate}
<tr>
<td colspan="2">
{if $institutiondata.uptodate}
{$institutiondata.uptodate}
{else}
<ul>
{if $institutiondata.strlatestbranchversion}<li>{$institutiondata.strlatestbranchversion|clean_html|safe}</li>{/if}
{if $institutiondata.strnotinsupport}<li><span class="text-danger">{$institutiondata.strnotinsupport}</span></li>{/if}
{if $institutiondata.strlatestversion}<li>{$institutiondata.strlatestversion|clean_html|safe}</li>{/if}
</ul>
{/if}
</td>
</tr>
{/if}
<tr> <tr>
<th>{str tag=Cron section=admin}</th> <th>{str tag=Cron section=admin}</th>
<td>{if $institutiondata.cronrunning}{str tag=runningnormally section=admin}{else} <td>{if $institutiondata.cronrunning}{str tag=runningnormally section=admin}{else}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment