<div><br>With no claim that it's the Right Way© <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> global $user;<br> if (is_null($item_id)) {<br> $iid = arg(2);<br> if (isset($iid)) {<br> $item = db_fetch_object(db_query(SYNDICATOR_PROMOTE_TO_NODE_QUERY, $iid));<br> }<br> }<br> else if (is_numeric($item_id)) {
<br> $item = db_fetch_object(db_query(SYNDICATOR_PROMOTE_TO_NODE_QUERY, $item_id));<br> }<br> if (isset($item)) {<br> $node = new stdClass();<br> $node->is_new = true;<br> $item->description = check_markup($item->description, $node->filter);
<br> $node->created = time();<br> $node->date = format_date($item->timestamp, 'custom', 'Y-m-d H:i:s O');<br> $node->type = variable_get('syndicator_publish_node_type', 'none');<br> $node->title = $item->title;
<br> $node->filter = variable_get('filter_default_format', FILTER_FORMAT_DEFAULT);<br> $node->body = theme('syndicator_published_content', $item);<br> $node->teaser = node_teaser(theme('syndicator_published_content', $item),
<br> variable_get('filter_default_format', FILTER_FORMAT_DEFAULT)); // might be unnecessary<br><br> $node_options = variable_get('node_options_' . $node->type, array());<br> $node->comment = variable_get('comment_' . $node->type, 2);
<br> unset($node->nid);<br> $node = node_submit($node);<br> $node->uid = $user->uid ? $user->uid : 1;<br> module_invoke('node', 'save', $node);<br> }<br>}<br><br><br></blockquote><br><div><span class="gmail_quote">
On 6/6/06, <b class="gmail_sendername">Robrecht Jacques</b> <<a href="mailto:robrechtj+drupal@gmail.com">robrechtj+drupal@gmail.com</a>> 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->type = 'story';<br>$node->uid = 1;<br>$node->title = ''; // invalid empty title!<br>$node->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> // "they" introduce something else that breaks<br> // "common sense". 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>