* trac/attachment.py
  (AttachmentModule._do_save):
    Use util.get_authentic_id() instead of just req.args.get().
  (AttachmentModule._render_form):
    Add fieldname argument to util.get_reporter_id() call.

* trac/ticket/web_ui.py:
  (NewticketModule.process_request): No effective behaviour change, but use
    code more consistent in style with similar operations elsewhere.
  (NewticketModule._do_create): Use util.get_authentic_id(). Logic is
    unchanged except for the addition of authentic-making the username,
    but the code is simplified.
  (TicketModule.process_request): Simplify code, with inconsequential
    logic changes.
  (TicketModule._do_save):
    Use util.get_authentic_id() instead of just req.args.get().

* trac/util.py (get_reporter_id):
    Always return req.authname if the request is authenticated.
    Add capability to fetch a value from a form field if one was specified.
  (get_authentic_id): New function - return req.authname if the request is
    authenticated, otherwise call get_reporter_id and mangle the return
    value to indicate its unauthenticated nature.

* trac/wiki/web_ui.py: Import util.get_authentic_id.
  (WikiModule._do_save):
    Use util.get_authentic_id() instead of just req.args.get().
  (WikiModule._render_editor): Logic unchanged. Code simplified by making
    use of the new behaviour of get_reporter_id.

* templates/attachment.cs, templates/newticket.cs, templates/ticket.cs,
  templates/wiki.cs: Only show "Your email or username:" field if not
    authenticated.
diff -ru trac-0.9.5.orig/templates/attachment.cs trac-0.9.5/templates/attachment.cs
--- trac-0.9.5.orig/templates/attachment.cs	2006-01-03 14:34:36.000000000 -0600
+++ trac-0.9.5/templates/attachment.cs	2006-06-11 17:00:53.000000000 -0500
@@ -14,11 +14,13 @@
   </div>
   <fieldset>
    <legend>Attachment Info</legend>
-   <div class="field">
-    <label>Your email or username:<br />
-    <input type="text" name="author" size="30" value="<?cs
-      var:attachment.author?>" /></label>
-   </div>
+   <?cs if:trac.authname == "anonymous" ?>
+    <div class="field">
+     <label>Your email or username:<br />
+     <input type="text" name="author" size="30" value="<?cs
+       var:attachment.author?>" /></label>
+    </div>
+   <?cs /if ?>
    <div class="field">
     <label>Description of the file (optional):<br />
     <input type="text" name="description" size="60" /></label>
diff -ru trac-0.9.5.orig/templates/newticket.cs trac-0.9.5/templates/newticket.cs
--- trac-0.9.5.orig/templates/newticket.cs	2005-11-05 10:51:06.000000000 -0600
+++ trac-0.9.5/templates/newticket.cs	2006-06-11 17:00:21.000000000 -0500
@@ -11,11 +11,13 @@
 <?cs include:"site_newticket.cs" ?>
 <form id="newticket" method="post" action="<?cs
   var:trac.href.newticket ?>#preview">
- <div class="field">
-  <label for="reporter">Your email or username:</label><br />
-  <input type="text" id="reporter" name="reporter" size="40" value="<?cs
-    var:newticket.reporter ?>" /><br />
- </div>
+ <?cs if:trac.authname == "anonymous" ?>
+  <div class="field">
+   <label for="reporter">Your email or username:</label><br />
+   <input type="text" id="reporter" name="reporter" size="40" value="<?cs
+     var:newticket.reporter ?>" /><br />
+  </div>
+ <?cs /if ?>
  <div class="field">
   <label for="summary">Short summary:</label><br />
   <input id="summary" type="text" name="summary" size="80" value="<?cs
diff -ru trac-0.9.5.orig/templates/ticket.cs trac-0.9.5/templates/ticket.cs
--- trac-0.9.5.orig/templates/ticket.cs	2005-11-05 10:51:06.000000000 -0600
+++ trac-0.9.5/templates/ticket.cs	2006-06-11 17:00:42.000000000 -0500
@@ -126,11 +126,13 @@
  <hr />
  <h3><a name="edit" onfocus="document.getElementById('comment').focus()">Add/Change #<?cs
    var:ticket.id ?> (<?cs var:ticket.summary ?>)</a></h3>
