Commit c1d3e301 authored by eileen's avatar eileen

Support a multiple select for activity types to include & exclude

parent 3c6f1a0c
......@@ -40,8 +40,8 @@ class CRM_Activity_Form_ActivityFilter extends CRM_Core_Form {
$activityOptions = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
asort($activityOptions);
$this->add('select', 'activity_type_filter_id', ts('Include'), array('' => ts('- all activity type(s) -')) + $activityOptions);
$this->add('select', 'activity_type_exclude_filter_id', ts('Exclude'), array('' => ts('- select activity type -')) + $activityOptions);
$this->add('select', 'activity_type_filter_id', ts('Include'), $activityOptions, FALSE, ['class' => 'crm-select2', 'multiple' => TRUE, 'placeholder' => ts('- all activity type(s) -')]);
$this->add('select', 'activity_type_exclude_filter_id', ts('Exclude'), $activityOptions, FALSE, ['class' => 'crm-select2', 'multiple' => TRUE, 'placeholder' => ts('- no types excluded -')]);
$this->addDatePickerRange('activity_date_time', ts('Date'));
$this->addSelect('status_id',
array('entity' => 'activity', 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -'))
......
......@@ -437,7 +437,7 @@ class CRM_Activity_Page_AJAX {
$formSearchField = 'activity_type_exclude_filter_id';
}
if (!empty($params[$searchField])) {
$activityFilter[$formSearchField] = CRM_Utils_Type::escape($params[$searchField], $dataType);
$activityFilter[$formSearchField] = $params[$searchField];
if (in_array($searchField, array('activity_date_time_low', 'activity_date_time_high'))) {
$activityFilter['activity_date_time_relative'] = 0;
}
......@@ -445,9 +445,6 @@ class CRM_Activity_Page_AJAX {
$activityFilter['status_id'] = explode(',', $activityFilter[$searchField]);
}
}
elseif (in_array($searchField, array('activity_type_id', 'activity_type_exclude_id'))) {
$activityFilter[$formSearchField] = '';
}
}
Civi::contactSettings()->set('activity_tab_filter', $activityFilter);
......
......@@ -270,7 +270,14 @@ class CRM_Core_Page_AJAX {
foreach ($optionalParams as $param => $type) {
if (CRM_Utils_Array::value($param, $_GET)) {
$params[$param] = CRM_Utils_Type::validate(CRM_Utils_Array::value($param, $_GET), $type);
if (!is_array($_GET[$param])) {
$params[$param] = CRM_Utils_Type::validate(CRM_Utils_Array::value($param, $_GET), $type);
}
else {
foreach ($_GET[$param] as $index => $value) {
$params[$param][$index] = CRM_Utils_Type::validate($value, $type);
}
}
}
}
......
......@@ -403,7 +403,6 @@ class CRM_Activity_BAO_ActivityTest extends CiviUnitTestCase {
);
$expectedFilters = array(
'activity_type_filter_id' => 1,
'activity_type_exclude_filter_id' => '',
);
list($activities, $activityFilter) = CRM_Activity_Page_AJAX::getContactActivity();
......@@ -414,11 +413,10 @@ class CRM_Activity_BAO_ActivityTest extends CiviUnitTestCase {
$this->assertContains('Meeting', $value['activity_type']);
}
unset($_GET['activity_type_id']);
$expectedFilters['activity_type_filter_id'] = '';
$_GET['activity_type_exclude_id'] = $expectedFilters['activity_type_exclude_filter_id'] = 1;
list($activities, $activityFilter) = CRM_Activity_Page_AJAX::getContactActivity();
$this->checkArrayEquals($expectedFilters, $activityFilter);
$this->assertEquals(['activity_type_exclude_filter_id' => 1], $activityFilter);
// None of the activities should be of type Meeting.
foreach ($activities['data'] as $value) {
$this->assertNotContains('Meeting', $value['activity_type']);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment