3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2020 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2020
33 class CRM_Utils_Check_Component_OptionGroups
extends CRM_Utils_Check_Component
{
38 public function checkOptionGroupValues() {
41 $optionGroups = civicrm_api3('OptionGroup', 'get', [
43 'data_type' => ['IS NOT NULL' => 1],
44 'options' => ['limit' => 0],
46 if ($optionGroups['count'] > 0) {
47 foreach ($optionGroups['values'] as $optionGroup) {
48 $values = CRM_Core_BAO_OptionValue
::getOptionValuesArray($optionGroup['id']);
49 if (count($values) > 0) {
50 foreach ($values as $value) {
52 CRM_Utils_Type
::validate($value['value'], $optionGroup['data_type'], FALSE, '', TRUE);
54 catch (Exception
$e) {
56 'group_name' => $optionGroup['title'],
57 'value_name' => $value['label'],
64 if (!empty($problemValues)) {
66 foreach ($problemValues as $problemValue) {
67 $strings .= ts('<tr><td> "%1" </td><td> "%2" </td></tr>', [
68 1 => $problemValue['group_name'],
69 2 => $problemValue['value_name'],
73 $messages[] = new CRM_Utils_Check_Message(
75 ts('The Following Option Values contain value fields that do not match the Data Type of the Option Group</p>
76 <p><table><tbody><th>Option Group</th><th>Option Value</th></tbody><tbody>') .
77 $strings . ts('</tbody></table></p>'),
78 ts('Option Values with problematic Values'),
79 \Psr\Log\LogLevel
::NOTICE
,