CRM-13187 - CRM_Upgrade_Incremental_php_FourFour - Match 675605a
authorTim Otten <totten@civicrm.org>
Mon, 2 Sep 2013 19:57:40 +0000 (12:57 -0700)
committerTim Otten <totten@civicrm.org>
Mon, 2 Sep 2013 19:57:40 +0000 (12:57 -0700)
----------------------------------------
* CRM-13187: hrui: Change breadcrumb from "CiviCRM" to "CiviHR"
  http://issues.civicrm.org/jira/browse/CRM-13187

CRM/Upgrade/Incremental/php/FourFour.php

index 1d412112d9ad3a3b436594ee90ddb105e9fbc5e8..df30f2d264addcd4058d739dc9e60453ad755891 100644 (file)
@@ -213,16 +213,18 @@ WHERE       source_contact_id IS NOT NULL";
    */
   static function wordReplacements(CRM_Queue_TaskContext $ctx) {
     $query = "
-CREATE TABLE IF NOT EXISTS civicrm_word_replacement (
-  id int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Word replacement ID',
-  find_word varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Word which need to be replaced',
-  replace_word varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Word which will replace the word in find',
-  is_active tinyint(4) DEFAULT NULL COMMENT 'Is this entry active?',
-  domain_id int(10) unsigned DEFAULT NULL COMMENT 'FK to Domain ID. This is for Domain specific word replacement',
-  PRIMARY KEY (id),
-  UNIQUE KEY UI_find (find_word),
-  KEY FK_civicrm_word_replacement_domain_id (domain_id)
-) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=4";
+CREATE TABLE IF NOT EXISTS `civicrm_word_replacement` (
+     `id` int unsigned NOT NULL AUTO_INCREMENT  COMMENT 'Word replacement ID',
+     `find_word` varchar(255)    COMMENT 'Word which need to be replaced',
+     `replace_word` varchar(255)    COMMENT 'Word which will replace the word in find',
+     `is_active` tinyint    COMMENT 'Is this entry active?',
+     `match_type` enum('wildcardMatch', 'exactMatch')   DEFAULT 'wildcardMatch',
+     `domain_id` int unsigned    COMMENT 'FK to Domain ID. This is for Domain specific word replacement',
+    PRIMARY KEY ( `id` ),
+    UNIQUE INDEX `UI_find`(find_word),
+    CONSTRAINT FK_civicrm_word_replacement_domain_id FOREIGN KEY (`domain_id`) REFERENCES `civicrm_domain`(`id`)
+)  ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci  ;
+    ";
     $dao = CRM_Core_DAO::executeQuery($query);
 
     self::rebuildWordReplacementTable();
@@ -286,22 +288,26 @@ CREATE TABLE IF NOT EXISTS civicrm_word_replacement (
     if (!empty($result["values"])) {
       foreach ($result["values"] as $value) {
         $params = array();
-        $params["is_active"] = TRUE;
         $params["domain_id"] = $value["id"];
         $params["options"] = array('wp-rebuild' => $rebuildEach);
         // unserialize word match string
         $localeCustomArray = unserialize($value["locale_custom_strings"]);
         if (!empty($localeCustomArray)) {
           $wordMatchArray = array();
+          // Traverse Language array
           foreach ($localeCustomArray as $localCustomData) {
-            $wordMatchArray = $localCustomData["enabled"]["wildcardMatch"];
-          }
-
-          if (!empty($wordMatchArray)) {
-            foreach ($wordMatchArray as $word => $replace) {
-              $params["find_word"] = $word;
-              $params["replace_word"] = $replace;
-              $wordReplacementCreateParams[] = $params;
+            // Traverse status array "enabled" "disabled"
+            foreach ($localCustomData as $status => $matchTypes) {
+              $params["is_active"] = ($status == "enabled")?TRUE:FALSE;
+              // Traverse Match Type array "wildcardMatch" "exactMatch"
+              foreach ($matchTypes as $matchType => $words) {
+                $params["match_type"] = $matchType;
+                foreach ($words as $word => $replace) {
+                  $params["find_word"] = $word;
+                  $params["replace_word"] = $replace;
+                  $wordReplacementCreateParams[] = $params;
+                }
+              }
             }
           }
         }