*/
public function postProcess($params = NULL) {
$fv = $params ?: $this->controller->exportValues($this->_name);
- $config = CRM_Core_Config::singleton();
$locName = NULL;
//get the address format sequence from the config file
$mailingFormat = Civi::settings()->get('mailing_format');
$returnProperties['last_name'] = 1;
}
- $individualFormat = FALSE;
-
/*
* CRM-8338: replace ids of household members with the id of their household
* so we can merge labels by household.
*/
if (isset($fv['merge_same_household'])) {
$this->mergeContactIdsByHousehold();
- $individualFormat = TRUE;
}
//get the contacts information
//get the total number of contacts to fetch from database.
$numberofContacts = count($this->_contactIds);
- $query = new CRM_Contact_BAO_Query($params, $returnProperties);
- $details = $query->apiQuery($params, $returnProperties, NULL, NULL, 0, $numberofContacts, TRUE, FALSE, TRUE, CRM_Contact_BAO_Query::MODE_CONTACTS, NULL, $primaryLocationOnly);
+ [$details] = CRM_Contact_BAO_Query::apiQuery($params, $returnProperties, NULL, NULL, 0, $numberofContacts, TRUE, FALSE, TRUE, CRM_Contact_BAO_Query::MODE_CONTACTS, NULL, $primaryLocationOnly);
$messageToken = CRM_Utils_Token::getTokens($mailingFormat);
- // $details[0] is an array of [ contactID => contactDetails ]
+ // $details is an array of [ contactID => contactDetails ]
// also get all token values
- CRM_Utils_Hook::tokenValues($details[0],
+ CRM_Utils_Hook::tokenValues($details,
$this->_contactIds,
NULL,
$messageToken,
foreach ($this->_contactIds as $value) {
foreach ($custom as $cfID) {
- if (isset($details[0][$value]["custom_{$cfID}"])) {
- $details[0][$value]["custom_{$cfID}"] = CRM_Core_BAO_CustomField::displayValue($details[0][$value]["custom_{$cfID}"], $cfID);
+ if (isset($details[$value]["custom_{$cfID}"])) {
+ $details[$value]["custom_{$cfID}"] = CRM_Core_BAO_CustomField::displayValue($details[$value]["custom_{$cfID}"], $cfID);
}
}
- $contact = $details['0'][$value] ?? NULL;
+ $contact = $details[$value] ?? NULL;
if (is_a($contact, 'CRM_Core_Error')) {
return NULL;
'im',
'openid',
])) {
- if ($k == 'im') {
+ if ($k === 'im') {
$rows[$value][$k] = $v['1']['name'];
}
else {
*/
class CRM_Contact_Form_Task_PrintMailingLabelTest extends CiviUnitTestCase {
- protected $_contactIds = NULL;
+ protected $_contactIds;
protected function setUp() {
parent::setUp();
];
}
+ /**
+ * Clean up after test.
+ */
+ protected function tearDown() {
+ unset($this->_contactIds);
+ parent::tearDown();
+ }
+
/**
* core/issue-1158: Test the mailing label rows contain the primary addresses when location_type_id = none (as primary) is chosen in form
*/
// create the non-primary address first
foreach (['non-primary', 'primary'] as $flag) {
// @TODO: bug - this doesn't affect as if its the first and only address created for a contact then it always consider it as primary
- $isPrimary = ($flag == 'primary');
+ $isPrimary = ($flag === 'primary');
$streetName = substr(sha1(rand()), 0, 7);
$addresses[$contactID][$flag] = $this->callAPISuccess('Address', 'create', [
'street_name' => $streetName,
'sequential' => 1,
])['values'][0];
- if ($flag == 'non-primary') {
+ if ($flag === 'non-primary') {
$addresses[$contactID][$flag] = $this->callAPISuccess('Address', 'create', [
'is_primary' => $isPrimary,
'id' => $addresses[$contactID][$flag]['id'],