2007-04-24 10:54:35 +00:00
<?php
// $Id$
2009-05-13 19:42:18 +00:00
/**
* @file
* Install, update and uninstall functions for the php module.
*/
2007-04-24 10:54:35 +00:00
/**
2009-05-27 18:34:03 +00:00
* Implement hook_install().
2007-04-24 10:54:35 +00:00
*/
function php_install() {
2009-09-18 00:04:24 +00:00
$format_exists = (bool) db_query_range('SELECT 1 FROM {filter_format} WHERE name = :name', 0, 1, array(':name' => 'PHP code'))->fetchField();
2009-01-21 16:58:42 +00:00
// Add a PHP code text format, if it does not exist. Do this only for the
2007-04-24 10:54:35 +00:00
// first install (or if the format has been manually deleted) as there is no
// reliable method to identify the format in an uninstall hook or in
// subsequent clean installs.
if (!$format_exists) {
2009-03-13 21:35:02 +00:00
$format = db_insert('filter_format')
->fields(array(
'name' => 'PHP code',
'cache' => 0,
))
->execute();
2007-04-24 10:54:35 +00:00
// Enable the PHP evaluator filter.
2009-03-13 21:35:02 +00:00
db_insert('filter')
->fields(array(
'format' => $format,
'module' => 'php',
2009-08-21 17:28:27 +00:00
'name' => 'php_code',
2009-03-13 21:35:02 +00:00
'weight' => 0,
2009-08-27 21:18:20 +00:00
'status' => 1,
2009-03-13 21:35:02 +00:00
))
->execute();
2007-04-24 10:54:35 +00:00
2009-08-28 16:23:05 +00:00
drupal_set_message(t('A !php-code text format has been created.', array('!php-code' => l('PHP code', 'admin/config/content/formats/' . $format))));
2007-04-24 10:54:35 +00:00
}
}
/**
2009-05-27 18:34:03 +00:00
* Implement hook_disable().
2007-04-24 10:54:35 +00:00
*/
function php_disable() {
drupal_set_message(t('The PHP module has been disabled. Please note that any existing content that was using the PHP filter will now be visible in plain text. This might pose a security risk by exposing sensitive information, if any, used in the PHP code.'));
}