Mercurial > hg > rr-repo
annotate modules/php/php.install @ 2:b74b41bb73f0
-- Google analytics module
author | danieleb <danielebarchiesi@me.com> |
---|---|
date | Thu, 22 Aug 2013 17:22:54 +0100 |
parents | ff03f76ab3fe |
children |
rev | line source |
---|---|
danielebarchiesi@0 | 1 <?php |
danielebarchiesi@0 | 2 |
danielebarchiesi@0 | 3 /** |
danielebarchiesi@0 | 4 * @file |
danielebarchiesi@0 | 5 * Install, update and uninstall functions for the php module. |
danielebarchiesi@0 | 6 */ |
danielebarchiesi@0 | 7 |
danielebarchiesi@0 | 8 /** |
danielebarchiesi@0 | 9 * Implements hook_enable(). |
danielebarchiesi@0 | 10 */ |
danielebarchiesi@0 | 11 function php_enable() { |
danielebarchiesi@0 | 12 $format_exists = (bool) db_query_range('SELECT 1 FROM {filter_format} WHERE name = :name', 0, 1, array(':name' => 'PHP code'))->fetchField(); |
danielebarchiesi@0 | 13 // Add a PHP code text format, if it does not exist. Do this only for the |
danielebarchiesi@0 | 14 // first install (or if the format has been manually deleted) as there is no |
danielebarchiesi@0 | 15 // reliable method to identify the format in an uninstall hook or in |
danielebarchiesi@0 | 16 // subsequent clean installs. |
danielebarchiesi@0 | 17 if (!$format_exists) { |
danielebarchiesi@0 | 18 $php_format = array( |
danielebarchiesi@0 | 19 'format' => 'php_code', |
danielebarchiesi@0 | 20 'name' => 'PHP code', |
danielebarchiesi@0 | 21 // 'Plain text' format is installed with a weight of 10 by default. Use a |
danielebarchiesi@0 | 22 // higher weight here to ensure that this format will not be the default |
danielebarchiesi@0 | 23 // format for anyone. |
danielebarchiesi@0 | 24 'weight' => 11, |
danielebarchiesi@0 | 25 'filters' => array( |
danielebarchiesi@0 | 26 // Enable the PHP evaluator filter. |
danielebarchiesi@0 | 27 'php_code' => array( |
danielebarchiesi@0 | 28 'weight' => 0, |
danielebarchiesi@0 | 29 'status' => 1, |
danielebarchiesi@0 | 30 ), |
danielebarchiesi@0 | 31 ), |
danielebarchiesi@0 | 32 ); |
danielebarchiesi@0 | 33 $php_format = (object) $php_format; |
danielebarchiesi@0 | 34 filter_format_save($php_format); |
danielebarchiesi@0 | 35 |
danielebarchiesi@0 | 36 drupal_set_message(t('A <a href="@php-code">PHP code</a> text format has been created.', array('@php-code' => url('admin/config/content/formats/' . $php_format->format)))); |
danielebarchiesi@0 | 37 } |
danielebarchiesi@0 | 38 } |
danielebarchiesi@0 | 39 |
danielebarchiesi@0 | 40 /** |
danielebarchiesi@0 | 41 * Implements hook_disable(). |
danielebarchiesi@0 | 42 */ |
danielebarchiesi@0 | 43 function php_disable() { |
danielebarchiesi@0 | 44 drupal_set_message(t('The PHP module has been disabled. 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.')); |
danielebarchiesi@0 | 45 } |