function anonymous_publishing_cl_username_alter in Anonymous Publishing 7
Implements hook_username_alter().
File
- modules/
cl/ anonymous_publishing_cl.module, line 338
Code
function anonymous_publishing_cl_username_alter(&$name, $account) {
$aliasopt = variable_get('anonymous_publishing_cl_alias', 0);
if (isset($account->comment_body) || isset($account->body) && $aliasopt && !$account->uid) {
if (isset($account->comment_body) && $account->cid) {
$amail = db_query("SELECT email FROM {anonymous_publishing} WHERE cid = :cid", array(
':cid' => $account->cid,
))
->fetchField();
}
elseif (isset($account->body) && $account->nid) {
$amail = db_query("SELECT email FROM {anonymous_publishing} WHERE nid = :nid", array(
':nid' => $account->nid,
))
->fetchField();
}
else {
$amail = '';
}
$alias = db_query("SELECT alias FROM {anonymous_publishing_emails} WHERE email = :email", array(
':email' => $amail,
))
->fetchField();
if (!empty($alias)) {
$name = $alias;
}
}
}