Commit 326c9f05 authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie
Browse files

Added extra field to setp 1, for configuring how the user wants their name

displayed.
parent 1954cc52
......@@ -25,8 +25,11 @@
*/
define('INTERNAL', 1);
define('MENUITEM', 'myviews');
// define('SUBMENUITEM', 'mygroups');
require(dirname(dirname(__FILE__)) . '/init.php');
require_once('pieforms/pieform.php');
require_once('template.php');
$createid = param_integer('createid', null);
......@@ -39,11 +42,31 @@ if ($createid === null) {
$SESSION->set('createid', $createid + 1);
}
define('MENUITEM', 'myviews');
// define('SUBMENUITEM', 'mygroups');
$data = $SESSION->get('create_' . $createid);
$tmpuser = new StdClass;
$tmpuser->firstname = $USER->get('firstname');
$tmpuser->lastname = $USER->get('lastname');
$tmpuser->preferredname = $USER->get('preferredname');
$formatstring = '%s (%s)';
$ownerformatoptions = array(
FORMAT_NAME_FIRSTNAME => sprintf($formatstring, get_string('firstname'), $USER->get('firstname')),
FORMAT_NAME_LASTNAME => sprintf($formatstring, get_string('lastname'), $USER->get('lastname')),
FORMAT_NAME_FIRSTNAMELASTNAME => sprintf($formatstring, get_string('fullname'), full_name())
);
$preferredname = $USER->get('preferredname');
if ($preferredname !== '') {
$ownerformatoptions[FORMAT_NAME_PREFERREDNAME] = sprintf($formatstring, get_string('preferredname'), $preferredname);
}
$studentid = (string)get_field('artefact', 'title', 'owner', $USER->get('id'), 'artefacttype', 'studentid');
if ($studentid !== '') {
$ownerformatoptions[FORMAT_NAME_STUDENTID] = sprintf($formatstring, get_string('studentid'), $studentid);
}
$ownerformatoptions[FORMAT_NAME_DISPLAYNAME] = sprintf($formatstring, get_string('displayname'), display_name($tmpuser));
$createview1 = pieform(array(
'name' => 'createview1',
'method' => 'post',
......@@ -83,6 +106,14 @@ $createview1 = pieform(array(
'cols' => 80,
'defaultvalue' => isset($data['description']) ? $data['description'] : null,
),
'ownerformat' => array(
'type' => 'select',
'title' => get_string('ownerformat'),
'description' => get_string('ownerformatdescription'),
'options' => $ownerformatoptions,
'defaultvalue' => isset($data['ownerformat']) ? $data['ownerformat'] : FORMAT_NAME_DISPLAYNAME,
'rules' => array('required' => true)
),
'submit' => array(
'type' => 'submitcancel',
'value' => array(get_string('next'), get_string('cancel')),
......@@ -112,6 +143,7 @@ function createview1_submit($values) {
$data['description'] = $values['description'];
$data['startdate'] = $values['startdate'];
$data['stopdate'] = $values['stopdate'];
$data['ownerformat'] = $values['ownerformat'];
$SESSION->set('create_' . $values['createid'], $data);
......
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