Index: override_node_options.module
===================================================================
--- override_node_options.module	(revision 1678)
+++ override_node_options.module	(working copy)
@@ -1,6 +1,26 @@
 <?php
 // $Id: override_node_options.module,v 1.2 2007/01/09 22:29:49 robroy Exp $
 
+ /**
+  * Implementation of hook_menu().
+  */
+function override_node_options_menu($may_cache) {
+
+ if (!$may_cache) {
+
+    $items[] = array(
+      'path' => 'admin/settings/override_node_options',
+      'description' => t('Control which node publishing overrides users have.'),
+      'title' => t('Override Node Options'),
+      'callback' => 'drupal_get_form',
+      'callback arguments' => 'override_node_options_admin_settings',
+      'access' => user_access('administer site configuration'),
+    );
+  }
+
+  return $items;
+}
+
 /**
  * @file
  * Allow users to override the default publishing options for nodes they can
@@ -23,11 +43,59 @@
   // TODO: Once in core, remove adminster nodes check.
   if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id && user_access('override node publishing options') && !user_access('administer nodes')) {
     $node = $form['#node'];
-    $form['options'] = array('#type' => 'fieldset', '#title' => t('Publishing options'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => 25);
-    $form['options']['override_publishing_status']   = array('#type' => 'checkbox', '#title' => t('Published'), '#default_value' => $node->status);
-    $form['options']['override_publishing_promote']  = array('#type' => 'checkbox', '#title' => t('Promoted to front page'), '#default_value' => $node->promote);
-    $form['options']['override_publishing_sticky']   = array('#type' => 'checkbox', '#title' => t('Sticky at top of lists'), '#default_value' => $node->sticky);
-    $form['options']['override_publishing_revision'] = array('#type' => 'checkbox', '#title' => t('Create new revision'), '#default_value' => $node->revision);
+
+    $publish_overrides = variable_get('override_node_options_publishing', 0);
+    $author_overrides = variable_get('override_node_options_author', 0);
+
+#    ob_start(); print_r($publish_overrides);
+#    drupal_set_message(ob_get_contents()); ob_end_clean();
+#    ob_start(); print_r($author_overrides);
+#    drupal_set_message(ob_get_contents()); ob_end_clean();
+    
+    $options = array(
+      'status'   => array('title' => t('Published'), 'default_value' => $node->status),
+      'promote'  => array('title' => t('Promoted to front page'), 'default_value' => $node->promote),
+      'sticky'   => array('title' => t('Sticky at top of lists'), 'default_value' => $node->sticky),
+      'revision' => array('title' => t('Create new revision'), 'default_value' => $node->revision),
+    );
+    
+    // Check to make sure at least one option was specified by admin
+    if (is_array($publish_overrides) && count($publish_overrides)) {
+      $form['options'] = array('#type' => 'fieldset', '#title' => t('Publishing options'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => 25);  
+      foreach ($publish_overrides as $key => $value) {
+        if ($value) {
+          $form['options']['override_publishing_'.$key] = array('#type' => 'checkbox', '#title' => $options[$key]['title'], '#default_value' => $options[$key]['default_value']);
+        }
+      }      
+    }
+    
+    if (is_array($author_overrides) && count($author_overrides)) {
+      $form['author'] = array('#type' => 'fieldset', '#title' => t('Authoring information'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => 20);
+      if ($author_overrides['name']) {
+        global $user;
+        $form['author']['override_author_name'] = array(
+          '#type' => 'textfield',
+          '#title' => t('Authored by'),
+          '#maxlength' => 60,
+          '#default_value' => $node->name ? $node->name : '',
+          '#weight' => -1,
+          '#description' => t('Leave blank for %anonymous.', array('%anonymous' => variable_get('anonymous', t('Anonymous')))),
+        );
+        // User must have permission 'access user profiles' for autocomplete
+        if (user_access('access user profiles')) {
+          $form['author']['override_author_name']['#autocomplete_path'] = 'user/autocomplete';
+        }
+      }
+      if ($author_overrides['date']) {
+        $form['author']['override_author_date'] = array(
+          '#type' => 'textfield',
+          '#title' => t('Authored on'),
+          '#maxlength' => 25,
+          '#default_value' => $node->date,
+          '#description' => t('Format: %time. Leave blank to use the time of form submission.', array('%time' => !empty($node->date) ? $node->date : format_date($node->created, 'custom', 'Y-m-d H:i:s O'))),
+        );
+      }
+    }      
   }
 }
 
@@ -47,12 +115,62 @@
           'override_publishing_sticky' => 'sticky',
           'override_publishing_revision' => 'revision',
         );
+	// Publishing options
         foreach ($keys as $override_key => $real_key) {
           if (isset($node->$override_key)) {
             $node->$real_key = $node->$override_key;
           }
         }
+        // Node creation date override
+        if ($node->date !== $node->override_author_date || !empty($node->override_author_date)) {
+          $node->created = !empty($node->override_author_date) ? strtotime($node->override_author_date) : time();
+        }
+        // Node author override
+        if ($node->name !== $node->override_author_name) {
+          if (!empty($node->override_author_name)) {
+            $account = user_load(array('name' => $node->override_author_name));
+            $node->uid = $account->uid;
+          }
+          else {
+            $node->uid = 0;
+          }
+        }
       }
       break;
   }
 }
+
+/**
+ * Admin settings form
+ */
+function override_node_options_admin_settings() {
+  $options = array(
+    'status' => t('Published'),
+    'promote' => t('Promoted to front page'),
+    'sticky' => t('Sticky at top of lists'),
+    'revision' => t('Create new revision'),
+  );
+  
+  $author = array(
+    'name' => t('Authored by'),
+    'date' => t('Authored on'),
+  );
+
+  $form['override_node_options_publishing'] = array(
+    '#type' => 'checkboxes',
+    '#title' => t('Available publishing overrides'),
+    '#default_value' => variable_get('override_node_options_publishing', $options),
+    '#options' => $options,
+    '#description' => t('Check only those publishing options you want users to be able to override. This setting applies to all users with roles including the permission <em>override node publishing options</em>.')
+  );
+  $form['override_node_options_author'] = array(
+    '#type' => 'checkboxes',
+    '#title' => t('Available author overrides'),
+    '#default_value' => variable_get('override_node_options_author', $author),
+    '#options' => $author,
+    '#description' => t('Check only those authoring options you want users to be able to override. This setting applies to all users with roles including the permission <em>override node publishing options</em>. Grant with care! If you allow users to change the author, they may need permissions that allow them to edit \'any\' given content type - otherwise they can lock themselves out of their own nodes.')
+  );
+
+  return system_settings_form($form);
+}
+
