Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions atrium_casetracker/atrium_casetracker.module
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ function atrium_casetracker_get_inactive_states() {
if (!isset($inactive_states)) {
$inactive_states = array();
$search = array('closed', 'defer', 'duplicate', 'postponed', 'fixed', 'resolved');
drupal_alter('atrium_casetracker_inactive_states', $search);
$states = casetracker_case_state_load(NULL, 'status');
foreach ($states as $status_id => $state) {
$state = strtolower($state);
Expand Down
14 changes: 14 additions & 0 deletions atrium_casetracker/atrium_casetracker.views.inc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ function atrium_casetracker_views_handlers() {
'atrium_casetracker_handler_filter_status_closed' => array(
'parent' => 'views_handler_filter_boolean_operator',
),
'atrium_casetracker_handler_sort_status_closed' => array(
'parent' => 'views_handler_sort',
),
),
);
}
Expand All @@ -34,6 +37,17 @@ function atrium_casetracker_views_data_alter(&$data) {
),
);
}
if (isset($data['casetracker_case_states'])) {
$data['casetracker_case_states']['case_status_closed'] = array(
'title' => t('Closed Case Status'),
'real field' => 'csid',
'sort' => array(
'field' => 'csid',
'handler' => 'atrium_casetracker_handler_sort_status_closed',
'help' => t('Sort by Case Active/Inactive status.'),
),
);
}
if (isset($data['casetracker_case']['case_priority_id']['field']['handler'])) {
$data['casetracker_case']['case_priority_id']['field']['handler'] = 'atrium_casetracker_handler_field_priority_name';
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
// $Id$

/**
* Defines a sort handler for the Atrium Casetracker inactive case status.
*/
class atrium_casetracker_handler_sort_status_closed extends views_handler_sort {
/**
* Override of views_handler_sort::query().
*/
function query() {
$pattern = '(' . db_escape_string(implode('|', atrium_casetracker_get_inactive_states())) . ')';
global $db_type;
switch ($db_type) {
case 'mysql':
case 'mysqli':
$formula = "{$this->table}.{$this->real_field} REGEXP '$pattern'";
break;
}
if (!empty($formula)) {
$this->ensure_my_table();
$this->query->add_orderby(NULL, $formula, $this->options['order'], $this->query->base_field . '_' . $this->field);
}
}
}