3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
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-2019
33 class CRM_Utils_Check_Component_OptionGroups
extends CRM_Utils_Check_Component
{
38 public function checkOptionGroupValues() {
40 $problemValues = array();
41 $optionGroups = civicrm_api3('OptionGroup', 'get', array(
43 'data_type' => array('IS NOT NULL' => 1),
44 'options' => array('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) {
51 $validate = CRM_Utils_Type
::validate($value['value'], $optionGroup['data_type'], FALSE);
52 if (is_null($validate)) {
53 $problemValues[] = array(
54 'group_name' => $optionGroup['title'],
55 'value_name' => $value['label'],
62 if (!empty($problemValues)) {
64 foreach ($problemValues as $problemValue) {
65 $strings .= ts('<tr><td> "%1" </td><td> "%2" </td></tr>', array(
66 1 => $problemValue['group_name'],
67 2 => $problemValue['value_name'],
71 $messages[] = new CRM_Utils_Check_Message(
73 ts('The Following Option Values contain value fields that do not match the Data Type of the Option Group</p>
74 <p><table><tbody><th>Option Group</th><th>Option Value</th></tbody><tbody>') .
75 $strings . ts('</tbody></table></p>'),
76 ts('Option Values with problematic Values'),
77 \Psr\Log\LogLevel
::NOTICE
,