Commit 079bd33a authored by eileen's avatar eileen 🎱 Committed by GitHub

Merge pull request #10940 from seamuslee001/CRM-20769-fields

CRM-20769 Add in columns to support customising profile buttons
parents e5a69e4c 41ace555
......@@ -371,9 +371,10 @@ ALTER TABLE {$tableName}
* @param string $tableName
* @param string $columnName
* @param bool $l18n
* @param bool $isUpgradeMode
*
*/
public static function dropColumn($tableName, $columnName, $l18n = FALSE) {
public static function dropColumn($tableName, $columnName, $l18n = FALSE, $isUpgradeMode = FALSE) {
if (self::checkIfFieldExists($tableName, $columnName)) {
$sql = "ALTER TABLE $tableName DROP COLUMN $columnName";
if ($l18n) {
......@@ -386,7 +387,7 @@ ALTER TABLE {$tableName}
$domain->find(TRUE);
if ($domain->locales) {
$locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
CRM_Core_I18n_Schema::rebuildMultilingualSchema($locales, NULL);
CRM_Core_I18n_Schema::rebuildMultilingualSchema($locales, NULL, $isUpgradeMode);
}
}
}
......
......@@ -30,7 +30,7 @@
*
* Generated from xml/schema/CRM/Core/UFGroup.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:d716aaa0c1ca4a43bbd533faef6d94c7)
* (GenCodeChecksum:d87b52f7baf5aa4e4ccaf26c6e7acabc)
*/
require_once 'CRM/Core/DAO.php';
require_once 'CRM/Utils/Type.php';
......@@ -187,6 +187,18 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
* @var boolean
*/
public $is_proximity_search;
/**
* Custom Text to display on the Cancel button when used in create or edit mode
*
* @var string
*/
public $cancel_button_text;
/**
* Custom Text to display on the submit button on profile edit/create screens
*
* @var string
*/
public $submit_button_text;
/**
* Class constructor.
*/
......@@ -483,6 +495,32 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
'bao' => 'CRM_Core_BAO_UFGroup',
'localizable' => 0,
) ,
'cancel_button_text' => array(
'name' => 'cancel_button_text',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Cancel Button Text') ,
'description' => 'Custom Text to display on the Cancel button when used in create or edit mode',
'maxlength' => 64,
'size' => CRM_Utils_Type::BIG,
'default' => 'NULL',
'table_name' => 'civicrm_uf_group',
'entity' => 'UFGroup',
'bao' => 'CRM_Core_BAO_UFGroup',
'localizable' => 1,
) ,
'submit_button_text' => array(
'name' => 'submit_button_text',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Submit Button Text') ,
'description' => 'Custom Text to display on the submit button on profile edit/create screens',
'maxlength' => 64,
'size' => CRM_Utils_Type::BIG,
'default' => 'NULL',
'table_name' => 'civicrm_uf_group',
'entity' => 'UFGroup',
'bao' => 'CRM_Core_BAO_UFGroup',
'localizable' => 1,
) ,
);
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
}
......
......@@ -295,8 +295,10 @@ class CRM_Core_I18n_Schema {
* locales to be rebuilt.
* @param string $version
* version of schema structure to use.
* @param bool $isUpgradeMode
* Are we upgrading our database
*/
public static function rebuildMultilingualSchema($locales, $version = NULL) {
public static function rebuildMultilingualSchema($locales, $version = NULL, $isUpgradeMode = FALSE) {
if ($version) {
$latest = self::getLatestSchema($version);
require_once "CRM/Core/I18n/SchemaStructure_{$latest}.php";
......@@ -337,7 +339,7 @@ class CRM_Core_I18n_Schema {
// rebuild views
foreach ($locales as $locale) {
foreach ($tables as $table) {
$queries[] = self::createViewQuery($locale, $table, $dao, $class);
$queries[] = self::createViewQuery($locale, $table, $dao, $class, $isUpgradeMode);
}
}
......@@ -481,13 +483,15 @@ class CRM_Core_I18n_Schema {
* A DAO object to run DESCRIBE queries.
* @param string $class
* schema structure class to use.
*
* @param bool $isUpgradeMode
* Are we in upgrade mode therefore only build based off table not class
* @return array
* array of CREATE INDEX queries
*/
private static function createViewQuery($locale, $table, &$dao, $class = 'CRM_Core_I18n_SchemaStructure') {
private static function createViewQuery($locale, $table, &$dao, $class = 'CRM_Core_I18n_SchemaStructure', $isUpgradeMode = FALSE) {
$columns =& $class::columns();
$cols = array();
$tableCols = array();
$dao->query("DESCRIBE {$table}", FALSE);
while ($dao->fetch()) {
// view non-internationalized columns directly
......@@ -496,10 +500,16 @@ class CRM_Core_I18n_Schema {
) {
$cols[] = $dao->Field;
}
$tableCols[] = $dao->Field;
}
// view intrernationalized columns through an alias
foreach ($columns[$table] as $column => $_) {
$cols[] = "{$column}_{$locale} {$column}";
if (!$isUpgradeMode) {
$cols[] = "{$column}_{$locale} {$column}";
}
elseif (in_array("{$column}_{$locale}", $tableCols)) {
$cols[] = "{$column}_{$locale} {$column}";
}
}
return "CREATE OR REPLACE VIEW {$table}_{$locale} AS SELECT " . implode(', ', $cols) . " FROM {$table}";
}
......
......@@ -160,7 +160,9 @@ class CRM_Upgrade_Incremental_Base {
if ($localizable) {
$locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
foreach ($locales as $locale) {
$queries[] = "ALTER TABLE `$table` ADD COLUMN `{$column}_{$locale}` $properties";
if (!CRM_Core_BAO_SchemaHandler::checkIfFieldExists($table, "{$column}_{$locale}")) {
$queries[] = "ALTER TABLE `$table` ADD COLUMN `{$column}_{$locale}` $properties";
}
}
}
else {
......@@ -176,7 +178,7 @@ class CRM_Upgrade_Incremental_Base {
}
if ($domain->locales) {
$locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
CRM_Core_I18n_Schema::rebuildMultilingualSchema($locales, NULL);
CRM_Core_I18n_Schema::rebuildMultilingualSchema($locales, NULL, TRUE);
}
return TRUE;
}
......
......@@ -414,6 +414,10 @@ class CRM_Upgrade_Incremental_php_FourSeven extends CRM_Upgrade_Incremental_Base
'civicrm_menu', 'module_data', "text COMMENT 'All other menu metadata not stored in other fields'");
$this->addTask('CRM-21052 - Determine activity revision policy', 'pickActivityRevisionPolicy');
$this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
$this->addTask('Add cancel button text column to civicrm_uf_group', 'addColumn',
'civicrm_uf_group', 'cancel_button_text', "varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Custom Text to display on the cancel button when used in create or edit mode'", TRUE);
$this->addTask('Add Submit button text column to civicrm_uf_group', 'addColumn',
'civicrm_uf_group', 'submit_button_text', "varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Custom Text to display on the submit button on profile edit/create screens'", TRUE);
}
......@@ -879,7 +883,7 @@ FROM `civicrm_dashboard_contact` JOIN `civicrm_contact` WHERE civicrm_dashboard_
ADD COLUMN `help_post_{$locale}` text COLLATE utf8_unicode_ci COMMENT 'Price field option post help text.'", array(), TRUE, NULL, FALSE, FALSE);
}
}
CRM_Core_I18n_Schema::rebuildMultilingualSchema($locales, NULL);
CRM_Core_I18n_Schema::rebuildMultilingualSchema($locales, NULL, TRUE);
}
else {
if (!CRM_Core_BAO_SchemaHandler::checkIfFieldExists('civicrm_price_field_value', 'help_pre')) {
......@@ -981,14 +985,14 @@ FROM `civicrm_dashboard_contact` JOIN `civicrm_contact` WHERE civicrm_dashboard_
}
$domain = new CRM_Core_DAO_Domain();
$domain->find(TRUE);
CRM_Core_BAO_SchemaHandler::dropColumn('civicrm_dashboard_contact', 'content');
CRM_Core_BAO_SchemaHandler::dropColumn('civicrm_dashboard_contact', 'is_minimized');
CRM_Core_BAO_SchemaHandler::dropColumn('civicrm_dashboard_contact', 'is_fullscreen');
CRM_Core_BAO_SchemaHandler::dropColumn('civicrm_dashboard_contact', 'created_date');
CRM_Core_BAO_SchemaHandler::dropColumn('civicrm_dashboard', 'is_fullscreen');
CRM_Core_BAO_SchemaHandler::dropColumn('civicrm_dashboard', 'is_minimized');
CRM_Core_BAO_SchemaHandler::dropColumn('civicrm_dashboard', 'column_no');
CRM_Core_BAO_SchemaHandler::dropColumn('civicrm_dashboard', 'weight');
CRM_Core_BAO_SchemaHandler::dropColumn('civicrm_dashboard_contact', 'content', FALSE, TRUE);
CRM_Core_BAO_SchemaHandler::dropColumn('civicrm_dashboard_contact', 'is_minimized', FALSE, TRUE);
CRM_Core_BAO_SchemaHandler::dropColumn('civicrm_dashboard_contact', 'is_fullscreen', FALSE, TRUE);
CRM_Core_BAO_SchemaHandler::dropColumn('civicrm_dashboard_contact', 'created_date', FALSE, TRUE);
CRM_Core_BAO_SchemaHandler::dropColumn('civicrm_dashboard', 'is_fullscreen', FALSE, TRUE);
CRM_Core_BAO_SchemaHandler::dropColumn('civicrm_dashboard', 'is_minimized', FALSE, TRUE);
CRM_Core_BAO_SchemaHandler::dropColumn('civicrm_dashboard', 'column_no', FALSE, TRUE);
CRM_Core_BAO_SchemaHandler::dropColumn('civicrm_dashboard', 'weight', FALSE, TRUE);
CRM_Core_DAO::executeQuery('UPDATE civicrm_dashboard SET url = REPLACE(url, "&snippet=5", ""), fullscreen_url = REPLACE(fullscreen_url, "&snippet=5", "")');
......@@ -998,7 +1002,7 @@ FROM `civicrm_dashboard_contact` JOIN `civicrm_contact` WHERE civicrm_dashboard_
}
if ($domain->locales) {
$locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
CRM_Core_I18n_Schema::rebuildMultilingualSchema($locales, NULL);
CRM_Core_I18n_Schema::rebuildMultilingualSchema($locales, NULL, TRUE);
}
CRM_Core_DAO::executeQuery('UPDATE civicrm_dashboard SET cache_minutes = 1440 WHERE name = "blog"');
......@@ -1050,7 +1054,7 @@ FROM `civicrm_dashboard_contact` JOIN `civicrm_contact` WHERE civicrm_dashboard_
$domain->find(TRUE);
if ($domain->locales) {
$locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
CRM_Core_I18n_Schema::rebuildMultilingualSchema($locales, NULL);
CRM_Core_I18n_Schema::rebuildMultilingualSchema($locales, NULL, TRUE);
}
CRM_Core_DAO::executeQuery("UPDATE `civicrm_option_group` SET `data_type` = 'Integer'
......
This diff is collapsed.
......@@ -252,4 +252,24 @@
<comment>Should we include proximity search feature in this profile search form?</comment>
<add>3.2</add>
</field>
<field>
<name>cancel_button_text</name>
<title>Cancel Button Text</title>
<type>varchar</type>
<length>64</length>
<comment>Custom Text to display on the Cancel button when used in create or edit mode</comment>
<default>NULL</default>
<localizable>true</localizable>
<add>4.7</add>
</field>
<field>
<name>submit_button_text</name>
<title>Submit Button Text</title>
<type>varchar</type>
<length>64</length>
<comment>Custom Text to display on the submit button on profile edit/create screens</comment>
<default>NULL</default>
<localizable>true</localizable>
<add>4.7</add>
</field>
</table>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment