Commit 202c4906 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Staff users get extra user fields in view user page

parent 6b6c2f2a
...@@ -3,12 +3,23 @@ ...@@ -3,12 +3,23 @@
{include file="adminmenu.tpl"} {include file="adminmenu.tpl"}
<div class="content"> <div class="content">
<h3>{$NAME}</h3> <h3>{$NAME}</h3>
<table><tbody> <table><tbody>
{foreach from=$PROFILE item=item} {foreach from=$USERFIELDS key=key item=item}
<tr><td>{str section=artefact.internal tag=$item.name}</td><td>{$item.value}</td></tr> <tr><td>{str section=mahara tag=$key}</td><td>{$item}</td></tr>
{/foreach}
</tbody></table>
<table><tbody>
{foreach from=$PROFILE key=key item=item name=profile}
{if $smarty.foreach.profile.first}
<tr><th>{str section=artefact.internal tag=profile}</th></tr>
{/if}
<tr><td>{str section=artefact.internal tag=$key}</td><td>{$item}</td></tr>
{/foreach} {/foreach}
</tbody></table> </tbody></table>
</div> </div>
{include file="footer.tpl"} {include file="footer.tpl"}
...@@ -30,11 +30,22 @@ require(dirname(dirname(__FILE__)).'/init.php'); ...@@ -30,11 +30,22 @@ require(dirname(dirname(__FILE__)).'/init.php');
$userid = param_integer('id',''); $userid = param_integer('id','');
$profile = array(); $profile = array();
$userfields = array();
if (!$user = get_record('usr', 'id', $userid)) { if (!$user = get_record('usr', 'id', $userid)) {
$name = get_string('usernotfound'); $name = get_string('usernotfound');
} }
else { else {
$name = display_name($user); $name = display_name($user);
// If the logged in user is on staff, get full name, institution, id number, email address
if ($USER->get('staff')) {
$userfields['fullname'] = $user->firstname . ' ' . $user->lastname;
$userfields['institution'] = $user->institution;
$userfields['studentid'] = $user->studentid;
$userfields['emailaddress'] = $user->email;
}
// Get public profile fields:
safe_require('artefact', 'internal'); safe_require('artefact', 'internal');
$publicfields = call_static_method(generate_artefact_class_name('profile'),'get_public_fields'); $publicfields = call_static_method(generate_artefact_class_name('profile'),'get_public_fields');
foreach (array_keys($publicfields) as $field) { foreach (array_keys($publicfields) as $field) {
...@@ -43,14 +54,14 @@ else { ...@@ -43,14 +54,14 @@ else {
if ($emails = get_records_array('artefact_internal_profile_email', 'owner', $userid)) { if ($emails = get_records_array('artefact_internal_profile_email', 'owner', $userid)) {
foreach ($emails as $email) { foreach ($emails as $email) {
$fieldname = $email->principal ? 'principalemailaddress' : 'emailaddress'; $fieldname = $email->principal ? 'principalemailaddress' : 'emailaddress';
$profile[] = array('name' => $fieldname, 'value' => $email->email); $profile[$fieldname] = $email->email;
} }
} }
} }
else { else {
$c = new $classname(0, array('owner' => $userid)); // email is different $c = new $classname(0, array('owner' => $userid)); // email is different
if ($value = $c->render(ARTEFACT_FORMAT_LISTITEM, null)) { if ($value = $c->render(ARTEFACT_FORMAT_LISTITEM, null)) {
$profile[] = array('name' => $field, 'value' => $value); $profile[$field] = $value;
} }
} }
} }
...@@ -59,6 +70,7 @@ else { ...@@ -59,6 +70,7 @@ else {
$smarty = smarty(); $smarty = smarty();
$smarty->assign('searchform',searchform()); $smarty->assign('searchform',searchform());
$smarty->assign('NAME',$name); $smarty->assign('NAME',$name);
$smarty->assign('USERFIELDS',$userfields);
$smarty->assign('PROFILE',$profile); $smarty->assign('PROFILE',$profile);
$smarty->display('user/view.tpl'); $smarty->display('user/view.tpl');
......
Supports Markdown
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