Merge pull request #19489 from colemanw/searchKitBugs
[civicrm-core.git] / CRM / Admin / Form / Setting / UF.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035
TO
16 */
17
18/**
ce064e4f 19 * This class generates form components for Site Url.
6a488035
TO
20 */
21class CRM_Admin_Form_Setting_UF extends CRM_Admin_Form_Setting {
22
be2fb01f 23 protected $_settings = [];
94c11eeb 24
d94d05a5 25 protected $_uf = NULL;
94c11eeb 26
6a488035 27 /**
eceb18cc 28 * Build the form object.
6a488035
TO
29 */
30 public function buildQuickForm() {
31 $config = CRM_Core_Config::singleton();
94c11eeb 32 $this->_uf = $config->userFramework;
5e7f101a 33 $this->_settings['syncCMSEmail'] = CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME;
6a488035 34
94c11eeb 35 if ($this->_uf == 'WordPress') {
348754d5 36 $this->_settings['wpBasePage'] = CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME;
94c11eeb 37 }
6a488035 38
94c11eeb 39 CRM_Utils_System::setTitle(
be2fb01f 40 ts('Settings - %1 Integration', [1 => $this->_uf])
94c11eeb
DL
41 );
42
348754d5
TO
43 if ($config->userSystem->is_drupal) {
44 $this->_settings['userFrameworkUsersTableName'] = CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME;
45 }
46
d94d05a5 47 // find out if drupal has its database prefixed
48 global $databases;
49 $drupal_prefix = '';
50 if (isset($databases['default']['default']['prefix'])) {
51 if (is_array($databases['default']['default']['prefix'])) {
52 $drupal_prefix = $databases['default']['default']['prefix']['default'];
53 }
54 else {
55 $drupal_prefix = $databases['default']['default']['prefix'];
56 }
57 }
58
9a8fe710 59 if ($config->userSystem->viewsExists() &&
d94d05a5 60 (
61 $config->dsn != $config->userFrameworkDSN || !empty($drupal_prefix)
62 )
6a488035 63 ) {
58d1e21e
SL
64 $dsn = CRM_Utils_SQL::autoSwitchDSN($config->dsn);
65 $dsnArray = DB::parseDSN($dsn);
3fa9688a 66 $tableNames = CRM_Core_DAO::getTableNames();
101d85bc 67 asort($tableNames);
94c11eeb 68 $tablePrefixes = '$databases[\'default\'][\'default\'][\'prefix\']= array(';
c1156f3f
HD
69 if ($config->userFramework === 'Backdrop') {
70 $tablePrefixes = '$database_prefix = array(';
71 }
0d48f1cc
TO
72 // add default prefix: the drupal database prefix
73 $tablePrefixes .= "\n 'default' => '$drupal_prefix',";
d94d05a5 74 $prefix = "";
75 if ($config->dsn != $config->userFrameworkDSN) {
76 $prefix = "`{$dsnArray['database']}`.";
6df4d2ca
HD
77 if ($config->userFramework === 'Backdrop') {
78 $prefix = "{$dsnArray['database']}.";
79 }
d94d05a5 80 }
3fa9688a 81 foreach ($tableNames as $tableName) {
d94d05a5 82 $tablePrefixes .= "\n '" . str_pad($tableName . "'", 41) . " => '{$prefix}',";
6a488035
TO
83 }
84 $tablePrefixes .= "\n);";
85 $this->assign('tablePrefixes', $tablePrefixes);
86 }
87
88 parent::buildQuickForm();
89 }
96025800 90
6a488035 91}