3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 class CRM_Utils_Check_Component_OptionGroups
extends CRM_Utils_Check_Component
{
22 public function checkOptionGroupValues() {
25 $optionGroups = civicrm_api3('OptionGroup', 'get', [
27 'data_type' => ['IS NOT NULL' => 1],
28 'options' => ['limit' => 0],
30 if ($optionGroups['count'] > 0) {
31 foreach ($optionGroups['values'] as $optionGroup) {
32 $values = CRM_Core_BAO_OptionValue
::getOptionValuesArray($optionGroup['id']);
33 if (count($values) > 0) {
34 foreach ($values as $value) {
36 CRM_Utils_Type
::validate($value['value'], $optionGroup['data_type']);
38 catch (CRM_Core_Exception
$e) {
40 'group_name' => $optionGroup['title'],
41 'value_name' => $value['label'],
48 if (!empty($problemValues)) {
50 foreach ($problemValues as $problemValue) {
51 $strings .= ts('<tr><td> "%1" </td><td> "%2" </td></tr>', [
52 1 => $problemValue['group_name'],
53 2 => $problemValue['value_name'],
57 $messages[] = new CRM_Utils_Check_Message(
59 ts('The Following Option Values contain value fields that do not match the Data Type of the Option Group</p>
60 <p><table><tbody><th>Option Group</th><th>Option Value</th></tbody><tbody>') .
61 $strings . ts('</tbody></table></p>'),
62 ts('Option Values with problematic Values'),
63 \Psr\Log\LogLevel
::NOTICE
,