protected $unsavedWarn = TRUE;
+ /*
+ * Is it possible to create separate activities with this form?
+ *
+ * When TRUE, the form will ask whether the user wants to create separate
+ * activities (if the user has specified multiple contacts in the "with"
+ * field).
+ *
+ * When FALSE, the form will create one activity with all contacts together
+ * and won't ask the user anything.
+ *
+ * Note: This is a class property so that child classes can turn off this
+ * behavior (e.g. in CRM_Case_Form_Activity)
+ *
+ * @var boolean
+ */
+ protected $supportsActivitySeparation = TRUE;
+
/**
* Explicitly declare the entity api name.
*
if ((!empty($fields['followup_activity_subject']) || !empty($fields['followup_date'])) && empty($fields['followup_activity_type_id'])) {
$errors['followup_activity_subject'] = ts('Follow-up Activity type is a required field.');
}
+
+ // Check that a value has been set for the "activity separation" field if needed
+ $separationIsPossible = $self->supportsActivitySeparation;
$actionIsAdd = $self->_action == CRM_Core_Action::ADD;
$hasMultipleTargetContacts = !empty($fields['target_contact_id']) && strpos($fields['target_contact_id'], ',') !== FALSE;
$separationFieldIsEmpty = empty($fields['separation']);
- if ($actionIsAdd && $hasMultipleTargetContacts && $separationFieldIsEmpty) {
+ if ($separationIsPossible && $actionIsAdd && $hasMultipleTargetContacts && $separationFieldIsEmpty) {
$errors['separation'] = ts('Activity Separation is a required field.');
}
+
return $errors;
}
}
}
+ // Turn off the prompt which asks the user if they want to create separate
+ // activities when specifying multiple contacts "with" a new activity.
+ // Instead, always create one activity with all contacts together.
+ $this->supportsActivitySeparation = FALSE;
+
$session = CRM_Core_Session::singleton();
$session->pushUserContext($url);
}