From f21a9fdffe2c7d72a50533ae2466938de5a0a8ee Mon Sep 17 00:00:00 2001 From: Christoph Burschka Date: Sat, 18 Jan 2014 13:03:11 +0100 Subject: Implement session auth for Drupal. --- plugins/drupal7/drupal7.module | 13 +++++++++++-- plugins/drupal8/drupal8.module | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/plugins/drupal7/drupal7.module b/plugins/drupal7/drupal7.module index 0c593cd..e1cd857 100644 --- a/plugins/drupal7/drupal7.module +++ b/plugins/drupal7/drupal7.module @@ -2,7 +2,7 @@ use Drupal\Core\DrupalKernel; -function drupal7_init($config) { +function drupal7_bootstrap($config) { define('DRUPAL_ROOT', $config['root_path']); $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; @@ -10,5 +10,14 @@ function drupal7_init($config) { require_once __DIR__ . '/BridgeDrupal7.php'; drupal_static('conf_path', "sites/{$config['site']}"); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); +} + +function drupal7_init($config) { + drupal7_bootstrap($config); return new BridgeDrupal7(); -} \ No newline at end of file +} + +function drupal7_session($config) { + drupal7_bootstrap($config); + return user_is_logged_in() ? $GLOBALS['user']->name : FALSE; +} diff --git a/plugins/drupal8/drupal8.module b/plugins/drupal8/drupal8.module index 390b678..193ddb8 100644 --- a/plugins/drupal8/drupal8.module +++ b/plugins/drupal8/drupal8.module @@ -2,7 +2,7 @@ use Drupal\Core\DrupalKernel; -function drupal8_init($config) { +function drupal8_bootstrap($config) { define('DRUPAL_ROOT', $config['root_path']); $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; require_once DRUPAL_ROOT . '/core/includes/bootstrap.inc'; @@ -12,5 +12,14 @@ function drupal8_init($config) { drupal_bootstrap(DRUPAL_BOOTSTRAP_CODE); $kernel = new DrupalKernel('prod', FALSE, NULL, cache('bootstrap')); $kernel->boot(); +} + +function drupal8_init($config) { + drupal8_bootstrap($config); return new BridgeDrupal8(); -} \ No newline at end of file +} + +function drupal8_session($config) { + drupal8_bootstrap($config); + return user_is_logged_in() ? $GLOBALS['user']->name : FALSE; +} -- cgit v1.1