Index: plugins/access/php.inc
===================================================================
RCS file: plugins/access/php.inc
diff -N plugins/access/php.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ plugins/access/php.inc	17 Jun 2009 13:35:20 -0000
@@ -0,0 +1,68 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Plugin to provide access control based on evaluated PHP.
+ */
+
+/**
+ * Implementation of specially named hook_ctools_access().
+ */
+function ctools_php_ctools_access() {
+  $args['php'] = array(
+    'title' => t("PHP"),
+    'description' => t('Control access through arbitrary PHP code.'),
+    'callback' => 'ctools_php_ctools_access_check',
+    'default' => array('php' => ''),
+    'settings form' => 'ctools_php_ctools_access_settings',
+    'summary' => 'ctools_php_ctools_acesss_summary',
+  );
+
+  return $args;
+}
+
+/**
+ * Settings form for the 'by perm' access plugin
+ *
+ * @todo Need a way to provide a list of all available contexts to be used by
+ *       the eval-ed PHP.
+ */
+function ctools_php_ctools_access_settings(&$form, &$form_state, $conf) {
+  $perms = array();
+
+  $form['settings']['description'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Description'),
+    '#default_value' => $conf['description'],
+    '#description' => t('A description for this access control. This will be seen when administering access control.'),
+    '#required' => TRUE,
+  );
+  $form['settings']['php'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Permission'),
+    '#default_value' => $conf['php'],
+    '#description' =>  t('Access will be granted if the following PHP code returns <code>TRUE</code>. Do not include &lt;?php ?&gt;. Note that executing incorrect PHP-code can break your Drupal site.') .'<br />'. t('The following contexts are available:') .'<ul><li>(need to provide list of available contexts)</li></ul>',
+    '#required' => TRUE,
+  );
+}
+
+/**
+ * Check for access.
+ *
+ * @todo Need a way to provide all available contexts to the eval-ed PHP.
+ *       Currently the $context argument is available to the PHP, but we have
+ *       no way to send all available contexts to this function without
+ *       explicitly listing them all.
+ */
+function ctools_php_ctools_access_check($__conf, $context) {
+  $access = eval($__conf['php']);
+  return $access;
+}
+
+/**
+ * Provide a summary description based upon the checked roles.
+ */
+function ctools_php_ctools_acesss_summary($conf, $context) {
+  return check_plain($conf['description']);
+}
