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.
*
}
$this->assign('surveyActivity', $this->_isSurveyActivity);
- // this option should be available only during add mode
- if ($this->_action != CRM_Core_Action::UPDATE) {
+ // Add the "Activity Separation" field
+ $actionIsAdd = $this->_action != CRM_Core_Action::UPDATE;
+ $separationIsPossible = $this->supportsActivitySeparation;
+ if ($actionIsAdd && $separationIsPossible) {
$this->addRadio(
'separation',
ts('Activity Separation'),
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;
}