From fee1dbb077fc6beb415f22be4d9ab712f319fe1e Sat, 2 Jul 2016 15:19:30 +0200
From: hass <hass@85918.no-reply.drupal.org>
Date: Sat, 2 Jul 2016 15:19:23 +0200
Subject: [PATCH] Testbot suxxx

diff --git a/tests/external_node_update.test b/tests/external_node_update.test
index 9edbcf8..641116d 100644
--- a/tests/external_node_update.test
+++ b/tests/external_node_update.test
@@ -29,6 +29,7 @@
       'name' => 'External node update',
       'description' => 'Test if nodes are correctly moderated when updated by third party modules.',
       'group' => 'Workbench Moderation',
+      'dependencies' => array('token'),
     );
   }
 
diff --git a/tests/workbench_moderation.files.test b/tests/workbench_moderation.files.test
index 874f2ed..6d50ad2 100644
--- a/tests/workbench_moderation.files.test
+++ b/tests/workbench_moderation.files.test
@@ -50,6 +50,7 @@
       'name' => 'Workbench Moderation file attachments',
       'description' => 'Test moderation on nodes with with file attachments.',
       'group' => 'Workbench Moderation',
+      'dependencies' => array('token'),
     );
   }
 
diff --git a/tests/workbench_moderation.test b/tests/workbench_moderation.test
index 3b692ff..314c05e 100644
--- a/tests/workbench_moderation.test
+++ b/tests/workbench_moderation.test
@@ -10,7 +10,7 @@
   protected $moderator_user;
 
   function setUp($modules = array()) {
-    $modules = array_merge($modules, array('workbench_moderation', 'workbench_moderation_test'));
+    $modules = array_merge($modules, array('token', 'workbench_moderation', 'workbench_moderation_test'));
     parent::setUp($modules);
 
     // Create a new content type and enable moderation on it.
@@ -50,6 +50,7 @@
       'name' => 'Moderation tab',
       'description' => 'Create a moderated node publish it using the "Moderate" tab.',
       'group' => 'Workbench Moderation',
+      'dependencies' => array('token'),
     );
   }
 
diff --git a/workbench_moderation.info b/workbench_moderation.info
index 3f9939f..7aa40af 100644
--- a/workbench_moderation.info
+++ b/workbench_moderation.info
@@ -16,3 +16,8 @@
 files[] = tests/external_node_update.test
 files[] = tests/workbench_moderation.test
 files[] = tests/workbench_moderation.files.test
+
+; Required for create/update log messages.
+dependencies[] = token
+
+test_dependencies[] = token
diff --git a/workbench_moderation.install b/workbench_moderation.install
index 8d68ed3..d02224a 100644
--- a/workbench_moderation.install
+++ b/workbench_moderation.install
@@ -31,6 +31,8 @@
   $types = node_type_get_types();
   foreach ($types as $type_object) {
     $type = $type_object->type;
+    variable_del("workbench_moderation_default_revision_information_log_create_$type");
+    variable_del("workbench_moderation_default_revision_information_log_update_$type");
     variable_del("workbench_moderation_default_state_$type");
 
     // Get node options that might hold a moderation flag.
diff --git a/workbench_moderation.module b/workbench_moderation.module
index 26ea794..39f52f5 100644
--- a/workbench_moderation.module
+++ b/workbench_moderation.module
@@ -703,7 +703,7 @@
 
   // Don't proceed if moderation is not enabled on this content, or if
   // we're replacing an already-published revision.
-  if (!workbench_moderation_node_moderated($node) || 
+  if (!workbench_moderation_node_moderated($node) ||
       !empty($node->workbench_moderation['updating_live_revision'])) {
     return;
   }
@@ -818,6 +818,31 @@
     'disabled' => array(':input[name="node_options[revision]"]' => array('checked' => FALSE)),
   );
 
+  // The default "create" moderation note.
+  $form['workflow']['workbench_moderation_default_revision_information_log_create'] = array(
+    '#default_value' => variable_get('workbench_moderation_default_revision_information_log_create_' . $form['#node_type']->type, t('Created by [user:name].')),
+    '#description' => t('Default create revision log message. Can be overridden by the user.'),
+    '#title' => t('Default create moderation notes'),
+    '#type' => 'textarea',
+    '#element_validate' => array('token_element_validate'),
+    '#token_types' => array('user'),
+  );
+  // The default "update" moderation note.
+  $form['workflow']['workbench_moderation_default_revision_information_log_update'] = array(
+    '#default_value' => variable_get('workbench_moderation_default_revision_information_log_update_' . $form['#node_type']->type, t('Edited by [user:name].')),
+    '#description' => t('Default update revision log message. Can be overridden by the user.'),
+    '#title' => t('Default update moderation notes'),
+    '#type' => 'textarea',
+    '#element_validate' => array('token_element_validate'),
+    '#token_types' => array('user'),
+  );
+  $form['workflow']['workbench_moderation_default_revision_information_log'] = array(
+    '#theme' => 'token_tree',
+    '#token_types' => array('user'),
+    '#show_restricted' => TRUE,
+    '#dialog' => TRUE,
+  );
+
   // This select element is hidden when moderation is not enabled.
   $form['workflow']['workbench_moderation_default_state'] = array(
     '#title' => t('Default moderation state'),
@@ -922,13 +947,13 @@
   );
 
   // Set a default revision log message.
-  $logged_name = (user_is_anonymous() ? variable_get('anonymous', t('Anonymous')) : format_username($user));
   if (!empty($form['#node']->nid)) {
-    $form['revision_information']['log']['#default_value'] = t('Edited by !user.', array('!user' => $logged_name));
+    $revision_information_log = t(variable_get('workbench_moderation_default_revision_information_log_update_' . $form['#node']->type, t('Edited by [user:name].')));
   }
   else {
-    $form['revision_information']['log']['#default_value'] = t('Created by !user.', array('!user' => $logged_name));
+    $revision_information_log = t(variable_get('workbench_moderation_default_revision_information_log_create_' . $form['#node']->type, t('Created by [user:name].')));
   }
+  $form['revision_information']['log']['#default_value'] = token_replace($revision_information_log, array('user' => $user), array('sanitize' => FALSE, 'clear' => TRUE));
 
   // Move the revision log into the publishing options to make things pretty.
   if ($form['options']['#access']) {
