Merge pull request #17078 from herbdool/ui-18
[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 ) {
d94d05a5 64 $dsnArray = DB::parseDSN($config->dsn);
3fa9688a 65 $tableNames = CRM_Core_DAO::getTableNames();
101d85bc 66 asort($tableNames);
94c11eeb 67 $tablePrefixes = '$databases[\'default\'][\'default\'][\'prefix\']= array(';
c1156f3f
HD
68 if ($config->userFramework === 'Backdrop') {
69 $tablePrefixes = '$database_prefix = array(';
70 }
0d48f1cc
TO
71 // add default prefix: the drupal database prefix
72 $tablePrefixes .= "\n 'default' => '$drupal_prefix',";
d94d05a5 73 $prefix = "";
74 if ($config->dsn != $config->userFrameworkDSN) {
75 $prefix = "`{$dsnArray['database']}`.";
76 }
3fa9688a 77 foreach ($tableNames as $tableName) {
d94d05a5 78 $tablePrefixes .= "\n '" . str_pad($tableName . "'", 41) . " => '{$prefix}',";
6a488035
TO
79 }
80 $tablePrefixes .= "\n);";
81 $this->assign('tablePrefixes', $tablePrefixes);
82 }
83
84 parent::buildQuickForm();
85 }
96025800 86
6a488035 87}