- <div class="field">
-  <label for="author">Your email or username:</label><br />
-  <input type="text" id="author" name="author" size="40"
-    value="<?cs var:ticket.reporter_id ?>" /><br />
- </div>
+ <?cs if:trac.authname == "anonymous" ?>
+  <div class="field">
+   <label for="author">Your email or username:</label><br />
+   <input type="text" id="author" name="author" size="40"
+     value="<?cs var:ticket.reporter_id ?>" /><br />
+  </div>
+ <?cs /if ?>
  <div class="field">
   <fieldset class="iefix">
    <label for="comment">Comment (you may use <a tabindex="42" href="<?cs
diff -ru trac-0.9.5.orig/templates/wiki.cs trac-0.9.5/templates/wiki.cs
--- trac-0.9.5.orig/templates/wiki.cs	2005-12-01 14:47:37.000000000 -0600
+++ trac-0.9.5/templates/wiki.cs	2006-06-11 17:00:03.000000000 -0500
@@ -235,11 +235,13 @@
     </div>
     <fieldset id="changeinfo">
      <legend>Change information</legend>
-     <div class="field">
-      <label>Your email or username:<br />
-      <input id="author" type="text" name="author" size="30" value="<?cs
-        var:wiki.author ?>" /></label>
-     </div>
+     <?cs if:trac.authname == "anonymous" ?>
+      <div class="field">
+       <label>Your email or username:<br />
+       <input id="author" type="text" name="author" size="30" value="<?cs
+         var:wiki.author ?>" /></label>
+      </div>
+     <?cs /if ?>
      <div class="field">
       <label>Comment about this change (optional):<br />
       <input id="comment" type="text" name="comment" size="60" value="<?cs
diff -ru trac-0.9.5.orig/trac/attachment.py trac-0.9.5/trac/attachment.py
--- trac-0.9.5.orig/trac/attachment.py	2006-01-03 14:40:12.000000000 -0600
+++ trac-0.9.5/trac/attachment.py	2006-06-11 12:35:23.000000000 -0500
@@ -318,7 +318,7 @@
                                                     'utf-8')).encode('utf-8')
 
         attachment.description = req.args.get('description', '')
-        attachment.author = req.args.get('author', '')
+        attachment.author = util.get_authentic_id(req, 'author')
         attachment.ipnr = req.remote_addr
         if req.args.get('replace'):
             try:
@@ -376,7 +376,7 @@
         text, link = self._get_parent_link(attachment)
         req.hdf['attachment'] = {
             'mode': 'new',
-            'author': util.get_reporter_id(req),
+            'author': util.get_reporter_id(req, 'author'),
             'parent': {'type': attachment.parent_type,
                        'id': attachment.parent_id, 'name': text, 'href': link}
         }
diff -ru trac-0.9.5.orig/trac/ticket/web_ui.py trac-0.9.5/trac/ticket/web_ui.py
--- trac-0.9.5.orig/trac/ticket/web_ui.py	2006-02-15 12:47:44.000000000 -0600
+++ trac-0.9.5/trac/ticket/web_ui.py	2006-06-11 16:18:04.000000000 -0500
@@ -84,7 +84,7 @@
 
         ticket = Ticket(self.env, db=db)
         ticket.populate(req.args)
-        ticket.values.setdefault('reporter', util.get_reporter_id(req))
+        ticket.values['reporter'] = util.get_reporter_id(req, 'reporter')
 
         if ticket.values.has_key('description'):
             description = wiki_to_html(ticket['description'], self.env, req, db)
@@ -133,8 +133,8 @@
             raise TracError('Tickets must contain a summary.')
 
         ticket = Ticket(self.env, db=db)
-        ticket.values.setdefault('reporter', util.get_reporter_id(req))
         ticket.populate(req.args)
+        ticket.values['reporter'] = util.get_authentic_id(req, 'reporter')
         ticket.insert(db=db)
         db.commit()
 
@@ -182,7 +182,6 @@
         id = int(req.args.get('id'))
 
         ticket = Ticket(self.env, id, db=db)
