Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REF Replace hardcoded IDs with pseudoconstants in activity form #14108

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions CRM/Activity/Form/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ public function setDefaultValues() {
}

// CRM-15472 - 50 is around the practical limit of how many items a select2 entityRef can handle
if ($this->_action == 2 && !empty($defaults['target_contact_id'])) {
if ($this->_action == CRM_Core_Action::UPDATE && !empty($defaults['target_contact_id'])) {
$count = count(is_array($defaults['target_contact_id']) ? $defaults['target_contact_id'] : explode(',', $defaults['target_contact_id']));
if ($count > 50) {
$this->freeze(['target_contact_id']);
Expand Down Expand Up @@ -860,14 +860,12 @@ public static function formRule($fields, $files, $self) {
$errors['activity_type_id'] = ts('Activity Type is a required field');
}

if (CRM_Utils_Array::value('activity_type_id', $fields) == 3 &&
CRM_Utils_Array::value('status_id', $fields) == 1
) {
if (CRM_Utils_Array::value('activity_type_id', $fields) == CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Email')
&& CRM_Utils_Array::value('status_id', $fields) == CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Scheduled')) {
$errors['status_id'] = ts('You cannot record scheduled email activity.');
}
elseif (CRM_Utils_Array::value('activity_type_id', $fields) == 4 &&
CRM_Utils_Array::value('status_id', $fields) == 1
) {
elseif (CRM_Utils_Array::value('activity_type_id', $fields) == CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'SMS')
&& CRM_Utils_Array::value('status_id', $fields) == CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Scheduled')) {
$errors['status_id'] = ts('You cannot record scheduled SMS activity.');
}

Expand Down Expand Up @@ -896,7 +894,9 @@ public static function formRule($fields, $files, $self) {
*
*
* @param array $params

* @return array|null
* @throws \CiviCRM_API3_Exception
*/
public function postProcess($params = NULL) {
if ($this->_action & CRM_Core_Action::DELETE) {
Expand Down