php.install

  1. 7.x drupal-7.x/modules/php/php.install
  2. 6.x drupal-6.x/modules/php/php.install

File

drupal-6.x/modules/php/php.install
View source
  1. <?php
  2. /**
  3. * Implementation of hook_install().
  4. */
  5. function php_install() {
  6. $format_exists = db_result(db_query("SELECT COUNT(*) FROM {filter_formats} WHERE name = 'PHP code'"));
  7. // Add a PHP code input format, if it does not exist. Do this only for the
  8. // first install (or if the format has been manually deleted) as there is no
  9. // reliable method to identify the format in an uninstall hook or in
  10. // subsequent clean installs.
  11. if (!$format_exists) {
  12. db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('PHP code', '', 0)");
  13. $format = db_result(db_query("SELECT MAX(format) FROM {filter_formats}"));
  14. // Enable the PHP evaluator filter.
  15. db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, 'php', 0, 0)", $format);
  16. drupal_set_message(t('A !php-code input format has been created.', array('!php-code' => l('PHP code', 'admin/settings/filters/'. $format))));
  17. }
  18. }
  19. /**
  20. * Implementation of hook_disable().
  21. */
  22. function php_disable() {
  23. 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.'));
  24. }