| 1 |
<?php
|
| 2 |
// $Id: getid3.install,v 1.5 2008/06/10 04:26:55 drewish Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implementation of hook_requirements()
|
| 6 |
*/
|
| 7 |
function getid3_requirements($phase) {
|
| 8 |
$t = get_t();
|
| 9 |
$requirements = array();
|
| 10 |
|
| 11 |
if ($phase == 'runtime') {
|
| 12 |
// Test getID3 version
|
| 13 |
$requirements['getid3']['title'] = $t('getID3()');
|
| 14 |
|
| 15 |
if (getid3_load(FALSE)) {
|
| 16 |
$requirements['getid3']['value'] = check_plain(getid3_get_version());
|
| 17 |
$getid3_demos_path = getid3_get_path() .'/../demos';
|
| 18 |
if (file_exists($getid3_demos_path)) {
|
| 19 |
$requirements['getid3']['description'] = $t("Your getID3 library is insecure! The demos distributed with getID3 contains code which creates a huge security hole. Remove the demos directory (%path) from beneth Drupal's directory.", array('%path' => realpath($getid3_demos_path)));
|
| 20 |
$requirements['getid3']['severity'] = REQUIREMENT_ERROR;
|
| 21 |
}
|
| 22 |
}
|
| 23 |
else {
|
| 24 |
$requirements['getid3']['value'] = $t('Not found or wrong version');
|
| 25 |
$requirements['getid3']['description'] = $t('You must install <a href="@getid3">getID3()</a> to %getid3dir, or <a href="@getid3settings">configure its installation path</a>.', array('@getid3' => 'http://www.getid3.org', '%getid3dir' => drupal_get_path('module', 'getid3') .'/getid3', '@getid3settings' => url('admin/settings/getid3')));
|
| 26 |
$requirements['getid3']['severity'] = REQUIREMENT_ERROR;
|
| 27 |
}
|
| 28 |
}
|
| 29 |
|
| 30 |
return $requirements;
|
| 31 |
}
|
| 32 |
|
| 33 |
/**
|
| 34 |
* Implementation of hook_enable()
|
| 35 |
*/
|
| 36 |
function getid3_enable() {
|
| 37 |
// Display a message if it fails to load getID3().
|
| 38 |
getid3_load();
|
| 39 |
}
|
| 40 |
|
| 41 |
/**
|
| 42 |
* Implementation of hook_install().
|
| 43 |
*/
|
| 44 |
function getid3_install() {
|
| 45 |
$status = array();
|
| 46 |
// Set module weight for the getID3 module
|
| 47 |
$status[] = db_query("UPDATE {system} SET weight = -10 WHERE name = 'getid3'");
|
| 48 |
|
| 49 |
// If there is one FALSE value in the status array, there was an error.
|
| 50 |
if (array_search(FALSE, $status) !== FALSE) {
|
| 51 |
drupal_set_message(t('Setting the module weight of getID3 failed.'), 'error');
|
| 52 |
}
|
| 53 |
}
|
| 54 |
|
| 55 |
/**
|
| 56 |
* Implementation of hook_uninstall()
|
| 57 |
*/
|
| 58 |
function getid3_uninstall() {
|
| 59 |
db_query("DELETE FROM {variable} WHERE name LIKE 'getid3_%'");
|
| 60 |
cache_clear_all('variables', 'cache');
|
| 61 |
}
|