/** * If survey, campaign are involved, add the specific fields. * * @param CRM_Contact_BAO_Contact $query */ public static function select(&$query) { self::$_applySurveyClause = FALSE; if (is_array($query->_params)) { foreach ($query->_params as $values) { if (!is_array($values) || count($values) != 5) { continue; } list($name, $op, $value, $grouping, $wildcard) = $values; if ($name == 'campaign_survey_id') { self::$_applySurveyClause = TRUE; break; } } } // CRM-13810 Translate campaign_id to label for search builder // CRM-14238 Only translate when we are in contact mode // Other modes need the untranslated data for export and other functions if (is_array($query->_select) && $query->_mode == CRM_Contact_BAO_Query::MODE_CONTACTS) { foreach ($query->_select as $field => $queryString) { if (substr($field, -11) == 'campaign_id') { $query->_pseudoConstantsSelect[$field] = array('pseudoField' => 'campaign_id', 'idCol' => $field, 'bao' => 'CRM_Activity_BAO_Activity'); } } } //get survey clause in force, //only when we have survey id. if (!self::$_applySurveyClause) { return; } //all below tables are require to fetch result. //1. get survey activity target table in. $query->_select['survey_activity_target_contact_id'] = 'civicrm_activity_target.contact_id as survey_activity_target_contact_id'; $query->_select['survey_activity_target_id'] = 'civicrm_activity_target.id as survey_activity_target_id'; $query->_element['survey_activity_target_id'] = 1; $query->_element['survey_activity_target_contact_id'] = 1; $query->_tables[self::CIVICRM_ACTIVITY_TARGET] = 1; $query->_whereTables[self::CIVICRM_ACTIVITY_TARGET] = 1; //2. get survey activity table in. $query->_select['survey_activity_id'] = 'civicrm_activity.id as survey_activity_id'; $query->_element['survey_activity_id'] = 1; $query->_tables[self::CIVICRM_ACTIVITY] = 1; $query->_whereTables[self::CIVICRM_ACTIVITY] = 1; //3. get the assignee table in. $query->_select['survey_interviewer_id'] = 'civicrm_activity_assignment.id as survey_interviewer_id'; $query->_element['survey_interviewer_id'] = 1; $query->_tables[self::CIVICRM_ACTIVITY_ASSIGNMENT] = 1; $query->_whereTables[self::CIVICRM_ACTIVITY_ASSIGNMENT] = 1; //4. get survey table. $query->_select['campaign_survey_id'] = 'civicrm_survey.id as campaign_survey_id'; $query->_element['campaign_survey_id'] = 1; $query->_tables['civicrm_survey'] = 1; $query->_whereTables['civicrm_survey'] = 1; //5. get campaign table. $query->_select['campaign_id'] = 'civicrm_campaign.id as campaign_id'; $query->_element['campaign_id'] = 1; $query->_tables['civicrm_campaign'] = 1; $query->_whereTables['civicrm_campaign'] = 1; }
/** * if survey, campaign are involved, add the specific fields. * * @return void * @access public */ static function select(&$query) { self::$_applySurveyClause = FALSE; if (is_array($query->_params)) { foreach ($query->_params as $values) { list($name, $op, $value, $grouping, $wildcard) = $values; if ($name == 'campaign_survey_id') { self::$_applySurveyClause = TRUE; break; } } } //get survey clause in force, //only when we have survey id. if (!self::$_applySurveyClause) { return; } //all below tables are require to fetch result. //1. get survey activity target table in. $query->_select['survey_activity_target_contact_id'] = 'civicrm_activity_target.target_contact_id as survey_activity_target_contact_id'; $query->_select['survey_activity_target_id'] = 'civicrm_activity_target.id as survey_activity_target_id'; $query->_element['survey_activity_target_id'] = 1; $query->_element['survey_activity_target_contact_id'] = 1; $query->_tables[self::civicrm_activity_target] = 1; $query->_whereTables[self::civicrm_activity_target] = 1; //2. get survey activity table in. $query->_select['survey_activity_id'] = 'civicrm_activity.id as survey_activity_id'; $query->_element['survey_activity_id'] = 1; $query->_tables[self::civicrm_activity] = 1; $query->_whereTables[self::civicrm_activity] = 1; //3. get the assignee table in. $query->_select['survey_interviewer_id'] = 'civicrm_activity_assignment.id as survey_interviewer_id'; $query->_element['survey_interviewer_id'] = 1; $query->_tables[self::civicrm_activity_assignment] = 1; $query->_whereTables[self::civicrm_activity_assignment] = 1; //4. get survey table. $query->_select['campaign_survey_id'] = 'civicrm_survey.id as campaign_survey_id'; $query->_element['campaign_survey_id'] = 1; $query->_tables['civicrm_survey'] = 1; $query->_whereTables['civicrm_survey'] = 1; //5. get campaign table. $query->_select['campaign_id'] = 'civicrm_campaign.id as campaign_id'; $query->_element['campaign_id'] = 1; $query->_tables['civicrm_campaign'] = 1; $query->_whereTables['civicrm_campaign'] = 1; }