Index: omniture_php/omniture_php.info
===================================================================
--- omniture_php/omniture_php.info	(revision 0)
+++ omniture_php/omniture_php.info	(revision 0)
@@ -0,0 +1,5 @@
+; $Id$ 
+name = Omniture PHP
+description = Adds the ability for appropriately permissioned administrators to write PHP for creating dynamic Omniture variables.
+core = 6.x
+dependencies[] = omniture
Index: omniture_php/omniture_php.install
===================================================================
--- omniture_php/omniture_php.install	(revision 0)
+++ omniture_php/omniture_php.install	(revision 0)
@@ -0,0 +1,16 @@
+<?php
+// $Id$
+
+/*
+ * Created by Greg Harvey on 14 Jun 2010
+ *
+ * http://www.drupaler.co.uk
+ */
+ 
+/**
+ * Implementation of hook_uninstall().
+ */
+function omniture_php_uninstall() {
+  // Delete any variables unique to this module.
+  variable_del('omniture_php_variables');
+}
Index: omniture_php/omniture_php.module
===================================================================
--- omniture_php/omniture_php.module	(revision 0)
+++ omniture_php/omniture_php.module	(revision 0)
@@ -0,0 +1,51 @@
+<?php
+// $Id$
+
+/*
+ * Created by Greg Harvey on 14 Jun 2010
+ *
+ * http://www.drupaler.co.uk
+ */
+
+/**
+ * Implementation of hook_perm().
+ */
+function omniture_php_perm() {
+  return array('use PHP to set Omniture variables');
+}
+
+/**
+ * Implementation of hook_omniture_variables().
+ */
+function omniture_php_omniture_variables($main) {
+  // Execute the saved PHP and return the result.
+  // We use eval() instead of drupal_eval() because the Drupal function just returns
+  // the string 'Array' and not the array itself.
+  return eval(variable_get('omniture_php_variables', ''));
+}
+
+/**
+ * Implementation of hook_form_omniture_admin_settings_alter().
+ */
+function omniture_php_form_omniture_admin_settings_alter(&$form, &$form_state) {
+  // Uncollapse the Advanced fieldset if there is PHP entered.
+  if (variable_get('omniture_php_variables', '')) {
+    $form['advanced']['#collapsed'] = FALSE;
+  }
+  $form['advanced']['omniture_php'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Omniture PHP code'),
+    '#default_value' => variable_get('omniture_php_variables', ''),
+    '#rows' => 15,
+    '#description' => t('Allows you to return complex PHP-driven Omniture variables from the Drupal administration section. Use with extreme caution! Your PHP must return a variables array as expected by hook_omniture_variables(). Do not include &lt;?php ?&gt; tags. !link', array('!link' => l(t('For more information and an example follow this link.'), 'http://drupal.org/node/182201#comment-1046683') )),
+  );
+  // Add in our additional submit function.
+  $form['#submit'][] = 'omniture_php_admin_settings_submit';
+}
+
+/**
+ * Submit function for saving any entered PHP in a Drupal variable.
+ */
+function omniture_php_admin_settings_submit($form, &$form_state) {
+  variable_set('omniture_php_variables', $form_state['values']['omniture_php']);
+}

