summaryrefslogtreecommitdiff
path: root/src/views/pages/users/individual.php
blob: 2483e6bcdfeb3466f9b23a39550cf38f70089abc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php global $mm, $uid;
// Honestly, the functions in this include should be in this file, but that
// would make this file too messy.
require_once(VIEWPATH.'/pages/users/include.php');

$user = $mm->getAuthObj($uid);

if (!$user->canRead()) {
	include(VIEWPATH.'/pages/users/401.php');
	exit();
}

// Read/Change the username
$username = $user->getName();
if (isset($_POST['auth_name'])) {
	$new_name = $_POST['auth_name'];
	if ($new_name != $username) {
		global $illegal_names;
		if (!in_array($new_name, $illegal_names)) {
			$changed_name = $user->setName($new_name);
			$username = $user->getName();
		}
	}
}

////////////////////////////////////////////////////////////////////////////////

$t = $mm->template();
$mm->header("Users: $username");

$t->tag('h1', array(), ($user->canEdit()?'Edit':'View')." User (UID: $uid)");

if ($user->canEdit()) {
	$t->openTag('form', array('method'=>'post',
	                          'action'=>$mm->baseUrl()."users/$username"));
} else {
	$t->openTag('form');
}

$t->openFieldset("Login / Authentication");
if (isset($changed_name) && !$changed_name) {
	$t->inputP("Error setting username to ".
	           "<q>$new_name</q>. This is probably because".
	           " a user with that name already exists.",
	           true);
}

$t->inputText('auth_name','Username',
              "This is the name you use to log in, but it is also a ".
              "short name that is used in various places, think of it ".
              "as a sort of <q>Twitter name</q>.",
              $username,!$user->canEdit());
if ($user->canEdit()) inputNewPassword($user, 'auth_password','Reset Password');
$t->closeFieldset();

$t->openFieldset("Information");
inputText($user, 'firstname','First Name','');
inputText($user, 'lastname','Last Name','');
inputText($user, 'hsclass','Highschool Class of','Please put the full year (ex: 2012)');
$t->closeFieldset();

$t->openFieldset("Contact");
inputText($user, 'email', 'Email',
          "Right now you can only have one email address, ".
          "but I'm working on making it so you can have ".
          "multiple.");
inputText($user, 'phone', 'Cell Number',
          "A home phone number isn't much use here because it is ".
          "used to text-message you (if you enable it), and ".
          "contact you at competition.");
$t->inputP("When I recieve a message, notify me using the following methods:");
inputArray($user, 'use', array('email'=>'Email',
                               'sms'=>'Text Message'));
$t->closeFieldSet();

$t->openFieldSet('Groups');
$groups = $mm->listGroupNames();
$group_arr = array();
foreach ($groups as $group_name) {
	$group_arr[$group_name] = ucwords($group_name);
}
inputArray($user, 'groups', $group_arr);
$t->closeFieldset();
	
if ($user->canEdit()) {
	$t->tag('input', array('type'=>'submit', 'value'=>'Save'));
}
$t->closeTag('form');
$mm->footer();