You are here

function _views_xml_format_author in Views Datasource 7

Same name and namespace in other branches
  1. 6 views_xml.module \_views_xml_format_author()

Creates an author object to use in the headers of OPML and Atom documents

Parameters

$username:

2 calls to _views_xml_format_author()
template_preprocess_views_views_xml_style_atom in views/theme/views_views_xml_style.theme.inc
Template preprocess for the Atom format
template_preprocess_views_views_xml_style_opml in views/theme/views_views_xml_style.theme.inc

File

./views_xml.module, line 414
Module definition for views_xml

Code

function _views_xml_format_author($username) {
  $author = array();
  $author['uri'] = '';
  $author['email'] = variable_get('site_mail', 'none@none.info');
  if (!$username) {
    $author['name'] = variable_get('anonymous', t('Anonymous'));
    return $author;
  }
  if (is_numeric($username)) {
    $account = user_load($username);
  }
  else {
    $account = user_load_by_name($username);
  }
  $author['name'] = check_plain($username);
  if (!$account) {
    if (is_numeric($username)) {

      // Do not let numeric user name.
      $author['name'] = variable_get('anonymous', t('Anonymous'));
    }
    return $author;
  }
  $author['name'] = check_plain(format_username($account));
  $author['email'] = check_plain($account->mail);
  if (user_access('access user profiles')) {
    $author['uri'] = url('user/' . $account->uid, array(
      'absolute' => TRUE,
    ));
  }
  return $author;
}