Skip to content

Commit

Permalink
CRM-20799: make activity filter user preference an optional setting
Browse files Browse the repository at this point in the history
  • Loading branch information
monishdeb committed Jul 1, 2017
1 parent 49d4d22 commit 68f8a93
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 15 deletions.
3 changes: 1 addition & 2 deletions CRM/Activity/Form/ActivityFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ public function buildQuickForm() {
public function setDefaultValues() {
// CRM-11761 retrieve user's activity filter preferences
$defaults = array();
$userID = CRM_Core_Session::getLoggedInContactID();
if ($userID) {
if (Civi::settings()->get('preserve_activity_tab_filter') && ($userID = CRM_Core_Session::getLoggedInContactID())) {
$defaults = Civi::service('settings_manager')
->getBagByContact(NULL, $userID)
->get('activity_tab_filter');
Expand Down
23 changes: 16 additions & 7 deletions CRM/Activity/Page/AJAX.php
Original file line number Diff line number Diff line change
Expand Up @@ -433,13 +433,22 @@ public static function getContactActivity() {
}

// store the activity filter preference CRM-11761
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
if ($userID) {
$activityFilter = array(
'activity_type_filter_id' => empty($params['activity_type_id']) ? '' : CRM_Utils_Type::escape($params['activity_type_id'], 'Integer'),
'activity_type_exclude_filter_id' => empty($params['activity_type_exclude_id']) ? '' : CRM_Utils_Type::escape($params['activity_type_exclude_id'], 'Integer'),
);
if (Civi::settings()->get('preserve_activity_tab_filter') && ($userID = CRM_Core_Session::getLoggedInContactID())) {
unset($optionalParameters['context']);
foreach ($optionalParameters as $searchField => $dataType) {
if (!empty($params[$searchField])) {
$activityFilter[$searchField] = CRM_Utils_Type::escape($params[$searchField], $dataType);
if (in_array($searchField, array('activity_date_low', 'activity_date_high'))) {
$activityFilter['activity_date_relative'] = 0;
}
elseif ($searchField == 'activity_status_id') {
$activityFilter['status_id'] = explode(',', $activityFilter[$searchField]);
}
}
elseif (in_array($searchField, array('activity_type_id', 'activity_type_exclude_id'))) {
$activityFilter[$searchField] = '';
}
}

/**
* @var \Civi\Core\SettingsBag $cSettings
Expand Down
17 changes: 11 additions & 6 deletions CRM/Admin/Form/Preferences/Display.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,34 +70,39 @@ public function preProcess() {
'title' => ts('Include ICal Invite to Activity Assignees'),
'weight' => 6,
),
'preserve_activity_tab_filter' => array(
'html_type' => 'checkbox',
'title' => ts('Preserve activity filters as a user preference'),
'weight' => 7,
),
'contact_ajax_check_similar' => array(
'html_type' => 'checkbox',
'title' => ts('Check for Similar Contacts'),
'weight' => 7,
'weight' => 8,
),
'user_dashboard_options' => array(
'html_type' => 'checkboxes',
'title' => ts('Contact Dashboard'),
'weight' => 8,
'weight' => 9,
),
'display_name_format' => array(
'html_type' => 'textarea',
'title' => ts('Individual Display Name Format'),
'weight' => 9,
'weight' => 10,
),
'sort_name_format' => array(
'html_type' => 'textarea',
'title' => ts('Individual Sort Name Format'),
'weight' => 10,
'weight' => 11,
),
'editor_id' => array(
'html_type' => NULL,
'weight' => 11,
'weight' => 12,
),
'ajaxPopupsEnabled' => array(
'html_type' => 'checkbox',
'title' => ts('Enable Popup Forms'),
'weight' => 12,
'weight' => 13,
),
),
);
Expand Down
14 changes: 14 additions & 0 deletions settings/Core.setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -953,4 +953,18 @@
'description' => 'If enabled, then CMS email id will be syncronised with CiviCRM contacts\'s primary email.',
'help_text' => NULL,
),
'preserve_activity_tab_filter' => array(
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'preserve_activity_tab_filter',
'type' => 'String',
'html_type' => 'Text',
'default' => '0',
'add' => '4.7',
'title' => 'Preserve activity filters as a user preference',
'is_domain' => 1,
'is_contact' => 0,
'description' => 'When enabled, any filter settings a user selects on the contact\'s Activity tab will be remembered as they visit other contacts',
'help_text' => NULL,
),
);
10 changes: 10 additions & 0 deletions templates/CRM/Admin/Form/Preferences/Display.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@
</td>
</tr>

<tr class="crm-preferences-display-form-block-preserve_activity_tab_filter">
<td class="label"></td>
<td>{$form.preserve_activity_tab_filter.html} {$form.preserve_activity_tab_filter.label}</td>
</tr>
<tr class="crm-preferences-display-form-block-description">
<td>&nbsp;</td>
<td class="description">{ts}When enabled, any filter settings a user selects on the contact\'s Activity tab will be remembered as they visit other contacts.{/ts}
</td>
</tr>

<tr class="crm-preferences-display-form-block-user_dashboard_options">
<td class="label">{$form.user_dashboard_options.label}</td>
<td>{$form.user_dashboard_options.html}<span id="invoice_help"> {help id="id-invoices_id"}</span></td>
Expand Down

0 comments on commit 68f8a93

Please sign in to comment.