An common request by people that use Case Tracker is to generate a list of cases that were created by or assigned to the current user.

At this moment this is only possible using Views OR in views 2.x or the new Sql OR capabilities in views 3.

So, this patch provides a new filter to use in that cases.

Comments

dawehner’s picture

I'm not sure whether this is the best way todo it :)

I would have used

+  function query() {
+    $table = $this->ensure_my_table();
+    $node = $this->query->ensure_table('node');
+    $this->query->add_where($this->options['group'], "***CURRENT_USER*** <> 0 AND ($table.assign_to = ***CURRENT_USER*** OR $node.uid = ***CURRENT_USER***)");
+  }

One big advantage of this approach is, that the code is better readable, because you can know, where the join goes to, see views_handler_filter_history_user_timestamp as example

dagmar’s picture

StatusFileSize
new2.36 KB
(14:20:31) merlinofchaos: dagmar1: i like dereine's approach except that the ensure_table() call needs to include $this->relationship

So, here is a new patch including the suggestions by dereine and merlinofchaos

dawehner’s picture

+    return false;

Minor code style issue :)

The rest looks fine.

dagmar’s picture

StatusFileSize
new2.34 KB

Thanks dereine

dawehner’s picture

From my views perspective this looks rtbc. But i didn't have tested the functionality

dagmar’s picture

Title: New filter: Cases created by or assigned to » New filter and argument: Cases created by or assigned to
StatusFileSize
new4.45 KB

This new patch includes an argument to allow user to get the uid from the url. Very useful if a Case view is embed into a profile page of a user.

Dereine, probably there is a better way to avoid to include "assign_to" in the argument handler, do you remember how to do that in the casetracker.views.inc?

dawehner’s picture

Sry i don't know a method todo it, perhaps earl knows. Btw. for me the argument handler looks fine.

dagmar’s picture

StatusFileSize
new4.87 KB

Well I have added exposed filter support. Maybe there is a better way to explain how it works, but for now is working properly.

RikiB’s picture

Worked perfect thanks. Just to reiterate:

Applied the patch here: http://drupal.org/node/737200#comment-2813496
Added the new Filter "Case Tracker: Case assigned to or created by current user" in the "casetracker_project_cases" view.
Set the new filter to only show posts Assigned or Created by me.
Win