State machine: States as arguments

asciikewl - May 27, 2008 - 22:40
Project:Workflow-ng
Version:5.x-2.1
Component:State Machines
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs work
Description

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.

AttachmentSize
states_views.inc_.diff1.44 KB

#1

aaron - May 29, 2008 - 21:10
Status:needs review» reviewed & tested by the community

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

#2

fago - May 30, 2008 - 09:18
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.

#3

asciikewl - May 30, 2008 - 11:54

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).

#4

aaron - May 30, 2008 - 13:43

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?

#5

fago - May 30, 2008 - 16:00

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.

#6

opensanta - March 30, 2009 - 01:27
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?

#7

fago - March 30, 2009 - 19:58
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.

 
 

Drupal is a registered trademark of Dries Buytaert.