Index: revision_moderation.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/revision_moderation/revision_moderation.module,v retrieving revision 1.26.2.12 diff -u -r1.26.2.12 revision_moderation.module --- revision_moderation.module 7 Dec 2007 16:43:25 -0000 1.26.2.12 +++ revision_moderation.module 19 Dec 2007 15:42:53 -0000 @@ -16,6 +16,11 @@ include_once drupal_get_path('module', 'revision_moderation') .'/revision_moderation_views.inc'; } +// Workflow-ng module support. +if (module_exists('workflow_ng')) { + include_once drupal_get_path('module', 'revision_moderation') .'/revision_moderation_workflow_ng.inc'; +} + /** * Implementation of hook_menu(). */ @@ -321,3 +326,43 @@ watchdog('content', t('@type: published %title revision %revision', array('@type' => t($node->type), '%title' => $node->title, '%revision' => $vid)), WATCHDOG_NOTICE, l(t('view'), "node/$nid/revisions/$vid/view")); drupal_goto("node/$nid"); } + +/** + * Implementation of hook_token_values(). + */ +function revision_moderation_token_values($entity_type, $object = NULL) { + $values = array(); + if ($entity_type == 'node') { + $values['revision_moderation'] = $object->revision_moderation ? t('on') : t('off'); + $values['revision'] = $object->revision ? t('on') : t('off'); + } + return $values; +} + +/** + * Implementation of hook_token_list(). + */ +function revision_moderation_token_list($entity_type = 'all') { + if ($entity_type == 'node') { + $tokens = array(); + $tokens['node']['revision_moderation'] = t('Whether revision moderation is on. (@on/@off)', array('@on' => t('on'), '@off' => t('off'))); + $tokens['node']['revision'] = t('Whether a new revision is to be created. (@on/@off)', array('@on' => t('on'), '@off' => t('off'))); + return $tokens; + } +} + +/** + * Enables revision moderation for a node. + */ +function revision_moderation_enable_moderation(&$node) { + $node->revision_moderation = 1; + // Also enable "Create new revisions" option, in case it isn't yet. + $node->revision = 1; +} + +/** + * Disables revision moderation for a node. + */ +function revision_moderation_disable_moderation(&$node) { + $node->revision_moderation = 0; +} Index: revision_moderation_actions.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/revision_moderation/revision_moderation_actions.inc,v retrieving revision 1.2 diff -u -r1.2 revision_moderation_actions.inc --- revision_moderation_actions.inc 2 Nov 2006 04:37:49 -0000 1.2 +++ revision_moderation_actions.inc 19 Dec 2007 15:42:53 -0000 @@ -21,9 +21,7 @@ ); break; case 'do': - $node->revision_moderation = 1; - // Also enable "Create new revisions" option, in case it isn't yet. - $node->revision = 1; + revision_moderation_enable_moderation($node); node_save($node); break; } @@ -44,7 +42,7 @@ ); break; case 'do': - $node->revision_moderation = 0; + revision_moderation_disable_moderation($node); node_save($node); break; } Index: revision_moderation_workflow_ng.inc =================================================================== RCS file: revision_moderation_workflow_ng.inc diff -N revision_moderation_workflow_ng.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ revision_moderation_workflow_ng.inc 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,68 @@ + array( + '#label' => t('Enable revision moderation for a content'), + '#arguments' => array( + 'node' => array( + '#entity' => 'node', + '#label' => t('Content'), + ), + ), + '#module' => t('Revision Moderation'), + ), + 'revision_moderation_workflow_ng_disable' => array( + '#label' => t('Disable revision moderation for a content'), + '#arguments' => array( + 'node' => array( + '#entity' => 'node', + '#label' => t('Content'), + ), + ), + '#module' => t('Revision Moderation'), + ), + 'revision_moderation_workflow_ng_publish' => array( + '#label' => t('Publish a content revision'), + '#arguments' => array( + 'node' => array( + '#entity' => 'node', + '#label' => t('Content, which is to be published'), + ), + ), + '#module' => t('Revision Moderation'), + ), + ); +} + +/** + * Implementation of a worklfow-ng action: enables revision moderation. + */ +function revision_moderation_workflow_ng_enable($node) { + revision_moderation_enable_moderation($node); + return array('node' => $node); +} + +/** + * Implementation of a worklfow-ng action: disables revision moderation. + */ +function revision_moderation_workflow_ng_disable($node) { + revision_moderation_disable_moderation($node); + return array('node' => $node); +} + +/** + * Implementation of a worklfow-ng action: publishes a revision. + */ +function revision_moderation_workflow_ng_publish($node) { + db_query("UPDATE {node} SET vid = %d WHERE nid = %d", $node->vid, $node->nid); +}