From 6dd38ca34fc9c3830ba6ececfe9bfd616a3dba0b Mon Sep 17 00:00:00 2001 From: Joseph Baxter Date: Fri, 23 May 2014 15:43:18 +0100 Subject: [PATCH] tidy up --- export.php | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/export.php b/export.php index a93e29f..f5f61e4 100644 --- a/export.php +++ b/export.php @@ -88,15 +88,14 @@ if ($mform->is_submitted()) { if (isset($formdata->ident['uname'])) { $data->tabhead[] = get_string('username'); } - if (isset($formdata->ident['idnumber'])) { - $data->tabhead[] = get_string('idnumber'); - } - if (isset($formdata->ident['institution'])) { - $data->tabhead[] = get_string('institution'); - } - if (isset($formdata->ident['department'])) { - $data->tabhead[] = get_string('department'); + + $optional = array('idnumber', 'institution', 'department'); + foreach ($optional as $opt) { + if (isset($formdata->ident[$opt])) { + $data->tabhead[] = get_string($opt); + } } + $data->tabhead[] = get_string('lastname'); $data->tabhead[] = get_string('firstname'); $groupmode = groups_get_activity_groupmode($cm, $course); @@ -130,15 +129,14 @@ if ($mform->is_submitted()) { if (isset($formdata->ident['uname'])) { $data->table[$i][] = $user->username; } - if (isset($formdata->ident['idnumber'])) { - $data->table[$i][] = $user->idnumber; - } - if (isset($formdata->ident['institution'])) { - $data->table[$i][] = $user->institution; - } - if (isset($formdata->ident['department'])) { - $data->table[$i][] = $user->department; + + $optional_row = array('idnumber', 'institution', 'department'); + foreach ($$optional_row as $opt) { + if (isset($formdata->ident[$opt])) { + $data->table[$i][] = $user->$opt; + } } + $data->table[$i][] = $user->lastname; $data->table[$i][] = $user->firstname; if (!empty($groupmode)) {