Commit a6475339 authored by Francois Marier's avatar Francois Marier
Browse files

Add upgrade/postinst script to selectively enable Gravatar support


Signed-off-by: default avatarFrancois Marier <francois@catalyst.net.nz>
parent 7e5b4698
......@@ -1354,8 +1354,9 @@ function xmldb_core_upgrade($oldversion=0) {
}
}
return $status;
if ($oldversion < 2010021600) {
set_remoteavatars_default();
}
return $status;
}
?>
......@@ -584,6 +584,7 @@ function core_postinst() {
(owner IS NULL AND "group" IS NULL AND institution IS NOT NULL)
)');
set_remoteavatars_default();
reload_html_filters();
return $status;
}
......@@ -1012,4 +1013,37 @@ function reload_html_filters() {
log_info('- YouTube');
set_config('filters', serialize($filters));
}
?>
/**
* Use a meaningful default for the 'remoteavatars' setting.
*/
function set_remoteavatars_default() {
// Check if the site is using https
$urlprotocol = substr(get_config('wwwroot'), 0, 5);
if (strtolower($urlprotocol) == 'https') {
// Avoid mix of secure and insecure contents
set_config('remoteavatars', 0);
}
else {
// Check to see if we can reach gravatar.com
$ch = curl_init();
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_VERBOSE, false);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 5); // timeout in seconds
curl_setopt($ch, CURLOPT_COOKIE, '');
curl_setopt($ch, CURLOPT_REFERER, ''); // for privacy
curl_setopt($ch, CURLOPT_URL, 'http://www.gravatar.com/');
if (curl_exec($ch)) {
// By default, turn it on
set_config('remoteavatars', 1);
}
else {
// Can't reach gravatar.com in a timely fashion
set_config('remoteavatars', 0);
}
curl_close($ch);
}
}
......@@ -28,10 +28,8 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2010021500;
$config->version = 2010021600;
$config->release = '1.3.0dev';
$config->minupgradefrom = 2008040200;
$config->minupgraderelease = '1.0.0 (release tag 1.0.0_RELEASE)';
$config->disablelogin = true;
?>
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