Users want to get a report of tickets filtered by priority (e.g. just the "high priority tickets"). I wanted a link for than functionality to generate that report. Here's a patch to add that feature via an API.
*** support/support.old Thu Jul 9 15:51:34 2009
--- ../modules/support/support.module Mon Jul 13 05:26:23 2009
*************** function support_page($client = NULL, $s
*** 2032,2038 ****
$state = $state ? "AND t.state = $state" : '';
}
! $sql = "SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, GREATEST(n.changed, l.last_comment_timestamp) AS last_updated, l.comment_count, t.state, t.priority, t.assigned FROM {node} n LEFT JOIN {support_ticket} t ON n.nid = t.nid INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {users} u ON n.uid = u.uid LEFT JOIN {comments} c ON n.nid = c.nid WHERE (c.status = ". COMMENT_PUBLISHED ." OR c.status IS NULL) AND n.status = 1 AND n.type = 'support_ticket' AND client = $client $state $my_open";
if (!user_access('view other users tickets') && !user_access('administer support') && !user_access('edit any ticket') && !user_access('delete any ticket')) {
$sql .= " AND n.uid = $user->uid";
}
--- 2032,2043 ----
$state = $state ? "AND t.state = $state" : '';
}
! $pid = empty($_REQUEST['pid'])?'':(int) $_REQUEST['pid'];
! if (is_int($pid)) {
! $priority_id = " AND t.priority = $pid ";
! }
!
! $sql = "SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, GREATEST(n.changed, l.last_comment_timestamp) AS last_updated, l.comment_count, t.state, t.priority, t.assigned FROM {node} n LEFT JOIN {support_ticket} t ON n.nid = t.nid INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {users} u ON n.uid = u.uid LEFT JOIN {comments} c ON n.nid = c.nid WHERE (c.status = ". COMMENT_PUBLISHED ." OR c.status IS NULL) AND n.status = 1 AND n.type = 'support_ticket' AND client = $client $state $priority_id $my_open";
if (!user_access('view other users tickets') && !user_access('administer support') && !user_access('edit any ticket') && !user_access('delete any ticket')) {
$sql .= " AND n.uid = $user->uid";
}
*************** function support_page($client = NULL, $s
*** 2060,2066 ****
$sql .= ", t.priority $order";
break;
}
! $sql_count = "SELECT COUNT(DISTINCT(n.nid)) FROM {node} n LEFT JOIN {comments} c ON n.nid = c.nid AND (c.status = %d OR c.status IS NULL) LEFT JOIN {support_ticket} t ON n.nid = t.nid WHERE n.status = 1 AND client = $client $state $my_open";
$sql_count = db_rewrite_sql($sql_count);
$result = pager_query($sql, 50, 0, $sql_count);
$rows = array();
--- 2065,2071 ----
$sql .= ", t.priority $order";
break;
}
! $sql_count = "SELECT COUNT(DISTINCT(n.nid)) FROM {node} n LEFT JOIN {comments} c ON n.nid = c.nid AND (c.status = %d OR c.status IS NULL) LEFT JOIN {support_ticket} t ON n.nid = t.nid WHERE n.status = 1 AND client = $client $state $priority_id $my_open";
$sql_count = db_rewrite_sql($sql_count);
$result = pager_query($sql, 50, 0, $sql_count);
$rows = array();
Comments
Comment #1
rar commentedOops - missed issue with drupal_goto called in support_module. This is an updated patch which moves relevent code above drupal_goto section.
Comment #2
jeremy commentedI don't recognize the format of your patch. Please follow these instructions and attach it as a file.
How exactly would this feature be used? I don't see an API here...?
Comment #3
jeremy commentedNo further feedback, closing.