$t('HTTP request status'),
'value' => $t('Fails'),
'severity' => REQUIREMENT_ERROR,
'description' => $t('Your system or network configuration does not allow Drupal to access web pages, resulting in reduced functionality. This could be due to your webserver configuration or PHP settings, and should be resolved in order to download information about available updates, fetch aggregator feeds, sign in via OpenID, or use other network-dependent services.'),
);
}
// Raise warning if Piwik user account has not been set yet.
if (!preg_match('/^\d{1,}$/', variable_get('piwik_site_id', ''))) {
$requirements['piwik'] = array(
'title' => $t('Piwik module'),
'description' => $t('Piwik module has not been configured yet. Please configure its settings from the Piwik settings page.', array('@url' => url('admin/settings/piwik'))),
'severity' => REQUIREMENT_WARNING,
'value' => $t('Not configured'),
);
}
break;
}
return $requirements;
}
/**
* Change visibility setting for paths.
*/
function piwik_update_6000() {
$ret = array();
// Orginal pages setting.
$pages = array(
'admin*',
'user*',
'node/add*',
'node/*/*',
);
$diff = array_diff($pages, preg_split('/(\r\n?|\n)/', variable_get('piwik_pages', implode("\n", $pages))));
if (empty($diff)) {
// No diff to original settings found. Update with new settings.
$pages = array(
'admin',
'admin/*',
'user/*/*',
'node/add*',
'node/*/*',
);
variable_set('piwik_pages', implode("\n", $pages));
$ret[] = array('success' => TRUE, 'query' => 'Path visibility filter setting changed from "admin*" to "admin, admin/*" and "user*" changed to "user/*/*".');
}
else {
$ret[] = array('success' => TRUE, 'query' => 'Custom path visibility filter setting found. Update skipped!');
}
return $ret;
}
/**
* Upgrade custom javascript settings.
*/
function piwik_update_6001() {
$ret = array();
variable_set('piwik_codesnippet_before', variable_get('piwik_codesnippet', ''));
variable_del('piwik_codesnippet');
$ret[] = array('success' => TRUE, 'query' => 'Upgraded custom javascript codesnippet setting.');
return $ret;
}
/**
* Remove obsolte token auth.
*/
function piwik_update_6002() {
$ret = array();
variable_del('piwik_auth');
$ret[] = array('success' => TRUE, 'query' => 'The global token_auth setting has been deleted. Users need to configure their personal token_auth.');
return $ret;
}
/**
* Update list of default extensions
*/
function piwik_update_6003() {
$ret = array();
if (variable_get('piwik_trackfiles_extensions', '') == '7z|aac|avi|csv|doc|exe|flv|gif|gz|jpe?g|js|mp(3|4|e?g)|mov|pdf|phps|png|ppt|rar|sit|tar|torrent|txt|wma|wmv|xls|xml|zip') {
variable_set('piwik_trackfiles_extensions', '7z|aac|arc|arj|asf|asx|avi|bin|csv|doc|exe|flv|gif|gz|gzip|hqx|jar|jpe?g|js|mp(2|3|4|e?g)|mov(ie)?|msi|msp|pdf|phps|png|ppt|qtm?|ra(m|r)?|sea|sit|tar|tgz|torrent|txt|wav|wma|wmv|wpd|xls|xml|z|zip');
}
$ret[] = array('success' => TRUE, 'query' => 'The default extensions for download tracking have been updated to piwik defaults.');
return $ret;
}
/**
* Add trailing slash to piwik URLs.
*/
function piwik_update_7200() {
$ret = array();
$url_http = variable_get('piwik_url_http', '');
$url_https = variable_get('piwik_url_https', '');
if (!empty($url_http)) {
variable_set('piwik_url_http', $url_http . '/');
$ret[] = array('success' => TRUE, 'query' => 'Added trailing slash to piwik HTTP URL.');
}
if (!empty($url_https)) {
variable_set('piwik_url_https', $url_https . '/');
$ret[] = array('success' => TRUE, 'query' => 'Added trailing slash to piwik HTTPS URLs.');
}
return $ret;
}
/**
* Move async tracking code to header.
*/
function piwik_update_7201() {
$ret = array();
variable_set('piwik_js_scope', 'header');
$ret[] = array('success' => TRUE, 'query' => 'Async tracking code has been moved to header.');
return $ret;
}
/**
* Backup synchronous code snippets.
*/
function piwik_update_7202() {
$ret = array();
// TODO: Backup synchronous code snippets. Remove variables in D8.
variable_set('piwik_codesnippet_before_backup_7202', variable_get('piwik_codesnippet_before', ''));
variable_set('piwik_codesnippet_after_backup_7202', variable_get('piwik_codesnippet_after', ''));
// Upgrade of BEFORE code snippet.
$code_before = variable_get('piwik_codesnippet_before', '');
if (!empty($code_before)) {
// No value, e.g. piwikTracker.enableLinkTracking()
$code_before = preg_replace('/(.*)piwikTracker\.(\w+)\(\);(.*)/i', '$1_paq.push(["$2"]);$3', $code_before);
// One value, e.g. piwikTracker.addDownloadExtensions("mp5|mp6"), piwikTracker.trackGoal(1)
$code_before = preg_replace('/(.*)piwikTracker\.(\w+)\(("|\'?)(\w+)("|\'?)\);(.*)/i', '$1_paq.push(["$2", $3$4$5]);$6', $code_before);
// Multiple values e.g. piwikTracker.trackLink('/store', 'addTransaction', trans)
$code_before = preg_replace('/(.*)piwikTracker\.(\w+)\((.*)\);(.*)/i', '$1_paq.push(["$2", $3]);$4', $code_before);
variable_set('piwik_codesnippet_before', $code_before);
$ret[] = array('success' => TRUE, 'query' => 'Upgraded custom "before" code snippet.');
drupal_set_message(db_prefix_tables("Attempted to upgrade Piwik custom 'before' code snippet. Backup of previous code snippet has been saved in database table '{variable}' as 'piwik_codesnippet_before_backup_7202'. Please consult Piwik's Asynchronous tracking Guide if the upgrade was successfully."), 'warning');
}
// Upgrade of AFTER code snippet.
// We cannot update this code snippet automatically. Show message that the upgrade has been skipped.
$code_after = variable_get('piwik_codesnippet_after', '');
if (!empty($code_after)) {
$ret[] = array('success' => TRUE, 'query' => 'Skipped custom "after" code snippet.');
drupal_set_message(db_prefix_tables("Automatic upgrade of Google Analytics custom 'after' code snippet has been skipped. Backup of previous code snippet has been saved in database table '{variable}' as 'piwik_codesnippet_after_backup_7202'. You need to manually upgrade the custom 'after' code snippet."), 'error');
}
return $ret;
}
/**
* Path visibility filter setting should hide "batch" path.
*/
function piwik_update_7203() {
$ret = array();
// Current pages setting.
$pages = array(
'admin',
'admin/*',
'user/*/*',
'node/add*',
'node/*/*',
);
$diff = array_diff($pages, preg_split('/(\r\n?|\n)/', variable_get('piwik_pages', implode("\n", $pages))));
if (empty($diff)) {
// No diff to previous settings found. Update with new settings.
$pages = array(
'admin',
'admin/*',
'batch',
'node/add*',
'node/*/*',
'user/*/*',
);
variable_set('piwik_pages', implode("\n", $pages));
$ret[] = array('success' => TRUE, 'query' => 'Added "batch" to path visibility filter setting.');
}
else {
$ret[] = array('success' => TRUE, 'query' => 'Custom path visibility filter setting found. Update skipped!');
}
return $ret;
}
/**
* Rename piwik_visibility variable to piwik_visibility_pages for consistency.
*/
function piwik_update_7204() {
$ret = array();
variable_set('piwik_visibility_pages', variable_get('piwik_visibility', 1));
variable_del('piwik_visibility');
$ret[] = array('success' => TRUE, 'query' => 'Renamed "piwik_visibility" settings variable to piwik_visibility_pages.');
return $ret;
}
/**
* Update list of default file extensions.
*/
function piwik_update_7205() {
$ret = array();
if (variable_get('piwik_trackfiles_extensions', '') == '7z|aac|arc|arj|asf|asx|avi|bin|csv|doc|exe|flv|gif|gz|gzip|hqx|jar|jpe?g|js|mp(2|3|4|e?g)|mov(ie)?|msi|msp|pdf|phps|png|ppt|qtm?|ra(m|r)?|sea|sit|tar|tgz|torrent|txt|wav|wma|wmv|wpd|xls|xml|z|zip') {
variable_set('piwik_trackfiles_extensions', '7z|aac|arc|arj|asf|asx|avi|bin|csv|doc(x|m)?|dot(x|m)?|exe|flv|gif|gz|gzip|hqx|jar|jpe?g|js|mp(2|3|4|e?g)|mov(ie)?|msi|msp|pdf|phps|png|ppt(x|m)?|pot(x|m)?|pps(x|m)?|ppam|sld(x|m)?|thmx|qtm?|ra(m|r)?|sea|sit|tar|tgz|torrent|txt|wav|wma|wmv|wpd|xls(x|m|b)?|xlt(x|m)|xlam|xml|z|zip');
$ret[] = array('success' => TRUE, 'query' => 'The default extensions for download tracking have been updated.');
}
else {
$ret[] = array('success' => TRUE, 'query' => 'Custom extensions for download tracking setting found. Update skipped!');
}
return $ret;
}