}
// FIX ME: we should potentially move this to component Query and write a wrapper function that
// handles pseudoconstant fixes for all component
- elseif (in_array($value['pseudoField'], array('participant_status', 'participant_role'))) {
- $pseudoOptions = $viewValues = array();
- $pseudoOptions = CRM_Core_PseudoConstant::get('CRM_Event_DAO_Participant', $value['idCol']);
- foreach (explode(CRM_Core_DAO::VALUE_SEPARATOR, $val) as $k => $v) {
- $viewValues[] = $pseudoOptions[$v];
+ elseif (in_array($value['pseudoField'], array('participant_role_id', 'participant_role'))) {
+ $viewValues = explode(CRM_Core_DAO::VALUE_SEPARATOR, $val);
+
+ if ($value['pseudoField'] == 'participant_role') {
+ $pseudoOptions = CRM_Core_PseudoConstant::get('CRM_Event_DAO_Participant', 'role_id');
+ foreach ($viewValues as $k => $v) {
+ $viewValues[$k] = $pseudoOptions[$v];
+ }
}
$dao->$key = implode(', ', $viewValues);
}
$query->_element['participant_role_id'] = 1;
$query->_tables['civicrm_participant'] = 1;
$query->_whereTables['civicrm_participant'] = 1;
+ $query->_pseudoConstantsSelect['participant_role_id'] = array(
+ 'pseudoField' => 'participant_role_id',
+ 'idCol' => 'participant_role_id',
+ );
}
//add participant_role
if (!empty($query->_returnProperties['participant_role'])) {
- $query->_select['participant_status'] = "participant_role.label as participant_role";
+ $query->_select['participant_status'] = "civicrm_participant.role_id as participant_role";
$query->_element['participant_role'] = 1;
$query->_tables['participant_role'] = 1;
$query->_whereTables['civicrm_participant'] = 1;
+ $query->_pseudoConstantsSelect['participant_role'] = array(
+ 'pseudoField' => 'participant_role',
+ 'idCol' => 'participant_role',
+ );
}
//add register date
$op = key($value);
$value = $value[$op];
}
- $regexOp = (strstr($op, '!') || strstr($op, 'NOT')) ? 'NOT REGEXP' : 'REGEXP';
- $query->_where[$grouping][] = " civicrm_participant.$name $regexOp '[[:<:]]*" . implode('[[:>:]]*|[[:<:]]*', (array) $value) . "[[:>:]]*' ";
+ if (!strstr($op, 'NULL') || !strstr($op, 'EMPTY')) {
+ $regexOp = (strstr($op, '!') || strstr($op, 'NOT')) ? 'NOT REGEXP' : 'REGEXP';
+ $query->_where[$grouping][] = " civicrm_participant.$name $regexOp '^" . implode('[[:cntrl:]]', (array) $value) . "$' ";
+ }
}
}
$dataType = !empty($fields[$qillName]['type']) ? CRM_Utils_Type::typeToString($fields[$qillName]['type']) : 'String';
$tableName = empty($tableName) ? 'civicrm_participant' : $tableName;
- if ($name != 'role_id') {
+ if ($name != 'role_id' || empty($regexOp)) {
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("$tableName.$name", $op, $value, $dataType);
}
case 'participant_role':
$from = " $side JOIN civicrm_option_group option_group_participant_role ON (option_group_participant_role.name = 'participant_role')";
- $from .= " $side JOIN civicrm_option_value participant_role ON (civicrm_participant.role_id = participant_role.value
+ $from .= " $side JOIN civicrm_option_value participant_role ON ((civicrm_participant.role_id = participant_role.value OR SUBSTRING_INDEX(role_id,'\ 1', 1) = participant_role.value)
AND option_group_participant_role.id = participant_role.option_group_id ) ";
break;
'event_type' => 1,
'participant_id' => 1,
'participant_status' => 1,
+ 'participant_status_id' => 1,
+ 'participant_role' => 1,
'participant_role_id' => 1,
'participant_note' => 1,
'participant_register_date' => 1,
}
}
$returnProperties[self::defaultReturnProperty($exportMode)] = 1;
- if ($exportMode == CRM_Export_Form_Select::EVENT_EXPORT && !empty($returnProperties['participant_role'])) {
- unset($returnProperties['participant_role']);
- $returnProperties['participant_role_id'] = 1;
- }
}
else {
$primary = TRUE;
elseif ($field == 'provider_id' || $field == 'im_provider') {
$fieldValue = CRM_Utils_Array::value($fieldValue, $imProviders);
}
- elseif ($field == 'participant_role_id') {
- $participantRoles = CRM_Event_PseudoConstant::participantRole();
- $sep = CRM_Core_DAO::VALUE_SEPARATOR;
- $viewRoles = array();
- foreach (explode($sep, $iterationDAO->$field) as $k => $v) {
- $viewRoles[] = $participantRoles[$v];
- }
- $fieldValue = implode(',', $viewRoles);
- }
elseif ($field == 'master_id') {
$masterAddressId = NULL;
if (isset($iterationDAO->master_id)) {