-        reporter_id = util.get_reporter_id(req)
 
         if req.method == 'POST':
             if not req.args.has_key('preview'):
@@ -195,7 +194,6 @@
                 req.hdf['ticket.reassign_owner'] = req.args.get('reassign_owner') \
                                                    or req.authname
                 req.hdf['ticket.resolve_resolution'] = req.args.get('resolve_resolution')
-                reporter_id = req.args.get('author')
                 comment = req.args.get('comment')
                 if comment:
                     req.hdf['ticket.comment'] = comment
@@ -208,7 +206,8 @@
             # Store a timestamp in order to detect "mid air collisions"
             req.hdf['ticket.ts'] = ticket.time_changed
 
-        self._insert_ticket_data(req, db, ticket, reporter_id)
+        self._insert_ticket_data(req, db, ticket,
+                                 util.get_reporter_id(req, 'author'))
 
         # If the ticket is being shown in the context of a query, add
         # links to help navigate in the query result set
@@ -343,7 +342,7 @@
             ticket['resolution'] = ''
 
         now = int(time.time())
-        ticket.save_changes(req.args.get('author', req.authname),
+        ticket.save_changes(util.get_authentic_id(req, 'author'),
                             req.args.get('comment'), when=now, db=db)
         db.commit()
 
diff -ru trac-0.9.5.orig/trac/util.py trac-0.9.5/trac/util.py
--- trac-0.9.5.orig/trac/util.py	2006-04-05 14:58:58.000000000 -0500
+++ trac-0.9.5/trac/util.py	2006-06-11 17:03:08.000000000 -0500
@@ -381,19 +381,30 @@
                 raise Exception('Failed to create unique name: ' + path)
             path = '%s.%d%s' % (parts[0], idx, parts[1])
 
-def get_reporter_id(req):
-    name = req.session.get('name', None)
-    email = req.session.get('email', None)
-    
+def get_reporter_id(req, argname):
     if req.authname != 'anonymous':
         return req.authname
-    elif name and email:
+
+    r = req.args.get(argname)
+    if r:
+        return r
+    name = req.session.get('name', None)
+    email = req.session.get('email', None)
+    if name and email:
         return '%s <%s>' % (name, email)
     elif not name and email:
         return email
     else:
         return req.authname
 
+def get_authentic_id(req, argname):
+    if req.authname != 'anonymous':
+        return req.authname
+    r = get_reporter_id(req, argname)
+    if r == 'anonymous':
+        return r
+    return r + ' [unauthenticated]'
+
 # Date/time utilities
 
 def format_datetime(t=None, format='%x %X', gmt=False):
diff -ru trac-0.9.5.orig/trac/wiki/web_ui.py trac-0.9.5/trac/wiki/web_ui.py
--- trac-0.9.5.orig/trac/wiki/web_ui.py	2006-01-08 06:38:08.000000000 -0600
+++ trac-0.9.5/trac/wiki/web_ui.py	2006-06-11 12:35:23.000000000 -0500
@@ -26,6 +26,7 @@
 from trac.Search import ISearchSource, query_to_sql, shorten_result
 from trac.Timeline import ITimelineEventProvider
 from trac.util import enum, format_datetime, get_reporter_id, \
+                      get_authentic_id, \
                       pretty_timedelta, shorten_line, Markup
 from trac.versioncontrol.diff import get_diff_options, hdf_diff
 from trac.web.chrome import add_link, add_stylesheet, INavigationContributor
@@ -183,7 +184,7 @@
             # WIKI_ADMIN
             page.readonly = int(req.args.has_key('readonly'))
 
-        page.save(req.args.get('author'), req.args.get('comment'),
+        page.save(get_authentic_id(req, 'author'), req.args.get('comment'),
                   req.remote_addr)
         req.redirect(self.env.href.wiki(page.name))
 
@@ -283,7 +284,7 @@
         if preview:
             page.readonly = req.args.has_key('readonly')
 
-        author = req.args.get('author', get_reporter_id(req))
+        author = get_reporter_id(req, 'author')
         comment = req.args.get('comment', '')
         editrows = req.args.get('editrows')
         if editrows:
