From e3c75a92965ffdf81b4f051c8ba649ccf42ff03d Mon Sep 17 00:00:00 2001 From: kurund Date: Sat, 8 Feb 2014 12:26:38 -0800 Subject: [PATCH] CRM-14181 fixes, deleted tsEnum() and code fixes ---------------------------------------- * CRM-14181: migrate enums to varchar in schema for all tables http://issues.civicrm.org/jira/browse/CRM-14181 --- CRM/Admin/Form/ParticipantStatus.php | 12 +++++++----- CRM/Contact/BAO/Group.php | 7 ++++--- xml/templates/dao.tpl | 26 -------------------------- 3 files changed, 11 insertions(+), 34 deletions(-) diff --git a/CRM/Admin/Form/ParticipantStatus.php b/CRM/Admin/Form/ParticipantStatus.php index ae10122449..4ad06f7c58 100644 --- a/CRM/Admin/Form/ParticipantStatus.php +++ b/CRM/Admin/Form/ParticipantStatus.php @@ -50,11 +50,13 @@ class CRM_Admin_Form_ParticipantStatus extends CRM_Admin_Form { $this->add('text', 'label', ts('Label'), $attributes['label'], TRUE); - $classes = array(); - foreach (array( - 'Positive', 'Pending', 'Waiting', 'Negative') as $class) { - $classes[$class] = CRM_Event_DAO_ParticipantStatusType::tsEnum('class', $class); - } + $classes = array( + 'Positive' => ts('Positive'), + 'Pending' => ts('Pending'), + 'Waiting' => ts('Waiting'), + 'Negative' => ts('Negative'), + ); + $this->add('select', 'class', ts('Class'), $classes, TRUE); $this->add('checkbox', 'is_active', ts('Active?')); diff --git a/CRM/Contact/BAO/Group.php b/CRM/Contact/BAO/Group.php index adec07dfc2..97cdd214a2 100644 --- a/CRM/Contact/BAO/Group.php +++ b/CRM/Contact/BAO/Group.php @@ -811,6 +811,8 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { $allTypes = CRM_Core_OptionGroup::values('group_type'); $values = array(); + $visibility = CRM_Core_SelectValues::ufVisibility(); + while ($object->fetch()) { $permission = CRM_Contact_BAO_Group::checkPermission($object->id, $object->title); //@todo CRM-12209 introduced an ACL check in the whereClause function @@ -861,9 +863,8 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { $action = $action & CRM_Core_Action::mask($groupPermissions); - $values[$object->id]['visibility'] = CRM_Contact_DAO_Group::tsEnum('visibility', - $values[$object->id]['visibility'] - ); + $values[$object->id]['visibility'] = $visibility[$values[$object->id]['visibility']]; + if (isset($values[$object->id]['group_type'])) { $groupTypes = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($values[$object->id]['group_type'], 1, -1) diff --git a/xml/templates/dao.tpl b/xml/templates/dao.tpl index 2956d9add2..1f3240c29e 100644 --- a/xml/templates/dao.tpl +++ b/xml/templates/dao.tpl @@ -359,32 +359,6 @@ class {$table.className} extends CRM_Core_DAO {ldelim} {if $table.hasEnum} - /** - * returns a ts()-translated enum value for display purposes - * - * @param string $field the enum field in question - * @param string $value the enum value up for translation - * - * @return string the display value of the enum - */ - static function tsEnum($field, $value) {ldelim} - static $translations = null; - if (!$translations) {ldelim} - $translations = array( - {foreach from=$table.fields item=field} - {if $field.crmType == 'CRM_Utils_Type::T_ENUM'} - '{$field.name}' => array( - {foreach from=$field.values item=value} - '{$value}' => ts('{$value}'), - {/foreach} - ), - {/if} - {/foreach} - ); - {rdelim} - return $translations[$field][$value]; - {rdelim} - /** * adds $value['foo_display'] for each $value['foo'] enum from {$table.name} * -- 2.25.1