--- revision_moderation.module 2007-03-22 18:40:19.000000000 +0100 +++ revision_moderation.module 2007-03-22 18:39:25.000000000 +0100 @@ -171,12 +171,15 @@ function revision_moderation_nodeapi(&$n case 'prepare': // If user has a pending revision for this node, load the latest version of // it instead. - if ($revisions = revision_moderation_get_node_pending_revisions($node->nid)) { + if ($revisions = revision_moderation_get_node_pending_revisions($node->nid, $node->vid)) { global $user; foreach ($revisions as $revision) { if ($revision->uid == $user->uid) { drupal_set_message(t('Editing your latest revision, which is still pending moderation.')); - $node = node_load($node->nid, $revision->vid); + + // It's safer to relaunch the whole edition process, for example to not loose the 'created' node info + // set in node_object_prepare() and that we drop if we do a node_load() here + drupal_goto('node/'. $node->nid .'/revisions/'. $revision->vid .'/edit'); break; } } @@ -285,9 +288,9 @@ function revision_moderation_get_all_pen * @param $nid * The node ID to retrieve. */ -function revision_moderation_get_node_pending_revisions($nid) { +function revision_moderation_get_node_pending_revisions($nid, $vid = 0) { // Obtain a list of revisions higher than current published revision for a given node. - $sql = "SELECT n.nid, r.vid, r.uid FROM {node} n INNER JOIN {node_revisions} r ON n.nid = r.nid WHERE r.vid > n.vid AND n.nid = %d ORDER BY r.vid DESC"; + $sql = "SELECT n.nid, r.vid, r.uid FROM {node} n INNER JOIN {node_revisions} r ON n.nid = r.nid WHERE r.vid > ". ($vid ? $vid : "n.vid") . " AND n.nid = %d ORDER BY r.vid DESC"; $result = db_query($sql, $nid); $revisions = array(); while ($revision = db_fetch_object($result)) {