<div><br>With no claim that it's the Right Way&copy; <br></div><br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">function syndicator_item_to_node($item_id = NULL) {
<br>&nbsp; global $user;<br>&nbsp; if (is_null($item_id)) {<br>&nbsp;&nbsp;&nbsp; $iid = arg(2);<br>&nbsp;&nbsp;&nbsp; if (isset($iid)) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $item = db_fetch_object(db_query(SYNDICATOR_PROMOTE_TO_NODE_QUERY, $iid));<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; }<br>&nbsp; else if (is_numeric($item_id)) {
<br>&nbsp;&nbsp;&nbsp; $item = db_fetch_object(db_query(SYNDICATOR_PROMOTE_TO_NODE_QUERY, $item_id));<br>&nbsp; }<br>&nbsp; if (isset($item)) {<br>&nbsp;&nbsp;&nbsp; $node = new stdClass();<br>&nbsp;&nbsp;&nbsp; $node-&gt;is_new = true;<br>&nbsp;&nbsp;&nbsp; $item-&gt;description = check_markup($item-&gt;description, $node-&gt;filter);
<br>&nbsp;&nbsp;&nbsp; $node-&gt;created = time();<br>&nbsp;&nbsp;&nbsp; $node-&gt;date = format_date($item-&gt;timestamp, 'custom', 'Y-m-d H:i:s O');<br>&nbsp;&nbsp;&nbsp; $node-&gt;type = variable_get('syndicator_publish_node_type', 'none');<br>&nbsp;&nbsp;&nbsp; $node-&gt;title = $item-&gt;title;
<br>&nbsp;&nbsp;&nbsp; $node-&gt;filter = variable_get('filter_default_format', FILTER_FORMAT_DEFAULT);<br>&nbsp;&nbsp;&nbsp; $node-&gt;body = theme('syndicator_published_content', $item);<br>&nbsp;&nbsp;&nbsp; $node-&gt;teaser = node_teaser(theme('syndicator_published_content', $item), 
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; variable_get('filter_default_format', FILTER_FORMAT_DEFAULT)); // might be unnecessary<br><br>&nbsp;&nbsp;&nbsp; $node_options = variable_get('node_options_' . $node-&gt;type, array());<br>&nbsp;&nbsp;&nbsp; $node-&gt;comment = variable_get('comment_' . $node-&gt;type, 2);
<br>&nbsp;&nbsp;&nbsp; unset($node-&gt;nid);<br>&nbsp;&nbsp;&nbsp; $node = node_submit($node);<br>&nbsp;&nbsp;&nbsp; $node-&gt;uid = $user-&gt;uid ? $user-&gt;uid : 1;<br>&nbsp;&nbsp;&nbsp; module_invoke('node', 'save', $node);<br>&nbsp; }<br>}<br><br><br></blockquote><br><div><span class="gmail_quote">
On 6/6/06, <b class="gmail_sendername">Robrecht Jacques</b> &lt;<a href="mailto:robrechtj+drupal@gmail.com">robrechtj+drupal@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div>- and the real question: how does the following sequence of 
4.6 translate into 4.7:<br><pre>$node-&gt;type = 'story';<br>$node-&gt;uid = 1;<br>$node-&gt;title = ''; // invalid empty title!<br>$node-&gt;body = ''; // invalid empty body!<br><br>$node = node_validate($node); // if life was only that
<br><br>                              // that easy in 4.7... <br><br>if (form_get_errors()) {<br>  // we detected the error... do something<br>  unset($GLOBALS['form']);<br><br>  // note: we unset $GLOBALS['form'] so the next time we
<br><br>  // try this trick, form_get_errors() return the errors<br>  // of the last run and not of the previous.<br>  // If something like this would be possible in 4.7 it<br>  // would be great, but form_set_error() in 
4.7 saves the<br><br>  // errors in a static variable inside form_set_error()<br>  // instead of in $GLOBALS['form']. I see no way to unset<br>  // that...<br>  $output .= node_view($node);<br>}<br>else {<br>  // no errors? hmm, great, save it... quickly before
<br><br>  // &quot;they&quot; introduce something else that breaks<br>  // &quot;common sense&quot;. Really: why call something<br>  // foobar_validate() if it doesn't validate anything<br>  // at all... Am I alone in this? I guess so.
<br><br>  node_save($node);<br>}<br></pre></div></div></blockquote></div><br>