From: Ravish Nair Date: Fri, 25 Oct 2013 11:37:32 +0000 (+0530) Subject: -- CRM-13327 handled upgrade X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=6b12405a12cdf95d2092cbe663e4f5edb1092025;p=civicrm-core.git -- CRM-13327 handled upgrade --- diff --git a/CRM/Upgrade/Incremental/php/FourFour.php b/CRM/Upgrade/Incremental/php/FourFour.php index 2ba2feb27e..e7c915b199 100644 --- a/CRM/Upgrade/Incremental/php/FourFour.php +++ b/CRM/Upgrade/Incremental/php/FourFour.php @@ -103,6 +103,46 @@ class CRM_Upgrade_Incremental_php_FourFour { $this->addTask('Migrate custom word-replacements', 'wordReplacements'); } + function upgrade_4_4_1($rev) { + // CRM-13327 upgrade handling for the newly added name badges + $ogID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'name_badge', 'id', 'name'); + $nameBadges = array_flip(array_values(CRM_Core_BAO_OptionValue::getOptionValuesAssocArrayFromName('name_badge'))); + unset($nameBadges['Avery 5395']); + if (!empty($nameBadges)) { + $dimension = '{"paper-size":"a4","orientation":"portrait","font-name":"times","font-size":6,"font-style":"","NX":2,"NY":4,"metric":"mm","lMargin":6,"tMargin":19,"SpaceX":0,"SpaceY":0,"width":100,"height":65,"lPadding":0,"tPadding":0}'; + $query = "UPDATE civicrm_option_value + SET value = '{$dimension}' + WHERE option_group_id = %1 AND name = 'Fattorini Name Badge 100x65'"; + + CRM_Core_DAO::executeQuery($query, array(1 => array($ogID, 'Integer'))); + } + else { + $dimensions = array( + 1 => '{"paper-size":"a4","orientation":"landscape","font-name":"times","font-size":6,"font-style":"","NX":2,"NY":1,"metric":"mm","lMargin":25,"tMargin":27,"SpaceX":0,"SpaceY":35,"width":106,"height":150,"lPadding":5,"tPadding":5}', + 2 => '{"paper-size":"a4","orientation":"portrait","font-name":"times","font-size":6,"font-style":"","NX":2,"NY":4,"metric":"mm","lMargin":6,"tMargin":19,"SpaceX":0,"SpaceY":0,"width":100,"height":65,"lPadding":0,"tPadding":0}', + 3 => '{"paper-size":"a4","orientation":"portrait","font-name":"times","font-size":6,"font-style":"","NX":2,"NY":2,"metric":"mm","lMargin":10,"tMargin":28,"SpaceX":0,"SpaceY":0,"width":96,"height":121,"lPadding":5,"tPadding":5}', + ); + $insertStatements = array( + 1 => "($ogID, %1, '{$dimensions[1]}', %1, NULL, 0, NULL, 2, NULL, 0, 0, 1, NULL, NULL)", + 2 => "($ogID, %2, '{$dimensions[2]}', %2, NULL, 0, NULL, 3, NULL, 0, 0, 1, NULL, NULL)", + 3 => "($ogID, %3, '{$dimensions[3]}', %3, NULL, 0, NULL, 4, NULL, 0, 0, 1, NULL, NULL)", + ); + + $queryParams = array( + 1 => array('A6 Badge Portrait 150x106', 'String'), + 2 => array('Fattorini Name Badge 100x65', 'String'), + 3 => array('Hanging Badge 3-3/4" x 4-3"/4', 'String'), + ); + + foreach ($insertStatements as $values) { + $query = 'INSERT INTO civicrm_option_value (`option_group_id`, `label`, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `description`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`) VALUES' . $values; + CRM_Core_DAO::executeQuery($query, $queryParams); + } + } + + $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.4.1')), 'task_4_4_x_runSql', $rev); + } + /** * Update activity contacts CRM-12274 * diff --git a/CRM/Upgrade/Incremental/sql/4.4.1.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.4.1.mysql.tpl index ae5816becd..a5615cfdd4 100644 --- a/CRM/Upgrade/Incremental/sql/4.4.1.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/4.4.1.mysql.tpl @@ -1 +1,6 @@ {* file to handle db changes in 4.4.1 during upgrade *} +-- CRM-13327 +SELECT @option_group_id_name_badge := max(id) from civicrm_option_group where name = 'name_badge'; +UPDATE civicrm_option_value +SET value = '{literal}{"name":"Avery 5395","paper-size":"a4","metric":"mm","lMargin":15,"tMargin":26,"NX":2,"NY":4,"SpaceX":10,"SpaceY":5,"width":83,"height":57,"font-size":12,"orientation":"portrait","font-name":"helvetica","font-style":"","lPadding":3,"tPadding":3}{/literal}' +WHERE option_group_id = @option_group_id_name_badge AND name = 'Avery 5395';