User login

Testing nodeapi to see when it lets us do what

So we have testing the data available to see what happens when we try to save one our action-space associated actions or other content.

The nodes created are 571: Required, an Action space (organic group).
And 572: A new action to test, an Action.

And I see a bunch of nodeapi node object outputs before the anything to do with the submission form. (one of them was for a 'profile', and two for a minimalistic action and action_space-- action, profile, action_space). Next was a longer action_space, with the title and the "Follow me home!" description we're inserting automatically somewhere. Still no nid though.

This is actually the fifth time nodeapi is called:

stdClass Object
(
[nid] =>
[vid] =>
[uid] => 1
[created] => 1195590173
[type] => action
[changed] =>
[title] => A new action to test
[body] => Please.....

...

[taxonomy] => Array
(
[tags] => Array
(
[1] =>
[2] =>
)

[6] => 189
)

Taxonomy term 189 is the "Proposed" status of the action. Still part of the same nodeapi output here:

[place_taxonomy] => Array
(
[5] => Array
(
[20] => Haiti
[40] =>
[60] => Port-au-Prince
[70] =>
)

)
...

Then an empty call to something. This would be when function wsf_action_combined_action_submit($form_id, &$form_values) is called, since I accidentally left the print test to $form (not $form_values).

Another minimalistic action object. If you have to see, here's the whole thing:

stdClass Object
(
[type] => action
[created] => 1195590179
[date] => 2007-11-20 16:22:59 -0400
[comment] => 2
)

Another action_space, full-size but still no nid.

And then, twice:

stdClass Object
(
[nid] => 571
[vid] => 918
[type] => action_space
[status] => 1
[created] => 1195590180
[changed] => 1195590180
...
[title] => Required

...
[tags] =>
)

stdClass Object
(
[nid] => 571
[vid] => 918
[uid] => 1
[created] => 1195590180
[type] => action_space
[changed] => 1195590180
[title] => Required
...
[preview] => Preview
[submit] => Submit
[form_id] => action_space_node_form
[comment] => 0
[og_public] => 1
...
[subscriptions_currentstatus] => 1
[menu] => Array
(
[title] =>
[description] =>
[pid] => 1
[path] =>
[weight] => 0
[mid] => 0
[type] => 86
)

[path] =>
[teaser] =>
[validated] => 1
[is_new] => 1
)

And after this one: Your Action space has been created.

That's all the pertinent differences between the two. You know, if I'd had nodeapi print out what 'op' it was doing I'd be learning a lot more here... http://api.drupal.org/api/function/hook_nodeapi/5

Load, validate, and submit I assume.

Another nid-less object, and then:

stdClass Object
(
[nid] => 572
[vid] => 919
[type] => action
[status] => 1
[created] => 1195590184
[changed] => 1195590184
[comment] => 2
[promote] => 1
[sticky] => 1
[revision_timestamp] => 1195590184
[title] => A new action to test
[body] => Please....
...
[tags] =>
)

The submin's usernode gets thrown in here.

And our friend the action again:

stdClass Object
(
[nid] => 572
[vid] => 919
[uid] => 1
[created] => 1195590184
[type] => action
[changed] => 1195590184
[title] => A new action to test
[body] => Please ....
...
[place_taxonomy] => Array
(
[5] => Array
(
[20] => Haiti
[40] =>
[60] => Port-au-Prince
[70] =>
)

)

[teaser] => Please....
[validated] => 1
[is_new] => 1
)

Last one had the same place_taxonomy and teaser by the way, I just cut it out. The validated and is_new is special to this round of nodeapi.

And: Your Action has been created.

OK, we have our game plan. And it relies very, very heavily on Drupal's taxonomy being such a simple and elegant system. All we have to do is make sure the right values show up in Drupal Taxonomy's term_node database table, and Drupal will do the rest.

Step one for that is to take

Even though this data is going in the other direction, we can do it at the same time.

RGGHHH

// so this is the first action for an action space
// meaning the action space was just created
// therefore we have to

Hmm, since I don't think the taxonomy terms are saved at any reasonable spot in the process (they're saved with the action, which is created after the action space) I guess the best thing for us to do is to double their values in the form and save them both through normal channels (although once we have the taxonomy terms being saved with the action space, we could in theory retrieve the values from here and enter it directly into the database on behalf of action nodes)

Resolution

What we ended up doing:

Using hook_nodeapi to stick in the terms (taken directly from the associated action space, or organic group) on insert or update.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.