I needed to build a view that takes the name of a state as an argument and does not seem to be supported, so I've written a patch to add it.

CommentFileSizeAuthor
states_views.inc_.diff1.44 KBasciikewl

Comments

aaron’s picture

Status: Needs review » Reviewed & tested by the community

this functionality is essential. tested, and the patch works as advertised.

fago’s picture

Status: Reviewed & tested by the community » Needs work

great! But doesn't get this double escaped?

+ $where = db_escape_string($arg);
+ $query->add_where("node_state.state = '%s'", $arg);

I think so. Please correct me when I'm wrong.

asciikewl’s picture

Being a bit of newbie at views, I modified that from views_node.inc line 503 that reads:

case 'filter':
$where = db_escape_string($arg);
$query->add_where("node.type = '%s'", $where);
break;

So looking at the code it should prob read:

$where = db_escape_string($arg);
$query->add_where("node_state.state = '%s'", $where);

or skip the db_escape_string part. Does add_where do escaping on the 2nd argument?

I'm a bit more worried about the 'link' case just after that as I haven't tested that much. (Not used in the site I'm building).

aaron’s picture

although i'm certain there won't be a namespace issue in this case, shouldn't the function be named something like states_handler_argument_statement?

fago’s picture

ah, thanks aaron. Yes it should.

@add_where: Yes, as it's inserted via db_query() in %s.
@title: looking at other arguments, you should check_plain that.

mitchell’s picture

Project: Workflow-ng » Rules
Version: 5.x-2.1 » 6.x-1.x-dev
Component: State Machines » Rules Engine

Where does this patch stand relative to the improvements since made to Rules?

fago’s picture

Project: Rules » Workflow-ng
Version: 6.x-1.x-dev » 5.x-2.1
Component: Rules Engine » State Machines

There won't be a states module for rules - as CCK + actions is the way go. So any possible improvements have to go into workflow-ng only.