<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.4 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
* $Id$
*
*/
protected $_settings = array();
- protected $_uf = null;
+ protected $_uf = NULL;
/**
* Function to build the form
*
- * @return None
+ * @return void
* @access public
*/
public function buildQuickForm() {
);
$this->addElement('text', 'userFrameworkUsersTableName', ts('%1 Users Table Name', array(1 => $this->_uf)));
+ // find out if drupal has its database prefixed
+ global $databases;
+ $drupal_prefix = '';
+ if (isset($databases['default']['default']['prefix'])) {
+ if (is_array($databases['default']['default']['prefix'])) {
+ $drupal_prefix = $databases['default']['default']['prefix']['default'];
+ }
+ else {
+ $drupal_prefix = $databases['default']['default']['prefix'];
+ }
+ }
+
if (
function_exists('module_exists') &&
module_exists('views') &&
- $config->dsn != $config->userFrameworkDSN
+ (
+ $config->dsn != $config->userFrameworkDSN || !empty($drupal_prefix)
+ )
) {
- $dsnArray = DB::parseDSN($config->dsn);
- $tableNames = CRM_Core_DAO::GetStorageValues(NULL, 0, 'Name');
+ $dsnArray = DB::parseDSN($config->dsn);
+ $tableNames = CRM_Core_DAO::GetStorageValues(NULL, 0, 'Name');
$tablePrefixes = '$databases[\'default\'][\'default\'][\'prefix\']= array(';
+ $tablePrefixes .= "\n 'default' => '$drupal_prefix',"; // add default prefix: the drupal database prefix
+ $prefix = "";
+ if ($config->dsn != $config->userFrameworkDSN) {
+ $prefix = "`{$dsnArray['database']}`.";
+ }
foreach ($tableNames as $tableName => $value) {
- $tablePrefixes .= "\n '" . str_pad($tableName . "'", 41) . " => '`{$dsnArray['database']}`.',";
+ $tablePrefixes .= "\n '" . str_pad($tableName . "'", 41) . " => '{$prefix}',";
}
$tablePrefixes .= "\n);";
$this->assign('tablePrefixes', $tablePrefixes);