| 1 |
<?php |
<?php |
| 2 |
|
|
| 3 |
// $Id$ |
// $Id: civicrm_error.install,v 1.1 2007/07/20 15:44:34 dalin Exp $ |
| 4 |
|
|
| 5 |
|
/** |
| 6 |
|
* @file |
| 7 |
|
* Install file for civicrm_error module |
| 8 |
|
*/ |
| 9 |
|
|
| 10 |
|
|
| 11 |
/** |
/** |
| 12 |
* Implementation of hook_install(). |
* Implementation of hook_install(). |
| 13 |
*/ |
*/ |
| 14 |
function civicrm_error_install() { |
function civicrm_error_install() { |
| 15 |
civicrm_error_config(true); |
civicrm_error_config(TRUE); |
| 16 |
} |
} |
| 17 |
|
|
| 18 |
/** |
/** |
| 23 |
civicrm_error_config(false); |
civicrm_error_config(false); |
| 24 |
} |
} |
| 25 |
|
|
| 26 |
function civicrm_error_config($setup = true) { |
function civicrm_error_config($setup = TRUE) { |
| 27 |
global $db_url; |
global $db_url; |
| 28 |
if (is_array($db_url) && isset($db_url['civicrm'])) { |
if (is_array($db_url) && isset($db_url['civicrm'])) { |
| 29 |
db_set_active('civicrm'); |
db_set_active('civicrm'); |
| 30 |
$domains = db_result(db_query('SELECT COUNT(id) FROM civicrm_domain')); |
$domains = db_result(db_query('SELECT COUNT(id) FROM civicrm_domain')); |
| 31 |
if ($domains = 1) { |
if ($domains = 1) { |
| 32 |
$config = unserialize(db_result(db_query('SELECT config_backend FROM civicrm_domain WHERE id = 1'))); |
$config = unserialize(db_result(db_query( |
| 33 |
|
'SELECT config_backend FROM civicrm_domain WHERE id = 1'))); |
| 34 |
if (array_key_exists('fatalErrorHandler', $config)) { |
if (array_key_exists('fatalErrorHandler', $config)) { |
| 35 |
$config['fatalErrorHandler'] = ($setup ? 'civicrm_error_handler' : null); |
$config['fatalErrorHandler'] = ($setup ? 'civicrm_error_handler' : NULL); |
| 36 |
/** TODO: this royal screws things up. Need to fix **/ |
/** TODO: this royally screws things up. Need to fix **/ |
| 37 |
// db_query('UPDATE civicrm_domain SET config_backend = "$s" WHERE id = 1', serialize($config)); |
// db_query('UPDATE civicrm_domain SET config_backend = "$s" WHERE id = 1', serialize($config)); |
| 38 |
$fail = true; |
$fail = TRUE; |
| 39 |
} |
} |
| 40 |
else { |
else { |
| 41 |
$fail = true; |
$fail = TRUE; |
| 42 |
} |
} |
| 43 |
} |
} |
| 44 |
else { |
else { |
| 45 |
$fail = true; |
$fail = TRUE; |
| 46 |
} |
} |
| 47 |
db_set_active(); |
db_set_active(); |
| 48 |
} |
} |
| 49 |
else { |
else { |
| 50 |
$fail = true; |
$fail = TRUE; |
| 51 |
} |
} |
| 52 |
if ($fail) { |
if ($fail) { |
| 53 |
$not = !$setup ? 'not ' : ''; |
$not = !$setup ? 'not ' : ''; |
| 54 |
drupal_set_message(t("Unable to set CiviCRM to {$not}use the custom error handler. Please go to %path and set %param to %value", array('%path' => 'Administer CiviCRM » Global Settings » Debugging', '%param' => 'Fatal Error Handler', '%value' => 'civicrm_error_handler'))); |
drupal_set_message(t("Unable to set CiviCRM to {$not}use the custom error handler. |
| 55 |
|
Please go to %path and set %param to %value", |
| 56 |
|
array( |
| 57 |
|
'%path' => 'Administer CiviCRM » Global Settings » Debugging', |
| 58 |
|
'%param' => 'Fatal Error Handler', '%value' => 'civicrm_error_handler' |
| 59 |
|
) |
| 60 |
|
)); |
| 61 |
} |
} |
| 62 |
else { |
else { |
| 63 |
drupal_set_message(t('CiviCRM Error Handler Installed')); |
drupal_set_message(t('CiviCRM Error Handler Installed')); |