Commit b5433c66 authored by Martyn Smith's avatar Martyn Smith Committed by Martyn Smith
Browse files

Added author to createview

parent 6a4407ec
......@@ -336,10 +336,7 @@ function template_render($template, $mode, $data=array()) {
}
break;
case 'author';
if (isset($data['author'])) {
// @todo get authorformat here
$block .= hsc($data['author']);
}
$block .= template_render_author($data['ownerformat']);
break;
case 'description';
if (isset($data['description'])) {
......@@ -681,4 +678,28 @@ function template_render_artefact_block($blockname, $artefact, $format) {
return $block;
}
function template_render_author($format) {
global $USER;
switch ($format) {
case FORMAT_NAME_FIRSTNAME:
return hsc($USER->get('firstname'));
break;
case FORMAT_NAME_LASTNAME:
return hsc($USER->get('firstname'));
break;
case FORMAT_NAME_FIRSTNAMELASTNAME:
return hsc(full_name());
break;
case FORMAT_NAME_PREFERREDNAME:
return hsc($USER->get('preferredname'));
break;
case FORMAT_NAME_STUDENTID:
return hsc((string)get_field('artefact', 'title', 'owner', $USER->get('id'), 'artefacttype', 'studentid'));
break;
default:
return hsc(display_name($USER));
break;
}
}
?>
......@@ -289,6 +289,16 @@ function display_name($user, $userto=null) {
throw new InvalidArgumentException("Invalid user passed to display_name");
}
if ($user instanceof User) {
$userObj = $user;
$user = new StdClass;
$user->id = $userObj->get('id');
$user->preferredname = $userObj->get('preferredname');
$user->firstname = $userObj->get('firstname');
$user->lastname = $userObj->get('lastname');
$user->admin = $userObj->get('admin');
}
// if they don't have a preferred name set, just return here
if (empty($user->preferredname)) {
return $user->firstname . ' ' . $user->lastname;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment