| 1 |
<?php
|
| 2 |
|
| 3 |
/**
|
| 4 |
* Ad Memcache module installation functions.
|
| 5 |
* Copyright (c) 2009 Jeremy Andrews <jeremy@tag1consulting.com>.
|
| 6 |
*/
|
| 7 |
|
| 8 |
/**
|
| 9 |
* Implementation of hook_requirements.
|
| 10 |
* Be sure that the memcache is properly installed before allowing this module
|
| 11 |
* to be enabled.
|
| 12 |
*/
|
| 13 |
function ad_memcache_requirements($phase = NULL) {
|
| 14 |
// Connect to memcached so we can retrieve its version.
|
| 15 |
if (function_exists('memcache_add_server')) {
|
| 16 |
require_once(drupal_get_path('module', 'ad_memcache') .'/ad_memcache.inc');
|
| 17 |
$memcache = ad_memcache_init();
|
| 18 |
// Retrieve the version of memcache.
|
| 19 |
if (function_exists('memcache_get_version')) {
|
| 20 |
$severity = REQUIREMENT_OK;
|
| 21 |
$message = memcache_get_version($memcache);
|
| 22 |
}
|
| 23 |
else {
|
| 24 |
$severity = REQUIREMENT_ERROR;
|
| 25 |
$message = t('Memcache installation not valid, %function not found.', array('%function' => 'memcache_get_version'));
|
| 26 |
}
|
| 27 |
}
|
| 28 |
else {
|
| 29 |
$severity = REQUIREMENT_ERROR;
|
| 30 |
$message = t('Memcache is not installed, %function not found.', array('%function' => 'memcache_add_server'));
|
| 31 |
}
|
| 32 |
|
| 33 |
return array(
|
| 34 |
'memcache' => array(
|
| 35 |
'title' => t('Memcache'),
|
| 36 |
'value' => $message,
|
| 37 |
'severity' => $severity,
|
| 38 |
),
|
| 39 |
);
|
| 40 |
}
|
| 41 |
|
| 42 |
/**
|
| 43 |
* Implementation of hook_disable().
|
| 44 |
*/
|
| 45 |
function ad_memcache_disable() {
|
| 46 |
if (variable_get('ad_cache', 'none') === 'memcache') {
|
| 47 |
variable_set('ad_cache', 'none');
|
| 48 |
drupal_set_message(t('The advertisement cache type has been reverted from %memcache to %none because the %name module was disabled.', array('%memcache' => t('memcache'), '%none' => t('none'), '%name' => t('ad memcache'))));
|
| 49 |
}
|
| 50 |
}
|