Is there any easy way to set the default author for a node being edited to the current author if it is currently anonymous? The site I am working on has a lot of Anonymous nodes because it is a migration from a system that didn't have a proper user system.  Users can claim their articles by going in and editing the node and changing the system author, but I'd like that to happen by default whenever someone (preferably someone who is not the administrator) edits a node that has the anonymous author.  I'm sure it must be imminently doable through some form alter or form preprocess hook, but I don't quite get the drupal form system yet.  Solutions and pointers to good sources of information both welcome.

UPDATE I refined this question here: How can I set a default node owner for anonymous nodes on the node edit form?
Option 1 - Adapt node author after editing it

If you have the Rules module enabled, you can simply use a rule that looks like so:

{ "rules_change_anonymous_user_to_current_user" : {
    "LABEL" : "Change anonymous user to current user",
    "PLUGIN" : "reaction rule",
    "ACTIVE" : false,
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_update" : [] },
    "IF" : [
      { "data_is" : { "data" : [ "node-unchanged:author:uid" ], "value" : "0" } },
      { "user_has_role" : {
          "account" : [ "site:current-user" ],
          "roles" : { "value" : { "2" : "2" } }
        }
      },
      { "NOT user_has_role" : {
          "account" : [ "site:current-user" ],
          "roles" : { "value" : { "3" : "3" } }
        }
      }
    ],
    "DO" : [
      { "data_set" : { "data" : [ "node:author" ], "value" : [ "site:current-user" ] } },
      { "drupal_message" : {
          "message" : "Be aware: this was a node with an anonymous author. Since you just edited it, you are now considered as the author of it.",
          "type" : "warning"
        }
      }
    ]
  }
}


After you enable the Rules UI, you should be able to import this rule in your own site.

Just in case it's not clear what this rule does:


Rules Event: after updating existing content.
Rules Conditions:


Author of node being edited has uid=0.
User editing the node is logged in.
User editing the node does NOT have role "administrator".

Rules Actions:


Set node author to current user.
Display a (warning) message like "Be aware: this was a node with an anonymous author. Since you just edited it, you are now considered as the author of it.".



Done! ... with Option 1.

Option 2 - Adapt node author after flagging it (instead of editing it)

As per your requirement like "...whenever someone (preferably someone who is not the administrator) edits a node that has the anonymous author ...") the previous option has a disadvantage I think: the node has to be edited. But what if the node content is actually fine, and does not need any edits at all? Therefor I'd recommend a possible alternative, which you either use together with the previous option, or as a replacement of it. Read on for more details ...

You could also use the Flag module to create a (non-global) flag that are allowed to be used by authenticated users. Let's say you define a flag labeled like "I am the author", with machine name "i_am_the_author". With such flag in place, you can use a variation of the rule from Option 1, which looks like so:

{ "rules_change_anonymous_user_to_flagging_user" : {
    "LABEL" : "Change anonymous user to flagging user",
    "PLUGIN" : "reaction rule",
    "ACTIVE" : false,
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "flag" ],
    "ON" : { "flag_flagged_i_am_the_author" : [] },
    "IF" : [
      { "data_is" : { "data" : [ "flagged-node:author:uid" ], "value" : "0" } },
      { "user_has_role" : {
          "account" : [ "site:current-user" ],
          "roles" : { "value" : { "2" : "2" } }
        }
      },
      { "NOT user_has_role" : {
          "account" : [ "site:current-user" ],
          "roles" : { "value" : { "3" : "3" } }
        }
      }
    ],
    "DO" : [
      { "data_set" : { "data" : [ "flagged-node:author" ], "value" : [ "site:current-user" ] } },
      { "drupal_message" : {
          "message" : "Be aware: this was a node with an anonymous author. Since you just flagged it, you are now considered as the author of it.",
          "type" : "warning"
        }
      }
    ]
  }
}


After you enable the Rules UI, you should be able to import this rule in your own site.

Just in case it's not clear what this rule does:


Rules Event: after a node has been flagged, under "I am the author".
Rules Conditions:


Author of node being flagged has uid=0.
User flagging the node is logged in.
User flagging the node does NOT have role "administrator".

Rules Actions:


Set node author to current user.
Display a (warning) message like "Be aware: this was a node with an anonymous author. Since you just flagged it, you are now considered as the author of it.".



Done! ... with Option 2.

Option 3 - Heading for the golden cradle

If you'd implement Option 2 (using the "I am the author" flag), you could even replace the rule from Option 1 by a variation of it, which is that you simply disallowed edit attempts of nodes that (still) have an anonymous user. Here is a summary of how such rule could look like:


Rules Event : Drupal is initializing.
Rules Condition: Current path is like /node/nid/edit (using a regular expression).
Rules actions:


Perform a redirect (to any path that fits, eg some help page to explain the reason for the direct).
Set a Drupal message to indicate that edits are only allowed by a user who flagged the node first by ... you guessed it ... the "I am the author" flag.



Voilà!

Option 4 - Resolving node author disputes

No matter which solution (option) you'd use, there is always a chance that multiple users might claim to be the node author.

To also take that scenario into consideration, you could create a variation of the rule from Option 2. Some details about such rule:


Replace 1st Rules Condition by "node author of flagged node is NOT uid=0.
Replace both Rules Actions with sending an eMail to (eg) the site administrator, to indicate that some type of conflict about a node author came up (and adapt the message being shown accordingly).


Game over!?!?