$wc = "contact_a.$fieldName";
}
else {
- $wc = "$tableName.id";
+ // Special handling for on_hold, so that we actually use the 'where'
+ // property in order to limit the query by the on_hold status of the email,
+ // instead of using email.id which would be nonsensical.
+ if ($field['name'] == 'on_hold') {
+ $wc = "{$field['where']}";
+ }
+ else {
+ $wc = "$tableName.id";
+ }
}
}
else {
*
* Generated from xml/schema/CRM/Core/Email.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:08f53d44527d7d174b4aa1bd545b028c)
+ * (GenCodeChecksum:efd9de6842b24f9800e2a65fd2199cf4)
*/
/**
public $is_billing;
/**
- * Is this address on bounce hold?
+ * Implicit FK to civicrm_option_value where option_group = email_on_hold.
*
- * @var boolean
+ * @var int unsigned
*/
public $on_hold;
],
'on_hold' => [
'name' => 'on_hold',
- 'type' => CRM_Utils_Type::T_BOOLEAN,
+ 'type' => CRM_Utils_Type::T_INT,
'title' => ts('On Hold'),
- 'description' => 'Is this address on bounce hold?',
+ 'description' => 'Implicit FK to civicrm_option_value where option_group = email_on_hold.',
'required' => TRUE,
'export' => TRUE,
'where' => 'civicrm_email.on_hold',
'bao' => 'CRM_Core_BAO_Email',
'localizable' => 0,
'html' => [
- 'type' => 'CheckBox',
+ 'type' => 'Select',
],
+ 'pseudoconstant' => [
+ 'callback' => 'CRM_Core_PseudoConstant::emailOnHoldOptions',
+ ]
],
'is_bulkmail' => [
'name' => 'is_bulkmail',
return Civi::$statics[__CLASS__]['taxRates'];
}
+ /**
+ * Get participant status class options.
+ *
+ * @return array
+ */
+ public static function emailOnHoldOptions() {
+ return array(
+ '0' => ts('No'),
+ '1' => ts('On Hold Bounce'),
+ '2' => ts('On Hold Opt Out'),
+ );
+ }
+
}
'Database check for created email address.'
);
- // Now call add() to update on_hold=true and check record state
+ // Now call add() to update on_hold=1 ("On Hold Bounce") and check record state
$params = array();
$params = array(
'id' => $emailId,
'Check if on_hold=1 in updated email record.'
);
- // Now call add() with on_hold=false and verify that reset_date is set.
+ // Now call add() to update on_hold=2 ("On Hold Opt-out") and check record state
+ $params = array();
+ $params = array(
+ 'id' => $emailId,
+ 'contact_id' => $contactId,
+ 'on_hold' => 2,
+ );
+
+ CRM_Core_BAO_Email::add($params);
+
+ // Use assertDBNotNull to get back value of hold_date and check that it's in the current year.
+ // NOTE: The assertEquals will fail IF this test is run just as the year is changing (low likelihood).
+ $holdDate = $this->assertDBNotNull('CRM_Core_DAO_Email', $emailId, 'hold_date', 'id',
+ 'Retrieve hold_date from the updated email record.'
+ );
+
+ $this->assertEquals(substr($holdDate, 0, 4), substr(date('YmdHis'), 0, 4),
+ 'Compare hold_date (' . $holdDate . ') in DB to current year.'
+ );
+
+ $this->assertDBCompareValue('CRM_Core_DAO_Email', $emailId, 'on_hold', 'id', 2,
+ 'Check if on_hold=2 in updated email record.'
+ );
+
+ // Now call add() with on_hold=null (not on hold) and verify that reset_date is set.
$params = array();
$params = array(
'id' => $emailId,
));
$this->callAPISuccess('Email', 'create', array(
'id' => $emailId,
- 'on_hold' => TRUE,
+ 'on_hold' => 1,
));
$this->callAPISuccess('GroupContact', 'create', array(
</index>
<field>
<name>on_hold</name>
+ <title>On Hold</title>
<export>true</export>
- <type>boolean</type>
+ <type>int unsigned</type>
<default>0</default>
<required>true</required>
- <comment>Is this address on bounce hold?</comment>
+ <comment>Implicit FK to civicrm_option_value where option_group = email_on_hold.</comment>
+ <pseudoconstant>
+ <callback>CRM_Core_PseudoConstant::emailOnHoldOptions</callback>
+ </pseudoconstant>
<add>1.1</add>
<html>
- <type>CheckBox</type>
+ <type>Select</type>
</html>
</field>
<field>