Merge pull request #17531 from colemanw/customIcon
authorEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 11 Jun 2020 21:26:25 +0000 (09:26 +1200)
committerGitHub <noreply@github.com>
Thu, 11 Jun 2020 21:26:25 +0000 (09:26 +1200)
Add icons to multi-valued custom groups and display on contact tab

1  2 
CRM/Custom/Form/Group.php
CRM/Upgrade/Incremental/php/FiveTwentyEight.php

Simple merge
index 1cd3d2a3a430b0d262d90011fd683b2c50595c4e,46667f025a89fdaa590e04949274cef50d16ed0b..fdba99c68ed8842a6d68432966831b5160dcf228
@@@ -52,47 -52,15 +52,41 @@@ class CRM_Upgrade_Incremental_php_FiveT
     * (change the x in the function name):
     */
  
-   //  /**
-   //   * Upgrade function.
-   //   *
-   //   * @param string $rev
-   //   */
-   //  public function upgrade_5_0_x($rev) {
-   //    $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);
-   //    $this->addTask('Do the foo change', 'taskFoo', ...);
-   //    // Additional tasks here...
-   //    // Note: do not use ts() in the addTask description because it adds unnecessary strings to transifex.
-   //    // The above is an exception because 'Upgrade DB to %1: SQL' is generic & reusable.
-   //  }
-   // public static function taskFoo(CRM_Queue_TaskContext $ctx, ...) {
-   //   return TRUE;
-   // }
+   /**
+    * Upgrade function.
+    *
+    * @param string $rev
+    */
+   public function upgrade_5_28_alpha1($rev) {
+     $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);
+     $this->addTask('Add icon column to civicrm_custom_group', 'addColumn',
+       'civicrm_custom_group', 'icon', "varchar(255) COMMENT 'crm-i icon class' DEFAULT NULL");
+   }
  
 +  /**
 +   * Upgrade function.
 +   *
 +   * @param string $rev
 +   */
 +  public function upgrade_5_28_alpha1($rev) {
 +    $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);
 +    $this->addTask('Populate missing Contact Type name fields', 'populateMissingContactTypeName');
 +  }
 +
 +  public static function populateMissingContactTypeName() {
 +    $contactTypes = \Civi\Api4\ContactType::get()
 +      ->setCheckPermissions(FALSE)
 +      ->execute();
 +    foreach ($contactTypes as $contactType) {
 +      if (empty($contactType['name'])) {
 +        \Civi\Api4\ContactType::update()
 +          ->addWhere('id', '=', $contactType['id'])
 +          ->addValue('name', ucfirst(CRM_Utils_String::munge($contactType['label'])))
 +          ->setCheckPermissions(FALSE)
 +          ->execute();
 +      }
 +    }
 +    return TRUE;
 +  }
 +
  }