Skip to content

Commit

Permalink
Improve code as per comment from Jitendra and exclude activity_type f…
Browse files Browse the repository at this point in the history
…rom the check when saving the option value form and re run regen.sh
  • Loading branch information
seamuslee001 committed Sep 10, 2016
1 parent a37e4e6 commit 89c05af
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 38 deletions.
9 changes: 3 additions & 6 deletions CRM/Admin/Form/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public static function formRule($fields, $files, $self) {
}

$dataType = self::getOptionGroupDataType($self->_gName);
if ($dataType) {
if ($dataType && $self->_gName !== 'activity_type') {
$validate = CRM_Utils_Type::validate($fields['value'], $dataType, FALSE);
if (!$validate) {
CRM_Core_Session::setStatus(
Expand All @@ -396,12 +396,9 @@ public static function formRule($fields, $files, $self) {
* @return string|null
*/
public static function getOptionGroupDataType($optionGroupName) {
$optionGroup = civicrm_api3('OptionGroup', 'get', array(
'sequential' => 1,
'name' => $optionGroupName,
));
$optionGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $optionGroupName, 'id', 'name');

$dataType = CRM_Core_BAO_OptionGroup::getDataType($optionGroup['id']);
$dataType = CRM_Core_BAO_OptionGroup::getDataType($optionGroupId);
return $dataType;
}

Expand Down
2 changes: 1 addition & 1 deletion CRM/Core/DAO/AllCoreTables.data.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
// (GenCodeChecksum:34170ee0f91484a207dc1ebaa2f71a09)
// (GenCodeChecksum:f94e4fdda574067e0b75677bf0e46f02)
return array(
'CRM_Core_DAO_AddressFormat' => array(
'name' => 'AddressFormat',
Expand Down
10 changes: 4 additions & 6 deletions CRM/Utils/Check/Component/OptionGroups.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,13 @@ public function checkOptionGroupValues() {
$optionGroups = civicrm_api3('OptionGroup', 'get', array(
'sequential' => 1,
'data_type' => array('IS NOT NULL' => 1),
'options' => array('limit' => 0),
));
if ($optionGroups['count'] > 0) {
foreach ($optionGroups['values'] as $optionGroup) {
$values = civicrm_api3('OptionValue', 'get', array(
'sequential' => 1,
'option_group_id' => $optionGroup['name'],
));
if ($values['count'] > 0) {
foreach ($values['values'] as $value) {
$values = CRM_Core_BAO_OptionValue::getOptionValuesArray($optionGroup['id']);
if (count($values) > 0) {
foreach ($values as $value) {
$validate = CRM_Utils_Type::validate($value['value'], $optionGroup['data_type'], FALSE);
if (!$validate) {
$problemValues[] = array(
Expand Down
50 changes: 25 additions & 25 deletions sql/civicrm_generated.mysql

Large diffs are not rendered by default.

0 comments on commit 89c05af

Please sign in to comment.